main.h 28 KB

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