main.h 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  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. extern const char driver_version[];
  38. enum {
  39. MWIFIEX_ASYNC_CMD,
  40. MWIFIEX_SYNC_CMD
  41. };
  42. #define DRV_MODE_STA 0x1
  43. struct mwifiex_drv_mode {
  44. u16 drv_mode;
  45. u16 intf_num;
  46. struct mwifiex_bss_attr *bss_attr;
  47. };
  48. #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
  49. #define MWIFIEX_TIMER_10S 10000
  50. #define MWIFIEX_TIMER_1S 1000
  51. #define MAX_TX_PENDING 100
  52. #define LOW_TX_PENDING 80
  53. #define MWIFIEX_UPLD_SIZE (2312)
  54. #define MAX_EVENT_SIZE 1024
  55. #define ARP_FILTER_MAX_BUF_SIZE 68
  56. #define MWIFIEX_KEY_BUFFER_SIZE 16
  57. #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
  58. #define MWIFIEX_MAX_REGION_CODE 7
  59. #define DEFAULT_BCN_AVG_FACTOR 8
  60. #define DEFAULT_DATA_AVG_FACTOR 8
  61. #define FIRST_VALID_CHANNEL 0xff
  62. #define DEFAULT_AD_HOC_CHANNEL 6
  63. #define DEFAULT_AD_HOC_CHANNEL_A 36
  64. #define DEFAULT_BCN_MISS_TIMEOUT 5
  65. #define MAX_SCAN_BEACON_BUFFER 8000
  66. #define SCAN_BEACON_ENTRY_PAD 6
  67. #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 200
  68. #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 200
  69. #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 110
  70. #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI)))
  71. #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
  72. #define RSN_GTK_OUI_OFFSET 2
  73. #define MWIFIEX_OUI_NOT_PRESENT 0
  74. #define MWIFIEX_OUI_PRESENT 1
  75. #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
  76. adapter->event_received || \
  77. adapter->data_received)
  78. #define MWIFIEX_TYPE_CMD 1
  79. #define MWIFIEX_TYPE_DATA 0
  80. #define MWIFIEX_TYPE_EVENT 3
  81. #define DBG_CMD_NUM 5
  82. #define MAX_BITMAP_RATES_SIZE 10
  83. #define MAX_CHANNEL_BAND_BG 14
  84. #define MAX_FREQUENCY_BAND_BG 2484
  85. struct mwifiex_dbg {
  86. u32 num_cmd_host_to_card_failure;
  87. u32 num_cmd_sleep_cfm_host_to_card_failure;
  88. u32 num_tx_host_to_card_failure;
  89. u32 num_event_deauth;
  90. u32 num_event_disassoc;
  91. u32 num_event_link_lost;
  92. u32 num_cmd_deauth;
  93. u32 num_cmd_assoc_success;
  94. u32 num_cmd_assoc_failure;
  95. u32 num_tx_timeout;
  96. u32 num_cmd_timeout;
  97. u16 timeout_cmd_id;
  98. u16 timeout_cmd_act;
  99. u16 last_cmd_id[DBG_CMD_NUM];
  100. u16 last_cmd_act[DBG_CMD_NUM];
  101. u16 last_cmd_index;
  102. u16 last_cmd_resp_id[DBG_CMD_NUM];
  103. u16 last_cmd_resp_index;
  104. u16 last_event[DBG_CMD_NUM];
  105. u16 last_event_index;
  106. };
  107. enum MWIFIEX_HARDWARE_STATUS {
  108. MWIFIEX_HW_STATUS_READY,
  109. MWIFIEX_HW_STATUS_INITIALIZING,
  110. MWIFIEX_HW_STATUS_FW_READY,
  111. MWIFIEX_HW_STATUS_INIT_DONE,
  112. MWIFIEX_HW_STATUS_RESET,
  113. MWIFIEX_HW_STATUS_CLOSING,
  114. MWIFIEX_HW_STATUS_NOT_READY
  115. };
  116. enum MWIFIEX_802_11_POWER_MODE {
  117. MWIFIEX_802_11_POWER_MODE_CAM,
  118. MWIFIEX_802_11_POWER_MODE_PSP
  119. };
  120. struct mwifiex_tx_param {
  121. u32 next_pkt_len;
  122. };
  123. enum MWIFIEX_PS_STATE {
  124. PS_STATE_AWAKE,
  125. PS_STATE_PRE_SLEEP,
  126. PS_STATE_SLEEP_CFM,
  127. PS_STATE_SLEEP
  128. };
  129. struct mwifiex_add_ba_param {
  130. u32 tx_win_size;
  131. u32 rx_win_size;
  132. u32 timeout;
  133. };
  134. struct mwifiex_tx_aggr {
  135. u8 ampdu_user;
  136. u8 ampdu_ap;
  137. u8 amsdu;
  138. };
  139. struct mwifiex_ra_list_tbl {
  140. struct list_head list;
  141. struct sk_buff_head skb_head;
  142. u8 ra[ETH_ALEN];
  143. u32 total_pkts_size;
  144. u32 total_pkts;
  145. u32 is_11n_enabled;
  146. };
  147. struct mwifiex_tid_tbl {
  148. struct list_head ra_list;
  149. /* spin lock for tid table */
  150. spinlock_t tid_tbl_lock;
  151. struct mwifiex_ra_list_tbl *ra_list_curr;
  152. };
  153. #define WMM_HIGHEST_PRIORITY 7
  154. #define HIGH_PRIO_TID 7
  155. #define LOW_PRIO_TID 0
  156. #define NO_PKT_PRIO_TID (-1)
  157. struct mwifiex_wmm_desc {
  158. struct mwifiex_tid_tbl tid_tbl_ptr[MAX_NUM_TID];
  159. u32 packets_out[MAX_NUM_TID];
  160. /* spin lock to protect ra_list */
  161. spinlock_t ra_list_spinlock;
  162. struct mwifiex_wmm_ac_status ac_status[IEEE80211_MAX_QUEUES];
  163. enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_MAX_QUEUES];
  164. u32 drv_pkt_delay_max;
  165. u8 queue_priority[IEEE80211_MAX_QUEUES];
  166. u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */
  167. /* Number of transmit packets queued */
  168. atomic_t tx_pkts_queued;
  169. /* Tracks highest priority with a packet queued */
  170. atomic_t highest_queued_prio;
  171. };
  172. struct mwifiex_802_11_security {
  173. u8 wpa_enabled;
  174. u8 wpa2_enabled;
  175. u8 wapi_enabled;
  176. u8 wapi_key_on;
  177. enum MWIFIEX_802_11_WEP_STATUS wep_status;
  178. u32 authentication_mode;
  179. u32 encryption_mode;
  180. };
  181. struct ieee_types_header {
  182. u8 element_id;
  183. u8 len;
  184. } __packed;
  185. struct ieee_obss_scan_param {
  186. u16 obss_scan_passive_dwell;
  187. u16 obss_scan_active_dwell;
  188. u16 bss_chan_width_trigger_scan_int;
  189. u16 obss_scan_passive_total;
  190. u16 obss_scan_active_total;
  191. u16 bss_width_chan_trans_delay;
  192. u16 obss_scan_active_threshold;
  193. } __packed;
  194. struct ieee_types_obss_scan_param {
  195. struct ieee_types_header ieee_hdr;
  196. struct ieee_obss_scan_param obss_scan;
  197. } __packed;
  198. #define MWIFIEX_SUPPORTED_RATES 14
  199. #define MWIFIEX_SUPPORTED_RATES_EXT 32
  200. #define IEEE_MAX_IE_SIZE 256
  201. struct ieee_types_vendor_specific {
  202. struct ieee_types_vendor_header vend_hdr;
  203. u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_vendor_header)];
  204. } __packed;
  205. struct ieee_types_generic {
  206. struct ieee_types_header ieee_hdr;
  207. u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)];
  208. } __packed;
  209. struct mwifiex_bssdescriptor {
  210. u8 mac_address[ETH_ALEN];
  211. struct mwifiex_802_11_ssid ssid;
  212. u32 privacy;
  213. s32 rssi;
  214. u32 channel;
  215. u32 freq;
  216. u16 beacon_period;
  217. u8 erp_flags;
  218. u32 bss_mode;
  219. u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
  220. u8 data_rates[MWIFIEX_SUPPORTED_RATES];
  221. /* Network band.
  222. * BAND_B(0x01): 'b' band
  223. * BAND_G(0x02): 'g' band
  224. * BAND_A(0X04): 'a' band
  225. */
  226. u16 bss_band;
  227. u64 network_tsf;
  228. u8 time_stamp[8];
  229. union ieee_types_phy_param_set phy_param_set;
  230. union ieee_types_ss_param_set ss_param_set;
  231. u16 cap_info_bitmap;
  232. struct ieee_types_wmm_parameter wmm_ie;
  233. u8 disable_11n;
  234. struct ieee80211_ht_cap *bcn_ht_cap;
  235. u16 ht_cap_offset;
  236. struct ieee80211_ht_info *bcn_ht_info;
  237. u16 ht_info_offset;
  238. u8 *bcn_bss_co_2040;
  239. u16 bss_co_2040_offset;
  240. u8 *bcn_ext_cap;
  241. u16 ext_cap_offset;
  242. struct ieee_types_obss_scan_param *bcn_obss_scan;
  243. u16 overlap_bss_offset;
  244. struct ieee_types_vendor_specific *bcn_wpa_ie;
  245. u16 wpa_offset;
  246. struct ieee_types_generic *bcn_rsn_ie;
  247. u16 rsn_offset;
  248. struct ieee_types_generic *bcn_wapi_ie;
  249. u16 wapi_offset;
  250. u8 *beacon_buf;
  251. u32 beacon_buf_size;
  252. u32 beacon_buf_size_max;
  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_index;
  311. u8 bss_type;
  312. u8 bss_role;
  313. u8 bss_priority;
  314. u8 bss_num;
  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 mwifiex_802_11_ssid prev_ssid;
  347. u8 prev_bssid[ETH_ALEN];
  348. struct mwifiex_current_bss_params curr_bss_params;
  349. u16 beacon_period;
  350. u16 listen_interval;
  351. u16 atim_window;
  352. u8 adhoc_channel;
  353. u8 adhoc_is_link_sensed;
  354. u8 adhoc_state;
  355. struct mwifiex_802_11_security sec_info;
  356. struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
  357. u16 wep_key_curr_index;
  358. u8 wpa_ie[256];
  359. u8 wpa_ie_len;
  360. u8 wpa_is_gtk_set;
  361. struct host_cmd_ds_802_11_key_material aes_key;
  362. u8 wapi_ie[256];
  363. u8 wapi_ie_len;
  364. u8 wmm_required;
  365. u8 wmm_enabled;
  366. u8 wmm_qosinfo;
  367. struct mwifiex_wmm_desc wmm;
  368. struct list_head tx_ba_stream_tbl_ptr;
  369. /* spin lock for tx_ba_stream_tbl_ptr queue */
  370. spinlock_t tx_ba_stream_tbl_lock;
  371. struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
  372. struct mwifiex_add_ba_param add_ba_param;
  373. u16 rx_seq[MAX_NUM_TID];
  374. struct list_head rx_reorder_tbl_ptr;
  375. /* spin lock for rx_reorder_tbl_ptr queue */
  376. spinlock_t rx_reorder_tbl_lock;
  377. /* spin lock for Rx packets */
  378. spinlock_t rx_pkt_lock;
  379. #define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
  380. u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
  381. u32 assoc_rsp_size;
  382. #define MWIFIEX_GENIE_BUF_SIZE 256
  383. u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
  384. u8 gen_ie_buf_len;
  385. struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
  386. #define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
  387. u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
  388. u8 assoc_tlv_buf_len;
  389. u8 *curr_bcn_buf;
  390. u32 curr_bcn_size;
  391. /* spin lock for beacon buffer */
  392. spinlock_t curr_bcn_buf_lock;
  393. struct wireless_dev *wdev;
  394. struct mwifiex_chan_freq_power cfp;
  395. char version_str[128];
  396. #ifdef CONFIG_DEBUG_FS
  397. struct dentry *dfs_dev_dir;
  398. #endif
  399. u8 nick_name[16];
  400. struct iw_statistics w_stats;
  401. u16 current_key_index;
  402. struct semaphore async_sem;
  403. u8 scan_pending_on_block;
  404. u8 report_scan_result;
  405. struct cfg80211_scan_request *scan_request;
  406. int scan_result_status;
  407. int assoc_request;
  408. u16 assoc_result;
  409. int ibss_join_request;
  410. u16 ibss_join_result;
  411. bool disconnect;
  412. u8 cfg_bssid[6];
  413. struct workqueue_struct *workqueue;
  414. struct work_struct cfg_workqueue;
  415. u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
  416. struct wps wps;
  417. u8 scan_block;
  418. };
  419. enum mwifiex_ba_status {
  420. BA_STREAM_NOT_SETUP = 0,
  421. BA_STREAM_SETUP_INPROGRESS,
  422. BA_STREAM_SETUP_COMPLETE
  423. };
  424. struct mwifiex_tx_ba_stream_tbl {
  425. struct list_head list;
  426. int tid;
  427. u8 ra[ETH_ALEN];
  428. enum mwifiex_ba_status ba_status;
  429. };
  430. struct mwifiex_rx_reorder_tbl;
  431. struct reorder_tmr_cnxt {
  432. struct timer_list timer;
  433. struct mwifiex_rx_reorder_tbl *ptr;
  434. struct mwifiex_private *priv;
  435. };
  436. struct mwifiex_rx_reorder_tbl {
  437. struct list_head list;
  438. int tid;
  439. u8 ta[ETH_ALEN];
  440. int start_win;
  441. int win_size;
  442. void **rx_reorder_ptr;
  443. struct reorder_tmr_cnxt timer_context;
  444. };
  445. struct mwifiex_bss_prio_node {
  446. struct list_head list;
  447. struct mwifiex_private *priv;
  448. };
  449. struct mwifiex_bss_prio_tbl {
  450. struct list_head bss_prio_head;
  451. /* spin lock for bss priority */
  452. spinlock_t bss_prio_lock;
  453. struct mwifiex_bss_prio_node *bss_prio_cur;
  454. };
  455. struct cmd_ctrl_node {
  456. struct list_head list;
  457. struct mwifiex_private *priv;
  458. u32 cmd_oid;
  459. u32 cmd_flag;
  460. struct sk_buff *cmd_skb;
  461. struct sk_buff *resp_skb;
  462. void *data_buf;
  463. u32 wait_q_enabled;
  464. struct sk_buff *skb;
  465. };
  466. struct mwifiex_if_ops {
  467. int (*init_if) (struct mwifiex_adapter *);
  468. void (*cleanup_if) (struct mwifiex_adapter *);
  469. int (*check_fw_status) (struct mwifiex_adapter *, u32, int *);
  470. int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
  471. int (*register_dev) (struct mwifiex_adapter *);
  472. void (*unregister_dev) (struct mwifiex_adapter *);
  473. int (*enable_int) (struct mwifiex_adapter *);
  474. int (*process_int_status) (struct mwifiex_adapter *);
  475. int (*host_to_card) (struct mwifiex_adapter *, u8,
  476. u8 *payload, u32 pkt_len,
  477. struct mwifiex_tx_param *);
  478. int (*wakeup) (struct mwifiex_adapter *);
  479. int (*wakeup_complete) (struct mwifiex_adapter *);
  480. void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
  481. void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
  482. };
  483. struct mwifiex_adapter {
  484. struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
  485. u8 priv_num;
  486. struct mwifiex_drv_mode *drv_mode;
  487. const struct firmware *firmware;
  488. char fw_name[32];
  489. struct device *dev;
  490. bool surprise_removed;
  491. u32 fw_release_number;
  492. u16 init_wait_q_woken;
  493. wait_queue_head_t init_wait_q;
  494. void *card;
  495. struct mwifiex_if_ops if_ops;
  496. atomic_t rx_pending;
  497. atomic_t tx_pending;
  498. atomic_t cmd_pending;
  499. struct workqueue_struct *workqueue;
  500. struct work_struct main_work;
  501. struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
  502. /* spin lock for init/shutdown */
  503. spinlock_t mwifiex_lock;
  504. /* spin lock for main process */
  505. spinlock_t main_proc_lock;
  506. u32 mwifiex_processing;
  507. u16 max_tx_buf_size;
  508. u16 tx_buf_size;
  509. u16 curr_tx_buf_size;
  510. u32 ioport;
  511. enum MWIFIEX_HARDWARE_STATUS hw_status;
  512. u16 number_of_antenna;
  513. u32 fw_cap_info;
  514. /* spin lock for interrupt handling */
  515. spinlock_t int_lock;
  516. u8 int_status;
  517. u32 event_cause;
  518. struct sk_buff *event_skb;
  519. u8 upld_buf[MWIFIEX_UPLD_SIZE];
  520. u8 data_sent;
  521. u8 cmd_sent;
  522. u8 cmd_resp_received;
  523. u8 event_received;
  524. u8 data_received;
  525. u16 seq_num;
  526. struct cmd_ctrl_node *cmd_pool;
  527. struct cmd_ctrl_node *curr_cmd;
  528. /* spin lock for command */
  529. spinlock_t mwifiex_cmd_lock;
  530. u32 num_cmd_timeout;
  531. u16 last_init_cmd;
  532. struct timer_list cmd_timer;
  533. struct list_head cmd_free_q;
  534. /* spin lock for cmd_free_q */
  535. spinlock_t cmd_free_q_lock;
  536. struct list_head cmd_pending_q;
  537. /* spin lock for cmd_pending_q */
  538. spinlock_t cmd_pending_q_lock;
  539. struct list_head scan_pending_q;
  540. /* spin lock for scan_pending_q */
  541. spinlock_t scan_pending_q_lock;
  542. u32 scan_processing;
  543. u16 region_code;
  544. struct mwifiex_802_11d_domain_reg domain_reg;
  545. struct mwifiex_bssdescriptor *scan_table;
  546. u32 num_in_scan_table;
  547. u16 scan_probes;
  548. u32 scan_mode;
  549. u16 specific_scan_time;
  550. u16 active_scan_time;
  551. u16 passive_scan_time;
  552. u8 bcn_buf[MAX_SCAN_BEACON_BUFFER];
  553. u8 *bcn_buf_end;
  554. u8 fw_bands;
  555. u8 adhoc_start_band;
  556. u8 config_bands;
  557. struct mwifiex_chan_scan_param_set *scan_channels;
  558. u8 tx_lock_flag;
  559. struct mwifiex_sleep_params sleep_params;
  560. struct mwifiex_sleep_period sleep_period;
  561. u16 ps_mode;
  562. u32 ps_state;
  563. u8 need_to_wakeup;
  564. u16 multiple_dtim;
  565. u16 local_listen_interval;
  566. u16 null_pkt_interval;
  567. struct sk_buff *sleep_cfm;
  568. u16 bcn_miss_time_out;
  569. u16 adhoc_awake_period;
  570. u8 is_deep_sleep;
  571. u8 delay_null_pkt;
  572. u16 delay_to_ps;
  573. u16 enhanced_ps_mode;
  574. u8 pm_wakeup_card_req;
  575. u16 gen_null_pkt;
  576. u16 pps_uapsd_mode;
  577. u32 pm_wakeup_fw_try;
  578. u8 is_hs_configured;
  579. struct mwifiex_hs_config_param hs_cfg;
  580. u8 hs_activated;
  581. u16 hs_activate_wait_q_woken;
  582. wait_queue_head_t hs_activate_wait_q;
  583. bool is_suspended;
  584. u8 event_body[MAX_EVENT_SIZE];
  585. u32 hw_dot_11n_dev_cap;
  586. u8 hw_dev_mcs_support;
  587. u8 adhoc_11n_enabled;
  588. u8 chan_offset;
  589. struct mwifiex_dbg dbg;
  590. u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
  591. u32 arp_filter_size;
  592. u16 cmd_wait_q_required;
  593. struct mwifiex_wait_queue cmd_wait_q;
  594. };
  595. int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
  596. void mwifiex_free_lock_list(struct mwifiex_adapter *adapter);
  597. int mwifiex_init_fw(struct mwifiex_adapter *adapter);
  598. int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
  599. int mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
  600. int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
  601. int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
  602. int mwifiex_recv_packet(struct mwifiex_adapter *, struct sk_buff *skb);
  603. int mwifiex_process_event(struct mwifiex_adapter *adapter);
  604. int mwifiex_complete_cmd(struct mwifiex_adapter *adapter);
  605. int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no,
  606. u16 cmd_action, u32 cmd_oid, void *data_buf);
  607. int mwifiex_send_cmd_sync(struct mwifiex_private *priv, uint16_t cmd_no,
  608. u16 cmd_action, u32 cmd_oid, void *data_buf);
  609. void mwifiex_cmd_timeout_func(unsigned long function_context);
  610. int mwifiex_get_debug_info(struct mwifiex_private *,
  611. struct mwifiex_debug_info *);
  612. int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
  613. int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
  614. void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
  615. void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
  616. void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
  617. struct cmd_ctrl_node *cmd_node);
  618. void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
  619. struct cmd_ctrl_node *cmd_node,
  620. u32 addtail);
  621. int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
  622. int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
  623. int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
  624. struct sk_buff *skb);
  625. int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
  626. struct mwifiex_tx_param *tx_param);
  627. int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
  628. int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
  629. struct sk_buff *skb, int status);
  630. int mwifiex_recv_packet_complete(struct mwifiex_adapter *,
  631. struct sk_buff *skb, int status);
  632. void mwifiex_clean_txrx(struct mwifiex_private *priv);
  633. u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
  634. void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
  635. void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
  636. u32);
  637. int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
  638. struct host_cmd_ds_command *cmd,
  639. u16 cmd_action, uint16_t ps_bitmap,
  640. struct mwifiex_ds_auto_ds *auto_ds);
  641. int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
  642. struct host_cmd_ds_command *resp,
  643. struct mwifiex_ds_pm_cfg *pm_cfg);
  644. void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
  645. void mwifiex_hs_activated_event(struct mwifiex_private *priv,
  646. u8 activated);
  647. int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
  648. struct host_cmd_ds_command *resp);
  649. int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter,
  650. struct sk_buff *skb);
  651. int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
  652. u16 cmd_action, u32 cmd_oid,
  653. void *data_buf, void *cmd_buf);
  654. int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
  655. struct host_cmd_ds_command *resp);
  656. int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *,
  657. struct sk_buff *skb);
  658. int mwifiex_process_sta_event(struct mwifiex_private *);
  659. void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
  660. int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
  661. int mwifiex_scan_networks(struct mwifiex_private *priv,
  662. const struct mwifiex_user_scan_cfg *user_scan_in);
  663. int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
  664. struct mwifiex_scan_cmd_config *scan_cfg);
  665. void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
  666. struct cmd_ctrl_node *cmd_node);
  667. int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
  668. struct host_cmd_ds_command *resp);
  669. s32 mwifiex_find_ssid_in_list(struct mwifiex_private *priv,
  670. struct mwifiex_802_11_ssid *ssid, u8 *bssid,
  671. u32 mode);
  672. s32 mwifiex_find_bssid_in_list(struct mwifiex_private *priv, u8 *bssid,
  673. u32 mode);
  674. int mwifiex_find_best_network(struct mwifiex_private *priv,
  675. struct mwifiex_ssid_bssid *req_ssid_bssid);
  676. s32 mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
  677. struct mwifiex_802_11_ssid *ssid2);
  678. int mwifiex_associate(struct mwifiex_private *priv,
  679. struct mwifiex_bssdescriptor *bss_desc);
  680. int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
  681. struct host_cmd_ds_command *cmd,
  682. struct mwifiex_bssdescriptor *bss_desc);
  683. int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
  684. struct host_cmd_ds_command *resp);
  685. void mwifiex_reset_connect_state(struct mwifiex_private *priv);
  686. void mwifiex_2040_coex_event(struct mwifiex_private *priv);
  687. u8 mwifiex_band_to_radio_type(u8 band);
  688. int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
  689. int mwifiex_adhoc_start(struct mwifiex_private *priv,
  690. struct mwifiex_802_11_ssid *adhoc_ssid);
  691. int mwifiex_adhoc_join(struct mwifiex_private *priv,
  692. struct mwifiex_bssdescriptor *bss_desc);
  693. int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
  694. struct host_cmd_ds_command *cmd,
  695. struct mwifiex_802_11_ssid *req_ssid);
  696. int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
  697. struct host_cmd_ds_command *cmd,
  698. struct mwifiex_bssdescriptor *bss_desc);
  699. int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
  700. struct host_cmd_ds_command *resp);
  701. int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
  702. struct mwifiex_chan_freq_power *
  703. mwifiex_get_cfp_by_band_and_channel_from_cfg80211(
  704. struct mwifiex_private *priv,
  705. u8 band, u16 channel);
  706. struct mwifiex_chan_freq_power *mwifiex_get_cfp_by_band_and_freq_from_cfg80211(
  707. struct mwifiex_private *priv,
  708. u8 band, u32 freq);
  709. u32 mwifiex_index_to_data_rate(u8 index, u8 ht_info);
  710. u32 mwifiex_find_freq_from_band_chan(u8, u8);
  711. int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
  712. u8 **buffer);
  713. u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
  714. u8 *rates);
  715. u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
  716. u8 mwifiex_data_rate_to_index(u32 rate);
  717. u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
  718. int mwifiex_get_rate_index(u16 *rateBitmap, int size);
  719. extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
  720. void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
  721. void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
  722. int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
  723. struct host_cmd_ds_command *cmd);
  724. int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
  725. struct host_cmd_ds_command *resp);
  726. int is_command_pending(struct mwifiex_adapter *adapter);
  727. /*
  728. * This function checks if the queuing is RA based or not.
  729. */
  730. static inline u8
  731. mwifiex_queuing_ra_based(struct mwifiex_private *priv)
  732. {
  733. /*
  734. * Currently we assume if we are in Infra, then DA=RA. This might not be
  735. * true in the future
  736. */
  737. if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
  738. (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
  739. return false;
  740. return true;
  741. }
  742. /*
  743. * This function copies rates.
  744. */
  745. static inline u32
  746. mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
  747. {
  748. int i;
  749. for (i = 0; i < len && src[i]; i++, pos++) {
  750. if (pos >= MWIFIEX_SUPPORTED_RATES)
  751. break;
  752. dest[pos] = src[i];
  753. }
  754. return pos;
  755. }
  756. /*
  757. * This function returns the correct private structure pointer based
  758. * upon the BSS type and BSS number.
  759. */
  760. static inline struct mwifiex_private *
  761. mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
  762. u8 bss_num, u8 bss_type)
  763. {
  764. int i;
  765. for (i = 0; i < adapter->priv_num; i++) {
  766. if (adapter->priv[i]) {
  767. if ((adapter->priv[i]->bss_num == bss_num)
  768. && (adapter->priv[i]->bss_type == bss_type))
  769. break;
  770. }
  771. }
  772. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  773. }
  774. /*
  775. * This function returns the first available private structure pointer
  776. * based upon the BSS role.
  777. */
  778. static inline struct mwifiex_private *
  779. mwifiex_get_priv(struct mwifiex_adapter *adapter,
  780. enum mwifiex_bss_role bss_role)
  781. {
  782. int i;
  783. for (i = 0; i < adapter->priv_num; i++) {
  784. if (adapter->priv[i]) {
  785. if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
  786. GET_BSS_ROLE(adapter->priv[i]) == bss_role)
  787. break;
  788. }
  789. }
  790. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  791. }
  792. /*
  793. * This function returns the driver private structure of a network device.
  794. */
  795. static inline struct mwifiex_private *
  796. mwifiex_netdev_get_priv(struct net_device *dev)
  797. {
  798. return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
  799. }
  800. struct mwifiex_private *mwifiex_bss_index_to_priv(struct mwifiex_adapter
  801. *adapter, u8 bss_index);
  802. int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
  803. u32 func_init_shutdown);
  804. int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *);
  805. int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
  806. void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
  807. int maxlen);
  808. int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
  809. struct mwifiex_multicast_list *mcast_list);
  810. int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
  811. struct net_device *dev);
  812. int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter);
  813. int mwifiex_bss_start(struct mwifiex_private *priv,
  814. struct mwifiex_ssid_bssid *ssid_bssid);
  815. int mwifiex_set_hs_params(struct mwifiex_private *priv,
  816. u16 action, int cmd_type,
  817. struct mwifiex_ds_hs_cfg *hscfg);
  818. int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
  819. int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
  820. int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
  821. int mwifiex_get_signal_info(struct mwifiex_private *priv,
  822. struct mwifiex_ds_get_signal *signal);
  823. int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
  824. struct mwifiex_rate_cfg *rate);
  825. int mwifiex_find_best_bss(struct mwifiex_private *priv,
  826. struct mwifiex_ssid_bssid *ssid_bssid);
  827. int mwifiex_request_scan(struct mwifiex_private *priv,
  828. struct mwifiex_802_11_ssid *req_ssid);
  829. int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
  830. struct mwifiex_user_scan_cfg *scan_req);
  831. int mwifiex_change_adhoc_chan(struct mwifiex_private *priv, int channel);
  832. int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
  833. int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel);
  834. int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
  835. int key_len, u8 key_index, int disable);
  836. int mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len);
  837. int mwifiex_get_ver_ext(struct mwifiex_private *priv);
  838. int mwifiex_get_stats_info(struct mwifiex_private *priv,
  839. struct mwifiex_ds_get_stats *log);
  840. int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
  841. u32 reg_offset, u32 reg_value);
  842. int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
  843. u32 reg_offset, u32 *value);
  844. int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
  845. u8 *value);
  846. int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
  847. int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
  848. int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
  849. int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
  850. int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
  851. int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
  852. char *version, int max_len);
  853. int mwifiex_set_tx_power(struct mwifiex_private *priv,
  854. struct mwifiex_power_cfg *power_cfg);
  855. int mwifiex_main_process(struct mwifiex_adapter *);
  856. int mwifiex_bss_set_channel(struct mwifiex_private *,
  857. struct mwifiex_chan_freq_power *cfp);
  858. int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *,
  859. struct mwifiex_ssid_bssid *);
  860. int mwifiex_set_radio_band_cfg(struct mwifiex_private *,
  861. struct mwifiex_ds_band_cfg *);
  862. int mwifiex_get_bss_info(struct mwifiex_private *,
  863. struct mwifiex_bss_info *);
  864. #ifdef CONFIG_DEBUG_FS
  865. void mwifiex_debugfs_init(void);
  866. void mwifiex_debugfs_remove(void);
  867. void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
  868. void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
  869. #endif
  870. #endif /* !_MWIFIEX_MAIN_H_ */