cfg80211.h 12 KB

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