/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h

http://github.com/mirrors/linux · C++ Header · 511 lines · 285 code · 46 blank · 180 comment · 0 complexity · cf3977c75960ad68344e4866712e849f MD5 · raw file

  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 _wl_cfg80211_h_
  17. #define _wl_cfg80211_h_
  18. /* for brcmu_d11inf */
  19. #include <brcmu_d11.h>
  20. #define WL_NUM_SCAN_MAX 10
  21. #define WL_NUM_PMKIDS_MAX MAXPMKID
  22. #define WL_TLV_INFO_MAX 1024
  23. #define WL_BSS_INFO_MAX 2048
  24. #define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */
  25. #define WL_EXTRA_BUF_MAX 2048
  26. #define WL_ROAM_TRIGGER_LEVEL -75
  27. #define WL_ROAM_DELTA 20
  28. #define WL_BEACON_TIMEOUT 3
  29. #define WL_SCAN_CHANNEL_TIME 40
  30. #define WL_SCAN_UNASSOC_TIME 40
  31. #define WL_SCAN_PASSIVE_TIME 120
  32. #define WL_ESCAN_BUF_SIZE (1024 * 64)
  33. #define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */
  34. #define WL_ESCAN_ACTION_START 1
  35. #define WL_ESCAN_ACTION_CONTINUE 2
  36. #define WL_ESCAN_ACTION_ABORT 3
  37. #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
  38. #define IE_MAX_LEN 512
  39. /* IE TLV processing */
  40. #define TLV_LEN_OFF 1 /* length offset */
  41. #define TLV_HDR_LEN 2 /* header length */
  42. #define TLV_BODY_OFF 2 /* body offset */
  43. #define TLV_OUI_LEN 3 /* oui id length */
  44. /* 802.11 Mgmt Packet flags */
  45. #define BRCMF_VNDR_IE_BEACON_FLAG 0x1
  46. #define BRCMF_VNDR_IE_PRBRSP_FLAG 0x2
  47. #define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4
  48. #define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x8
  49. #define BRCMF_VNDR_IE_PRBREQ_FLAG 0x10
  50. #define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20
  51. /* vendor IE in IW advertisement protocol ID field */
  52. #define BRCMF_VNDR_IE_IWAPID_FLAG 0x40
  53. /* allow custom IE id */
  54. #define BRCMF_VNDR_IE_CUSTOM_FLAG 0x100
  55. /* P2P Action Frames flags (spec ordered) */
  56. #define BRCMF_VNDR_IE_GONREQ_FLAG 0x001000
  57. #define BRCMF_VNDR_IE_GONRSP_FLAG 0x002000
  58. #define BRCMF_VNDR_IE_GONCFM_FLAG 0x004000
  59. #define BRCMF_VNDR_IE_INVREQ_FLAG 0x008000
  60. #define BRCMF_VNDR_IE_INVRSP_FLAG 0x010000
  61. #define BRCMF_VNDR_IE_DISREQ_FLAG 0x020000
  62. #define BRCMF_VNDR_IE_DISRSP_FLAG 0x040000
  63. #define BRCMF_VNDR_IE_PRDREQ_FLAG 0x080000
  64. #define BRCMF_VNDR_IE_PRDRSP_FLAG 0x100000
  65. #define BRCMF_VNDR_IE_P2PAF_SHIFT 12
  66. /**
  67. * enum brcmf_scan_status - scan engine status
  68. *
  69. * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
  70. * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
  71. * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.
  72. */
  73. enum brcmf_scan_status {
  74. BRCMF_SCAN_STATUS_BUSY,
  75. BRCMF_SCAN_STATUS_ABORT,
  76. BRCMF_SCAN_STATUS_SUPPRESS,
  77. };
  78. /**
  79. * enum wl_mode - driver mode of virtual interface.
  80. *
  81. * @WL_MODE_BSS: connects to BSS.
  82. * @WL_MODE_IBSS: operate as ad-hoc.
  83. * @WL_MODE_AP: operate as access-point.
  84. * @WL_MODE_P2P: provide P2P discovery.
  85. */
  86. enum wl_mode {
  87. WL_MODE_BSS,
  88. WL_MODE_IBSS,
  89. WL_MODE_AP,
  90. WL_MODE_P2P
  91. };
  92. /* dongle configuration */
  93. struct brcmf_cfg80211_conf {
  94. u32 frag_threshold;
  95. u32 rts_threshold;
  96. u32 retry_short;
  97. u32 retry_long;
  98. s32 tx_power;
  99. struct ieee80211_channel channel;
  100. };
  101. /* basic structure of scan request */
  102. struct brcmf_cfg80211_scan_req {
  103. struct brcmf_ssid_le ssid_le;
  104. };
  105. /* basic structure of information element */
  106. struct brcmf_cfg80211_ie {
  107. u16 offset;
  108. u8 buf[WL_TLV_INFO_MAX];
  109. };
  110. /* security information with currently associated ap */
  111. struct brcmf_cfg80211_security {
  112. u32 wpa_versions;
  113. u32 auth_type;
  114. u32 cipher_pairwise;
  115. u32 cipher_group;
  116. u32 wpa_auth;
  117. };
  118. /**
  119. * struct brcmf_cfg80211_profile - profile information.
  120. *
  121. * @ssid: ssid of associated/associating ap.
  122. * @bssid: bssid of joined/joining ibss.
  123. * @sec: security information.
  124. */
  125. struct brcmf_cfg80211_profile {
  126. struct brcmf_ssid ssid;
  127. u8 bssid[ETH_ALEN];
  128. struct brcmf_cfg80211_security sec;
  129. };
  130. /**
  131. * enum brcmf_vif_status - bit indices for vif status.
  132. *
  133. * @BRCMF_VIF_STATUS_READY: ready for operation.
  134. * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
  135. * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully.
  136. * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
  137. * @BRCMF_VIF_STATUS_AP_CREATING: interface configured for AP operation.
  138. * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
  139. */
  140. enum brcmf_vif_status {
  141. BRCMF_VIF_STATUS_READY,
  142. BRCMF_VIF_STATUS_CONNECTING,
  143. BRCMF_VIF_STATUS_CONNECTED,
  144. BRCMF_VIF_STATUS_DISCONNECTING,
  145. BRCMF_VIF_STATUS_AP_CREATING,
  146. BRCMF_VIF_STATUS_AP_CREATED
  147. };
  148. /**
  149. * struct vif_saved_ie - holds saved IEs for a virtual interface.
  150. *
  151. * @probe_req_ie: IE info for probe request.
  152. * @probe_res_ie: IE info for probe response.
  153. * @beacon_ie: IE info for beacon frame.
  154. * @probe_req_ie_len: IE info length for probe request.
  155. * @probe_res_ie_len: IE info length for probe response.
  156. * @beacon_ie_len: IE info length for beacon frame.
  157. */
  158. struct vif_saved_ie {
  159. u8 probe_req_ie[IE_MAX_LEN];
  160. u8 probe_res_ie[IE_MAX_LEN];
  161. u8 beacon_ie[IE_MAX_LEN];
  162. u8 assoc_req_ie[IE_MAX_LEN];
  163. u32 probe_req_ie_len;
  164. u32 probe_res_ie_len;
  165. u32 beacon_ie_len;
  166. u32 assoc_req_ie_len;
  167. };
  168. /**
  169. * struct brcmf_cfg80211_vif - virtual interface specific information.
  170. *
  171. * @ifp: lower layer interface pointer
  172. * @wdev: wireless device.
  173. * @profile: profile information.
  174. * @mode: operating mode.
  175. * @roam_off: roaming state.
  176. * @sme_state: SME state using enum brcmf_vif_status bits.
  177. * @pm_block: power-management blocked.
  178. * @list: linked list.
  179. * @mgmt_rx_reg: registered rx mgmt frame types.
  180. */
  181. struct brcmf_cfg80211_vif {
  182. struct brcmf_if *ifp;
  183. struct wireless_dev wdev;
  184. struct brcmf_cfg80211_profile profile;
  185. s32 mode;
  186. s32 roam_off;
  187. unsigned long sme_state;
  188. bool pm_block;
  189. struct vif_saved_ie saved_ie;
  190. struct list_head list;
  191. u16 mgmt_rx_reg;
  192. };
  193. /* association inform */
  194. struct brcmf_cfg80211_connect_info {
  195. u8 *req_ie;
  196. s32 req_ie_len;
  197. u8 *resp_ie;
  198. s32 resp_ie_len;
  199. };
  200. /* assoc ie length */
  201. struct brcmf_cfg80211_assoc_ielen_le {
  202. __le32 req_len;
  203. __le32 resp_len;
  204. };
  205. /* wpa2 pmk list */
  206. struct brcmf_cfg80211_pmk_list {
  207. struct pmkid_list pmkids;
  208. struct pmkid foo[MAXPMKID - 1];
  209. };
  210. /* dongle escan state */
  211. enum wl_escan_state {
  212. WL_ESCAN_STATE_IDLE,
  213. WL_ESCAN_STATE_SCANNING
  214. };
  215. struct escan_info {
  216. u32 escan_state;
  217. u8 escan_buf[WL_ESCAN_BUF_SIZE];
  218. struct wiphy *wiphy;
  219. struct brcmf_if *ifp;
  220. s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
  221. struct cfg80211_scan_request *request, u16 action);
  222. };
  223. /**
  224. * struct brcmf_pno_param_le - PNO scan configuration parameters
  225. *
  226. * @version: PNO parameters version.
  227. * @scan_freq: scan frequency.
  228. * @lost_network_timeout: #sec. to declare discovered network as lost.
  229. * @flags: Bit field to control features of PFN such as sort criteria auto
  230. * enable switch and background scan.
  231. * @rssi_margin: Margin to avoid jitter for choosing a PFN based on RSSI sort
  232. * criteria.
  233. * @bestn: number of best networks in each scan.
  234. * @mscan: number of scans recorded.
  235. * @repeat: minimum number of scan intervals before scan frequency changes
  236. * in adaptive scan.
  237. * @exp: exponent of 2 for maximum scan interval.
  238. * @slow_freq: slow scan period.
  239. */
  240. struct brcmf_pno_param_le {
  241. __le32 version;
  242. __le32 scan_freq;
  243. __le32 lost_network_timeout;
  244. __le16 flags;
  245. __le16 rssi_margin;
  246. u8 bestn;
  247. u8 mscan;
  248. u8 repeat;
  249. u8 exp;
  250. __le32 slow_freq;
  251. };
  252. /**
  253. * struct brcmf_pno_net_param_le - scan parameters per preferred network.
  254. *
  255. * @ssid: ssid name and its length.
  256. * @flags: bit2: hidden.
  257. * @infra: BSS vs IBSS.
  258. * @auth: Open vs Closed.
  259. * @wpa_auth: WPA type.
  260. * @wsec: wsec value.
  261. */
  262. struct brcmf_pno_net_param_le {
  263. struct brcmf_ssid_le ssid;
  264. __le32 flags;
  265. __le32 infra;
  266. __le32 auth;
  267. __le32 wpa_auth;
  268. __le32 wsec;
  269. };
  270. /**
  271. * struct brcmf_pno_net_info_le - information per found network.
  272. *
  273. * @bssid: BSS network identifier.
  274. * @channel: channel number only.
  275. * @SSID_len: length of ssid.
  276. * @SSID: ssid characters.
  277. * @RSSI: receive signal strength (in dBm).
  278. * @timestamp: age in seconds.
  279. */
  280. struct brcmf_pno_net_info_le {
  281. u8 bssid[ETH_ALEN];
  282. u8 channel;
  283. u8 SSID_len;
  284. u8 SSID[32];
  285. __le16 RSSI;
  286. __le16 timestamp;
  287. };
  288. /**
  289. * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
  290. *
  291. * @version: PNO version identifier.
  292. * @status: indicates completion status of PNO scan.
  293. * @count: amount of brcmf_pno_net_info_le entries appended.
  294. */
  295. struct brcmf_pno_scanresults_le {
  296. __le32 version;
  297. __le32 status;
  298. __le32 count;
  299. };
  300. /**
  301. * struct brcmf_cfg80211_vif_event - virtual interface event information.
  302. *
  303. * @vif_wq: waitqueue awaiting interface event from firmware.
  304. * @vif_event_lock: protects other members in this structure.
  305. * @vif_complete: completion for net attach.
  306. * @action: either add, change, or delete.
  307. * @vif: virtual interface object related to the event.
  308. */
  309. struct brcmf_cfg80211_vif_event {
  310. wait_queue_head_t vif_wq;
  311. struct mutex vif_event_lock;
  312. u8 action;
  313. struct brcmf_cfg80211_vif *vif;
  314. };
  315. /**
  316. * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
  317. *
  318. * @wiphy: wiphy object for cfg80211 interface.
  319. * @conf: dongle configuration.
  320. * @p2p: peer-to-peer specific information.
  321. * @btcoex: Bluetooth coexistence information.
  322. * @scan_request: cfg80211 scan request object.
  323. * @usr_sync: mainly for dongle up/down synchronization.
  324. * @bss_list: bss_list holding scanned ap information.
  325. * @scan_req_int: internal scan request object.
  326. * @bss_info: bss information for cfg80211 layer.
  327. * @ie: information element object for internal purpose.
  328. * @conn_info: association info.
  329. * @pmk_list: wpa2 pmk list.
  330. * @scan_status: scan activity on the dongle.
  331. * @pub: common driver information.
  332. * @channel: current channel.
  333. * @active_scan: current scan mode.
  334. * @sched_escan: e-scan for scheduled scan support running.
  335. * @ibss_starter: indicates this sta is ibss starter.
  336. * @pwr_save: indicate whether dongle to support power save mode.
  337. * @dongle_up: indicate whether dongle up or not.
  338. * @roam_on: on/off switch for dongle self-roaming.
  339. * @scan_tried: indicates if first scan attempted.
  340. * @dcmd_buf: dcmd buffer.
  341. * @extra_buf: mainly to grab assoc information.
  342. * @debugfsdir: debugfs folder for this device.
  343. * @escan_info: escan information.
  344. * @escan_timeout: Timer for catch scan timeout.
  345. * @escan_timeout_work: scan timeout worker.
  346. * @escan_ioctl_buf: dongle command buffer for escan commands.
  347. * @vif_list: linked list of vif instances.
  348. * @vif_cnt: number of vif instances.
  349. * @vif_event: vif event signalling.
  350. */
  351. struct brcmf_cfg80211_info {
  352. struct wiphy *wiphy;
  353. struct brcmf_cfg80211_conf *conf;
  354. struct brcmf_p2p_info p2p;
  355. struct brcmf_btcoex_info *btcoex;
  356. struct cfg80211_scan_request *scan_request;
  357. struct mutex usr_sync;
  358. struct brcmf_scan_results *bss_list;
  359. struct brcmf_cfg80211_scan_req scan_req_int;
  360. struct wl_cfg80211_bss_info *bss_info;
  361. struct brcmf_cfg80211_ie ie;
  362. struct brcmf_cfg80211_connect_info conn_info;
  363. struct brcmf_cfg80211_pmk_list *pmk_list;
  364. unsigned long scan_status;
  365. struct brcmf_pub *pub;
  366. u32 channel;
  367. bool active_scan;
  368. bool sched_escan;
  369. bool ibss_starter;
  370. bool pwr_save;
  371. bool dongle_up;
  372. bool roam_on;
  373. bool scan_tried;
  374. u8 *dcmd_buf;
  375. u8 *extra_buf;
  376. struct dentry *debugfsdir;
  377. struct escan_info escan_info;
  378. struct timer_list escan_timeout;
  379. struct work_struct escan_timeout_work;
  380. u8 *escan_ioctl_buf;
  381. struct list_head vif_list;
  382. u8 vif_cnt;
  383. struct brcmf_cfg80211_vif_event vif_event;
  384. struct completion vif_disabled;
  385. struct brcmu_d11inf d11inf;
  386. };
  387. /**
  388. * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
  389. *
  390. * @id: tag identifier.
  391. * @len: number of bytes in value buffer.
  392. * @data: value buffer.
  393. */
  394. struct brcmf_tlv {
  395. u8 id;
  396. u8 len;
  397. u8 data[1];
  398. };
  399. static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
  400. {
  401. return cfg->wiphy;
  402. }
  403. static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
  404. {
  405. return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
  406. }
  407. static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
  408. {
  409. return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
  410. }
  411. static inline
  412. struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
  413. {
  414. struct brcmf_cfg80211_vif *vif;
  415. vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
  416. return vif->wdev.netdev;
  417. }
  418. static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
  419. {
  420. return wdev_to_cfg(ndev->ieee80211_ptr);
  421. }
  422. static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
  423. {
  424. struct brcmf_if *ifp = netdev_priv(nd);
  425. return &ifp->vif->profile;
  426. }
  427. static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
  428. {
  429. struct brcmf_if *ifp = netdev_priv(ndev);
  430. return ifp->vif;
  431. }
  432. static inline struct
  433. brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
  434. {
  435. return &cfg->conn_info;
  436. }
  437. struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
  438. struct device *busdev);
  439. void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
  440. s32 brcmf_cfg80211_up(struct net_device *ndev);
  441. s32 brcmf_cfg80211_down(struct net_device *ndev);
  442. enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
  443. struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
  444. enum nl80211_iftype type,
  445. bool pm_block);
  446. void brcmf_free_vif(struct brcmf_cfg80211_info *cfg,
  447. struct brcmf_cfg80211_vif *vif);
  448. s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
  449. const u8 *vndr_ie_buf, u32 vndr_ie_len);
  450. s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
  451. struct brcmf_tlv *brcmf_parse_tlvs(void *buf, int buflen, uint key);
  452. u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
  453. struct ieee80211_channel *ch);
  454. u32 wl_get_vif_state_all(struct brcmf_cfg80211_info *cfg, unsigned long state);
  455. void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
  456. struct brcmf_cfg80211_vif *vif);
  457. bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
  458. int brcmf_cfg80211_wait_vif_event_timeout(struct brcmf_cfg80211_info *cfg,
  459. u8 action, ulong timeout);
  460. s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
  461. struct brcmf_if *ifp, bool aborted,
  462. bool fw_abort);
  463. void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
  464. void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
  465. #endif /* _wl_cfg80211_h_ */