main.h 28 KB

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