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