main.h 30 KB

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