wl_cfg80211.h 11 KB

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