cfg80211.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. /*
  2. * Copyright (c) 2010 Broadcom Corporation
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  11. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  13. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef BRCMFMAC_CFG80211_H
  17. #define BRCMFMAC_CFG80211_H
  18. /* for brcmu_d11inf */
  19. #include <brcmu_d11.h>
  20. #include "core.h"
  21. #include "fwil_types.h"
  22. #include "p2p.h"
  23. #define BRCMF_SCAN_IE_LEN_MAX 2048
  24. #define WL_NUM_SCAN_MAX 10
  25. #define WL_TLV_INFO_MAX 1024
  26. #define WL_BSS_INFO_MAX 2048
  27. #define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */
  28. #define WL_EXTRA_BUF_MAX 2048
  29. #define WL_ROAM_TRIGGER_LEVEL -75
  30. #define WL_ROAM_DELTA 20
  31. /* Keep BRCMF_ESCAN_BUF_SIZE below 64K (65536). Allocing over 64K can be
  32. * problematic on some systems and should be avoided.
  33. */
  34. #define BRCMF_ESCAN_BUF_SIZE 65000
  35. #define BRCMF_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */
  36. #define WL_ESCAN_ACTION_START 1
  37. #define WL_ESCAN_ACTION_CONTINUE 2
  38. #define WL_ESCAN_ACTION_ABORT 3
  39. #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
  40. #define IE_MAX_LEN 512
  41. /* IE TLV processing */
  42. #define TLV_LEN_OFF 1 /* length offset */
  43. #define TLV_HDR_LEN 2 /* header length */
  44. #define TLV_BODY_OFF 2 /* body offset */
  45. #define TLV_OUI_LEN 3 /* oui id length */
  46. /* 802.11 Mgmt Packet flags */
  47. #define BRCMF_VNDR_IE_BEACON_FLAG 0x1
  48. #define BRCMF_VNDR_IE_PRBRSP_FLAG 0x2
  49. #define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4
  50. #define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x8
  51. #define BRCMF_VNDR_IE_PRBREQ_FLAG 0x10
  52. #define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20
  53. /* vendor IE in IW advertisement protocol ID field */
  54. #define BRCMF_VNDR_IE_IWAPID_FLAG 0x40
  55. /* allow custom IE id */
  56. #define BRCMF_VNDR_IE_CUSTOM_FLAG 0x100
  57. /* P2P Action Frames flags (spec ordered) */
  58. #define BRCMF_VNDR_IE_GONREQ_FLAG 0x001000
  59. #define BRCMF_VNDR_IE_GONRSP_FLAG 0x002000
  60. #define BRCMF_VNDR_IE_GONCFM_FLAG 0x004000
  61. #define BRCMF_VNDR_IE_INVREQ_FLAG 0x008000
  62. #define BRCMF_VNDR_IE_INVRSP_FLAG 0x010000
  63. #define BRCMF_VNDR_IE_DISREQ_FLAG 0x020000
  64. #define BRCMF_VNDR_IE_DISRSP_FLAG 0x040000
  65. #define BRCMF_VNDR_IE_PRDREQ_FLAG 0x080000
  66. #define BRCMF_VNDR_IE_PRDRSP_FLAG 0x100000
  67. #define BRCMF_VNDR_IE_P2PAF_SHIFT 12
  68. #define BRCMF_MAX_DEFAULT_KEYS 6
  69. /* beacon loss timeout defaults */
  70. #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON 2
  71. #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_OFF 4
  72. #define BRCMF_VIF_EVENT_TIMEOUT msecs_to_jiffies(1500)
  73. /**
  74. * enum brcmf_scan_status - scan engine status
  75. *
  76. * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
  77. * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
  78. * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.
  79. */
  80. enum brcmf_scan_status {
  81. BRCMF_SCAN_STATUS_BUSY,
  82. BRCMF_SCAN_STATUS_ABORT,
  83. BRCMF_SCAN_STATUS_SUPPRESS,
  84. };
  85. /* dongle configuration */
  86. struct brcmf_cfg80211_conf {
  87. u32 frag_threshold;
  88. u32 rts_threshold;
  89. u32 retry_short;
  90. u32 retry_long;
  91. };
  92. /* security information with currently associated ap */
  93. struct brcmf_cfg80211_security {
  94. u32 wpa_versions;
  95. u32 auth_type;
  96. u32 cipher_pairwise;
  97. u32 cipher_group;
  98. };
  99. enum brcmf_profile_fwsup {
  100. BRCMF_PROFILE_FWSUP_NONE,
  101. BRCMF_PROFILE_FWSUP_PSK,
  102. BRCMF_PROFILE_FWSUP_1X
  103. };
  104. /**
  105. * struct brcmf_cfg80211_profile - profile information.
  106. *
  107. * @bssid: bssid of joined/joining ibss.
  108. * @sec: security information.
  109. * @key: key information
  110. */
  111. struct brcmf_cfg80211_profile {
  112. u8 bssid[ETH_ALEN];
  113. struct brcmf_cfg80211_security sec;
  114. struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS];
  115. enum brcmf_profile_fwsup use_fwsup;
  116. };
  117. /**
  118. * enum brcmf_vif_status - bit indices for vif status.
  119. *
  120. * @BRCMF_VIF_STATUS_READY: ready for operation.
  121. * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
  122. * @BRCMF_VIF_STATUS_CONNECTED: connected/joined successfully.
  123. * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
  124. * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
  125. * @BRCMF_VIF_STATUS_EAP_SUCCUSS: EAPOL handshake successful.
  126. * @BRCMF_VIF_STATUS_ASSOC_SUCCESS: successful SET_SSID received.
  127. */
  128. enum brcmf_vif_status {
  129. BRCMF_VIF_STATUS_READY,
  130. BRCMF_VIF_STATUS_CONNECTING,
  131. BRCMF_VIF_STATUS_CONNECTED,
  132. BRCMF_VIF_STATUS_DISCONNECTING,
  133. BRCMF_VIF_STATUS_AP_CREATED,
  134. BRCMF_VIF_STATUS_EAP_SUCCESS,
  135. BRCMF_VIF_STATUS_ASSOC_SUCCESS,
  136. };
  137. /**
  138. * struct vif_saved_ie - holds saved IEs for a virtual interface.
  139. *
  140. * @probe_req_ie: IE info for probe request.
  141. * @probe_res_ie: IE info for probe response.
  142. * @beacon_ie: IE info for beacon frame.
  143. * @probe_req_ie_len: IE info length for probe request.
  144. * @probe_res_ie_len: IE info length for probe response.
  145. * @beacon_ie_len: IE info length for beacon frame.
  146. */
  147. struct vif_saved_ie {
  148. u8 probe_req_ie[IE_MAX_LEN];
  149. u8 probe_res_ie[IE_MAX_LEN];
  150. u8 beacon_ie[IE_MAX_LEN];
  151. u8 assoc_req_ie[IE_MAX_LEN];
  152. u32 probe_req_ie_len;
  153. u32 probe_res_ie_len;
  154. u32 beacon_ie_len;
  155. u32 assoc_req_ie_len;
  156. };
  157. /**
  158. * struct brcmf_cfg80211_vif - virtual interface specific information.
  159. *
  160. * @ifp: lower layer interface pointer
  161. * @wdev: wireless device.
  162. * @profile: profile information.
  163. * @sme_state: SME state using enum brcmf_vif_status bits.
  164. * @list: linked list.
  165. * @mgmt_rx_reg: registered rx mgmt frame types.
  166. * @mbss: Multiple BSS type, set if not first AP (not relevant for P2P).
  167. */
  168. struct brcmf_cfg80211_vif {
  169. struct brcmf_if *ifp;
  170. struct wireless_dev wdev;
  171. struct brcmf_cfg80211_profile profile;
  172. unsigned long sme_state;
  173. struct vif_saved_ie saved_ie;
  174. struct list_head list;
  175. u16 mgmt_rx_reg;
  176. bool mbss;
  177. int is_11d;
  178. };
  179. /* association inform */
  180. struct brcmf_cfg80211_connect_info {
  181. u8 *req_ie;
  182. s32 req_ie_len;
  183. u8 *resp_ie;
  184. s32 resp_ie_len;
  185. };
  186. /* assoc ie length */
  187. struct brcmf_cfg80211_assoc_ielen_le {
  188. __le32 req_len;
  189. __le32 resp_len;
  190. };
  191. /* dongle escan state */
  192. enum wl_escan_state {
  193. WL_ESCAN_STATE_IDLE,
  194. WL_ESCAN_STATE_SCANNING
  195. };
  196. struct escan_info {
  197. u32 escan_state;
  198. u8 *escan_buf;
  199. struct wiphy *wiphy;
  200. struct brcmf_if *ifp;
  201. s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
  202. struct cfg80211_scan_request *request);
  203. };
  204. /**
  205. * struct brcmf_cfg80211_vif_event - virtual interface event information.
  206. *
  207. * @vif_wq: waitqueue awaiting interface event from firmware.
  208. * @vif_event_lock: protects other members in this structure.
  209. * @vif_complete: completion for net attach.
  210. * @action: either add, change, or delete.
  211. * @vif: virtual interface object related to the event.
  212. */
  213. struct brcmf_cfg80211_vif_event {
  214. wait_queue_head_t vif_wq;
  215. spinlock_t vif_event_lock;
  216. u8 action;
  217. struct brcmf_cfg80211_vif *vif;
  218. };
  219. /**
  220. * struct brcmf_cfg80211_wowl - wowl related information.
  221. *
  222. * @active: set on suspend, cleared on resume.
  223. * @pre_pmmode: firmware PM mode at entering suspend.
  224. * @nd: net dectect data.
  225. * @nd_info: helper struct to pass to cfg80211.
  226. * @nd_data_wait: wait queue to sync net detect data.
  227. * @nd_data_completed: completion for net detect data.
  228. * @nd_enabled: net detect enabled.
  229. */
  230. struct brcmf_cfg80211_wowl {
  231. bool active;
  232. u32 pre_pmmode;
  233. struct cfg80211_wowlan_nd_match *nd;
  234. struct cfg80211_wowlan_nd_info *nd_info;
  235. wait_queue_head_t nd_data_wait;
  236. bool nd_data_completed;
  237. bool nd_enabled;
  238. };
  239. /**
  240. * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
  241. *
  242. * @wiphy: wiphy object for cfg80211 interface.
  243. * @ops: pointer to copy of ops as registered with wiphy object.
  244. * @conf: dongle configuration.
  245. * @p2p: peer-to-peer specific information.
  246. * @btcoex: Bluetooth coexistence information.
  247. * @scan_request: cfg80211 scan request object.
  248. * @usr_sync: mainly for dongle up/down synchronization.
  249. * @bss_list: bss_list holding scanned ap information.
  250. * @bss_info: bss information for cfg80211 layer.
  251. * @conn_info: association info.
  252. * @pmk_list: wpa2 pmk list.
  253. * @scan_status: scan activity on the dongle.
  254. * @pub: common driver information.
  255. * @channel: current channel.
  256. * @int_escan_map: bucket map for which internal e-scan is done.
  257. * @ibss_starter: indicates this sta is ibss starter.
  258. * @pwr_save: indicate whether dongle to support power save mode.
  259. * @dongle_up: indicate whether dongle up or not.
  260. * @roam_on: on/off switch for dongle self-roaming.
  261. * @scan_tried: indicates if first scan attempted.
  262. * @dcmd_buf: dcmd buffer.
  263. * @extra_buf: mainly to grab assoc information.
  264. * @debugfsdir: debugfs folder for this device.
  265. * @escan_info: escan information.
  266. * @escan_timeout: Timer for catch scan timeout.
  267. * @escan_timeout_work: scan timeout worker.
  268. * @vif_list: linked list of vif instances.
  269. * @vif_cnt: number of vif instances.
  270. * @vif_event: vif event signalling.
  271. * @wowl: wowl related information.
  272. * @pno: information of pno module.
  273. */
  274. struct brcmf_cfg80211_info {
  275. struct wiphy *wiphy;
  276. struct cfg80211_ops *ops;
  277. struct brcmf_cfg80211_conf *conf;
  278. struct brcmf_p2p_info p2p;
  279. struct brcmf_btcoex_info *btcoex;
  280. struct cfg80211_scan_request *scan_request;
  281. struct mutex usr_sync;
  282. struct wl_cfg80211_bss_info *bss_info;
  283. struct brcmf_cfg80211_connect_info conn_info;
  284. struct brcmf_pmk_list_le pmk_list;
  285. unsigned long scan_status;
  286. struct brcmf_pub *pub;
  287. u32 channel;
  288. u32 int_escan_map;
  289. bool ibss_starter;
  290. bool pwr_save;
  291. bool dongle_up;
  292. bool scan_tried;
  293. u8 *dcmd_buf;
  294. u8 *extra_buf;
  295. struct dentry *debugfsdir;
  296. struct escan_info escan_info;
  297. struct timer_list escan_timeout;
  298. struct work_struct escan_timeout_work;
  299. struct list_head vif_list;
  300. struct brcmf_cfg80211_vif_event vif_event;
  301. struct completion vif_disabled;
  302. struct brcmu_d11inf d11inf;
  303. struct brcmf_assoclist_le assoclist;
  304. struct brcmf_cfg80211_wowl wowl;
  305. struct brcmf_pno_info *pno;
  306. };
  307. /**
  308. * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
  309. *
  310. * @id: tag identifier.
  311. * @len: number of bytes in value buffer.
  312. * @data: value buffer.
  313. */
  314. struct brcmf_tlv {
  315. u8 id;
  316. u8 len;
  317. u8 data[1];
  318. };
  319. static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
  320. {
  321. return cfg->wiphy;
  322. }
  323. static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
  324. {
  325. struct brcmf_pub *drvr = wiphy_priv(w);
  326. return drvr->config;
  327. }
  328. static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
  329. {
  330. return wiphy_to_cfg(wd->wiphy);
  331. }
  332. static inline struct brcmf_cfg80211_vif *wdev_to_vif(struct wireless_dev *wdev)
  333. {
  334. return container_of(wdev, struct brcmf_cfg80211_vif, wdev);
  335. }
  336. static inline
  337. struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
  338. {
  339. return brcmf_get_ifp(cfg->pub, 0)->ndev;
  340. }
  341. static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
  342. {
  343. return wdev_to_cfg(ndev->ieee80211_ptr);
  344. }
  345. static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
  346. {
  347. struct brcmf_if *ifp = netdev_priv(nd);
  348. return &ifp->vif->profile;
  349. }
  350. static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
  351. {
  352. struct brcmf_if *ifp = netdev_priv(ndev);
  353. return ifp->vif;
  354. }
  355. static inline struct
  356. brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
  357. {
  358. return &cfg->conn_info;
  359. }
  360. struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
  361. struct cfg80211_ops *ops,
  362. bool p2pdev_forced);
  363. void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
  364. s32 brcmf_cfg80211_up(struct net_device *ndev);
  365. s32 brcmf_cfg80211_down(struct net_device *ndev);
  366. struct cfg80211_ops *brcmf_cfg80211_get_ops(struct brcmf_mp_device *settings);
  367. enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
  368. struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
  369. enum nl80211_iftype type);
  370. void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
  371. s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
  372. const u8 *vndr_ie_buf, u32 vndr_ie_len);
  373. s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
  374. u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
  375. struct ieee80211_channel *ch);
  376. bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg,
  377. unsigned long state);
  378. void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
  379. struct brcmf_cfg80211_vif *vif);
  380. bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
  381. int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg,
  382. u8 action, ulong timeout);
  383. s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
  384. struct brcmf_if *ifp, bool aborted,
  385. bool fw_abort);
  386. void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
  387. void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
  388. void brcmf_cfg80211_free_netdev(struct net_device *ndev);
  389. #endif /* BRCMFMAC_CFG80211_H */