1828c91f7SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 25e6e3a92SBing Zhao /* 3932183aaSGanapathi Bhat * NXP Wireless LAN device driver: generic data structures and APIs 45e6e3a92SBing Zhao * 5932183aaSGanapathi Bhat * Copyright 2011-2020 NXP 65e6e3a92SBing Zhao */ 75e6e3a92SBing Zhao 85e6e3a92SBing Zhao #ifndef _MWIFIEX_DECL_H_ 95e6e3a92SBing Zhao #define _MWIFIEX_DECL_H_ 105e6e3a92SBing Zhao 115e6e3a92SBing Zhao #undef pr_fmt 125e6e3a92SBing Zhao #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 135e6e3a92SBing Zhao 145e6e3a92SBing Zhao #include <linux/wait.h> 155e6e3a92SBing Zhao #include <linux/timer.h> 165e6e3a92SBing Zhao #include <linux/ieee80211.h> 17587b36d3SAvinash Patil #include <uapi/linux/if_arp.h> 1850d55b6dSJohannes Berg #include <net/cfg80211.h> 195e6e3a92SBing Zhao 20d219b7ebSChunfan Chen #define MWIFIEX_BSS_COEX_COUNT 2 21197f4a2eSStone Piao #define MWIFIEX_MAX_BSS_NUM (3) 225e6e3a92SBing Zhao 2384b313b3SXinming Hu #define MWIFIEX_DMA_ALIGN_SZ 64 2431def91bSAvinash Patil #define MWIFIEX_RX_HEADROOM 64 2584b313b3SXinming Hu #define MAX_TXPD_SZ 32 2684b313b3SXinming Hu #define INTF_HDR_ALIGN 4 2784b313b3SXinming Hu 2884b313b3SXinming Hu #define MWIFIEX_MIN_DATA_HEADER_LEN (MWIFIEX_DMA_ALIGN_SZ + INTF_HDR_ALIGN + \ 2984b313b3SXinming Hu MAX_TXPD_SZ) 30e39faa73SStone Piao #define MWIFIEX_MGMT_FRAME_HEADER_SIZE 8 /* sizeof(pkt_type) 31e39faa73SStone Piao * + sizeof(tx_control) 32e39faa73SStone Piao */ 335e6e3a92SBing Zhao 3436995892SDavid Lin #define FRMCTL_LEN 2 3536995892SDavid Lin #define DURATION_LEN 2 3636995892SDavid Lin #define SEQCTL_LEN 2 3736995892SDavid Lin /* special FW 4 address management header */ 3836995892SDavid Lin #define MWIFIEX_MGMT_HEADER_LEN (FRMCTL_LEN + DURATION_LEN + ETH_ALEN + \ 3936995892SDavid Lin ETH_ALEN + ETH_ALEN + SEQCTL_LEN + ETH_ALEN) 4036995892SDavid Lin 4136995892SDavid Lin #define AUTH_ALG_LEN 2 4236995892SDavid Lin #define AUTH_TRANSACTION_LEN 2 4336995892SDavid Lin #define AUTH_STATUS_LEN 2 4436995892SDavid Lin #define MWIFIEX_AUTH_BODY_LEN (AUTH_ALG_LEN + AUTH_TRANSACTION_LEN + \ 4536995892SDavid Lin AUTH_STATUS_LEN) 4636995892SDavid Lin 4736995892SDavid Lin #define HOST_MLME_AUTH_PENDING BIT(0) 4836995892SDavid Lin #define HOST_MLME_AUTH_DONE BIT(1) 4936995892SDavid Lin 5036995892SDavid Lin #define HOST_MLME_MGMT_MASK (BIT(IEEE80211_STYPE_AUTH >> 4) | \ 5136995892SDavid Lin BIT(IEEE80211_STYPE_DEAUTH >> 4) | \ 5236995892SDavid Lin BIT(IEEE80211_STYPE_DISASSOC >> 4)) 5336995892SDavid Lin #define AUTH_TX_DEFAULT_WAIT_TIME 2400 5436995892SDavid Lin 5536995892SDavid Lin #define WLAN_AUTH_NONE 0xFFFF 5636995892SDavid Lin 575e6e3a92SBing Zhao #define MWIFIEX_MAX_TX_BASTREAM_SUPPORTED 2 585e6e3a92SBing Zhao #define MWIFIEX_MAX_RX_BASTREAM_SUPPORTED 16 5972df6310SXinming Hu #define MWIFIEX_MAX_TDLS_PEER_SUPPORTED 8 605e6e3a92SBing Zhao 6142e37272SAmitkumar Karwar #define MWIFIEX_STA_AMPDU_DEF_TXWINSIZE 64 6242e37272SAmitkumar Karwar #define MWIFIEX_STA_AMPDU_DEF_RXWINSIZE 64 63d219b7ebSChunfan Chen #define MWIFIEX_STA_COEX_AMPDU_DEF_RXWINSIZE 16 64d219b7ebSChunfan Chen 6504abc0a3SAvinash Patil #define MWIFIEX_UAP_AMPDU_DEF_TXWINSIZE 32 66d219b7ebSChunfan Chen 67d219b7ebSChunfan Chen #define MWIFIEX_UAP_COEX_AMPDU_DEF_RXWINSIZE 16 68d219b7ebSChunfan Chen 6904abc0a3SAvinash Patil #define MWIFIEX_UAP_AMPDU_DEF_RXWINSIZE 16 70258ed9f0SAmitkumar Karwar #define MWIFIEX_11AC_STA_AMPDU_DEF_TXWINSIZE 64 71258ed9f0SAmitkumar Karwar #define MWIFIEX_11AC_STA_AMPDU_DEF_RXWINSIZE 64 7250398ee0SAvinash Patil #define MWIFIEX_11AC_UAP_AMPDU_DEF_TXWINSIZE 64 7350398ee0SAvinash Patil #define MWIFIEX_11AC_UAP_AMPDU_DEF_RXWINSIZE 64 7404abc0a3SAvinash Patil 755e6e3a92SBing Zhao #define MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT 0xffff 765e6e3a92SBing Zhao 775e6e3a92SBing Zhao #define MWIFIEX_RATE_BITMAP_MCS0 32 785e6e3a92SBing Zhao 795e6e3a92SBing Zhao #define MWIFIEX_RX_DATA_BUF_SIZE (4 * 1024) 804daffe35SAmitkumar Karwar #define MWIFIEX_RX_CMD_BUF_SIZE (2 * 1024) 815e6e3a92SBing Zhao 8212190c5dSAvinash Patil #define MAX_BEACON_PERIOD (4000) 8312190c5dSAvinash Patil #define MIN_BEACON_PERIOD (50) 8412190c5dSAvinash Patil #define MAX_DTIM_PERIOD (100) 8512190c5dSAvinash Patil #define MIN_DTIM_PERIOD (1) 8612190c5dSAvinash Patil 875e6e3a92SBing Zhao #define MWIFIEX_RTS_MIN_VALUE (0) 885e6e3a92SBing Zhao #define MWIFIEX_RTS_MAX_VALUE (2347) 895e6e3a92SBing Zhao #define MWIFIEX_FRAG_MIN_VALUE (256) 905e6e3a92SBing Zhao #define MWIFIEX_FRAG_MAX_VALUE (2346) 9154428c57SAvinash Patil #define MWIFIEX_WMM_VERSION 0x01 9254428c57SAvinash Patil #define MWIFIEX_WMM_SUBTYPE 0x01 935e6e3a92SBing Zhao 949b930eaeSAvinash Patil #define MWIFIEX_RETRY_LIMIT 14 955e6e3a92SBing Zhao #define MWIFIEX_SDIO_BLOCK_SIZE 256 965e6e3a92SBing Zhao 975e6e3a92SBing Zhao #define MWIFIEX_BUF_FLAG_REQUEUED_PKT BIT(0) 98838e4f44SAvinash Patil #define MWIFIEX_BUF_FLAG_BRIDGED_PKT BIT(1) 99b23bce29SAvinash Patil #define MWIFIEX_BUF_FLAG_TDLS_PKT BIT(2) 100808bbebcSAmitkumar Karwar #define MWIFIEX_BUF_FLAG_EAPOL_TX_STATUS BIT(3) 10118ca4382SAmitkumar Karwar #define MWIFIEX_BUF_FLAG_ACTION_TX_STATUS BIT(4) 102e35000eaSZhaoyang Liu #define MWIFIEX_BUF_FLAG_AGGR_PKT BIT(5) 103838e4f44SAvinash Patil 10461c87304SAvinash Patil #define MWIFIEX_BRIDGED_PKTS_THR_HIGH 1024 10561c87304SAvinash Patil #define MWIFIEX_BRIDGED_PKTS_THR_LOW 128 1065e6e3a92SBing Zhao 107429d90d2SAvinash Patil #define MWIFIEX_TDLS_DISABLE_LINK 0x00 108429d90d2SAvinash Patil #define MWIFIEX_TDLS_ENABLE_LINK 0x01 109429d90d2SAvinash Patil #define MWIFIEX_TDLS_CREATE_LINK 0x02 110429d90d2SAvinash Patil #define MWIFIEX_TDLS_CONFIG_LINK 0x03 111429d90d2SAvinash Patil 1129927baa3SAvinash Patil #define MWIFIEX_TDLS_RSSI_HIGH 50 1139927baa3SAvinash Patil #define MWIFIEX_TDLS_RSSI_LOW 55 1149927baa3SAvinash Patil #define MWIFIEX_TDLS_MAX_FAIL_COUNT 4 1159927baa3SAvinash Patil #define MWIFIEX_AUTO_TDLS_IDLE_TIME 10 1169927baa3SAvinash Patil 117cbf6e055SXinming Hu /* 54M rates, index from 0 to 11 */ 118cbf6e055SXinming Hu #define MWIFIEX_RATE_INDEX_MCS0 12 119cbf6e055SXinming Hu /* 12-27=MCS0-15(BW20) */ 120cbf6e055SXinming Hu #define MWIFIEX_BW20_MCS_NUM 15 121cbf6e055SXinming Hu 122cbf6e055SXinming Hu /* Rate index for OFDM 0 */ 123cbf6e055SXinming Hu #define MWIFIEX_RATE_INDEX_OFDM0 4 124cbf6e055SXinming Hu 1255b13d3e1SShengzhen Li #define MWIFIEX_MAX_STA_NUM 3 1265b13d3e1SShengzhen Li #define MWIFIEX_MAX_UAP_NUM 3 1275b13d3e1SShengzhen Li #define MWIFIEX_MAX_P2P_NUM 3 128cf052335SAvinash Patil 12985afb186SAvinash Patil #define MWIFIEX_A_BAND_START_FREQ 5000 13085afb186SAvinash Patil 13192263a84SZhaoyang Liu /* SDIO Aggr data packet special info */ 13292263a84SZhaoyang Liu #define SDIO_MAX_AGGR_BUF_SIZE (256 * 255) 13392263a84SZhaoyang Liu #define BLOCK_NUMBER_OFFSET 15 13492263a84SZhaoyang Liu #define SDIO_HEADER_OFFSET 28 13592263a84SZhaoyang Liu 13656486026SXinming Hu #define MWIFIEX_SIZE_4K 0x4000 13756486026SXinming Hu 1385e6e3a92SBing Zhao enum mwifiex_bss_type { 1395e6e3a92SBing Zhao MWIFIEX_BSS_TYPE_STA = 0, 1405e6e3a92SBing Zhao MWIFIEX_BSS_TYPE_UAP = 1, 141197f4a2eSStone Piao MWIFIEX_BSS_TYPE_P2P = 2, 1425e6e3a92SBing Zhao MWIFIEX_BSS_TYPE_ANY = 0xff, 1435e6e3a92SBing Zhao }; 1445e6e3a92SBing Zhao 1455e6e3a92SBing Zhao enum mwifiex_bss_role { 1465e6e3a92SBing Zhao MWIFIEX_BSS_ROLE_STA = 0, 1475e6e3a92SBing Zhao MWIFIEX_BSS_ROLE_UAP = 1, 1485e6e3a92SBing Zhao MWIFIEX_BSS_ROLE_ANY = 0xff, 1495e6e3a92SBing Zhao }; 1505e6e3a92SBing Zhao 1515f2caaf3SAvinash Patil enum mwifiex_tdls_status { 1525f2caaf3SAvinash Patil TDLS_NOT_SETUP = 0, 1535f2caaf3SAvinash Patil TDLS_SETUP_INPROGRESS, 1545f2caaf3SAvinash Patil TDLS_SETUP_COMPLETE, 1555f2caaf3SAvinash Patil TDLS_SETUP_FAILURE, 1565f2caaf3SAvinash Patil TDLS_LINK_TEARDOWN, 157ba101ad5SXinming Hu TDLS_CHAN_SWITCHING, 158ba101ad5SXinming Hu TDLS_IN_BASE_CHAN, 159ba101ad5SXinming Hu TDLS_IN_OFF_CHAN, 1605f2caaf3SAvinash Patil }; 1615f2caaf3SAvinash Patil 162429d90d2SAvinash Patil enum mwifiex_tdls_error_code { 163429d90d2SAvinash Patil TDLS_ERR_NO_ERROR = 0, 164429d90d2SAvinash Patil TDLS_ERR_INTERNAL_ERROR, 165429d90d2SAvinash Patil TDLS_ERR_MAX_LINKS_EST, 166429d90d2SAvinash Patil TDLS_ERR_LINK_EXISTS, 167429d90d2SAvinash Patil TDLS_ERR_LINK_NONEXISTENT, 168429d90d2SAvinash Patil TDLS_ERR_PEER_STA_UNREACHABLE = 25, 169429d90d2SAvinash Patil }; 170429d90d2SAvinash Patil 1715e6e3a92SBing Zhao #define BSS_ROLE_BIT_MASK BIT(0) 1725e6e3a92SBing Zhao 1735e6e3a92SBing Zhao #define GET_BSS_ROLE(priv) ((priv)->bss_role & BSS_ROLE_BIT_MASK) 1745e6e3a92SBing Zhao 1755e6e3a92SBing Zhao enum mwifiex_data_frame_type { 1765e6e3a92SBing Zhao MWIFIEX_DATA_FRAME_TYPE_ETH_II = 0, 1775e6e3a92SBing Zhao MWIFIEX_DATA_FRAME_TYPE_802_11, 1785e6e3a92SBing Zhao }; 1795e6e3a92SBing Zhao 1805e6e3a92SBing Zhao struct mwifiex_fw_image { 1815e6e3a92SBing Zhao u8 *helper_buf; 1825e6e3a92SBing Zhao u32 helper_len; 1835e6e3a92SBing Zhao u8 *fw_buf; 1845e6e3a92SBing Zhao u32 fw_len; 1855e6e3a92SBing Zhao }; 1865e6e3a92SBing Zhao 18712190c5dSAvinash Patil struct mwifiex_802_11_ssid { 18812190c5dSAvinash Patil u32 ssid_len; 18912190c5dSAvinash Patil u8 ssid[IEEE80211_MAX_SSID_LEN]; 19012190c5dSAvinash Patil }; 19112190c5dSAvinash Patil 1925e6e3a92SBing Zhao struct mwifiex_wait_queue { 193600f5d90SAmitkumar Karwar wait_queue_head_t wait; 1945e6e3a92SBing Zhao int status; 1955e6e3a92SBing Zhao }; 1965e6e3a92SBing Zhao 1975e6e3a92SBing Zhao struct mwifiex_rxinfo { 19892263a84SZhaoyang Liu struct sk_buff *parent; 1999da9a3b2SYogesh Ashok Powar u8 bss_num; 2009da9a3b2SYogesh Ashok Powar u8 bss_type; 2015e6e3a92SBing Zhao u8 use_count; 20292263a84SZhaoyang Liu u8 buf_type; 2035e6e3a92SBing Zhao }; 2045e6e3a92SBing Zhao 2055e6e3a92SBing Zhao struct mwifiex_txinfo { 2065e6e3a92SBing Zhao u8 flags; 2079da9a3b2SYogesh Ashok Powar u8 bss_num; 2089da9a3b2SYogesh Ashok Powar u8 bss_type; 209e35000eaSZhaoyang Liu u8 aggr_num; 210a1ed4849SUjjal Roy u32 pkt_len; 211808bbebcSAmitkumar Karwar u8 ack_frame_id; 21218ca4382SAmitkumar Karwar u64 cookie; 2135e6e3a92SBing Zhao }; 2145e6e3a92SBing Zhao 2155e6e3a92SBing Zhao enum mwifiex_wmm_ac_e { 2165e6e3a92SBing Zhao WMM_AC_BK, 2175e6e3a92SBing Zhao WMM_AC_BE, 2185e6e3a92SBing Zhao WMM_AC_VI, 2195e6e3a92SBing Zhao WMM_AC_VO 2205e6e3a92SBing Zhao } __packed; 22154428c57SAvinash Patil 22254428c57SAvinash Patil struct ieee_types_wmm_ac_parameters { 22354428c57SAvinash Patil u8 aci_aifsn_bitmap; 22454428c57SAvinash Patil u8 ecw_bitmap; 22554428c57SAvinash Patil __le16 tx_op_limit; 22654428c57SAvinash Patil } __packed; 22754428c57SAvinash Patil 22854428c57SAvinash Patil struct mwifiex_types_wmm_info { 22954428c57SAvinash Patil u8 oui[4]; 23054428c57SAvinash Patil u8 subtype; 23154428c57SAvinash Patil u8 version; 23254428c57SAvinash Patil u8 qos_info; 23354428c57SAvinash Patil u8 reserved; 23454428c57SAvinash Patil struct ieee_types_wmm_ac_parameters ac_params[IEEE80211_NUM_ACS]; 23554428c57SAvinash Patil } __packed; 236587b36d3SAvinash Patil 237587b36d3SAvinash Patil struct mwifiex_arp_eth_header { 238587b36d3SAvinash Patil struct arphdr hdr; 239587b36d3SAvinash Patil u8 ar_sha[ETH_ALEN]; 240587b36d3SAvinash Patil u8 ar_sip[4]; 241587b36d3SAvinash Patil u8 ar_tha[ETH_ALEN]; 242587b36d3SAvinash Patil u8 ar_tip[4]; 243587b36d3SAvinash Patil } __packed; 244bf354433SAvinash Patil 245bf354433SAvinash Patil struct mwifiex_chan_stats { 246bf354433SAvinash Patil u8 chan_num; 247bf354433SAvinash Patil u8 bandcfg; 248bf354433SAvinash Patil u8 flags; 249bf354433SAvinash Patil s8 noise; 250bf354433SAvinash Patil u16 total_bss; 251bf354433SAvinash Patil u16 cca_scan_dur; 252bf354433SAvinash Patil u16 cca_busy_dur; 253bf354433SAvinash Patil } __packed; 254cbf6e055SXinming Hu 255cbf6e055SXinming Hu #define MWIFIEX_HIST_MAX_SAMPLES 1048576 256cbf6e055SXinming Hu #define MWIFIEX_MAX_RX_RATES 44 257cbf6e055SXinming Hu #define MWIFIEX_MAX_AC_RX_RATES 74 258cbf6e055SXinming Hu #define MWIFIEX_MAX_SNR 256 259cbf6e055SXinming Hu #define MWIFIEX_MAX_NOISE_FLR 256 260cbf6e055SXinming Hu #define MWIFIEX_MAX_SIG_STRENGTH 256 261cbf6e055SXinming Hu 262cbf6e055SXinming Hu struct mwifiex_histogram_data { 263cbf6e055SXinming Hu atomic_t rx_rate[MWIFIEX_MAX_AC_RX_RATES]; 264cbf6e055SXinming Hu atomic_t snr[MWIFIEX_MAX_SNR]; 265cbf6e055SXinming Hu atomic_t noise_flr[MWIFIEX_MAX_NOISE_FLR]; 266cbf6e055SXinming Hu atomic_t sig_str[MWIFIEX_MAX_SIG_STRENGTH]; 267cbf6e055SXinming Hu atomic_t num_samples; 268cbf6e055SXinming Hu }; 269cbf6e055SXinming Hu 270cf052335SAvinash Patil struct mwifiex_iface_comb { 271cf052335SAvinash Patil u8 sta_intf; 272cf052335SAvinash Patil u8 uap_intf; 273cf052335SAvinash Patil u8 p2p_intf; 274cf052335SAvinash Patil }; 275cf052335SAvinash Patil 27685afb186SAvinash Patil struct mwifiex_radar_params { 27785afb186SAvinash Patil struct cfg80211_chan_def *chandef; 27885afb186SAvinash Patil u32 cac_time_ms; 27985afb186SAvinash Patil } __packed; 280cf075eacSAvinash Patil 281cf075eacSAvinash Patil struct mwifiex_11h_intf_state { 282cf075eacSAvinash Patil bool is_11h_enabled; 283cf075eacSAvinash Patil bool is_11h_active; 284cf075eacSAvinash Patil } __packed; 2859a862322SXinming Hu 2869a862322SXinming Hu #define MWIFIEX_FW_DUMP_IDX 0xff 28711e70824SXinming Hu #define MWIFIEX_FW_DUMP_MAX_MEMSIZE 0x160000 2889a862322SXinming Hu #define MWIFIEX_DRV_INFO_IDX 20 2899a862322SXinming Hu #define FW_DUMP_MAX_NAME_LEN 8 2909a862322SXinming Hu #define FW_DUMP_HOST_READY 0xEE 2919a862322SXinming Hu #define FW_DUMP_DONE 0xFF 2929a862322SXinming Hu #define FW_DUMP_READ_DONE 0xFE 2939a862322SXinming Hu 2949a862322SXinming Hu struct memory_type_mapping { 2959a862322SXinming Hu u8 mem_name[FW_DUMP_MAX_NAME_LEN]; 2969a862322SXinming Hu u8 *mem_ptr; 2979a862322SXinming Hu u32 mem_size; 2989a862322SXinming Hu u8 done_flag; 2999a862322SXinming Hu }; 3009a862322SXinming Hu 3019a862322SXinming Hu enum rdwr_status { 3029a862322SXinming Hu RDWR_STATUS_SUCCESS = 0, 3039a862322SXinming Hu RDWR_STATUS_FAILURE = 1, 3049a862322SXinming Hu RDWR_STATUS_DONE = 2 3059a862322SXinming Hu }; 3069a862322SXinming Hu 30728bf8312SGanapathi Bhat enum mwifiex_chan_width { 30828bf8312SGanapathi Bhat CHAN_BW_20MHZ = 0, 30928bf8312SGanapathi Bhat CHAN_BW_10MHZ, 31028bf8312SGanapathi Bhat CHAN_BW_40MHZ, 31128bf8312SGanapathi Bhat CHAN_BW_80MHZ, 31228bf8312SGanapathi Bhat CHAN_BW_8080MHZ, 31328bf8312SGanapathi Bhat CHAN_BW_160MHZ, 31428bf8312SGanapathi Bhat CHAN_BW_5MHZ, 31528bf8312SGanapathi Bhat }; 31628bf8312SGanapathi Bhat 31728bf8312SGanapathi Bhat enum mwifiex_chan_offset { 31828bf8312SGanapathi Bhat SEC_CHAN_NONE = 0, 31928bf8312SGanapathi Bhat SEC_CHAN_ABOVE = 1, 32028bf8312SGanapathi Bhat SEC_CHAN_5MHZ = 2, 32128bf8312SGanapathi Bhat SEC_CHAN_BELOW = 3 32228bf8312SGanapathi Bhat }; 32328bf8312SGanapathi Bhat 3245e6e3a92SBing Zhao #endif /* !_MWIFIEX_DECL_H_ */ 325