2 * Marvell Wireless LAN device driver: major data structures and prototypes
4 * Copyright (C) 2011-2014, Marvell International Ltd.
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.
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.
20 #ifndef _MWIFIEX_MAIN_H_
21 #define _MWIFIEX_MAIN_H_
23 #include <linux/completion.h>
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/sched.h>
27 #include <linux/semaphore.h>
29 #include <linux/skbuff.h>
30 #include <linux/if_arp.h>
31 #include <linux/etherdevice.h>
33 #include <net/lib80211.h>
34 #include <linux/vmalloc.h>
35 #include <linux/firmware.h>
36 #include <linux/ctype.h>
38 #include <linux/idr.h>
39 #include <linux/inetdevice.h>
40 #include <linux/devcoredump.h>
41 #include <linux/err.h>
42 #include <linux/gpio.h>
43 #include <linux/gfp.h>
44 #include <linux/interrupt.h>
46 #include <linux/of_gpio.h>
47 #include <linux/of_platform.h>
48 #include <linux/platform_device.h>
49 #include <linux/pm_runtime.h>
50 #include <linux/slab.h>
51 #include <linux/of_irq.h>
61 extern const char driver_version
[];
63 extern bool aggr_ctrl
;
65 struct mwifiex_adapter
;
66 struct mwifiex_private
;
73 #define MWIFIEX_DRIVER_MODE_STA BIT(0)
74 #define MWIFIEX_DRIVER_MODE_UAP BIT(1)
75 #define MWIFIEX_DRIVER_MODE_P2P BIT(2)
76 #define MWIFIEX_DRIVER_MODE_BITMASK (BIT(0) | BIT(1) | BIT(2))
78 #define MWIFIEX_MAX_AP 64
80 #define MWIFIEX_MAX_PKTS_TXQ 16
82 #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
84 #define MWIFIEX_TIMER_10S 10000
85 #define MWIFIEX_TIMER_1S 1000
87 #define MAX_TX_PENDING 400
88 #define LOW_TX_PENDING 380
90 #define HIGH_RX_PENDING 50
91 #define LOW_RX_PENDING 20
93 #define MWIFIEX_UPLD_SIZE (2312)
95 #define MAX_EVENT_SIZE 2048
97 #define MWIFIEX_FW_DUMP_SIZE (2 * 1024 * 1024)
99 #define ARP_FILTER_MAX_BUF_SIZE 68
101 #define MWIFIEX_KEY_BUFFER_SIZE 16
102 #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
103 #define MWIFIEX_MAX_REGION_CODE 9
105 #define DEFAULT_BCN_AVG_FACTOR 8
106 #define DEFAULT_DATA_AVG_FACTOR 8
108 #define FIRST_VALID_CHANNEL 0xff
109 #define DEFAULT_AD_HOC_CHANNEL 6
110 #define DEFAULT_AD_HOC_CHANNEL_A 36
112 #define DEFAULT_BCN_MISS_TIMEOUT 5
114 #define MAX_SCAN_BEACON_BUFFER 8000
116 #define SCAN_BEACON_ENTRY_PAD 6
118 #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
119 #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 40
120 #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 40
121 #define MWIFIEX_DEF_SCAN_CHAN_GAP_TIME 50
123 #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI)))
125 #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
127 #define RSN_GTK_OUI_OFFSET 2
129 #define MWIFIEX_OUI_NOT_PRESENT 0
130 #define MWIFIEX_OUI_PRESENT 1
132 #define PKT_TYPE_MGMT 0xE5
135 * Do not check for data_received for USB, as data_received
136 * is handled in mwifiex_usb_recv for USB
138 #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
139 adapter->event_received || \
140 adapter->data_received)
142 #define MWIFIEX_TYPE_CMD 1
143 #define MWIFIEX_TYPE_DATA 0
144 #define MWIFIEX_TYPE_AGGR_DATA 10
145 #define MWIFIEX_TYPE_EVENT 3
147 #define MAX_BITMAP_RATES_SIZE 18
149 #define MAX_CHANNEL_BAND_BG 14
150 #define MAX_CHANNEL_BAND_A 165
152 #define MAX_FREQUENCY_BAND_BG 2484
154 #define MWIFIEX_EVENT_HEADER_LEN 4
155 #define MWIFIEX_UAP_EVENT_EXTRA_HEADER 2
157 #define MWIFIEX_TYPE_LEN 4
158 #define MWIFIEX_USB_TYPE_CMD 0xF00DFACE
159 #define MWIFIEX_USB_TYPE_DATA 0xBEADC0DE
160 #define MWIFIEX_USB_TYPE_EVENT 0xBEEFFACE
162 /* Threshold for tx_timeout_cnt before we trigger a card reset */
163 #define TX_TIMEOUT_THRESHOLD 6
165 #define MWIFIEX_DRV_INFO_SIZE_MAX 0x40000
167 /* Address alignment */
168 #define MWIFIEX_ALIGN_ADDR(p, a) (((long)(p) + (a) - 1) & ~((a) - 1))
170 #define MWIFIEX_MAC_LOCAL_ADMIN_BIT 41
173 *enum mwifiex_debug_level - marvell wifi debug level
175 enum MWIFIEX_DEBUG_LEVEL
{
176 MWIFIEX_DBG_MSG
= 0x00000001,
177 MWIFIEX_DBG_FATAL
= 0x00000002,
178 MWIFIEX_DBG_ERROR
= 0x00000004,
179 MWIFIEX_DBG_DATA
= 0x00000008,
180 MWIFIEX_DBG_CMD
= 0x00000010,
181 MWIFIEX_DBG_EVENT
= 0x00000020,
182 MWIFIEX_DBG_INTR
= 0x00000040,
183 MWIFIEX_DBG_IOCTL
= 0x00000080,
185 MWIFIEX_DBG_MPA_D
= 0x00008000,
186 MWIFIEX_DBG_DAT_D
= 0x00010000,
187 MWIFIEX_DBG_CMD_D
= 0x00020000,
188 MWIFIEX_DBG_EVT_D
= 0x00040000,
189 MWIFIEX_DBG_FW_D
= 0x00080000,
190 MWIFIEX_DBG_IF_D
= 0x00100000,
192 MWIFIEX_DBG_ENTRY
= 0x10000000,
193 MWIFIEX_DBG_WARN
= 0x20000000,
194 MWIFIEX_DBG_INFO
= 0x40000000,
195 MWIFIEX_DBG_DUMP
= 0x80000000,
197 MWIFIEX_DBG_ANY
= 0xffffffff
200 #define MWIFIEX_DEFAULT_DEBUG_MASK (MWIFIEX_DBG_MSG | \
201 MWIFIEX_DBG_FATAL | \
205 void _mwifiex_dbg(const struct mwifiex_adapter
*adapter
, int mask
,
206 const char *fmt
, ...);
207 #define mwifiex_dbg(adapter, mask, fmt, ...) \
208 _mwifiex_dbg(adapter, MWIFIEX_DBG_##mask, fmt, ##__VA_ARGS__)
210 #define DEBUG_DUMP_DATA_MAX_LEN 128
211 #define mwifiex_dbg_dump(adapter, dbg_mask, str, buf, len) \
213 if ((adapter)->debug_mask & MWIFIEX_DBG_##dbg_mask) \
214 print_hex_dump(KERN_DEBUG, str, \
215 DUMP_PREFIX_OFFSET, 16, 1, \
219 /** Min BGSCAN interval 15 second */
220 #define MWIFIEX_BGSCAN_INTERVAL 15000
221 /** default repeat count */
222 #define MWIFIEX_BGSCAN_REPEAT_COUNT 6
225 u32 num_cmd_host_to_card_failure
;
226 u32 num_cmd_sleep_cfm_host_to_card_failure
;
227 u32 num_tx_host_to_card_failure
;
228 u32 num_event_deauth
;
229 u32 num_event_disassoc
;
230 u32 num_event_link_lost
;
232 u32 num_cmd_assoc_success
;
233 u32 num_cmd_assoc_failure
;
237 u16 last_cmd_id
[DBG_CMD_NUM
];
238 u16 last_cmd_act
[DBG_CMD_NUM
];
240 u16 last_cmd_resp_id
[DBG_CMD_NUM
];
241 u16 last_cmd_resp_index
;
242 u16 last_event
[DBG_CMD_NUM
];
243 u16 last_event_index
;
244 u32 last_mp_wr_bitmap
[MWIFIEX_DBG_SDIO_MP_NUM
];
245 u32 last_mp_wr_ports
[MWIFIEX_DBG_SDIO_MP_NUM
];
246 u32 last_mp_wr_len
[MWIFIEX_DBG_SDIO_MP_NUM
];
247 u32 last_mp_curr_wr_port
[MWIFIEX_DBG_SDIO_MP_NUM
];
248 u8 last_sdio_mp_index
;
251 enum MWIFIEX_HARDWARE_STATUS
{
252 MWIFIEX_HW_STATUS_READY
,
253 MWIFIEX_HW_STATUS_INITIALIZING
,
254 MWIFIEX_HW_STATUS_INIT_DONE
,
255 MWIFIEX_HW_STATUS_RESET
,
256 MWIFIEX_HW_STATUS_NOT_READY
259 enum MWIFIEX_802_11_POWER_MODE
{
260 MWIFIEX_802_11_POWER_MODE_CAM
,
261 MWIFIEX_802_11_POWER_MODE_PSP
264 struct mwifiex_tx_param
{
268 enum MWIFIEX_PS_STATE
{
275 enum mwifiex_iface_type
{
281 struct mwifiex_add_ba_param
{
289 struct mwifiex_tx_aggr
{
295 enum mwifiex_ba_status
{
301 struct mwifiex_ra_list_tbl
{
302 struct list_head list
;
303 struct sk_buff_head skb_head
;
309 enum mwifiex_ba_status ba_status
;
316 struct mwifiex_tid_tbl
{
317 struct list_head ra_list
;
320 #define WMM_HIGHEST_PRIORITY 7
321 #define HIGH_PRIO_TID 7
322 #define LOW_PRIO_TID 0
323 #define NO_PKT_PRIO_TID -1
324 #define MWIFIEX_WMM_DRV_DELAY_MAX 510
326 struct mwifiex_wmm_desc
{
327 struct mwifiex_tid_tbl tid_tbl_ptr
[MAX_NUM_TID
];
328 u32 packets_out
[MAX_NUM_TID
];
329 u32 pkts_paused
[MAX_NUM_TID
];
330 /* spin lock to protect ra_list */
331 spinlock_t ra_list_spinlock
;
332 struct mwifiex_wmm_ac_status ac_status
[IEEE80211_NUM_ACS
];
333 enum mwifiex_wmm_ac_e ac_down_graded_vals
[IEEE80211_NUM_ACS
];
334 u32 drv_pkt_delay_max
;
335 u8 queue_priority
[IEEE80211_NUM_ACS
];
336 u32 user_pri_pkt_tx_ctrl
[WMM_HIGHEST_PRIORITY
+ 1]; /* UP: 0 to 7 */
337 /* Number of transmit packets queued */
338 atomic_t tx_pkts_queued
;
339 /* Tracks highest priority with a packet queued */
340 atomic_t highest_queued_prio
;
343 struct mwifiex_802_11_security
{
349 u32 authentication_mode
;
354 struct ieee_types_header
{
359 struct ieee_types_vendor_specific
{
360 struct ieee_types_vendor_header vend_hdr
;
361 u8 data
[IEEE_MAX_IE_SIZE
- sizeof(struct ieee_types_vendor_header
)];
364 struct ieee_types_generic
{
365 struct ieee_types_header ieee_hdr
;
366 u8 data
[IEEE_MAX_IE_SIZE
- sizeof(struct ieee_types_header
)];
369 struct ieee_types_bss_co_2040
{
370 struct ieee_types_header ieee_hdr
;
374 struct ieee_types_extcap
{
375 struct ieee_types_header ieee_hdr
;
379 struct ieee_types_vht_cap
{
380 struct ieee_types_header ieee_hdr
;
381 struct ieee80211_vht_cap vhtcap
;
384 struct ieee_types_vht_oper
{
385 struct ieee_types_header ieee_hdr
;
386 struct ieee80211_vht_operation vhtoper
;
389 struct ieee_types_aid
{
390 struct ieee_types_header ieee_hdr
;
394 struct mwifiex_bssdescriptor
{
395 u8 mac_address
[ETH_ALEN
];
396 struct cfg80211_ssid ssid
;
404 u8 supported_rates
[MWIFIEX_SUPPORTED_RATES
];
405 u8 data_rates
[MWIFIEX_SUPPORTED_RATES
];
407 * BAND_B(0x01): 'b' band
408 * BAND_G(0x02): 'g' band
409 * BAND_A(0X04): 'a' band
414 union ieee_types_phy_param_set phy_param_set
;
415 union ieee_types_ss_param_set ss_param_set
;
417 struct ieee_types_wmm_parameter wmm_ie
;
419 struct ieee80211_ht_cap
*bcn_ht_cap
;
421 struct ieee80211_ht_operation
*bcn_ht_oper
;
424 u16 bss_co_2040_offset
;
427 struct ieee80211_vht_cap
*bcn_vht_cap
;
429 struct ieee80211_vht_operation
*bcn_vht_oper
;
431 struct ieee_types_oper_mode_ntf
*oper_mode
;
432 u16 oper_mode_offset
;
434 struct ieee_types_vendor_specific
*bcn_wpa_ie
;
436 struct ieee_types_generic
*bcn_rsn_ie
;
438 struct ieee_types_generic
*bcn_wapi_ie
;
444 u8 chan_sw_ie_present
;
447 struct mwifiex_current_bss_params
{
448 struct mwifiex_bssdescriptor bss_descriptor
;
450 u8 wmm_uapsd_enabled
;
453 u8 data_rates
[MWIFIEX_SUPPORTED_RATES
];
456 struct mwifiex_sleep_params
{
465 struct mwifiex_sleep_period
{
470 struct mwifiex_wep_key
{
474 u8 key_material
[MWIFIEX_KEY_BUFFER_SIZE
];
477 #define MAX_REGION_CHANNEL_NUM 2
479 struct mwifiex_chan_freq_power
{
491 #define MWIFIEX_MAX_TRIPLET_802_11D 83
493 struct mwifiex_802_11d_domain_reg
{
494 u8 country_code
[IEEE80211_COUNTRY_STRING_LEN
];
496 struct ieee80211_country_ie_triplet
497 triplet
[MWIFIEX_MAX_TRIPLET_802_11D
];
500 struct mwifiex_vendor_spec_cfg_ie
{
503 u8 ie
[MWIFIEX_MAX_VSIE_LEN
];
510 struct mwifiex_roc_cfg
{
512 struct ieee80211_channel chan
;
515 enum mwifiex_iface_work_flags
{
516 MWIFIEX_IFACE_WORK_DEVICE_DUMP
,
517 MWIFIEX_IFACE_WORK_CARD_RESET
,
520 struct mwifiex_band_config
{
527 struct mwifiex_channel_band
{
528 struct mwifiex_band_config band_config
;
532 struct mwifiex_private
{
533 struct mwifiex_adapter
*adapter
;
540 u8 curr_addr
[ETH_ALEN
];
545 /* track consecutive timeout */
547 struct net_device
*netdev
;
548 struct net_device_stats stats
;
553 u8 max_tx_power_level
;
554 u8 min_tx_power_level
;
562 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
564 u8 is_data_rate_auto
;
575 struct mwifiex_bssdescriptor
*attempted_bss_desc
;
576 struct cfg80211_ssid prev_ssid
;
577 u8 prev_bssid
[ETH_ALEN
];
578 struct mwifiex_current_bss_params curr_bss_params
;
584 u8 adhoc_is_link_sensed
;
586 struct mwifiex_802_11_security sec_info
;
587 struct mwifiex_wep_key wep_key
[NUM_WEP_KEYS
];
588 u16 wep_key_curr_index
;
592 struct host_cmd_ds_802_11_key_material aes_key
;
593 struct host_cmd_ds_802_11_key_material_v2 aes_key_v2
;
601 struct mwifiex_wmm_desc wmm
;
602 atomic_t wmm_tx_pending
[IEEE80211_NUM_ACS
];
603 struct list_head sta_list
;
604 /* spin lock for associated station/TDLS peers list */
605 spinlock_t sta_list_spinlock
;
606 struct list_head auto_tdls_list
;
607 /* spin lock for auto TDLS peer list */
608 spinlock_t auto_tdls_lock
;
609 struct list_head tx_ba_stream_tbl_ptr
;
610 /* spin lock for tx_ba_stream_tbl_ptr queue */
611 spinlock_t tx_ba_stream_tbl_lock
;
612 struct mwifiex_tx_aggr aggr_prio_tbl
[MAX_NUM_TID
];
613 struct mwifiex_add_ba_param add_ba_param
;
614 u16 rx_seq
[MAX_NUM_TID
];
615 u8 tos_to_tid_inv
[MAX_NUM_TID
];
616 struct list_head rx_reorder_tbl_ptr
;
617 /* spin lock for rx_reorder_tbl_ptr queue */
618 spinlock_t rx_reorder_tbl_lock
;
619 /* spin lock for Rx packets */
620 spinlock_t rx_pkt_lock
;
622 #define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
623 u8 assoc_rsp_buf
[MWIFIEX_ASSOC_RSP_BUF_SIZE
];
626 #define MWIFIEX_GENIE_BUF_SIZE 256
627 u8 gen_ie_buf
[MWIFIEX_GENIE_BUF_SIZE
];
630 struct mwifiex_vendor_spec_cfg_ie vs_ie
[MWIFIEX_MAX_VSIE_NUM
];
632 #define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
633 u8 assoc_tlv_buf
[MWIFIEX_ASSOC_TLV_BUF_SIZE
];
634 u8 assoc_tlv_buf_len
;
638 /* spin lock for beacon buffer */
639 spinlock_t curr_bcn_buf_lock
;
640 struct wireless_dev wdev
;
641 struct mwifiex_chan_freq_power cfp
;
643 char version_str
[128];
644 #ifdef CONFIG_DEBUG_FS
645 struct dentry
*dfs_dev_dir
;
647 u16 current_key_index
;
648 struct mutex async_mutex
;
649 struct cfg80211_scan_request
*scan_request
;
655 u8 subsc_evt_rssi_state
;
656 struct mwifiex_ds_misc_subsc_evt async_subsc_evt_storage
;
657 struct mwifiex_ie mgmt_ie
[MAX_MGMT_IE_INDEX
];
665 struct mwifiex_roc_cfg roc_cfg
;
669 unsigned long csa_expire_time
;
672 struct mwifiex_uap_bss_param bss_cfg
;
673 struct cfg80211_chan_def bss_chandef
;
674 struct station_parameters
*sta_params
;
675 struct sk_buff_head tdls_txq
;
677 struct timer_list auto_tdls_timer
;
678 bool auto_tdls_timer_active
;
679 struct idr ack_status_frames
;
680 /* spin lock for ack status */
681 spinlock_t ack_status_lock
;
682 /** rx histogram data */
683 struct mwifiex_histogram_data
*hist_data
;
684 struct cfg80211_chan_def dfs_chandef
;
685 struct workqueue_struct
*dfs_cac_workqueue
;
686 struct delayed_work dfs_cac_work
;
687 struct timer_list dfs_chan_switch_timer
;
688 struct workqueue_struct
*dfs_chan_sw_workqueue
;
689 struct delayed_work dfs_chan_sw_work
;
690 struct cfg80211_beacon_data beacon_after
;
691 struct mwifiex_11h_intf_state state_11h
;
692 struct mwifiex_ds_mem_rw mem_rw
;
693 struct sk_buff_head bypass_txq
;
694 struct mwifiex_user_scan_chan hidden_chan
[MWIFIEX_USER_SCAN_CHAN_MAX
];
695 u8 assoc_resp_ht_param
;
696 bool ht_param_present
;
700 struct mwifiex_tx_ba_stream_tbl
{
701 struct list_head list
;
704 enum mwifiex_ba_status ba_status
;
708 struct mwifiex_rx_reorder_tbl
;
710 struct reorder_tmr_cnxt
{
711 struct timer_list timer
;
712 struct mwifiex_rx_reorder_tbl
*ptr
;
713 struct mwifiex_private
*priv
;
717 struct mwifiex_rx_reorder_tbl
{
718 struct list_head list
;
724 void **rx_reorder_ptr
;
725 struct reorder_tmr_cnxt timer_context
;
730 struct mwifiex_bss_prio_node
{
731 struct list_head list
;
732 struct mwifiex_private
*priv
;
735 struct mwifiex_bss_prio_tbl
{
736 struct list_head bss_prio_head
;
737 /* spin lock for bss priority */
738 spinlock_t bss_prio_lock
;
739 struct mwifiex_bss_prio_node
*bss_prio_cur
;
742 struct cmd_ctrl_node
{
743 struct list_head list
;
744 struct mwifiex_private
*priv
;
747 struct sk_buff
*cmd_skb
;
748 struct sk_buff
*resp_skb
;
756 struct mwifiex_bss_priv
{
761 struct mwifiex_tdls_capab
{
768 struct ieee80211_ht_cap ht_capb
;
769 struct ieee80211_ht_operation ht_oper
;
770 struct ieee_types_extcap extcap
;
771 struct ieee_types_generic rsn_ie
;
772 struct ieee80211_vht_cap vhtcap
;
773 struct ieee80211_vht_operation vhtoper
;
776 struct mwifiex_station_stats
{
788 /* This is AP/TDLS specific structure which stores information
789 * about associated/peer STA
791 struct mwifiex_sta_node
{
792 struct list_head list
;
793 u8 mac_addr
[ETH_ALEN
];
797 u8 ampdu_sta
[MAX_NUM_TID
];
798 u16 rx_seq
[MAX_NUM_TID
];
801 struct mwifiex_tdls_capab tdls_cap
;
802 struct mwifiex_station_stats stats
;
806 struct mwifiex_auto_tdls_peer
{
807 struct list_head list
;
808 u8 mac_addr
[ETH_ALEN
];
817 #define MWIFIEX_TYPE_AGGR_DATA_V2 11
818 #define MWIFIEX_BUS_AGGR_MODE_LEN_V2 (2)
819 #define MWIFIEX_BUS_AGGR_MAX_LEN 16000
820 #define MWIFIEX_BUS_AGGR_MAX_NUM 10
821 struct bus_aggr_params
{
824 u16 tx_aggr_max_size
;
829 struct mwifiex_if_ops
{
830 int (*init_if
) (struct mwifiex_adapter
*);
831 void (*cleanup_if
) (struct mwifiex_adapter
*);
832 int (*check_fw_status
) (struct mwifiex_adapter
*, u32
);
833 int (*check_winner_status
)(struct mwifiex_adapter
*);
834 int (*prog_fw
) (struct mwifiex_adapter
*, struct mwifiex_fw_image
*);
835 int (*register_dev
) (struct mwifiex_adapter
*);
836 void (*unregister_dev
) (struct mwifiex_adapter
*);
837 int (*enable_int
) (struct mwifiex_adapter
*);
838 void (*disable_int
) (struct mwifiex_adapter
*);
839 int (*process_int_status
) (struct mwifiex_adapter
*);
840 int (*host_to_card
) (struct mwifiex_adapter
*, u8
, struct sk_buff
*,
841 struct mwifiex_tx_param
*);
842 int (*wakeup
) (struct mwifiex_adapter
*);
843 int (*wakeup_complete
) (struct mwifiex_adapter
*);
845 /* Interface specific functions */
846 void (*update_mp_end_port
) (struct mwifiex_adapter
*, u16
);
847 void (*cleanup_mpa_buf
) (struct mwifiex_adapter
*);
848 int (*cmdrsp_complete
) (struct mwifiex_adapter
*, struct sk_buff
*);
849 int (*event_complete
) (struct mwifiex_adapter
*, struct sk_buff
*);
850 int (*init_fw_port
) (struct mwifiex_adapter
*);
851 int (*dnld_fw
) (struct mwifiex_adapter
*, struct mwifiex_fw_image
*);
852 void (*card_reset
) (struct mwifiex_adapter
*);
853 int (*reg_dump
)(struct mwifiex_adapter
*, char *);
854 void (*device_dump
)(struct mwifiex_adapter
*);
855 int (*clean_pcie_ring
) (struct mwifiex_adapter
*adapter
);
856 void (*iface_work
)(struct work_struct
*work
);
857 void (*submit_rem_rx_urbs
)(struct mwifiex_adapter
*adapter
);
858 void (*deaggr_pkt
)(struct mwifiex_adapter
*, struct sk_buff
*);
859 void (*multi_port_resync
)(struct mwifiex_adapter
*);
860 bool (*is_port_ready
)(struct mwifiex_private
*);
861 void (*down_dev
)(struct mwifiex_adapter
*);
862 void (*up_dev
)(struct mwifiex_adapter
*);
865 struct mwifiex_adapter
{
867 unsigned int debug_mask
;
868 struct mwifiex_iface_comb iface_limit
;
869 struct mwifiex_iface_comb curr_iface_comb
;
870 struct mwifiex_private
*priv
[MWIFIEX_MAX_BSS_NUM
];
872 const struct firmware
*firmware
;
877 u8 perm_addr
[ETH_ALEN
];
878 bool surprise_removed
;
879 u32 fw_release_number
;
881 u16 init_wait_q_woken
;
882 wait_queue_head_t init_wait_q
;
884 struct mwifiex_if_ops if_ops
;
885 atomic_t bypass_tx_pending
;
888 atomic_t cmd_pending
;
889 atomic_t tx_hw_pending
;
890 struct workqueue_struct
*workqueue
;
891 struct work_struct main_work
;
892 struct workqueue_struct
*rx_workqueue
;
893 struct work_struct rx_work
;
894 struct workqueue_struct
*dfs_workqueue
;
895 struct work_struct dfs_work
;
896 bool rx_work_enabled
;
898 bool delay_main_work
;
901 struct mwifiex_bss_prio_tbl bss_prio_tbl
[MWIFIEX_MAX_BSS_NUM
];
902 /* spin lock for main process */
903 spinlock_t main_proc_lock
;
904 u32 mwifiex_processing
;
907 u16 curr_tx_buf_size
;
908 /* sdio single port rx aggregation capability */
909 bool host_disable_sdio_rx_aggr
;
910 bool sdio_rx_aggr_enable
;
911 u16 sdio_rx_block_size
;
913 enum MWIFIEX_HARDWARE_STATUS hw_status
;
914 u16 number_of_antenna
;
916 /* spin lock for interrupt handling */
920 struct sk_buff
*event_skb
;
921 u8 upld_buf
[MWIFIEX_UPLD_SIZE
];
924 u8 cmd_resp_received
;
928 struct cmd_ctrl_node
*cmd_pool
;
929 struct cmd_ctrl_node
*curr_cmd
;
930 /* spin lock for command */
931 spinlock_t mwifiex_cmd_lock
;
934 struct timer_list cmd_timer
;
935 struct list_head cmd_free_q
;
936 /* spin lock for cmd_free_q */
937 spinlock_t cmd_free_q_lock
;
938 struct list_head cmd_pending_q
;
939 /* spin lock for cmd_pending_q */
940 spinlock_t cmd_pending_q_lock
;
941 struct list_head scan_pending_q
;
942 /* spin lock for scan_pending_q */
943 spinlock_t scan_pending_q_lock
;
944 /* spin lock for RX processing routine */
945 spinlock_t rx_proc_lock
;
946 struct sk_buff_head tx_data_q
;
950 struct mwifiex_802_11d_domain_reg domain_reg
;
953 u16 specific_scan_time
;
954 u16 active_scan_time
;
955 u16 passive_scan_time
;
956 u16 scan_chan_gap_time
;
960 struct mwifiex_chan_scan_param_set
*scan_channels
;
962 struct mwifiex_sleep_params sleep_params
;
963 struct mwifiex_sleep_period sleep_period
;
968 u16 local_listen_interval
;
969 u16 null_pkt_interval
;
970 struct sk_buff
*sleep_cfm
;
971 u16 bcn_miss_time_out
;
972 u16 adhoc_awake_period
;
976 u16 enhanced_ps_mode
;
977 u8 pm_wakeup_card_req
;
980 u32 pm_wakeup_fw_try
;
981 struct timer_list wakeup_timer
;
983 struct mwifiex_hs_config_param hs_cfg
;
985 u16 hs_activate_wait_q_woken
;
986 wait_queue_head_t hs_activate_wait_q
;
989 u8 event_body
[MAX_EVENT_SIZE
];
990 u32 hw_dot_11n_dev_cap
;
991 u8 hw_dev_mcs_support
;
992 u8 user_dev_mcs_support
;
993 u8 adhoc_11n_enabled
;
995 struct mwifiex_dbg dbg
;
996 u8 arp_filter
[ARP_FILTER_MAX_BUF_SIZE
];
998 struct mwifiex_wait_queue cmd_wait_q
;
999 u8 scan_wait_q_woken
;
1000 spinlock_t queue_lock
; /* lock for tx queues */
1001 u8 country_code
[IEEE80211_COUNTRY_STRING_LEN
];
1002 u16 max_mgmt_ie_index
;
1003 const struct firmware
*cal_data
;
1004 struct device_node
*dt_node
;
1007 u32 is_hw_11ac_capable
;
1008 u32 hw_dot_11ac_dev_cap
;
1009 u32 hw_dot_11ac_mcs_support
;
1010 u32 usr_dot_11ac_dev_cap_bg
;
1011 u32 usr_dot_11ac_dev_cap_a
;
1012 u32 usr_dot_11ac_mcs_support
;
1014 atomic_t pending_bridged_pkts
;
1016 /* For synchronizing FW initialization with device lifecycle. */
1017 struct completion
*fw_done
;
1021 u8 key_api_major_ver
, key_api_minor_ver
;
1022 struct memory_type_mapping
*mem_type_mapping_tbl
;
1024 bool scan_chan_gap_enabled
;
1025 struct sk_buff_head rx_data_q
;
1027 struct mwifiex_chan_stats
*chan_stats
;
1028 u32 num_in_chan_stats
;
1032 u8 coex_min_scan_time
;
1033 u8 coex_max_scan_time
;
1035 u8 coex_tx_win_size
;
1036 u8 coex_rx_win_size
;
1038 u8 active_scan_triggered
;
1041 struct cfg80211_wowlan_nd_info
*nd_info
;
1042 struct ieee80211_regdomain
*regd
;
1044 /* Wake-on-WLAN (WoWLAN) */
1047 /* Aggregation parameters*/
1048 struct bus_aggr_params bus_aggr
;
1049 /* Device dump data/length */
1052 struct timer_list devdump_timer
;
1055 void mwifiex_process_tx_queue(struct mwifiex_adapter
*adapter
);
1057 int mwifiex_init_lock_list(struct mwifiex_adapter
*adapter
);
1059 void mwifiex_set_trans_start(struct net_device
*dev
);
1061 void mwifiex_stop_net_dev_queue(struct net_device
*netdev
,
1062 struct mwifiex_adapter
*adapter
);
1064 void mwifiex_wake_up_net_dev_queue(struct net_device
*netdev
,
1065 struct mwifiex_adapter
*adapter
);
1067 int mwifiex_init_priv(struct mwifiex_private
*priv
);
1068 void mwifiex_free_priv(struct mwifiex_private
*priv
);
1070 int mwifiex_init_fw(struct mwifiex_adapter
*adapter
);
1072 int mwifiex_init_fw_complete(struct mwifiex_adapter
*adapter
);
1074 void mwifiex_shutdown_drv(struct mwifiex_adapter
*adapter
);
1076 int mwifiex_dnld_fw(struct mwifiex_adapter
*, struct mwifiex_fw_image
*);
1078 int mwifiex_recv_packet(struct mwifiex_private
*priv
, struct sk_buff
*skb
);
1079 int mwifiex_uap_recv_packet(struct mwifiex_private
*priv
,
1080 struct sk_buff
*skb
);
1082 int mwifiex_process_mgmt_packet(struct mwifiex_private
*priv
,
1083 struct sk_buff
*skb
);
1085 int mwifiex_process_event(struct mwifiex_adapter
*adapter
);
1087 int mwifiex_complete_cmd(struct mwifiex_adapter
*adapter
,
1088 struct cmd_ctrl_node
*cmd_node
);
1090 int mwifiex_send_cmd(struct mwifiex_private
*priv
, u16 cmd_no
,
1091 u16 cmd_action
, u32 cmd_oid
, void *data_buf
, bool sync
);
1093 void mwifiex_cmd_timeout_func(struct timer_list
*t
);
1095 int mwifiex_get_debug_info(struct mwifiex_private
*,
1096 struct mwifiex_debug_info
*);
1098 int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter
*adapter
);
1099 void mwifiex_free_cmd_buffer(struct mwifiex_adapter
*adapter
);
1100 void mwifiex_free_cmd_buffers(struct mwifiex_adapter
*adapter
);
1101 void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter
*adapter
);
1102 void mwifiex_cancel_pending_scan_cmd(struct mwifiex_adapter
*adapter
);
1103 void mwifiex_cancel_scan(struct mwifiex_adapter
*adapter
);
1105 void mwifiex_recycle_cmd_node(struct mwifiex_adapter
*adapter
,
1106 struct cmd_ctrl_node
*cmd_node
);
1108 void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter
*adapter
,
1109 struct cmd_ctrl_node
*cmd_node
);
1111 int mwifiex_exec_next_cmd(struct mwifiex_adapter
*adapter
);
1112 int mwifiex_process_cmdresp(struct mwifiex_adapter
*adapter
);
1113 int mwifiex_handle_rx_packet(struct mwifiex_adapter
*adapter
,
1114 struct sk_buff
*skb
);
1115 int mwifiex_process_tx(struct mwifiex_private
*priv
, struct sk_buff
*skb
,
1116 struct mwifiex_tx_param
*tx_param
);
1117 int mwifiex_send_null_packet(struct mwifiex_private
*priv
, u8 flags
);
1118 int mwifiex_write_data_complete(struct mwifiex_adapter
*adapter
,
1119 struct sk_buff
*skb
, int aggr
, int status
);
1120 void mwifiex_clean_txrx(struct mwifiex_private
*priv
);
1121 u8
mwifiex_check_last_packet_indication(struct mwifiex_private
*priv
);
1122 void mwifiex_check_ps_cond(struct mwifiex_adapter
*adapter
);
1123 void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter
*, u8
*,
1125 int mwifiex_cmd_enh_power_mode(struct mwifiex_private
*priv
,
1126 struct host_cmd_ds_command
*cmd
,
1127 u16 cmd_action
, uint16_t ps_bitmap
,
1128 struct mwifiex_ds_auto_ds
*auto_ds
);
1129 int mwifiex_ret_enh_power_mode(struct mwifiex_private
*priv
,
1130 struct host_cmd_ds_command
*resp
,
1131 struct mwifiex_ds_pm_cfg
*pm_cfg
);
1132 void mwifiex_process_hs_config(struct mwifiex_adapter
*adapter
);
1133 void mwifiex_hs_activated_event(struct mwifiex_private
*priv
,
1135 int mwifiex_set_hs_params(struct mwifiex_private
*priv
, u16 action
,
1136 int cmd_type
, struct mwifiex_ds_hs_cfg
*hs_cfg
);
1137 int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private
*priv
,
1138 struct host_cmd_ds_command
*resp
);
1139 int mwifiex_process_rx_packet(struct mwifiex_private
*priv
,
1140 struct sk_buff
*skb
);
1141 int mwifiex_sta_prepare_cmd(struct mwifiex_private
*, uint16_t cmd_no
,
1142 u16 cmd_action
, u32 cmd_oid
,
1143 void *data_buf
, void *cmd_buf
);
1144 int mwifiex_uap_prepare_cmd(struct mwifiex_private
*priv
, uint16_t cmd_no
,
1145 u16 cmd_action
, u32 cmd_oid
,
1146 void *data_buf
, void *cmd_buf
);
1147 int mwifiex_process_sta_cmdresp(struct mwifiex_private
*, u16 cmdresp_no
,
1148 struct host_cmd_ds_command
*resp
);
1149 int mwifiex_process_sta_rx_packet(struct mwifiex_private
*,
1150 struct sk_buff
*skb
);
1151 int mwifiex_process_uap_rx_packet(struct mwifiex_private
*priv
,
1152 struct sk_buff
*skb
);
1153 int mwifiex_handle_uap_rx_forward(struct mwifiex_private
*priv
,
1154 struct sk_buff
*skb
);
1155 int mwifiex_process_sta_event(struct mwifiex_private
*);
1156 int mwifiex_process_uap_event(struct mwifiex_private
*);
1157 void mwifiex_delete_all_station_list(struct mwifiex_private
*priv
);
1158 void mwifiex_wmm_del_peer_ra_list(struct mwifiex_private
*priv
,
1160 void *mwifiex_process_sta_txpd(struct mwifiex_private
*, struct sk_buff
*skb
);
1161 void *mwifiex_process_uap_txpd(struct mwifiex_private
*, struct sk_buff
*skb
);
1162 int mwifiex_sta_init_cmd(struct mwifiex_private
*, u8 first_sta
, bool init
);
1163 int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command
*cmd
,
1164 struct mwifiex_scan_cmd_config
*scan_cfg
);
1165 void mwifiex_queue_scan_cmd(struct mwifiex_private
*priv
,
1166 struct cmd_ctrl_node
*cmd_node
);
1167 int mwifiex_ret_802_11_scan(struct mwifiex_private
*priv
,
1168 struct host_cmd_ds_command
*resp
);
1169 s32
mwifiex_ssid_cmp(struct cfg80211_ssid
*ssid1
, struct cfg80211_ssid
*ssid2
);
1170 int mwifiex_associate(struct mwifiex_private
*priv
,
1171 struct mwifiex_bssdescriptor
*bss_desc
);
1172 int mwifiex_cmd_802_11_associate(struct mwifiex_private
*priv
,
1173 struct host_cmd_ds_command
*cmd
,
1174 struct mwifiex_bssdescriptor
*bss_desc
);
1175 int mwifiex_ret_802_11_associate(struct mwifiex_private
*priv
,
1176 struct host_cmd_ds_command
*resp
);
1177 void mwifiex_reset_connect_state(struct mwifiex_private
*priv
, u16 reason
,
1179 u8
mwifiex_band_to_radio_type(u8 band
);
1180 int mwifiex_deauthenticate(struct mwifiex_private
*priv
, u8
*mac
);
1181 void mwifiex_deauthenticate_all(struct mwifiex_adapter
*adapter
);
1182 int mwifiex_adhoc_start(struct mwifiex_private
*priv
,
1183 struct cfg80211_ssid
*adhoc_ssid
);
1184 int mwifiex_adhoc_join(struct mwifiex_private
*priv
,
1185 struct mwifiex_bssdescriptor
*bss_desc
);
1186 int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private
*priv
,
1187 struct host_cmd_ds_command
*cmd
,
1188 struct cfg80211_ssid
*req_ssid
);
1189 int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private
*priv
,
1190 struct host_cmd_ds_command
*cmd
,
1191 struct mwifiex_bssdescriptor
*bss_desc
);
1192 int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private
*priv
,
1193 struct host_cmd_ds_command
*resp
);
1194 int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command
*cmd
);
1195 struct mwifiex_chan_freq_power
*mwifiex_get_cfp(struct mwifiex_private
*priv
,
1196 u8 band
, u16 channel
, u32 freq
);
1197 u32
mwifiex_index_to_data_rate(struct mwifiex_private
*priv
,
1198 u8 index
, u8 ht_info
);
1199 u32
mwifiex_index_to_acs_data_rate(struct mwifiex_private
*priv
,
1200 u8 index
, u8 ht_info
);
1201 u32
mwifiex_find_freq_from_band_chan(u8
, u8
);
1202 int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private
*priv
, u16 vsie_mask
,
1204 u32
mwifiex_get_active_data_rates(struct mwifiex_private
*priv
,
1206 u32
mwifiex_get_supported_rates(struct mwifiex_private
*priv
, u8
*rates
);
1207 u32
mwifiex_get_rates_from_cfg80211(struct mwifiex_private
*priv
,
1208 u8
*rates
, u8 radio_type
);
1209 u8
mwifiex_is_rate_auto(struct mwifiex_private
*priv
);
1210 extern u16 region_code_index
[MWIFIEX_MAX_REGION_CODE
];
1211 void mwifiex_save_curr_bcn(struct mwifiex_private
*priv
);
1212 void mwifiex_free_curr_bcn(struct mwifiex_private
*priv
);
1213 int mwifiex_cmd_get_hw_spec(struct mwifiex_private
*priv
,
1214 struct host_cmd_ds_command
*cmd
);
1215 int mwifiex_ret_get_hw_spec(struct mwifiex_private
*priv
,
1216 struct host_cmd_ds_command
*resp
);
1217 int is_command_pending(struct mwifiex_adapter
*adapter
);
1218 void mwifiex_init_priv_params(struct mwifiex_private
*priv
,
1219 struct net_device
*dev
);
1220 int mwifiex_set_secure_params(struct mwifiex_private
*priv
,
1221 struct mwifiex_uap_bss_param
*bss_config
,
1222 struct cfg80211_ap_settings
*params
);
1223 void mwifiex_set_ht_params(struct mwifiex_private
*priv
,
1224 struct mwifiex_uap_bss_param
*bss_cfg
,
1225 struct cfg80211_ap_settings
*params
);
1226 void mwifiex_set_vht_params(struct mwifiex_private
*priv
,
1227 struct mwifiex_uap_bss_param
*bss_cfg
,
1228 struct cfg80211_ap_settings
*params
);
1229 void mwifiex_set_tpc_params(struct mwifiex_private
*priv
,
1230 struct mwifiex_uap_bss_param
*bss_cfg
,
1231 struct cfg80211_ap_settings
*params
);
1232 void mwifiex_set_uap_rates(struct mwifiex_uap_bss_param
*bss_cfg
,
1233 struct cfg80211_ap_settings
*params
);
1234 void mwifiex_set_vht_width(struct mwifiex_private
*priv
,
1235 enum nl80211_chan_width width
,
1236 bool ap_11ac_disable
);
1238 mwifiex_set_wmm_params(struct mwifiex_private
*priv
,
1239 struct mwifiex_uap_bss_param
*bss_cfg
,
1240 struct cfg80211_ap_settings
*params
);
1241 void mwifiex_set_ba_params(struct mwifiex_private
*priv
);
1243 void mwifiex_update_ampdu_txwinsize(struct mwifiex_adapter
*pmadapter
);
1244 void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private
*priv
,
1245 struct sk_buff
*event_skb
);
1247 void mwifiex_set_11ac_ba_params(struct mwifiex_private
*priv
);
1248 int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private
*priv
,
1249 struct host_cmd_ds_command
*cmd
,
1251 int mwifiex_ret_802_11_scan_ext(struct mwifiex_private
*priv
,
1252 struct host_cmd_ds_command
*resp
);
1253 int mwifiex_handle_event_ext_scan_report(struct mwifiex_private
*priv
,
1255 int mwifiex_cmd_802_11_bg_scan_config(struct mwifiex_private
*priv
,
1256 struct host_cmd_ds_command
*cmd
,
1258 int mwifiex_stop_bg_scan(struct mwifiex_private
*priv
);
1261 * This function checks if the queuing is RA based or not.
1264 mwifiex_queuing_ra_based(struct mwifiex_private
*priv
)
1267 * Currently we assume if we are in Infra, then DA=RA. This might not be
1268 * true in the future
1270 if ((priv
->bss_mode
== NL80211_IFTYPE_STATION
||
1271 priv
->bss_mode
== NL80211_IFTYPE_P2P_CLIENT
) &&
1272 (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
))
1279 * This function copies rates.
1282 mwifiex_copy_rates(u8
*dest
, u32 pos
, u8
*src
, int len
)
1286 for (i
= 0; i
< len
&& src
[i
]; i
++, pos
++) {
1287 if (pos
>= MWIFIEX_SUPPORTED_RATES
)
1295 /* This function return interface number with the same bss_type.
1298 mwifiex_get_intf_num(struct mwifiex_adapter
*adapter
, u8 bss_type
)
1302 for (i
= 0; i
< adapter
->priv_num
; i
++)
1303 if (adapter
->priv
[i
] && adapter
->priv
[i
]->bss_type
== bss_type
)
1309 * This function returns the correct private structure pointer based
1310 * upon the BSS type and BSS number.
1312 static inline struct mwifiex_private
*
1313 mwifiex_get_priv_by_id(struct mwifiex_adapter
*adapter
,
1314 u8 bss_num
, u8 bss_type
)
1318 for (i
= 0; i
< adapter
->priv_num
; i
++) {
1319 if (adapter
->priv
[i
]) {
1320 if ((adapter
->priv
[i
]->bss_num
== bss_num
) &&
1321 (adapter
->priv
[i
]->bss_type
== bss_type
))
1325 return ((i
< adapter
->priv_num
) ? adapter
->priv
[i
] : NULL
);
1329 * This function returns the first available private structure pointer
1330 * based upon the BSS role.
1332 static inline struct mwifiex_private
*
1333 mwifiex_get_priv(struct mwifiex_adapter
*adapter
,
1334 enum mwifiex_bss_role bss_role
)
1338 for (i
= 0; i
< adapter
->priv_num
; i
++) {
1339 if (adapter
->priv
[i
]) {
1340 if (bss_role
== MWIFIEX_BSS_ROLE_ANY
||
1341 GET_BSS_ROLE(adapter
->priv
[i
]) == bss_role
)
1346 return ((i
< adapter
->priv_num
) ? adapter
->priv
[i
] : NULL
);
1350 * This function checks available bss_num when adding new interface or
1351 * changing interface type.
1354 mwifiex_get_unused_bss_num(struct mwifiex_adapter
*adapter
, u8 bss_type
)
1357 int index
[MWIFIEX_MAX_BSS_NUM
];
1359 memset(index
, 0, sizeof(index
));
1360 for (i
= 0; i
< adapter
->priv_num
; i
++)
1361 if (adapter
->priv
[i
]) {
1362 if (adapter
->priv
[i
]->bss_type
== bss_type
&&
1363 !(adapter
->priv
[i
]->bss_mode
==
1364 NL80211_IFTYPE_UNSPECIFIED
)) {
1365 index
[adapter
->priv
[i
]->bss_num
] = 1;
1368 for (j
= 0; j
< MWIFIEX_MAX_BSS_NUM
; j
++)
1375 * This function returns the first available unused private structure pointer.
1377 static inline struct mwifiex_private
*
1378 mwifiex_get_unused_priv_by_bss_type(struct mwifiex_adapter
*adapter
,
1383 for (i
= 0; i
< adapter
->priv_num
; i
++)
1384 if (adapter
->priv
[i
]->bss_mode
==
1385 NL80211_IFTYPE_UNSPECIFIED
) {
1386 adapter
->priv
[i
]->bss_num
=
1387 mwifiex_get_unused_bss_num(adapter
, bss_type
);
1391 return ((i
< adapter
->priv_num
) ? adapter
->priv
[i
] : NULL
);
1395 * This function returns the driver private structure of a network device.
1397 static inline struct mwifiex_private
*
1398 mwifiex_netdev_get_priv(struct net_device
*dev
)
1400 return (struct mwifiex_private
*) (*(unsigned long *) netdev_priv(dev
));
1404 * This function checks if a skb holds a management frame.
1406 static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff
*skb
)
1408 return (get_unaligned_le32(skb
->data
) == PKT_TYPE_MGMT
);
1411 /* This function retrieves channel closed for operation by Channel
1412 * Switch Announcement.
1415 mwifiex_11h_get_csa_closed_channel(struct mwifiex_private
*priv
)
1417 if (!priv
->csa_chan
)
1420 /* Clear csa channel, if DFS channel move time has passed */
1421 if (time_after(jiffies
, priv
->csa_expire_time
)) {
1423 priv
->csa_expire_time
= 0;
1426 return priv
->csa_chan
;
1429 static inline u8
mwifiex_is_any_intf_active(struct mwifiex_private
*priv
)
1431 struct mwifiex_private
*priv_num
;
1434 for (i
= 0; i
< priv
->adapter
->priv_num
; i
++) {
1435 priv_num
= priv
->adapter
->priv
[i
];
1437 if ((GET_BSS_ROLE(priv_num
) == MWIFIEX_BSS_ROLE_UAP
&&
1438 priv_num
->bss_started
) ||
1439 (GET_BSS_ROLE(priv_num
) == MWIFIEX_BSS_ROLE_STA
&&
1440 priv_num
->media_connected
))
1448 static inline u8
mwifiex_is_tdls_link_setup(u8 status
)
1451 case TDLS_SETUP_COMPLETE
:
1452 case TDLS_CHAN_SWITCHING
:
1453 case TDLS_IN_BASE_CHAN
:
1454 case TDLS_IN_OFF_CHAN
:
1463 /* Disable platform specific wakeup interrupt */
1464 static inline void mwifiex_disable_wake(struct mwifiex_adapter
*adapter
)
1466 if (adapter
->irq_wakeup
>= 0) {
1467 disable_irq_wake(adapter
->irq_wakeup
);
1468 disable_irq(adapter
->irq_wakeup
);
1469 if (adapter
->wake_by_wifi
)
1470 /* Undo our disable, since interrupt handler already
1473 enable_irq(adapter
->irq_wakeup
);
1478 /* Enable platform specific wakeup interrupt */
1479 static inline void mwifiex_enable_wake(struct mwifiex_adapter
*adapter
)
1481 /* Enable platform specific wakeup interrupt */
1482 if (adapter
->irq_wakeup
>= 0) {
1483 adapter
->wake_by_wifi
= false;
1484 enable_irq(adapter
->irq_wakeup
);
1485 enable_irq_wake(adapter
->irq_wakeup
);
1489 int mwifiex_init_shutdown_fw(struct mwifiex_private
*priv
,
1490 u32 func_init_shutdown
);
1492 int mwifiex_add_card(void *card
, struct completion
*fw_done
,
1493 struct mwifiex_if_ops
*if_ops
, u8 iface_type
,
1494 struct device
*dev
);
1495 int mwifiex_remove_card(struct mwifiex_adapter
*adapter
);
1497 void mwifiex_get_version(struct mwifiex_adapter
*adapter
, char *version
,
1499 int mwifiex_request_set_multicast_list(struct mwifiex_private
*priv
,
1500 struct mwifiex_multicast_list
*mcast_list
);
1501 int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list
*mlist
,
1502 struct net_device
*dev
);
1503 int mwifiex_wait_queue_complete(struct mwifiex_adapter
*adapter
,
1504 struct cmd_ctrl_node
*cmd_queued
);
1505 int mwifiex_bss_start(struct mwifiex_private
*priv
, struct cfg80211_bss
*bss
,
1506 struct cfg80211_ssid
*req_ssid
);
1507 int mwifiex_cancel_hs(struct mwifiex_private
*priv
, int cmd_type
);
1508 int mwifiex_enable_hs(struct mwifiex_adapter
*adapter
);
1509 int mwifiex_disable_auto_ds(struct mwifiex_private
*priv
);
1510 int mwifiex_drv_get_data_rate(struct mwifiex_private
*priv
, u32
*rate
);
1511 int mwifiex_request_scan(struct mwifiex_private
*priv
,
1512 struct cfg80211_ssid
*req_ssid
);
1513 int mwifiex_scan_networks(struct mwifiex_private
*priv
,
1514 const struct mwifiex_user_scan_cfg
*user_scan_in
);
1515 int mwifiex_set_radio(struct mwifiex_private
*priv
, u8 option
);
1517 int mwifiex_set_encode(struct mwifiex_private
*priv
, struct key_params
*kp
,
1518 const u8
*key
, int key_len
, u8 key_index
,
1519 const u8
*mac_addr
, int disable
);
1521 int mwifiex_set_gen_ie(struct mwifiex_private
*priv
, const u8
*ie
, int ie_len
);
1523 int mwifiex_get_ver_ext(struct mwifiex_private
*priv
, u32 version_str_sel
);
1525 int mwifiex_remain_on_chan_cfg(struct mwifiex_private
*priv
, u16 action
,
1526 struct ieee80211_channel
*chan
,
1527 unsigned int duration
);
1529 int mwifiex_get_stats_info(struct mwifiex_private
*priv
,
1530 struct mwifiex_ds_get_stats
*log
);
1532 int mwifiex_reg_write(struct mwifiex_private
*priv
, u32 reg_type
,
1533 u32 reg_offset
, u32 reg_value
);
1535 int mwifiex_reg_read(struct mwifiex_private
*priv
, u32 reg_type
,
1536 u32 reg_offset
, u32
*value
);
1538 int mwifiex_eeprom_read(struct mwifiex_private
*priv
, u16 offset
, u16 bytes
,
1541 int mwifiex_set_11n_httx_cfg(struct mwifiex_private
*priv
, int data
);
1543 int mwifiex_get_11n_httx_cfg(struct mwifiex_private
*priv
, int *data
);
1545 int mwifiex_set_tx_rate_cfg(struct mwifiex_private
*priv
, int tx_rate_index
);
1547 int mwifiex_get_tx_rate_cfg(struct mwifiex_private
*priv
, int *tx_rate_index
);
1549 int mwifiex_drv_set_power(struct mwifiex_private
*priv
, u32
*ps_mode
);
1551 int mwifiex_drv_get_driver_version(struct mwifiex_adapter
*adapter
,
1552 char *version
, int max_len
);
1554 int mwifiex_set_tx_power(struct mwifiex_private
*priv
,
1555 struct mwifiex_power_cfg
*power_cfg
);
1557 int mwifiex_main_process(struct mwifiex_adapter
*);
1559 int mwifiex_queue_tx_pkt(struct mwifiex_private
*priv
, struct sk_buff
*skb
);
1561 int mwifiex_get_bss_info(struct mwifiex_private
*,
1562 struct mwifiex_bss_info
*);
1563 int mwifiex_fill_new_bss_desc(struct mwifiex_private
*priv
,
1564 struct cfg80211_bss
*bss
,
1565 struct mwifiex_bssdescriptor
*bss_desc
);
1566 int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter
*adapter
,
1567 struct mwifiex_bssdescriptor
*bss_entry
);
1568 int mwifiex_check_network_compatibility(struct mwifiex_private
*priv
,
1569 struct mwifiex_bssdescriptor
*bss_desc
);
1571 u8
mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type
);
1572 u8
mwifiex_get_chan_type(struct mwifiex_private
*priv
);
1574 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
1576 unsigned char name_assign_type
,
1577 enum nl80211_iftype type
,
1578 struct vif_params
*params
);
1579 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
);
1581 void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param
*config
);
1583 int mwifiex_add_wowlan_magic_pkt_filter(struct mwifiex_adapter
*adapter
);
1585 int mwifiex_set_mgmt_ies(struct mwifiex_private
*priv
,
1586 struct cfg80211_beacon_data
*data
);
1587 int mwifiex_del_mgmt_ies(struct mwifiex_private
*priv
);
1588 u8
*mwifiex_11d_code_2_region(u8 code
);
1589 void mwifiex_uap_set_channel(struct mwifiex_private
*priv
,
1590 struct mwifiex_uap_bss_param
*bss_cfg
,
1591 struct cfg80211_chan_def chandef
);
1592 int mwifiex_config_start_uap(struct mwifiex_private
*priv
,
1593 struct mwifiex_uap_bss_param
*bss_cfg
);
1594 void mwifiex_uap_del_sta_data(struct mwifiex_private
*priv
,
1595 struct mwifiex_sta_node
*node
);
1597 void mwifiex_config_uap_11d(struct mwifiex_private
*priv
,
1598 struct cfg80211_beacon_data
*beacon_data
);
1600 void mwifiex_init_11h_params(struct mwifiex_private
*priv
);
1601 int mwifiex_is_11h_active(struct mwifiex_private
*priv
);
1602 int mwifiex_11h_activate(struct mwifiex_private
*priv
, bool flag
);
1604 void mwifiex_11h_process_join(struct mwifiex_private
*priv
, u8
**buffer
,
1605 struct mwifiex_bssdescriptor
*bss_desc
);
1606 int mwifiex_11h_handle_event_chanswann(struct mwifiex_private
*priv
);
1607 int mwifiex_dnld_dt_cfgdata(struct mwifiex_private
*priv
,
1608 struct device_node
*node
, const char *prefix
);
1609 void mwifiex_dnld_txpwr_table(struct mwifiex_private
*priv
);
1611 extern const struct ethtool_ops mwifiex_ethtool_ops
;
1613 void mwifiex_del_all_sta_list(struct mwifiex_private
*priv
);
1614 void mwifiex_del_sta_entry(struct mwifiex_private
*priv
, const u8
*mac
);
1616 mwifiex_set_sta_ht_cap(struct mwifiex_private
*priv
, const u8
*ies
,
1617 int ies_len
, struct mwifiex_sta_node
*node
);
1618 struct mwifiex_sta_node
*
1619 mwifiex_add_sta_entry(struct mwifiex_private
*priv
, const u8
*mac
);
1620 struct mwifiex_sta_node
*
1621 mwifiex_get_sta_entry(struct mwifiex_private
*priv
, const u8
*mac
);
1622 u8
mwifiex_is_tdls_chan_switching(struct mwifiex_private
*priv
);
1623 u8
mwifiex_is_tdls_off_chan(struct mwifiex_private
*priv
);
1624 u8
mwifiex_is_send_cmd_allowed(struct mwifiex_private
*priv
);
1625 int mwifiex_send_tdls_data_frame(struct mwifiex_private
*priv
, const u8
*peer
,
1626 u8 action_code
, u8 dialog_token
,
1627 u16 status_code
, const u8
*extra_ies
,
1628 size_t extra_ies_len
);
1629 int mwifiex_send_tdls_action_frame(struct mwifiex_private
*priv
, const u8
*peer
,
1630 u8 action_code
, u8 dialog_token
,
1631 u16 status_code
, const u8
*extra_ies
,
1632 size_t extra_ies_len
);
1633 void mwifiex_process_tdls_action_frame(struct mwifiex_private
*priv
,
1635 int mwifiex_tdls_oper(struct mwifiex_private
*priv
, const u8
*peer
, u8 action
);
1636 int mwifiex_get_tdls_link_status(struct mwifiex_private
*priv
, const u8
*mac
);
1637 int mwifiex_get_tdls_list(struct mwifiex_private
*priv
,
1638 struct tdls_peer_info
*buf
);
1639 void mwifiex_disable_all_tdls_links(struct mwifiex_private
*priv
);
1640 bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private
*priv
);
1641 u8
mwifiex_get_center_freq_index(struct mwifiex_private
*priv
, u8 band
,
1642 u32 pri_chan
, u8 chan_bw
);
1643 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
);
1645 int mwifiex_tdls_check_tx(struct mwifiex_private
*priv
, struct sk_buff
*skb
);
1646 void mwifiex_flush_auto_tdls_list(struct mwifiex_private
*priv
);
1647 void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private
*priv
,
1648 const u8
*mac
, u8 link_status
);
1649 void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private
*priv
,
1650 u8
*mac
, s8 snr
, s8 nflr
);
1651 void mwifiex_check_auto_tdls(struct timer_list
*t
);
1652 void mwifiex_add_auto_tdls_peer(struct mwifiex_private
*priv
, const u8
*mac
);
1653 void mwifiex_setup_auto_tdls_timer(struct mwifiex_private
*priv
);
1654 void mwifiex_clean_auto_tdls(struct mwifiex_private
*priv
);
1655 int mwifiex_config_tdls_enable(struct mwifiex_private
*priv
);
1656 int mwifiex_config_tdls_disable(struct mwifiex_private
*priv
);
1657 int mwifiex_config_tdls_cs_params(struct mwifiex_private
*priv
);
1658 int mwifiex_stop_tdls_cs(struct mwifiex_private
*priv
, const u8
*peer_mac
);
1659 int mwifiex_start_tdls_cs(struct mwifiex_private
*priv
, const u8
*peer_mac
,
1660 u8 primary_chan
, u8 second_chan_offset
, u8 band
);
1662 int mwifiex_cmd_issue_chan_report_request(struct mwifiex_private
*priv
,
1663 struct host_cmd_ds_command
*cmd
,
1665 int mwifiex_11h_handle_chanrpt_ready(struct mwifiex_private
*priv
,
1666 struct sk_buff
*skb
);
1668 void mwifiex_parse_tx_status_event(struct mwifiex_private
*priv
,
1672 mwifiex_clone_skb_for_tx_status(struct mwifiex_private
*priv
,
1673 struct sk_buff
*skb
, u8 flag
, u64
*cookie
);
1674 void mwifiex_dfs_cac_work_queue(struct work_struct
*work
);
1675 void mwifiex_dfs_chan_sw_work_queue(struct work_struct
*work
);
1676 void mwifiex_abort_cac(struct mwifiex_private
*priv
);
1677 int mwifiex_stop_radar_detection(struct mwifiex_private
*priv
,
1678 struct cfg80211_chan_def
*chandef
);
1679 int mwifiex_11h_handle_radar_detected(struct mwifiex_private
*priv
,
1680 struct sk_buff
*skb
);
1682 void mwifiex_hist_data_set(struct mwifiex_private
*priv
, u8 rx_rate
, s8 snr
,
1684 void mwifiex_hist_data_reset(struct mwifiex_private
*priv
);
1685 void mwifiex_hist_data_add(struct mwifiex_private
*priv
,
1686 u8 rx_rate
, s8 snr
, s8 nflr
);
1687 u8
mwifiex_adjust_data_rate(struct mwifiex_private
*priv
,
1688 u8 rx_rate
, u8 ht_info
);
1690 void mwifiex_drv_info_dump(struct mwifiex_adapter
*adapter
);
1691 void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter
*adapter
);
1692 void mwifiex_upload_device_dump(struct mwifiex_adapter
*adapter
);
1693 void *mwifiex_alloc_dma_align_buf(int rx_len
, gfp_t flags
);
1694 void mwifiex_fw_dump_event(struct mwifiex_private
*priv
);
1695 void mwifiex_queue_main_work(struct mwifiex_adapter
*adapter
);
1696 int mwifiex_get_wakeup_reason(struct mwifiex_private
*priv
, u16 action
,
1698 struct mwifiex_ds_wakeup_reason
*wakeup_reason
);
1699 int mwifiex_get_chan_info(struct mwifiex_private
*priv
,
1700 struct mwifiex_channel_band
*channel_band
);
1701 int mwifiex_ret_wakeup_reason(struct mwifiex_private
*priv
,
1702 struct host_cmd_ds_command
*resp
,
1703 struct host_cmd_ds_wakeup_reason
*wakeup_reason
);
1704 void mwifiex_coex_ampdu_rxwinsize(struct mwifiex_adapter
*adapter
);
1705 void mwifiex_11n_delba(struct mwifiex_private
*priv
, int tid
);
1706 int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
);
1707 void mwifiex_process_tx_pause_event(struct mwifiex_private
*priv
,
1708 struct sk_buff
*event
);
1709 void mwifiex_process_multi_chan_event(struct mwifiex_private
*priv
,
1710 struct sk_buff
*event_skb
);
1711 void mwifiex_multi_chan_resync(struct mwifiex_adapter
*adapter
);
1712 int mwifiex_set_mac_address(struct mwifiex_private
*priv
,
1713 struct net_device
*dev
,
1714 bool external
, u8
*new_mac
);
1715 void mwifiex_devdump_tmo_func(unsigned long function_context
);
1717 #ifdef CONFIG_DEBUG_FS
1718 void mwifiex_debugfs_init(void);
1719 void mwifiex_debugfs_remove(void);
1721 void mwifiex_dev_debugfs_init(struct mwifiex_private
*priv
);
1722 void mwifiex_dev_debugfs_remove(struct mwifiex_private
*priv
);
1724 int mwifiex_reinit_sw(struct mwifiex_adapter
*adapter
);
1725 int mwifiex_shutdown_sw(struct mwifiex_adapter
*adapter
);
1726 #endif /* !_MWIFIEX_MAIN_H_ */