main.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  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. /* Number of transmit packets queued */
  173. atomic_t tx_pkts_queued;
  174. };
  175. struct mwifiex_802_11_security {
  176. u8 wpa_enabled;
  177. u8 wpa2_enabled;
  178. u8 wapi_enabled;
  179. u8 wapi_key_on;
  180. enum MWIFIEX_802_11_WEP_STATUS wep_status;
  181. u32 authentication_mode;
  182. u32 encryption_mode;
  183. };
  184. struct ieee_types_header {
  185. u8 element_id;
  186. u8 len;
  187. } __packed;
  188. struct ieee_obss_scan_param {
  189. u16 obss_scan_passive_dwell;
  190. u16 obss_scan_active_dwell;
  191. u16 bss_chan_width_trigger_scan_int;
  192. u16 obss_scan_passive_total;
  193. u16 obss_scan_active_total;
  194. u16 bss_width_chan_trans_delay;
  195. u16 obss_scan_active_threshold;
  196. } __packed;
  197. struct ieee_types_obss_scan_param {
  198. struct ieee_types_header ieee_hdr;
  199. struct ieee_obss_scan_param obss_scan;
  200. } __packed;
  201. #define MWIFIEX_SUPPORTED_RATES 14
  202. #define MWIFIEX_SUPPORTED_RATES_EXT 32
  203. #define IEEE_MAX_IE_SIZE 256
  204. struct ieee_types_vendor_specific {
  205. struct ieee_types_vendor_header vend_hdr;
  206. u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_vendor_header)];
  207. } __packed;
  208. struct ieee_types_generic {
  209. struct ieee_types_header ieee_hdr;
  210. u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)];
  211. } __packed;
  212. struct mwifiex_bssdescriptor {
  213. u8 mac_address[ETH_ALEN];
  214. struct mwifiex_802_11_ssid ssid;
  215. u32 privacy;
  216. s32 rssi;
  217. u32 channel;
  218. u32 freq;
  219. u16 beacon_period;
  220. u8 erp_flags;
  221. u32 bss_mode;
  222. u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
  223. u8 data_rates[MWIFIEX_SUPPORTED_RATES];
  224. /* Network band.
  225. * BAND_B(0x01): 'b' band
  226. * BAND_G(0x02): 'g' band
  227. * BAND_A(0X04): 'a' band
  228. */
  229. u16 bss_band;
  230. u64 network_tsf;
  231. u8 time_stamp[8];
  232. union ieee_types_phy_param_set phy_param_set;
  233. union ieee_types_ss_param_set ss_param_set;
  234. u16 cap_info_bitmap;
  235. struct ieee_types_wmm_parameter wmm_ie;
  236. u8 disable_11n;
  237. struct ieee80211_ht_cap *bcn_ht_cap;
  238. u16 ht_cap_offset;
  239. struct ieee80211_ht_info *bcn_ht_info;
  240. u16 ht_info_offset;
  241. u8 *bcn_bss_co_2040;
  242. u16 bss_co_2040_offset;
  243. u8 *bcn_ext_cap;
  244. u16 ext_cap_offset;
  245. struct ieee_types_obss_scan_param *bcn_obss_scan;
  246. u16 overlap_bss_offset;
  247. struct ieee_types_vendor_specific *bcn_wpa_ie;
  248. u16 wpa_offset;
  249. struct ieee_types_generic *bcn_rsn_ie;
  250. u16 rsn_offset;
  251. struct ieee_types_generic *bcn_wapi_ie;
  252. u16 wapi_offset;
  253. u8 *beacon_buf;
  254. u32 beacon_buf_size;
  255. u32 beacon_buf_size_max;
  256. };
  257. struct mwifiex_current_bss_params {
  258. struct mwifiex_bssdescriptor bss_descriptor;
  259. u8 wmm_enabled;
  260. u8 wmm_uapsd_enabled;
  261. u8 band;
  262. u32 num_of_rates;
  263. u8 data_rates[MWIFIEX_SUPPORTED_RATES];
  264. };
  265. struct mwifiex_sleep_params {
  266. u16 sp_error;
  267. u16 sp_offset;
  268. u16 sp_stable_time;
  269. u8 sp_cal_control;
  270. u8 sp_ext_sleep_clk;
  271. u16 sp_reserved;
  272. };
  273. struct mwifiex_sleep_period {
  274. u16 period;
  275. u16 reserved;
  276. };
  277. struct mwifiex_wep_key {
  278. u32 length;
  279. u32 key_index;
  280. u32 key_length;
  281. u8 key_material[MWIFIEX_KEY_BUFFER_SIZE];
  282. };
  283. #define MAX_REGION_CHANNEL_NUM 2
  284. struct mwifiex_chan_freq_power {
  285. u16 channel;
  286. u32 freq;
  287. u16 max_tx_power;
  288. u8 unsupported;
  289. };
  290. enum state_11d_t {
  291. DISABLE_11D = 0,
  292. ENABLE_11D = 1,
  293. };
  294. #define MWIFIEX_MAX_TRIPLET_802_11D 83
  295. struct mwifiex_802_11d_domain_reg {
  296. u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
  297. u8 no_of_triplet;
  298. struct ieee80211_country_ie_triplet
  299. triplet[MWIFIEX_MAX_TRIPLET_802_11D];
  300. };
  301. struct mwifiex_vendor_spec_cfg_ie {
  302. u16 mask;
  303. u16 flag;
  304. u8 ie[MWIFIEX_MAX_VSIE_LEN];
  305. };
  306. struct wps {
  307. u8 session_enable;
  308. };
  309. struct mwifiex_adapter;
  310. struct mwifiex_private;
  311. struct mwifiex_private {
  312. struct mwifiex_adapter *adapter;
  313. u8 bss_index;
  314. u8 bss_type;
  315. u8 bss_role;
  316. u8 bss_priority;
  317. u8 bss_num;
  318. u8 frame_type;
  319. u8 curr_addr[ETH_ALEN];
  320. u8 media_connected;
  321. u32 num_tx_timeout;
  322. struct net_device *netdev;
  323. struct net_device_stats stats;
  324. u16 curr_pkt_filter;
  325. u32 bss_mode;
  326. u32 pkt_tx_ctrl;
  327. u16 tx_power_level;
  328. u8 max_tx_power_level;
  329. u8 min_tx_power_level;
  330. u8 tx_rate;
  331. u8 tx_htinfo;
  332. u8 rxpd_htinfo;
  333. u8 rxpd_rate;
  334. u16 rate_bitmap;
  335. u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
  336. u32 data_rate;
  337. u8 is_data_rate_auto;
  338. u16 bcn_avg_factor;
  339. u16 data_avg_factor;
  340. s16 data_rssi_last;
  341. s16 data_nf_last;
  342. s16 data_rssi_avg;
  343. s16 data_nf_avg;
  344. s16 bcn_rssi_last;
  345. s16 bcn_nf_last;
  346. s16 bcn_rssi_avg;
  347. s16 bcn_nf_avg;
  348. struct mwifiex_bssdescriptor *attempted_bss_desc;
  349. struct mwifiex_802_11_ssid prev_ssid;
  350. u8 prev_bssid[ETH_ALEN];
  351. struct mwifiex_current_bss_params curr_bss_params;
  352. u16 beacon_period;
  353. u16 listen_interval;
  354. u16 atim_window;
  355. u8 adhoc_channel;
  356. u8 adhoc_is_link_sensed;
  357. u8 adhoc_state;
  358. struct mwifiex_802_11_security sec_info;
  359. struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
  360. u16 wep_key_curr_index;
  361. u8 wpa_ie[256];
  362. u8 wpa_ie_len;
  363. u8 wpa_is_gtk_set;
  364. struct host_cmd_ds_802_11_key_material aes_key;
  365. u8 wapi_ie[256];
  366. u8 wapi_ie_len;
  367. u8 wmm_required;
  368. u8 wmm_enabled;
  369. u8 wmm_qosinfo;
  370. struct mwifiex_wmm_desc wmm;
  371. struct list_head tx_ba_stream_tbl_ptr;
  372. /* spin lock for tx_ba_stream_tbl_ptr queue */
  373. spinlock_t tx_ba_stream_tbl_lock;
  374. struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
  375. struct mwifiex_add_ba_param add_ba_param;
  376. u16 rx_seq[MAX_NUM_TID];
  377. struct list_head rx_reorder_tbl_ptr;
  378. /* spin lock for rx_reorder_tbl_ptr queue */
  379. spinlock_t rx_reorder_tbl_lock;
  380. /* spin lock for Rx packets */
  381. spinlock_t rx_pkt_lock;
  382. #define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
  383. u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
  384. u32 assoc_rsp_size;
  385. #define MWIFIEX_GENIE_BUF_SIZE 256
  386. u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
  387. u8 gen_ie_buf_len;
  388. struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
  389. #define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
  390. u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
  391. u8 assoc_tlv_buf_len;
  392. u8 *curr_bcn_buf;
  393. u32 curr_bcn_size;
  394. /* spin lock for beacon buffer */
  395. spinlock_t curr_bcn_buf_lock;
  396. struct wireless_dev *wdev;
  397. struct mwifiex_chan_freq_power cfp;
  398. char version_str[128];
  399. #ifdef CONFIG_DEBUG_FS
  400. struct dentry *dfs_dev_dir;
  401. #endif
  402. u8 nick_name[16];
  403. struct iw_statistics w_stats;
  404. u16 current_key_index;
  405. struct semaphore async_sem;
  406. u8 scan_pending_on_block;
  407. u8 report_scan_result;
  408. struct cfg80211_scan_request *scan_request;
  409. int scan_result_status;
  410. int assoc_request;
  411. u16 assoc_result;
  412. int ibss_join_request;
  413. u16 ibss_join_result;
  414. bool disconnect;
  415. u8 cfg_bssid[6];
  416. struct workqueue_struct *workqueue;
  417. struct work_struct cfg_workqueue;
  418. u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
  419. struct wps wps;
  420. u8 scan_block;
  421. };
  422. enum mwifiex_ba_status {
  423. BA_STREAM_NOT_SETUP = 0,
  424. BA_STREAM_SETUP_INPROGRESS,
  425. BA_STREAM_SETUP_COMPLETE
  426. };
  427. struct mwifiex_tx_ba_stream_tbl {
  428. struct list_head list;
  429. int tid;
  430. u8 ra[ETH_ALEN];
  431. enum mwifiex_ba_status ba_status;
  432. };
  433. struct mwifiex_rx_reorder_tbl;
  434. struct reorder_tmr_cnxt {
  435. struct timer_list timer;
  436. struct mwifiex_rx_reorder_tbl *ptr;
  437. struct mwifiex_private *priv;
  438. };
  439. struct mwifiex_rx_reorder_tbl {
  440. struct list_head list;
  441. int tid;
  442. u8 ta[ETH_ALEN];
  443. int start_win;
  444. int win_size;
  445. void **rx_reorder_ptr;
  446. struct reorder_tmr_cnxt timer_context;
  447. };
  448. struct mwifiex_bss_prio_node {
  449. struct list_head list;
  450. struct mwifiex_private *priv;
  451. };
  452. struct mwifiex_bss_prio_tbl {
  453. struct list_head bss_prio_head;
  454. /* spin lock for bss priority */
  455. spinlock_t bss_prio_lock;
  456. struct mwifiex_bss_prio_node *bss_prio_cur;
  457. };
  458. struct cmd_ctrl_node {
  459. struct list_head list;
  460. struct mwifiex_private *priv;
  461. u32 cmd_oid;
  462. u32 cmd_flag;
  463. struct sk_buff *cmd_skb;
  464. struct sk_buff *resp_skb;
  465. void *data_buf;
  466. u32 wait_q_enabled;
  467. struct sk_buff *skb;
  468. };
  469. struct mwifiex_if_ops {
  470. int (*init_if) (struct mwifiex_adapter *);
  471. void (*cleanup_if) (struct mwifiex_adapter *);
  472. int (*check_fw_status) (struct mwifiex_adapter *, u32, int *);
  473. int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
  474. int (*register_dev) (struct mwifiex_adapter *);
  475. void (*unregister_dev) (struct mwifiex_adapter *);
  476. int (*enable_int) (struct mwifiex_adapter *);
  477. int (*process_int_status) (struct mwifiex_adapter *);
  478. int (*host_to_card) (struct mwifiex_adapter *, u8,
  479. u8 *payload, u32 pkt_len,
  480. struct mwifiex_tx_param *);
  481. int (*wakeup) (struct mwifiex_adapter *);
  482. int (*wakeup_complete) (struct mwifiex_adapter *);
  483. void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
  484. void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
  485. };
  486. struct mwifiex_adapter {
  487. struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
  488. u8 priv_num;
  489. struct mwifiex_drv_mode *drv_mode;
  490. const struct firmware *firmware;
  491. struct device *dev;
  492. bool surprise_removed;
  493. u32 fw_release_number;
  494. u32 revision_id;
  495. u16 init_wait_q_woken;
  496. wait_queue_head_t init_wait_q;
  497. void *card;
  498. struct mwifiex_if_ops if_ops;
  499. atomic_t rx_pending;
  500. atomic_t tx_pending;
  501. atomic_t cmd_pending;
  502. struct workqueue_struct *workqueue;
  503. struct work_struct main_work;
  504. struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
  505. /* spin lock for init/shutdown */
  506. spinlock_t mwifiex_lock;
  507. /* spin lock for main process */
  508. spinlock_t main_proc_lock;
  509. u32 mwifiex_processing;
  510. u16 max_tx_buf_size;
  511. u16 tx_buf_size;
  512. u16 curr_tx_buf_size;
  513. u32 ioport;
  514. enum MWIFIEX_HARDWARE_STATUS hw_status;
  515. u16 number_of_antenna;
  516. u32 fw_cap_info;
  517. /* spin lock for interrupt handling */
  518. spinlock_t int_lock;
  519. u8 int_status;
  520. u32 event_cause;
  521. struct sk_buff *event_skb;
  522. u8 upld_buf[MWIFIEX_UPLD_SIZE];
  523. u8 data_sent;
  524. u8 cmd_sent;
  525. u8 cmd_resp_received;
  526. u8 event_received;
  527. u8 data_received;
  528. u16 seq_num;
  529. struct cmd_ctrl_node *cmd_pool;
  530. struct cmd_ctrl_node *curr_cmd;
  531. /* spin lock for command */
  532. spinlock_t mwifiex_cmd_lock;
  533. u32 num_cmd_timeout;
  534. u16 last_init_cmd;
  535. struct timer_list cmd_timer;
  536. struct list_head cmd_free_q;
  537. /* spin lock for cmd_free_q */
  538. spinlock_t cmd_free_q_lock;
  539. struct list_head cmd_pending_q;
  540. /* spin lock for cmd_pending_q */
  541. spinlock_t cmd_pending_q_lock;
  542. struct list_head scan_pending_q;
  543. /* spin lock for scan_pending_q */
  544. spinlock_t scan_pending_q_lock;
  545. u32 scan_processing;
  546. u16 region_code;
  547. struct mwifiex_802_11d_domain_reg domain_reg;
  548. struct mwifiex_bssdescriptor *scan_table;
  549. u32 num_in_scan_table;
  550. u16 scan_probes;
  551. u32 scan_mode;
  552. u16 specific_scan_time;
  553. u16 active_scan_time;
  554. u16 passive_scan_time;
  555. u8 bcn_buf[MAX_SCAN_BEACON_BUFFER];
  556. u8 *bcn_buf_end;
  557. u8 fw_bands;
  558. u8 adhoc_start_band;
  559. u8 config_bands;
  560. struct mwifiex_chan_scan_param_set *scan_channels;
  561. u8 tx_lock_flag;
  562. struct mwifiex_sleep_params sleep_params;
  563. struct mwifiex_sleep_period sleep_period;
  564. u16 ps_mode;
  565. u32 ps_state;
  566. u8 need_to_wakeup;
  567. u16 multiple_dtim;
  568. u16 local_listen_interval;
  569. u16 null_pkt_interval;
  570. struct sk_buff *sleep_cfm;
  571. u16 bcn_miss_time_out;
  572. u16 adhoc_awake_period;
  573. u8 is_deep_sleep;
  574. u8 delay_null_pkt;
  575. u16 delay_to_ps;
  576. u16 enhanced_ps_mode;
  577. u8 pm_wakeup_card_req;
  578. u16 gen_null_pkt;
  579. u16 pps_uapsd_mode;
  580. u32 pm_wakeup_fw_try;
  581. u8 is_hs_configured;
  582. struct mwifiex_hs_config_param hs_cfg;
  583. u8 hs_activated;
  584. u16 hs_activate_wait_q_woken;
  585. wait_queue_head_t hs_activate_wait_q;
  586. bool is_suspended;
  587. u8 event_body[MAX_EVENT_SIZE];
  588. u32 hw_dot_11n_dev_cap;
  589. u8 hw_dev_mcs_support;
  590. u8 adhoc_11n_enabled;
  591. u8 chan_offset;
  592. struct mwifiex_dbg dbg;
  593. u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
  594. u32 arp_filter_size;
  595. u16 cmd_wait_q_required;
  596. struct mwifiex_wait_queue cmd_wait_q;
  597. };
  598. int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
  599. void mwifiex_free_lock_list(struct mwifiex_adapter *adapter);
  600. int mwifiex_init_fw(struct mwifiex_adapter *adapter);
  601. int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
  602. int mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
  603. int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
  604. int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
  605. int mwifiex_recv_packet(struct mwifiex_adapter *, struct sk_buff *skb);
  606. int mwifiex_process_event(struct mwifiex_adapter *adapter);
  607. int mwifiex_complete_cmd(struct mwifiex_adapter *adapter);
  608. int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no,
  609. u16 cmd_action, u32 cmd_oid, void *data_buf);
  610. int mwifiex_send_cmd_sync(struct mwifiex_private *priv, uint16_t cmd_no,
  611. u16 cmd_action, u32 cmd_oid, void *data_buf);
  612. void mwifiex_cmd_timeout_func(unsigned long function_context);
  613. int mwifiex_get_debug_info(struct mwifiex_private *,
  614. struct mwifiex_debug_info *);
  615. int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
  616. int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
  617. void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
  618. void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
  619. void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
  620. struct cmd_ctrl_node *cmd_node);
  621. void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
  622. struct cmd_ctrl_node *cmd_node,
  623. u32 addtail);
  624. int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
  625. int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
  626. int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
  627. struct sk_buff *skb);
  628. int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
  629. struct mwifiex_tx_param *tx_param);
  630. int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
  631. int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
  632. struct sk_buff *skb, int status);
  633. int mwifiex_recv_packet_complete(struct mwifiex_adapter *,
  634. struct sk_buff *skb, int status);
  635. void mwifiex_clean_txrx(struct mwifiex_private *priv);
  636. u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
  637. void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
  638. void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
  639. u32);
  640. int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
  641. struct host_cmd_ds_command *cmd,
  642. u16 cmd_action, uint16_t ps_bitmap,
  643. void *data_buf);
  644. int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
  645. struct host_cmd_ds_command *resp,
  646. void *data_buf);
  647. void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
  648. void mwifiex_hs_activated_event(struct mwifiex_private *priv,
  649. u8 activated);
  650. int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
  651. struct host_cmd_ds_command *resp);
  652. int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter,
  653. struct sk_buff *skb);
  654. int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
  655. u16 cmd_action, u32 cmd_oid,
  656. void *data_buf, void *cmd_buf);
  657. int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
  658. void *cmd_buf);
  659. int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *,
  660. struct sk_buff *skb);
  661. int mwifiex_process_sta_event(struct mwifiex_private *);
  662. void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
  663. int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
  664. int mwifiex_scan_networks(struct mwifiex_private *priv,
  665. const struct mwifiex_user_scan_cfg *user_scan_in);
  666. int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
  667. void *data_buf);
  668. void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
  669. struct cmd_ctrl_node *cmd_node);
  670. int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
  671. struct host_cmd_ds_command *resp);
  672. s32 mwifiex_find_ssid_in_list(struct mwifiex_private *priv,
  673. struct mwifiex_802_11_ssid *ssid, u8 *bssid,
  674. u32 mode);
  675. s32 mwifiex_find_bssid_in_list(struct mwifiex_private *priv, u8 *bssid,
  676. u32 mode);
  677. int mwifiex_find_best_network(struct mwifiex_private *priv,
  678. struct mwifiex_ssid_bssid *req_ssid_bssid);
  679. s32 mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
  680. struct mwifiex_802_11_ssid *ssid2);
  681. int mwifiex_associate(struct mwifiex_private *priv,
  682. struct mwifiex_bssdescriptor *bss_desc);
  683. int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
  684. struct host_cmd_ds_command
  685. *cmd, void *data_buf);
  686. int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
  687. struct host_cmd_ds_command *resp);
  688. void mwifiex_reset_connect_state(struct mwifiex_private *priv);
  689. void mwifiex_2040_coex_event(struct mwifiex_private *priv);
  690. u8 mwifiex_band_to_radio_type(u8 band);
  691. int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
  692. int mwifiex_adhoc_start(struct mwifiex_private *priv,
  693. struct mwifiex_802_11_ssid *adhoc_ssid);
  694. int mwifiex_adhoc_join(struct mwifiex_private *priv,
  695. struct mwifiex_bssdescriptor *bss_desc);
  696. int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
  697. struct host_cmd_ds_command *cmd,
  698. void *data_buf);
  699. int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
  700. struct host_cmd_ds_command *cmd,
  701. void *data_buf);
  702. int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
  703. struct host_cmd_ds_command *resp);
  704. int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
  705. struct mwifiex_chan_freq_power *
  706. mwifiex_get_cfp_by_band_and_channel_from_cfg80211(
  707. struct mwifiex_private *priv,
  708. u8 band, u16 channel);
  709. struct mwifiex_chan_freq_power *mwifiex_get_cfp_by_band_and_freq_from_cfg80211(
  710. struct mwifiex_private *priv,
  711. u8 band, u32 freq);
  712. u32 mwifiex_index_to_data_rate(u8 index, u8 ht_info);
  713. u32 mwifiex_find_freq_from_band_chan(u8, u8);
  714. int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
  715. u8 **buffer);
  716. u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
  717. u8 *rates);
  718. u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
  719. u8 mwifiex_data_rate_to_index(u32 rate);
  720. u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
  721. int mwifiex_get_rate_index(u16 *rateBitmap, int size);
  722. extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
  723. void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
  724. void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
  725. int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
  726. struct host_cmd_ds_command *cmd);
  727. int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
  728. struct host_cmd_ds_command *resp);
  729. int is_command_pending(struct mwifiex_adapter *adapter);
  730. /*
  731. * This function checks if the queuing is RA based or not.
  732. */
  733. static inline u8
  734. mwifiex_queuing_ra_based(struct mwifiex_private *priv)
  735. {
  736. /*
  737. * Currently we assume if we are in Infra, then DA=RA. This might not be
  738. * true in the future
  739. */
  740. if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
  741. (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
  742. return false;
  743. return true;
  744. }
  745. /*
  746. * This function copies rates.
  747. */
  748. static inline u32
  749. mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
  750. {
  751. int i;
  752. for (i = 0; i < len && src[i]; i++, pos++) {
  753. if (pos >= MWIFIEX_SUPPORTED_RATES)
  754. break;
  755. dest[pos] = src[i];
  756. }
  757. return pos;
  758. }
  759. /*
  760. * This function returns the correct private structure pointer based
  761. * upon the BSS type and BSS number.
  762. */
  763. static inline struct mwifiex_private *
  764. mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
  765. u8 bss_num, u8 bss_type)
  766. {
  767. int i;
  768. for (i = 0; i < adapter->priv_num; i++) {
  769. if (adapter->priv[i]) {
  770. if ((adapter->priv[i]->bss_num == bss_num)
  771. && (adapter->priv[i]->bss_type == bss_type))
  772. break;
  773. }
  774. }
  775. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  776. }
  777. /*
  778. * This function returns the first available private structure pointer
  779. * based upon the BSS role.
  780. */
  781. static inline struct mwifiex_private *
  782. mwifiex_get_priv(struct mwifiex_adapter *adapter,
  783. enum mwifiex_bss_role bss_role)
  784. {
  785. int i;
  786. for (i = 0; i < adapter->priv_num; i++) {
  787. if (adapter->priv[i]) {
  788. if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
  789. GET_BSS_ROLE(adapter->priv[i]) == bss_role)
  790. break;
  791. }
  792. }
  793. return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
  794. }
  795. /*
  796. * This function returns the driver private structure of a network device.
  797. */
  798. static inline struct mwifiex_private *
  799. mwifiex_netdev_get_priv(struct net_device *dev)
  800. {
  801. return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
  802. }
  803. struct mwifiex_private *mwifiex_bss_index_to_priv(struct mwifiex_adapter
  804. *adapter, u8 bss_index);
  805. int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
  806. u32 func_init_shutdown);
  807. int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *);
  808. int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
  809. void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
  810. int maxlen);
  811. int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
  812. struct mwifiex_multicast_list *mcast_list);
  813. int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
  814. struct net_device *dev);
  815. int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter);
  816. int mwifiex_bss_start(struct mwifiex_private *priv,
  817. struct mwifiex_ssid_bssid *ssid_bssid);
  818. int mwifiex_set_hs_params(struct mwifiex_private *priv,
  819. u16 action, int cmd_type,
  820. struct mwifiex_ds_hs_cfg *hscfg);
  821. int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
  822. int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
  823. int mwifiex_get_signal_info(struct mwifiex_private *priv,
  824. struct mwifiex_ds_get_signal *signal);
  825. int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
  826. struct mwifiex_rate_cfg *rate);
  827. int mwifiex_find_best_bss(struct mwifiex_private *priv,
  828. struct mwifiex_ssid_bssid *ssid_bssid);
  829. int mwifiex_request_scan(struct mwifiex_private *priv,
  830. struct mwifiex_802_11_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_change_adhoc_chan(struct mwifiex_private *priv, int channel);
  834. int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
  835. int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel);
  836. int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
  837. int key_len, u8 key_index, 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_bss_set_channel(struct mwifiex_private *,
  859. struct mwifiex_chan_freq_power *cfp);
  860. int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *,
  861. struct mwifiex_ssid_bssid *);
  862. int mwifiex_set_radio_band_cfg(struct mwifiex_private *,
  863. struct mwifiex_ds_band_cfg *);
  864. int mwifiex_get_bss_info(struct mwifiex_private *,
  865. struct mwifiex_bss_info *);
  866. #ifdef CONFIG_DEBUG_FS
  867. void mwifiex_debugfs_init(void);
  868. void mwifiex_debugfs_remove(void);
  869. void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
  870. void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
  871. #endif
  872. #endif /* !_MWIFIEX_MAIN_H_ */