main.h 38 KB

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