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/kernel.h>
24 #include <linux/module.h>
25 #include <linux/sched.h>
26 #include <linux/semaphore.h>
28 #include <linux/skbuff.h>
29 #include <linux/if_arp.h>
30 #include <linux/etherdevice.h>
32 #include <net/lib80211.h>
33 #include <linux/vmalloc.h>
34 #include <linux/firmware.h>
35 #include <linux/ctype.h>
37 #include <linux/idr.h>
45 extern const char driver_version[];
52 #define MWIFIEX_DRIVER_MODE_STA BIT(0)
53 #define MWIFIEX_DRIVER_MODE_UAP BIT(1)
54 #define MWIFIEX_DRIVER_MODE_P2P BIT(2)
55 #define MWIFIEX_DRIVER_MODE_BITMASK (BIT(0) | BIT(1) | BIT(2))
57 #define MWIFIEX_MAX_AP 64
59 #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
61 #define MWIFIEX_TIMER_10S 10000
62 #define MWIFIEX_TIMER_1S 1000
64 #define MAX_TX_PENDING 100
65 #define LOW_TX_PENDING 80
67 #define HIGH_RX_PENDING 50
68 #define LOW_RX_PENDING 20
70 #define MWIFIEX_UPLD_SIZE (2312)
72 #define MAX_EVENT_SIZE 2048
74 #define ARP_FILTER_MAX_BUF_SIZE 68
76 #define MWIFIEX_KEY_BUFFER_SIZE 16
77 #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
78 #define MWIFIEX_MAX_REGION_CODE 7
80 #define DEFAULT_BCN_AVG_FACTOR 8
81 #define DEFAULT_DATA_AVG_FACTOR 8
83 #define FIRST_VALID_CHANNEL 0xff
84 #define DEFAULT_AD_HOC_CHANNEL 6
85 #define DEFAULT_AD_HOC_CHANNEL_A 36
87 #define DEFAULT_BCN_MISS_TIMEOUT 5
89 #define MAX_SCAN_BEACON_BUFFER 8000
91 #define SCAN_BEACON_ENTRY_PAD 6
93 #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
94 #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 30
95 #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 30
96 #define MWIFIEX_DEF_SCAN_CHAN_GAP_TIME 50
98 #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI)))
100 #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
102 #define RSN_GTK_OUI_OFFSET 2
104 #define MWIFIEX_OUI_NOT_PRESENT 0
105 #define MWIFIEX_OUI_PRESENT 1
107 #define PKT_TYPE_MGMT 0xE5
110 * Do not check for data_received for USB, as data_received
111 * is handled in mwifiex_usb_recv for USB
113 #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
114 adapter->event_received || \
115 adapter->data_received)
117 #define MWIFIEX_TYPE_CMD 1
118 #define MWIFIEX_TYPE_DATA 0
119 #define MWIFIEX_TYPE_EVENT 3
121 #define MAX_BITMAP_RATES_SIZE 18
123 #define MAX_CHANNEL_BAND_BG 14
124 #define MAX_CHANNEL_BAND_A 165
126 #define MAX_FREQUENCY_BAND_BG 2484
128 #define MWIFIEX_EVENT_HEADER_LEN 4
129 #define MWIFIEX_UAP_EVENT_EXTRA_HEADER 2
131 #define MWIFIEX_TYPE_LEN 4
132 #define MWIFIEX_USB_TYPE_CMD 0xF00DFACE
133 #define MWIFIEX_USB_TYPE_DATA 0xBEADC0DE
134 #define MWIFIEX_USB_TYPE_EVENT 0xBEEFFACE
136 /* Threshold for tx_timeout_cnt before we trigger a card reset */
137 #define TX_TIMEOUT_THRESHOLD 6
140 u32 num_cmd_host_to_card_failure;
141 u32 num_cmd_sleep_cfm_host_to_card_failure;
142 u32 num_tx_host_to_card_failure;
143 u32 num_event_deauth;
144 u32 num_event_disassoc;
145 u32 num_event_link_lost;
147 u32 num_cmd_assoc_success;
148 u32 num_cmd_assoc_failure;
152 u16 last_cmd_id[DBG_CMD_NUM];
153 u16 last_cmd_act[DBG_CMD_NUM];
155 u16 last_cmd_resp_id[DBG_CMD_NUM];
156 u16 last_cmd_resp_index;
157 u16 last_event[DBG_CMD_NUM];
158 u16 last_event_index;
161 enum MWIFIEX_HARDWARE_STATUS {
162 MWIFIEX_HW_STATUS_READY,
163 MWIFIEX_HW_STATUS_INITIALIZING,
164 MWIFIEX_HW_STATUS_FW_READY,
165 MWIFIEX_HW_STATUS_INIT_DONE,
166 MWIFIEX_HW_STATUS_RESET,
167 MWIFIEX_HW_STATUS_CLOSING,
168 MWIFIEX_HW_STATUS_NOT_READY
171 enum MWIFIEX_802_11_POWER_MODE {
172 MWIFIEX_802_11_POWER_MODE_CAM,
173 MWIFIEX_802_11_POWER_MODE_PSP
176 struct mwifiex_tx_param {
180 enum MWIFIEX_PS_STATE {
187 enum mwifiex_iface_type {
193 struct mwifiex_add_ba_param {
201 struct mwifiex_tx_aggr {
207 struct mwifiex_ra_list_tbl {
208 struct list_head list;
209 struct sk_buff_head skb_head;
219 struct mwifiex_tid_tbl {
220 struct list_head ra_list;
223 #define WMM_HIGHEST_PRIORITY 7
224 #define HIGH_PRIO_TID 7
225 #define LOW_PRIO_TID 0
227 struct mwifiex_wmm_desc {
228 struct mwifiex_tid_tbl tid_tbl_ptr[MAX_NUM_TID];
229 u32 packets_out[MAX_NUM_TID];
230 /* spin lock to protect ra_list */
231 spinlock_t ra_list_spinlock;
232 struct mwifiex_wmm_ac_status ac_status[IEEE80211_NUM_ACS];
233 enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_NUM_ACS];
234 u32 drv_pkt_delay_max;
235 u8 queue_priority[IEEE80211_NUM_ACS];
236 u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */
237 /* Number of transmit packets queued */
238 atomic_t tx_pkts_queued;
239 /* Tracks highest priority with a packet queued */
240 atomic_t highest_queued_prio;
243 struct mwifiex_802_11_security {
249 u32 authentication_mode;
254 struct ieee_types_header {
259 struct ieee_types_vendor_specific {
260 struct ieee_types_vendor_header vend_hdr;
261 u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_vendor_header)];
264 struct ieee_types_generic {
265 struct ieee_types_header ieee_hdr;
266 u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)];
269 struct ieee_types_bss_co_2040 {
270 struct ieee_types_header ieee_hdr;
274 struct ieee_types_extcap {
275 struct ieee_types_header ieee_hdr;
279 struct ieee_types_vht_cap {
280 struct ieee_types_header ieee_hdr;
281 struct ieee80211_vht_cap vhtcap;
284 struct ieee_types_vht_oper {
285 struct ieee_types_header ieee_hdr;
286 struct ieee80211_vht_operation vhtoper;
289 struct ieee_types_aid {
290 struct ieee_types_header ieee_hdr;
294 struct mwifiex_bssdescriptor {
295 u8 mac_address[ETH_ALEN];
296 struct cfg80211_ssid ssid;
304 u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
305 u8 data_rates[MWIFIEX_SUPPORTED_RATES];
307 * BAND_B(0x01): 'b' band
308 * BAND_G(0x02): 'g' band
309 * BAND_A(0X04): 'a' band
314 union ieee_types_phy_param_set phy_param_set;
315 union ieee_types_ss_param_set ss_param_set;
317 struct ieee_types_wmm_parameter wmm_ie;
319 struct ieee80211_ht_cap *bcn_ht_cap;
321 struct ieee80211_ht_operation *bcn_ht_oper;
324 u16 bss_co_2040_offset;
327 struct ieee80211_vht_cap *bcn_vht_cap;
329 struct ieee80211_vht_operation *bcn_vht_oper;
331 struct ieee_types_oper_mode_ntf *oper_mode;
332 u16 oper_mode_offset;
334 struct ieee_types_vendor_specific *bcn_wpa_ie;
336 struct ieee_types_generic *bcn_rsn_ie;
338 struct ieee_types_generic *bcn_wapi_ie;
344 u8 chan_sw_ie_present;
347 struct mwifiex_current_bss_params {
348 struct mwifiex_bssdescriptor bss_descriptor;
350 u8 wmm_uapsd_enabled;
353 u8 data_rates[MWIFIEX_SUPPORTED_RATES];
356 struct mwifiex_sleep_params {
365 struct mwifiex_sleep_period {
370 struct mwifiex_wep_key {
374 u8 key_material[MWIFIEX_KEY_BUFFER_SIZE];
377 #define MAX_REGION_CHANNEL_NUM 2
379 struct mwifiex_chan_freq_power {
391 #define MWIFIEX_MAX_TRIPLET_802_11D 83
393 struct mwifiex_802_11d_domain_reg {
394 u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
396 struct ieee80211_country_ie_triplet
397 triplet[MWIFIEX_MAX_TRIPLET_802_11D];
400 struct mwifiex_vendor_spec_cfg_ie {
403 u8 ie[MWIFIEX_MAX_VSIE_LEN];
410 struct mwifiex_roc_cfg {
412 struct ieee80211_channel chan;
415 #define MWIFIEX_FW_DUMP_IDX 0xff
416 #define FW_DUMP_MAX_NAME_LEN 8
417 #define FW_DUMP_HOST_READY 0xEE
418 #define FW_DUMP_DONE 0xFF
419 #define FW_DUMP_READ_DONE 0xFE
421 struct memory_type_mapping {
422 u8 mem_name[FW_DUMP_MAX_NAME_LEN];
429 RDWR_STATUS_SUCCESS = 0,
430 RDWR_STATUS_FAILURE = 1,
434 enum mwifiex_iface_work_flags {
435 MWIFIEX_IFACE_WORK_FW_DUMP,
436 MWIFIEX_IFACE_WORK_CARD_RESET,
439 struct mwifiex_adapter;
440 struct mwifiex_private;
442 struct mwifiex_private {
443 struct mwifiex_adapter *adapter;
450 u8 curr_addr[ETH_ALEN];
453 /* track consecutive timeout */
455 struct net_device *netdev;
456 struct net_device_stats stats;
461 u8 max_tx_power_level;
462 u8 min_tx_power_level;
468 u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
470 u8 is_data_rate_auto;
481 struct mwifiex_bssdescriptor *attempted_bss_desc;
482 struct cfg80211_ssid prev_ssid;
483 u8 prev_bssid[ETH_ALEN];
484 struct mwifiex_current_bss_params curr_bss_params;
490 u8 adhoc_is_link_sensed;
492 struct mwifiex_802_11_security sec_info;
493 struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
494 u16 wep_key_curr_index;
498 struct host_cmd_ds_802_11_key_material aes_key;
499 struct host_cmd_ds_802_11_key_material_v2 aes_key_v2;
507 struct mwifiex_wmm_desc wmm;
508 atomic_t wmm_tx_pending[IEEE80211_NUM_ACS];
509 struct list_head sta_list;
510 /* spin lock for associated station/TDLS peers list */
511 spinlock_t sta_list_spinlock;
512 struct list_head auto_tdls_list;
513 /* spin lock for auto TDLS peer list */
514 spinlock_t auto_tdls_lock;
515 struct list_head tx_ba_stream_tbl_ptr;
516 /* spin lock for tx_ba_stream_tbl_ptr queue */
517 spinlock_t tx_ba_stream_tbl_lock;
518 struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
519 struct mwifiex_add_ba_param add_ba_param;
520 u16 rx_seq[MAX_NUM_TID];
521 u8 tos_to_tid_inv[MAX_NUM_TID];
522 struct list_head rx_reorder_tbl_ptr;
523 /* spin lock for rx_reorder_tbl_ptr queue */
524 spinlock_t rx_reorder_tbl_lock;
525 /* spin lock for Rx packets */
526 spinlock_t rx_pkt_lock;
528 #define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
529 u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
532 #define MWIFIEX_GENIE_BUF_SIZE 256
533 u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
536 struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
538 #define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
539 u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
540 u8 assoc_tlv_buf_len;
544 /* spin lock for beacon buffer */
545 spinlock_t curr_bcn_buf_lock;
546 struct wireless_dev *wdev;
547 struct mwifiex_chan_freq_power cfp;
548 char version_str[128];
549 #ifdef CONFIG_DEBUG_FS
550 struct dentry *dfs_dev_dir;
553 u16 current_key_index;
554 struct semaphore async_sem;
555 struct cfg80211_scan_request *scan_request;
561 u8 subsc_evt_rssi_state;
562 struct mwifiex_ds_misc_subsc_evt async_subsc_evt_storage;
563 struct mwifiex_ie mgmt_ie[MAX_MGMT_IE_INDEX];
571 struct mwifiex_roc_cfg roc_cfg;
574 unsigned long csa_expire_time;
577 struct station_parameters *sta_params;
578 struct sk_buff_head tdls_txq;
580 struct timer_list auto_tdls_timer;
581 bool auto_tdls_timer_active;
582 struct idr ack_status_frames;
583 /* spin lock for ack status */
584 spinlock_t ack_status_lock;
585 /** rx histogram data */
586 struct mwifiex_histogram_data *hist_data;
589 enum mwifiex_ba_status {
595 struct mwifiex_tx_ba_stream_tbl {
596 struct list_head list;
599 enum mwifiex_ba_status ba_status;
603 struct mwifiex_rx_reorder_tbl;
605 struct reorder_tmr_cnxt {
606 struct timer_list timer;
607 struct mwifiex_rx_reorder_tbl *ptr;
608 struct mwifiex_private *priv;
612 struct mwifiex_rx_reorder_tbl {
613 struct list_head list;
619 void **rx_reorder_ptr;
620 struct reorder_tmr_cnxt timer_context;
625 struct mwifiex_bss_prio_node {
626 struct list_head list;
627 struct mwifiex_private *priv;
630 struct mwifiex_bss_prio_tbl {
631 struct list_head bss_prio_head;
632 /* spin lock for bss priority */
633 spinlock_t bss_prio_lock;
634 struct mwifiex_bss_prio_node *bss_prio_cur;
637 struct cmd_ctrl_node {
638 struct list_head list;
639 struct mwifiex_private *priv;
642 struct sk_buff *cmd_skb;
643 struct sk_buff *resp_skb;
651 struct mwifiex_bss_priv {
656 struct mwifiex_tdls_capab {
663 struct ieee80211_ht_cap ht_capb;
664 struct ieee80211_ht_operation ht_oper;
665 struct ieee_types_extcap extcap;
666 struct ieee_types_generic rsn_ie;
667 struct ieee80211_vht_cap vhtcap;
668 struct ieee80211_vht_operation vhtoper;
671 /* This is AP/TDLS specific structure which stores information
672 * about associated/peer STA
674 struct mwifiex_sta_node {
675 struct list_head list;
676 u8 mac_addr[ETH_ALEN];
680 u8 ampdu_sta[MAX_NUM_TID];
681 u16 rx_seq[MAX_NUM_TID];
684 struct mwifiex_tdls_capab tdls_cap;
687 struct mwifiex_auto_tdls_peer {
688 struct list_head list;
689 u8 mac_addr[ETH_ALEN];
698 struct mwifiex_if_ops {
699 int (*init_if) (struct mwifiex_adapter *);
700 void (*cleanup_if) (struct mwifiex_adapter *);
701 int (*check_fw_status) (struct mwifiex_adapter *, u32);
702 int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
703 int (*register_dev) (struct mwifiex_adapter *);
704 void (*unregister_dev) (struct mwifiex_adapter *);
705 int (*enable_int) (struct mwifiex_adapter *);
706 void (*disable_int) (struct mwifiex_adapter *);
707 int (*process_int_status) (struct mwifiex_adapter *);
708 int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *,
709 struct mwifiex_tx_param *);
710 int (*wakeup) (struct mwifiex_adapter *);
711 int (*wakeup_complete) (struct mwifiex_adapter *);
713 /* Interface specific functions */
714 void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
715 void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
716 int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
717 int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
718 int (*init_fw_port) (struct mwifiex_adapter *);
719 int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
720 void (*card_reset) (struct mwifiex_adapter *);
721 void (*fw_dump)(struct mwifiex_adapter *);
722 int (*clean_pcie_ring) (struct mwifiex_adapter *adapter);
723 void (*iface_work)(struct work_struct *work);
724 void (*submit_rem_rx_urbs)(struct mwifiex_adapter *adapter);
727 struct mwifiex_adapter {
729 struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
731 const struct firmware *firmware;
736 bool surprise_removed;
737 u32 fw_release_number;
738 u16 init_wait_q_woken;
739 wait_queue_head_t init_wait_q;
741 struct mwifiex_if_ops if_ops;
744 atomic_t cmd_pending;
745 struct workqueue_struct *workqueue;
746 struct work_struct main_work;
747 struct workqueue_struct *rx_workqueue;
748 struct work_struct rx_work;
749 bool rx_work_enabled;
751 bool delay_main_work;
753 struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
754 /* spin lock for init/shutdown */
755 spinlock_t mwifiex_lock;
756 /* spin lock for main process */
757 spinlock_t main_proc_lock;
758 u32 mwifiex_processing;
760 u16 curr_tx_buf_size;
762 enum MWIFIEX_HARDWARE_STATUS hw_status;
763 u16 number_of_antenna;
765 /* spin lock for interrupt handling */
769 struct sk_buff *event_skb;
770 u8 upld_buf[MWIFIEX_UPLD_SIZE];
773 u8 cmd_resp_received;
777 struct cmd_ctrl_node *cmd_pool;
778 struct cmd_ctrl_node *curr_cmd;
779 /* spin lock for command */
780 spinlock_t mwifiex_cmd_lock;
783 struct timer_list cmd_timer;
784 struct list_head cmd_free_q;
785 /* spin lock for cmd_free_q */
786 spinlock_t cmd_free_q_lock;
787 struct list_head cmd_pending_q;
788 /* spin lock for cmd_pending_q */
789 spinlock_t cmd_pending_q_lock;
790 struct list_head scan_pending_q;
791 /* spin lock for scan_pending_q */
792 spinlock_t scan_pending_q_lock;
793 /* spin lock for RX processing routine */
794 spinlock_t rx_proc_lock;
797 struct mwifiex_802_11d_domain_reg domain_reg;
800 u16 specific_scan_time;
801 u16 active_scan_time;
802 u16 passive_scan_time;
803 u16 scan_chan_gap_time;
807 struct mwifiex_chan_scan_param_set *scan_channels;
809 struct mwifiex_sleep_params sleep_params;
810 struct mwifiex_sleep_period sleep_period;
815 u16 local_listen_interval;
816 u16 null_pkt_interval;
817 struct sk_buff *sleep_cfm;
818 u16 bcn_miss_time_out;
819 u16 adhoc_awake_period;
823 u16 enhanced_ps_mode;
824 u8 pm_wakeup_card_req;
827 u32 pm_wakeup_fw_try;
829 struct mwifiex_hs_config_param hs_cfg;
831 u16 hs_activate_wait_q_woken;
832 wait_queue_head_t hs_activate_wait_q;
835 u8 event_body[MAX_EVENT_SIZE];
836 u32 hw_dot_11n_dev_cap;
837 u8 hw_dev_mcs_support;
838 u8 user_dev_mcs_support;
839 u8 adhoc_11n_enabled;
841 struct mwifiex_dbg dbg;
842 u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
844 struct mwifiex_wait_queue cmd_wait_q;
845 u8 scan_wait_q_woken;
846 spinlock_t queue_lock; /* lock for tx queues */
847 u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
848 u16 max_mgmt_ie_index;
849 const struct firmware *cal_data;
850 struct device_node *dt_node;
853 u32 is_hw_11ac_capable;
854 u32 hw_dot_11ac_dev_cap;
855 u32 hw_dot_11ac_mcs_support;
856 u32 usr_dot_11ac_dev_cap_bg;
857 u32 usr_dot_11ac_dev_cap_a;
858 u32 usr_dot_11ac_mcs_support;
860 atomic_t pending_bridged_pkts;
861 struct semaphore *card_sem;
864 u8 key_api_major_ver, key_api_minor_ver;
865 struct work_struct iface_work;
866 unsigned long iface_work_flags;
867 struct memory_type_mapping *mem_type_mapping_tbl;
870 bool scan_chan_gap_enabled;
871 struct sk_buff_head rx_data_q;
872 struct mwifiex_chan_stats *chan_stats;
873 u32 num_in_chan_stats;
878 int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
880 void mwifiex_set_trans_start(struct net_device *dev);
882 void mwifiex_stop_net_dev_queue(struct net_device *netdev,
883 struct mwifiex_adapter *adapter);
885 void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
886 struct mwifiex_adapter *adapter);
888 int mwifiex_init_priv(struct mwifiex_private *priv);
889 void mwifiex_free_priv(struct mwifiex_private *priv);
891 int mwifiex_init_fw(struct mwifiex_adapter *adapter);
893 int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
895 int mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
897 int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
899 int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
901 int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb);
903 int mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
904 struct sk_buff *skb);
906 int mwifiex_process_event(struct mwifiex_adapter *adapter);
908 int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
909 struct cmd_ctrl_node *cmd_node);
911 int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
912 u16 cmd_action, u32 cmd_oid, void *data_buf, bool sync);
914 void mwifiex_cmd_timeout_func(unsigned long function_context);
916 int mwifiex_get_debug_info(struct mwifiex_private *,
917 struct mwifiex_debug_info *);
919 int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
920 int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
921 void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
922 void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
924 void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
925 struct cmd_ctrl_node *cmd_node);
926 void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter,
927 struct cmd_ctrl_node *cmd_node);
929 void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
930 struct cmd_ctrl_node *cmd_node,
933 int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
934 int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
935 int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
936 struct sk_buff *skb);
937 int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
938 struct mwifiex_tx_param *tx_param);
939 int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
940 int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
941 struct sk_buff *skb, int aggr, int status);
942 void mwifiex_clean_txrx(struct mwifiex_private *priv);
943 u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
944 void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
945 void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
947 int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
948 struct host_cmd_ds_command *cmd,
949 u16 cmd_action, uint16_t ps_bitmap,
950 struct mwifiex_ds_auto_ds *auto_ds);
951 int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
952 struct host_cmd_ds_command *resp,
953 struct mwifiex_ds_pm_cfg *pm_cfg);
954 void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
955 void mwifiex_hs_activated_event(struct mwifiex_private *priv,
957 int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
958 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg);
959 int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
960 struct host_cmd_ds_command *resp);
961 int mwifiex_process_rx_packet(struct mwifiex_private *priv,
962 struct sk_buff *skb);
963 int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
964 u16 cmd_action, u32 cmd_oid,
965 void *data_buf, void *cmd_buf);
966 int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
967 u16 cmd_action, u32 cmd_oid,
968 void *data_buf, void *cmd_buf);
969 int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
970 struct host_cmd_ds_command *resp);
971 int mwifiex_process_sta_rx_packet(struct mwifiex_private *,
972 struct sk_buff *skb);
973 int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
974 struct sk_buff *skb);
975 int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
976 struct sk_buff *skb);
977 int mwifiex_process_sta_event(struct mwifiex_private *);
978 int mwifiex_process_uap_event(struct mwifiex_private *);
979 void mwifiex_delete_all_station_list(struct mwifiex_private *priv);
980 void mwifiex_wmm_del_peer_ra_list(struct mwifiex_private *priv,
982 void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
983 void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb);
984 int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
985 int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
986 struct mwifiex_scan_cmd_config *scan_cfg);
987 void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
988 struct cmd_ctrl_node *cmd_node);
989 int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
990 struct host_cmd_ds_command *resp);
991 s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
992 int mwifiex_associate(struct mwifiex_private *priv,
993 struct mwifiex_bssdescriptor *bss_desc);
994 int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
995 struct host_cmd_ds_command *cmd,
996 struct mwifiex_bssdescriptor *bss_desc);
997 int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
998 struct host_cmd_ds_command *resp);
999 void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason);
1000 u8 mwifiex_band_to_radio_type(u8 band);
1001 int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
1002 void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter);
1003 int mwifiex_adhoc_start(struct mwifiex_private *priv,
1004 struct cfg80211_ssid *adhoc_ssid);
1005 int mwifiex_adhoc_join(struct mwifiex_private *priv,
1006 struct mwifiex_bssdescriptor *bss_desc);
1007 int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
1008 struct host_cmd_ds_command *cmd,
1009 struct cfg80211_ssid *req_ssid);
1010 int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
1011 struct host_cmd_ds_command *cmd,
1012 struct mwifiex_bssdescriptor *bss_desc);
1013 int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
1014 struct host_cmd_ds_command *resp);
1015 int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
1016 struct mwifiex_chan_freq_power *mwifiex_get_cfp(struct mwifiex_private *priv,
1017 u8 band, u16 channel, u32 freq);
1018 u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv,
1019 u8 index, u8 ht_info);
1020 u32 mwifiex_index_to_acs_data_rate(struct mwifiex_private *priv,
1021 u8 index, u8 ht_info);
1022 u32 mwifiex_find_freq_from_band_chan(u8, u8);
1023 int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
1025 u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
1027 u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
1028 u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv,
1029 u8 *rates, u8 radio_type);
1030 u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
1031 extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
1032 void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
1033 void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
1034 int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
1035 struct host_cmd_ds_command *cmd);
1036 int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
1037 struct host_cmd_ds_command *resp);
1038 int is_command_pending(struct mwifiex_adapter *adapter);
1039 void mwifiex_init_priv_params(struct mwifiex_private *priv,
1040 struct net_device *dev);
1041 int mwifiex_set_secure_params(struct mwifiex_private *priv,
1042 struct mwifiex_uap_bss_param *bss_config,
1043 struct cfg80211_ap_settings *params);
1044 void mwifiex_set_ht_params(struct mwifiex_private *priv,
1045 struct mwifiex_uap_bss_param *bss_cfg,
1046 struct cfg80211_ap_settings *params);
1047 void mwifiex_set_vht_params(struct mwifiex_private *priv,
1048 struct mwifiex_uap_bss_param *bss_cfg,
1049 struct cfg80211_ap_settings *params);
1050 void mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg,
1051 struct cfg80211_ap_settings *params);
1052 void mwifiex_set_vht_width(struct mwifiex_private *priv,
1053 enum nl80211_chan_width width,
1054 bool ap_11ac_disable);
1056 mwifiex_set_wmm_params(struct mwifiex_private *priv,
1057 struct mwifiex_uap_bss_param *bss_cfg,
1058 struct cfg80211_ap_settings *params);
1059 void mwifiex_set_ba_params(struct mwifiex_private *priv);
1060 void mwifiex_set_11ac_ba_params(struct mwifiex_private *priv);
1061 int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
1062 struct host_cmd_ds_command *cmd,
1064 int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv,
1065 struct host_cmd_ds_command *resp);
1066 int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
1070 * This function checks if the queuing is RA based or not.
1073 mwifiex_queuing_ra_based(struct mwifiex_private *priv)
1076 * Currently we assume if we are in Infra, then DA=RA. This might not be
1077 * true in the future
1079 if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
1080 (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
1087 * This function copies rates.
1090 mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
1094 for (i = 0; i < len && src[i]; i++, pos++) {
1095 if (pos >= MWIFIEX_SUPPORTED_RATES)
1104 * This function returns the correct private structure pointer based
1105 * upon the BSS type and BSS number.
1107 static inline struct mwifiex_private *
1108 mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
1109 u8 bss_num, u8 bss_type)
1113 for (i = 0; i < adapter->priv_num; i++) {
1114 if (adapter->priv[i]) {
1115 if ((adapter->priv[i]->bss_num == bss_num) &&
1116 (adapter->priv[i]->bss_type == bss_type))
1120 return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1124 * This function returns the first available private structure pointer
1125 * based upon the BSS role.
1127 static inline struct mwifiex_private *
1128 mwifiex_get_priv(struct mwifiex_adapter *adapter,
1129 enum mwifiex_bss_role bss_role)
1133 for (i = 0; i < adapter->priv_num; i++) {
1134 if (adapter->priv[i]) {
1135 if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
1136 GET_BSS_ROLE(adapter->priv[i]) == bss_role)
1141 return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1145 * This function returns the driver private structure of a network device.
1147 static inline struct mwifiex_private *
1148 mwifiex_netdev_get_priv(struct net_device *dev)
1150 return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
1154 * This function checks if a skb holds a management frame.
1156 static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
1158 return (le32_to_cpu(*(__le32 *)skb->data) == PKT_TYPE_MGMT);
1161 /* This function retrieves channel closed for operation by Channel
1162 * Switch Announcement.
1165 mwifiex_11h_get_csa_closed_channel(struct mwifiex_private *priv)
1167 if (!priv->csa_chan)
1170 /* Clear csa channel, if DFS channel move time has passed */
1171 if (time_after(jiffies, priv->csa_expire_time)) {
1173 priv->csa_expire_time = 0;
1176 return priv->csa_chan;
1179 static inline u8 mwifiex_is_any_intf_active(struct mwifiex_private *priv)
1181 struct mwifiex_private *priv_num;
1184 for (i = 0; i < priv->adapter->priv_num; i++) {
1185 priv_num = priv->adapter->priv[i];
1187 if ((GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_UAP &&
1188 priv_num->bss_started) ||
1189 (GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_STA &&
1190 priv_num->media_connected))
1198 int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
1199 u32 func_init_shutdown);
1200 int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
1201 int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
1203 void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
1205 int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
1206 struct mwifiex_multicast_list *mcast_list);
1207 int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
1208 struct net_device *dev);
1209 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
1210 struct cmd_ctrl_node *cmd_queued);
1211 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
1212 struct cfg80211_ssid *req_ssid);
1213 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
1214 int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
1215 int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
1216 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
1217 int mwifiex_request_scan(struct mwifiex_private *priv,
1218 struct cfg80211_ssid *req_ssid);
1219 int mwifiex_scan_networks(struct mwifiex_private *priv,
1220 const struct mwifiex_user_scan_cfg *user_scan_in);
1221 int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
1223 int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
1224 const u8 *key, int key_len, u8 key_index,
1225 const u8 *mac_addr, int disable);
1227 int mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len);
1229 int mwifiex_get_ver_ext(struct mwifiex_private *priv);
1231 int mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action,
1232 struct ieee80211_channel *chan,
1233 unsigned int duration);
1235 int mwifiex_set_bss_role(struct mwifiex_private *priv, u8 bss_role);
1237 int mwifiex_get_stats_info(struct mwifiex_private *priv,
1238 struct mwifiex_ds_get_stats *log);
1240 int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1241 u32 reg_offset, u32 reg_value);
1243 int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1244 u32 reg_offset, u32 *value);
1246 int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1249 int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
1251 int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
1253 int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
1255 int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
1257 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
1259 int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
1260 char *version, int max_len);
1262 int mwifiex_set_tx_power(struct mwifiex_private *priv,
1263 struct mwifiex_power_cfg *power_cfg);
1265 int mwifiex_main_process(struct mwifiex_adapter *);
1267 int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb);
1269 int mwifiex_get_bss_info(struct mwifiex_private *,
1270 struct mwifiex_bss_info *);
1271 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
1272 struct cfg80211_bss *bss,
1273 struct mwifiex_bssdescriptor *bss_desc);
1274 int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
1275 struct mwifiex_bssdescriptor *bss_entry);
1276 int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
1277 struct mwifiex_bssdescriptor *bss_desc);
1279 u8 mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type);
1281 struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1283 enum nl80211_iftype type,
1285 struct vif_params *params);
1286 int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
1288 void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config);
1290 int mwifiex_add_wowlan_magic_pkt_filter(struct mwifiex_adapter *adapter);
1292 int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
1293 struct cfg80211_beacon_data *data);
1294 int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
1295 u8 *mwifiex_11d_code_2_region(u8 code);
1296 void mwifiex_uap_del_sta_data(struct mwifiex_private *priv,
1297 struct mwifiex_sta_node *node);
1299 void mwifiex_11h_process_join(struct mwifiex_private *priv, u8 **buffer,
1300 struct mwifiex_bssdescriptor *bss_desc);
1301 int mwifiex_11h_handle_event_chanswann(struct mwifiex_private *priv);
1302 int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv,
1303 struct device_node *node, const char *prefix);
1304 void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv);
1306 extern const struct ethtool_ops mwifiex_ethtool_ops;
1308 void mwifiex_del_all_sta_list(struct mwifiex_private *priv);
1309 void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1311 mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies,
1312 int ies_len, struct mwifiex_sta_node *node);
1313 struct mwifiex_sta_node *
1314 mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1315 struct mwifiex_sta_node *
1316 mwifiex_get_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1317 int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
1318 u8 action_code, u8 dialog_token,
1319 u16 status_code, const u8 *extra_ies,
1320 size_t extra_ies_len);
1321 int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
1322 u8 action_code, u8 dialog_token,
1323 u16 status_code, const u8 *extra_ies,
1324 size_t extra_ies_len);
1325 void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
1327 int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action);
1328 int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac);
1329 int mwifiex_get_tdls_list(struct mwifiex_private *priv,
1330 struct tdls_peer_info *buf);
1331 void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
1332 bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
1333 u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
1334 u32 pri_chan, u8 chan_bw);
1335 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter);
1337 int mwifiex_tdls_check_tx(struct mwifiex_private *priv, struct sk_buff *skb);
1338 void mwifiex_flush_auto_tdls_list(struct mwifiex_private *priv);
1339 void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private *priv,
1340 const u8 *mac, u8 link_status);
1341 void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv,
1342 u8 *mac, s8 snr, s8 nflr);
1343 void mwifiex_check_auto_tdls(unsigned long context);
1344 void mwifiex_add_auto_tdls_peer(struct mwifiex_private *priv, const u8 *mac);
1345 void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv);
1346 void mwifiex_clean_auto_tdls(struct mwifiex_private *priv);
1348 void mwifiex_parse_tx_status_event(struct mwifiex_private *priv,
1352 mwifiex_clone_skb_for_tx_status(struct mwifiex_private *priv,
1353 struct sk_buff *skb, u8 flag, u64 *cookie);
1355 void mwifiex_hist_data_set(struct mwifiex_private *priv, u8 rx_rate, s8 snr,
1357 void mwifiex_hist_data_reset(struct mwifiex_private *priv);
1358 void mwifiex_hist_data_add(struct mwifiex_private *priv,
1359 u8 rx_rate, s8 snr, s8 nflr);
1360 u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
1361 u8 rx_rate, u8 ht_info);
1363 #ifdef CONFIG_DEBUG_FS
1364 void mwifiex_debugfs_init(void);
1365 void mwifiex_debugfs_remove(void);
1367 void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
1368 void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
1370 #endif /* !_MWIFIEX_MAIN_H_ */