main.h 39 KB

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