main.h 30 KB

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