wl_cfg80211.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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. #include "dhd_dbg.h"
  19. #define WL_INFO(fmt, ...) brcmf_dbg(INFO, fmt, ##__VA_ARGS__)
  20. #define WL_TRACE(fmt, ...) brcmf_dbg(TRACE, fmt, ##__VA_ARGS__)
  21. #define WL_SCAN(fmt, ...) brcmf_dbg(SCAN, fmt, ##__VA_ARGS__)
  22. #define WL_CONN(fmt, ...) brcmf_dbg(CONN, fmt, ##__VA_ARGS__)
  23. #define WL_NUM_SCAN_MAX 10
  24. #define WL_NUM_PMKIDS_MAX MAXPMKID
  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. #define WL_BEACON_TIMEOUT 3
  32. #define WL_SCAN_CHANNEL_TIME 40
  33. #define WL_SCAN_UNASSOC_TIME 40
  34. #define WL_SCAN_PASSIVE_TIME 120
  35. #define WL_ESCAN_BUF_SIZE (1024 * 64)
  36. #define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */
  37. #define WL_ESCAN_ACTION_START 1
  38. #define WL_ESCAN_ACTION_CONTINUE 2
  39. #define WL_ESCAN_ACTION_ABORT 3
  40. #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
  41. #define IE_MAX_LEN 512
  42. /**
  43. * enum brcmf_scan_status - dongle scan status
  44. *
  45. * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
  46. * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
  47. */
  48. enum brcmf_scan_status {
  49. BRCMF_SCAN_STATUS_BUSY,
  50. BRCMF_SCAN_STATUS_ABORT,
  51. };
  52. /* wi-fi mode */
  53. enum wl_mode {
  54. WL_MODE_BSS,
  55. WL_MODE_IBSS,
  56. WL_MODE_AP
  57. };
  58. /* dongle configuration */
  59. struct brcmf_cfg80211_conf {
  60. u32 frag_threshold;
  61. u32 rts_threshold;
  62. u32 retry_short;
  63. u32 retry_long;
  64. s32 tx_power;
  65. struct ieee80211_channel channel;
  66. };
  67. /* basic structure of scan request */
  68. struct brcmf_cfg80211_scan_req {
  69. struct brcmf_ssid_le ssid_le;
  70. };
  71. /* basic structure of information element */
  72. struct brcmf_cfg80211_ie {
  73. u16 offset;
  74. u8 buf[WL_TLV_INFO_MAX];
  75. };
  76. /* security information with currently associated ap */
  77. struct brcmf_cfg80211_security {
  78. u32 wpa_versions;
  79. u32 auth_type;
  80. u32 cipher_pairwise;
  81. u32 cipher_group;
  82. u32 wpa_auth;
  83. };
  84. /**
  85. * struct brcmf_cfg80211_profile - profile information.
  86. *
  87. * @ssid: ssid of associated/associating ap.
  88. * @bssid: bssid of joined/joining ibss.
  89. * @sec: security information.
  90. */
  91. struct brcmf_cfg80211_profile {
  92. struct brcmf_ssid ssid;
  93. u8 bssid[ETH_ALEN];
  94. struct brcmf_cfg80211_security sec;
  95. };
  96. /**
  97. * enum brcmf_vif_status - bit indices for vif status.
  98. *
  99. * @BRCMF_VIF_STATUS_READY: ready for operation.
  100. * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
  101. * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully.
  102. * @BRCMF_VIF_STATUS_AP_CREATING: interface configured for AP operation.
  103. * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
  104. */
  105. enum brcmf_vif_status {
  106. BRCMF_VIF_STATUS_READY,
  107. BRCMF_VIF_STATUS_CONNECTING,
  108. BRCMF_VIF_STATUS_CONNECTED,
  109. BRCMF_VIF_STATUS_AP_CREATING,
  110. BRCMF_VIF_STATUS_AP_CREATED
  111. };
  112. /**
  113. * struct vif_saved_ie - holds saved IEs for a virtual interface.
  114. *
  115. * @probe_res_ie: IE info for probe response.
  116. * @beacon_ie: IE info for beacon frame.
  117. * @probe_res_ie_len: IE info length for probe response.
  118. * @beacon_ie_len: IE info length for beacon frame.
  119. */
  120. struct vif_saved_ie {
  121. u8 probe_res_ie[IE_MAX_LEN];
  122. u8 beacon_ie[IE_MAX_LEN];
  123. u32 probe_res_ie_len;
  124. u32 beacon_ie_len;
  125. };
  126. /**
  127. * struct brcmf_cfg80211_vif - virtual interface specific information.
  128. *
  129. * @ifp: lower layer interface pointer
  130. * @wdev: wireless device.
  131. * @profile: profile information.
  132. * @mode: operating mode.
  133. * @roam_off: roaming state.
  134. * @sme_state: SME state using enum brcmf_vif_status bits.
  135. * @pm_block: power-management blocked.
  136. * @list: linked list.
  137. */
  138. struct brcmf_cfg80211_vif {
  139. struct brcmf_if *ifp;
  140. struct wireless_dev wdev;
  141. struct brcmf_cfg80211_profile profile;
  142. s32 mode;
  143. s32 roam_off;
  144. unsigned long sme_state;
  145. bool pm_block;
  146. struct vif_saved_ie saved_ie;
  147. struct list_head list;
  148. };
  149. /* association inform */
  150. struct brcmf_cfg80211_connect_info {
  151. u8 *req_ie;
  152. s32 req_ie_len;
  153. u8 *resp_ie;
  154. s32 resp_ie_len;
  155. };
  156. /* assoc ie length */
  157. struct brcmf_cfg80211_assoc_ielen_le {
  158. __le32 req_len;
  159. __le32 resp_len;
  160. };
  161. /* wpa2 pmk list */
  162. struct brcmf_cfg80211_pmk_list {
  163. struct pmkid_list pmkids;
  164. struct pmkid foo[MAXPMKID - 1];
  165. };
  166. /* dongle escan state */
  167. enum wl_escan_state {
  168. WL_ESCAN_STATE_IDLE,
  169. WL_ESCAN_STATE_SCANNING
  170. };
  171. struct escan_info {
  172. u32 escan_state;
  173. u8 escan_buf[WL_ESCAN_BUF_SIZE];
  174. struct wiphy *wiphy;
  175. struct net_device *ndev;
  176. };
  177. /**
  178. * struct brcmf_pno_param_le - PNO scan configuration parameters
  179. *
  180. * @version: PNO parameters version.
  181. * @scan_freq: scan frequency.
  182. * @lost_network_timeout: #sec. to declare discovered network as lost.
  183. * @flags: Bit field to control features of PFN such as sort criteria auto
  184. * enable switch and background scan.
  185. * @rssi_margin: Margin to avoid jitter for choosing a PFN based on RSSI sort
  186. * criteria.
  187. * @bestn: number of best networks in each scan.
  188. * @mscan: number of scans recorded.
  189. * @repeat: minimum number of scan intervals before scan frequency changes
  190. * in adaptive scan.
  191. * @exp: exponent of 2 for maximum scan interval.
  192. * @slow_freq: slow scan period.
  193. */
  194. struct brcmf_pno_param_le {
  195. __le32 version;
  196. __le32 scan_freq;
  197. __le32 lost_network_timeout;
  198. __le16 flags;
  199. __le16 rssi_margin;
  200. u8 bestn;
  201. u8 mscan;
  202. u8 repeat;
  203. u8 exp;
  204. __le32 slow_freq;
  205. };
  206. /**
  207. * struct brcmf_pno_net_param_le - scan parameters per preferred network.
  208. *
  209. * @ssid: ssid name and its length.
  210. * @flags: bit2: hidden.
  211. * @infra: BSS vs IBSS.
  212. * @auth: Open vs Closed.
  213. * @wpa_auth: WPA type.
  214. * @wsec: wsec value.
  215. */
  216. struct brcmf_pno_net_param_le {
  217. struct brcmf_ssid_le ssid;
  218. __le32 flags;
  219. __le32 infra;
  220. __le32 auth;
  221. __le32 wpa_auth;
  222. __le32 wsec;
  223. };
  224. /**
  225. * struct brcmf_pno_net_info_le - information per found network.
  226. *
  227. * @bssid: BSS network identifier.
  228. * @channel: channel number only.
  229. * @SSID_len: length of ssid.
  230. * @SSID: ssid characters.
  231. * @RSSI: receive signal strength (in dBm).
  232. * @timestamp: age in seconds.
  233. */
  234. struct brcmf_pno_net_info_le {
  235. u8 bssid[ETH_ALEN];
  236. u8 channel;
  237. u8 SSID_len;
  238. u8 SSID[32];
  239. __le16 RSSI;
  240. __le16 timestamp;
  241. };
  242. /**
  243. * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
  244. *
  245. * @version: PNO version identifier.
  246. * @status: indicates completion status of PNO scan.
  247. * @count: amount of brcmf_pno_net_info_le entries appended.
  248. */
  249. struct brcmf_pno_scanresults_le {
  250. __le32 version;
  251. __le32 status;
  252. __le32 count;
  253. };
  254. /**
  255. * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
  256. *
  257. * @wiphy: wiphy object for cfg80211 interface.
  258. * @conf: dongle configuration.
  259. * @scan_request: cfg80211 scan request object.
  260. * @usr_sync: mainly for dongle up/down synchronization.
  261. * @bss_list: bss_list holding scanned ap information.
  262. * @scan_req_int: internal scan request object.
  263. * @bss_info: bss information for cfg80211 layer.
  264. * @ie: information element object for internal purpose.
  265. * @conn_info: association info.
  266. * @pmk_list: wpa2 pmk list.
  267. * @scan_status: scan activity on the dongle.
  268. * @pub: common driver information.
  269. * @channel: current channel.
  270. * @active_scan: current scan mode.
  271. * @sched_escan: e-scan for scheduled scan support running.
  272. * @ibss_starter: indicates this sta is ibss starter.
  273. * @pwr_save: indicate whether dongle to support power save mode.
  274. * @dongle_up: indicate whether dongle up or not.
  275. * @roam_on: on/off switch for dongle self-roaming.
  276. * @scan_tried: indicates if first scan attempted.
  277. * @dcmd_buf: dcmd buffer.
  278. * @extra_buf: mainly to grab assoc information.
  279. * @debugfsdir: debugfs folder for this device.
  280. * @escan_info: escan information.
  281. * @escan_timeout: Timer for catch scan timeout.
  282. * @escan_timeout_work: scan timeout worker.
  283. * @escan_ioctl_buf: dongle command buffer for escan commands.
  284. * @vif_list: linked list of vif instances.
  285. * @vif_cnt: number of vif instances.
  286. */
  287. struct brcmf_cfg80211_info {
  288. struct wiphy *wiphy;
  289. struct brcmf_cfg80211_conf *conf;
  290. struct cfg80211_scan_request *scan_request;
  291. struct mutex usr_sync;
  292. struct brcmf_scan_results *bss_list;
  293. struct brcmf_cfg80211_scan_req scan_req_int;
  294. struct wl_cfg80211_bss_info *bss_info;
  295. struct brcmf_cfg80211_ie ie;
  296. struct brcmf_cfg80211_connect_info conn_info;
  297. struct brcmf_cfg80211_pmk_list *pmk_list;
  298. unsigned long scan_status;
  299. struct brcmf_pub *pub;
  300. u32 channel;
  301. bool active_scan;
  302. bool sched_escan;
  303. bool ibss_starter;
  304. bool pwr_save;
  305. bool dongle_up;
  306. bool roam_on;
  307. bool scan_tried;
  308. u8 *dcmd_buf;
  309. u8 *extra_buf;
  310. struct dentry *debugfsdir;
  311. struct escan_info escan_info;
  312. struct timer_list escan_timeout;
  313. struct work_struct escan_timeout_work;
  314. u8 *escan_ioctl_buf;
  315. struct list_head vif_list;
  316. u8 vif_cnt;
  317. };
  318. static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
  319. {
  320. return cfg->wiphy;
  321. }
  322. static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
  323. {
  324. return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
  325. }
  326. static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
  327. {
  328. return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
  329. }
  330. static inline
  331. struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
  332. {
  333. struct brcmf_cfg80211_vif *vif;
  334. vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
  335. return vif->wdev.netdev;
  336. }
  337. static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
  338. {
  339. return wdev_to_cfg(ndev->ieee80211_ptr);
  340. }
  341. static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
  342. {
  343. struct brcmf_if *ifp = netdev_priv(nd);
  344. return &ifp->vif->profile;
  345. }
  346. static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
  347. {
  348. struct brcmf_if *ifp = netdev_priv(ndev);
  349. return ifp->vif;
  350. }
  351. static inline struct
  352. brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
  353. {
  354. return &cfg->conn_info;
  355. }
  356. struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
  357. struct device *busdev);
  358. void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
  359. s32 brcmf_cfg80211_up(struct net_device *ndev);
  360. s32 brcmf_cfg80211_down(struct net_device *ndev);
  361. #endif /* _wl_cfg80211_h_ */