cfg80211.h 12 KB

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