main.h 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  1. /*
  2. * Marvell Wireless LAN device driver: major data structures and prototypes
  3. *
  4. * Copyright (C) 2011, 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/firmware.h>
  32. #include <linux/ctype.h>
  33. #include <linux/of.h>
  34. #include "decl.h"
  35. #include "ioctl.h"
  36. #include "util.h"
  37. #include "fw.h"
  38. #include "pcie.h"
  39. extern const char driver_version[];
  40. enum {
  41. MWIFIEX_ASYNC_CMD,
  42. MWIFIEX_SYNC_CMD
  43. };
  44. #define MWIFIEX_MAX_AP 64
  45. #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
  46. #define MWIFIEX_TIMER_10S 10000
  47. #define MWIFIEX_TIMER_1S 1000
  48. #define MAX_TX_PENDING 100
  49. #define LOW_TX_PENDING 80
  50. #define MWIFIEX_UPLD_SIZE (2312)
  51. #define MAX_EVENT_SIZE 2048
  52. #define ARP_FILTER_MAX_BUF_SIZE 68
  53. #define MWIFIEX_KEY_BUFFER_SIZE 16
  54. #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
  55. #define MWIFIEX_MAX_REGION_CODE 7
  56. #define DEFAULT_BCN_AVG_FACTOR 8
  57. #define DEFAULT_DATA_AVG_FACTOR 8
  58. #define FIRST_VALID_CHANNEL 0xff
  59. #define DEFAULT_AD_HOC_CHANNEL 6
  60. #define DEFAULT_AD_HOC_CHANNEL_A 36
  61. #define DEFAULT_BCN_MISS_TIMEOUT 5
  62. #define MAX_SCAN_BEACON_BUFFER 8000
  63. #define SCAN_BEACON_ENTRY_PAD 6
  64. #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
  65. #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 30
  66. #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 30
  67. #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI)))
  68. #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
  69. #define MWIFIEX_MAX_SCAN_DELAY_CNT 50
  70. #define MWIFIEX_MAX_EMPTY_TX_Q_CNT 10
  71. #define MWIFIEX_SCAN_DELAY_MSEC 20
  72. #define MWIFIEX_MIN_TX_PENDING_TO_CANCEL_SCAN 2
  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. struct mwifiex_adapter;
  345. struct mwifiex_private;
  346. struct mwifiex_private {
  347. struct mwifiex_adapter *adapter;
  348. u8 bss_type;
  349. u8 bss_role;
  350. u8 bss_priority;
  351. u8 bss_num;
  352. u8 bss_started;
  353. u8 frame_type;
  354. u8 curr_addr[ETH_ALEN];
  355. u8 media_connected;
  356. u32 num_tx_timeout;
  357. /* track consecutive timeout */
  358. u8 tx_timeout_cnt;
  359. struct net_device *netdev;
  360. struct net_device_stats stats;
  361. u16 curr_pkt_filter;
  362. u32 bss_mode;
  363. u32 pkt_tx_ctrl;
  364. u16 tx_power_level;
  365. u8 max_tx_power_level;
  366. u8 min_tx_power_level;
  367. u8 tx_rate;
  368. u8 tx_htinfo;
  369. u8 rxpd_htinfo;
  370. u8 rxpd_rate;
  371. u16 rate_bitmap;
  372. u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
  373. u32 data_rate;
  374. u8 is_data_rate_auto;
  375. u16 bcn_avg_factor;
  376. u16 data_avg_factor;
  377. s16 data_rssi_last;
  378. s16 data_nf_last;
  379. s16 data_rssi_avg;
  380. s16 data_nf_avg;
  381. s16 bcn_rssi_last;
  382. s16 bcn_nf_last;
  383. s16 bcn_rssi_avg;
  384. s16 bcn_nf_avg;
  385. struct mwifiex_bssdescriptor *attempted_bss_desc;
  386. struct cfg80211_ssid prev_ssid;
  387. u8 prev_bssid[ETH_ALEN];
  388. struct mwifiex_current_bss_params curr_bss_params;
  389. u16 beacon_period;
  390. u8 dtim_period;
  391. u16 listen_interval;
  392. u16 atim_window;
  393. u8 adhoc_channel;
  394. u8 adhoc_is_link_sensed;
  395. u8 adhoc_state;
  396. struct mwifiex_802_11_security sec_info;
  397. struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
  398. u16 wep_key_curr_index;
  399. u8 wpa_ie[256];
  400. u8 wpa_ie_len;
  401. u8 wpa_is_gtk_set;
  402. struct host_cmd_ds_802_11_key_material aes_key;
  403. struct host_cmd_ds_802_11_key_material_v2 aes_key_v2;
  404. u8 wapi_ie[256];
  405. u8 wapi_ie_len;
  406. u8 *wps_ie;
  407. u8 wps_ie_len;
  408. u8 wmm_required;
  409. u8 wmm_enabled;
  410. u8 wmm_qosinfo;
  411. struct mwifiex_wmm_desc wmm;
  412. atomic_t wmm_tx_pending[IEEE80211_NUM_ACS];
  413. struct list_head sta_list;
  414. /* spin lock for associated station list */
  415. spinlock_t sta_list_spinlock;
  416. struct list_head tx_ba_stream_tbl_ptr;
  417. /* spin lock for tx_ba_stream_tbl_ptr queue */
  418. spinlock_t tx_ba_stream_tbl_lock;
  419. struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
  420. struct mwifiex_add_ba_param add_ba_param;
  421. u16 rx_seq[MAX_NUM_TID];
  422. u8 tos_to_tid_inv[MAX_NUM_TID];
  423. struct list_head rx_reorder_tbl_ptr;
  424. /* spin lock for rx_reorder_tbl_ptr queue */
  425. spinlock_t rx_reorder_tbl_lock;
  426. /* spin lock for Rx packets */
  427. spinlock_t rx_pkt_lock;
  428. #define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
  429. u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
  430. u32 assoc_rsp_size;
  431. #define MWIFIEX_GENIE_BUF_SIZE 256
  432. u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
  433. u8 gen_ie_buf_len;
  434. struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
  435. #define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
  436. u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
  437. u8 assoc_tlv_buf_len;
  438. u8 *curr_bcn_buf;
  439. u32 curr_bcn_size;
  440. /* spin lock for beacon buffer */
  441. spinlock_t curr_bcn_buf_lock;
  442. struct wireless_dev *wdev;
  443. struct mwifiex_chan_freq_power cfp;
  444. char version_str[128];
  445. #ifdef CONFIG_DEBUG_FS
  446. struct dentry *dfs_dev_dir;
  447. #endif
  448. u8 nick_name[16];
  449. u16 current_key_index;
  450. struct semaphore async_sem;
  451. u8 report_scan_result;
  452. struct cfg80211_scan_request *scan_request;
  453. u8 cfg_bssid[6];
  454. struct wps wps;
  455. u8 scan_block;
  456. s32 cqm_rssi_thold;
  457. u32 cqm_rssi_hyst;
  458. u8 subsc_evt_rssi_state;
  459. struct mwifiex_ds_misc_subsc_evt async_subsc_evt_storage;
  460. struct mwifiex_ie mgmt_ie[MAX_MGMT_IE_INDEX];
  461. u16 beacon_idx;
  462. u16 proberesp_idx;
  463. u16 assocresp_idx;
  464. u16 rsn_idx;
  465. struct timer_list scan_delay_timer;
  466. u8 ap_11n_enabled;
  467. u8 ap_11ac_enabled;
  468. u32 mgmt_frame_mask;
  469. struct mwifiex_roc_cfg roc_cfg;
  470. bool scan_aborting;
  471. u8 csa_chan;
  472. unsigned long csa_expire_time;
  473. u8 del_list_idx;
  474. bool hs2_enabled;
  475. struct station_parameters *sta_params;
  476. struct sk_buff_head tdls_txq;
  477. };
  478. enum mwifiex_ba_status {
  479. BA_SETUP_NONE = 0,
  480. BA_SETUP_INPROGRESS,
  481. BA_SETUP_COMPLETE
  482. };
  483. struct mwifiex_tx_ba_stream_tbl {
  484. struct list_head list;
  485. int tid;
  486. u8 ra[ETH_ALEN];
  487. enum mwifiex_ba_status ba_status;
  488. u8 amsdu;
  489. };
  490. struct mwifiex_rx_reorder_tbl;
  491. struct reorder_tmr_cnxt {
  492. struct timer_list timer;
  493. struct mwifiex_rx_reorder_tbl *ptr;
  494. struct mwifiex_private *priv;
  495. };
  496. struct mwifiex_rx_reorder_tbl {
  497. struct list_head list;
  498. int tid;
  499. u8 ta[ETH_ALEN];
  500. int init_win;
  501. int start_win;
  502. int win_size;
  503. void **rx_reorder_ptr;
  504. struct reorder_tmr_cnxt timer_context;
  505. u8 amsdu;
  506. u8 flags;
  507. };
  508. struct mwifiex_bss_prio_node {
  509. struct list_head list;
  510. struct mwifiex_private *priv;
  511. };
  512. struct mwifiex_bss_prio_tbl {
  513. struct list_head bss_prio_head;
  514. /* spin lock for bss priority */
  515. spinlock_t bss_prio_lock;
  516. struct mwifiex_bss_prio_node *bss_prio_cur;
  517. };
  518. struct cmd_ctrl_node {
  519. struct list_head list;
  520. struct mwifiex_private *priv;
  521. u32 cmd_oid;
  522. u32 cmd_flag;
  523. struct sk_buff *cmd_skb;
  524. struct sk_buff *resp_skb;
  525. void *data_buf;
  526. u32 wait_q_enabled;
  527. struct sk_buff *skb;
  528. u8 *condition;
  529. u8 cmd_wait_q_woken;
  530. };
  531. struct mwifiex_bss_priv {
  532. u8 band;
  533. u64 fw_tsf;
  534. };
  535. struct mwifiex_tdls_capab {
  536. __le16 capab;
  537. u8 rates[32];
  538. u8 rates_len;
  539. u8 qos_info;
  540. u8 coex_2040;
  541. u16 aid;
  542. struct ieee80211_ht_cap ht_capb;
  543. struct ieee80211_ht_operation ht_oper;
  544. struct ieee_types_extcap extcap;
  545. struct ieee_types_generic rsn_ie;
  546. struct ieee80211_vht_cap vhtcap;
  547. struct ieee80211_vht_operation vhtoper;
  548. };
  549. /* This is AP/TDLS specific structure which stores information
  550. * about associated/peer STA
  551. */
  552. struct mwifiex_sta_node {
  553. struct list_head list;
  554. u8 mac_addr[ETH_ALEN];
  555. u8 is_wmm_enabled;
  556. u8 is_11n_enabled;
  557. u8 is_11ac_enabled;
  558. u8 ampdu_sta[MAX_NUM_TID];
  559. u16 rx_seq[MAX_NUM_TID];
  560. u16 max_amsdu;
  561. u8 tdls_status;
  562. struct mwifiex_tdls_capab tdls_cap;
  563. };
  564. struct mwifiex_if_ops {
  565. int (*init_if) (struct mwifiex_adapter *);
  566. void (*cleanup_if) (struct mwifiex_adapter *);
  567. int (*check_fw_status) (struct mwifiex_adapter *, u32);
  568. int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
  569. int (*register_dev) (struct mwifiex_adapter *);
  570. void (*unregister_dev) (struct mwifiex_adapter *);
  571. int (*enable_int) (struct mwifiex_adapter *);
  572. void (*disable_int) (struct mwifiex_adapter *);
  573. int (*process_int_status) (struct mwifiex_adapter *);
  574. int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *,
  575. struct mwifiex_tx_param *);
  576. int (*wakeup) (struct mwifiex_adapter *);
  577. int (*wakeup_complete) (struct mwifiex_adapter *);
  578. /* Interface specific functions */
  579. void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
  580. void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
  581. int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
  582. int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
  583. int (*data_complete) (struct mwifiex_adapter *);
  584. int (*init_fw_port) (struct mwifiex_adapter *);
  585. int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
  586. void (*card_reset) (struct mwifiex_adapter *);
  587. void (*fw_dump)(struct mwifiex_adapter *);
  588. int (*clean_pcie_ring) (struct mwifiex_adapter *adapter);
  589. };
  590. struct mwifiex_adapter {
  591. u8 iface_type;
  592. struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
  593. u8 priv_num;
  594. const struct firmware *firmware;
  595. char fw_name[32];
  596. int winner;
  597. struct device *dev;
  598. struct wiphy *wiphy;
  599. bool surprise_removed;
  600. u32 fw_release_number;
  601. u16 init_wait_q_woken;
  602. wait_queue_head_t init_wait_q;
  603. void *card;
  604. struct mwifiex_if_ops if_ops;
  605. atomic_t rx_pending;
  606. atomic_t tx_pending;
  607. atomic_t cmd_pending;
  608. struct workqueue_struct *workqueue;
  609. struct work_struct main_work;
  610. struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
  611. /* spin lock for init/shutdown */
  612. spinlock_t mwifiex_lock;
  613. /* spin lock for main process */
  614. spinlock_t main_proc_lock;
  615. u32 mwifiex_processing;
  616. u16 tx_buf_size;
  617. u16 curr_tx_buf_size;
  618. u32 ioport;
  619. enum MWIFIEX_HARDWARE_STATUS hw_status;
  620. u16 number_of_antenna;
  621. u32 fw_cap_info;
  622. /* spin lock for interrupt handling */
  623. spinlock_t int_lock;
  624. u8 int_status;
  625. u32 event_cause;
  626. struct sk_buff *event_skb;
  627. u8 upld_buf[MWIFIEX_UPLD_SIZE];
  628. u8 data_sent;
  629. u8 cmd_sent;
  630. u8 cmd_resp_received;
  631. u8 event_received;
  632. u8 data_received;
  633. u16 seq_num;
  634. struct cmd_ctrl_node *cmd_pool;
  635. struct cmd_ctrl_node *curr_cmd;
  636. /* spin lock for command */
  637. spinlock_t mwifiex_cmd_lock;
  638. u8 is_cmd_timedout;
  639. u16 last_init_cmd;
  640. struct timer_list cmd_timer;
  641. struct list_head cmd_free_q;
  642. /* spin lock for cmd_free_q */
  643. spinlock_t cmd_free_q_lock;
  644. struct list_head cmd_pending_q;
  645. /* spin lock for cmd_pending_q */
  646. spinlock_t cmd_pending_q_lock;
  647. struct list_head scan_pending_q;
  648. /* spin lock for scan_pending_q */
  649. spinlock_t scan_pending_q_lock;
  650. struct sk_buff_head usb_rx_data_q;
  651. u32 scan_processing;
  652. u16 region_code;
  653. struct mwifiex_802_11d_domain_reg domain_reg;
  654. u16 scan_probes;
  655. u32 scan_mode;
  656. u16 specific_scan_time;
  657. u16 active_scan_time;
  658. u16 passive_scan_time;
  659. u8 fw_bands;
  660. u8 adhoc_start_band;
  661. u8 config_bands;
  662. struct mwifiex_chan_scan_param_set *scan_channels;
  663. u8 tx_lock_flag;
  664. struct mwifiex_sleep_params sleep_params;
  665. struct mwifiex_sleep_period sleep_period;
  666. u16 ps_mode;
  667. u32 ps_state;
  668. u8 need_to_wakeup;
  669. u16 multiple_dtim;
  670. u16 local_listen_interval;
  671. u16 null_pkt_interval;
  672. struct sk_buff *sleep_cfm;
  673. u16 bcn_miss_time_out;
  674. u16 adhoc_awake_period;
  675. u8 is_deep_sleep;
  676. u8 delay_null_pkt;
  677. u16 delay_to_ps;
  678. u16 enhanced_ps_mode;
  679. u8 pm_wakeup_card_req;
  680. u16 gen_null_pkt;
  681. u16 pps_uapsd_mode;
  682. u32 pm_wakeup_fw_try;
  683. u8 is_hs_configured;
  684. struct mwifiex_hs_config_param hs_cfg;
  685. u8 hs_activated;
  686. u16 hs_activate_wait_q_woken;
  687. wait_queue_head_t hs_activate_wait_q;
  688. bool is_suspended;
  689. bool hs_enabling;
  690. u8 event_body[MAX_EVENT_SIZE];
  691. u32 hw_dot_11n_dev_cap;
  692. u8 hw_dev_mcs_support;
  693. u8 user_dev_mcs_support;
  694. u8 adhoc_11n_enabled;
  695. u8 sec_chan_offset;
  696. struct mwifiex_dbg dbg;
  697. u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
  698. u32 arp_filter_size;
  699. struct mwifiex_wait_queue cmd_wait_q;
  700. u8 scan_wait_q_woken;
  701. spinlock_t queue_lock; /* lock for tx queues */
  702. u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
  703. u16 max_mgmt_ie_index;
  704. u8 scan_delay_cnt;
  705. u8 empty_tx_q_cnt;
  706. const struct firmware *cal_data;
  707. struct device_node *dt_node;
  708. /* 11AC */
  709. u32 is_hw_11ac_capable;
  710. u32 hw_dot_11ac_dev_cap;
  711. u32 hw_dot_11ac_mcs_support;
  712. u32 usr_dot_11ac_dev_cap_bg;
  713. u32 usr_dot_11ac_dev_cap_a;
  714. u32 usr_dot_11ac_mcs_support;
  715. atomic_t is_tx_received;
  716. atomic_t pending_bridged_pkts;
  717. struct semaphore *card_sem;
  718. bool ext_scan;
  719. u8 fw_api_ver;
  720. u8 fw_key_api_major_ver, fw_key_api_minor_ver;
  721. };
  722. int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
  723. void mwifiex_set_trans_start(struct net_device *dev);
  724. void mwifiex_stop_net_dev_queue(struct net_device *netdev,
  725. struct mwifiex_adapter *adapter);
  726. void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
  727. struct mwifiex_adapter *adapter);
  728. int mwifiex_init_priv(struct mwifiex_private *priv);
  729. void mwifiex_free_priv(struct mwifiex_private *priv);
  730. int mwifiex_init_fw(struct mwifiex_adapter *adapter);
  731. int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
  732. int mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
  733. int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
  734. int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
  735. int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb);
  736. int mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
  737. struct sk_buff *skb);
  738. int mwifiex_process_event(struct mwifiex_adapter *adapter);
  739. int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
  740. struct cmd_ctrl_node *cmd_node);
  741. int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
  742. u16 cmd_action, u32 cmd_oid, void *data_buf, bool sync);
  743. void mwifiex_cmd_timeout_func(unsigned long function_context);
  744. int mwifiex_get_debug_info(struct mwifiex_private *,
  745. struct mwifiex_debug_info *);
  746. int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
  747. int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
  748. void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
  749. void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
  750. void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
  751. struct cmd_ctrl_node *cmd_node);
  752. void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter,
  753. struct cmd_ctrl_node *cmd_node);
  754. void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
  755. struct cmd_ctrl_node *cmd_node,
  756. u32 addtail);
  757. int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
  758. int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
  759. int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
  760. struct sk_buff *skb);
  761. int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
  762. struct mwifiex_tx_param *tx_param);
  763. int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
  764. int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
  765. struct sk_buff *skb, int aggr, int status);
  766. void mwifiex_clean_txrx(struct mwifiex_private *priv);
  767. u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
  768. void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
  769. void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
  770. u32);
  771. int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
  772. struct host_cmd_ds_command *cmd,
  773. u16 cmd_action, uint16_t ps_bitmap,
  774. struct mwifiex_ds_auto_ds *auto_ds);
  775. int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
  776. struct host_cmd_ds_command *resp,
  777. struct mwifiex_ds_pm_cfg *pm_cfg);
  778. void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
  779. void mwifiex_hs_activated_event(struct mwifiex_private *priv,
  780. u8 activated);
  781. int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
  782. struct host_cmd_ds_command *resp);
  783. int mwifiex_process_rx_packet(struct mwifiex_private *priv,
  784. struct sk_buff *skb);
  785. int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
  786. u16 cmd_action, u32 cmd_oid,
  787. void *data_buf, void *cmd_buf);
  788. int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
  789. u16 cmd_action, u32 cmd_oid,
  790. void *data_buf, void *cmd_buf);
  791. int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
  792. struct host_cmd_ds_command *resp);
  793. int mwifiex_process_sta_rx_packet(struct mwifiex_private *,
  794. struct sk_buff *skb);
  795. int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
  796. struct sk_buff *skb);
  797. int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
  798. struct sk_buff *skb);
  799. int mwifiex_process_sta_event(struct mwifiex_private *);
  800. int mwifiex_process_uap_event(struct mwifiex_private *);
  801. void mwifiex_delete_all_station_list(struct mwifiex_private *priv);
  802. void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
  803. void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb);
  804. int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
  805. int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
  806. struct mwifiex_scan_cmd_config *scan_cfg);
  807. void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
  808. struct cmd_ctrl_node *cmd_node);
  809. int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
  810. struct host_cmd_ds_command *resp);
  811. s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
  812. int mwifiex_associate(struct mwifiex_private *priv,
  813. struct mwifiex_bssdescriptor *bss_desc);
  814. int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
  815. struct host_cmd_ds_command *cmd,
  816. struct mwifiex_bssdescriptor *bss_desc);
  817. int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
  818. struct host_cmd_ds_command *resp);
  819. void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason);
  820. u8 mwifiex_band_to_radio_type(u8 band);
  821. int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
  822. void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter);
  823. int mwifiex_adhoc_start(struct mwifiex_private *priv,
  824. struct cfg80211_ssid *adhoc_ssid);
  825. int mwifiex_adhoc_join(struct mwifiex_private *priv,
  826. struct mwifiex_bssdescriptor *bss_desc);
  827. int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
  828. struct host_cmd_ds_command *cmd,
  829. struct cfg80211_ssid *req_ssid);
  830. int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
  831. struct host_cmd_ds_command *cmd,
  832. struct mwifiex_bssdescriptor *bss_desc);
  833. int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
  834. struct host_cmd_ds_command *resp);
  835. int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
  836. struct mwifiex_chan_freq_power *mwifiex_get_cfp(struct mwifiex_private *priv,
  837. u8 band, u16 channel, u32 freq);
  838. u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv,
  839. u8 index, u8 ht_info);
  840. u32 mwifiex_index_to_acs_data_rate(struct mwifiex_private *priv,
  841. u8 index, u8 ht_info);
  842. u32 mwifiex_find_freq_from_band_chan(u8, u8);
  843. int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
  844. u8 **buffer);
  845. u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
  846. u8 *rates);
  847. u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
  848. u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv,
  849. u8 *rates, u8 radio_type);
  850. u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
  851. extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
  852. void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
  853. void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
  854. int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
  855. struct host_cmd_ds_command *cmd);
  856. int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
  857. struct host_cmd_ds_command *resp);
  858. int is_command_pending(struct mwifiex_adapter *adapter);
  859. void mwifiex_init_priv_params(struct mwifiex_private *priv,
  860. struct net_device *dev);
  861. int mwifiex_set_secure_params(struct mwifiex_private *priv,
  862. struct mwifiex_uap_bss_param *bss_config,
  863. struct cfg80211_ap_settings *params);
  864. void mwifiex_set_ht_params(struct mwifiex_private *priv,
  865. struct mwifiex_uap_bss_param *bss_cfg,
  866. struct cfg80211_ap_settings *params);
  867. void mwifiex_set_vht_params(struct mwifiex_private *priv,
  868. struct mwifiex_uap_bss_param *bss_cfg,
  869. struct cfg80211_ap_settings *params);
  870. void mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg,
  871. struct cfg80211_ap_settings *params);
  872. void mwifiex_set_vht_width(struct mwifiex_private *priv,
  873. enum nl80211_chan_width width,
  874. bool ap_11ac_disable);
  875. void
  876. mwifiex_set_wmm_params(struct mwifiex_private *priv,
  877. struct mwifiex_uap_bss_param *bss_cfg,
  878. struct cfg80211_ap_settings *params);
  879. void mwifiex_set_ba_params(struct mwifiex_private *priv);
  880. void mwifiex_set_11ac_ba_params(struct mwifiex_private *priv);
  881. int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
  882. struct host_cmd_ds_command *cmd,
  883. void *data_buf);
  884. int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv);
  885. int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
  886. void *buf);
  887. /*
  888. * This function checks if the queuing is RA based or not.
  889. */
  890. static inline u8
  891. mwifiex_queuing_ra_based(struct mwifiex_private *priv)
  892. {
  893. /*
  894. * Currently we assume if we are in Infra, then DA=RA. This might not be
  895. * true in the future
  896. */
  897. if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
  898. (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
  899. return false;
  900. return true;
  901. }
  902. /*
  903. * This function copies rates.
  904. */
  905. static inline u32
  906. mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
  907. {
  908. int i;
  909. for (i = 0; i < len && src[i]; i++, pos++) {
  910. if (pos >= MWIFIEX_SUPPORTED_RATES)
  911. break;
  912. dest[pos] = src[i];
  913. }
  914. return pos;
  915. }
  916. /*
  917. * This function returns the correct private structure pointer based
  918. * upon the BSS type and BSS number.
  919. */
  920. static inline struct mwifiex_private *
  921. mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
  922. u8 bss_num, u8 bss_type)
  923. {
  924. int i;
  925. for (i = 0; i < adapter->priv_num; i++) {
  926. if (adapter->priv[i]) {
  927. if ((adapter->priv[i]->bss_num == bss_num) &&
  928. (adapter->priv[i]->bss_type == bss_type))
  929. break;
  930. }
  931. }
  932. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  933. }
  934. /*
  935. * This function returns the first available private structure pointer
  936. * based upon the BSS role.
  937. */
  938. static inline struct mwifiex_private *
  939. mwifiex_get_priv(struct mwifiex_adapter *adapter,
  940. enum mwifiex_bss_role bss_role)
  941. {
  942. int i;
  943. for (i = 0; i < adapter->priv_num; i++) {
  944. if (adapter->priv[i]) {
  945. if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
  946. GET_BSS_ROLE(adapter->priv[i]) == bss_role)
  947. break;
  948. }
  949. }
  950. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  951. }
  952. /*
  953. * This function returns the driver private structure of a network device.
  954. */
  955. static inline struct mwifiex_private *
  956. mwifiex_netdev_get_priv(struct net_device *dev)
  957. {
  958. return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
  959. }
  960. /*
  961. * This function checks if a skb holds a management frame.
  962. */
  963. static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
  964. {
  965. return (le32_to_cpu(*(__le32 *)skb->data) == PKT_TYPE_MGMT);
  966. }
  967. /* This function retrieves channel closed for operation by Channel
  968. * Switch Announcement.
  969. */
  970. static inline u8
  971. mwifiex_11h_get_csa_closed_channel(struct mwifiex_private *priv)
  972. {
  973. if (!priv->csa_chan)
  974. return 0;
  975. /* Clear csa channel, if DFS channel move time has passed */
  976. if (time_after(jiffies, priv->csa_expire_time)) {
  977. priv->csa_chan = 0;
  978. priv->csa_expire_time = 0;
  979. }
  980. return priv->csa_chan;
  981. }
  982. int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
  983. u32 func_init_shutdown);
  984. int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
  985. int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
  986. void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
  987. int maxlen);
  988. int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
  989. struct mwifiex_multicast_list *mcast_list);
  990. int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
  991. struct net_device *dev);
  992. int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
  993. struct cmd_ctrl_node *cmd_queued);
  994. int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
  995. struct cfg80211_ssid *req_ssid);
  996. int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
  997. int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
  998. int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
  999. int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
  1000. int mwifiex_request_scan(struct mwifiex_private *priv,
  1001. struct cfg80211_ssid *req_ssid);
  1002. int mwifiex_scan_networks(struct mwifiex_private *priv,
  1003. const struct mwifiex_user_scan_cfg *user_scan_in);
  1004. int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
  1005. int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
  1006. const u8 *key, int key_len, u8 key_index,
  1007. const u8 *mac_addr, int disable);
  1008. int mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len);
  1009. int mwifiex_get_ver_ext(struct mwifiex_private *priv);
  1010. int mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action,
  1011. struct ieee80211_channel *chan,
  1012. unsigned int duration);
  1013. int mwifiex_set_bss_role(struct mwifiex_private *priv, u8 bss_role);
  1014. int mwifiex_get_stats_info(struct mwifiex_private *priv,
  1015. struct mwifiex_ds_get_stats *log);
  1016. int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
  1017. u32 reg_offset, u32 reg_value);
  1018. int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
  1019. u32 reg_offset, u32 *value);
  1020. int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
  1021. u8 *value);
  1022. int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
  1023. int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
  1024. int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
  1025. int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
  1026. int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
  1027. int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
  1028. char *version, int max_len);
  1029. int mwifiex_set_tx_power(struct mwifiex_private *priv,
  1030. struct mwifiex_power_cfg *power_cfg);
  1031. int mwifiex_main_process(struct mwifiex_adapter *);
  1032. int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb);
  1033. int mwifiex_get_bss_info(struct mwifiex_private *,
  1034. struct mwifiex_bss_info *);
  1035. int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
  1036. struct cfg80211_bss *bss,
  1037. struct mwifiex_bssdescriptor *bss_desc);
  1038. int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
  1039. struct mwifiex_bssdescriptor *bss_entry);
  1040. int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
  1041. struct mwifiex_bssdescriptor *bss_desc);
  1042. u8 mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type);
  1043. struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
  1044. const char *name,
  1045. enum nl80211_iftype type,
  1046. u32 *flags,
  1047. struct vif_params *params);
  1048. int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
  1049. void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config);
  1050. int mwifiex_add_wowlan_magic_pkt_filter(struct mwifiex_adapter *adapter);
  1051. int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
  1052. struct cfg80211_beacon_data *data);
  1053. int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
  1054. u8 *mwifiex_11d_code_2_region(u8 code);
  1055. void mwifiex_uap_del_sta_data(struct mwifiex_private *priv,
  1056. struct mwifiex_sta_node *node);
  1057. void mwifiex_11h_process_join(struct mwifiex_private *priv, u8 **buffer,
  1058. struct mwifiex_bssdescriptor *bss_desc);
  1059. int mwifiex_11h_handle_event_chanswann(struct mwifiex_private *priv);
  1060. int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv,
  1061. struct device_node *node, const char *prefix);
  1062. void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv);
  1063. extern const struct ethtool_ops mwifiex_ethtool_ops;
  1064. void mwifiex_del_all_sta_list(struct mwifiex_private *priv);
  1065. void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac);
  1066. void
  1067. mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies,
  1068. int ies_len, struct mwifiex_sta_node *node);
  1069. struct mwifiex_sta_node *
  1070. mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac);
  1071. struct mwifiex_sta_node *
  1072. mwifiex_get_sta_entry(struct mwifiex_private *priv, const u8 *mac);
  1073. int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
  1074. u8 action_code, u8 dialog_token,
  1075. u16 status_code, const u8 *extra_ies,
  1076. size_t extra_ies_len);
  1077. int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
  1078. u8 action_code, u8 dialog_token,
  1079. u16 status_code, const u8 *extra_ies,
  1080. size_t extra_ies_len);
  1081. void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
  1082. u8 *buf, int len);
  1083. int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action);
  1084. int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac);
  1085. void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
  1086. bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
  1087. u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
  1088. u32 pri_chan, u8 chan_bw);
  1089. #ifdef CONFIG_DEBUG_FS
  1090. void mwifiex_debugfs_init(void);
  1091. void mwifiex_debugfs_remove(void);
  1092. void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
  1093. void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
  1094. #endif
  1095. #endif /* !_MWIFIEX_MAIN_H_ */