main.h 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285
  1. /*
  2. * Marvell Wireless LAN device driver: major data structures and prototypes
  3. *
  4. * Copyright (C) 2011-2014, Marvell International Ltd.
  5. *
  6. * This software file (the "File") is distributed by Marvell International
  7. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  8. * (the "License"). You may use, redistribute and/or modify this File in
  9. * accordance with the terms and conditions of the License, a copy of which
  10. * is available by writing to the Free Software Foundation, Inc.,
  11. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
  12. * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  13. *
  14. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  16. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  17. * this warranty disclaimer.
  18. */
  19. #ifndef _MWIFIEX_MAIN_H_
  20. #define _MWIFIEX_MAIN_H_
  21. #include <linux/kernel.h>
  22. #include <linux/module.h>
  23. #include <linux/sched.h>
  24. #include <linux/semaphore.h>
  25. #include <linux/ip.h>
  26. #include <linux/skbuff.h>
  27. #include <linux/if_arp.h>
  28. #include <linux/etherdevice.h>
  29. #include <net/sock.h>
  30. #include <net/lib80211.h>
  31. #include <linux/vmalloc.h>
  32. #include <linux/firmware.h>
  33. #include <linux/ctype.h>
  34. #include <linux/of.h>
  35. #include "decl.h"
  36. #include "ioctl.h"
  37. #include "util.h"
  38. #include "fw.h"
  39. #include "pcie.h"
  40. extern const char driver_version[];
  41. enum {
  42. MWIFIEX_ASYNC_CMD,
  43. MWIFIEX_SYNC_CMD
  44. };
  45. #define MWIFIEX_MAX_AP 64
  46. #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
  47. #define MWIFIEX_TIMER_10S 10000
  48. #define MWIFIEX_TIMER_1S 1000
  49. #define MAX_TX_PENDING 100
  50. #define LOW_TX_PENDING 80
  51. #define MWIFIEX_UPLD_SIZE (2312)
  52. #define MAX_EVENT_SIZE 2048
  53. #define ARP_FILTER_MAX_BUF_SIZE 68
  54. #define MWIFIEX_KEY_BUFFER_SIZE 16
  55. #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
  56. #define MWIFIEX_MAX_REGION_CODE 7
  57. #define DEFAULT_BCN_AVG_FACTOR 8
  58. #define DEFAULT_DATA_AVG_FACTOR 8
  59. #define FIRST_VALID_CHANNEL 0xff
  60. #define DEFAULT_AD_HOC_CHANNEL 6
  61. #define DEFAULT_AD_HOC_CHANNEL_A 36
  62. #define DEFAULT_BCN_MISS_TIMEOUT 5
  63. #define MAX_SCAN_BEACON_BUFFER 8000
  64. #define SCAN_BEACON_ENTRY_PAD 6
  65. #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
  66. #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 30
  67. #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 30
  68. #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI)))
  69. #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
  70. #define MWIFIEX_MAX_SCAN_DELAY_CNT 50
  71. #define MWIFIEX_MAX_EMPTY_TX_Q_CNT 10
  72. #define MWIFIEX_SCAN_DELAY_MSEC 20
  73. #define MWIFIEX_MIN_TX_PENDING_TO_CANCEL_SCAN 2
  74. #define RSN_GTK_OUI_OFFSET 2
  75. #define MWIFIEX_OUI_NOT_PRESENT 0
  76. #define MWIFIEX_OUI_PRESENT 1
  77. #define PKT_TYPE_MGMT 0xE5
  78. /*
  79. * Do not check for data_received for USB, as data_received
  80. * is handled in mwifiex_usb_recv for USB
  81. */
  82. #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
  83. adapter->event_received || \
  84. ((adapter->iface_type != MWIFIEX_USB) && \
  85. adapter->data_received) || \
  86. ((adapter->iface_type == MWIFIEX_USB) && \
  87. !skb_queue_empty(&adapter->usb_rx_data_q)))
  88. #define MWIFIEX_TYPE_CMD 1
  89. #define MWIFIEX_TYPE_DATA 0
  90. #define MWIFIEX_TYPE_EVENT 3
  91. #define MAX_BITMAP_RATES_SIZE 18
  92. #define MAX_CHANNEL_BAND_BG 14
  93. #define MAX_CHANNEL_BAND_A 165
  94. #define MAX_FREQUENCY_BAND_BG 2484
  95. #define MWIFIEX_EVENT_HEADER_LEN 4
  96. #define MWIFIEX_UAP_EVENT_EXTRA_HEADER 2
  97. #define MWIFIEX_TYPE_LEN 4
  98. #define MWIFIEX_USB_TYPE_CMD 0xF00DFACE
  99. #define MWIFIEX_USB_TYPE_DATA 0xBEADC0DE
  100. #define MWIFIEX_USB_TYPE_EVENT 0xBEEFFACE
  101. /* Threshold for tx_timeout_cnt before we trigger a card reset */
  102. #define TX_TIMEOUT_THRESHOLD 6
  103. struct mwifiex_dbg {
  104. u32 num_cmd_host_to_card_failure;
  105. u32 num_cmd_sleep_cfm_host_to_card_failure;
  106. u32 num_tx_host_to_card_failure;
  107. u32 num_event_deauth;
  108. u32 num_event_disassoc;
  109. u32 num_event_link_lost;
  110. u32 num_cmd_deauth;
  111. u32 num_cmd_assoc_success;
  112. u32 num_cmd_assoc_failure;
  113. u32 num_tx_timeout;
  114. u16 timeout_cmd_id;
  115. u16 timeout_cmd_act;
  116. u16 last_cmd_id[DBG_CMD_NUM];
  117. u16 last_cmd_act[DBG_CMD_NUM];
  118. u16 last_cmd_index;
  119. u16 last_cmd_resp_id[DBG_CMD_NUM];
  120. u16 last_cmd_resp_index;
  121. u16 last_event[DBG_CMD_NUM];
  122. u16 last_event_index;
  123. };
  124. enum MWIFIEX_HARDWARE_STATUS {
  125. MWIFIEX_HW_STATUS_READY,
  126. MWIFIEX_HW_STATUS_INITIALIZING,
  127. MWIFIEX_HW_STATUS_FW_READY,
  128. MWIFIEX_HW_STATUS_INIT_DONE,
  129. MWIFIEX_HW_STATUS_RESET,
  130. MWIFIEX_HW_STATUS_CLOSING,
  131. MWIFIEX_HW_STATUS_NOT_READY
  132. };
  133. enum MWIFIEX_802_11_POWER_MODE {
  134. MWIFIEX_802_11_POWER_MODE_CAM,
  135. MWIFIEX_802_11_POWER_MODE_PSP
  136. };
  137. struct mwifiex_tx_param {
  138. u32 next_pkt_len;
  139. };
  140. enum MWIFIEX_PS_STATE {
  141. PS_STATE_AWAKE,
  142. PS_STATE_PRE_SLEEP,
  143. PS_STATE_SLEEP_CFM,
  144. PS_STATE_SLEEP
  145. };
  146. enum mwifiex_iface_type {
  147. MWIFIEX_SDIO,
  148. MWIFIEX_PCIE,
  149. MWIFIEX_USB
  150. };
  151. struct mwifiex_add_ba_param {
  152. u32 tx_win_size;
  153. u32 rx_win_size;
  154. u32 timeout;
  155. u8 tx_amsdu;
  156. u8 rx_amsdu;
  157. };
  158. struct mwifiex_tx_aggr {
  159. u8 ampdu_user;
  160. u8 ampdu_ap;
  161. u8 amsdu;
  162. };
  163. struct mwifiex_ra_list_tbl {
  164. struct list_head list;
  165. struct sk_buff_head skb_head;
  166. u8 ra[ETH_ALEN];
  167. u32 is_11n_enabled;
  168. u16 max_amsdu;
  169. u16 ba_pkt_count;
  170. u8 ba_packet_thr;
  171. u16 total_pkt_count;
  172. bool tdls_link;
  173. };
  174. struct mwifiex_tid_tbl {
  175. struct list_head ra_list;
  176. };
  177. #define WMM_HIGHEST_PRIORITY 7
  178. #define HIGH_PRIO_TID 7
  179. #define LOW_PRIO_TID 0
  180. struct mwifiex_wmm_desc {
  181. struct mwifiex_tid_tbl tid_tbl_ptr[MAX_NUM_TID];
  182. u32 packets_out[MAX_NUM_TID];
  183. /* spin lock to protect ra_list */
  184. spinlock_t ra_list_spinlock;
  185. struct mwifiex_wmm_ac_status ac_status[IEEE80211_NUM_ACS];
  186. enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_NUM_ACS];
  187. u32 drv_pkt_delay_max;
  188. u8 queue_priority[IEEE80211_NUM_ACS];
  189. u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */
  190. /* Number of transmit packets queued */
  191. atomic_t tx_pkts_queued;
  192. /* Tracks highest priority with a packet queued */
  193. atomic_t highest_queued_prio;
  194. };
  195. struct mwifiex_802_11_security {
  196. u8 wpa_enabled;
  197. u8 wpa2_enabled;
  198. u8 wapi_enabled;
  199. u8 wapi_key_on;
  200. u8 wep_enabled;
  201. u32 authentication_mode;
  202. u8 is_authtype_auto;
  203. u32 encryption_mode;
  204. };
  205. struct ieee_types_header {
  206. u8 element_id;
  207. u8 len;
  208. } __packed;
  209. struct ieee_types_vendor_specific {
  210. struct ieee_types_vendor_header vend_hdr;
  211. u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_vendor_header)];
  212. } __packed;
  213. struct ieee_types_generic {
  214. struct ieee_types_header ieee_hdr;
  215. u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)];
  216. } __packed;
  217. struct ieee_types_bss_co_2040 {
  218. struct ieee_types_header ieee_hdr;
  219. u8 bss_2040co;
  220. } __packed;
  221. struct ieee_types_extcap {
  222. struct ieee_types_header ieee_hdr;
  223. u8 ext_capab[8];
  224. } __packed;
  225. struct ieee_types_vht_cap {
  226. struct ieee_types_header ieee_hdr;
  227. struct ieee80211_vht_cap vhtcap;
  228. } __packed;
  229. struct ieee_types_vht_oper {
  230. struct ieee_types_header ieee_hdr;
  231. struct ieee80211_vht_operation vhtoper;
  232. } __packed;
  233. struct ieee_types_aid {
  234. struct ieee_types_header ieee_hdr;
  235. u16 aid;
  236. } __packed;
  237. struct mwifiex_bssdescriptor {
  238. u8 mac_address[ETH_ALEN];
  239. struct cfg80211_ssid ssid;
  240. u32 privacy;
  241. s32 rssi;
  242. u32 channel;
  243. u32 freq;
  244. u16 beacon_period;
  245. u8 erp_flags;
  246. u32 bss_mode;
  247. u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
  248. u8 data_rates[MWIFIEX_SUPPORTED_RATES];
  249. /* Network band.
  250. * BAND_B(0x01): 'b' band
  251. * BAND_G(0x02): 'g' band
  252. * BAND_A(0X04): 'a' band
  253. */
  254. u16 bss_band;
  255. u64 fw_tsf;
  256. u64 timestamp;
  257. union ieee_types_phy_param_set phy_param_set;
  258. union ieee_types_ss_param_set ss_param_set;
  259. u16 cap_info_bitmap;
  260. struct ieee_types_wmm_parameter wmm_ie;
  261. u8 disable_11n;
  262. struct ieee80211_ht_cap *bcn_ht_cap;
  263. u16 ht_cap_offset;
  264. struct ieee80211_ht_operation *bcn_ht_oper;
  265. u16 ht_info_offset;
  266. u8 *bcn_bss_co_2040;
  267. u16 bss_co_2040_offset;
  268. u8 *bcn_ext_cap;
  269. u16 ext_cap_offset;
  270. struct ieee80211_vht_cap *bcn_vht_cap;
  271. u16 vht_cap_offset;
  272. struct ieee80211_vht_operation *bcn_vht_oper;
  273. u16 vht_info_offset;
  274. struct ieee_types_oper_mode_ntf *oper_mode;
  275. u16 oper_mode_offset;
  276. u8 disable_11ac;
  277. struct ieee_types_vendor_specific *bcn_wpa_ie;
  278. u16 wpa_offset;
  279. struct ieee_types_generic *bcn_rsn_ie;
  280. u16 rsn_offset;
  281. struct ieee_types_generic *bcn_wapi_ie;
  282. u16 wapi_offset;
  283. u8 *beacon_buf;
  284. u32 beacon_buf_size;
  285. u8 sensed_11h;
  286. u8 local_constraint;
  287. u8 chan_sw_ie_present;
  288. };
  289. struct mwifiex_current_bss_params {
  290. struct mwifiex_bssdescriptor bss_descriptor;
  291. u8 wmm_enabled;
  292. u8 wmm_uapsd_enabled;
  293. u8 band;
  294. u32 num_of_rates;
  295. u8 data_rates[MWIFIEX_SUPPORTED_RATES];
  296. };
  297. struct mwifiex_sleep_params {
  298. u16 sp_error;
  299. u16 sp_offset;
  300. u16 sp_stable_time;
  301. u8 sp_cal_control;
  302. u8 sp_ext_sleep_clk;
  303. u16 sp_reserved;
  304. };
  305. struct mwifiex_sleep_period {
  306. u16 period;
  307. u16 reserved;
  308. };
  309. struct mwifiex_wep_key {
  310. u32 length;
  311. u32 key_index;
  312. u32 key_length;
  313. u8 key_material[MWIFIEX_KEY_BUFFER_SIZE];
  314. };
  315. #define MAX_REGION_CHANNEL_NUM 2
  316. struct mwifiex_chan_freq_power {
  317. u16 channel;
  318. u32 freq;
  319. u16 max_tx_power;
  320. u8 unsupported;
  321. };
  322. enum state_11d_t {
  323. DISABLE_11D = 0,
  324. ENABLE_11D = 1,
  325. };
  326. #define MWIFIEX_MAX_TRIPLET_802_11D 83
  327. struct mwifiex_802_11d_domain_reg {
  328. u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
  329. u8 no_of_triplet;
  330. struct ieee80211_country_ie_triplet
  331. triplet[MWIFIEX_MAX_TRIPLET_802_11D];
  332. };
  333. struct mwifiex_vendor_spec_cfg_ie {
  334. u16 mask;
  335. u16 flag;
  336. u8 ie[MWIFIEX_MAX_VSIE_LEN];
  337. };
  338. struct wps {
  339. u8 session_enable;
  340. };
  341. struct mwifiex_roc_cfg {
  342. u64 cookie;
  343. struct ieee80211_channel chan;
  344. };
  345. #define MWIFIEX_FW_DUMP_IDX 0xff
  346. #define FW_DUMP_MAX_NAME_LEN 8
  347. #define FW_DUMP_HOST_READY 0xEE
  348. #define FW_DUMP_DONE 0xFF
  349. struct memory_type_mapping {
  350. u8 mem_name[FW_DUMP_MAX_NAME_LEN];
  351. u8 *mem_ptr;
  352. u32 mem_size;
  353. u8 done_flag;
  354. };
  355. enum rdwr_status {
  356. RDWR_STATUS_SUCCESS = 0,
  357. RDWR_STATUS_FAILURE = 1,
  358. RDWR_STATUS_DONE = 2
  359. };
  360. enum mwifiex_iface_work_flags {
  361. MWIFIEX_IFACE_WORK_FW_DUMP,
  362. MWIFIEX_IFACE_WORK_CARD_RESET,
  363. };
  364. struct mwifiex_adapter;
  365. struct mwifiex_private;
  366. struct mwifiex_private {
  367. struct mwifiex_adapter *adapter;
  368. u8 bss_type;
  369. u8 bss_role;
  370. u8 bss_priority;
  371. u8 bss_num;
  372. u8 bss_started;
  373. u8 frame_type;
  374. u8 curr_addr[ETH_ALEN];
  375. u8 media_connected;
  376. u32 num_tx_timeout;
  377. /* track consecutive timeout */
  378. u8 tx_timeout_cnt;
  379. struct net_device *netdev;
  380. struct net_device_stats stats;
  381. u16 curr_pkt_filter;
  382. u32 bss_mode;
  383. u32 pkt_tx_ctrl;
  384. u16 tx_power_level;
  385. u8 max_tx_power_level;
  386. u8 min_tx_power_level;
  387. u8 tx_rate;
  388. u8 tx_htinfo;
  389. u8 rxpd_htinfo;
  390. u8 rxpd_rate;
  391. u16 rate_bitmap;
  392. u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
  393. u32 data_rate;
  394. u8 is_data_rate_auto;
  395. u16 bcn_avg_factor;
  396. u16 data_avg_factor;
  397. s16 data_rssi_last;
  398. s16 data_nf_last;
  399. s16 data_rssi_avg;
  400. s16 data_nf_avg;
  401. s16 bcn_rssi_last;
  402. s16 bcn_nf_last;
  403. s16 bcn_rssi_avg;
  404. s16 bcn_nf_avg;
  405. struct mwifiex_bssdescriptor *attempted_bss_desc;
  406. struct cfg80211_ssid prev_ssid;
  407. u8 prev_bssid[ETH_ALEN];
  408. struct mwifiex_current_bss_params curr_bss_params;
  409. u16 beacon_period;
  410. u8 dtim_period;
  411. u16 listen_interval;
  412. u16 atim_window;
  413. u8 adhoc_channel;
  414. u8 adhoc_is_link_sensed;
  415. u8 adhoc_state;
  416. struct mwifiex_802_11_security sec_info;
  417. struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
  418. u16 wep_key_curr_index;
  419. u8 wpa_ie[256];
  420. u8 wpa_ie_len;
  421. u8 wpa_is_gtk_set;
  422. struct host_cmd_ds_802_11_key_material aes_key;
  423. struct host_cmd_ds_802_11_key_material_v2 aes_key_v2;
  424. u8 wapi_ie[256];
  425. u8 wapi_ie_len;
  426. u8 *wps_ie;
  427. u8 wps_ie_len;
  428. u8 wmm_required;
  429. u8 wmm_enabled;
  430. u8 wmm_qosinfo;
  431. struct mwifiex_wmm_desc wmm;
  432. atomic_t wmm_tx_pending[IEEE80211_NUM_ACS];
  433. struct list_head sta_list;
  434. /* spin lock for associated station list */
  435. spinlock_t sta_list_spinlock;
  436. struct list_head tx_ba_stream_tbl_ptr;
  437. /* spin lock for tx_ba_stream_tbl_ptr queue */
  438. spinlock_t tx_ba_stream_tbl_lock;
  439. struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
  440. struct mwifiex_add_ba_param add_ba_param;
  441. u16 rx_seq[MAX_NUM_TID];
  442. u8 tos_to_tid_inv[MAX_NUM_TID];
  443. struct list_head rx_reorder_tbl_ptr;
  444. /* spin lock for rx_reorder_tbl_ptr queue */
  445. spinlock_t rx_reorder_tbl_lock;
  446. /* spin lock for Rx packets */
  447. spinlock_t rx_pkt_lock;
  448. #define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
  449. u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
  450. u32 assoc_rsp_size;
  451. #define MWIFIEX_GENIE_BUF_SIZE 256
  452. u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
  453. u8 gen_ie_buf_len;
  454. struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
  455. #define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
  456. u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
  457. u8 assoc_tlv_buf_len;
  458. u8 *curr_bcn_buf;
  459. u32 curr_bcn_size;
  460. /* spin lock for beacon buffer */
  461. spinlock_t curr_bcn_buf_lock;
  462. struct wireless_dev *wdev;
  463. struct mwifiex_chan_freq_power cfp;
  464. char version_str[128];
  465. #ifdef CONFIG_DEBUG_FS
  466. struct dentry *dfs_dev_dir;
  467. #endif
  468. u8 nick_name[16];
  469. u16 current_key_index;
  470. struct semaphore async_sem;
  471. u8 report_scan_result;
  472. struct cfg80211_scan_request *scan_request;
  473. u8 cfg_bssid[6];
  474. struct wps wps;
  475. u8 scan_block;
  476. s32 cqm_rssi_thold;
  477. u32 cqm_rssi_hyst;
  478. u8 subsc_evt_rssi_state;
  479. struct mwifiex_ds_misc_subsc_evt async_subsc_evt_storage;
  480. struct mwifiex_ie mgmt_ie[MAX_MGMT_IE_INDEX];
  481. u16 beacon_idx;
  482. u16 proberesp_idx;
  483. u16 assocresp_idx;
  484. u16 rsn_idx;
  485. struct timer_list scan_delay_timer;
  486. u8 ap_11n_enabled;
  487. u8 ap_11ac_enabled;
  488. u32 mgmt_frame_mask;
  489. struct mwifiex_roc_cfg roc_cfg;
  490. bool scan_aborting;
  491. u8 csa_chan;
  492. unsigned long csa_expire_time;
  493. u8 del_list_idx;
  494. bool hs2_enabled;
  495. struct station_parameters *sta_params;
  496. struct sk_buff_head tdls_txq;
  497. };
  498. enum mwifiex_ba_status {
  499. BA_SETUP_NONE = 0,
  500. BA_SETUP_INPROGRESS,
  501. BA_SETUP_COMPLETE
  502. };
  503. struct mwifiex_tx_ba_stream_tbl {
  504. struct list_head list;
  505. int tid;
  506. u8 ra[ETH_ALEN];
  507. enum mwifiex_ba_status ba_status;
  508. u8 amsdu;
  509. };
  510. struct mwifiex_rx_reorder_tbl;
  511. struct reorder_tmr_cnxt {
  512. struct timer_list timer;
  513. struct mwifiex_rx_reorder_tbl *ptr;
  514. struct mwifiex_private *priv;
  515. };
  516. struct mwifiex_rx_reorder_tbl {
  517. struct list_head list;
  518. int tid;
  519. u8 ta[ETH_ALEN];
  520. int init_win;
  521. int start_win;
  522. int win_size;
  523. void **rx_reorder_ptr;
  524. struct reorder_tmr_cnxt timer_context;
  525. u8 amsdu;
  526. u8 flags;
  527. };
  528. struct mwifiex_bss_prio_node {
  529. struct list_head list;
  530. struct mwifiex_private *priv;
  531. };
  532. struct mwifiex_bss_prio_tbl {
  533. struct list_head bss_prio_head;
  534. /* spin lock for bss priority */
  535. spinlock_t bss_prio_lock;
  536. struct mwifiex_bss_prio_node *bss_prio_cur;
  537. };
  538. struct cmd_ctrl_node {
  539. struct list_head list;
  540. struct mwifiex_private *priv;
  541. u32 cmd_oid;
  542. u32 cmd_flag;
  543. struct sk_buff *cmd_skb;
  544. struct sk_buff *resp_skb;
  545. void *data_buf;
  546. u32 wait_q_enabled;
  547. struct sk_buff *skb;
  548. u8 *condition;
  549. u8 cmd_wait_q_woken;
  550. };
  551. struct mwifiex_bss_priv {
  552. u8 band;
  553. u64 fw_tsf;
  554. };
  555. struct mwifiex_tdls_capab {
  556. __le16 capab;
  557. u8 rates[32];
  558. u8 rates_len;
  559. u8 qos_info;
  560. u8 coex_2040;
  561. u16 aid;
  562. struct ieee80211_ht_cap ht_capb;
  563. struct ieee80211_ht_operation ht_oper;
  564. struct ieee_types_extcap extcap;
  565. struct ieee_types_generic rsn_ie;
  566. struct ieee80211_vht_cap vhtcap;
  567. struct ieee80211_vht_operation vhtoper;
  568. };
  569. /* This is AP/TDLS specific structure which stores information
  570. * about associated/peer STA
  571. */
  572. struct mwifiex_sta_node {
  573. struct list_head list;
  574. u8 mac_addr[ETH_ALEN];
  575. u8 is_wmm_enabled;
  576. u8 is_11n_enabled;
  577. u8 is_11ac_enabled;
  578. u8 ampdu_sta[MAX_NUM_TID];
  579. u16 rx_seq[MAX_NUM_TID];
  580. u16 max_amsdu;
  581. u8 tdls_status;
  582. struct mwifiex_tdls_capab tdls_cap;
  583. };
  584. struct mwifiex_if_ops {
  585. int (*init_if) (struct mwifiex_adapter *);
  586. void (*cleanup_if) (struct mwifiex_adapter *);
  587. int (*check_fw_status) (struct mwifiex_adapter *, u32);
  588. int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
  589. int (*register_dev) (struct mwifiex_adapter *);
  590. void (*unregister_dev) (struct mwifiex_adapter *);
  591. int (*enable_int) (struct mwifiex_adapter *);
  592. void (*disable_int) (struct mwifiex_adapter *);
  593. int (*process_int_status) (struct mwifiex_adapter *);
  594. int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *,
  595. struct mwifiex_tx_param *);
  596. int (*wakeup) (struct mwifiex_adapter *);
  597. int (*wakeup_complete) (struct mwifiex_adapter *);
  598. /* Interface specific functions */
  599. void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
  600. void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
  601. int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
  602. int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
  603. int (*data_complete) (struct mwifiex_adapter *);
  604. int (*init_fw_port) (struct mwifiex_adapter *);
  605. int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
  606. void (*card_reset) (struct mwifiex_adapter *);
  607. void (*fw_dump)(struct mwifiex_adapter *);
  608. int (*clean_pcie_ring) (struct mwifiex_adapter *adapter);
  609. void (*iface_work)(struct work_struct *work);
  610. };
  611. struct mwifiex_adapter {
  612. u8 iface_type;
  613. struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
  614. u8 priv_num;
  615. const struct firmware *firmware;
  616. char fw_name[32];
  617. int winner;
  618. struct device *dev;
  619. struct wiphy *wiphy;
  620. bool surprise_removed;
  621. u32 fw_release_number;
  622. u16 init_wait_q_woken;
  623. wait_queue_head_t init_wait_q;
  624. void *card;
  625. struct mwifiex_if_ops if_ops;
  626. atomic_t rx_pending;
  627. atomic_t tx_pending;
  628. atomic_t cmd_pending;
  629. struct workqueue_struct *workqueue;
  630. struct work_struct main_work;
  631. struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
  632. /* spin lock for init/shutdown */
  633. spinlock_t mwifiex_lock;
  634. /* spin lock for main process */
  635. spinlock_t main_proc_lock;
  636. u32 mwifiex_processing;
  637. u16 tx_buf_size;
  638. u16 curr_tx_buf_size;
  639. u32 ioport;
  640. enum MWIFIEX_HARDWARE_STATUS hw_status;
  641. u16 number_of_antenna;
  642. u32 fw_cap_info;
  643. /* spin lock for interrupt handling */
  644. spinlock_t int_lock;
  645. u8 int_status;
  646. u32 event_cause;
  647. struct sk_buff *event_skb;
  648. u8 upld_buf[MWIFIEX_UPLD_SIZE];
  649. u8 data_sent;
  650. u8 cmd_sent;
  651. u8 cmd_resp_received;
  652. u8 event_received;
  653. u8 data_received;
  654. u16 seq_num;
  655. struct cmd_ctrl_node *cmd_pool;
  656. struct cmd_ctrl_node *curr_cmd;
  657. /* spin lock for command */
  658. spinlock_t mwifiex_cmd_lock;
  659. u8 is_cmd_timedout;
  660. u16 last_init_cmd;
  661. struct timer_list cmd_timer;
  662. struct list_head cmd_free_q;
  663. /* spin lock for cmd_free_q */
  664. spinlock_t cmd_free_q_lock;
  665. struct list_head cmd_pending_q;
  666. /* spin lock for cmd_pending_q */
  667. spinlock_t cmd_pending_q_lock;
  668. struct list_head scan_pending_q;
  669. /* spin lock for scan_pending_q */
  670. spinlock_t scan_pending_q_lock;
  671. struct sk_buff_head usb_rx_data_q;
  672. u32 scan_processing;
  673. u16 region_code;
  674. struct mwifiex_802_11d_domain_reg domain_reg;
  675. u16 scan_probes;
  676. u32 scan_mode;
  677. u16 specific_scan_time;
  678. u16 active_scan_time;
  679. u16 passive_scan_time;
  680. u8 fw_bands;
  681. u8 adhoc_start_band;
  682. u8 config_bands;
  683. struct mwifiex_chan_scan_param_set *scan_channels;
  684. u8 tx_lock_flag;
  685. struct mwifiex_sleep_params sleep_params;
  686. struct mwifiex_sleep_period sleep_period;
  687. u16 ps_mode;
  688. u32 ps_state;
  689. u8 need_to_wakeup;
  690. u16 multiple_dtim;
  691. u16 local_listen_interval;
  692. u16 null_pkt_interval;
  693. struct sk_buff *sleep_cfm;
  694. u16 bcn_miss_time_out;
  695. u16 adhoc_awake_period;
  696. u8 is_deep_sleep;
  697. u8 delay_null_pkt;
  698. u16 delay_to_ps;
  699. u16 enhanced_ps_mode;
  700. u8 pm_wakeup_card_req;
  701. u16 gen_null_pkt;
  702. u16 pps_uapsd_mode;
  703. u32 pm_wakeup_fw_try;
  704. u8 is_hs_configured;
  705. struct mwifiex_hs_config_param hs_cfg;
  706. u8 hs_activated;
  707. u16 hs_activate_wait_q_woken;
  708. wait_queue_head_t hs_activate_wait_q;
  709. bool is_suspended;
  710. bool hs_enabling;
  711. u8 event_body[MAX_EVENT_SIZE];
  712. u32 hw_dot_11n_dev_cap;
  713. u8 hw_dev_mcs_support;
  714. u8 user_dev_mcs_support;
  715. u8 adhoc_11n_enabled;
  716. u8 sec_chan_offset;
  717. struct mwifiex_dbg dbg;
  718. u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
  719. u32 arp_filter_size;
  720. struct mwifiex_wait_queue cmd_wait_q;
  721. u8 scan_wait_q_woken;
  722. spinlock_t queue_lock; /* lock for tx queues */
  723. u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
  724. u16 max_mgmt_ie_index;
  725. u8 scan_delay_cnt;
  726. u8 empty_tx_q_cnt;
  727. const struct firmware *cal_data;
  728. struct device_node *dt_node;
  729. /* 11AC */
  730. u32 is_hw_11ac_capable;
  731. u32 hw_dot_11ac_dev_cap;
  732. u32 hw_dot_11ac_mcs_support;
  733. u32 usr_dot_11ac_dev_cap_bg;
  734. u32 usr_dot_11ac_dev_cap_a;
  735. u32 usr_dot_11ac_mcs_support;
  736. atomic_t is_tx_received;
  737. atomic_t pending_bridged_pkts;
  738. struct semaphore *card_sem;
  739. bool ext_scan;
  740. u8 fw_api_ver;
  741. u8 fw_key_api_major_ver, fw_key_api_minor_ver;
  742. struct work_struct iface_work;
  743. unsigned long iface_work_flags;
  744. struct memory_type_mapping *mem_type_mapping_tbl;
  745. u8 num_mem_types;
  746. u8 curr_mem_idx;
  747. };
  748. int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
  749. void mwifiex_set_trans_start(struct net_device *dev);
  750. void mwifiex_stop_net_dev_queue(struct net_device *netdev,
  751. struct mwifiex_adapter *adapter);
  752. void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
  753. struct mwifiex_adapter *adapter);
  754. int mwifiex_init_priv(struct mwifiex_private *priv);
  755. void mwifiex_free_priv(struct mwifiex_private *priv);
  756. int mwifiex_init_fw(struct mwifiex_adapter *adapter);
  757. int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
  758. int mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
  759. int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
  760. int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
  761. int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb);
  762. int mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
  763. struct sk_buff *skb);
  764. int mwifiex_process_event(struct mwifiex_adapter *adapter);
  765. int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
  766. struct cmd_ctrl_node *cmd_node);
  767. int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
  768. u16 cmd_action, u32 cmd_oid, void *data_buf, bool sync);
  769. void mwifiex_cmd_timeout_func(unsigned long function_context);
  770. int mwifiex_get_debug_info(struct mwifiex_private *,
  771. struct mwifiex_debug_info *);
  772. int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
  773. int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
  774. void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
  775. void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
  776. void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
  777. struct cmd_ctrl_node *cmd_node);
  778. void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter,
  779. struct cmd_ctrl_node *cmd_node);
  780. void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
  781. struct cmd_ctrl_node *cmd_node,
  782. u32 addtail);
  783. int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
  784. int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
  785. int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
  786. struct sk_buff *skb);
  787. int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
  788. struct mwifiex_tx_param *tx_param);
  789. int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
  790. int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
  791. struct sk_buff *skb, int aggr, int status);
  792. void mwifiex_clean_txrx(struct mwifiex_private *priv);
  793. u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
  794. void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
  795. void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
  796. u32);
  797. int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
  798. struct host_cmd_ds_command *cmd,
  799. u16 cmd_action, uint16_t ps_bitmap,
  800. struct mwifiex_ds_auto_ds *auto_ds);
  801. int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
  802. struct host_cmd_ds_command *resp,
  803. struct mwifiex_ds_pm_cfg *pm_cfg);
  804. void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
  805. void mwifiex_hs_activated_event(struct mwifiex_private *priv,
  806. u8 activated);
  807. int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
  808. int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg);
  809. int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
  810. struct host_cmd_ds_command *resp);
  811. int mwifiex_process_rx_packet(struct mwifiex_private *priv,
  812. struct sk_buff *skb);
  813. int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
  814. u16 cmd_action, u32 cmd_oid,
  815. void *data_buf, void *cmd_buf);
  816. int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
  817. u16 cmd_action, u32 cmd_oid,
  818. void *data_buf, void *cmd_buf);
  819. int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
  820. struct host_cmd_ds_command *resp);
  821. int mwifiex_process_sta_rx_packet(struct mwifiex_private *,
  822. struct sk_buff *skb);
  823. int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
  824. struct sk_buff *skb);
  825. int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
  826. struct sk_buff *skb);
  827. int mwifiex_process_sta_event(struct mwifiex_private *);
  828. int mwifiex_process_uap_event(struct mwifiex_private *);
  829. void mwifiex_delete_all_station_list(struct mwifiex_private *priv);
  830. void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
  831. void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb);
  832. int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
  833. int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
  834. struct mwifiex_scan_cmd_config *scan_cfg);
  835. void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
  836. struct cmd_ctrl_node *cmd_node);
  837. int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
  838. struct host_cmd_ds_command *resp);
  839. s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
  840. int mwifiex_associate(struct mwifiex_private *priv,
  841. struct mwifiex_bssdescriptor *bss_desc);
  842. int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
  843. struct host_cmd_ds_command *cmd,
  844. struct mwifiex_bssdescriptor *bss_desc);
  845. int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
  846. struct host_cmd_ds_command *resp);
  847. void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason);
  848. u8 mwifiex_band_to_radio_type(u8 band);
  849. int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
  850. void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter);
  851. int mwifiex_adhoc_start(struct mwifiex_private *priv,
  852. struct cfg80211_ssid *adhoc_ssid);
  853. int mwifiex_adhoc_join(struct mwifiex_private *priv,
  854. struct mwifiex_bssdescriptor *bss_desc);
  855. int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
  856. struct host_cmd_ds_command *cmd,
  857. struct cfg80211_ssid *req_ssid);
  858. int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
  859. struct host_cmd_ds_command *cmd,
  860. struct mwifiex_bssdescriptor *bss_desc);
  861. int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
  862. struct host_cmd_ds_command *resp);
  863. int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
  864. struct mwifiex_chan_freq_power *mwifiex_get_cfp(struct mwifiex_private *priv,
  865. u8 band, u16 channel, u32 freq);
  866. u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv,
  867. u8 index, u8 ht_info);
  868. u32 mwifiex_index_to_acs_data_rate(struct mwifiex_private *priv,
  869. u8 index, u8 ht_info);
  870. u32 mwifiex_find_freq_from_band_chan(u8, u8);
  871. int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
  872. u8 **buffer);
  873. u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
  874. u8 *rates);
  875. u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
  876. u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv,
  877. u8 *rates, u8 radio_type);
  878. u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
  879. extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
  880. void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
  881. void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
  882. int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
  883. struct host_cmd_ds_command *cmd);
  884. int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
  885. struct host_cmd_ds_command *resp);
  886. int is_command_pending(struct mwifiex_adapter *adapter);
  887. void mwifiex_init_priv_params(struct mwifiex_private *priv,
  888. struct net_device *dev);
  889. int mwifiex_set_secure_params(struct mwifiex_private *priv,
  890. struct mwifiex_uap_bss_param *bss_config,
  891. struct cfg80211_ap_settings *params);
  892. void mwifiex_set_ht_params(struct mwifiex_private *priv,
  893. struct mwifiex_uap_bss_param *bss_cfg,
  894. struct cfg80211_ap_settings *params);
  895. void mwifiex_set_vht_params(struct mwifiex_private *priv,
  896. struct mwifiex_uap_bss_param *bss_cfg,
  897. struct cfg80211_ap_settings *params);
  898. void mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg,
  899. struct cfg80211_ap_settings *params);
  900. void mwifiex_set_vht_width(struct mwifiex_private *priv,
  901. enum nl80211_chan_width width,
  902. bool ap_11ac_disable);
  903. void
  904. mwifiex_set_wmm_params(struct mwifiex_private *priv,
  905. struct mwifiex_uap_bss_param *bss_cfg,
  906. struct cfg80211_ap_settings *params);
  907. void mwifiex_set_ba_params(struct mwifiex_private *priv);
  908. void mwifiex_set_11ac_ba_params(struct mwifiex_private *priv);
  909. int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
  910. struct host_cmd_ds_command *cmd,
  911. void *data_buf);
  912. int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv);
  913. int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
  914. void *buf);
  915. /*
  916. * This function checks if the queuing is RA based or not.
  917. */
  918. static inline u8
  919. mwifiex_queuing_ra_based(struct mwifiex_private *priv)
  920. {
  921. /*
  922. * Currently we assume if we are in Infra, then DA=RA. This might not be
  923. * true in the future
  924. */
  925. if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
  926. (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
  927. return false;
  928. return true;
  929. }
  930. /*
  931. * This function copies rates.
  932. */
  933. static inline u32
  934. mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
  935. {
  936. int i;
  937. for (i = 0; i < len && src[i]; i++, pos++) {
  938. if (pos >= MWIFIEX_SUPPORTED_RATES)
  939. break;
  940. dest[pos] = src[i];
  941. }
  942. return pos;
  943. }
  944. /*
  945. * This function returns the correct private structure pointer based
  946. * upon the BSS type and BSS number.
  947. */
  948. static inline struct mwifiex_private *
  949. mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
  950. u8 bss_num, u8 bss_type)
  951. {
  952. int i;
  953. for (i = 0; i < adapter->priv_num; i++) {
  954. if (adapter->priv[i]) {
  955. if ((adapter->priv[i]->bss_num == bss_num) &&
  956. (adapter->priv[i]->bss_type == bss_type))
  957. break;
  958. }
  959. }
  960. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  961. }
  962. /*
  963. * This function returns the first available private structure pointer
  964. * based upon the BSS role.
  965. */
  966. static inline struct mwifiex_private *
  967. mwifiex_get_priv(struct mwifiex_adapter *adapter,
  968. enum mwifiex_bss_role bss_role)
  969. {
  970. int i;
  971. for (i = 0; i < adapter->priv_num; i++) {
  972. if (adapter->priv[i]) {
  973. if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
  974. GET_BSS_ROLE(adapter->priv[i]) == bss_role)
  975. break;
  976. }
  977. }
  978. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  979. }
  980. /*
  981. * This function returns the driver private structure of a network device.
  982. */
  983. static inline struct mwifiex_private *
  984. mwifiex_netdev_get_priv(struct net_device *dev)
  985. {
  986. return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
  987. }
  988. /*
  989. * This function checks if a skb holds a management frame.
  990. */
  991. static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
  992. {
  993. return (le32_to_cpu(*(__le32 *)skb->data) == PKT_TYPE_MGMT);
  994. }
  995. /* This function retrieves channel closed for operation by Channel
  996. * Switch Announcement.
  997. */
  998. static inline u8
  999. mwifiex_11h_get_csa_closed_channel(struct mwifiex_private *priv)
  1000. {
  1001. if (!priv->csa_chan)
  1002. return 0;
  1003. /* Clear csa channel, if DFS channel move time has passed */
  1004. if (time_after(jiffies, priv->csa_expire_time)) {
  1005. priv->csa_chan = 0;
  1006. priv->csa_expire_time = 0;
  1007. }
  1008. return priv->csa_chan;
  1009. }
  1010. int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
  1011. u32 func_init_shutdown);
  1012. int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
  1013. int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
  1014. void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
  1015. int maxlen);
  1016. int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
  1017. struct mwifiex_multicast_list *mcast_list);
  1018. int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
  1019. struct net_device *dev);
  1020. int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
  1021. struct cmd_ctrl_node *cmd_queued);
  1022. int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
  1023. struct cfg80211_ssid *req_ssid);
  1024. int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
  1025. int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
  1026. int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
  1027. int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
  1028. int mwifiex_request_scan(struct mwifiex_private *priv,
  1029. struct cfg80211_ssid *req_ssid);
  1030. int mwifiex_scan_networks(struct mwifiex_private *priv,
  1031. const struct mwifiex_user_scan_cfg *user_scan_in);
  1032. int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
  1033. int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
  1034. const u8 *key, int key_len, u8 key_index,
  1035. const u8 *mac_addr, int disable);
  1036. int mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len);
  1037. int mwifiex_get_ver_ext(struct mwifiex_private *priv);
  1038. int mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action,
  1039. struct ieee80211_channel *chan,
  1040. unsigned int duration);
  1041. int mwifiex_set_bss_role(struct mwifiex_private *priv, u8 bss_role);
  1042. int mwifiex_get_stats_info(struct mwifiex_private *priv,
  1043. struct mwifiex_ds_get_stats *log);
  1044. int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
  1045. u32 reg_offset, u32 reg_value);
  1046. int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
  1047. u32 reg_offset, u32 *value);
  1048. int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
  1049. u8 *value);
  1050. int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
  1051. int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
  1052. int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
  1053. int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
  1054. int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
  1055. int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
  1056. char *version, int max_len);
  1057. int mwifiex_set_tx_power(struct mwifiex_private *priv,
  1058. struct mwifiex_power_cfg *power_cfg);
  1059. int mwifiex_main_process(struct mwifiex_adapter *);
  1060. int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb);
  1061. int mwifiex_get_bss_info(struct mwifiex_private *,
  1062. struct mwifiex_bss_info *);
  1063. int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
  1064. struct cfg80211_bss *bss,
  1065. struct mwifiex_bssdescriptor *bss_desc);
  1066. int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
  1067. struct mwifiex_bssdescriptor *bss_entry);
  1068. int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
  1069. struct mwifiex_bssdescriptor *bss_desc);
  1070. u8 mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type);
  1071. struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
  1072. const char *name,
  1073. enum nl80211_iftype type,
  1074. u32 *flags,
  1075. struct vif_params *params);
  1076. int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
  1077. void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config);
  1078. int mwifiex_add_wowlan_magic_pkt_filter(struct mwifiex_adapter *adapter);
  1079. int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
  1080. struct cfg80211_beacon_data *data);
  1081. int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
  1082. u8 *mwifiex_11d_code_2_region(u8 code);
  1083. void mwifiex_uap_del_sta_data(struct mwifiex_private *priv,
  1084. struct mwifiex_sta_node *node);
  1085. void mwifiex_11h_process_join(struct mwifiex_private *priv, u8 **buffer,
  1086. struct mwifiex_bssdescriptor *bss_desc);
  1087. int mwifiex_11h_handle_event_chanswann(struct mwifiex_private *priv);
  1088. int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv,
  1089. struct device_node *node, const char *prefix);
  1090. void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv);
  1091. extern const struct ethtool_ops mwifiex_ethtool_ops;
  1092. void mwifiex_del_all_sta_list(struct mwifiex_private *priv);
  1093. void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac);
  1094. void
  1095. mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies,
  1096. int ies_len, struct mwifiex_sta_node *node);
  1097. struct mwifiex_sta_node *
  1098. mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac);
  1099. struct mwifiex_sta_node *
  1100. mwifiex_get_sta_entry(struct mwifiex_private *priv, const u8 *mac);
  1101. int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
  1102. u8 action_code, u8 dialog_token,
  1103. u16 status_code, const u8 *extra_ies,
  1104. size_t extra_ies_len);
  1105. int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
  1106. u8 action_code, u8 dialog_token,
  1107. u16 status_code, const u8 *extra_ies,
  1108. size_t extra_ies_len);
  1109. void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
  1110. u8 *buf, int len);
  1111. int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action);
  1112. int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac);
  1113. void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
  1114. bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
  1115. u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
  1116. u32 pri_chan, u8 chan_bw);
  1117. #ifdef CONFIG_DEBUG_FS
  1118. void mwifiex_debugfs_init(void);
  1119. void mwifiex_debugfs_remove(void);
  1120. void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
  1121. void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
  1122. #endif
  1123. #endif /* !_MWIFIEX_MAIN_H_ */