main.h 29 KB

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