main.h 28 KB

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