main.h 28 KB

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