main.h 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  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 "decl.h"
  34. #include "ioctl.h"
  35. #include "util.h"
  36. #include "fw.h"
  37. #include "pcie.h"
  38. extern const char driver_version[];
  39. enum {
  40. MWIFIEX_ASYNC_CMD,
  41. MWIFIEX_SYNC_CMD
  42. };
  43. #define MWIFIEX_MAX_AP 64
  44. #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
  45. #define MWIFIEX_TIMER_10S 10000
  46. #define MWIFIEX_TIMER_1S 1000
  47. #define MAX_TX_PENDING 100
  48. #define LOW_TX_PENDING 80
  49. #define MWIFIEX_UPLD_SIZE (2312)
  50. #define MAX_EVENT_SIZE 1024
  51. #define ARP_FILTER_MAX_BUF_SIZE 68
  52. #define MWIFIEX_KEY_BUFFER_SIZE 16
  53. #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
  54. #define MWIFIEX_MAX_REGION_CODE 7
  55. #define DEFAULT_BCN_AVG_FACTOR 8
  56. #define DEFAULT_DATA_AVG_FACTOR 8
  57. #define FIRST_VALID_CHANNEL 0xff
  58. #define DEFAULT_AD_HOC_CHANNEL 6
  59. #define DEFAULT_AD_HOC_CHANNEL_A 36
  60. #define DEFAULT_BCN_MISS_TIMEOUT 5
  61. #define MAX_SCAN_BEACON_BUFFER 8000
  62. #define SCAN_BEACON_ENTRY_PAD 6
  63. #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
  64. #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 30
  65. #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 30
  66. #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI)))
  67. #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
  68. #define MWIFIEX_MAX_SCAN_DELAY_CNT 50
  69. #define MWIFIEX_MAX_EMPTY_TX_Q_CNT 10
  70. #define MWIFIEX_SCAN_DELAY_MSEC 20
  71. #define RSN_GTK_OUI_OFFSET 2
  72. #define MWIFIEX_OUI_NOT_PRESENT 0
  73. #define MWIFIEX_OUI_PRESENT 1
  74. /*
  75. * Do not check for data_received for USB, as data_received
  76. * is handled in mwifiex_usb_recv for USB
  77. */
  78. #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
  79. adapter->event_received || \
  80. ((adapter->iface_type != MWIFIEX_USB) && \
  81. adapter->data_received) || \
  82. ((adapter->iface_type == MWIFIEX_USB) && \
  83. !skb_queue_empty(&adapter->usb_rx_data_q)))
  84. #define MWIFIEX_TYPE_CMD 1
  85. #define MWIFIEX_TYPE_DATA 0
  86. #define MWIFIEX_TYPE_EVENT 3
  87. #define DBG_CMD_NUM 5
  88. #define MAX_BITMAP_RATES_SIZE 10
  89. #define MAX_CHANNEL_BAND_BG 14
  90. #define MAX_FREQUENCY_BAND_BG 2484
  91. #define MWIFIEX_EVENT_HEADER_LEN 4
  92. #define MWIFIEX_UAP_EVENT_EXTRA_HEADER 2
  93. #define MWIFIEX_TYPE_LEN 4
  94. #define MWIFIEX_USB_TYPE_CMD 0xF00DFACE
  95. #define MWIFIEX_USB_TYPE_DATA 0xBEADC0DE
  96. #define MWIFIEX_USB_TYPE_EVENT 0xBEEFFACE
  97. struct mwifiex_dbg {
  98. u32 num_cmd_host_to_card_failure;
  99. u32 num_cmd_sleep_cfm_host_to_card_failure;
  100. u32 num_tx_host_to_card_failure;
  101. u32 num_event_deauth;
  102. u32 num_event_disassoc;
  103. u32 num_event_link_lost;
  104. u32 num_cmd_deauth;
  105. u32 num_cmd_assoc_success;
  106. u32 num_cmd_assoc_failure;
  107. u32 num_tx_timeout;
  108. u32 num_cmd_timeout;
  109. u16 timeout_cmd_id;
  110. u16 timeout_cmd_act;
  111. u16 last_cmd_id[DBG_CMD_NUM];
  112. u16 last_cmd_act[DBG_CMD_NUM];
  113. u16 last_cmd_index;
  114. u16 last_cmd_resp_id[DBG_CMD_NUM];
  115. u16 last_cmd_resp_index;
  116. u16 last_event[DBG_CMD_NUM];
  117. u16 last_event_index;
  118. };
  119. enum MWIFIEX_HARDWARE_STATUS {
  120. MWIFIEX_HW_STATUS_READY,
  121. MWIFIEX_HW_STATUS_INITIALIZING,
  122. MWIFIEX_HW_STATUS_FW_READY,
  123. MWIFIEX_HW_STATUS_INIT_DONE,
  124. MWIFIEX_HW_STATUS_RESET,
  125. MWIFIEX_HW_STATUS_CLOSING,
  126. MWIFIEX_HW_STATUS_NOT_READY
  127. };
  128. enum MWIFIEX_802_11_POWER_MODE {
  129. MWIFIEX_802_11_POWER_MODE_CAM,
  130. MWIFIEX_802_11_POWER_MODE_PSP
  131. };
  132. struct mwifiex_tx_param {
  133. u32 next_pkt_len;
  134. };
  135. enum MWIFIEX_PS_STATE {
  136. PS_STATE_AWAKE,
  137. PS_STATE_PRE_SLEEP,
  138. PS_STATE_SLEEP_CFM,
  139. PS_STATE_SLEEP
  140. };
  141. enum mwifiex_iface_type {
  142. MWIFIEX_SDIO,
  143. MWIFIEX_PCIE,
  144. MWIFIEX_USB
  145. };
  146. struct mwifiex_add_ba_param {
  147. u32 tx_win_size;
  148. u32 rx_win_size;
  149. u32 timeout;
  150. };
  151. struct mwifiex_tx_aggr {
  152. u8 ampdu_user;
  153. u8 ampdu_ap;
  154. u8 amsdu;
  155. };
  156. struct mwifiex_ra_list_tbl {
  157. struct list_head list;
  158. struct sk_buff_head skb_head;
  159. u8 ra[ETH_ALEN];
  160. u32 total_pkts_size;
  161. u32 is_11n_enabled;
  162. };
  163. struct mwifiex_tid_tbl {
  164. struct list_head ra_list;
  165. /* spin lock for tid table */
  166. spinlock_t tid_tbl_lock;
  167. struct mwifiex_ra_list_tbl *ra_list_curr;
  168. };
  169. #define WMM_HIGHEST_PRIORITY 7
  170. #define HIGH_PRIO_TID 7
  171. #define LOW_PRIO_TID 0
  172. #define NO_PKT_PRIO_TID (-1)
  173. struct mwifiex_wmm_desc {
  174. struct mwifiex_tid_tbl tid_tbl_ptr[MAX_NUM_TID];
  175. u32 packets_out[MAX_NUM_TID];
  176. /* spin lock to protect ra_list */
  177. spinlock_t ra_list_spinlock;
  178. struct mwifiex_wmm_ac_status ac_status[IEEE80211_NUM_ACS];
  179. enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_NUM_ACS];
  180. u32 drv_pkt_delay_max;
  181. u8 queue_priority[IEEE80211_NUM_ACS];
  182. u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */
  183. /* Number of transmit packets queued */
  184. atomic_t tx_pkts_queued;
  185. /* Tracks highest priority with a packet queued */
  186. atomic_t highest_queued_prio;
  187. };
  188. struct mwifiex_802_11_security {
  189. u8 wpa_enabled;
  190. u8 wpa2_enabled;
  191. u8 wapi_enabled;
  192. u8 wapi_key_on;
  193. u8 wep_enabled;
  194. u32 authentication_mode;
  195. u8 is_authtype_auto;
  196. u32 encryption_mode;
  197. };
  198. struct ieee_types_header {
  199. u8 element_id;
  200. u8 len;
  201. } __packed;
  202. #define MWIFIEX_SUPPORTED_RATES 14
  203. #define MWIFIEX_SUPPORTED_RATES_EXT 32
  204. struct ieee_types_vendor_specific {
  205. struct ieee_types_vendor_header vend_hdr;
  206. u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_vendor_header)];
  207. } __packed;
  208. struct ieee_types_generic {
  209. struct ieee_types_header ieee_hdr;
  210. u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)];
  211. } __packed;
  212. struct mwifiex_bssdescriptor {
  213. u8 mac_address[ETH_ALEN];
  214. struct cfg80211_ssid ssid;
  215. u32 privacy;
  216. s32 rssi;
  217. u32 channel;
  218. u32 freq;
  219. u16 beacon_period;
  220. u8 erp_flags;
  221. u32 bss_mode;
  222. u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
  223. u8 data_rates[MWIFIEX_SUPPORTED_RATES];
  224. /* Network band.
  225. * BAND_B(0x01): 'b' band
  226. * BAND_G(0x02): 'g' band
  227. * BAND_A(0X04): 'a' band
  228. */
  229. u16 bss_band;
  230. u64 fw_tsf;
  231. u64 timestamp;
  232. union ieee_types_phy_param_set phy_param_set;
  233. union ieee_types_ss_param_set ss_param_set;
  234. u16 cap_info_bitmap;
  235. struct ieee_types_wmm_parameter wmm_ie;
  236. u8 disable_11n;
  237. struct ieee80211_ht_cap *bcn_ht_cap;
  238. u16 ht_cap_offset;
  239. struct ieee80211_ht_operation *bcn_ht_oper;
  240. u16 ht_info_offset;
  241. u8 *bcn_bss_co_2040;
  242. u16 bss_co_2040_offset;
  243. u8 *bcn_ext_cap;
  244. u16 ext_cap_offset;
  245. struct ieee_types_vendor_specific *bcn_wpa_ie;
  246. u16 wpa_offset;
  247. struct ieee_types_generic *bcn_rsn_ie;
  248. u16 rsn_offset;
  249. struct ieee_types_generic *bcn_wapi_ie;
  250. u16 wapi_offset;
  251. u8 *beacon_buf;
  252. u32 beacon_buf_size;
  253. };
  254. struct mwifiex_current_bss_params {
  255. struct mwifiex_bssdescriptor bss_descriptor;
  256. u8 wmm_enabled;
  257. u8 wmm_uapsd_enabled;
  258. u8 band;
  259. u32 num_of_rates;
  260. u8 data_rates[MWIFIEX_SUPPORTED_RATES];
  261. };
  262. struct mwifiex_sleep_params {
  263. u16 sp_error;
  264. u16 sp_offset;
  265. u16 sp_stable_time;
  266. u8 sp_cal_control;
  267. u8 sp_ext_sleep_clk;
  268. u16 sp_reserved;
  269. };
  270. struct mwifiex_sleep_period {
  271. u16 period;
  272. u16 reserved;
  273. };
  274. struct mwifiex_wep_key {
  275. u32 length;
  276. u32 key_index;
  277. u32 key_length;
  278. u8 key_material[MWIFIEX_KEY_BUFFER_SIZE];
  279. };
  280. #define MAX_REGION_CHANNEL_NUM 2
  281. struct mwifiex_chan_freq_power {
  282. u16 channel;
  283. u32 freq;
  284. u16 max_tx_power;
  285. u8 unsupported;
  286. };
  287. enum state_11d_t {
  288. DISABLE_11D = 0,
  289. ENABLE_11D = 1,
  290. };
  291. #define MWIFIEX_MAX_TRIPLET_802_11D 83
  292. struct mwifiex_802_11d_domain_reg {
  293. u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
  294. u8 no_of_triplet;
  295. struct ieee80211_country_ie_triplet
  296. triplet[MWIFIEX_MAX_TRIPLET_802_11D];
  297. };
  298. struct mwifiex_vendor_spec_cfg_ie {
  299. u16 mask;
  300. u16 flag;
  301. u8 ie[MWIFIEX_MAX_VSIE_LEN];
  302. };
  303. struct wps {
  304. u8 session_enable;
  305. };
  306. struct mwifiex_adapter;
  307. struct mwifiex_private;
  308. struct mwifiex_private {
  309. struct mwifiex_adapter *adapter;
  310. u8 bss_type;
  311. u8 bss_role;
  312. u8 bss_priority;
  313. u8 bss_num;
  314. u8 bss_started;
  315. u8 frame_type;
  316. u8 curr_addr[ETH_ALEN];
  317. u8 media_connected;
  318. u32 num_tx_timeout;
  319. struct net_device *netdev;
  320. struct net_device_stats stats;
  321. u16 curr_pkt_filter;
  322. u32 bss_mode;
  323. u32 pkt_tx_ctrl;
  324. u16 tx_power_level;
  325. u8 max_tx_power_level;
  326. u8 min_tx_power_level;
  327. u8 tx_rate;
  328. u8 tx_htinfo;
  329. u8 rxpd_htinfo;
  330. u8 rxpd_rate;
  331. u16 rate_bitmap;
  332. u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
  333. u32 data_rate;
  334. u8 is_data_rate_auto;
  335. u16 bcn_avg_factor;
  336. u16 data_avg_factor;
  337. s16 data_rssi_last;
  338. s16 data_nf_last;
  339. s16 data_rssi_avg;
  340. s16 data_nf_avg;
  341. s16 bcn_rssi_last;
  342. s16 bcn_nf_last;
  343. s16 bcn_rssi_avg;
  344. s16 bcn_nf_avg;
  345. struct mwifiex_bssdescriptor *attempted_bss_desc;
  346. struct cfg80211_ssid prev_ssid;
  347. u8 prev_bssid[ETH_ALEN];
  348. struct mwifiex_current_bss_params curr_bss_params;
  349. u16 beacon_period;
  350. u8 dtim_period;
  351. u16 listen_interval;
  352. u16 atim_window;
  353. u8 adhoc_channel;
  354. u8 adhoc_is_link_sensed;
  355. u8 adhoc_state;
  356. struct mwifiex_802_11_security sec_info;
  357. struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
  358. u16 wep_key_curr_index;
  359. u8 wpa_ie[256];
  360. u8 wpa_ie_len;
  361. u8 wpa_is_gtk_set;
  362. struct host_cmd_ds_802_11_key_material aes_key;
  363. u8 wapi_ie[256];
  364. u8 wapi_ie_len;
  365. u8 *wps_ie;
  366. u8 wps_ie_len;
  367. u8 wmm_required;
  368. u8 wmm_enabled;
  369. u8 wmm_qosinfo;
  370. struct mwifiex_wmm_desc wmm;
  371. struct list_head tx_ba_stream_tbl_ptr;
  372. /* spin lock for tx_ba_stream_tbl_ptr queue */
  373. spinlock_t tx_ba_stream_tbl_lock;
  374. struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
  375. struct mwifiex_add_ba_param add_ba_param;
  376. u16 rx_seq[MAX_NUM_TID];
  377. struct list_head rx_reorder_tbl_ptr;
  378. /* spin lock for rx_reorder_tbl_ptr queue */
  379. spinlock_t rx_reorder_tbl_lock;
  380. /* spin lock for Rx packets */
  381. spinlock_t rx_pkt_lock;
  382. #define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
  383. u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
  384. u32 assoc_rsp_size;
  385. #define MWIFIEX_GENIE_BUF_SIZE 256
  386. u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
  387. u8 gen_ie_buf_len;
  388. struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
  389. #define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
  390. u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
  391. u8 assoc_tlv_buf_len;
  392. u8 *curr_bcn_buf;
  393. u32 curr_bcn_size;
  394. /* spin lock for beacon buffer */
  395. spinlock_t curr_bcn_buf_lock;
  396. struct wireless_dev *wdev;
  397. struct mwifiex_chan_freq_power cfp;
  398. char version_str[128];
  399. #ifdef CONFIG_DEBUG_FS
  400. struct dentry *dfs_dev_dir;
  401. #endif
  402. u8 nick_name[16];
  403. u16 current_key_index;
  404. struct semaphore async_sem;
  405. u8 scan_pending_on_block;
  406. u8 report_scan_result;
  407. struct cfg80211_scan_request *scan_request;
  408. struct mwifiex_user_scan_cfg *user_scan_cfg;
  409. u8 cfg_bssid[6];
  410. struct wps wps;
  411. u8 scan_block;
  412. s32 cqm_rssi_thold;
  413. u32 cqm_rssi_hyst;
  414. u8 subsc_evt_rssi_state;
  415. struct mwifiex_ie mgmt_ie[MAX_MGMT_IE_INDEX];
  416. u16 beacon_idx;
  417. u16 proberesp_idx;
  418. u16 assocresp_idx;
  419. u16 rsn_idx;
  420. struct timer_list scan_delay_timer;
  421. u8 ap_11n_enabled;
  422. };
  423. enum mwifiex_ba_status {
  424. BA_SETUP_NONE = 0,
  425. BA_SETUP_INPROGRESS,
  426. BA_SETUP_COMPLETE
  427. };
  428. struct mwifiex_tx_ba_stream_tbl {
  429. struct list_head list;
  430. int tid;
  431. u8 ra[ETH_ALEN];
  432. enum mwifiex_ba_status ba_status;
  433. };
  434. struct mwifiex_rx_reorder_tbl;
  435. struct reorder_tmr_cnxt {
  436. struct timer_list timer;
  437. struct mwifiex_rx_reorder_tbl *ptr;
  438. struct mwifiex_private *priv;
  439. };
  440. struct mwifiex_rx_reorder_tbl {
  441. struct list_head list;
  442. int tid;
  443. u8 ta[ETH_ALEN];
  444. int start_win;
  445. int win_size;
  446. void **rx_reorder_ptr;
  447. struct reorder_tmr_cnxt timer_context;
  448. };
  449. struct mwifiex_bss_prio_node {
  450. struct list_head list;
  451. struct mwifiex_private *priv;
  452. };
  453. struct mwifiex_bss_prio_tbl {
  454. struct list_head bss_prio_head;
  455. /* spin lock for bss priority */
  456. spinlock_t bss_prio_lock;
  457. struct mwifiex_bss_prio_node *bss_prio_cur;
  458. };
  459. struct cmd_ctrl_node {
  460. struct list_head list;
  461. struct mwifiex_private *priv;
  462. u32 cmd_oid;
  463. u32 cmd_flag;
  464. struct sk_buff *cmd_skb;
  465. struct sk_buff *resp_skb;
  466. void *data_buf;
  467. u32 wait_q_enabled;
  468. struct sk_buff *skb;
  469. u8 *condition;
  470. u8 cmd_wait_q_woken;
  471. };
  472. struct mwifiex_bss_priv {
  473. u8 band;
  474. u64 fw_tsf;
  475. };
  476. struct mwifiex_if_ops {
  477. int (*init_if) (struct mwifiex_adapter *);
  478. void (*cleanup_if) (struct mwifiex_adapter *);
  479. int (*check_fw_status) (struct mwifiex_adapter *, u32);
  480. int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
  481. int (*register_dev) (struct mwifiex_adapter *);
  482. void (*unregister_dev) (struct mwifiex_adapter *);
  483. int (*enable_int) (struct mwifiex_adapter *);
  484. int (*process_int_status) (struct mwifiex_adapter *);
  485. int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *,
  486. struct mwifiex_tx_param *);
  487. int (*wakeup) (struct mwifiex_adapter *);
  488. int (*wakeup_complete) (struct mwifiex_adapter *);
  489. /* Interface specific functions */
  490. void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
  491. void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
  492. int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
  493. int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
  494. int (*data_complete) (struct mwifiex_adapter *, struct sk_buff *);
  495. int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
  496. };
  497. struct mwifiex_adapter {
  498. u8 iface_type;
  499. struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
  500. u8 priv_num;
  501. const struct firmware *firmware;
  502. char fw_name[32];
  503. int winner;
  504. struct device *dev;
  505. struct wiphy *wiphy;
  506. bool surprise_removed;
  507. u32 fw_release_number;
  508. u16 init_wait_q_woken;
  509. wait_queue_head_t init_wait_q;
  510. void *card;
  511. struct mwifiex_if_ops if_ops;
  512. atomic_t rx_pending;
  513. atomic_t tx_pending;
  514. atomic_t cmd_pending;
  515. struct workqueue_struct *workqueue;
  516. struct work_struct main_work;
  517. struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
  518. /* spin lock for init/shutdown */
  519. spinlock_t mwifiex_lock;
  520. /* spin lock for main process */
  521. spinlock_t main_proc_lock;
  522. u32 mwifiex_processing;
  523. u16 max_tx_buf_size;
  524. u16 tx_buf_size;
  525. u16 curr_tx_buf_size;
  526. u32 ioport;
  527. enum MWIFIEX_HARDWARE_STATUS hw_status;
  528. u16 number_of_antenna;
  529. u32 fw_cap_info;
  530. /* spin lock for interrupt handling */
  531. spinlock_t int_lock;
  532. u8 int_status;
  533. u32 event_cause;
  534. struct sk_buff *event_skb;
  535. u8 upld_buf[MWIFIEX_UPLD_SIZE];
  536. u8 data_sent;
  537. u8 cmd_sent;
  538. u8 cmd_resp_received;
  539. u8 event_received;
  540. u8 data_received;
  541. u16 seq_num;
  542. struct cmd_ctrl_node *cmd_pool;
  543. struct cmd_ctrl_node *curr_cmd;
  544. /* spin lock for command */
  545. spinlock_t mwifiex_cmd_lock;
  546. u32 num_cmd_timeout;
  547. u16 last_init_cmd;
  548. struct timer_list cmd_timer;
  549. struct list_head cmd_free_q;
  550. /* spin lock for cmd_free_q */
  551. spinlock_t cmd_free_q_lock;
  552. struct list_head cmd_pending_q;
  553. /* spin lock for cmd_pending_q */
  554. spinlock_t cmd_pending_q_lock;
  555. struct list_head scan_pending_q;
  556. /* spin lock for scan_pending_q */
  557. spinlock_t scan_pending_q_lock;
  558. struct sk_buff_head usb_rx_data_q;
  559. u32 scan_processing;
  560. u16 region_code;
  561. struct mwifiex_802_11d_domain_reg domain_reg;
  562. u16 scan_probes;
  563. u32 scan_mode;
  564. u16 specific_scan_time;
  565. u16 active_scan_time;
  566. u16 passive_scan_time;
  567. u8 fw_bands;
  568. u8 adhoc_start_band;
  569. u8 config_bands;
  570. struct mwifiex_chan_scan_param_set *scan_channels;
  571. u8 tx_lock_flag;
  572. struct mwifiex_sleep_params sleep_params;
  573. struct mwifiex_sleep_period sleep_period;
  574. u16 ps_mode;
  575. u32 ps_state;
  576. u8 need_to_wakeup;
  577. u16 multiple_dtim;
  578. u16 local_listen_interval;
  579. u16 null_pkt_interval;
  580. struct sk_buff *sleep_cfm;
  581. u16 bcn_miss_time_out;
  582. u16 adhoc_awake_period;
  583. u8 is_deep_sleep;
  584. u8 delay_null_pkt;
  585. u16 delay_to_ps;
  586. u16 enhanced_ps_mode;
  587. u8 pm_wakeup_card_req;
  588. u16 gen_null_pkt;
  589. u16 pps_uapsd_mode;
  590. u32 pm_wakeup_fw_try;
  591. u8 is_hs_configured;
  592. struct mwifiex_hs_config_param hs_cfg;
  593. u8 hs_activated;
  594. u16 hs_activate_wait_q_woken;
  595. wait_queue_head_t hs_activate_wait_q;
  596. bool is_suspended;
  597. u8 event_body[MAX_EVENT_SIZE];
  598. u32 hw_dot_11n_dev_cap;
  599. u8 hw_dev_mcs_support;
  600. u8 adhoc_11n_enabled;
  601. u8 sec_chan_offset;
  602. struct mwifiex_dbg dbg;
  603. u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
  604. u32 arp_filter_size;
  605. u16 cmd_wait_q_required;
  606. struct mwifiex_wait_queue cmd_wait_q;
  607. u8 scan_wait_q_woken;
  608. struct cmd_ctrl_node *cmd_queued;
  609. spinlock_t queue_lock; /* lock for tx queues */
  610. struct completion fw_load;
  611. u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
  612. u16 max_mgmt_ie_index;
  613. u8 scan_delay_cnt;
  614. u8 empty_tx_q_cnt;
  615. atomic_t is_tx_received;
  616. };
  617. int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
  618. void mwifiex_set_trans_start(struct net_device *dev);
  619. void mwifiex_stop_net_dev_queue(struct net_device *netdev,
  620. struct mwifiex_adapter *adapter);
  621. void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
  622. struct mwifiex_adapter *adapter);
  623. int mwifiex_init_fw(struct mwifiex_adapter *adapter);
  624. int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
  625. int mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
  626. int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
  627. int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
  628. int mwifiex_recv_packet(struct mwifiex_adapter *, struct sk_buff *skb);
  629. int mwifiex_process_event(struct mwifiex_adapter *adapter);
  630. int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
  631. struct cmd_ctrl_node *cmd_node);
  632. int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no,
  633. u16 cmd_action, u32 cmd_oid, void *data_buf);
  634. int mwifiex_send_cmd_sync(struct mwifiex_private *priv, uint16_t cmd_no,
  635. u16 cmd_action, u32 cmd_oid, void *data_buf);
  636. void mwifiex_cmd_timeout_func(unsigned long function_context);
  637. int mwifiex_get_debug_info(struct mwifiex_private *,
  638. struct mwifiex_debug_info *);
  639. int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
  640. int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
  641. void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
  642. void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
  643. void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
  644. struct cmd_ctrl_node *cmd_node);
  645. void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
  646. struct cmd_ctrl_node *cmd_node,
  647. u32 addtail);
  648. int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
  649. int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
  650. int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
  651. struct sk_buff *skb);
  652. int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
  653. struct mwifiex_tx_param *tx_param);
  654. int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
  655. int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
  656. struct sk_buff *skb, int status);
  657. void mwifiex_clean_txrx(struct mwifiex_private *priv);
  658. u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
  659. void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
  660. void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
  661. u32);
  662. int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
  663. struct host_cmd_ds_command *cmd,
  664. u16 cmd_action, uint16_t ps_bitmap,
  665. struct mwifiex_ds_auto_ds *auto_ds);
  666. int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
  667. struct host_cmd_ds_command *resp,
  668. struct mwifiex_ds_pm_cfg *pm_cfg);
  669. void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
  670. void mwifiex_hs_activated_event(struct mwifiex_private *priv,
  671. u8 activated);
  672. int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
  673. struct host_cmd_ds_command *resp);
  674. int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter,
  675. struct sk_buff *skb);
  676. int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
  677. u16 cmd_action, u32 cmd_oid,
  678. void *data_buf, void *cmd_buf);
  679. int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
  680. u16 cmd_action, u32 cmd_oid,
  681. void *data_buf, void *cmd_buf);
  682. int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
  683. struct host_cmd_ds_command *resp);
  684. int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *,
  685. struct sk_buff *skb);
  686. int mwifiex_process_sta_event(struct mwifiex_private *);
  687. void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
  688. int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
  689. int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
  690. struct mwifiex_scan_cmd_config *scan_cfg);
  691. void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
  692. struct cmd_ctrl_node *cmd_node);
  693. int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
  694. struct host_cmd_ds_command *resp);
  695. s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
  696. int mwifiex_associate(struct mwifiex_private *priv,
  697. struct mwifiex_bssdescriptor *bss_desc);
  698. int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
  699. struct host_cmd_ds_command *cmd,
  700. struct mwifiex_bssdescriptor *bss_desc);
  701. int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
  702. struct host_cmd_ds_command *resp);
  703. void mwifiex_reset_connect_state(struct mwifiex_private *priv);
  704. u8 mwifiex_band_to_radio_type(u8 band);
  705. int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
  706. int mwifiex_adhoc_start(struct mwifiex_private *priv,
  707. struct cfg80211_ssid *adhoc_ssid);
  708. int mwifiex_adhoc_join(struct mwifiex_private *priv,
  709. struct mwifiex_bssdescriptor *bss_desc);
  710. int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
  711. struct host_cmd_ds_command *cmd,
  712. struct cfg80211_ssid *req_ssid);
  713. int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
  714. struct host_cmd_ds_command *cmd,
  715. struct mwifiex_bssdescriptor *bss_desc);
  716. int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
  717. struct host_cmd_ds_command *resp);
  718. int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
  719. struct mwifiex_chan_freq_power *mwifiex_get_cfp(struct mwifiex_private *priv,
  720. u8 band, u16 channel, u32 freq);
  721. u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv, u8 index,
  722. u8 ht_info);
  723. u32 mwifiex_find_freq_from_band_chan(u8, u8);
  724. int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
  725. u8 **buffer);
  726. u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
  727. u8 *rates);
  728. u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
  729. u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
  730. extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
  731. void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
  732. void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
  733. int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
  734. struct host_cmd_ds_command *cmd);
  735. int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
  736. struct host_cmd_ds_command *resp);
  737. int is_command_pending(struct mwifiex_adapter *adapter);
  738. void mwifiex_init_priv_params(struct mwifiex_private *priv,
  739. struct net_device *dev);
  740. int mwifiex_set_secure_params(struct mwifiex_private *priv,
  741. struct mwifiex_uap_bss_param *bss_config,
  742. struct cfg80211_ap_settings *params);
  743. void mwifiex_set_ht_params(struct mwifiex_private *priv,
  744. struct mwifiex_uap_bss_param *bss_cfg,
  745. struct cfg80211_ap_settings *params);
  746. /*
  747. * This function checks if the queuing is RA based or not.
  748. */
  749. static inline u8
  750. mwifiex_queuing_ra_based(struct mwifiex_private *priv)
  751. {
  752. /*
  753. * Currently we assume if we are in Infra, then DA=RA. This might not be
  754. * true in the future
  755. */
  756. if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
  757. (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
  758. return false;
  759. return true;
  760. }
  761. /*
  762. * This function copies rates.
  763. */
  764. static inline u32
  765. mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
  766. {
  767. int i;
  768. for (i = 0; i < len && src[i]; i++, pos++) {
  769. if (pos >= MWIFIEX_SUPPORTED_RATES)
  770. break;
  771. dest[pos] = src[i];
  772. }
  773. return pos;
  774. }
  775. /*
  776. * This function returns the correct private structure pointer based
  777. * upon the BSS type and BSS number.
  778. */
  779. static inline struct mwifiex_private *
  780. mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
  781. u8 bss_num, u8 bss_type)
  782. {
  783. int i;
  784. for (i = 0; i < adapter->priv_num; i++) {
  785. if (adapter->priv[i]) {
  786. if ((adapter->priv[i]->bss_num == bss_num) &&
  787. (adapter->priv[i]->bss_type == bss_type))
  788. break;
  789. }
  790. }
  791. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  792. }
  793. /*
  794. * This function returns the first available private structure pointer
  795. * based upon the BSS role.
  796. */
  797. static inline struct mwifiex_private *
  798. mwifiex_get_priv(struct mwifiex_adapter *adapter,
  799. enum mwifiex_bss_role bss_role)
  800. {
  801. int i;
  802. for (i = 0; i < adapter->priv_num; i++) {
  803. if (adapter->priv[i]) {
  804. if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
  805. GET_BSS_ROLE(adapter->priv[i]) == bss_role)
  806. break;
  807. }
  808. }
  809. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  810. }
  811. /*
  812. * This function returns the driver private structure of a network device.
  813. */
  814. static inline struct mwifiex_private *
  815. mwifiex_netdev_get_priv(struct net_device *dev)
  816. {
  817. return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
  818. }
  819. int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
  820. u32 func_init_shutdown);
  821. int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
  822. int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
  823. void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
  824. int maxlen);
  825. int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
  826. struct mwifiex_multicast_list *mcast_list);
  827. int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
  828. struct net_device *dev);
  829. int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter);
  830. int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
  831. struct cfg80211_ssid *req_ssid);
  832. int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
  833. int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
  834. int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
  835. int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
  836. int mwifiex_request_scan(struct mwifiex_private *priv,
  837. struct cfg80211_ssid *req_ssid);
  838. int mwifiex_scan_networks(struct mwifiex_private *priv,
  839. const struct mwifiex_user_scan_cfg *user_scan_in);
  840. int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
  841. int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
  842. int key_len, u8 key_index, const u8 *mac_addr,
  843. int disable);
  844. int mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len);
  845. int mwifiex_get_ver_ext(struct mwifiex_private *priv);
  846. int mwifiex_get_stats_info(struct mwifiex_private *priv,
  847. struct mwifiex_ds_get_stats *log);
  848. int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
  849. u32 reg_offset, u32 reg_value);
  850. int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
  851. u32 reg_offset, u32 *value);
  852. int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
  853. u8 *value);
  854. int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
  855. int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
  856. int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
  857. int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
  858. int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
  859. int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
  860. char *version, int max_len);
  861. int mwifiex_set_tx_power(struct mwifiex_private *priv,
  862. struct mwifiex_power_cfg *power_cfg);
  863. int mwifiex_main_process(struct mwifiex_adapter *);
  864. int mwifiex_get_bss_info(struct mwifiex_private *,
  865. struct mwifiex_bss_info *);
  866. int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
  867. struct cfg80211_bss *bss,
  868. struct mwifiex_bssdescriptor *bss_desc);
  869. int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
  870. struct mwifiex_bssdescriptor *bss_entry);
  871. int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
  872. struct mwifiex_bssdescriptor *bss_desc);
  873. struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
  874. char *name,
  875. enum nl80211_iftype type,
  876. u32 *flags,
  877. struct vif_params *params);
  878. int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
  879. void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config);
  880. int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
  881. struct cfg80211_beacon_data *data);
  882. int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
  883. u8 *mwifiex_11d_code_2_region(u8 code);
  884. #ifdef CONFIG_DEBUG_FS
  885. void mwifiex_debugfs_init(void);
  886. void mwifiex_debugfs_remove(void);
  887. void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
  888. void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
  889. #endif
  890. #endif /* !_MWIFIEX_MAIN_H_ */