main.h 28 KB

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