main.h 29 KB

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