Merge tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee139...
[deliverable/linux.git] / drivers / net / wireless / mwifiex / main.h
1 /*
2 * Marvell Wireless LAN device driver: major data structures and prototypes
3 *
4 * Copyright (C) 2011-2014, 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
20 #ifndef _MWIFIEX_MAIN_H_
21 #define _MWIFIEX_MAIN_H_
22
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/sched.h>
26 #include <linux/semaphore.h>
27 #include <linux/ip.h>
28 #include <linux/skbuff.h>
29 #include <linux/if_arp.h>
30 #include <linux/etherdevice.h>
31 #include <net/sock.h>
32 #include <net/lib80211.h>
33 #include <linux/vmalloc.h>
34 #include <linux/firmware.h>
35 #include <linux/ctype.h>
36 #include <linux/of.h>
37 #include <linux/idr.h>
38
39 #include "decl.h"
40 #include "ioctl.h"
41 #include "util.h"
42 #include "fw.h"
43 #include "pcie.h"
44 #include "usb.h"
45 #include "sdio.h"
46
47 extern const char driver_version[];
48
49 enum {
50 MWIFIEX_ASYNC_CMD,
51 MWIFIEX_SYNC_CMD
52 };
53
54 #define MWIFIEX_DRIVER_MODE_STA BIT(0)
55 #define MWIFIEX_DRIVER_MODE_UAP BIT(1)
56 #define MWIFIEX_DRIVER_MODE_P2P BIT(2)
57 #define MWIFIEX_DRIVER_MODE_BITMASK (BIT(0) | BIT(1) | BIT(2))
58
59 #define MWIFIEX_MAX_AP 64
60
61 #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
62
63 #define MWIFIEX_TIMER_10S 10000
64 #define MWIFIEX_TIMER_1S 1000
65
66 #define MAX_TX_PENDING 100
67 #define LOW_TX_PENDING 80
68
69 #define HIGH_RX_PENDING 50
70 #define LOW_RX_PENDING 20
71
72 #define MWIFIEX_UPLD_SIZE (2312)
73
74 #define MAX_EVENT_SIZE 2048
75
76 #define ARP_FILTER_MAX_BUF_SIZE 68
77
78 #define MWIFIEX_KEY_BUFFER_SIZE 16
79 #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
80 #define MWIFIEX_MAX_REGION_CODE 7
81
82 #define DEFAULT_BCN_AVG_FACTOR 8
83 #define DEFAULT_DATA_AVG_FACTOR 8
84
85 #define FIRST_VALID_CHANNEL 0xff
86 #define DEFAULT_AD_HOC_CHANNEL 6
87 #define DEFAULT_AD_HOC_CHANNEL_A 36
88
89 #define DEFAULT_BCN_MISS_TIMEOUT 5
90
91 #define MAX_SCAN_BEACON_BUFFER 8000
92
93 #define SCAN_BEACON_ENTRY_PAD 6
94
95 #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
96 #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 30
97 #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 30
98 #define MWIFIEX_DEF_SCAN_CHAN_GAP_TIME 50
99
100 #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI)))
101
102 #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
103
104 #define RSN_GTK_OUI_OFFSET 2
105
106 #define MWIFIEX_OUI_NOT_PRESENT 0
107 #define MWIFIEX_OUI_PRESENT 1
108
109 #define PKT_TYPE_MGMT 0xE5
110
111 /*
112 * Do not check for data_received for USB, as data_received
113 * is handled in mwifiex_usb_recv for USB
114 */
115 #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
116 adapter->event_received || \
117 adapter->data_received)
118
119 #define MWIFIEX_TYPE_CMD 1
120 #define MWIFIEX_TYPE_DATA 0
121 #define MWIFIEX_TYPE_EVENT 3
122
123 #define MAX_BITMAP_RATES_SIZE 18
124
125 #define MAX_CHANNEL_BAND_BG 14
126 #define MAX_CHANNEL_BAND_A 165
127
128 #define MAX_FREQUENCY_BAND_BG 2484
129
130 #define MWIFIEX_EVENT_HEADER_LEN 4
131 #define MWIFIEX_UAP_EVENT_EXTRA_HEADER 2
132
133 #define MWIFIEX_TYPE_LEN 4
134 #define MWIFIEX_USB_TYPE_CMD 0xF00DFACE
135 #define MWIFIEX_USB_TYPE_DATA 0xBEADC0DE
136 #define MWIFIEX_USB_TYPE_EVENT 0xBEEFFACE
137
138 /* Threshold for tx_timeout_cnt before we trigger a card reset */
139 #define TX_TIMEOUT_THRESHOLD 6
140
141 #define MWIFIEX_DRV_INFO_SIZE_MAX 0x40000
142
143 struct mwifiex_dbg {
144 u32 num_cmd_host_to_card_failure;
145 u32 num_cmd_sleep_cfm_host_to_card_failure;
146 u32 num_tx_host_to_card_failure;
147 u32 num_event_deauth;
148 u32 num_event_disassoc;
149 u32 num_event_link_lost;
150 u32 num_cmd_deauth;
151 u32 num_cmd_assoc_success;
152 u32 num_cmd_assoc_failure;
153 u32 num_tx_timeout;
154 u16 timeout_cmd_id;
155 u16 timeout_cmd_act;
156 u16 last_cmd_id[DBG_CMD_NUM];
157 u16 last_cmd_act[DBG_CMD_NUM];
158 u16 last_cmd_index;
159 u16 last_cmd_resp_id[DBG_CMD_NUM];
160 u16 last_cmd_resp_index;
161 u16 last_event[DBG_CMD_NUM];
162 u16 last_event_index;
163 };
164
165 enum MWIFIEX_HARDWARE_STATUS {
166 MWIFIEX_HW_STATUS_READY,
167 MWIFIEX_HW_STATUS_INITIALIZING,
168 MWIFIEX_HW_STATUS_INIT_DONE,
169 MWIFIEX_HW_STATUS_RESET,
170 MWIFIEX_HW_STATUS_CLOSING,
171 MWIFIEX_HW_STATUS_NOT_READY
172 };
173
174 enum MWIFIEX_802_11_POWER_MODE {
175 MWIFIEX_802_11_POWER_MODE_CAM,
176 MWIFIEX_802_11_POWER_MODE_PSP
177 };
178
179 struct mwifiex_tx_param {
180 u32 next_pkt_len;
181 };
182
183 enum MWIFIEX_PS_STATE {
184 PS_STATE_AWAKE,
185 PS_STATE_PRE_SLEEP,
186 PS_STATE_SLEEP_CFM,
187 PS_STATE_SLEEP
188 };
189
190 enum mwifiex_iface_type {
191 MWIFIEX_SDIO,
192 MWIFIEX_PCIE,
193 MWIFIEX_USB
194 };
195
196 struct mwifiex_add_ba_param {
197 u32 tx_win_size;
198 u32 rx_win_size;
199 u32 timeout;
200 u8 tx_amsdu;
201 u8 rx_amsdu;
202 };
203
204 struct mwifiex_tx_aggr {
205 u8 ampdu_user;
206 u8 ampdu_ap;
207 u8 amsdu;
208 };
209
210 struct mwifiex_ra_list_tbl {
211 struct list_head list;
212 struct sk_buff_head skb_head;
213 u8 ra[ETH_ALEN];
214 u32 is_11n_enabled;
215 u16 max_amsdu;
216 u16 ba_pkt_count;
217 u8 ba_packet_thr;
218 u16 total_pkt_count;
219 bool tdls_link;
220 };
221
222 struct mwifiex_tid_tbl {
223 struct list_head ra_list;
224 };
225
226 #define WMM_HIGHEST_PRIORITY 7
227 #define HIGH_PRIO_TID 7
228 #define LOW_PRIO_TID 0
229
230 struct mwifiex_wmm_desc {
231 struct mwifiex_tid_tbl tid_tbl_ptr[MAX_NUM_TID];
232 u32 packets_out[MAX_NUM_TID];
233 /* spin lock to protect ra_list */
234 spinlock_t ra_list_spinlock;
235 struct mwifiex_wmm_ac_status ac_status[IEEE80211_NUM_ACS];
236 enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_NUM_ACS];
237 u32 drv_pkt_delay_max;
238 u8 queue_priority[IEEE80211_NUM_ACS];
239 u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */
240 /* Number of transmit packets queued */
241 atomic_t tx_pkts_queued;
242 /* Tracks highest priority with a packet queued */
243 atomic_t highest_queued_prio;
244 };
245
246 struct mwifiex_802_11_security {
247 u8 wpa_enabled;
248 u8 wpa2_enabled;
249 u8 wapi_enabled;
250 u8 wapi_key_on;
251 u8 wep_enabled;
252 u32 authentication_mode;
253 u8 is_authtype_auto;
254 u32 encryption_mode;
255 };
256
257 struct ieee_types_header {
258 u8 element_id;
259 u8 len;
260 } __packed;
261
262 struct ieee_types_vendor_specific {
263 struct ieee_types_vendor_header vend_hdr;
264 u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_vendor_header)];
265 } __packed;
266
267 struct ieee_types_generic {
268 struct ieee_types_header ieee_hdr;
269 u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)];
270 } __packed;
271
272 struct ieee_types_bss_co_2040 {
273 struct ieee_types_header ieee_hdr;
274 u8 bss_2040co;
275 } __packed;
276
277 struct ieee_types_extcap {
278 struct ieee_types_header ieee_hdr;
279 u8 ext_capab[8];
280 } __packed;
281
282 struct ieee_types_vht_cap {
283 struct ieee_types_header ieee_hdr;
284 struct ieee80211_vht_cap vhtcap;
285 } __packed;
286
287 struct ieee_types_vht_oper {
288 struct ieee_types_header ieee_hdr;
289 struct ieee80211_vht_operation vhtoper;
290 } __packed;
291
292 struct ieee_types_aid {
293 struct ieee_types_header ieee_hdr;
294 u16 aid;
295 } __packed;
296
297 struct mwifiex_bssdescriptor {
298 u8 mac_address[ETH_ALEN];
299 struct cfg80211_ssid ssid;
300 u32 privacy;
301 s32 rssi;
302 u32 channel;
303 u32 freq;
304 u16 beacon_period;
305 u8 erp_flags;
306 u32 bss_mode;
307 u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
308 u8 data_rates[MWIFIEX_SUPPORTED_RATES];
309 /* Network band.
310 * BAND_B(0x01): 'b' band
311 * BAND_G(0x02): 'g' band
312 * BAND_A(0X04): 'a' band
313 */
314 u16 bss_band;
315 u64 fw_tsf;
316 u64 timestamp;
317 union ieee_types_phy_param_set phy_param_set;
318 union ieee_types_ss_param_set ss_param_set;
319 u16 cap_info_bitmap;
320 struct ieee_types_wmm_parameter wmm_ie;
321 u8 disable_11n;
322 struct ieee80211_ht_cap *bcn_ht_cap;
323 u16 ht_cap_offset;
324 struct ieee80211_ht_operation *bcn_ht_oper;
325 u16 ht_info_offset;
326 u8 *bcn_bss_co_2040;
327 u16 bss_co_2040_offset;
328 u8 *bcn_ext_cap;
329 u16 ext_cap_offset;
330 struct ieee80211_vht_cap *bcn_vht_cap;
331 u16 vht_cap_offset;
332 struct ieee80211_vht_operation *bcn_vht_oper;
333 u16 vht_info_offset;
334 struct ieee_types_oper_mode_ntf *oper_mode;
335 u16 oper_mode_offset;
336 u8 disable_11ac;
337 struct ieee_types_vendor_specific *bcn_wpa_ie;
338 u16 wpa_offset;
339 struct ieee_types_generic *bcn_rsn_ie;
340 u16 rsn_offset;
341 struct ieee_types_generic *bcn_wapi_ie;
342 u16 wapi_offset;
343 u8 *beacon_buf;
344 u32 beacon_buf_size;
345 u8 sensed_11h;
346 u8 local_constraint;
347 u8 chan_sw_ie_present;
348 };
349
350 struct mwifiex_current_bss_params {
351 struct mwifiex_bssdescriptor bss_descriptor;
352 u8 wmm_enabled;
353 u8 wmm_uapsd_enabled;
354 u8 band;
355 u32 num_of_rates;
356 u8 data_rates[MWIFIEX_SUPPORTED_RATES];
357 };
358
359 struct mwifiex_sleep_params {
360 u16 sp_error;
361 u16 sp_offset;
362 u16 sp_stable_time;
363 u8 sp_cal_control;
364 u8 sp_ext_sleep_clk;
365 u16 sp_reserved;
366 };
367
368 struct mwifiex_sleep_period {
369 u16 period;
370 u16 reserved;
371 };
372
373 struct mwifiex_wep_key {
374 u32 length;
375 u32 key_index;
376 u32 key_length;
377 u8 key_material[MWIFIEX_KEY_BUFFER_SIZE];
378 };
379
380 #define MAX_REGION_CHANNEL_NUM 2
381
382 struct mwifiex_chan_freq_power {
383 u16 channel;
384 u32 freq;
385 u16 max_tx_power;
386 u8 unsupported;
387 };
388
389 enum state_11d_t {
390 DISABLE_11D = 0,
391 ENABLE_11D = 1,
392 };
393
394 #define MWIFIEX_MAX_TRIPLET_802_11D 83
395
396 struct mwifiex_802_11d_domain_reg {
397 u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
398 u8 no_of_triplet;
399 struct ieee80211_country_ie_triplet
400 triplet[MWIFIEX_MAX_TRIPLET_802_11D];
401 };
402
403 struct mwifiex_vendor_spec_cfg_ie {
404 u16 mask;
405 u16 flag;
406 u8 ie[MWIFIEX_MAX_VSIE_LEN];
407 };
408
409 struct wps {
410 u8 session_enable;
411 };
412
413 struct mwifiex_roc_cfg {
414 u64 cookie;
415 struct ieee80211_channel chan;
416 };
417
418 #define MWIFIEX_FW_DUMP_IDX 0xff
419 #define MWIFIEX_DRV_INFO_IDX 20
420 #define FW_DUMP_MAX_NAME_LEN 8
421 #define FW_DUMP_HOST_READY 0xEE
422 #define FW_DUMP_DONE 0xFF
423 #define FW_DUMP_READ_DONE 0xFE
424
425 struct memory_type_mapping {
426 u8 mem_name[FW_DUMP_MAX_NAME_LEN];
427 u8 *mem_ptr;
428 u32 mem_size;
429 u8 done_flag;
430 };
431
432 enum rdwr_status {
433 RDWR_STATUS_SUCCESS = 0,
434 RDWR_STATUS_FAILURE = 1,
435 RDWR_STATUS_DONE = 2
436 };
437
438 enum mwifiex_iface_work_flags {
439 MWIFIEX_IFACE_WORK_FW_DUMP,
440 MWIFIEX_IFACE_WORK_CARD_RESET,
441 };
442
443 struct mwifiex_adapter;
444 struct mwifiex_private;
445
446 struct mwifiex_private {
447 struct mwifiex_adapter *adapter;
448 u8 bss_type;
449 u8 bss_role;
450 u8 bss_priority;
451 u8 bss_num;
452 u8 bss_started;
453 u8 frame_type;
454 u8 curr_addr[ETH_ALEN];
455 u8 media_connected;
456 u32 num_tx_timeout;
457 /* track consecutive timeout */
458 u8 tx_timeout_cnt;
459 struct net_device *netdev;
460 struct net_device_stats stats;
461 u16 curr_pkt_filter;
462 u32 bss_mode;
463 u32 pkt_tx_ctrl;
464 u16 tx_power_level;
465 u8 max_tx_power_level;
466 u8 min_tx_power_level;
467 u8 tx_rate;
468 u8 tx_htinfo;
469 u8 rxpd_htinfo;
470 u8 rxpd_rate;
471 u16 rate_bitmap;
472 u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
473 u32 data_rate;
474 u8 is_data_rate_auto;
475 u16 bcn_avg_factor;
476 u16 data_avg_factor;
477 s16 data_rssi_last;
478 s16 data_nf_last;
479 s16 data_rssi_avg;
480 s16 data_nf_avg;
481 s16 bcn_rssi_last;
482 s16 bcn_nf_last;
483 s16 bcn_rssi_avg;
484 s16 bcn_nf_avg;
485 struct mwifiex_bssdescriptor *attempted_bss_desc;
486 struct cfg80211_ssid prev_ssid;
487 u8 prev_bssid[ETH_ALEN];
488 struct mwifiex_current_bss_params curr_bss_params;
489 u16 beacon_period;
490 u8 dtim_period;
491 u16 listen_interval;
492 u16 atim_window;
493 u8 adhoc_channel;
494 u8 adhoc_is_link_sensed;
495 u8 adhoc_state;
496 struct mwifiex_802_11_security sec_info;
497 struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
498 u16 wep_key_curr_index;
499 u8 wpa_ie[256];
500 u8 wpa_ie_len;
501 u8 wpa_is_gtk_set;
502 struct host_cmd_ds_802_11_key_material aes_key;
503 struct host_cmd_ds_802_11_key_material_v2 aes_key_v2;
504 u8 wapi_ie[256];
505 u8 wapi_ie_len;
506 u8 *wps_ie;
507 u8 wps_ie_len;
508 u8 wmm_required;
509 u8 wmm_enabled;
510 u8 wmm_qosinfo;
511 struct mwifiex_wmm_desc wmm;
512 atomic_t wmm_tx_pending[IEEE80211_NUM_ACS];
513 struct list_head sta_list;
514 /* spin lock for associated station/TDLS peers list */
515 spinlock_t sta_list_spinlock;
516 struct list_head auto_tdls_list;
517 /* spin lock for auto TDLS peer list */
518 spinlock_t auto_tdls_lock;
519 struct list_head tx_ba_stream_tbl_ptr;
520 /* spin lock for tx_ba_stream_tbl_ptr queue */
521 spinlock_t tx_ba_stream_tbl_lock;
522 struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
523 struct mwifiex_add_ba_param add_ba_param;
524 u16 rx_seq[MAX_NUM_TID];
525 u8 tos_to_tid_inv[MAX_NUM_TID];
526 struct list_head rx_reorder_tbl_ptr;
527 /* spin lock for rx_reorder_tbl_ptr queue */
528 spinlock_t rx_reorder_tbl_lock;
529 /* spin lock for Rx packets */
530 spinlock_t rx_pkt_lock;
531
532 #define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
533 u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
534 u32 assoc_rsp_size;
535
536 #define MWIFIEX_GENIE_BUF_SIZE 256
537 u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
538 u8 gen_ie_buf_len;
539
540 struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
541
542 #define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
543 u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
544 u8 assoc_tlv_buf_len;
545
546 u8 *curr_bcn_buf;
547 u32 curr_bcn_size;
548 /* spin lock for beacon buffer */
549 spinlock_t curr_bcn_buf_lock;
550 struct wireless_dev wdev;
551 struct mwifiex_chan_freq_power cfp;
552 char version_str[128];
553 #ifdef CONFIG_DEBUG_FS
554 struct dentry *dfs_dev_dir;
555 #endif
556 u16 current_key_index;
557 struct semaphore async_sem;
558 struct cfg80211_scan_request *scan_request;
559 u8 cfg_bssid[6];
560 struct wps wps;
561 u8 scan_block;
562 s32 cqm_rssi_thold;
563 u32 cqm_rssi_hyst;
564 u8 subsc_evt_rssi_state;
565 struct mwifiex_ds_misc_subsc_evt async_subsc_evt_storage;
566 struct mwifiex_ie mgmt_ie[MAX_MGMT_IE_INDEX];
567 u16 beacon_idx;
568 u16 proberesp_idx;
569 u16 assocresp_idx;
570 u16 gen_idx;
571 u8 ap_11n_enabled;
572 u8 ap_11ac_enabled;
573 u32 mgmt_frame_mask;
574 struct mwifiex_roc_cfg roc_cfg;
575 bool scan_aborting;
576 u8 csa_chan;
577 unsigned long csa_expire_time;
578 u8 del_list_idx;
579 bool hs2_enabled;
580 struct mwifiex_uap_bss_param bss_cfg;
581 struct station_parameters *sta_params;
582 struct sk_buff_head tdls_txq;
583 u8 check_tdls_tx;
584 struct timer_list auto_tdls_timer;
585 bool auto_tdls_timer_active;
586 struct idr ack_status_frames;
587 /* spin lock for ack status */
588 spinlock_t ack_status_lock;
589 /** rx histogram data */
590 struct mwifiex_histogram_data *hist_data;
591 struct cfg80211_chan_def dfs_chandef;
592 struct workqueue_struct *dfs_cac_workqueue;
593 struct delayed_work dfs_cac_work;
594 struct timer_list dfs_chan_switch_timer;
595 struct workqueue_struct *dfs_chan_sw_workqueue;
596 struct delayed_work dfs_chan_sw_work;
597 struct cfg80211_beacon_data beacon_after;
598 struct mwifiex_11h_intf_state state_11h;
599 };
600
601 enum mwifiex_ba_status {
602 BA_SETUP_NONE = 0,
603 BA_SETUP_INPROGRESS,
604 BA_SETUP_COMPLETE
605 };
606
607 struct mwifiex_tx_ba_stream_tbl {
608 struct list_head list;
609 int tid;
610 u8 ra[ETH_ALEN];
611 enum mwifiex_ba_status ba_status;
612 u8 amsdu;
613 };
614
615 struct mwifiex_rx_reorder_tbl;
616
617 struct reorder_tmr_cnxt {
618 struct timer_list timer;
619 struct mwifiex_rx_reorder_tbl *ptr;
620 struct mwifiex_private *priv;
621 u8 timer_is_set;
622 };
623
624 struct mwifiex_rx_reorder_tbl {
625 struct list_head list;
626 int tid;
627 u8 ta[ETH_ALEN];
628 int init_win;
629 int start_win;
630 int win_size;
631 void **rx_reorder_ptr;
632 struct reorder_tmr_cnxt timer_context;
633 u8 amsdu;
634 u8 flags;
635 };
636
637 struct mwifiex_bss_prio_node {
638 struct list_head list;
639 struct mwifiex_private *priv;
640 };
641
642 struct mwifiex_bss_prio_tbl {
643 struct list_head bss_prio_head;
644 /* spin lock for bss priority */
645 spinlock_t bss_prio_lock;
646 struct mwifiex_bss_prio_node *bss_prio_cur;
647 };
648
649 struct cmd_ctrl_node {
650 struct list_head list;
651 struct mwifiex_private *priv;
652 u32 cmd_oid;
653 u32 cmd_flag;
654 struct sk_buff *cmd_skb;
655 struct sk_buff *resp_skb;
656 void *data_buf;
657 u32 wait_q_enabled;
658 struct sk_buff *skb;
659 u8 *condition;
660 u8 cmd_wait_q_woken;
661 };
662
663 struct mwifiex_bss_priv {
664 u8 band;
665 u64 fw_tsf;
666 };
667
668 struct mwifiex_tdls_capab {
669 __le16 capab;
670 u8 rates[32];
671 u8 rates_len;
672 u8 qos_info;
673 u8 coex_2040;
674 u16 aid;
675 struct ieee80211_ht_cap ht_capb;
676 struct ieee80211_ht_operation ht_oper;
677 struct ieee_types_extcap extcap;
678 struct ieee_types_generic rsn_ie;
679 struct ieee80211_vht_cap vhtcap;
680 struct ieee80211_vht_operation vhtoper;
681 };
682
683 /* This is AP/TDLS specific structure which stores information
684 * about associated/peer STA
685 */
686 struct mwifiex_sta_node {
687 struct list_head list;
688 u8 mac_addr[ETH_ALEN];
689 u8 is_wmm_enabled;
690 u8 is_11n_enabled;
691 u8 is_11ac_enabled;
692 u8 ampdu_sta[MAX_NUM_TID];
693 u16 rx_seq[MAX_NUM_TID];
694 u16 max_amsdu;
695 u8 tdls_status;
696 struct mwifiex_tdls_capab tdls_cap;
697 };
698
699 struct mwifiex_auto_tdls_peer {
700 struct list_head list;
701 u8 mac_addr[ETH_ALEN];
702 u8 tdls_status;
703 int rssi;
704 long rssi_jiffies;
705 u8 failure_count;
706 u8 do_discover;
707 u8 do_setup;
708 };
709
710 struct mwifiex_if_ops {
711 int (*init_if) (struct mwifiex_adapter *);
712 void (*cleanup_if) (struct mwifiex_adapter *);
713 int (*check_fw_status) (struct mwifiex_adapter *, u32);
714 int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
715 int (*register_dev) (struct mwifiex_adapter *);
716 void (*unregister_dev) (struct mwifiex_adapter *);
717 int (*enable_int) (struct mwifiex_adapter *);
718 void (*disable_int) (struct mwifiex_adapter *);
719 int (*process_int_status) (struct mwifiex_adapter *);
720 int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *,
721 struct mwifiex_tx_param *);
722 int (*wakeup) (struct mwifiex_adapter *);
723 int (*wakeup_complete) (struct mwifiex_adapter *);
724
725 /* Interface specific functions */
726 void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
727 void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
728 int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
729 int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
730 int (*init_fw_port) (struct mwifiex_adapter *);
731 int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
732 void (*card_reset) (struct mwifiex_adapter *);
733 void (*fw_dump)(struct mwifiex_adapter *);
734 int (*reg_dump)(struct mwifiex_adapter *, char *);
735 int (*clean_pcie_ring) (struct mwifiex_adapter *adapter);
736 void (*iface_work)(struct work_struct *work);
737 void (*submit_rem_rx_urbs)(struct mwifiex_adapter *adapter);
738 };
739
740 struct mwifiex_adapter {
741 u8 iface_type;
742 struct mwifiex_iface_comb iface_limit;
743 struct mwifiex_iface_comb curr_iface_comb;
744 struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
745 u8 priv_num;
746 const struct firmware *firmware;
747 char fw_name[32];
748 int winner;
749 struct device *dev;
750 struct wiphy *wiphy;
751 u8 perm_addr[ETH_ALEN];
752 bool surprise_removed;
753 u32 fw_release_number;
754 u16 init_wait_q_woken;
755 wait_queue_head_t init_wait_q;
756 void *card;
757 struct mwifiex_if_ops if_ops;
758 atomic_t rx_pending;
759 atomic_t tx_pending;
760 atomic_t cmd_pending;
761 struct workqueue_struct *workqueue;
762 struct work_struct main_work;
763 struct workqueue_struct *rx_workqueue;
764 struct work_struct rx_work;
765 struct workqueue_struct *dfs_workqueue;
766 struct work_struct dfs_work;
767 bool rx_work_enabled;
768 bool rx_processing;
769 bool delay_main_work;
770 bool rx_locked;
771 struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
772 /* spin lock for init/shutdown */
773 spinlock_t mwifiex_lock;
774 /* spin lock for main process */
775 spinlock_t main_proc_lock;
776 u32 mwifiex_processing;
777 u16 tx_buf_size;
778 u16 curr_tx_buf_size;
779 u32 ioport;
780 enum MWIFIEX_HARDWARE_STATUS hw_status;
781 u16 number_of_antenna;
782 u32 fw_cap_info;
783 /* spin lock for interrupt handling */
784 spinlock_t int_lock;
785 u8 int_status;
786 u32 event_cause;
787 struct sk_buff *event_skb;
788 u8 upld_buf[MWIFIEX_UPLD_SIZE];
789 u8 data_sent;
790 u8 cmd_sent;
791 u8 cmd_resp_received;
792 u8 event_received;
793 u8 data_received;
794 u16 seq_num;
795 struct cmd_ctrl_node *cmd_pool;
796 struct cmd_ctrl_node *curr_cmd;
797 /* spin lock for command */
798 spinlock_t mwifiex_cmd_lock;
799 u8 is_cmd_timedout;
800 u16 last_init_cmd;
801 struct timer_list cmd_timer;
802 struct list_head cmd_free_q;
803 /* spin lock for cmd_free_q */
804 spinlock_t cmd_free_q_lock;
805 struct list_head cmd_pending_q;
806 /* spin lock for cmd_pending_q */
807 spinlock_t cmd_pending_q_lock;
808 struct list_head scan_pending_q;
809 /* spin lock for scan_pending_q */
810 spinlock_t scan_pending_q_lock;
811 /* spin lock for RX processing routine */
812 spinlock_t rx_proc_lock;
813 u32 scan_processing;
814 u16 region_code;
815 struct mwifiex_802_11d_domain_reg domain_reg;
816 u16 scan_probes;
817 u32 scan_mode;
818 u16 specific_scan_time;
819 u16 active_scan_time;
820 u16 passive_scan_time;
821 u16 scan_chan_gap_time;
822 u8 fw_bands;
823 u8 adhoc_start_band;
824 u8 config_bands;
825 struct mwifiex_chan_scan_param_set *scan_channels;
826 u8 tx_lock_flag;
827 struct mwifiex_sleep_params sleep_params;
828 struct mwifiex_sleep_period sleep_period;
829 u16 ps_mode;
830 u32 ps_state;
831 u8 need_to_wakeup;
832 u16 multiple_dtim;
833 u16 local_listen_interval;
834 u16 null_pkt_interval;
835 struct sk_buff *sleep_cfm;
836 u16 bcn_miss_time_out;
837 u16 adhoc_awake_period;
838 u8 is_deep_sleep;
839 u8 delay_null_pkt;
840 u16 delay_to_ps;
841 u16 enhanced_ps_mode;
842 u8 pm_wakeup_card_req;
843 u16 gen_null_pkt;
844 u16 pps_uapsd_mode;
845 u32 pm_wakeup_fw_try;
846 struct timer_list wakeup_timer;
847 u8 is_hs_configured;
848 struct mwifiex_hs_config_param hs_cfg;
849 u8 hs_activated;
850 u16 hs_activate_wait_q_woken;
851 wait_queue_head_t hs_activate_wait_q;
852 bool is_suspended;
853 bool hs_enabling;
854 u8 event_body[MAX_EVENT_SIZE];
855 u32 hw_dot_11n_dev_cap;
856 u8 hw_dev_mcs_support;
857 u8 user_dev_mcs_support;
858 u8 adhoc_11n_enabled;
859 u8 sec_chan_offset;
860 struct mwifiex_dbg dbg;
861 u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
862 u32 arp_filter_size;
863 struct mwifiex_wait_queue cmd_wait_q;
864 u8 scan_wait_q_woken;
865 spinlock_t queue_lock; /* lock for tx queues */
866 u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
867 u16 max_mgmt_ie_index;
868 const struct firmware *cal_data;
869 struct device_node *dt_node;
870
871 /* 11AC */
872 u32 is_hw_11ac_capable;
873 u32 hw_dot_11ac_dev_cap;
874 u32 hw_dot_11ac_mcs_support;
875 u32 usr_dot_11ac_dev_cap_bg;
876 u32 usr_dot_11ac_dev_cap_a;
877 u32 usr_dot_11ac_mcs_support;
878
879 atomic_t pending_bridged_pkts;
880 struct semaphore *card_sem;
881 bool ext_scan;
882 u8 fw_api_ver;
883 u8 key_api_major_ver, key_api_minor_ver;
884 struct work_struct iface_work;
885 unsigned long iface_work_flags;
886 struct memory_type_mapping *mem_type_mapping_tbl;
887 u8 num_mem_types;
888 u8 curr_mem_idx;
889 void *drv_info_dump;
890 u32 drv_info_size;
891 bool scan_chan_gap_enabled;
892 struct sk_buff_head rx_data_q;
893 struct mwifiex_chan_stats *chan_stats;
894 u32 num_in_chan_stats;
895 int survey_idx;
896 bool auto_tdls;
897 };
898
899 int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
900
901 void mwifiex_set_trans_start(struct net_device *dev);
902
903 void mwifiex_stop_net_dev_queue(struct net_device *netdev,
904 struct mwifiex_adapter *adapter);
905
906 void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
907 struct mwifiex_adapter *adapter);
908
909 int mwifiex_init_priv(struct mwifiex_private *priv);
910 void mwifiex_free_priv(struct mwifiex_private *priv);
911
912 int mwifiex_init_fw(struct mwifiex_adapter *adapter);
913
914 int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
915
916 int mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
917
918 int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
919
920 int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
921
922 int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb);
923
924 int mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
925 struct sk_buff *skb);
926
927 int mwifiex_process_event(struct mwifiex_adapter *adapter);
928
929 int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
930 struct cmd_ctrl_node *cmd_node);
931
932 int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
933 u16 cmd_action, u32 cmd_oid, void *data_buf, bool sync);
934
935 void mwifiex_cmd_timeout_func(unsigned long function_context);
936
937 int mwifiex_get_debug_info(struct mwifiex_private *,
938 struct mwifiex_debug_info *);
939
940 int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
941 int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
942 void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
943 void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
944
945 void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
946 struct cmd_ctrl_node *cmd_node);
947 void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter,
948 struct cmd_ctrl_node *cmd_node);
949
950 void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
951 struct cmd_ctrl_node *cmd_node,
952 u32 addtail);
953
954 int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
955 int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
956 int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
957 struct sk_buff *skb);
958 int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
959 struct mwifiex_tx_param *tx_param);
960 int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
961 int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
962 struct sk_buff *skb, int aggr, int status);
963 void mwifiex_clean_txrx(struct mwifiex_private *priv);
964 u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
965 void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
966 void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
967 u32);
968 int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
969 struct host_cmd_ds_command *cmd,
970 u16 cmd_action, uint16_t ps_bitmap,
971 struct mwifiex_ds_auto_ds *auto_ds);
972 int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
973 struct host_cmd_ds_command *resp,
974 struct mwifiex_ds_pm_cfg *pm_cfg);
975 void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
976 void mwifiex_hs_activated_event(struct mwifiex_private *priv,
977 u8 activated);
978 int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
979 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg);
980 int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
981 struct host_cmd_ds_command *resp);
982 int mwifiex_process_rx_packet(struct mwifiex_private *priv,
983 struct sk_buff *skb);
984 int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
985 u16 cmd_action, u32 cmd_oid,
986 void *data_buf, void *cmd_buf);
987 int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
988 u16 cmd_action, u32 cmd_oid,
989 void *data_buf, void *cmd_buf);
990 int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
991 struct host_cmd_ds_command *resp);
992 int mwifiex_process_sta_rx_packet(struct mwifiex_private *,
993 struct sk_buff *skb);
994 int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
995 struct sk_buff *skb);
996 int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
997 struct sk_buff *skb);
998 int mwifiex_process_sta_event(struct mwifiex_private *);
999 int mwifiex_process_uap_event(struct mwifiex_private *);
1000 void mwifiex_delete_all_station_list(struct mwifiex_private *priv);
1001 void mwifiex_wmm_del_peer_ra_list(struct mwifiex_private *priv,
1002 const u8 *ra_addr);
1003 void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
1004 void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb);
1005 int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta, bool init);
1006 int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
1007 struct mwifiex_scan_cmd_config *scan_cfg);
1008 void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
1009 struct cmd_ctrl_node *cmd_node);
1010 int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
1011 struct host_cmd_ds_command *resp);
1012 s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
1013 int mwifiex_associate(struct mwifiex_private *priv,
1014 struct mwifiex_bssdescriptor *bss_desc);
1015 int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
1016 struct host_cmd_ds_command *cmd,
1017 struct mwifiex_bssdescriptor *bss_desc);
1018 int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
1019 struct host_cmd_ds_command *resp);
1020 void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason);
1021 u8 mwifiex_band_to_radio_type(u8 band);
1022 int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
1023 void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter);
1024 int mwifiex_adhoc_start(struct mwifiex_private *priv,
1025 struct cfg80211_ssid *adhoc_ssid);
1026 int mwifiex_adhoc_join(struct mwifiex_private *priv,
1027 struct mwifiex_bssdescriptor *bss_desc);
1028 int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
1029 struct host_cmd_ds_command *cmd,
1030 struct cfg80211_ssid *req_ssid);
1031 int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
1032 struct host_cmd_ds_command *cmd,
1033 struct mwifiex_bssdescriptor *bss_desc);
1034 int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
1035 struct host_cmd_ds_command *resp);
1036 int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
1037 struct mwifiex_chan_freq_power *mwifiex_get_cfp(struct mwifiex_private *priv,
1038 u8 band, u16 channel, u32 freq);
1039 u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv,
1040 u8 index, u8 ht_info);
1041 u32 mwifiex_index_to_acs_data_rate(struct mwifiex_private *priv,
1042 u8 index, u8 ht_info);
1043 u32 mwifiex_find_freq_from_band_chan(u8, u8);
1044 int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
1045 u8 **buffer);
1046 u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
1047 u8 *rates);
1048 u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
1049 u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv,
1050 u8 *rates, u8 radio_type);
1051 u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
1052 extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
1053 void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
1054 void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
1055 int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
1056 struct host_cmd_ds_command *cmd);
1057 int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
1058 struct host_cmd_ds_command *resp);
1059 int is_command_pending(struct mwifiex_adapter *adapter);
1060 void mwifiex_init_priv_params(struct mwifiex_private *priv,
1061 struct net_device *dev);
1062 int mwifiex_set_secure_params(struct mwifiex_private *priv,
1063 struct mwifiex_uap_bss_param *bss_config,
1064 struct cfg80211_ap_settings *params);
1065 void mwifiex_set_ht_params(struct mwifiex_private *priv,
1066 struct mwifiex_uap_bss_param *bss_cfg,
1067 struct cfg80211_ap_settings *params);
1068 void mwifiex_set_vht_params(struct mwifiex_private *priv,
1069 struct mwifiex_uap_bss_param *bss_cfg,
1070 struct cfg80211_ap_settings *params);
1071 void mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg,
1072 struct cfg80211_ap_settings *params);
1073 void mwifiex_set_vht_width(struct mwifiex_private *priv,
1074 enum nl80211_chan_width width,
1075 bool ap_11ac_disable);
1076 void
1077 mwifiex_set_wmm_params(struct mwifiex_private *priv,
1078 struct mwifiex_uap_bss_param *bss_cfg,
1079 struct cfg80211_ap_settings *params);
1080 void mwifiex_set_ba_params(struct mwifiex_private *priv);
1081 void mwifiex_set_11ac_ba_params(struct mwifiex_private *priv);
1082 int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
1083 struct host_cmd_ds_command *cmd,
1084 void *data_buf);
1085 int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv,
1086 struct host_cmd_ds_command *resp);
1087 int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
1088 void *buf);
1089
1090 /*
1091 * This function checks if the queuing is RA based or not.
1092 */
1093 static inline u8
1094 mwifiex_queuing_ra_based(struct mwifiex_private *priv)
1095 {
1096 /*
1097 * Currently we assume if we are in Infra, then DA=RA. This might not be
1098 * true in the future
1099 */
1100 if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
1101 (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
1102 return false;
1103
1104 return true;
1105 }
1106
1107 /*
1108 * This function copies rates.
1109 */
1110 static inline u32
1111 mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
1112 {
1113 int i;
1114
1115 for (i = 0; i < len && src[i]; i++, pos++) {
1116 if (pos >= MWIFIEX_SUPPORTED_RATES)
1117 break;
1118 dest[pos] = src[i];
1119 }
1120
1121 return pos;
1122 }
1123
1124 /*
1125 * This function returns the correct private structure pointer based
1126 * upon the BSS type and BSS number.
1127 */
1128 static inline struct mwifiex_private *
1129 mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
1130 u8 bss_num, u8 bss_type)
1131 {
1132 int i;
1133
1134 for (i = 0; i < adapter->priv_num; i++) {
1135 if (adapter->priv[i]) {
1136 if ((adapter->priv[i]->bss_num == bss_num) &&
1137 (adapter->priv[i]->bss_type == bss_type))
1138 break;
1139 }
1140 }
1141 return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1142 }
1143
1144 /*
1145 * This function returns the first available private structure pointer
1146 * based upon the BSS role.
1147 */
1148 static inline struct mwifiex_private *
1149 mwifiex_get_priv(struct mwifiex_adapter *adapter,
1150 enum mwifiex_bss_role bss_role)
1151 {
1152 int i;
1153
1154 for (i = 0; i < adapter->priv_num; i++) {
1155 if (adapter->priv[i]) {
1156 if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
1157 GET_BSS_ROLE(adapter->priv[i]) == bss_role)
1158 break;
1159 }
1160 }
1161
1162 return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1163 }
1164
1165 /*
1166 * This function returns the first available unused private structure pointer.
1167 */
1168 static inline struct mwifiex_private *
1169 mwifiex_get_unused_priv(struct mwifiex_adapter *adapter)
1170 {
1171 int i;
1172
1173 for (i = 0; i < adapter->priv_num; i++) {
1174 if (adapter->priv[i]) {
1175 if (adapter->priv[i]->bss_mode ==
1176 NL80211_IFTYPE_UNSPECIFIED)
1177 break;
1178 }
1179 }
1180
1181 return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1182 }
1183
1184 /*
1185 * This function returns the driver private structure of a network device.
1186 */
1187 static inline struct mwifiex_private *
1188 mwifiex_netdev_get_priv(struct net_device *dev)
1189 {
1190 return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
1191 }
1192
1193 /*
1194 * This function checks if a skb holds a management frame.
1195 */
1196 static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
1197 {
1198 return (le32_to_cpu(*(__le32 *)skb->data) == PKT_TYPE_MGMT);
1199 }
1200
1201 /* This function retrieves channel closed for operation by Channel
1202 * Switch Announcement.
1203 */
1204 static inline u8
1205 mwifiex_11h_get_csa_closed_channel(struct mwifiex_private *priv)
1206 {
1207 if (!priv->csa_chan)
1208 return 0;
1209
1210 /* Clear csa channel, if DFS channel move time has passed */
1211 if (time_after(jiffies, priv->csa_expire_time)) {
1212 priv->csa_chan = 0;
1213 priv->csa_expire_time = 0;
1214 }
1215
1216 return priv->csa_chan;
1217 }
1218
1219 static inline u8 mwifiex_is_any_intf_active(struct mwifiex_private *priv)
1220 {
1221 struct mwifiex_private *priv_num;
1222 int i;
1223
1224 for (i = 0; i < priv->adapter->priv_num; i++) {
1225 priv_num = priv->adapter->priv[i];
1226 if (priv_num) {
1227 if ((GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_UAP &&
1228 priv_num->bss_started) ||
1229 (GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_STA &&
1230 priv_num->media_connected))
1231 return 1;
1232 }
1233 }
1234
1235 return 0;
1236 }
1237
1238 int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
1239 u32 func_init_shutdown);
1240 int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
1241 int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
1242
1243 void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
1244 int maxlen);
1245 int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
1246 struct mwifiex_multicast_list *mcast_list);
1247 int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
1248 struct net_device *dev);
1249 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
1250 struct cmd_ctrl_node *cmd_queued);
1251 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
1252 struct cfg80211_ssid *req_ssid);
1253 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
1254 int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
1255 int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
1256 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
1257 int mwifiex_request_scan(struct mwifiex_private *priv,
1258 struct cfg80211_ssid *req_ssid);
1259 int mwifiex_scan_networks(struct mwifiex_private *priv,
1260 const struct mwifiex_user_scan_cfg *user_scan_in);
1261 int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
1262
1263 int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
1264 const u8 *key, int key_len, u8 key_index,
1265 const u8 *mac_addr, int disable);
1266
1267 int mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len);
1268
1269 int mwifiex_get_ver_ext(struct mwifiex_private *priv);
1270
1271 int mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action,
1272 struct ieee80211_channel *chan,
1273 unsigned int duration);
1274
1275 int mwifiex_get_stats_info(struct mwifiex_private *priv,
1276 struct mwifiex_ds_get_stats *log);
1277
1278 int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1279 u32 reg_offset, u32 reg_value);
1280
1281 int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1282 u32 reg_offset, u32 *value);
1283
1284 int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1285 u8 *value);
1286
1287 int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
1288
1289 int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
1290
1291 int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
1292
1293 int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
1294
1295 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
1296
1297 int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
1298 char *version, int max_len);
1299
1300 int mwifiex_set_tx_power(struct mwifiex_private *priv,
1301 struct mwifiex_power_cfg *power_cfg);
1302
1303 int mwifiex_main_process(struct mwifiex_adapter *);
1304
1305 int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb);
1306
1307 int mwifiex_get_bss_info(struct mwifiex_private *,
1308 struct mwifiex_bss_info *);
1309 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
1310 struct cfg80211_bss *bss,
1311 struct mwifiex_bssdescriptor *bss_desc);
1312 int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
1313 struct mwifiex_bssdescriptor *bss_entry);
1314 int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
1315 struct mwifiex_bssdescriptor *bss_desc);
1316
1317 u8 mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type);
1318
1319 struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1320 const char *name,
1321 enum nl80211_iftype type,
1322 u32 *flags,
1323 struct vif_params *params);
1324 int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
1325
1326 void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config);
1327
1328 int mwifiex_add_wowlan_magic_pkt_filter(struct mwifiex_adapter *adapter);
1329
1330 int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
1331 struct cfg80211_beacon_data *data);
1332 int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
1333 u8 *mwifiex_11d_code_2_region(u8 code);
1334 void mwifiex_uap_set_channel(struct mwifiex_uap_bss_param *bss_cfg,
1335 struct cfg80211_chan_def chandef);
1336 int mwifiex_config_start_uap(struct mwifiex_private *priv,
1337 struct mwifiex_uap_bss_param *bss_cfg);
1338 void mwifiex_uap_del_sta_data(struct mwifiex_private *priv,
1339 struct mwifiex_sta_node *node);
1340
1341 void mwifiex_init_11h_params(struct mwifiex_private *priv);
1342 int mwifiex_is_11h_active(struct mwifiex_private *priv);
1343 int mwifiex_11h_activate(struct mwifiex_private *priv, bool flag);
1344
1345 void mwifiex_11h_process_join(struct mwifiex_private *priv, u8 **buffer,
1346 struct mwifiex_bssdescriptor *bss_desc);
1347 int mwifiex_11h_handle_event_chanswann(struct mwifiex_private *priv);
1348 int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv,
1349 struct device_node *node, const char *prefix);
1350 void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv);
1351
1352 extern const struct ethtool_ops mwifiex_ethtool_ops;
1353
1354 void mwifiex_del_all_sta_list(struct mwifiex_private *priv);
1355 void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1356 void
1357 mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies,
1358 int ies_len, struct mwifiex_sta_node *node);
1359 struct mwifiex_sta_node *
1360 mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1361 struct mwifiex_sta_node *
1362 mwifiex_get_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1363 int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
1364 u8 action_code, u8 dialog_token,
1365 u16 status_code, const u8 *extra_ies,
1366 size_t extra_ies_len);
1367 int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
1368 u8 action_code, u8 dialog_token,
1369 u16 status_code, const u8 *extra_ies,
1370 size_t extra_ies_len);
1371 void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
1372 u8 *buf, int len);
1373 int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action);
1374 int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac);
1375 int mwifiex_get_tdls_list(struct mwifiex_private *priv,
1376 struct tdls_peer_info *buf);
1377 void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
1378 bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
1379 u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
1380 u32 pri_chan, u8 chan_bw);
1381 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter);
1382
1383 int mwifiex_tdls_check_tx(struct mwifiex_private *priv, struct sk_buff *skb);
1384 void mwifiex_flush_auto_tdls_list(struct mwifiex_private *priv);
1385 void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private *priv,
1386 const u8 *mac, u8 link_status);
1387 void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv,
1388 u8 *mac, s8 snr, s8 nflr);
1389 void mwifiex_check_auto_tdls(unsigned long context);
1390 void mwifiex_add_auto_tdls_peer(struct mwifiex_private *priv, const u8 *mac);
1391 void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv);
1392 void mwifiex_clean_auto_tdls(struct mwifiex_private *priv);
1393 int mwifiex_cmd_issue_chan_report_request(struct mwifiex_private *priv,
1394 struct host_cmd_ds_command *cmd,
1395 void *data_buf);
1396 int mwifiex_11h_handle_chanrpt_ready(struct mwifiex_private *priv,
1397 struct sk_buff *skb);
1398
1399 void mwifiex_parse_tx_status_event(struct mwifiex_private *priv,
1400 void *event_body);
1401
1402 struct sk_buff *
1403 mwifiex_clone_skb_for_tx_status(struct mwifiex_private *priv,
1404 struct sk_buff *skb, u8 flag, u64 *cookie);
1405 void mwifiex_dfs_cac_work_queue(struct work_struct *work);
1406 void mwifiex_dfs_chan_sw_work_queue(struct work_struct *work);
1407 void mwifiex_abort_cac(struct mwifiex_private *priv);
1408 int mwifiex_11h_handle_radar_detected(struct mwifiex_private *priv,
1409 struct sk_buff *skb);
1410
1411 void mwifiex_hist_data_set(struct mwifiex_private *priv, u8 rx_rate, s8 snr,
1412 s8 nflr);
1413 void mwifiex_hist_data_reset(struct mwifiex_private *priv);
1414 void mwifiex_hist_data_add(struct mwifiex_private *priv,
1415 u8 rx_rate, s8 snr, s8 nflr);
1416 u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
1417 u8 rx_rate, u8 ht_info);
1418
1419 void mwifiex_dump_drv_info(struct mwifiex_adapter *adapter);
1420
1421 #ifdef CONFIG_DEBUG_FS
1422 void mwifiex_debugfs_init(void);
1423 void mwifiex_debugfs_remove(void);
1424
1425 void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
1426 void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
1427 #endif
1428 #endif /* !_MWIFIEX_MAIN_H_ */
This page took 0.114325 seconds and 6 git commands to generate.