1d27a76faSLarry Finger /* SPDX-License-Identifier: GPL-2.0 */ 2d27a76faSLarry Finger /* Copyright(c) 2009-2012 Realtek Corporation.*/ 3f1d2b4d3SLarry Finger 4f1d2b4d3SLarry Finger #ifndef __RTL_WIFI_H__ 5f1d2b4d3SLarry Finger #define __RTL_WIFI_H__ 6f1d2b4d3SLarry Finger 7f1d2b4d3SLarry Finger #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8f1d2b4d3SLarry Finger 9f1d2b4d3SLarry Finger #include <linux/sched.h> 10f1d2b4d3SLarry Finger #include <linux/firmware.h> 11f1d2b4d3SLarry Finger #include <linux/etherdevice.h> 12f1d2b4d3SLarry Finger #include <linux/vmalloc.h> 13f1d2b4d3SLarry Finger #include <linux/usb.h> 14f1d2b4d3SLarry Finger #include <net/mac80211.h> 15f1d2b4d3SLarry Finger #include <linux/completion.h> 16f5678bfeSLarry Finger #include <linux/bitfield.h> 17f1d2b4d3SLarry Finger #include "debug.h" 18f1d2b4d3SLarry Finger 19f1d2b4d3SLarry Finger #define MASKBYTE0 0xff 20f1d2b4d3SLarry Finger #define MASKBYTE1 0xff00 21f1d2b4d3SLarry Finger #define MASKBYTE2 0xff0000 22f1d2b4d3SLarry Finger #define MASKBYTE3 0xff000000 23f1d2b4d3SLarry Finger #define MASKHWORD 0xffff0000 24f1d2b4d3SLarry Finger #define MASKLWORD 0x0000ffff 25f1d2b4d3SLarry Finger #define MASKDWORD 0xffffffff 26f1d2b4d3SLarry Finger #define MASK12BITS 0xfff 27f1d2b4d3SLarry Finger #define MASKH4BITS 0xf0000000 28f1d2b4d3SLarry Finger #define MASKOFDM_D 0xffc00000 29f1d2b4d3SLarry Finger #define MASKCCK 0x3f3f3f3f 30f1d2b4d3SLarry Finger 31f1d2b4d3SLarry Finger #define MASK4BITS 0x0f 32f1d2b4d3SLarry Finger #define MASK20BITS 0xfffff 33f1d2b4d3SLarry Finger #define RFREG_OFFSET_MASK 0xfffff 34f1d2b4d3SLarry Finger 35f1d2b4d3SLarry Finger #define MASKBYTE0 0xff 36f1d2b4d3SLarry Finger #define MASKBYTE1 0xff00 37f1d2b4d3SLarry Finger #define MASKBYTE2 0xff0000 38f1d2b4d3SLarry Finger #define MASKBYTE3 0xff000000 39f1d2b4d3SLarry Finger #define MASKHWORD 0xffff0000 40f1d2b4d3SLarry Finger #define MASKLWORD 0x0000ffff 41f1d2b4d3SLarry Finger #define MASKDWORD 0xffffffff 42f1d2b4d3SLarry Finger #define MASK12BITS 0xfff 43f1d2b4d3SLarry Finger #define MASKH4BITS 0xf0000000 44f1d2b4d3SLarry Finger #define MASKOFDM_D 0xffc00000 45f1d2b4d3SLarry Finger #define MASKCCK 0x3f3f3f3f 46f1d2b4d3SLarry Finger 47f1d2b4d3SLarry Finger #define MASK4BITS 0x0f 48f1d2b4d3SLarry Finger #define MASK20BITS 0xfffff 49f1d2b4d3SLarry Finger #define RFREG_OFFSET_MASK 0xfffff 50f1d2b4d3SLarry Finger 51f1d2b4d3SLarry Finger #define RF_CHANGE_BY_INIT 0 52f1d2b4d3SLarry Finger #define RF_CHANGE_BY_IPS BIT(28) 53f1d2b4d3SLarry Finger #define RF_CHANGE_BY_PS BIT(29) 54f1d2b4d3SLarry Finger #define RF_CHANGE_BY_HW BIT(30) 55f1d2b4d3SLarry Finger #define RF_CHANGE_BY_SW BIT(31) 56f1d2b4d3SLarry Finger 57f1d2b4d3SLarry Finger #define IQK_ADDA_REG_NUM 16 58f1d2b4d3SLarry Finger #define IQK_MAC_REG_NUM 4 59f1d2b4d3SLarry Finger #define IQK_THRESHOLD 8 60f1d2b4d3SLarry Finger 61f1d2b4d3SLarry Finger #define MAX_KEY_LEN 61 62f1d2b4d3SLarry Finger #define KEY_BUF_SIZE 5 63f1d2b4d3SLarry Finger 64f1d2b4d3SLarry Finger /* QoS related. */ 65f1d2b4d3SLarry Finger /*aci: 0x00 Best Effort*/ 66f1d2b4d3SLarry Finger /*aci: 0x01 Background*/ 67f1d2b4d3SLarry Finger /*aci: 0x10 Video*/ 68f1d2b4d3SLarry Finger /*aci: 0x11 Voice*/ 69f1d2b4d3SLarry Finger /*Max: define total number.*/ 70f1d2b4d3SLarry Finger #define AC0_BE 0 71f1d2b4d3SLarry Finger #define AC1_BK 1 72f1d2b4d3SLarry Finger #define AC2_VI 2 73f1d2b4d3SLarry Finger #define AC3_VO 3 74f1d2b4d3SLarry Finger #define AC_MAX 4 75f1d2b4d3SLarry Finger #define QOS_QUEUE_NUM 4 76f1d2b4d3SLarry Finger #define RTL_MAC80211_NUM_QUEUE 5 77f1d2b4d3SLarry Finger #define REALTEK_USB_VENQT_MAX_BUF_SIZE 254 78f1d2b4d3SLarry Finger #define RTL_USB_MAX_RX_COUNT 100 79f1d2b4d3SLarry Finger #define QBSS_LOAD_SIZE 5 80f1d2b4d3SLarry Finger #define MAX_WMMELE_LENGTH 64 81c713fb07SLarry Finger #define ASPM_L1_LATENCY 7 82f1d2b4d3SLarry Finger 83f1d2b4d3SLarry Finger #define TOTAL_CAM_ENTRY 32 84f1d2b4d3SLarry Finger 85f1d2b4d3SLarry Finger /*slot time for 11g. */ 86f1d2b4d3SLarry Finger #define RTL_SLOT_TIME_9 9 87f1d2b4d3SLarry Finger #define RTL_SLOT_TIME_20 20 88f1d2b4d3SLarry Finger 89f1d2b4d3SLarry Finger /*related to tcp/ip. */ 90f1d2b4d3SLarry Finger #define SNAP_SIZE 6 91f1d2b4d3SLarry Finger #define PROTOC_TYPE_SIZE 2 92f1d2b4d3SLarry Finger 93f1d2b4d3SLarry Finger /*related with 802.11 frame*/ 94f1d2b4d3SLarry Finger #define MAC80211_3ADDR_LEN 24 95f1d2b4d3SLarry Finger #define MAC80211_4ADDR_LEN 30 96f1d2b4d3SLarry Finger 97f1d2b4d3SLarry Finger #define CHANNEL_MAX_NUMBER (14 + 24 + 21) /* 14 is the max channel no */ 98f1d2b4d3SLarry Finger #define CHANNEL_MAX_NUMBER_2G 14 990a44b220SLarry Finger #define CHANNEL_MAX_NUMBER_5G 49 /* Please refer to 100f1d2b4d3SLarry Finger *"phy_GetChnlGroup8812A" and 101f1d2b4d3SLarry Finger * "Hal_ReadTxPowerInfo8812A" 102f1d2b4d3SLarry Finger */ 103f1d2b4d3SLarry Finger #define CHANNEL_MAX_NUMBER_5G_80M 7 104f1d2b4d3SLarry Finger #define CHANNEL_GROUP_MAX (3 + 9) /* ch1~3, 4~9, 10~14 = three groups */ 105f1d2b4d3SLarry Finger #define MAX_PG_GROUP 13 106f1d2b4d3SLarry Finger #define CHANNEL_GROUP_MAX_2G 3 107f1d2b4d3SLarry Finger #define CHANNEL_GROUP_IDX_5GL 3 108f1d2b4d3SLarry Finger #define CHANNEL_GROUP_IDX_5GM 6 109f1d2b4d3SLarry Finger #define CHANNEL_GROUP_IDX_5GH 9 110f1d2b4d3SLarry Finger #define CHANNEL_GROUP_MAX_5G 9 111f1d2b4d3SLarry Finger #define AVG_THERMAL_NUM 8 112f1d2b4d3SLarry Finger #define AVG_THERMAL_NUM_88E 4 113f1d2b4d3SLarry Finger #define AVG_THERMAL_NUM_8723BE 4 114f1d2b4d3SLarry Finger #define MAX_TID_COUNT 9 115f1d2b4d3SLarry Finger 116f1d2b4d3SLarry Finger /* for early mode */ 117f1d2b4d3SLarry Finger #define FCS_LEN 4 118f1d2b4d3SLarry Finger #define EM_HDR_LEN 8 119f1d2b4d3SLarry Finger 120f1d2b4d3SLarry Finger enum rtl8192c_h2c_cmd { 121f1d2b4d3SLarry Finger H2C_AP_OFFLOAD = 0, 122f1d2b4d3SLarry Finger H2C_SETPWRMODE = 1, 123f1d2b4d3SLarry Finger H2C_JOINBSSRPT = 2, 124f1d2b4d3SLarry Finger H2C_RSVDPAGE = 3, 125f1d2b4d3SLarry Finger H2C_RSSI_REPORT = 5, 126f1d2b4d3SLarry Finger H2C_RA_MASK = 6, 127f1d2b4d3SLarry Finger H2C_MACID_PS_MODE = 7, 128f1d2b4d3SLarry Finger H2C_P2P_PS_OFFLOAD = 8, 129f1d2b4d3SLarry Finger H2C_MAC_MODE_SEL = 9, 130f1d2b4d3SLarry Finger H2C_PWRM = 15, 131f1d2b4d3SLarry Finger H2C_P2P_PS_CTW_CMD = 24, 132f1d2b4d3SLarry Finger MAX_H2CCMD 133f1d2b4d3SLarry Finger }; 134f1d2b4d3SLarry Finger 135d7297a86SPing-Ke Shih enum { 136d7297a86SPing-Ke Shih H2C_BT_PORT_ID = 0x71, 137d7297a86SPing-Ke Shih }; 138d7297a86SPing-Ke Shih 1397aeb100bSPing-Ke Shih enum rtl_c2h_evt_v1 { 1407aeb100bSPing-Ke Shih C2H_DBG = 0, 1417aeb100bSPing-Ke Shih C2H_LB = 1, 1427aeb100bSPing-Ke Shih C2H_TXBF = 2, 1437aeb100bSPing-Ke Shih C2H_TX_REPORT = 3, 1447aeb100bSPing-Ke Shih C2H_BT_INFO = 9, 1457aeb100bSPing-Ke Shih C2H_BT_MP = 11, 1467aeb100bSPing-Ke Shih C2H_RA_RPT = 12, 1477aeb100bSPing-Ke Shih 1487aeb100bSPing-Ke Shih C2H_FW_SWCHNL = 0x10, 1497aeb100bSPing-Ke Shih C2H_IQK_FINISH = 0x11, 1507aeb100bSPing-Ke Shih 1517aeb100bSPing-Ke Shih C2H_EXT_V2 = 0xFF, 1527aeb100bSPing-Ke Shih }; 1537aeb100bSPing-Ke Shih 1547aeb100bSPing-Ke Shih enum rtl_c2h_evt_v2 { 1557aeb100bSPing-Ke Shih C2H_V2_CCX_RPT = 0x0F, 1567aeb100bSPing-Ke Shih }; 1577aeb100bSPing-Ke Shih 1589644032eSPing-Ke Shih #define GET_C2H_CMD_ID(c2h) ({u8 *__c2h = c2h; __c2h[0]; }) 1599644032eSPing-Ke Shih #define GET_C2H_SEQ(c2h) ({u8 *__c2h = c2h; __c2h[1]; }) 1609644032eSPing-Ke Shih #define C2H_DATA_OFFSET 2 1619644032eSPing-Ke Shih #define GET_C2H_DATA_PTR(c2h) ({u8 *__c2h = c2h; &__c2h[C2H_DATA_OFFSET]; }) 1629644032eSPing-Ke Shih 1635f380cefSPing-Ke Shih #define GET_TX_REPORT_SN_V1(c2h) (c2h[6]) 1645f380cefSPing-Ke Shih #define GET_TX_REPORT_ST_V1(c2h) (c2h[0] & 0xC0) 1655f380cefSPing-Ke Shih #define GET_TX_REPORT_RETRY_V1(c2h) (c2h[2] & 0x3F) 1665f380cefSPing-Ke Shih #define GET_TX_REPORT_SN_V2(c2h) (c2h[6]) 1675f380cefSPing-Ke Shih #define GET_TX_REPORT_ST_V2(c2h) (c2h[7] & 0xC0) 1685f380cefSPing-Ke Shih #define GET_TX_REPORT_RETRY_V2(c2h) (c2h[8] & 0x3F) 1695f380cefSPing-Ke Shih 170f1d2b4d3SLarry Finger #define MAX_TX_COUNT 4 171f1d2b4d3SLarry Finger #define MAX_REGULATION_NUM 4 172f1d2b4d3SLarry Finger #define MAX_RF_PATH_NUM 4 17381b813edSPing-Ke Shih #define MAX_RATE_SECTION_NUM 6 /* = MAX_RATE_SECTION */ 174d5e58252SLarry Finger #define MAX_2_4G_BANDWIDTH_NUM 4 175d5e58252SLarry Finger #define MAX_5G_BANDWIDTH_NUM 4 176f1d2b4d3SLarry Finger #define MAX_RF_PATH 4 177f1d2b4d3SLarry Finger #define MAX_CHNL_GROUP_24G 6 178f1d2b4d3SLarry Finger #define MAX_CHNL_GROUP_5G 14 179f1d2b4d3SLarry Finger 180f1d2b4d3SLarry Finger #define TX_PWR_BY_RATE_NUM_BAND 2 181f1d2b4d3SLarry Finger #define TX_PWR_BY_RATE_NUM_RF 4 182f1d2b4d3SLarry Finger #define TX_PWR_BY_RATE_NUM_SECTION 12 1834a7093b9SPing-Ke Shih #define TX_PWR_BY_RATE_NUM_RATE 84 /* >= TX_PWR_BY_RATE_NUM_SECTION */ 18481b813edSPing-Ke Shih #define MAX_BASE_NUM_IN_PHY_REG_PG_24G 6 /* MAX_RATE_SECTION */ 18581b813edSPing-Ke Shih #define MAX_BASE_NUM_IN_PHY_REG_PG_5G 5 /* MAX_RATE_SECTION -1 */ 186f1d2b4d3SLarry Finger 1870c07bd74SPing-Ke Shih #define BUFDESC_SEG_NUM 1 /* 0:2 seg, 1: 4 seg, 2: 8 seg */ 188f1d2b4d3SLarry Finger 189f1d2b4d3SLarry Finger #define DEL_SW_IDX_SZ 30 190f1d2b4d3SLarry Finger 191f1d2b4d3SLarry Finger /* For now, it's just for 8192ee 192f1d2b4d3SLarry Finger * but not OK yet, keep it 0 193f1d2b4d3SLarry Finger */ 1940c07bd74SPing-Ke Shih #define RTL8192EE_SEG_NUM BUFDESC_SEG_NUM 195f1d2b4d3SLarry Finger 196f1d2b4d3SLarry Finger enum rf_tx_num { 197f1d2b4d3SLarry Finger RF_1TX = 0, 198f1d2b4d3SLarry Finger RF_2TX, 199f1d2b4d3SLarry Finger RF_MAX_TX_NUM, 200f1d2b4d3SLarry Finger RF_TX_NUM_NONIMPLEMENT, 201f1d2b4d3SLarry Finger }; 202f1d2b4d3SLarry Finger 203f1d2b4d3SLarry Finger #define PACKET_NORMAL 0 204f1d2b4d3SLarry Finger #define PACKET_DHCP 1 205f1d2b4d3SLarry Finger #define PACKET_ARP 2 206f1d2b4d3SLarry Finger #define PACKET_EAPOL 3 207f1d2b4d3SLarry Finger 208f1d2b4d3SLarry Finger #define MAX_SUPPORT_WOL_PATTERN_NUM 16 209f1d2b4d3SLarry Finger #define RSVD_WOL_PATTERN_NUM 1 210f1d2b4d3SLarry Finger #define WKFMCAM_ADDR_NUM 6 211f1d2b4d3SLarry Finger #define WKFMCAM_SIZE 24 212f1d2b4d3SLarry Finger 213f1d2b4d3SLarry Finger #define MAX_WOL_BIT_MASK_SIZE 16 214f1d2b4d3SLarry Finger /* MIN LEN keeps 13 here */ 215f1d2b4d3SLarry Finger #define MIN_WOL_PATTERN_SIZE 13 216f1d2b4d3SLarry Finger #define MAX_WOL_PATTERN_SIZE 128 217f1d2b4d3SLarry Finger 218f1d2b4d3SLarry Finger #define WAKE_ON_MAGIC_PACKET BIT(0) 219f1d2b4d3SLarry Finger #define WAKE_ON_PATTERN_MATCH BIT(1) 220f1d2b4d3SLarry Finger 221f1d2b4d3SLarry Finger #define WOL_REASON_PTK_UPDATE BIT(0) 222f1d2b4d3SLarry Finger #define WOL_REASON_GTK_UPDATE BIT(1) 223f1d2b4d3SLarry Finger #define WOL_REASON_DISASSOC BIT(2) 224f1d2b4d3SLarry Finger #define WOL_REASON_DEAUTH BIT(3) 225f1d2b4d3SLarry Finger #define WOL_REASON_AP_LOST BIT(4) 226f1d2b4d3SLarry Finger #define WOL_REASON_MAGIC_PKT BIT(5) 227f1d2b4d3SLarry Finger #define WOL_REASON_UNICAST_PKT BIT(6) 228f1d2b4d3SLarry Finger #define WOL_REASON_PATTERN_PKT BIT(7) 229f1d2b4d3SLarry Finger #define WOL_REASON_RTD3_SSID_MATCH BIT(8) 230f1d2b4d3SLarry Finger #define WOL_REASON_REALWOW_V2_WAKEUPPKT BIT(9) 231f1d2b4d3SLarry Finger #define WOL_REASON_REALWOW_V2_ACKLOST BIT(10) 232f1d2b4d3SLarry Finger 233f1d2b4d3SLarry Finger struct rtlwifi_firmware_header { 234f1d2b4d3SLarry Finger __le16 signature; 235f1d2b4d3SLarry Finger u8 category; 236f1d2b4d3SLarry Finger u8 function; 237f1d2b4d3SLarry Finger __le16 version; 238f1d2b4d3SLarry Finger u8 subversion; 239f1d2b4d3SLarry Finger u8 rsvd1; 240f1d2b4d3SLarry Finger u8 month; 241f1d2b4d3SLarry Finger u8 date; 242f1d2b4d3SLarry Finger u8 hour; 243f1d2b4d3SLarry Finger u8 minute; 244e703c5ddSLarry Finger __le16 ramcodesize; 245f1d2b4d3SLarry Finger __le16 rsvd2; 246f1d2b4d3SLarry Finger __le32 svnindex; 247f1d2b4d3SLarry Finger __le32 rsvd3; 248f1d2b4d3SLarry Finger __le32 rsvd4; 249f1d2b4d3SLarry Finger __le32 rsvd5; 250f1d2b4d3SLarry Finger }; 251f1d2b4d3SLarry Finger 252f1d2b4d3SLarry Finger struct txpower_info_2g { 253f1d2b4d3SLarry Finger u8 index_cck_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G]; 254f1d2b4d3SLarry Finger u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G]; 255f1d2b4d3SLarry Finger /*If only one tx, only BW20 and OFDM are used.*/ 256f1d2b4d3SLarry Finger u8 cck_diff[MAX_RF_PATH][MAX_TX_COUNT]; 257f1d2b4d3SLarry Finger u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT]; 258f1d2b4d3SLarry Finger u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT]; 259f1d2b4d3SLarry Finger u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT]; 260f1d2b4d3SLarry Finger u8 bw80_diff[MAX_RF_PATH][MAX_TX_COUNT]; 261f1d2b4d3SLarry Finger u8 bw160_diff[MAX_RF_PATH][MAX_TX_COUNT]; 262f1d2b4d3SLarry Finger }; 263f1d2b4d3SLarry Finger 264f1d2b4d3SLarry Finger struct txpower_info_5g { 265f1d2b4d3SLarry Finger u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_5G]; 266f1d2b4d3SLarry Finger /*If only one tx, only BW20, OFDM, BW80 and BW160 are used.*/ 267f1d2b4d3SLarry Finger u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT]; 268f1d2b4d3SLarry Finger u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT]; 269f1d2b4d3SLarry Finger u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT]; 270f1d2b4d3SLarry Finger u8 bw80_diff[MAX_RF_PATH][MAX_TX_COUNT]; 271f1d2b4d3SLarry Finger u8 bw160_diff[MAX_RF_PATH][MAX_TX_COUNT]; 272f1d2b4d3SLarry Finger }; 273f1d2b4d3SLarry Finger 274f1d2b4d3SLarry Finger enum rate_section { 275f1d2b4d3SLarry Finger CCK = 0, 276f1d2b4d3SLarry Finger OFDM, 277f1d2b4d3SLarry Finger HT_MCS0_MCS7, 278f1d2b4d3SLarry Finger HT_MCS8_MCS15, 279f1d2b4d3SLarry Finger VHT_1SSMCS0_1SSMCS9, 280f1d2b4d3SLarry Finger VHT_2SSMCS0_2SSMCS9, 28181b813edSPing-Ke Shih MAX_RATE_SECTION, 282f1d2b4d3SLarry Finger }; 283f1d2b4d3SLarry Finger 284f1d2b4d3SLarry Finger enum intf_type { 285f1d2b4d3SLarry Finger INTF_PCI = 0, 286f1d2b4d3SLarry Finger INTF_USB = 1, 287f1d2b4d3SLarry Finger }; 288f1d2b4d3SLarry Finger 289f1d2b4d3SLarry Finger enum radio_path { 290f1d2b4d3SLarry Finger RF90_PATH_A = 0, 291f1d2b4d3SLarry Finger RF90_PATH_B = 1, 292f1d2b4d3SLarry Finger RF90_PATH_C = 2, 293f1d2b4d3SLarry Finger RF90_PATH_D = 3, 294f1d2b4d3SLarry Finger }; 295f1d2b4d3SLarry Finger 296ed979a1eSPing-Ke Shih enum radio_mask { 297ed979a1eSPing-Ke Shih RF_MASK_A = BIT(0), 298ed979a1eSPing-Ke Shih RF_MASK_B = BIT(1), 299ed979a1eSPing-Ke Shih RF_MASK_C = BIT(2), 300ed979a1eSPing-Ke Shih RF_MASK_D = BIT(3), 301ed979a1eSPing-Ke Shih }; 302ed979a1eSPing-Ke Shih 303f1d2b4d3SLarry Finger enum regulation_txpwr_lmt { 304f1d2b4d3SLarry Finger TXPWR_LMT_FCC = 0, 305f1d2b4d3SLarry Finger TXPWR_LMT_MKK = 1, 306f1d2b4d3SLarry Finger TXPWR_LMT_ETSI = 2, 307f1d2b4d3SLarry Finger TXPWR_LMT_WW = 3, 308f1d2b4d3SLarry Finger 309f1d2b4d3SLarry Finger TXPWR_LMT_MAX_REGULATION_NUM = 4 310f1d2b4d3SLarry Finger }; 311f1d2b4d3SLarry Finger 312f1d2b4d3SLarry Finger enum rt_eeprom_type { 313f1d2b4d3SLarry Finger EEPROM_93C46, 314f1d2b4d3SLarry Finger EEPROM_93C56, 315f1d2b4d3SLarry Finger EEPROM_BOOT_EFUSE, 316f1d2b4d3SLarry Finger }; 317f1d2b4d3SLarry Finger 318f1d2b4d3SLarry Finger enum ttl_status { 319f1d2b4d3SLarry Finger RTL_STATUS_INTERFACE_START = 0, 320f1d2b4d3SLarry Finger }; 321f1d2b4d3SLarry Finger 322f1d2b4d3SLarry Finger enum hardware_type { 323f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8192E, 324f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8192U, 325f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8192SE, 326f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8192SU, 327f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8192CE, 328f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8192CU, 329f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8192DE, 330f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8192DU, 331f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8723AE, 332f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8723U, 333f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8188EE, 334f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8723BE, 335f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8192EE, 336f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8821AE, 337f1d2b4d3SLarry Finger HARDWARE_TYPE_RTL8812AE, 33858438d9aSPing-Ke Shih HARDWARE_TYPE_RTL8822BE, 339f1d2b4d3SLarry Finger 340f1d2b4d3SLarry Finger /* keep it last */ 341f1d2b4d3SLarry Finger HARDWARE_TYPE_NUM 342f1d2b4d3SLarry Finger }; 343f1d2b4d3SLarry Finger 34458438d9aSPing-Ke Shih #define RTL_HW_TYPE(rtlpriv) (rtl_hal((struct rtl_priv *)rtlpriv)->hw_type) 34558438d9aSPing-Ke Shih #define IS_NEW_GENERATION_IC(rtlpriv) \ 34658438d9aSPing-Ke Shih (RTL_HW_TYPE(rtlpriv) >= HARDWARE_TYPE_RTL8192EE) 34758438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8192CE(rtlpriv) \ 34858438d9aSPing-Ke Shih (RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8192CE) 34958438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8812(rtlpriv) \ 35058438d9aSPing-Ke Shih (RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8812AE) 35158438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8821(rtlpriv) \ 35258438d9aSPing-Ke Shih (RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8821AE) 35358438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8723A(rtlpriv) \ 35458438d9aSPing-Ke Shih (RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8723AE) 35558438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8723B(rtlpriv) \ 35658438d9aSPing-Ke Shih (RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8723BE) 35758438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8192E(rtlpriv) \ 35858438d9aSPing-Ke Shih (RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8192EE) 35958438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8822B(rtlpriv) \ 36058438d9aSPing-Ke Shih (RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8822BE) 361f1d2b4d3SLarry Finger 362f1d2b4d3SLarry Finger #define RX_HAL_IS_CCK_RATE(rxmcs) \ 363f1d2b4d3SLarry Finger ((rxmcs) == DESC_RATE1M || \ 364f1d2b4d3SLarry Finger (rxmcs) == DESC_RATE2M || \ 365f1d2b4d3SLarry Finger (rxmcs) == DESC_RATE5_5M || \ 366f1d2b4d3SLarry Finger (rxmcs) == DESC_RATE11M) 367f1d2b4d3SLarry Finger 368f1d2b4d3SLarry Finger enum scan_operation_backup_opt { 369f1d2b4d3SLarry Finger SCAN_OPT_BACKUP = 0, 370f1d2b4d3SLarry Finger SCAN_OPT_BACKUP_BAND0 = 0, 371f1d2b4d3SLarry Finger SCAN_OPT_BACKUP_BAND1, 372f1d2b4d3SLarry Finger SCAN_OPT_RESTORE, 373f1d2b4d3SLarry Finger SCAN_OPT_MAX 374f1d2b4d3SLarry Finger }; 375f1d2b4d3SLarry Finger 376f1d2b4d3SLarry Finger /*RF state.*/ 377f1d2b4d3SLarry Finger enum rf_pwrstate { 378f1d2b4d3SLarry Finger ERFON, 379f1d2b4d3SLarry Finger ERFSLEEP, 380f1d2b4d3SLarry Finger ERFOFF 381f1d2b4d3SLarry Finger }; 382f1d2b4d3SLarry Finger 383f1d2b4d3SLarry Finger struct bb_reg_def { 384f1d2b4d3SLarry Finger u32 rfintfs; 385f1d2b4d3SLarry Finger u32 rfintfi; 386f1d2b4d3SLarry Finger u32 rfintfo; 387f1d2b4d3SLarry Finger u32 rfintfe; 388f1d2b4d3SLarry Finger u32 rf3wire_offset; 389f1d2b4d3SLarry Finger u32 rflssi_select; 390f1d2b4d3SLarry Finger u32 rftxgain_stage; 391f1d2b4d3SLarry Finger u32 rfhssi_para1; 392f1d2b4d3SLarry Finger u32 rfhssi_para2; 393f1d2b4d3SLarry Finger u32 rfsw_ctrl; 394f1d2b4d3SLarry Finger u32 rfagc_control1; 395f1d2b4d3SLarry Finger u32 rfagc_control2; 396f1d2b4d3SLarry Finger u32 rfrxiq_imbal; 397f1d2b4d3SLarry Finger u32 rfrx_afe; 398f1d2b4d3SLarry Finger u32 rftxiq_imbal; 399f1d2b4d3SLarry Finger u32 rftx_afe; 400f1d2b4d3SLarry Finger u32 rf_rb; /* rflssi_readback */ 401f1d2b4d3SLarry Finger u32 rf_rbpi; /* rflssi_readbackpi */ 402f1d2b4d3SLarry Finger }; 403f1d2b4d3SLarry Finger 404f1d2b4d3SLarry Finger enum io_type { 405f1d2b4d3SLarry Finger IO_CMD_PAUSE_DM_BY_SCAN = 0, 406f1d2b4d3SLarry Finger IO_CMD_PAUSE_BAND0_DM_BY_SCAN = 0, 407f1d2b4d3SLarry Finger IO_CMD_PAUSE_BAND1_DM_BY_SCAN = 1, 408f1d2b4d3SLarry Finger IO_CMD_RESUME_DM_BY_SCAN = 2, 409f1d2b4d3SLarry Finger }; 410f1d2b4d3SLarry Finger 411f1d2b4d3SLarry Finger enum hw_variables { 4128334ffdcSLarry Finger HW_VAR_ETHER_ADDR = 0x0, 4138334ffdcSLarry Finger HW_VAR_MULTICAST_REG = 0x1, 4148334ffdcSLarry Finger HW_VAR_BASIC_RATE = 0x2, 4158334ffdcSLarry Finger HW_VAR_BSSID = 0x3, 4168334ffdcSLarry Finger HW_VAR_MEDIA_STATUS = 0x4, 4178334ffdcSLarry Finger HW_VAR_SECURITY_CONF = 0x5, 4188334ffdcSLarry Finger HW_VAR_BEACON_INTERVAL = 0x6, 4198334ffdcSLarry Finger HW_VAR_ATIM_WINDOW = 0x7, 4208334ffdcSLarry Finger HW_VAR_LISTEN_INTERVAL = 0x8, 4218334ffdcSLarry Finger HW_VAR_CS_COUNTER = 0x9, 4228334ffdcSLarry Finger HW_VAR_DEFAULTKEY0 = 0xa, 4238334ffdcSLarry Finger HW_VAR_DEFAULTKEY1 = 0xb, 4248334ffdcSLarry Finger HW_VAR_DEFAULTKEY2 = 0xc, 4258334ffdcSLarry Finger HW_VAR_DEFAULTKEY3 = 0xd, 4268334ffdcSLarry Finger HW_VAR_SIFS = 0xe, 4278334ffdcSLarry Finger HW_VAR_R2T_SIFS = 0xf, 4288334ffdcSLarry Finger HW_VAR_DIFS = 0x10, 4298334ffdcSLarry Finger HW_VAR_EIFS = 0x11, 4308334ffdcSLarry Finger HW_VAR_SLOT_TIME = 0x12, 4318334ffdcSLarry Finger HW_VAR_ACK_PREAMBLE = 0x13, 4328334ffdcSLarry Finger HW_VAR_CW_CONFIG = 0x14, 4338334ffdcSLarry Finger HW_VAR_CW_VALUES = 0x15, 4348334ffdcSLarry Finger HW_VAR_RATE_FALLBACK_CONTROL = 0x16, 4358334ffdcSLarry Finger HW_VAR_CONTENTION_WINDOW = 0x17, 4368334ffdcSLarry Finger HW_VAR_RETRY_COUNT = 0x18, 4378334ffdcSLarry Finger HW_VAR_TR_SWITCH = 0x19, 4388334ffdcSLarry Finger HW_VAR_COMMAND = 0x1a, 4398334ffdcSLarry Finger HW_VAR_WPA_CONFIG = 0x1b, 4408334ffdcSLarry Finger HW_VAR_AMPDU_MIN_SPACE = 0x1c, 4418334ffdcSLarry Finger HW_VAR_SHORTGI_DENSITY = 0x1d, 4428334ffdcSLarry Finger HW_VAR_AMPDU_FACTOR = 0x1e, 4438334ffdcSLarry Finger HW_VAR_MCS_RATE_AVAILABLE = 0x1f, 4448334ffdcSLarry Finger HW_VAR_AC_PARAM = 0x20, 4458334ffdcSLarry Finger HW_VAR_ACM_CTRL = 0x21, 446e703c5ddSLarry Finger HW_VAR_DIS_REQ_QSIZE = 0x22, 4478334ffdcSLarry Finger HW_VAR_CCX_CHNL_LOAD = 0x23, 4488334ffdcSLarry Finger HW_VAR_CCX_NOISE_HISTOGRAM = 0x24, 4498334ffdcSLarry Finger HW_VAR_CCX_CLM_NHM = 0x25, 450e703c5ddSLarry Finger HW_VAR_TXOPLIMIT = 0x26, 4518334ffdcSLarry Finger HW_VAR_TURBO_MODE = 0x27, 4528334ffdcSLarry Finger HW_VAR_RF_STATE = 0x28, 4538334ffdcSLarry Finger HW_VAR_RF_OFF_BY_HW = 0x29, 4548334ffdcSLarry Finger HW_VAR_BUS_SPEED = 0x2a, 4558334ffdcSLarry Finger HW_VAR_SET_DEV_POWER = 0x2b, 456f1d2b4d3SLarry Finger 4578334ffdcSLarry Finger HW_VAR_RCR = 0x2c, 4588334ffdcSLarry Finger HW_VAR_RATR_0 = 0x2d, 4598334ffdcSLarry Finger HW_VAR_RRSR = 0x2e, 4608334ffdcSLarry Finger HW_VAR_CPU_RST = 0x2f, 4618334ffdcSLarry Finger HW_VAR_CHECK_BSSID = 0x30, 4628334ffdcSLarry Finger HW_VAR_LBK_MODE = 0x31, 4638334ffdcSLarry Finger HW_VAR_AES_11N_FIX = 0x32, 4648334ffdcSLarry Finger HW_VAR_USB_RX_AGGR = 0x33, 4658334ffdcSLarry Finger HW_VAR_USER_CONTROL_TURBO_MODE = 0x34, 4668334ffdcSLarry Finger HW_VAR_RETRY_LIMIT = 0x35, 4678334ffdcSLarry Finger HW_VAR_INIT_TX_RATE = 0x36, 4688334ffdcSLarry Finger HW_VAR_TX_RATE_REG = 0x37, 4698334ffdcSLarry Finger HW_VAR_EFUSE_USAGE = 0x38, 4708334ffdcSLarry Finger HW_VAR_EFUSE_BYTES = 0x39, 4718334ffdcSLarry Finger HW_VAR_AUTOLOAD_STATUS = 0x3a, 4728334ffdcSLarry Finger HW_VAR_RF_2R_DISABLE = 0x3b, 4738334ffdcSLarry Finger HW_VAR_SET_RPWM = 0x3c, 4748334ffdcSLarry Finger HW_VAR_H2C_FW_PWRMODE = 0x3d, 4758334ffdcSLarry Finger HW_VAR_H2C_FW_JOINBSSRPT = 0x3e, 4768334ffdcSLarry Finger HW_VAR_H2C_FW_MEDIASTATUSRPT = 0x3f, 4778334ffdcSLarry Finger HW_VAR_H2C_FW_P2P_PS_OFFLOAD = 0x40, 4788334ffdcSLarry Finger HW_VAR_FW_PSMODE_STATUS = 0x41, 4798334ffdcSLarry Finger HW_VAR_INIT_RTS_RATE = 0x42, 4808334ffdcSLarry Finger HW_VAR_RESUME_CLK_ON = 0x43, 4818334ffdcSLarry Finger HW_VAR_FW_LPS_ACTION = 0x44, 4828334ffdcSLarry Finger HW_VAR_1X1_RECV_COMBINE = 0x45, 4838334ffdcSLarry Finger HW_VAR_STOP_SEND_BEACON = 0x46, 4848334ffdcSLarry Finger HW_VAR_TSF_TIMER = 0x47, 4858334ffdcSLarry Finger HW_VAR_IO_CMD = 0x48, 486f1d2b4d3SLarry Finger 4878334ffdcSLarry Finger HW_VAR_RF_RECOVERY = 0x49, 4888334ffdcSLarry Finger HW_VAR_H2C_FW_UPDATE_GTK = 0x4a, 4898334ffdcSLarry Finger HW_VAR_WF_MASK = 0x4b, 4908334ffdcSLarry Finger HW_VAR_WF_CRC = 0x4c, 4918334ffdcSLarry Finger HW_VAR_WF_IS_MAC_ADDR = 0x4d, 4928334ffdcSLarry Finger HW_VAR_H2C_FW_OFFLOAD = 0x4e, 4938334ffdcSLarry Finger HW_VAR_RESET_WFCRC = 0x4f, 494f1d2b4d3SLarry Finger 4958334ffdcSLarry Finger HW_VAR_HANDLE_FW_C2H = 0x50, 4968334ffdcSLarry Finger HW_VAR_DL_FW_RSVD_PAGE = 0x51, 4978334ffdcSLarry Finger HW_VAR_AID = 0x52, 4988334ffdcSLarry Finger HW_VAR_HW_SEQ_ENABLE = 0x53, 4998334ffdcSLarry Finger HW_VAR_CORRECT_TSF = 0x54, 5008334ffdcSLarry Finger HW_VAR_BCN_VALID = 0x55, 5018334ffdcSLarry Finger HW_VAR_FWLPS_RF_ON = 0x56, 5028334ffdcSLarry Finger HW_VAR_DUAL_TSF_RST = 0x57, 503e703c5ddSLarry Finger HW_VAR_SWITCH_EPHY_WOWLAN = 0x58, 5048334ffdcSLarry Finger HW_VAR_INT_MIGRATION = 0x59, 5058334ffdcSLarry Finger HW_VAR_INT_AC = 0x5a, 5068334ffdcSLarry Finger HW_VAR_RF_TIMING = 0x5b, 507f1d2b4d3SLarry Finger 5088334ffdcSLarry Finger HAL_DEF_WOWLAN = 0x5c, 5098334ffdcSLarry Finger HW_VAR_MRC = 0x5d, 5108334ffdcSLarry Finger HW_VAR_KEEP_ALIVE = 0x5e, 5118334ffdcSLarry Finger HW_VAR_NAV_UPPER = 0x5f, 512f1d2b4d3SLarry Finger 5138334ffdcSLarry Finger HW_VAR_MGT_FILTER = 0x60, 5148334ffdcSLarry Finger HW_VAR_CTRL_FILTER = 0x61, 5158334ffdcSLarry Finger HW_VAR_DATA_FILTER = 0x62, 516f1d2b4d3SLarry Finger }; 517f1d2b4d3SLarry Finger 518f1d2b4d3SLarry Finger enum rt_media_status { 519f1d2b4d3SLarry Finger RT_MEDIA_DISCONNECT = 0, 520f1d2b4d3SLarry Finger RT_MEDIA_CONNECT = 1 521f1d2b4d3SLarry Finger }; 522f1d2b4d3SLarry Finger 523f1d2b4d3SLarry Finger enum rt_oem_id { 524f1d2b4d3SLarry Finger RT_CID_DEFAULT = 0, 525f1d2b4d3SLarry Finger RT_CID_8187_ALPHA0 = 1, 526f1d2b4d3SLarry Finger RT_CID_8187_SERCOMM_PS = 2, 527f1d2b4d3SLarry Finger RT_CID_8187_HW_LED = 3, 528f1d2b4d3SLarry Finger RT_CID_8187_NETGEAR = 4, 529f1d2b4d3SLarry Finger RT_CID_WHQL = 5, 530f1d2b4d3SLarry Finger RT_CID_819X_CAMEO = 6, 531f1d2b4d3SLarry Finger RT_CID_819X_RUNTOP = 7, 532f1d2b4d3SLarry Finger RT_CID_819X_SENAO = 8, 533f1d2b4d3SLarry Finger RT_CID_TOSHIBA = 9, 534f1d2b4d3SLarry Finger RT_CID_819X_NETCORE = 10, 535f1d2b4d3SLarry Finger RT_CID_NETTRONIX = 11, 536f1d2b4d3SLarry Finger RT_CID_DLINK = 12, 537f1d2b4d3SLarry Finger RT_CID_PRONET = 13, 538f1d2b4d3SLarry Finger RT_CID_COREGA = 14, 539f1d2b4d3SLarry Finger RT_CID_819X_ALPHA = 15, 540f1d2b4d3SLarry Finger RT_CID_819X_SITECOM = 16, 541f1d2b4d3SLarry Finger RT_CID_CCX = 17, 542f1d2b4d3SLarry Finger RT_CID_819X_LENOVO = 18, 543f1d2b4d3SLarry Finger RT_CID_819X_QMI = 19, 544f1d2b4d3SLarry Finger RT_CID_819X_EDIMAX_BELKIN = 20, 545f1d2b4d3SLarry Finger RT_CID_819X_SERCOMM_BELKIN = 21, 546f1d2b4d3SLarry Finger RT_CID_819X_CAMEO1 = 22, 547f1d2b4d3SLarry Finger RT_CID_819X_MSI = 23, 548f1d2b4d3SLarry Finger RT_CID_819X_ACER = 24, 549f1d2b4d3SLarry Finger RT_CID_819X_HP = 27, 550f1d2b4d3SLarry Finger RT_CID_819X_CLEVO = 28, 551f1d2b4d3SLarry Finger RT_CID_819X_ARCADYAN_BELKIN = 29, 552f1d2b4d3SLarry Finger RT_CID_819X_SAMSUNG = 30, 553f1d2b4d3SLarry Finger RT_CID_819X_WNC_COREGA = 31, 554f1d2b4d3SLarry Finger RT_CID_819X_FOXCOON = 32, 555f1d2b4d3SLarry Finger RT_CID_819X_DELL = 33, 556f1d2b4d3SLarry Finger RT_CID_819X_PRONETS = 34, 557f1d2b4d3SLarry Finger RT_CID_819X_EDIMAX_ASUS = 35, 558f1d2b4d3SLarry Finger RT_CID_NETGEAR = 36, 559f1d2b4d3SLarry Finger RT_CID_PLANEX = 37, 560f1d2b4d3SLarry Finger RT_CID_CC_C = 38, 561a1ee1a09SPing-Ke Shih RT_CID_LENOVO_CHINA = 40, 562f1d2b4d3SLarry Finger }; 563f1d2b4d3SLarry Finger 564f1d2b4d3SLarry Finger enum hw_descs { 565f1d2b4d3SLarry Finger HW_DESC_OWN, 566f1d2b4d3SLarry Finger HW_DESC_RXOWN, 567f1d2b4d3SLarry Finger HW_DESC_TX_NEXTDESC_ADDR, 568f1d2b4d3SLarry Finger HW_DESC_TXBUFF_ADDR, 569f1d2b4d3SLarry Finger HW_DESC_RXBUFF_ADDR, 570f1d2b4d3SLarry Finger HW_DESC_RXPKT_LEN, 571f1d2b4d3SLarry Finger HW_DESC_RXERO, 572f1d2b4d3SLarry Finger HW_DESC_RX_PREPARE, 573f1d2b4d3SLarry Finger }; 574f1d2b4d3SLarry Finger 575f1d2b4d3SLarry Finger enum prime_sc { 576f1d2b4d3SLarry Finger PRIME_CHNL_OFFSET_DONT_CARE = 0, 577f1d2b4d3SLarry Finger PRIME_CHNL_OFFSET_LOWER = 1, 578f1d2b4d3SLarry Finger PRIME_CHNL_OFFSET_UPPER = 2, 579f1d2b4d3SLarry Finger }; 580f1d2b4d3SLarry Finger 581f1d2b4d3SLarry Finger enum rf_type { 582f1d2b4d3SLarry Finger RF_1T1R = 0, 583f1d2b4d3SLarry Finger RF_1T2R = 1, 584f1d2b4d3SLarry Finger RF_2T2R = 2, 585f1d2b4d3SLarry Finger RF_2T2R_GREEN = 3, 58608ab7465SPing-Ke Shih RF_2T3R = 4, 58708ab7465SPing-Ke Shih RF_2T4R = 5, 58808ab7465SPing-Ke Shih RF_3T3R = 6, 58908ab7465SPing-Ke Shih RF_3T4R = 7, 59008ab7465SPing-Ke Shih RF_4T4R = 8, 591f1d2b4d3SLarry Finger }; 592f1d2b4d3SLarry Finger 593f1d2b4d3SLarry Finger enum ht_channel_width { 594f1d2b4d3SLarry Finger HT_CHANNEL_WIDTH_20 = 0, 595f1d2b4d3SLarry Finger HT_CHANNEL_WIDTH_20_40 = 1, 596f1d2b4d3SLarry Finger HT_CHANNEL_WIDTH_80 = 2, 597ed979a1eSPing-Ke Shih HT_CHANNEL_WIDTH_MAX, 598f1d2b4d3SLarry Finger }; 599f1d2b4d3SLarry Finger 600cc0e5f1cSPaul Walmsley /* Ref: 802.11i spec D10.0 7.3.2.25.1 601d3da329cSLarry Finger * Cipher Suites Encryption Algorithms 602d3da329cSLarry Finger */ 603f1d2b4d3SLarry Finger enum rt_enc_alg { 604f1d2b4d3SLarry Finger NO_ENCRYPTION = 0, 605f1d2b4d3SLarry Finger WEP40_ENCRYPTION = 1, 606f1d2b4d3SLarry Finger TKIP_ENCRYPTION = 2, 607f1d2b4d3SLarry Finger RSERVED_ENCRYPTION = 3, 608f1d2b4d3SLarry Finger AESCCMP_ENCRYPTION = 4, 609f1d2b4d3SLarry Finger WEP104_ENCRYPTION = 5, 610f1d2b4d3SLarry Finger AESCMAC_ENCRYPTION = 6, /*IEEE802.11w */ 611f1d2b4d3SLarry Finger }; 612f1d2b4d3SLarry Finger 613f1d2b4d3SLarry Finger enum rtl_hal_state { 614f1d2b4d3SLarry Finger _HAL_STATE_STOP = 0, 615f1d2b4d3SLarry Finger _HAL_STATE_START = 1, 616f1d2b4d3SLarry Finger }; 617f1d2b4d3SLarry Finger 6186ec9dfbcSPing-Ke Shih enum rtl_desc_rate { 619f1d2b4d3SLarry Finger DESC_RATE1M = 0x00, 620f1d2b4d3SLarry Finger DESC_RATE2M = 0x01, 621f1d2b4d3SLarry Finger DESC_RATE5_5M = 0x02, 622f1d2b4d3SLarry Finger DESC_RATE11M = 0x03, 623f1d2b4d3SLarry Finger 624f1d2b4d3SLarry Finger DESC_RATE6M = 0x04, 625f1d2b4d3SLarry Finger DESC_RATE9M = 0x05, 626f1d2b4d3SLarry Finger DESC_RATE12M = 0x06, 627f1d2b4d3SLarry Finger DESC_RATE18M = 0x07, 628f1d2b4d3SLarry Finger DESC_RATE24M = 0x08, 629f1d2b4d3SLarry Finger DESC_RATE36M = 0x09, 630f1d2b4d3SLarry Finger DESC_RATE48M = 0x0a, 631f1d2b4d3SLarry Finger DESC_RATE54M = 0x0b, 632f1d2b4d3SLarry Finger 633f1d2b4d3SLarry Finger DESC_RATEMCS0 = 0x0c, 634f1d2b4d3SLarry Finger DESC_RATEMCS1 = 0x0d, 635f1d2b4d3SLarry Finger DESC_RATEMCS2 = 0x0e, 636f1d2b4d3SLarry Finger DESC_RATEMCS3 = 0x0f, 637f1d2b4d3SLarry Finger DESC_RATEMCS4 = 0x10, 638f1d2b4d3SLarry Finger DESC_RATEMCS5 = 0x11, 639f1d2b4d3SLarry Finger DESC_RATEMCS6 = 0x12, 640f1d2b4d3SLarry Finger DESC_RATEMCS7 = 0x13, 641f1d2b4d3SLarry Finger DESC_RATEMCS8 = 0x14, 642f1d2b4d3SLarry Finger DESC_RATEMCS9 = 0x15, 643f1d2b4d3SLarry Finger DESC_RATEMCS10 = 0x16, 644f1d2b4d3SLarry Finger DESC_RATEMCS11 = 0x17, 645f1d2b4d3SLarry Finger DESC_RATEMCS12 = 0x18, 646f1d2b4d3SLarry Finger DESC_RATEMCS13 = 0x19, 647f1d2b4d3SLarry Finger DESC_RATEMCS14 = 0x1a, 648f1d2b4d3SLarry Finger DESC_RATEMCS15 = 0x1b, 649f1d2b4d3SLarry Finger DESC_RATEMCS15_SG = 0x1c, 650f1d2b4d3SLarry Finger DESC_RATEMCS32 = 0x20, 651f1d2b4d3SLarry Finger 652f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS0 = 0x2c, 653f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS1 = 0x2d, 654f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS2 = 0x2e, 655f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS3 = 0x2f, 656f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS4 = 0x30, 657f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS5 = 0x31, 658f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS6 = 0x32, 659f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS7 = 0x33, 660f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS8 = 0x34, 661f1d2b4d3SLarry Finger DESC_RATEVHT1SS_MCS9 = 0x35, 662f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS0 = 0x36, 663f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS1 = 0x37, 664f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS2 = 0x38, 665f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS3 = 0x39, 666f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS4 = 0x3a, 667f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS5 = 0x3b, 668f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS6 = 0x3c, 669f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS7 = 0x3d, 670f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS8 = 0x3e, 671f1d2b4d3SLarry Finger DESC_RATEVHT2SS_MCS9 = 0x3f, 672f1d2b4d3SLarry Finger }; 673f1d2b4d3SLarry Finger 674f1d2b4d3SLarry Finger enum rtl_var_map { 675f1d2b4d3SLarry Finger /*reg map */ 676f1d2b4d3SLarry Finger SYS_ISO_CTRL = 0, 677f1d2b4d3SLarry Finger SYS_FUNC_EN, 678f1d2b4d3SLarry Finger SYS_CLK, 679f1d2b4d3SLarry Finger MAC_RCR_AM, 680f1d2b4d3SLarry Finger MAC_RCR_AB, 681f1d2b4d3SLarry Finger MAC_RCR_ACRC32, 682f1d2b4d3SLarry Finger MAC_RCR_ACF, 683f1d2b4d3SLarry Finger MAC_RCR_AAP, 684f1d2b4d3SLarry Finger MAC_HIMR, 685f1d2b4d3SLarry Finger MAC_HIMRE, 686f1d2b4d3SLarry Finger MAC_HSISR, 687f1d2b4d3SLarry Finger 688f1d2b4d3SLarry Finger /*efuse map */ 689f1d2b4d3SLarry Finger EFUSE_TEST, 690f1d2b4d3SLarry Finger EFUSE_CTRL, 691f1d2b4d3SLarry Finger EFUSE_CLK, 692f1d2b4d3SLarry Finger EFUSE_CLK_CTRL, 693f1d2b4d3SLarry Finger EFUSE_PWC_EV12V, 694f1d2b4d3SLarry Finger EFUSE_FEN_ELDR, 695f1d2b4d3SLarry Finger EFUSE_LOADER_CLK_EN, 696f1d2b4d3SLarry Finger EFUSE_ANA8M, 697f1d2b4d3SLarry Finger EFUSE_HWSET_MAX_SIZE, 698f1d2b4d3SLarry Finger EFUSE_MAX_SECTION_MAP, 699f1d2b4d3SLarry Finger EFUSE_REAL_CONTENT_SIZE, 700f1d2b4d3SLarry Finger EFUSE_OOB_PROTECT_BYTES_LEN, 701f1d2b4d3SLarry Finger EFUSE_ACCESS, 702f1d2b4d3SLarry Finger 703f1d2b4d3SLarry Finger /*CAM map */ 704f1d2b4d3SLarry Finger RWCAM, 705f1d2b4d3SLarry Finger WCAMI, 706f1d2b4d3SLarry Finger RCAMO, 707f1d2b4d3SLarry Finger CAMDBG, 708f1d2b4d3SLarry Finger SECR, 709f1d2b4d3SLarry Finger SEC_CAM_NONE, 710f1d2b4d3SLarry Finger SEC_CAM_WEP40, 711f1d2b4d3SLarry Finger SEC_CAM_TKIP, 712f1d2b4d3SLarry Finger SEC_CAM_AES, 713f1d2b4d3SLarry Finger SEC_CAM_WEP104, 714f1d2b4d3SLarry Finger 715f1d2b4d3SLarry Finger /*IMR map */ 716f1d2b4d3SLarry Finger RTL_IMR_BCNDMAINT6, /*Beacon DMA Interrupt 6 */ 717f1d2b4d3SLarry Finger RTL_IMR_BCNDMAINT5, /*Beacon DMA Interrupt 5 */ 718f1d2b4d3SLarry Finger RTL_IMR_BCNDMAINT4, /*Beacon DMA Interrupt 4 */ 719f1d2b4d3SLarry Finger RTL_IMR_BCNDMAINT3, /*Beacon DMA Interrupt 3 */ 720f1d2b4d3SLarry Finger RTL_IMR_BCNDMAINT2, /*Beacon DMA Interrupt 2 */ 721f1d2b4d3SLarry Finger RTL_IMR_BCNDMAINT1, /*Beacon DMA Interrupt 1 */ 722f1d2b4d3SLarry Finger RTL_IMR_BCNDOK8, /*Beacon Queue DMA OK Interrup 8 */ 723f1d2b4d3SLarry Finger RTL_IMR_BCNDOK7, /*Beacon Queue DMA OK Interrup 7 */ 724f1d2b4d3SLarry Finger RTL_IMR_BCNDOK6, /*Beacon Queue DMA OK Interrup 6 */ 725f1d2b4d3SLarry Finger RTL_IMR_BCNDOK5, /*Beacon Queue DMA OK Interrup 5 */ 726f1d2b4d3SLarry Finger RTL_IMR_BCNDOK4, /*Beacon Queue DMA OK Interrup 4 */ 727f1d2b4d3SLarry Finger RTL_IMR_BCNDOK3, /*Beacon Queue DMA OK Interrup 3 */ 728f1d2b4d3SLarry Finger RTL_IMR_BCNDOK2, /*Beacon Queue DMA OK Interrup 2 */ 729f1d2b4d3SLarry Finger RTL_IMR_BCNDOK1, /*Beacon Queue DMA OK Interrup 1 */ 730f1d2b4d3SLarry Finger RTL_IMR_TIMEOUT2, /*Timeout interrupt 2 */ 731f1d2b4d3SLarry Finger RTL_IMR_TIMEOUT1, /*Timeout interrupt 1 */ 732f1d2b4d3SLarry Finger RTL_IMR_TXFOVW, /*Transmit FIFO Overflow */ 733f1d2b4d3SLarry Finger RTL_IMR_PSTIMEOUT, /*Power save time out interrupt */ 734f1d2b4d3SLarry Finger RTL_IMR_BCNINT, /*Beacon DMA Interrupt 0 */ 735f1d2b4d3SLarry Finger RTL_IMR_RXFOVW, /*Receive FIFO Overflow */ 736f1d2b4d3SLarry Finger RTL_IMR_RDU, /*Receive Descriptor Unavailable */ 737f1d2b4d3SLarry Finger RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */ 73889d3e8abSPing-Ke Shih RTL_IMR_H2CDOK, /*H2C Queue DMA OK Interrupt */ 739f1d2b4d3SLarry Finger RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */ 740f1d2b4d3SLarry Finger RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */ 741f1d2b4d3SLarry Finger RTL_IMR_COMDOK, /*Command Queue DMA OK Interrupt*/ 742f1d2b4d3SLarry Finger RTL_IMR_TBDOK, /*Transmit Beacon OK interrup */ 743f1d2b4d3SLarry Finger RTL_IMR_MGNTDOK, /*Management Queue DMA OK Interrupt */ 744f1d2b4d3SLarry Finger RTL_IMR_TBDER, /*For 92C,Transmit Beacon Error Interrupt */ 745f1d2b4d3SLarry Finger RTL_IMR_BKDOK, /*AC_BK DMA OK Interrupt */ 746f1d2b4d3SLarry Finger RTL_IMR_BEDOK, /*AC_BE DMA OK Interrupt */ 747f1d2b4d3SLarry Finger RTL_IMR_VIDOK, /*AC_VI DMA OK Interrupt */ 748f1d2b4d3SLarry Finger RTL_IMR_VODOK, /*AC_VO DMA Interrupt */ 749f1d2b4d3SLarry Finger RTL_IMR_ROK, /*Receive DMA OK Interrupt */ 750f1d2b4d3SLarry Finger RTL_IMR_HSISR_IND, /*HSISR Interrupt*/ 751f1d2b4d3SLarry Finger RTL_IBSS_INT_MASKS, /*(RTL_IMR_BCNINT | RTL_IMR_TBDOK | 752d3da329cSLarry Finger * RTL_IMR_TBDER) 753d3da329cSLarry Finger */ 754f1d2b4d3SLarry Finger RTL_IMR_C2HCMD, /*fw interrupt*/ 755f1d2b4d3SLarry Finger 756f1d2b4d3SLarry Finger /*CCK Rates, TxHT = 0 */ 757f1d2b4d3SLarry Finger RTL_RC_CCK_RATE1M, 758f1d2b4d3SLarry Finger RTL_RC_CCK_RATE2M, 759f1d2b4d3SLarry Finger RTL_RC_CCK_RATE5_5M, 760f1d2b4d3SLarry Finger RTL_RC_CCK_RATE11M, 761f1d2b4d3SLarry Finger 762f1d2b4d3SLarry Finger /*OFDM Rates, TxHT = 0 */ 763f1d2b4d3SLarry Finger RTL_RC_OFDM_RATE6M, 764f1d2b4d3SLarry Finger RTL_RC_OFDM_RATE9M, 765f1d2b4d3SLarry Finger RTL_RC_OFDM_RATE12M, 766f1d2b4d3SLarry Finger RTL_RC_OFDM_RATE18M, 767f1d2b4d3SLarry Finger RTL_RC_OFDM_RATE24M, 768f1d2b4d3SLarry Finger RTL_RC_OFDM_RATE36M, 769f1d2b4d3SLarry Finger RTL_RC_OFDM_RATE48M, 770f1d2b4d3SLarry Finger RTL_RC_OFDM_RATE54M, 771f1d2b4d3SLarry Finger 772f1d2b4d3SLarry Finger RTL_RC_HT_RATEMCS7, 773f1d2b4d3SLarry Finger RTL_RC_HT_RATEMCS15, 774f1d2b4d3SLarry Finger 775f1d2b4d3SLarry Finger RTL_RC_VHT_RATE_1SS_MCS7, 776f1d2b4d3SLarry Finger RTL_RC_VHT_RATE_1SS_MCS8, 777f1d2b4d3SLarry Finger RTL_RC_VHT_RATE_1SS_MCS9, 778f1d2b4d3SLarry Finger RTL_RC_VHT_RATE_2SS_MCS7, 779f1d2b4d3SLarry Finger RTL_RC_VHT_RATE_2SS_MCS8, 780f1d2b4d3SLarry Finger RTL_RC_VHT_RATE_2SS_MCS9, 781f1d2b4d3SLarry Finger 782f1d2b4d3SLarry Finger /*keep it last */ 783f1d2b4d3SLarry Finger RTL_VAR_MAP_MAX, 784f1d2b4d3SLarry Finger }; 785f1d2b4d3SLarry Finger 786f1d2b4d3SLarry Finger /*Firmware PS mode for control LPS.*/ 787f1d2b4d3SLarry Finger enum _fw_ps_mode { 788f1d2b4d3SLarry Finger FW_PS_ACTIVE_MODE = 0, 789f1d2b4d3SLarry Finger FW_PS_MIN_MODE = 1, 790f1d2b4d3SLarry Finger FW_PS_MAX_MODE = 2, 791f1d2b4d3SLarry Finger FW_PS_DTIM_MODE = 3, 792f1d2b4d3SLarry Finger FW_PS_VOIP_MODE = 4, 793f1d2b4d3SLarry Finger FW_PS_UAPSD_WMM_MODE = 5, 794f1d2b4d3SLarry Finger FW_PS_UAPSD_MODE = 6, 795f1d2b4d3SLarry Finger FW_PS_IBSS_MODE = 7, 796f1d2b4d3SLarry Finger FW_PS_WWLAN_MODE = 8, 797e703c5ddSLarry Finger FW_PS_PM_RADIO_OFF = 9, 798e703c5ddSLarry Finger FW_PS_PM_CARD_DISABLE = 10, 799f1d2b4d3SLarry Finger }; 800f1d2b4d3SLarry Finger 801f1d2b4d3SLarry Finger enum rt_psmode { 802f1d2b4d3SLarry Finger EACTIVE, /*Active/Continuous access. */ 803f1d2b4d3SLarry Finger EMAXPS, /*Max power save mode. */ 804f1d2b4d3SLarry Finger EFASTPS, /*Fast power save mode. */ 805f1d2b4d3SLarry Finger EAUTOPS, /*Auto power save mode. */ 806f1d2b4d3SLarry Finger }; 807f1d2b4d3SLarry Finger 808f1d2b4d3SLarry Finger /*LED related.*/ 809f1d2b4d3SLarry Finger enum led_ctl_mode { 810f1d2b4d3SLarry Finger LED_CTL_POWER_ON = 1, 811f1d2b4d3SLarry Finger LED_CTL_LINK = 2, 812f1d2b4d3SLarry Finger LED_CTL_NO_LINK = 3, 813f1d2b4d3SLarry Finger LED_CTL_TX = 4, 814f1d2b4d3SLarry Finger LED_CTL_RX = 5, 815f1d2b4d3SLarry Finger LED_CTL_SITE_SURVEY = 6, 816f1d2b4d3SLarry Finger LED_CTL_POWER_OFF = 7, 817f1d2b4d3SLarry Finger LED_CTL_START_TO_LINK = 8, 818f1d2b4d3SLarry Finger LED_CTL_START_WPS = 9, 819f1d2b4d3SLarry Finger LED_CTL_STOP_WPS = 10, 820f1d2b4d3SLarry Finger }; 821f1d2b4d3SLarry Finger 822f1d2b4d3SLarry Finger enum rtl_led_pin { 823f1d2b4d3SLarry Finger LED_PIN_GPIO0, 824f1d2b4d3SLarry Finger LED_PIN_LED0, 825f1d2b4d3SLarry Finger LED_PIN_LED1, 826f1d2b4d3SLarry Finger LED_PIN_LED2 827f1d2b4d3SLarry Finger }; 828f1d2b4d3SLarry Finger 829f1d2b4d3SLarry Finger /*QoS related.*/ 830f1d2b4d3SLarry Finger /*acm implementation method.*/ 831f1d2b4d3SLarry Finger enum acm_method { 832e703c5ddSLarry Finger EACMWAY0_SWANDHW = 0, 833e703c5ddSLarry Finger EACMWAY1_HW = 1, 834f1d2b4d3SLarry Finger EACMWAY2_SW = 2, 835f1d2b4d3SLarry Finger }; 836f1d2b4d3SLarry Finger 837f1d2b4d3SLarry Finger enum macphy_mode { 838f1d2b4d3SLarry Finger SINGLEMAC_SINGLEPHY = 0, 839f1d2b4d3SLarry Finger DUALMAC_DUALPHY, 840f1d2b4d3SLarry Finger DUALMAC_SINGLEPHY, 841f1d2b4d3SLarry Finger }; 842f1d2b4d3SLarry Finger 843f1d2b4d3SLarry Finger enum band_type { 844f1d2b4d3SLarry Finger BAND_ON_2_4G = 0, 845f1d2b4d3SLarry Finger BAND_ON_5G, 846f1d2b4d3SLarry Finger BAND_ON_BOTH, 847f1d2b4d3SLarry Finger BANDMAX 848f1d2b4d3SLarry Finger }; 849f1d2b4d3SLarry Finger 850f1d2b4d3SLarry Finger /* aci/aifsn Field. 851d3da329cSLarry Finger * Ref: WMM spec 2.2.2: WME Parameter Element, p.12. 852d3da329cSLarry Finger */ 853f1d2b4d3SLarry Finger union aci_aifsn { 854f1d2b4d3SLarry Finger u8 char_data; 855f1d2b4d3SLarry Finger 856f1d2b4d3SLarry Finger struct { 857f1d2b4d3SLarry Finger u8 aifsn:4; 858f1d2b4d3SLarry Finger u8 acm:1; 859f1d2b4d3SLarry Finger u8 aci:2; 860f1d2b4d3SLarry Finger u8 reserved:1; 861f1d2b4d3SLarry Finger } f; /* Field */ 862f1d2b4d3SLarry Finger }; 863f1d2b4d3SLarry Finger 864f1d2b4d3SLarry Finger /*mlme related.*/ 865f1d2b4d3SLarry Finger enum wireless_mode { 866f1d2b4d3SLarry Finger WIRELESS_MODE_UNKNOWN = 0x00, 867f1d2b4d3SLarry Finger WIRELESS_MODE_A = 0x01, 868f1d2b4d3SLarry Finger WIRELESS_MODE_B = 0x02, 869f1d2b4d3SLarry Finger WIRELESS_MODE_G = 0x04, 870f1d2b4d3SLarry Finger WIRELESS_MODE_AUTO = 0x08, 871f1d2b4d3SLarry Finger WIRELESS_MODE_N_24G = 0x10, 872f1d2b4d3SLarry Finger WIRELESS_MODE_N_5G = 0x20, 873f1d2b4d3SLarry Finger WIRELESS_MODE_AC_5G = 0x40, 874f1d2b4d3SLarry Finger WIRELESS_MODE_AC_24G = 0x80, 875f1d2b4d3SLarry Finger WIRELESS_MODE_AC_ONLY = 0x100, 876f1d2b4d3SLarry Finger WIRELESS_MODE_MAX = 0x800 877f1d2b4d3SLarry Finger }; 878f1d2b4d3SLarry Finger 879f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_A(wirelessmode) \ 880f1d2b4d3SLarry Finger (wirelessmode == WIRELESS_MODE_A) 881f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_B(wirelessmode) \ 882f1d2b4d3SLarry Finger (wirelessmode == WIRELESS_MODE_B) 883f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_G(wirelessmode) \ 884f1d2b4d3SLarry Finger (wirelessmode == WIRELESS_MODE_G) 885f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_N_24G(wirelessmode) \ 886f1d2b4d3SLarry Finger (wirelessmode == WIRELESS_MODE_N_24G) 887f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_N_5G(wirelessmode) \ 888f1d2b4d3SLarry Finger (wirelessmode == WIRELESS_MODE_N_5G) 889f1d2b4d3SLarry Finger 890f1d2b4d3SLarry Finger enum ratr_table_mode { 891f1d2b4d3SLarry Finger RATR_INX_WIRELESS_NGB = 0, 892f1d2b4d3SLarry Finger RATR_INX_WIRELESS_NG = 1, 893f1d2b4d3SLarry Finger RATR_INX_WIRELESS_NB = 2, 894f1d2b4d3SLarry Finger RATR_INX_WIRELESS_N = 3, 895f1d2b4d3SLarry Finger RATR_INX_WIRELESS_GB = 4, 896f1d2b4d3SLarry Finger RATR_INX_WIRELESS_G = 5, 897f1d2b4d3SLarry Finger RATR_INX_WIRELESS_B = 6, 898f1d2b4d3SLarry Finger RATR_INX_WIRELESS_MC = 7, 899f1d2b4d3SLarry Finger RATR_INX_WIRELESS_A = 8, 900f1d2b4d3SLarry Finger RATR_INX_WIRELESS_AC_5N = 8, 901f1d2b4d3SLarry Finger RATR_INX_WIRELESS_AC_24N = 9, 902f1d2b4d3SLarry Finger }; 903f1d2b4d3SLarry Finger 904be98db15SPing-Ke Shih enum ratr_table_mode_new { 905be98db15SPing-Ke Shih RATEID_IDX_BGN_40M_2SS = 0, 906be98db15SPing-Ke Shih RATEID_IDX_BGN_40M_1SS = 1, 907be98db15SPing-Ke Shih RATEID_IDX_BGN_20M_2SS_BN = 2, 908be98db15SPing-Ke Shih RATEID_IDX_BGN_20M_1SS_BN = 3, 909be98db15SPing-Ke Shih RATEID_IDX_GN_N2SS = 4, 910be98db15SPing-Ke Shih RATEID_IDX_GN_N1SS = 5, 911be98db15SPing-Ke Shih RATEID_IDX_BG = 6, 912be98db15SPing-Ke Shih RATEID_IDX_G = 7, 913be98db15SPing-Ke Shih RATEID_IDX_B = 8, 914be98db15SPing-Ke Shih RATEID_IDX_VHT_2SS = 9, 915be98db15SPing-Ke Shih RATEID_IDX_VHT_1SS = 10, 916be98db15SPing-Ke Shih RATEID_IDX_MIX1 = 11, 917be98db15SPing-Ke Shih RATEID_IDX_MIX2 = 12, 918be98db15SPing-Ke Shih RATEID_IDX_VHT_3SS = 13, 919be98db15SPing-Ke Shih RATEID_IDX_BGN_3SS = 14, 920be98db15SPing-Ke Shih }; 921be98db15SPing-Ke Shih 922f1d2b4d3SLarry Finger enum rtl_link_state { 923f1d2b4d3SLarry Finger MAC80211_NOLINK = 0, 924f1d2b4d3SLarry Finger MAC80211_LINKING = 1, 925f1d2b4d3SLarry Finger MAC80211_LINKED = 2, 926f1d2b4d3SLarry Finger MAC80211_LINKED_SCANNING = 3, 927f1d2b4d3SLarry Finger }; 928f1d2b4d3SLarry Finger 929f1d2b4d3SLarry Finger enum act_category { 930f1d2b4d3SLarry Finger ACT_CAT_QOS = 1, 931f1d2b4d3SLarry Finger ACT_CAT_DLS = 2, 932f1d2b4d3SLarry Finger ACT_CAT_BA = 3, 933f1d2b4d3SLarry Finger ACT_CAT_HT = 7, 934f1d2b4d3SLarry Finger ACT_CAT_WMM = 17, 935f1d2b4d3SLarry Finger }; 936f1d2b4d3SLarry Finger 937f1d2b4d3SLarry Finger enum ba_action { 938f1d2b4d3SLarry Finger ACT_ADDBAREQ = 0, 939f1d2b4d3SLarry Finger ACT_ADDBARSP = 1, 940f1d2b4d3SLarry Finger ACT_DELBA = 2, 941f1d2b4d3SLarry Finger }; 942f1d2b4d3SLarry Finger 943f1d2b4d3SLarry Finger enum rt_polarity_ctl { 944f1d2b4d3SLarry Finger RT_POLARITY_LOW_ACT = 0, 945f1d2b4d3SLarry Finger RT_POLARITY_HIGH_ACT = 1, 946f1d2b4d3SLarry Finger }; 947f1d2b4d3SLarry Finger 948f1d2b4d3SLarry Finger /* After 8188E, we use V2 reason define. 88C/8723A use V1 reason. */ 949f1d2b4d3SLarry Finger enum fw_wow_reason_v2 { 950f1d2b4d3SLarry Finger FW_WOW_V2_PTK_UPDATE_EVENT = 0x01, 951f1d2b4d3SLarry Finger FW_WOW_V2_GTK_UPDATE_EVENT = 0x02, 952f1d2b4d3SLarry Finger FW_WOW_V2_DISASSOC_EVENT = 0x04, 953f1d2b4d3SLarry Finger FW_WOW_V2_DEAUTH_EVENT = 0x08, 954f1d2b4d3SLarry Finger FW_WOW_V2_FW_DISCONNECT_EVENT = 0x10, 955f1d2b4d3SLarry Finger FW_WOW_V2_MAGIC_PKT_EVENT = 0x21, 956f1d2b4d3SLarry Finger FW_WOW_V2_UNICAST_PKT_EVENT = 0x22, 957f1d2b4d3SLarry Finger FW_WOW_V2_PATTERN_PKT_EVENT = 0x23, 958f1d2b4d3SLarry Finger FW_WOW_V2_RTD3_SSID_MATCH_EVENT = 0x24, 959f1d2b4d3SLarry Finger FW_WOW_V2_REALWOW_V2_WAKEUPPKT = 0x30, 960f1d2b4d3SLarry Finger FW_WOW_V2_REALWOW_V2_ACKLOST = 0x31, 961f1d2b4d3SLarry Finger FW_WOW_V2_REASON_MAX = 0xff, 962f1d2b4d3SLarry Finger }; 963f1d2b4d3SLarry Finger 964f1d2b4d3SLarry Finger enum wolpattern_type { 965f1d2b4d3SLarry Finger UNICAST_PATTERN = 0, 966f1d2b4d3SLarry Finger MULTICAST_PATTERN = 1, 967f1d2b4d3SLarry Finger BROADCAST_PATTERN = 2, 968f1d2b4d3SLarry Finger DONT_CARE_DA = 3, 969f1d2b4d3SLarry Finger UNKNOWN_TYPE = 4, 970f1d2b4d3SLarry Finger }; 971f1d2b4d3SLarry Finger 9727fe1fe75SPing-Ke Shih enum package_type { 9737fe1fe75SPing-Ke Shih PACKAGE_DEFAULT, 9747fe1fe75SPing-Ke Shih PACKAGE_QFN68, 9757fe1fe75SPing-Ke Shih PACKAGE_TFBGA90, 9767fe1fe75SPing-Ke Shih PACKAGE_TFBGA80, 9777fe1fe75SPing-Ke Shih PACKAGE_TFBGA79 9787fe1fe75SPing-Ke Shih }; 9797fe1fe75SPing-Ke Shih 980a75f3eebSPing-Ke Shih enum rtl_spec_ver { 981a75f3eebSPing-Ke Shih RTL_SPEC_NEW_RATEID = BIT(0), /* use ratr_table_mode_new */ 9821ca72c30SPing-Ke Shih RTL_SPEC_SUPPORT_VHT = BIT(1), /* support VHT */ 9835f380cefSPing-Ke Shih RTL_SPEC_EXT_C2H = BIT(2), /* extend FW C2H (e.g. TX REPORT) */ 984a75f3eebSPing-Ke Shih }; 985a75f3eebSPing-Ke Shih 9865ffd1155SPing-Ke Shih enum dm_info_query { 9875ffd1155SPing-Ke Shih DM_INFO_FA_OFDM, 9885ffd1155SPing-Ke Shih DM_INFO_FA_CCK, 9895ffd1155SPing-Ke Shih DM_INFO_FA_TOTAL, 9905ffd1155SPing-Ke Shih DM_INFO_CCA_OFDM, 9915ffd1155SPing-Ke Shih DM_INFO_CCA_CCK, 9925ffd1155SPing-Ke Shih DM_INFO_CCA_ALL, 9935ffd1155SPing-Ke Shih DM_INFO_CRC32_OK_VHT, 9945ffd1155SPing-Ke Shih DM_INFO_CRC32_OK_HT, 9955ffd1155SPing-Ke Shih DM_INFO_CRC32_OK_LEGACY, 9965ffd1155SPing-Ke Shih DM_INFO_CRC32_OK_CCK, 9975ffd1155SPing-Ke Shih DM_INFO_CRC32_ERROR_VHT, 9985ffd1155SPing-Ke Shih DM_INFO_CRC32_ERROR_HT, 9995ffd1155SPing-Ke Shih DM_INFO_CRC32_ERROR_LEGACY, 10005ffd1155SPing-Ke Shih DM_INFO_CRC32_ERROR_CCK, 10015ffd1155SPing-Ke Shih DM_INFO_EDCCA_FLAG, 10025ffd1155SPing-Ke Shih DM_INFO_OFDM_ENABLE, 10035ffd1155SPing-Ke Shih DM_INFO_CCK_ENABLE, 10045ffd1155SPing-Ke Shih DM_INFO_CRC32_OK_HT_AGG, 10055ffd1155SPing-Ke Shih DM_INFO_CRC32_ERROR_HT_AGG, 10065ffd1155SPing-Ke Shih DM_INFO_DBG_PORT_0, 10075ffd1155SPing-Ke Shih DM_INFO_CURR_IGI, 10085ffd1155SPing-Ke Shih DM_INFO_RSSI_MIN, 10095ffd1155SPing-Ke Shih DM_INFO_RSSI_MAX, 10105ffd1155SPing-Ke Shih DM_INFO_CLM_RATIO, 10115ffd1155SPing-Ke Shih DM_INFO_NHM_RATIO, 10125ffd1155SPing-Ke Shih DM_INFO_IQK_ALL, 10135ffd1155SPing-Ke Shih DM_INFO_IQK_OK, 10145ffd1155SPing-Ke Shih DM_INFO_IQK_NG, 10155ffd1155SPing-Ke Shih DM_INFO_SIZE, 10165ffd1155SPing-Ke Shih }; 10175ffd1155SPing-Ke Shih 1018c4528686SPing-Ke Shih enum rx_packet_type { 1019c4528686SPing-Ke Shih NORMAL_RX, 1020c4528686SPing-Ke Shih TX_REPORT1, 1021c4528686SPing-Ke Shih TX_REPORT2, 1022c4528686SPing-Ke Shih HIS_REPORT, 1023c4528686SPing-Ke Shih C2H_PACKET, 1024c4528686SPing-Ke Shih }; 1025c4528686SPing-Ke Shih 10266acfbb81STzu-En Huang struct rtlwifi_tx_info { 10276acfbb81STzu-En Huang int sn; 10286acfbb81STzu-En Huang unsigned long send_time; 10296acfbb81STzu-En Huang }; 10306acfbb81STzu-En Huang 10316acfbb81STzu-En Huang static inline struct rtlwifi_tx_info *rtl_tx_skb_cb_info(struct sk_buff *skb) 10326acfbb81STzu-En Huang { 10336acfbb81STzu-En Huang struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 10346acfbb81STzu-En Huang 10356acfbb81STzu-En Huang BUILD_BUG_ON(sizeof(struct rtlwifi_tx_info) > 10366acfbb81STzu-En Huang sizeof(info->status.status_driver_data)); 10376acfbb81STzu-En Huang 10386acfbb81STzu-En Huang return (struct rtlwifi_tx_info *)(info->status.status_driver_data); 10396acfbb81STzu-En Huang } 10406acfbb81STzu-En Huang 1041f1d2b4d3SLarry Finger struct octet_string { 1042f1d2b4d3SLarry Finger u8 *octet; 1043f1d2b4d3SLarry Finger u16 length; 1044f1d2b4d3SLarry Finger }; 1045f1d2b4d3SLarry Finger 1046f1d2b4d3SLarry Finger struct rtl_hdr_3addr { 1047f1d2b4d3SLarry Finger __le16 frame_ctl; 1048f1d2b4d3SLarry Finger __le16 duration_id; 1049f1d2b4d3SLarry Finger u8 addr1[ETH_ALEN]; 1050f1d2b4d3SLarry Finger u8 addr2[ETH_ALEN]; 1051f1d2b4d3SLarry Finger u8 addr3[ETH_ALEN]; 1052f1d2b4d3SLarry Finger __le16 seq_ctl; 1053a1b7714bSGustavo A. R. Silva u8 payload[]; 1054f1d2b4d3SLarry Finger } __packed; 1055f1d2b4d3SLarry Finger 1056f1d2b4d3SLarry Finger struct rtl_info_element { 1057f1d2b4d3SLarry Finger u8 id; 1058f1d2b4d3SLarry Finger u8 len; 1059a1b7714bSGustavo A. R. Silva u8 data[]; 1060f1d2b4d3SLarry Finger } __packed; 1061f1d2b4d3SLarry Finger 1062f1d2b4d3SLarry Finger struct rtl_probe_rsp { 1063f1d2b4d3SLarry Finger struct rtl_hdr_3addr header; 1064f1d2b4d3SLarry Finger u32 time_stamp[2]; 1065f1d2b4d3SLarry Finger __le16 beacon_interval; 1066f1d2b4d3SLarry Finger __le16 capability; 1067f1d2b4d3SLarry Finger /*SSID, supported rates, FH params, DS params, 1068d3da329cSLarry Finger * CF params, IBSS params, TIM (if beacon), RSN 1069d3da329cSLarry Finger */ 1070a1b7714bSGustavo A. R. Silva struct rtl_info_element info_element[]; 1071f1d2b4d3SLarry Finger } __packed; 1072f1d2b4d3SLarry Finger 1073f1d2b4d3SLarry Finger struct rtl_led_ctl { 1074f1d2b4d3SLarry Finger bool led_opendrain; 1075084f1f55SDmitry Antipov enum rtl_led_pin sw_led0; 1076084f1f55SDmitry Antipov enum rtl_led_pin sw_led1; 1077f1d2b4d3SLarry Finger }; 1078f1d2b4d3SLarry Finger 1079f1d2b4d3SLarry Finger struct rtl_qos_parameters { 1080f1d2b4d3SLarry Finger __le16 cw_min; 1081f1d2b4d3SLarry Finger __le16 cw_max; 1082f1d2b4d3SLarry Finger u8 aifs; 1083f1d2b4d3SLarry Finger u8 flag; 1084f1d2b4d3SLarry Finger __le16 tx_op; 1085f1d2b4d3SLarry Finger } __packed; 1086f1d2b4d3SLarry Finger 1087f1d2b4d3SLarry Finger struct rt_smooth_data { 1088f1d2b4d3SLarry Finger u32 elements[100]; /*array to store values */ 1089f1d2b4d3SLarry Finger u32 index; /*index to current array to store */ 1090f1d2b4d3SLarry Finger u32 total_num; /*num of valid elements */ 1091f1d2b4d3SLarry Finger u32 total_val; /*sum of valid elements */ 1092f1d2b4d3SLarry Finger }; 1093f1d2b4d3SLarry Finger 1094f1d2b4d3SLarry Finger struct false_alarm_statistics { 1095f1d2b4d3SLarry Finger u32 cnt_parity_fail; 1096f1d2b4d3SLarry Finger u32 cnt_rate_illegal; 1097f1d2b4d3SLarry Finger u32 cnt_crc8_fail; 1098f1d2b4d3SLarry Finger u32 cnt_mcs_fail; 1099f1d2b4d3SLarry Finger u32 cnt_fast_fsync_fail; 1100f1d2b4d3SLarry Finger u32 cnt_sb_search_fail; 1101f1d2b4d3SLarry Finger u32 cnt_ofdm_fail; 1102f1d2b4d3SLarry Finger u32 cnt_cck_fail; 1103f1d2b4d3SLarry Finger u32 cnt_all; 1104f1d2b4d3SLarry Finger u32 cnt_ofdm_cca; 1105f1d2b4d3SLarry Finger u32 cnt_cck_cca; 1106f1d2b4d3SLarry Finger u32 cnt_cca_all; 1107f1d2b4d3SLarry Finger u32 cnt_bw_usc; 1108f1d2b4d3SLarry Finger u32 cnt_bw_lsc; 1109f1d2b4d3SLarry Finger }; 1110f1d2b4d3SLarry Finger 1111f1d2b4d3SLarry Finger struct init_gain { 1112f1d2b4d3SLarry Finger u8 xaagccore1; 1113f1d2b4d3SLarry Finger u8 xbagccore1; 1114f1d2b4d3SLarry Finger u8 xcagccore1; 1115f1d2b4d3SLarry Finger u8 xdagccore1; 1116f1d2b4d3SLarry Finger u8 cca; 1117f1d2b4d3SLarry Finger 1118f1d2b4d3SLarry Finger }; 1119f1d2b4d3SLarry Finger 1120f1d2b4d3SLarry Finger struct wireless_stats { 112174451b93SPing-Ke Shih u64 txbytesunicast; 112274451b93SPing-Ke Shih u64 txbytesmulticast; 112374451b93SPing-Ke Shih u64 txbytesbroadcast; 112474451b93SPing-Ke Shih u64 rxbytesunicast; 112574451b93SPing-Ke Shih 112674451b93SPing-Ke Shih u64 txbytesunicast_inperiod; 112774451b93SPing-Ke Shih u64 rxbytesunicast_inperiod; 112874451b93SPing-Ke Shih u32 txbytesunicast_inperiod_tp; 112974451b93SPing-Ke Shih u32 rxbytesunicast_inperiod_tp; 113074451b93SPing-Ke Shih u64 txbytesunicast_last; 113174451b93SPing-Ke Shih u64 rxbytesunicast_last; 1132f1d2b4d3SLarry Finger 1133f1d2b4d3SLarry Finger long rx_snr_db[4]; 1134f1d2b4d3SLarry Finger /*Correct smoothed ss in Dbm, only used 1135d3da329cSLarry Finger * in driver to report real power now. 1136d3da329cSLarry Finger */ 1137f1d2b4d3SLarry Finger long recv_signal_power; 1138f1d2b4d3SLarry Finger long signal_quality; 1139f1d2b4d3SLarry Finger long last_sigstrength_inpercent; 1140f1d2b4d3SLarry Finger 1141f1d2b4d3SLarry Finger u32 rssi_calculate_cnt; 1142f1d2b4d3SLarry Finger u32 pwdb_all_cnt; 1143f1d2b4d3SLarry Finger 1144f1d2b4d3SLarry Finger /* Transformed, in dbm. Beautified signal 1145d3da329cSLarry Finger * strength for UI, not correct. 1146d3da329cSLarry Finger */ 1147f1d2b4d3SLarry Finger long signal_strength; 1148f1d2b4d3SLarry Finger 1149f1d2b4d3SLarry Finger u8 rx_rssi_percentage[4]; 1150f1d2b4d3SLarry Finger u8 rx_evm_dbm[4]; 1151f1d2b4d3SLarry Finger u8 rx_evm_percentage[2]; 1152f1d2b4d3SLarry Finger 1153f1d2b4d3SLarry Finger u16 rx_cfo_short[4]; 1154f1d2b4d3SLarry Finger u16 rx_cfo_tail[4]; 1155f1d2b4d3SLarry Finger 1156f1d2b4d3SLarry Finger struct rt_smooth_data ui_rssi; 1157f1d2b4d3SLarry Finger struct rt_smooth_data ui_link_quality; 1158f1d2b4d3SLarry Finger }; 1159f1d2b4d3SLarry Finger 1160f1d2b4d3SLarry Finger struct rate_adaptive { 1161f1d2b4d3SLarry Finger u8 rate_adaptive_disabled; 1162f1d2b4d3SLarry Finger u8 ratr_state; 1163f1d2b4d3SLarry Finger u16 reserve; 1164f1d2b4d3SLarry Finger 1165f1d2b4d3SLarry Finger u32 high_rssi_thresh_for_ra; 1166f1d2b4d3SLarry Finger u32 high2low_rssi_thresh_for_ra; 1167f1d2b4d3SLarry Finger u8 low2high_rssi_thresh_for_ra40m; 1168f1d2b4d3SLarry Finger u32 low_rssi_thresh_for_ra40m; 1169f1d2b4d3SLarry Finger u8 low2high_rssi_thresh_for_ra20m; 1170f1d2b4d3SLarry Finger u32 low_rssi_thresh_for_ra20m; 1171f1d2b4d3SLarry Finger u32 upper_rssi_threshold_ratr; 1172f1d2b4d3SLarry Finger u32 middleupper_rssi_threshold_ratr; 1173f1d2b4d3SLarry Finger u32 middle_rssi_threshold_ratr; 1174f1d2b4d3SLarry Finger u32 middlelow_rssi_threshold_ratr; 1175f1d2b4d3SLarry Finger u32 low_rssi_threshold_ratr; 1176f1d2b4d3SLarry Finger u32 ultralow_rssi_threshold_ratr; 1177f1d2b4d3SLarry Finger u32 low_rssi_threshold_ratr_40m; 1178f1d2b4d3SLarry Finger u32 low_rssi_threshold_ratr_20m; 1179f1d2b4d3SLarry Finger u8 ping_rssi_enable; 1180f1d2b4d3SLarry Finger u32 ping_rssi_ratr; 1181f1d2b4d3SLarry Finger u32 ping_rssi_thresh_for_ra; 1182f1d2b4d3SLarry Finger u32 last_ratr; 1183f1d2b4d3SLarry Finger u8 pre_ratr_state; 1184f1d2b4d3SLarry Finger u8 ldpc_thres; 1185f1d2b4d3SLarry Finger bool use_ldpc; 1186f1d2b4d3SLarry Finger bool lower_rts_rate; 1187f1d2b4d3SLarry Finger bool is_special_data; 1188f1d2b4d3SLarry Finger }; 1189f1d2b4d3SLarry Finger 1190f1d2b4d3SLarry Finger struct regd_pair_mapping { 1191f1d2b4d3SLarry Finger u16 reg_dmnenum; 1192f1d2b4d3SLarry Finger u16 reg_5ghz_ctl; 1193f1d2b4d3SLarry Finger u16 reg_2ghz_ctl; 1194f1d2b4d3SLarry Finger }; 1195f1d2b4d3SLarry Finger 1196f1d2b4d3SLarry Finger struct dynamic_primary_cca { 1197f1d2b4d3SLarry Finger u8 pricca_flag; 1198f1d2b4d3SLarry Finger u8 intf_flag; 1199f1d2b4d3SLarry Finger u8 intf_type; 1200f1d2b4d3SLarry Finger u8 dup_rts_flag; 1201f1d2b4d3SLarry Finger u8 monitor_flag; 1202f1d2b4d3SLarry Finger u8 ch_offset; 1203f1d2b4d3SLarry Finger u8 mf_state; 1204f1d2b4d3SLarry Finger }; 1205f1d2b4d3SLarry Finger 1206f1d2b4d3SLarry Finger struct rtl_regulatory { 120708aba42fSArnd Bergmann s8 alpha2[2]; 1208f1d2b4d3SLarry Finger u16 country_code; 1209f1d2b4d3SLarry Finger u16 max_power_level; 1210f1d2b4d3SLarry Finger u32 tp_scale; 1211f1d2b4d3SLarry Finger u16 current_rd; 1212f1d2b4d3SLarry Finger u16 current_rd_ext; 1213f1d2b4d3SLarry Finger int16_t power_limit; 1214f1d2b4d3SLarry Finger struct regd_pair_mapping *regpair; 1215f1d2b4d3SLarry Finger }; 1216f1d2b4d3SLarry Finger 1217f1d2b4d3SLarry Finger struct rtl_rfkill { 1218f1d2b4d3SLarry Finger bool rfkill_state; /*0 is off, 1 is on */ 1219f1d2b4d3SLarry Finger }; 1220f1d2b4d3SLarry Finger 1221f1d2b4d3SLarry Finger /*for P2P PS**/ 1222f1d2b4d3SLarry Finger #define P2P_MAX_NOA_NUM 2 1223f1d2b4d3SLarry Finger 1224f1d2b4d3SLarry Finger enum p2p_role { 1225f1d2b4d3SLarry Finger P2P_ROLE_DISABLE = 0, 1226f1d2b4d3SLarry Finger P2P_ROLE_DEVICE = 1, 1227f1d2b4d3SLarry Finger P2P_ROLE_CLIENT = 2, 1228f1d2b4d3SLarry Finger P2P_ROLE_GO = 3 1229f1d2b4d3SLarry Finger }; 1230f1d2b4d3SLarry Finger 1231f1d2b4d3SLarry Finger enum p2p_ps_state { 1232f1d2b4d3SLarry Finger P2P_PS_DISABLE = 0, 1233f1d2b4d3SLarry Finger P2P_PS_ENABLE = 1, 1234f1d2b4d3SLarry Finger P2P_PS_SCAN = 2, 1235f1d2b4d3SLarry Finger P2P_PS_SCAN_DONE = 3, 1236f1d2b4d3SLarry Finger P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */ 1237f1d2b4d3SLarry Finger }; 1238f1d2b4d3SLarry Finger 1239f1d2b4d3SLarry Finger enum p2p_ps_mode { 1240f1d2b4d3SLarry Finger P2P_PS_NONE = 0, 1241f1d2b4d3SLarry Finger P2P_PS_CTWINDOW = 1, 1242f1d2b4d3SLarry Finger P2P_PS_NOA = 2, 1243f1d2b4d3SLarry Finger P2P_PS_MIX = 3, /* CTWindow and NoA */ 1244f1d2b4d3SLarry Finger }; 1245f1d2b4d3SLarry Finger 1246f1d2b4d3SLarry Finger struct rtl_p2p_ps_info { 1247f1d2b4d3SLarry Finger enum p2p_ps_mode p2p_ps_mode; /* indicate p2p ps mode */ 1248f1d2b4d3SLarry Finger enum p2p_ps_state p2p_ps_state; /* indicate p2p ps state */ 1249f1d2b4d3SLarry Finger u8 noa_index; /* Identifies instance of Notice of Absence timing. */ 1250f1d2b4d3SLarry Finger /* Client traffic window. A period of time in TU after TBTT. */ 1251f1d2b4d3SLarry Finger u8 ctwindow; 1252f1d2b4d3SLarry Finger u8 opp_ps; /* opportunistic power save. */ 1253f1d2b4d3SLarry Finger u8 noa_num; /* number of NoA descriptor in P2P IE. */ 1254f1d2b4d3SLarry Finger /* Count for owner, Type of client. */ 1255f1d2b4d3SLarry Finger u8 noa_count_type[P2P_MAX_NOA_NUM]; 1256f1d2b4d3SLarry Finger /* Max duration for owner, preferred or min acceptable duration 1257f1d2b4d3SLarry Finger * for client. 1258f1d2b4d3SLarry Finger */ 1259f1d2b4d3SLarry Finger u32 noa_duration[P2P_MAX_NOA_NUM]; 1260f1d2b4d3SLarry Finger /* Length of interval for owner, preferred or max acceptable intervali 1261f1d2b4d3SLarry Finger * of client. 1262f1d2b4d3SLarry Finger */ 1263f1d2b4d3SLarry Finger u32 noa_interval[P2P_MAX_NOA_NUM]; 1264f1d2b4d3SLarry Finger /* schedule in terms of the lower 4 bytes of the TSF timer. */ 1265f1d2b4d3SLarry Finger u32 noa_start_time[P2P_MAX_NOA_NUM]; 1266f1d2b4d3SLarry Finger }; 1267f1d2b4d3SLarry Finger 1268f1d2b4d3SLarry Finger struct p2p_ps_offload_t { 1269f1d2b4d3SLarry Finger u8 offload_en:1; 1270f1d2b4d3SLarry Finger u8 role:1; /* 1: Owner, 0: Client */ 1271f1d2b4d3SLarry Finger u8 ctwindow_en:1; 1272f1d2b4d3SLarry Finger u8 noa0_en:1; 1273f1d2b4d3SLarry Finger u8 noa1_en:1; 1274f1d2b4d3SLarry Finger u8 allstasleep:1; 1275f1d2b4d3SLarry Finger u8 discovery:1; 1276f1d2b4d3SLarry Finger u8 reserved:1; 1277f1d2b4d3SLarry Finger }; 1278f1d2b4d3SLarry Finger 1279f1d2b4d3SLarry Finger #define IQK_MATRIX_REG_NUM 8 1280f1d2b4d3SLarry Finger #define IQK_MATRIX_SETTINGS_NUM (1 + 24 + 21) 1281f1d2b4d3SLarry Finger 1282f1d2b4d3SLarry Finger struct iqk_matrix_regs { 1283f1d2b4d3SLarry Finger bool iqk_done; 1284f1d2b4d3SLarry Finger long value[1][IQK_MATRIX_REG_NUM]; 1285f1d2b4d3SLarry Finger }; 1286f1d2b4d3SLarry Finger 1287f1d2b4d3SLarry Finger struct phy_parameters { 1288f1d2b4d3SLarry Finger u16 length; 1289f1d2b4d3SLarry Finger u32 *pdata; 1290f1d2b4d3SLarry Finger }; 1291f1d2b4d3SLarry Finger 1292f1d2b4d3SLarry Finger enum hw_param_tab_index { 1293f1d2b4d3SLarry Finger PHY_REG_2T, 1294f1d2b4d3SLarry Finger PHY_REG_1T, 1295f1d2b4d3SLarry Finger PHY_REG_PG, 1296f1d2b4d3SLarry Finger RADIOA_2T, 1297f1d2b4d3SLarry Finger RADIOB_2T, 1298f1d2b4d3SLarry Finger RADIOA_1T, 1299f1d2b4d3SLarry Finger RADIOB_1T, 1300f1d2b4d3SLarry Finger MAC_REG, 1301f1d2b4d3SLarry Finger AGCTAB_2T, 1302f1d2b4d3SLarry Finger AGCTAB_1T, 1303f1d2b4d3SLarry Finger MAX_TAB 1304f1d2b4d3SLarry Finger }; 1305f1d2b4d3SLarry Finger 1306f1d2b4d3SLarry Finger struct rtl_phy { 1307f1d2b4d3SLarry Finger struct bb_reg_def phyreg_def[4]; /*Radio A/B/C/D */ 1308f1d2b4d3SLarry Finger struct init_gain initgain_backup; 1309f1d2b4d3SLarry Finger enum io_type current_io_type; 1310f1d2b4d3SLarry Finger 1311f1d2b4d3SLarry Finger u8 rf_mode; 1312f1d2b4d3SLarry Finger u8 rf_type; 1313f1d2b4d3SLarry Finger u8 current_chan_bw; 1314f1d2b4d3SLarry Finger u8 set_bwmode_inprogress; 1315f1d2b4d3SLarry Finger u8 sw_chnl_inprogress; 1316f1d2b4d3SLarry Finger u8 sw_chnl_stage; 1317f1d2b4d3SLarry Finger u8 sw_chnl_step; 1318f1d2b4d3SLarry Finger u8 current_channel; 1319f1d2b4d3SLarry Finger u8 h2c_box_num; 1320f1d2b4d3SLarry Finger u8 set_io_inprogress; 1321f1d2b4d3SLarry Finger u8 lck_inprogress; 1322f1d2b4d3SLarry Finger 1323f1d2b4d3SLarry Finger /* record for power tracking */ 1324f1d2b4d3SLarry Finger s32 reg_e94; 1325f1d2b4d3SLarry Finger s32 reg_e9c; 1326f1d2b4d3SLarry Finger s32 reg_ea4; 1327f1d2b4d3SLarry Finger s32 reg_eac; 1328f1d2b4d3SLarry Finger s32 reg_eb4; 1329f1d2b4d3SLarry Finger s32 reg_ebc; 1330f1d2b4d3SLarry Finger s32 reg_ec4; 1331f1d2b4d3SLarry Finger s32 reg_ecc; 1332f1d2b4d3SLarry Finger u8 rfpienable; 1333f1d2b4d3SLarry Finger u8 reserve_0; 1334f1d2b4d3SLarry Finger u16 reserve_1; 1335f1d2b4d3SLarry Finger u32 reg_c04, reg_c08, reg_874; 1336f1d2b4d3SLarry Finger u32 adda_backup[16]; 1337f1d2b4d3SLarry Finger u32 iqk_mac_backup[IQK_MAC_REG_NUM]; 1338f1d2b4d3SLarry Finger u32 iqk_bb_backup[10]; 1339f1d2b4d3SLarry Finger bool iqk_initialized; 1340f1d2b4d3SLarry Finger 1341f1d2b4d3SLarry Finger bool rfpath_rx_enable[MAX_RF_PATH]; 1342f1d2b4d3SLarry Finger u8 reg_837; 1343f1d2b4d3SLarry Finger /* Dual mac */ 1344f1d2b4d3SLarry Finger bool need_iqk; 1345f1d2b4d3SLarry Finger struct iqk_matrix_regs iqk_matrix[IQK_MATRIX_SETTINGS_NUM]; 1346f1d2b4d3SLarry Finger 1347f1d2b4d3SLarry Finger bool rfpi_enable; 1348f1d2b4d3SLarry Finger bool iqk_in_progress; 1349f1d2b4d3SLarry Finger 1350f1d2b4d3SLarry Finger u8 pwrgroup_cnt; 1351f1d2b4d3SLarry Finger u8 cck_high_power; 1352f1d2b4d3SLarry Finger /* this is for 88E & 8723A */ 1353f1d2b4d3SLarry Finger u32 mcs_txpwrlevel_origoffset[MAX_PG_GROUP][16]; 1354f1d2b4d3SLarry Finger /* MAX_PG_GROUP groups of pwr diff by rates */ 1355f1d2b4d3SLarry Finger u32 mcs_offset[MAX_PG_GROUP][16]; 1356f1d2b4d3SLarry Finger u32 tx_power_by_rate_offset[TX_PWR_BY_RATE_NUM_BAND] 1357f1d2b4d3SLarry Finger [TX_PWR_BY_RATE_NUM_RF] 1358f1d2b4d3SLarry Finger [TX_PWR_BY_RATE_NUM_RF] 13594a7093b9SPing-Ke Shih [TX_PWR_BY_RATE_NUM_RATE]; 1360f1d2b4d3SLarry Finger u8 txpwr_by_rate_base_24g[TX_PWR_BY_RATE_NUM_RF] 1361f1d2b4d3SLarry Finger [TX_PWR_BY_RATE_NUM_RF] 1362f1d2b4d3SLarry Finger [MAX_BASE_NUM_IN_PHY_REG_PG_24G]; 1363f1d2b4d3SLarry Finger u8 txpwr_by_rate_base_5g[TX_PWR_BY_RATE_NUM_RF] 1364f1d2b4d3SLarry Finger [TX_PWR_BY_RATE_NUM_RF] 1365f1d2b4d3SLarry Finger [MAX_BASE_NUM_IN_PHY_REG_PG_5G]; 1366f1d2b4d3SLarry Finger u8 default_initialgain[4]; 1367f1d2b4d3SLarry Finger 1368f1d2b4d3SLarry Finger /* the current Tx power level */ 1369f1d2b4d3SLarry Finger u8 cur_cck_txpwridx; 1370f1d2b4d3SLarry Finger u8 cur_ofdm24g_txpwridx; 1371f1d2b4d3SLarry Finger u8 cur_bw20_txpwridx; 1372f1d2b4d3SLarry Finger u8 cur_bw40_txpwridx; 1373f1d2b4d3SLarry Finger 137408aba42fSArnd Bergmann s8 txpwr_limit_2_4g[MAX_REGULATION_NUM] 1375d5e58252SLarry Finger [MAX_2_4G_BANDWIDTH_NUM] 1376f1d2b4d3SLarry Finger [MAX_RATE_SECTION_NUM] 1377f1d2b4d3SLarry Finger [CHANNEL_MAX_NUMBER_2G] 1378f1d2b4d3SLarry Finger [MAX_RF_PATH_NUM]; 137908aba42fSArnd Bergmann s8 txpwr_limit_5g[MAX_REGULATION_NUM] 1380d5e58252SLarry Finger [MAX_5G_BANDWIDTH_NUM] 1381f1d2b4d3SLarry Finger [MAX_RATE_SECTION_NUM] 1382f1d2b4d3SLarry Finger [CHANNEL_MAX_NUMBER_5G] 1383f1d2b4d3SLarry Finger [MAX_RF_PATH_NUM]; 1384f1d2b4d3SLarry Finger 1385f1d2b4d3SLarry Finger u32 rfreg_chnlval[2]; 1386f1d2b4d3SLarry Finger bool apk_done; 1387f1d2b4d3SLarry Finger u32 reg_rf3c[2]; /* pathA / pathB */ 1388f1d2b4d3SLarry Finger 1389f1d2b4d3SLarry Finger u32 backup_rf_0x1a;/*92ee*/ 1390f1d2b4d3SLarry Finger /* bfsync */ 1391f1d2b4d3SLarry Finger u8 framesync; 1392f1d2b4d3SLarry Finger u32 framesync_c34; 1393f1d2b4d3SLarry Finger 1394f1d2b4d3SLarry Finger u8 num_total_rfpath; 1395f1d2b4d3SLarry Finger struct phy_parameters hwparam_tables[MAX_TAB]; 1396f1d2b4d3SLarry Finger u16 rf_pathmap; 1397f1d2b4d3SLarry Finger 1398f1d2b4d3SLarry Finger u8 hw_rof_enable; /*Enable GPIO[9] as WL RF HW PDn source*/ 1399f1d2b4d3SLarry Finger enum rt_polarity_ctl polarity_ctl; 1400f1d2b4d3SLarry Finger }; 1401f1d2b4d3SLarry Finger 1402f1d2b4d3SLarry Finger #define MAX_TID_COUNT 9 1403f1d2b4d3SLarry Finger #define RTL_AGG_STOP 0 1404f1d2b4d3SLarry Finger #define RTL_AGG_PROGRESS 1 1405f1d2b4d3SLarry Finger #define RTL_AGG_START 2 1406f1d2b4d3SLarry Finger #define RTL_AGG_OPERATIONAL 3 1407f1d2b4d3SLarry Finger #define RTL_AGG_OFF 0 1408f1d2b4d3SLarry Finger #define RTL_AGG_ON 1 1409f1d2b4d3SLarry Finger #define RTL_RX_AGG_START 1 1410f1d2b4d3SLarry Finger #define RTL_RX_AGG_STOP 0 1411f1d2b4d3SLarry Finger #define RTL_AGG_EMPTYING_HW_QUEUE_ADDBA 2 1412f1d2b4d3SLarry Finger #define RTL_AGG_EMPTYING_HW_QUEUE_DELBA 3 1413f1d2b4d3SLarry Finger 1414f1d2b4d3SLarry Finger struct rtl_ht_agg { 1415f1d2b4d3SLarry Finger u16 txq_id; 1416f1d2b4d3SLarry Finger u16 wait_for_ba; 1417f1d2b4d3SLarry Finger u16 start_idx; 1418f1d2b4d3SLarry Finger u64 bitmap; 1419f1d2b4d3SLarry Finger u32 rate_n_flags; 1420f1d2b4d3SLarry Finger u8 agg_state; 1421f1d2b4d3SLarry Finger u8 rx_agg_state; 1422f1d2b4d3SLarry Finger }; 1423f1d2b4d3SLarry Finger 1424f1d2b4d3SLarry Finger struct rssi_sta { 1425f1d2b4d3SLarry Finger long undec_sm_pwdb; 1426f1d2b4d3SLarry Finger long undec_sm_cck; 1427f1d2b4d3SLarry Finger }; 1428f1d2b4d3SLarry Finger 1429f1d2b4d3SLarry Finger struct rtl_tid_data { 1430f1d2b4d3SLarry Finger struct rtl_ht_agg agg; 1431f1d2b4d3SLarry Finger }; 1432f1d2b4d3SLarry Finger 1433f1d2b4d3SLarry Finger struct rtl_sta_info { 1434f1d2b4d3SLarry Finger struct list_head list; 1435f1d2b4d3SLarry Finger struct rtl_tid_data tids[MAX_TID_COUNT]; 1436f1d2b4d3SLarry Finger /* just used for ap adhoc or mesh*/ 1437f1d2b4d3SLarry Finger struct rssi_sta rssi_stat; 143808ab7465SPing-Ke Shih u8 rssi_level; 143973fb2705SLarry Finger u16 wireless_mode; 144073fb2705SLarry Finger u8 ratr_index; 144173fb2705SLarry Finger u8 mimo_ps; 144273fb2705SLarry Finger u8 mac_addr[ETH_ALEN]; 1443f1d2b4d3SLarry Finger } __packed; 1444f1d2b4d3SLarry Finger 1445f1d2b4d3SLarry Finger struct rtl_priv; 1446f1d2b4d3SLarry Finger struct rtl_io { 1447f1d2b4d3SLarry Finger struct device *dev; 1448f1d2b4d3SLarry Finger struct mutex bb_mutex; 1449f1d2b4d3SLarry Finger 1450f1d2b4d3SLarry Finger /*PCI MEM map */ 1451f1d2b4d3SLarry Finger unsigned long pci_mem_end; /*shared mem end */ 1452f1d2b4d3SLarry Finger unsigned long pci_mem_start; /*shared mem start */ 1453f1d2b4d3SLarry Finger 1454f1d2b4d3SLarry Finger /*PCI IO map */ 1455f1d2b4d3SLarry Finger unsigned long pci_base_addr; /*device I/O address */ 1456f1d2b4d3SLarry Finger 1457f1d2b4d3SLarry Finger void (*write8_async)(struct rtl_priv *rtlpriv, u32 addr, u8 val); 1458f1d2b4d3SLarry Finger void (*write16_async)(struct rtl_priv *rtlpriv, u32 addr, u16 val); 1459f1d2b4d3SLarry Finger void (*write32_async)(struct rtl_priv *rtlpriv, u32 addr, u32 val); 1460f1d2b4d3SLarry Finger 1461f1d2b4d3SLarry Finger u8 (*read8_sync)(struct rtl_priv *rtlpriv, u32 addr); 1462f1d2b4d3SLarry Finger u16 (*read16_sync)(struct rtl_priv *rtlpriv, u32 addr); 1463f1d2b4d3SLarry Finger u32 (*read32_sync)(struct rtl_priv *rtlpriv, u32 addr); 1464f1d2b4d3SLarry Finger 1465f1d2b4d3SLarry Finger }; 1466f1d2b4d3SLarry Finger 1467f1d2b4d3SLarry Finger struct rtl_mac { 1468f1d2b4d3SLarry Finger u8 mac_addr[ETH_ALEN]; 1469f1d2b4d3SLarry Finger u8 mac80211_registered; 1470f1d2b4d3SLarry Finger u8 beacon_enabled; 1471f1d2b4d3SLarry Finger 1472f1d2b4d3SLarry Finger u32 tx_ss_num; 1473f1d2b4d3SLarry Finger u32 rx_ss_num; 1474f1d2b4d3SLarry Finger 147557fbcce3SJohannes Berg struct ieee80211_supported_band bands[NUM_NL80211_BANDS]; 1476f1d2b4d3SLarry Finger struct ieee80211_hw *hw; 1477f1d2b4d3SLarry Finger struct ieee80211_vif *vif; 1478f1d2b4d3SLarry Finger enum nl80211_iftype opmode; 1479f1d2b4d3SLarry Finger 1480f1d2b4d3SLarry Finger /*Probe Beacon management */ 1481f1d2b4d3SLarry Finger struct rtl_tid_data tids[MAX_TID_COUNT]; 1482f1d2b4d3SLarry Finger enum rtl_link_state link_state; 1483f1d2b4d3SLarry Finger 1484f1d2b4d3SLarry Finger int n_channels; 1485f1d2b4d3SLarry Finger int n_bitrates; 1486f1d2b4d3SLarry Finger 1487f1d2b4d3SLarry Finger bool offchan_delay; 1488f1d2b4d3SLarry Finger u8 p2p; /*using p2p role*/ 1489f1d2b4d3SLarry Finger bool p2p_in_use; 1490f1d2b4d3SLarry Finger 1491f1d2b4d3SLarry Finger /*filters */ 1492f1d2b4d3SLarry Finger u32 rx_conf; 1493f1d2b4d3SLarry Finger u16 rx_mgt_filter; 1494f1d2b4d3SLarry Finger u16 rx_ctrl_filter; 1495f1d2b4d3SLarry Finger u16 rx_data_filter; 1496f1d2b4d3SLarry Finger 1497f1d2b4d3SLarry Finger bool act_scanning; 1498f1d2b4d3SLarry Finger u8 cnt_after_linked; 1499f1d2b4d3SLarry Finger bool skip_scan; 1500f1d2b4d3SLarry Finger 1501f1d2b4d3SLarry Finger /* early mode */ 1502f1d2b4d3SLarry Finger /* skb wait queue */ 1503f1d2b4d3SLarry Finger struct sk_buff_head skb_waitq[MAX_TID_COUNT]; 1504f1d2b4d3SLarry Finger 1505f1d2b4d3SLarry Finger u8 ht_stbc_cap; 1506f1d2b4d3SLarry Finger u8 ht_cur_stbc; 1507f1d2b4d3SLarry Finger 1508f1d2b4d3SLarry Finger /*vht support*/ 1509f1d2b4d3SLarry Finger u8 vht_enable; 1510f1d2b4d3SLarry Finger u8 bw_80; 1511f1d2b4d3SLarry Finger u8 vht_cur_ldpc; 1512f1d2b4d3SLarry Finger u8 vht_cur_stbc; 1513f1d2b4d3SLarry Finger u8 vht_stbc_cap; 1514f1d2b4d3SLarry Finger u8 vht_ldpc_cap; 1515f1d2b4d3SLarry Finger 1516f1d2b4d3SLarry Finger /*RDG*/ 1517f1d2b4d3SLarry Finger bool rdg_en; 1518f1d2b4d3SLarry Finger 1519f1d2b4d3SLarry Finger /*AP*/ 1520f1d2b4d3SLarry Finger u8 bssid[ETH_ALEN] __aligned(2); 1521f1d2b4d3SLarry Finger u32 vendor; 1522f1d2b4d3SLarry Finger u8 mcs[16]; /* 16 bytes mcs for HT rates. */ 1523f1d2b4d3SLarry Finger u32 basic_rates; /* b/g rates */ 1524f1d2b4d3SLarry Finger u8 ht_enable; 1525f1d2b4d3SLarry Finger u8 sgi_40; 1526f1d2b4d3SLarry Finger u8 sgi_20; 1527f1d2b4d3SLarry Finger u8 bw_40; 1528f1d2b4d3SLarry Finger u16 mode; /* wireless mode */ 1529f1d2b4d3SLarry Finger u8 slot_time; 1530f1d2b4d3SLarry Finger u8 short_preamble; 1531f1d2b4d3SLarry Finger u8 use_cts_protect; 1532f1d2b4d3SLarry Finger u8 cur_40_prime_sc; 1533f1d2b4d3SLarry Finger u8 cur_40_prime_sc_bk; 1534f1d2b4d3SLarry Finger u8 cur_80_prime_sc; 1535f1d2b4d3SLarry Finger u64 tsf; 1536f1d2b4d3SLarry Finger u8 retry_short; 1537f1d2b4d3SLarry Finger u8 retry_long; 1538f1d2b4d3SLarry Finger u16 assoc_id; 1539f1d2b4d3SLarry Finger bool hiddenssid; 1540f1d2b4d3SLarry Finger 1541f1d2b4d3SLarry Finger /*IBSS*/ 1542f1d2b4d3SLarry Finger int beacon_interval; 1543f1d2b4d3SLarry Finger 1544f1d2b4d3SLarry Finger /*AMPDU*/ 1545f1d2b4d3SLarry Finger u8 min_space_cfg; /*For Min spacing configurations */ 1546f1d2b4d3SLarry Finger u8 max_mss_density; 1547f1d2b4d3SLarry Finger u8 current_ampdu_factor; 1548f1d2b4d3SLarry Finger u8 current_ampdu_density; 1549f1d2b4d3SLarry Finger 1550f1d2b4d3SLarry Finger /*QOS & EDCA */ 1551f1d2b4d3SLarry Finger struct ieee80211_tx_queue_params edca_param[RTL_MAC80211_NUM_QUEUE]; 1552f1d2b4d3SLarry Finger struct rtl_qos_parameters ac[AC_MAX]; 1553f1d2b4d3SLarry Finger 1554f1d2b4d3SLarry Finger /* counters */ 1555f1d2b4d3SLarry Finger u64 last_txok_cnt; 1556f1d2b4d3SLarry Finger u64 last_rxok_cnt; 1557f1d2b4d3SLarry Finger u32 last_bt_edca_ul; 1558f1d2b4d3SLarry Finger u32 last_bt_edca_dl; 1559f1d2b4d3SLarry Finger }; 1560f1d2b4d3SLarry Finger 1561f1d2b4d3SLarry Finger struct btdm_8723 { 1562f1d2b4d3SLarry Finger bool all_off; 1563f1d2b4d3SLarry Finger bool agc_table_en; 1564f1d2b4d3SLarry Finger bool adc_back_off_on; 1565f1d2b4d3SLarry Finger bool b2_ant_hid_en; 1566f1d2b4d3SLarry Finger bool low_penalty_rate_adaptive; 1567f1d2b4d3SLarry Finger bool rf_rx_lpf_shrink; 1568f1d2b4d3SLarry Finger bool reject_aggre_pkt; 1569f1d2b4d3SLarry Finger bool tra_tdma_on; 1570f1d2b4d3SLarry Finger u8 tra_tdma_nav; 1571f1d2b4d3SLarry Finger u8 tra_tdma_ant; 1572f1d2b4d3SLarry Finger bool tdma_on; 1573f1d2b4d3SLarry Finger u8 tdma_ant; 1574f1d2b4d3SLarry Finger u8 tdma_nav; 1575f1d2b4d3SLarry Finger u8 tdma_dac_swing; 1576f1d2b4d3SLarry Finger u8 fw_dac_swing_lvl; 1577f1d2b4d3SLarry Finger bool ps_tdma_on; 1578f1d2b4d3SLarry Finger u8 ps_tdma_byte[5]; 1579f1d2b4d3SLarry Finger bool pta_on; 1580f1d2b4d3SLarry Finger u32 val_0x6c0; 1581f1d2b4d3SLarry Finger u32 val_0x6c8; 1582f1d2b4d3SLarry Finger u32 val_0x6cc; 1583f1d2b4d3SLarry Finger bool sw_dac_swing_on; 1584f1d2b4d3SLarry Finger u32 sw_dac_swing_lvl; 1585f1d2b4d3SLarry Finger u32 wlan_act_hi; 1586f1d2b4d3SLarry Finger u32 wlan_act_lo; 1587f1d2b4d3SLarry Finger u32 bt_retry_index; 1588f1d2b4d3SLarry Finger bool dec_bt_pwr; 1589f1d2b4d3SLarry Finger bool ignore_wlan_act; 1590f1d2b4d3SLarry Finger }; 1591f1d2b4d3SLarry Finger 1592f1d2b4d3SLarry Finger struct bt_coexist_8723 { 1593f1d2b4d3SLarry Finger u32 high_priority_tx; 1594f1d2b4d3SLarry Finger u32 high_priority_rx; 1595f1d2b4d3SLarry Finger u32 low_priority_tx; 1596f1d2b4d3SLarry Finger u32 low_priority_rx; 1597f1d2b4d3SLarry Finger u8 c2h_bt_info; 1598f1d2b4d3SLarry Finger bool c2h_bt_info_req_sent; 1599f1d2b4d3SLarry Finger bool c2h_bt_inquiry_page; 1600*71ffa1bcSDmitry Antipov unsigned long bt_inq_page_start_time; 1601f1d2b4d3SLarry Finger u8 bt_retry_cnt; 1602f1d2b4d3SLarry Finger u8 c2h_bt_info_original; 1603f1d2b4d3SLarry Finger u8 bt_inquiry_page_cnt; 1604f1d2b4d3SLarry Finger struct btdm_8723 btdm; 1605f1d2b4d3SLarry Finger }; 1606f1d2b4d3SLarry Finger 1607f1d2b4d3SLarry Finger struct rtl_hal { 1608f1d2b4d3SLarry Finger struct ieee80211_hw *hw; 1609f1d2b4d3SLarry Finger bool driver_is_goingto_unload; 1610f1d2b4d3SLarry Finger bool up_first_time; 1611f1d2b4d3SLarry Finger bool first_init; 1612f1d2b4d3SLarry Finger bool being_init_adapter; 1613f1d2b4d3SLarry Finger bool bbrf_ready; 1614f1d2b4d3SLarry Finger bool mac_func_enable; 1615f1d2b4d3SLarry Finger bool pre_edcca_enable; 1616f1d2b4d3SLarry Finger struct bt_coexist_8723 hal_coex_8723; 1617f1d2b4d3SLarry Finger 1618f1d2b4d3SLarry Finger enum intf_type interface; 1619f1d2b4d3SLarry Finger u16 hw_type; /*92c or 92d or 92s and so on */ 1620f1d2b4d3SLarry Finger u8 ic_class; 1621f1d2b4d3SLarry Finger u8 oem_id; 1622f1d2b4d3SLarry Finger u32 version; /*version of chip */ 1623f1d2b4d3SLarry Finger u8 state; /*stop 0, start 1 */ 1624f1d2b4d3SLarry Finger u8 board_type; 16257fe1fe75SPing-Ke Shih u8 package_type; 1626f1d2b4d3SLarry Finger u8 external_pa; 1627f1d2b4d3SLarry Finger 1628f1d2b4d3SLarry Finger u8 pa_mode; 1629f1d2b4d3SLarry Finger u8 pa_type_2g; 1630f1d2b4d3SLarry Finger u8 pa_type_5g; 1631f1d2b4d3SLarry Finger u8 lna_type_2g; 1632f1d2b4d3SLarry Finger u8 lna_type_5g; 1633f1d2b4d3SLarry Finger u8 external_pa_2g; 1634f1d2b4d3SLarry Finger u8 external_lna_2g; 1635f1d2b4d3SLarry Finger u8 external_pa_5g; 1636f1d2b4d3SLarry Finger u8 external_lna_5g; 163784d26fdaSPing-Ke Shih u8 type_glna; 163884d26fdaSPing-Ke Shih u8 type_gpa; 163984d26fdaSPing-Ke Shih u8 type_alna; 164084d26fdaSPing-Ke Shih u8 type_apa; 1641f1d2b4d3SLarry Finger u8 rfe_type; 1642f1d2b4d3SLarry Finger 1643f1d2b4d3SLarry Finger /*firmware */ 1644f1d2b4d3SLarry Finger u32 fwsize; 1645f1d2b4d3SLarry Finger u8 *pfirmware; 1646f1d2b4d3SLarry Finger u16 fw_version; 1647f1d2b4d3SLarry Finger u16 fw_subversion; 1648f1d2b4d3SLarry Finger bool h2c_setinprogress; 1649f1d2b4d3SLarry Finger u8 last_hmeboxnum; 1650f1d2b4d3SLarry Finger bool fw_ready; 1651f1d2b4d3SLarry Finger /*Reserve page start offset except beacon in TxQ. */ 1652f1d2b4d3SLarry Finger u8 fw_rsvdpage_startoffset; 1653f1d2b4d3SLarry Finger u8 h2c_txcmd_seq; 1654f1d2b4d3SLarry Finger u8 current_ra_rate; 1655f1d2b4d3SLarry Finger 1656f1d2b4d3SLarry Finger /* FW Cmd IO related */ 1657f1d2b4d3SLarry Finger u16 fwcmd_iomap; 1658f1d2b4d3SLarry Finger u32 fwcmd_ioparam; 1659f1d2b4d3SLarry Finger bool set_fwcmd_inprogress; 1660f1d2b4d3SLarry Finger u8 current_fwcmd_io; 1661f1d2b4d3SLarry Finger 1662f1d2b4d3SLarry Finger struct p2p_ps_offload_t p2p_ps_offload; 1663f1d2b4d3SLarry Finger bool fw_clk_change_in_progress; 1664f1d2b4d3SLarry Finger bool allow_sw_to_change_hwclc; 1665f1d2b4d3SLarry Finger u8 fw_ps_state; 1666f1d2b4d3SLarry Finger 1667f1d2b4d3SLarry Finger /*AMPDU init min space*/ 1668f1d2b4d3SLarry Finger u8 minspace_cfg; /*For Min spacing configurations */ 1669f1d2b4d3SLarry Finger 1670f1d2b4d3SLarry Finger /* Dual mac */ 1671f1d2b4d3SLarry Finger enum macphy_mode macphymode; 1672f1d2b4d3SLarry Finger enum band_type current_bandtype; /* 0:2.4G, 1:5G */ 1673f1d2b4d3SLarry Finger enum band_type current_bandtypebackup; 1674f1d2b4d3SLarry Finger enum band_type bandset; 1675f1d2b4d3SLarry Finger /* dual MAC 0--Mac0 1--Mac1 */ 1676f1d2b4d3SLarry Finger u32 interfaceindex; 1677f1d2b4d3SLarry Finger /* just for DualMac S3S4 */ 1678f1d2b4d3SLarry Finger u8 macphyctl_reg; 1679f1d2b4d3SLarry Finger bool earlymode_enable; 1680f1d2b4d3SLarry Finger u8 max_earlymode_num; 1681f1d2b4d3SLarry Finger /* Dual mac*/ 1682f1d2b4d3SLarry Finger bool during_mac0init_radiob; 1683f1d2b4d3SLarry Finger bool during_mac1init_radioa; 1684f1d2b4d3SLarry Finger bool reloadtxpowerindex; 1685f1d2b4d3SLarry Finger /* True if IMR or IQK have done 1686d3da329cSLarry Finger * for 2.4G in scan progress 1687d3da329cSLarry Finger */ 1688f1d2b4d3SLarry Finger bool load_imrandiqk_setting_for2g; 1689f1d2b4d3SLarry Finger 1690f1d2b4d3SLarry Finger bool disable_amsdu_8k; 1691f1d2b4d3SLarry Finger bool master_of_dmsp; 1692f1d2b4d3SLarry Finger bool slave_of_dmsp; 1693f1d2b4d3SLarry Finger 1694f1d2b4d3SLarry Finger u16 rx_tag;/*for 92ee*/ 1695f1d2b4d3SLarry Finger u8 rts_en; 1696f1d2b4d3SLarry Finger 1697f1d2b4d3SLarry Finger /*for wowlan*/ 1698f1d2b4d3SLarry Finger bool wow_enable; 1699f1d2b4d3SLarry Finger bool enter_pnp_sleep; 1700f1d2b4d3SLarry Finger bool wake_from_pnp_sleep; 1701f1d2b4d3SLarry Finger bool wow_enabled; 17023c92d551SArnd Bergmann time64_t last_suspend_sec; 1703f1d2b4d3SLarry Finger u32 wowlan_fwsize; 1704f1d2b4d3SLarry Finger u8 *wowlan_firmware; 1705f1d2b4d3SLarry Finger 1706f1d2b4d3SLarry Finger u8 hw_rof_enable; /*Enable GPIO[9] as WL RF HW PDn source*/ 1707f1d2b4d3SLarry Finger 1708f1d2b4d3SLarry Finger bool real_wow_v2_enable; 1709f1d2b4d3SLarry Finger bool re_init_llt_table; 1710f1d2b4d3SLarry Finger }; 1711f1d2b4d3SLarry Finger 1712f1d2b4d3SLarry Finger struct rtl_security { 1713f1d2b4d3SLarry Finger /*default 0 */ 1714f1d2b4d3SLarry Finger bool use_sw_sec; 1715f1d2b4d3SLarry Finger 1716f1d2b4d3SLarry Finger bool being_setkey; 1717f1d2b4d3SLarry Finger bool use_defaultkey; 1718f1d2b4d3SLarry Finger /*Encryption Algorithm for Unicast Packet */ 1719f1d2b4d3SLarry Finger enum rt_enc_alg pairwise_enc_algorithm; 1720f1d2b4d3SLarry Finger /*Encryption Algorithm for Brocast/Multicast */ 1721f1d2b4d3SLarry Finger enum rt_enc_alg group_enc_algorithm; 1722f1d2b4d3SLarry Finger /*Cam Entry Bitmap */ 1723f1d2b4d3SLarry Finger u32 hwsec_cam_bitmap; 1724f1d2b4d3SLarry Finger u8 hwsec_cam_sta_addr[TOTAL_CAM_ENTRY][ETH_ALEN]; 1725f1d2b4d3SLarry Finger /*local Key buffer, indx 0 is for 1726d3da329cSLarry Finger * pairwise key 1-4 is for agoup key. 1727d3da329cSLarry Finger */ 1728f1d2b4d3SLarry Finger u8 key_buf[KEY_BUF_SIZE][MAX_KEY_LEN]; 1729f1d2b4d3SLarry Finger u8 key_len[KEY_BUF_SIZE]; 1730f1d2b4d3SLarry Finger 1731f1d2b4d3SLarry Finger /*The pointer of Pairwise Key, 1732d3da329cSLarry Finger * it always points to KeyBuf[4] 1733d3da329cSLarry Finger */ 1734f1d2b4d3SLarry Finger u8 *pairwise_key; 1735f1d2b4d3SLarry Finger }; 1736f1d2b4d3SLarry Finger 1737f1d2b4d3SLarry Finger #define ASSOCIATE_ENTRY_NUM 33 1738f1d2b4d3SLarry Finger 1739f1d2b4d3SLarry Finger struct fast_ant_training { 1740f1d2b4d3SLarry Finger u8 bssid[6]; 1741f1d2b4d3SLarry Finger u8 antsel_rx_keep_0; 1742f1d2b4d3SLarry Finger u8 antsel_rx_keep_1; 1743f1d2b4d3SLarry Finger u8 antsel_rx_keep_2; 1744f1d2b4d3SLarry Finger u32 ant_sum[7]; 1745f1d2b4d3SLarry Finger u32 ant_cnt[7]; 1746f1d2b4d3SLarry Finger u32 ant_ave[7]; 1747f1d2b4d3SLarry Finger u8 fat_state; 1748f1d2b4d3SLarry Finger u32 train_idx; 1749f1d2b4d3SLarry Finger u8 antsel_a[ASSOCIATE_ENTRY_NUM]; 1750f1d2b4d3SLarry Finger u8 antsel_b[ASSOCIATE_ENTRY_NUM]; 1751f1d2b4d3SLarry Finger u8 antsel_c[ASSOCIATE_ENTRY_NUM]; 1752f1d2b4d3SLarry Finger u32 main_ant_sum[ASSOCIATE_ENTRY_NUM]; 1753f1d2b4d3SLarry Finger u32 aux_ant_sum[ASSOCIATE_ENTRY_NUM]; 1754f1d2b4d3SLarry Finger u32 main_ant_cnt[ASSOCIATE_ENTRY_NUM]; 1755f1d2b4d3SLarry Finger u32 aux_ant_cnt[ASSOCIATE_ENTRY_NUM]; 1756f1d2b4d3SLarry Finger u8 rx_idle_ant; 1757f1d2b4d3SLarry Finger bool becomelinked; 1758f1d2b4d3SLarry Finger }; 1759f1d2b4d3SLarry Finger 1760f1d2b4d3SLarry Finger struct dm_phy_dbg_info { 176108aba42fSArnd Bergmann s8 rx_snrdb[4]; 1762f1d2b4d3SLarry Finger u64 num_qry_phy_status; 1763f1d2b4d3SLarry Finger u64 num_qry_phy_status_cck; 1764f1d2b4d3SLarry Finger u64 num_qry_phy_status_ofdm; 1765f1d2b4d3SLarry Finger u16 num_qry_beacon_pkt; 1766f1d2b4d3SLarry Finger u16 num_non_be_pkt; 1767f1d2b4d3SLarry Finger s32 rx_evm[4]; 1768f1d2b4d3SLarry Finger }; 1769f1d2b4d3SLarry Finger 1770f1d2b4d3SLarry Finger struct rtl_dm { 1771f1d2b4d3SLarry Finger /*PHY status for Dynamic Management */ 1772f1d2b4d3SLarry Finger long entry_min_undec_sm_pwdb; 1773f1d2b4d3SLarry Finger long undec_sm_cck; 1774f1d2b4d3SLarry Finger long undec_sm_pwdb; /*out dm */ 1775f1d2b4d3SLarry Finger long entry_max_undec_sm_pwdb; 1776f1d2b4d3SLarry Finger s32 ofdm_pkt_cnt; 1777f1d2b4d3SLarry Finger bool dm_initialgain_enable; 1778f1d2b4d3SLarry Finger bool dynamic_txpower_enable; 1779f1d2b4d3SLarry Finger bool current_turbo_edca; 1780f1d2b4d3SLarry Finger bool is_any_nonbepkts; /*out dm */ 1781f1d2b4d3SLarry Finger bool is_cur_rdlstate; 1782f1d2b4d3SLarry Finger bool txpower_trackinginit; 1783f1d2b4d3SLarry Finger bool disable_framebursting; 1784f1d2b4d3SLarry Finger bool cck_inch14; 1785f1d2b4d3SLarry Finger bool txpower_tracking; 1786f1d2b4d3SLarry Finger bool useramask; 1787f1d2b4d3SLarry Finger bool rfpath_rxenable[4]; 1788f1d2b4d3SLarry Finger bool inform_fw_driverctrldm; 1789f1d2b4d3SLarry Finger bool current_mrc_switch; 1790f1d2b4d3SLarry Finger u8 txpowercount; 1791f1d2b4d3SLarry Finger u8 powerindex_backup[6]; 1792f1d2b4d3SLarry Finger 1793f1d2b4d3SLarry Finger u8 thermalvalue_rxgain; 1794f1d2b4d3SLarry Finger u8 thermalvalue_iqk; 1795f1d2b4d3SLarry Finger u8 thermalvalue_lck; 1796f1d2b4d3SLarry Finger u8 thermalvalue; 1797f1d2b4d3SLarry Finger u8 last_dtp_lvl; 1798f1d2b4d3SLarry Finger u8 thermalvalue_avg[AVG_THERMAL_NUM]; 1799f1d2b4d3SLarry Finger u8 thermalvalue_avg_index; 1800f1d2b4d3SLarry Finger u8 tm_trigger; 1801f1d2b4d3SLarry Finger bool done_txpower; 1802f1d2b4d3SLarry Finger u8 dynamic_txhighpower_lvl; /*Tx high power level */ 1803f1d2b4d3SLarry Finger u8 dm_flag; /*Indicate each dynamic mechanism's status. */ 1804f1d2b4d3SLarry Finger u8 dm_flag_tmp; 1805f1d2b4d3SLarry Finger u8 dm_type; 1806f1d2b4d3SLarry Finger u8 dm_rssi_sel; 1807f1d2b4d3SLarry Finger u8 txpower_track_control; 1808f1d2b4d3SLarry Finger bool interrupt_migration; 1809f1d2b4d3SLarry Finger bool disable_tx_int; 181008aba42fSArnd Bergmann s8 ofdm_index[MAX_RF_PATH]; 1811f1d2b4d3SLarry Finger u8 default_ofdm_index; 1812f1d2b4d3SLarry Finger u8 default_cck_index; 181308aba42fSArnd Bergmann s8 cck_index; 181408aba42fSArnd Bergmann s8 delta_power_index[MAX_RF_PATH]; 181508aba42fSArnd Bergmann s8 delta_power_index_last[MAX_RF_PATH]; 181608aba42fSArnd Bergmann s8 power_index_offset[MAX_RF_PATH]; 181708aba42fSArnd Bergmann s8 absolute_ofdm_swing_idx[MAX_RF_PATH]; 181808aba42fSArnd Bergmann s8 remnant_ofdm_swing_idx[MAX_RF_PATH]; 181908aba42fSArnd Bergmann s8 remnant_cck_idx; 1820f1d2b4d3SLarry Finger bool modify_txagc_flag_path_a; 1821f1d2b4d3SLarry Finger bool modify_txagc_flag_path_b; 1822f1d2b4d3SLarry Finger 1823f1d2b4d3SLarry Finger bool one_entry_only; 1824f1d2b4d3SLarry Finger struct dm_phy_dbg_info dbginfo; 1825f1d2b4d3SLarry Finger 1826f1d2b4d3SLarry Finger /* Dynamic ATC switch */ 1827f1d2b4d3SLarry Finger bool atc_status; 1828f1d2b4d3SLarry Finger bool large_cfo_hit; 1829f1d2b4d3SLarry Finger bool is_freeze; 1830f1d2b4d3SLarry Finger int cfo_tail[2]; 1831f1d2b4d3SLarry Finger int cfo_ave_pre; 1832f1d2b4d3SLarry Finger int crystal_cap; 1833f1d2b4d3SLarry Finger u8 cfo_threshold; 1834f1d2b4d3SLarry Finger u32 packet_count; 1835f1d2b4d3SLarry Finger u32 packet_count_pre; 1836f1d2b4d3SLarry Finger u8 tx_rate; 1837f1d2b4d3SLarry Finger 1838f1d2b4d3SLarry Finger /*88e tx power tracking*/ 1839f1d2b4d3SLarry Finger u8 swing_idx_ofdm[MAX_RF_PATH]; 1840f1d2b4d3SLarry Finger u8 swing_idx_ofdm_cur; 1841f1d2b4d3SLarry Finger u8 swing_idx_ofdm_base[MAX_RF_PATH]; 1842f1d2b4d3SLarry Finger bool swing_flag_ofdm; 1843f1d2b4d3SLarry Finger u8 swing_idx_cck; 1844f1d2b4d3SLarry Finger u8 swing_idx_cck_cur; 1845f1d2b4d3SLarry Finger u8 swing_idx_cck_base; 1846f1d2b4d3SLarry Finger bool swing_flag_cck; 1847f1d2b4d3SLarry Finger 184808aba42fSArnd Bergmann s8 swing_diff_2g; 184908aba42fSArnd Bergmann s8 swing_diff_5g; 1850f1d2b4d3SLarry Finger 1851f1d2b4d3SLarry Finger /* DMSP */ 1852f1d2b4d3SLarry Finger bool supp_phymode_switch; 1853f1d2b4d3SLarry Finger 1854f1d2b4d3SLarry Finger /* DulMac */ 1855f1d2b4d3SLarry Finger struct fast_ant_training fat_table; 1856f1d2b4d3SLarry Finger 1857f1d2b4d3SLarry Finger u8 resp_tx_path; 1858f1d2b4d3SLarry Finger u8 path_sel; 1859f1d2b4d3SLarry Finger u32 patha_sum; 1860f1d2b4d3SLarry Finger u32 pathb_sum; 1861f1d2b4d3SLarry Finger u32 patha_cnt; 1862f1d2b4d3SLarry Finger u32 pathb_cnt; 1863f1d2b4d3SLarry Finger 1864f1d2b4d3SLarry Finger u8 pre_channel; 1865f1d2b4d3SLarry Finger u8 *p_channel; 1866f1d2b4d3SLarry Finger u8 linked_interval; 1867f1d2b4d3SLarry Finger 1868f1d2b4d3SLarry Finger u64 last_tx_ok_cnt; 1869f1d2b4d3SLarry Finger u64 last_rx_ok_cnt; 1870f1d2b4d3SLarry Finger }; 1871f1d2b4d3SLarry Finger 1872f1d2b4d3SLarry Finger #define EFUSE_MAX_LOGICAL_SIZE 512 1873f1d2b4d3SLarry Finger 1874f1d2b4d3SLarry Finger struct rtl_efuse { 18752cdd634eSPing-Ke Shih const struct rtl_efuse_ops *efuse_ops; 1876e703c5ddSLarry Finger bool autoload_ok; 1877f1d2b4d3SLarry Finger bool bootfromefuse; 1878f1d2b4d3SLarry Finger u16 max_physical_size; 1879f1d2b4d3SLarry Finger 1880f1d2b4d3SLarry Finger u8 efuse_map[2][EFUSE_MAX_LOGICAL_SIZE]; 1881f1d2b4d3SLarry Finger u16 efuse_usedbytes; 1882f1d2b4d3SLarry Finger u8 efuse_usedpercentage; 1883f1d2b4d3SLarry Finger 1884f1d2b4d3SLarry Finger u8 autoload_failflag; 1885f1d2b4d3SLarry Finger u8 autoload_status; 1886f1d2b4d3SLarry Finger 1887f1d2b4d3SLarry Finger short epromtype; 1888f1d2b4d3SLarry Finger u16 eeprom_vid; 1889f1d2b4d3SLarry Finger u16 eeprom_did; 1890f1d2b4d3SLarry Finger u16 eeprom_svid; 1891f1d2b4d3SLarry Finger u16 eeprom_smid; 1892f1d2b4d3SLarry Finger u8 eeprom_oemid; 1893f1d2b4d3SLarry Finger u16 eeprom_channelplan; 1894f1d2b4d3SLarry Finger u8 eeprom_version; 1895f1d2b4d3SLarry Finger u8 board_type; 1896f1d2b4d3SLarry Finger u8 external_pa; 1897f1d2b4d3SLarry Finger 1898f1d2b4d3SLarry Finger u8 dev_addr[6]; 1899f1d2b4d3SLarry Finger u8 wowlan_enable; 1900f1d2b4d3SLarry Finger u8 antenna_div_cfg; 1901f1d2b4d3SLarry Finger u8 antenna_div_type; 1902f1d2b4d3SLarry Finger 1903f1d2b4d3SLarry Finger bool txpwr_fromeprom; 1904f1d2b4d3SLarry Finger u8 eeprom_crystalcap; 1905f1d2b4d3SLarry Finger u8 eeprom_tssi[2]; 1906f1d2b4d3SLarry Finger u8 eeprom_tssi_5g[3][2]; /* for 5GL/5GM/5GH band. */ 1907f1d2b4d3SLarry Finger u8 eeprom_pwrlimit_ht20[CHANNEL_GROUP_MAX]; 1908f1d2b4d3SLarry Finger u8 eeprom_pwrlimit_ht40[CHANNEL_GROUP_MAX]; 1909f1d2b4d3SLarry Finger u8 eeprom_chnlarea_txpwr_cck[MAX_RF_PATH][CHANNEL_GROUP_MAX_2G]; 1910f1d2b4d3SLarry Finger u8 eeprom_chnlarea_txpwr_ht40_1s[MAX_RF_PATH][CHANNEL_GROUP_MAX]; 1911f1d2b4d3SLarry Finger u8 eprom_chnl_txpwr_ht40_2sdf[MAX_RF_PATH][CHANNEL_GROUP_MAX]; 1912f1d2b4d3SLarry Finger 1913f1d2b4d3SLarry Finger u8 internal_pa_5g[2]; /* pathA / pathB */ 1914f1d2b4d3SLarry Finger u8 eeprom_c9; 1915f1d2b4d3SLarry Finger u8 eeprom_cc; 1916f1d2b4d3SLarry Finger 1917f1d2b4d3SLarry Finger /*For power group */ 1918f1d2b4d3SLarry Finger u8 eeprom_pwrgroup[2][3]; 1919f1d2b4d3SLarry Finger u8 pwrgroup_ht20[2][CHANNEL_MAX_NUMBER]; 1920f1d2b4d3SLarry Finger u8 pwrgroup_ht40[2][CHANNEL_MAX_NUMBER]; 1921f1d2b4d3SLarry Finger 1922f1d2b4d3SLarry Finger u8 txpwrlevel_cck[MAX_RF_PATH][CHANNEL_MAX_NUMBER_2G]; 1923f1d2b4d3SLarry Finger /*For HT 40MHZ pwr */ 1924f1d2b4d3SLarry Finger u8 txpwrlevel_ht40_1s[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; 1925f1d2b4d3SLarry Finger /*For HT 40MHZ pwr */ 1926f1d2b4d3SLarry Finger u8 txpwrlevel_ht40_2s[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; 1927f1d2b4d3SLarry Finger 1928f1d2b4d3SLarry Finger /*--------------------------------------------------------* 1929f1d2b4d3SLarry Finger * 8192CE\8192SE\8192DE\8723AE use the following 4 arrays, 1930f1d2b4d3SLarry Finger * other ICs (8188EE\8723BE\8192EE\8812AE...) 1931f1d2b4d3SLarry Finger * define new arrays in Windows code. 1932f1d2b4d3SLarry Finger * BUT, in linux code, we use the same array for all ICs. 1933f1d2b4d3SLarry Finger * 1934f1d2b4d3SLarry Finger * The Correspondance relation between two arrays is: 1935f1d2b4d3SLarry Finger * txpwr_cckdiff[][] == CCK_24G_Diff[][] 1936f1d2b4d3SLarry Finger * txpwr_ht20diff[][] == BW20_24G_Diff[][] 1937f1d2b4d3SLarry Finger * txpwr_ht40diff[][] == BW40_24G_Diff[][] 1938f1d2b4d3SLarry Finger * txpwr_legacyhtdiff[][] == OFDM_24G_Diff[][] 1939f1d2b4d3SLarry Finger * 1940f1d2b4d3SLarry Finger * Sizes of these arrays are decided by the larger ones. 1941f1d2b4d3SLarry Finger */ 194208aba42fSArnd Bergmann s8 txpwr_cckdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; 194308aba42fSArnd Bergmann s8 txpwr_ht20diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; 194408aba42fSArnd Bergmann s8 txpwr_ht40diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; 194508aba42fSArnd Bergmann s8 txpwr_legacyhtdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; 1946f1d2b4d3SLarry Finger 1947f1d2b4d3SLarry Finger u8 txpwr_5g_bw40base[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; 1948f1d2b4d3SLarry Finger u8 txpwr_5g_bw80base[MAX_RF_PATH][CHANNEL_MAX_NUMBER_5G_80M]; 194908aba42fSArnd Bergmann s8 txpwr_5g_ofdmdiff[MAX_RF_PATH][MAX_TX_COUNT]; 195008aba42fSArnd Bergmann s8 txpwr_5g_bw20diff[MAX_RF_PATH][MAX_TX_COUNT]; 195108aba42fSArnd Bergmann s8 txpwr_5g_bw40diff[MAX_RF_PATH][MAX_TX_COUNT]; 195208aba42fSArnd Bergmann s8 txpwr_5g_bw80diff[MAX_RF_PATH][MAX_TX_COUNT]; 1953f1d2b4d3SLarry Finger 1954f1d2b4d3SLarry Finger u8 txpwr_safetyflag; /* Band edge enable flag */ 1955f1d2b4d3SLarry Finger u16 eeprom_txpowerdiff; 1956f1d2b4d3SLarry Finger u8 antenna_txpwdiff[3]; 1957f1d2b4d3SLarry Finger 1958f1d2b4d3SLarry Finger u8 eeprom_regulatory; 1959f1d2b4d3SLarry Finger u8 eeprom_thermalmeter; 1960f1d2b4d3SLarry Finger u8 thermalmeter[2]; /*ThermalMeter, index 0 for RFIC0, 1 for RFIC1 */ 1961f1d2b4d3SLarry Finger u16 tssi_13dbm; 1962f1d2b4d3SLarry Finger u8 crystalcap; /* CrystalCap. */ 1963f1d2b4d3SLarry Finger u8 delta_iqk; 1964f1d2b4d3SLarry Finger u8 delta_lck; 1965f1d2b4d3SLarry Finger 1966f1d2b4d3SLarry Finger u8 legacy_ht_txpowerdiff; /*Legacy to HT rate power diff */ 1967f1d2b4d3SLarry Finger bool apk_thermalmeterignore; 1968f1d2b4d3SLarry Finger 1969f1d2b4d3SLarry Finger bool b1x1_recvcombine; 1970f1d2b4d3SLarry Finger bool b1ss_support; 1971f1d2b4d3SLarry Finger 1972f1d2b4d3SLarry Finger /*channel plan */ 1973f1d2b4d3SLarry Finger u8 channel_plan; 1974f1d2b4d3SLarry Finger }; 1975f1d2b4d3SLarry Finger 19762cdd634eSPing-Ke Shih struct rtl_efuse_ops { 19772cdd634eSPing-Ke Shih int (*efuse_onebyte_read)(struct ieee80211_hw *hw, u16 addr, u8 *data); 19782cdd634eSPing-Ke Shih void (*efuse_logical_map_read)(struct ieee80211_hw *hw, u8 type, 19792cdd634eSPing-Ke Shih u16 offset, u32 *value); 19802cdd634eSPing-Ke Shih }; 19812cdd634eSPing-Ke Shih 19828479580bSPing-Ke Shih struct rtl_tx_report { 19838479580bSPing-Ke Shih atomic_t sn; 19848479580bSPing-Ke Shih u16 last_sent_sn; 19858479580bSPing-Ke Shih unsigned long last_sent_time; 19868479580bSPing-Ke Shih u16 last_recv_sn; 19876acfbb81STzu-En Huang struct sk_buff_head queue; 19888479580bSPing-Ke Shih }; 19898479580bSPing-Ke Shih 1990f1d2b4d3SLarry Finger struct rtl_ps_ctl { 1991f1d2b4d3SLarry Finger bool pwrdomain_protect; 1992f1d2b4d3SLarry Finger bool in_powersavemode; 1993f1d2b4d3SLarry Finger bool rfchange_inprogress; 1994f1d2b4d3SLarry Finger bool swrf_processing; 1995f1d2b4d3SLarry Finger bool hwradiooff; 1996d3da329cSLarry Finger /* just for PCIE ASPM 1997f1d2b4d3SLarry Finger * If it supports ASPM, Offset[560h] = 0x40, 1998f1d2b4d3SLarry Finger * otherwise Offset[560h] = 0x00. 1999d3da329cSLarry Finger */ 2000f1d2b4d3SLarry Finger bool support_aspm; 2001f1d2b4d3SLarry Finger bool support_backdoor; 2002f1d2b4d3SLarry Finger 2003f1d2b4d3SLarry Finger /*for LPS */ 2004f1d2b4d3SLarry Finger enum rt_psmode dot11_psmode; /*Power save mode configured. */ 2005f1d2b4d3SLarry Finger bool swctrl_lps; 2006f1d2b4d3SLarry Finger bool leisure_ps; 2007f1d2b4d3SLarry Finger bool fwctrl_lps; 2008f1d2b4d3SLarry Finger u8 fwctrl_psmode; 2009f1d2b4d3SLarry Finger /*For Fw control LPS mode */ 2010f1d2b4d3SLarry Finger u8 reg_fwctrl_lps; 2011f1d2b4d3SLarry Finger /*Record Fw PS mode status. */ 2012f1d2b4d3SLarry Finger bool fw_current_inpsmode; 2013f1d2b4d3SLarry Finger u8 reg_max_lps_awakeintvl; 2014f1d2b4d3SLarry Finger bool report_linked; 2015f1d2b4d3SLarry Finger bool low_power_enable;/*for 32k*/ 2016f1d2b4d3SLarry Finger 2017f1d2b4d3SLarry Finger /*for IPS */ 2018f1d2b4d3SLarry Finger bool inactiveps; 2019f1d2b4d3SLarry Finger 2020f1d2b4d3SLarry Finger u32 rfoff_reason; 2021f1d2b4d3SLarry Finger 2022f1d2b4d3SLarry Finger /*RF OFF Level */ 2023f1d2b4d3SLarry Finger u32 cur_ps_level; 2024f1d2b4d3SLarry Finger u32 reg_rfps_level; 2025f1d2b4d3SLarry Finger 2026f1d2b4d3SLarry Finger /*just for PCIE ASPM */ 2027f1d2b4d3SLarry Finger u8 const_amdpci_aspm; 2028f1d2b4d3SLarry Finger bool pwrdown_mode; 2029f1d2b4d3SLarry Finger 2030f1d2b4d3SLarry Finger enum rf_pwrstate inactive_pwrstate; 2031f1d2b4d3SLarry Finger enum rf_pwrstate rfpwr_state; /*cur power state */ 2032f1d2b4d3SLarry Finger 2033f1d2b4d3SLarry Finger /* for SW LPS*/ 2034f1d2b4d3SLarry Finger bool sw_ps_enabled; 2035f1d2b4d3SLarry Finger bool state; 2036f1d2b4d3SLarry Finger bool state_inap; 2037f1d2b4d3SLarry Finger bool multi_buffered; 2038f1d2b4d3SLarry Finger u16 nullfunc_seq; 2039f1d2b4d3SLarry Finger unsigned int dtim_counter; 2040f1d2b4d3SLarry Finger unsigned int sleep_ms; 2041f1d2b4d3SLarry Finger unsigned long last_sleep_jiffies; 2042f1d2b4d3SLarry Finger unsigned long last_awake_jiffies; 2043f1d2b4d3SLarry Finger unsigned long last_delaylps_stamp_jiffies; 2044f1d2b4d3SLarry Finger unsigned long last_dtim; 2045f1d2b4d3SLarry Finger unsigned long last_beacon; 2046f1d2b4d3SLarry Finger unsigned long last_action; 2047f1d2b4d3SLarry Finger unsigned long last_slept; 2048f1d2b4d3SLarry Finger 2049f1d2b4d3SLarry Finger /*For P2P PS */ 2050f1d2b4d3SLarry Finger struct rtl_p2p_ps_info p2p_ps_info; 2051f1d2b4d3SLarry Finger u8 pwr_mode; 2052f1d2b4d3SLarry Finger u8 smart_ps; 2053f1d2b4d3SLarry Finger 2054f1d2b4d3SLarry Finger /* wake up on line */ 2055f1d2b4d3SLarry Finger u8 wo_wlan_mode; 2056f1d2b4d3SLarry Finger u8 arp_offload_enable; 2057f1d2b4d3SLarry Finger u8 gtk_offload_enable; 2058f1d2b4d3SLarry Finger /* Used for WOL, indicates the reason for waking event.*/ 2059f1d2b4d3SLarry Finger u32 wakeup_reason; 2060f1d2b4d3SLarry Finger }; 2061f1d2b4d3SLarry Finger 2062f1d2b4d3SLarry Finger struct rtl_stats { 2063f1d2b4d3SLarry Finger u8 psaddr[ETH_ALEN]; 2064f1d2b4d3SLarry Finger u32 mac_time[2]; 2065f1d2b4d3SLarry Finger s8 rssi; 2066f1d2b4d3SLarry Finger u8 signal; 2067f1d2b4d3SLarry Finger u8 noise; 2068f1d2b4d3SLarry Finger u8 rate; /* hw desc rate */ 2069f1d2b4d3SLarry Finger u8 received_channel; 2070f1d2b4d3SLarry Finger u8 control; 2071f1d2b4d3SLarry Finger u8 mask; 2072f1d2b4d3SLarry Finger u8 freq; 2073f1d2b4d3SLarry Finger u16 len; 2074f1d2b4d3SLarry Finger u64 tsf; 2075f1d2b4d3SLarry Finger u32 beacon_time; 2076f1d2b4d3SLarry Finger u8 nic_type; 2077f1d2b4d3SLarry Finger u16 length; 2078f1d2b4d3SLarry Finger u8 signalquality; /*in 0-100 index. */ 2079d3da329cSLarry Finger /* Real power in dBm for this packet, 2080f1d2b4d3SLarry Finger * no beautification and aggregation. 2081d3da329cSLarry Finger */ 2082f1d2b4d3SLarry Finger s32 recvsignalpower; 2083f1d2b4d3SLarry Finger s8 rxpower; /*in dBm Translate from PWdB */ 2084f1d2b4d3SLarry Finger u8 signalstrength; /*in 0-100 index. */ 2085f1d2b4d3SLarry Finger u16 hwerror:1; 2086f1d2b4d3SLarry Finger u16 crc:1; 2087f1d2b4d3SLarry Finger u16 icv:1; 2088f1d2b4d3SLarry Finger u16 shortpreamble:1; 2089f1d2b4d3SLarry Finger u16 antenna:1; 2090f1d2b4d3SLarry Finger u16 decrypted:1; 2091f1d2b4d3SLarry Finger u16 wakeup:1; 2092f1d2b4d3SLarry Finger u32 timestamp_low; 2093f1d2b4d3SLarry Finger u32 timestamp_high; 2094f1d2b4d3SLarry Finger bool shift; 2095f1d2b4d3SLarry Finger 2096f1d2b4d3SLarry Finger u8 rx_drvinfo_size; 2097f1d2b4d3SLarry Finger u8 rx_bufshift; 2098f1d2b4d3SLarry Finger bool isampdu; 2099f1d2b4d3SLarry Finger bool isfirst_ampdu; 2100e703c5ddSLarry Finger bool rx_is40mhzpacket; 2101f1d2b4d3SLarry Finger u8 rx_packet_bw; 2102f1d2b4d3SLarry Finger u32 rx_pwdb_all; 2103f1d2b4d3SLarry Finger u8 rx_mimo_signalstrength[4]; /*in 0~100 index */ 2104f1d2b4d3SLarry Finger s8 rx_mimo_signalquality[4]; 2105f1d2b4d3SLarry Finger u8 rx_mimo_evm_dbm[4]; 2106f1d2b4d3SLarry Finger u16 cfo_short[4]; /* per-path's Cfo_short */ 2107f1d2b4d3SLarry Finger u16 cfo_tail[4]; 2108f1d2b4d3SLarry Finger 2109f1d2b4d3SLarry Finger s8 rx_mimo_sig_qual[4]; 2110f1d2b4d3SLarry Finger u8 rx_pwr[4]; /* per-path's pwdb */ 2111f1d2b4d3SLarry Finger u8 rx_snr[4]; /* per-path's SNR */ 2112f1d2b4d3SLarry Finger u8 bandwidth; 2113f1d2b4d3SLarry Finger u8 bt_coex_pwr_adjust; 2114f1d2b4d3SLarry Finger bool packet_matchbssid; 2115f1d2b4d3SLarry Finger bool is_cck; 2116f1d2b4d3SLarry Finger bool is_ht; 2117f1d2b4d3SLarry Finger bool packet_toself; 2118f1d2b4d3SLarry Finger bool packet_beacon; /*for rssi */ 211908aba42fSArnd Bergmann s8 cck_adc_pwdb[4]; /*for rx path selection */ 2120f1d2b4d3SLarry Finger 2121f1d2b4d3SLarry Finger bool is_vht; 2122f1d2b4d3SLarry Finger bool is_short_gi; 2123f1d2b4d3SLarry Finger u8 vht_nss; 2124f1d2b4d3SLarry Finger 2125f1d2b4d3SLarry Finger u8 packet_report_type; 2126f1d2b4d3SLarry Finger 2127f1d2b4d3SLarry Finger u32 macid; 2128f1d2b4d3SLarry Finger u32 bt_rx_rssi_percentage; 2129f1d2b4d3SLarry Finger u32 macid_valid_entry[2]; 2130f1d2b4d3SLarry Finger }; 2131f1d2b4d3SLarry Finger 2132f1d2b4d3SLarry Finger struct rt_link_detect { 2133f1d2b4d3SLarry Finger /* count for roaming */ 2134f1d2b4d3SLarry Finger u32 bcn_rx_inperiod; 2135f1d2b4d3SLarry Finger u32 roam_times; 2136f1d2b4d3SLarry Finger 2137f1d2b4d3SLarry Finger u32 num_tx_in4period[4]; 2138f1d2b4d3SLarry Finger u32 num_rx_in4period[4]; 2139f1d2b4d3SLarry Finger 2140f1d2b4d3SLarry Finger u32 num_tx_inperiod; 2141f1d2b4d3SLarry Finger u32 num_rx_inperiod; 2142f1d2b4d3SLarry Finger 2143f1d2b4d3SLarry Finger bool busytraffic; 2144f1d2b4d3SLarry Finger bool tx_busy_traffic; 2145f1d2b4d3SLarry Finger bool rx_busy_traffic; 2146f1d2b4d3SLarry Finger bool higher_busytraffic; 2147f1d2b4d3SLarry Finger bool higher_busyrxtraffic; 2148f1d2b4d3SLarry Finger 2149f1d2b4d3SLarry Finger u32 tidtx_in4period[MAX_TID_COUNT][4]; 2150f1d2b4d3SLarry Finger u32 tidtx_inperiod[MAX_TID_COUNT]; 2151f1d2b4d3SLarry Finger bool higher_busytxtraffic[MAX_TID_COUNT]; 2152f1d2b4d3SLarry Finger }; 2153f1d2b4d3SLarry Finger 2154f1d2b4d3SLarry Finger struct rtl_tcb_desc { 2155f1d2b4d3SLarry Finger u8 packet_bw:2; 2156f1d2b4d3SLarry Finger u8 multicast:1; 2157f1d2b4d3SLarry Finger u8 broadcast:1; 2158f1d2b4d3SLarry Finger 2159f1d2b4d3SLarry Finger u8 rts_stbc:1; 2160f1d2b4d3SLarry Finger u8 rts_enable:1; 2161f1d2b4d3SLarry Finger u8 cts_enable:1; 2162f1d2b4d3SLarry Finger u8 rts_use_shortpreamble:1; 2163f1d2b4d3SLarry Finger u8 rts_use_shortgi:1; 2164f1d2b4d3SLarry Finger u8 rts_sc:1; 2165f1d2b4d3SLarry Finger u8 rts_bw:1; 2166f1d2b4d3SLarry Finger u8 rts_rate; 2167f1d2b4d3SLarry Finger 2168f1d2b4d3SLarry Finger u8 use_shortgi:1; 2169f1d2b4d3SLarry Finger u8 use_shortpreamble:1; 2170f1d2b4d3SLarry Finger u8 use_driver_rate:1; 2171f1d2b4d3SLarry Finger u8 disable_ratefallback:1; 2172f1d2b4d3SLarry Finger 21738479580bSPing-Ke Shih u8 use_spe_rpt:1; 21748479580bSPing-Ke Shih 2175f1d2b4d3SLarry Finger u8 ratr_index; 2176f1d2b4d3SLarry Finger u8 mac_id; 2177f1d2b4d3SLarry Finger u8 hw_rate; 2178f1d2b4d3SLarry Finger 2179f1d2b4d3SLarry Finger u8 last_inipkt:1; 2180f1d2b4d3SLarry Finger u8 cmd_or_init:1; 2181f1d2b4d3SLarry Finger u8 queue_index; 2182f1d2b4d3SLarry Finger 2183f1d2b4d3SLarry Finger /* early mode */ 2184f1d2b4d3SLarry Finger u8 empkt_num; 2185f1d2b4d3SLarry Finger /* The max value by HW */ 2186f1d2b4d3SLarry Finger u32 empkt_len[10]; 2187f1d2b4d3SLarry Finger bool tx_enable_sw_calc_duration; 2188f1d2b4d3SLarry Finger }; 2189f1d2b4d3SLarry Finger 2190f1d2b4d3SLarry Finger struct rtl_wow_pattern { 2191f1d2b4d3SLarry Finger u8 type; 2192f1d2b4d3SLarry Finger u16 crc; 2193f1d2b4d3SLarry Finger u32 mask[4]; 2194f1d2b4d3SLarry Finger }; 2195f1d2b4d3SLarry Finger 219678aa6012SLarry Finger /* struct to store contents of interrupt vectors */ 219778aa6012SLarry Finger struct rtl_int { 219878aa6012SLarry Finger u32 inta; 219978aa6012SLarry Finger u32 intb; 220078aa6012SLarry Finger u32 intc; 220178aa6012SLarry Finger u32 intd; 220278aa6012SLarry Finger }; 220378aa6012SLarry Finger 2204f1d2b4d3SLarry Finger struct rtl_hal_ops { 2205f1d2b4d3SLarry Finger int (*init_sw_vars)(struct ieee80211_hw *hw); 2206f1d2b4d3SLarry Finger void (*deinit_sw_vars)(struct ieee80211_hw *hw); 2207f1d2b4d3SLarry Finger void (*read_chip_version)(struct ieee80211_hw *hw); 2208f1d2b4d3SLarry Finger void (*read_eeprom_info)(struct ieee80211_hw *hw); 2209f1d2b4d3SLarry Finger void (*interrupt_recognized)(struct ieee80211_hw *hw, 221078aa6012SLarry Finger struct rtl_int *intvec); 2211f1d2b4d3SLarry Finger int (*hw_init)(struct ieee80211_hw *hw); 2212f1d2b4d3SLarry Finger void (*hw_disable)(struct ieee80211_hw *hw); 2213f1d2b4d3SLarry Finger void (*hw_suspend)(struct ieee80211_hw *hw); 2214f1d2b4d3SLarry Finger void (*hw_resume)(struct ieee80211_hw *hw); 2215f1d2b4d3SLarry Finger void (*enable_interrupt)(struct ieee80211_hw *hw); 2216f1d2b4d3SLarry Finger void (*disable_interrupt)(struct ieee80211_hw *hw); 2217f1d2b4d3SLarry Finger int (*set_network_type)(struct ieee80211_hw *hw, 2218f1d2b4d3SLarry Finger enum nl80211_iftype type); 2219f1d2b4d3SLarry Finger void (*set_chk_bssid)(struct ieee80211_hw *hw, 2220f1d2b4d3SLarry Finger bool check_bssid); 2221f1d2b4d3SLarry Finger void (*set_bw_mode)(struct ieee80211_hw *hw, 2222f1d2b4d3SLarry Finger enum nl80211_channel_type ch_type); 2223f1d2b4d3SLarry Finger u8 (*switch_channel)(struct ieee80211_hw *hw); 2224f1d2b4d3SLarry Finger void (*set_qos)(struct ieee80211_hw *hw, int aci); 2225f1d2b4d3SLarry Finger void (*set_bcn_reg)(struct ieee80211_hw *hw); 2226f1d2b4d3SLarry Finger void (*set_bcn_intv)(struct ieee80211_hw *hw); 2227f1d2b4d3SLarry Finger void (*update_interrupt_mask)(struct ieee80211_hw *hw, 2228f1d2b4d3SLarry Finger u32 add_msr, u32 rm_msr); 2229f1d2b4d3SLarry Finger void (*get_hw_reg)(struct ieee80211_hw *hw, u8 variable, u8 *val); 2230f1d2b4d3SLarry Finger void (*set_hw_reg)(struct ieee80211_hw *hw, u8 variable, u8 *val); 2231f1d2b4d3SLarry Finger void (*update_rate_tbl)(struct ieee80211_hw *hw, 22321d22b177SPing-Ke Shih struct ieee80211_sta *sta, u8 rssi_leve, 22331d22b177SPing-Ke Shih bool update_bw); 2234f1d2b4d3SLarry Finger void (*pre_fill_tx_bd_desc)(struct ieee80211_hw *hw, u8 *tx_bd_desc, 2235f1d2b4d3SLarry Finger u8 *desc, u8 queue_index, 2236f1d2b4d3SLarry Finger struct sk_buff *skb, dma_addr_t addr); 2237f1d2b4d3SLarry Finger void (*update_rate_mask)(struct ieee80211_hw *hw, u8 rssi_level); 2238f1d2b4d3SLarry Finger u16 (*rx_desc_buff_remained_cnt)(struct ieee80211_hw *hw, 2239f1d2b4d3SLarry Finger u8 queue_index); 2240f1d2b4d3SLarry Finger void (*rx_check_dma_ok)(struct ieee80211_hw *hw, u8 *header_desc, 2241f1d2b4d3SLarry Finger u8 queue_index); 2242f1d2b4d3SLarry Finger void (*fill_tx_desc)(struct ieee80211_hw *hw, 2243f1d2b4d3SLarry Finger struct ieee80211_hdr *hdr, u8 *pdesc_tx, 2244f1d2b4d3SLarry Finger u8 *pbd_desc_tx, 2245f1d2b4d3SLarry Finger struct ieee80211_tx_info *info, 2246f1d2b4d3SLarry Finger struct ieee80211_sta *sta, 2247f1d2b4d3SLarry Finger struct sk_buff *skb, u8 hw_queue, 2248f1d2b4d3SLarry Finger struct rtl_tcb_desc *ptcb_desc); 2249e703c5ddSLarry Finger void (*fill_fake_txdesc)(struct ieee80211_hw *hw, u8 *pdesc, 2250e703c5ddSLarry Finger u32 buffer_len, bool bsspspoll); 2251f1d2b4d3SLarry Finger void (*fill_tx_cmddesc)(struct ieee80211_hw *hw, u8 *pdesc, 2252f1d2b4d3SLarry Finger bool firstseg, bool lastseg, 2253f1d2b4d3SLarry Finger struct sk_buff *skb); 225489d3e8abSPing-Ke Shih void (*fill_tx_special_desc)(struct ieee80211_hw *hw, 225589d3e8abSPing-Ke Shih u8 *pdesc, u8 *pbd_desc, 225689d3e8abSPing-Ke Shih struct sk_buff *skb, u8 hw_queue); 2257f1d2b4d3SLarry Finger bool (*query_rx_desc)(struct ieee80211_hw *hw, 2258f1d2b4d3SLarry Finger struct rtl_stats *stats, 2259f1d2b4d3SLarry Finger struct ieee80211_rx_status *rx_status, 2260f1d2b4d3SLarry Finger u8 *pdesc, struct sk_buff *skb); 2261f1d2b4d3SLarry Finger void (*set_channel_access)(struct ieee80211_hw *hw); 2262f1d2b4d3SLarry Finger bool (*radio_onoff_checking)(struct ieee80211_hw *hw, u8 *valid); 2263f1d2b4d3SLarry Finger void (*dm_watchdog)(struct ieee80211_hw *hw); 2264f1d2b4d3SLarry Finger void (*scan_operation_backup)(struct ieee80211_hw *hw, u8 operation); 2265f1d2b4d3SLarry Finger bool (*set_rf_power_state)(struct ieee80211_hw *hw, 2266f1d2b4d3SLarry Finger enum rf_pwrstate rfpwr_state); 2267f1d2b4d3SLarry Finger void (*led_control)(struct ieee80211_hw *hw, 2268f1d2b4d3SLarry Finger enum led_ctl_mode ledaction); 2269f1d2b4d3SLarry Finger void (*set_desc)(struct ieee80211_hw *hw, u8 *pdesc, bool istx, 2270f1d2b4d3SLarry Finger u8 desc_name, u8 *val); 22710c07bd74SPing-Ke Shih u64 (*get_desc)(struct ieee80211_hw *hw, u8 *pdesc, bool istx, 22720c07bd74SPing-Ke Shih u8 desc_name); 2273f1d2b4d3SLarry Finger bool (*is_tx_desc_closed)(struct ieee80211_hw *hw, 2274f1d2b4d3SLarry Finger u8 hw_queue, u16 index); 2275f1d2b4d3SLarry Finger void (*tx_polling)(struct ieee80211_hw *hw, u8 hw_queue); 2276f1d2b4d3SLarry Finger void (*enable_hw_sec)(struct ieee80211_hw *hw); 2277f1d2b4d3SLarry Finger void (*set_key)(struct ieee80211_hw *hw, u32 key_index, 2278f1d2b4d3SLarry Finger u8 *macaddr, bool is_group, u8 enc_algo, 2279f1d2b4d3SLarry Finger bool is_wepkey, bool clear_all); 2280f1d2b4d3SLarry Finger u32 (*get_bbreg)(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask); 2281f1d2b4d3SLarry Finger void (*set_bbreg)(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask, 2282f1d2b4d3SLarry Finger u32 data); 2283f1d2b4d3SLarry Finger u32 (*get_rfreg)(struct ieee80211_hw *hw, enum radio_path rfpath, 2284f1d2b4d3SLarry Finger u32 regaddr, u32 bitmask); 2285f1d2b4d3SLarry Finger void (*set_rfreg)(struct ieee80211_hw *hw, enum radio_path rfpath, 2286f1d2b4d3SLarry Finger u32 regaddr, u32 bitmask, u32 data); 2287f1d2b4d3SLarry Finger void (*linked_set_reg)(struct ieee80211_hw *hw); 2288f1d2b4d3SLarry Finger void (*chk_switch_dmdp)(struct ieee80211_hw *hw); 2289f1d2b4d3SLarry Finger void (*dualmac_switch_to_dmdp)(struct ieee80211_hw *hw); 2290f1d2b4d3SLarry Finger bool (*phy_rf6052_config)(struct ieee80211_hw *hw); 2291f1d2b4d3SLarry Finger void (*phy_rf6052_set_cck_txpower)(struct ieee80211_hw *hw, 2292f1d2b4d3SLarry Finger u8 *powerlevel); 2293f1d2b4d3SLarry Finger void (*phy_rf6052_set_ofdm_txpower)(struct ieee80211_hw *hw, 2294f1d2b4d3SLarry Finger u8 *ppowerlevel, u8 channel); 2295f1d2b4d3SLarry Finger bool (*config_bb_with_headerfile)(struct ieee80211_hw *hw, 2296f1d2b4d3SLarry Finger u8 configtype); 2297f1d2b4d3SLarry Finger bool (*config_bb_with_pgheaderfile)(struct ieee80211_hw *hw, 2298f1d2b4d3SLarry Finger u8 configtype); 2299f1d2b4d3SLarry Finger void (*phy_lc_calibrate)(struct ieee80211_hw *hw, bool is2t); 2300f1d2b4d3SLarry Finger void (*phy_set_bw_mode_callback)(struct ieee80211_hw *hw); 2301f1d2b4d3SLarry Finger void (*dm_dynamic_txpower)(struct ieee80211_hw *hw); 2302f1d2b4d3SLarry Finger void (*c2h_command_handle)(struct ieee80211_hw *hw); 2303f1d2b4d3SLarry Finger void (*bt_wifi_media_status_notify)(struct ieee80211_hw *hw, 2304f1d2b4d3SLarry Finger bool mstate); 2305f1d2b4d3SLarry Finger void (*bt_coex_off_before_lps)(struct ieee80211_hw *hw); 2306f1d2b4d3SLarry Finger void (*fill_h2c_cmd)(struct ieee80211_hw *hw, u8 element_id, 2307f1d2b4d3SLarry Finger u32 cmd_len, u8 *p_cmdbuffer); 2308d7297a86SPing-Ke Shih void (*set_default_port_id_cmd)(struct ieee80211_hw *hw); 2309f1d2b4d3SLarry Finger bool (*get_btc_status)(void); 2310f1d2b4d3SLarry Finger bool (*is_fw_header)(struct rtlwifi_firmware_header *hdr); 2311f1d2b4d3SLarry Finger void (*add_wowlan_pattern)(struct ieee80211_hw *hw, 2312f1d2b4d3SLarry Finger struct rtl_wow_pattern *rtl_pattern, 2313f1d2b4d3SLarry Finger u8 index); 2314f1d2b4d3SLarry Finger u16 (*get_available_desc)(struct ieee80211_hw *hw, u8 q_idx); 231516cefa44SPing-Ke Shih void (*c2h_ra_report_handler)(struct ieee80211_hw *hw, 231616cefa44SPing-Ke Shih u8 *cmd_buf, u8 cmd_len); 2317f1d2b4d3SLarry Finger }; 2318f1d2b4d3SLarry Finger 2319f1d2b4d3SLarry Finger struct rtl_intf_ops { 2320f1d2b4d3SLarry Finger /*com */ 2321f1d2b4d3SLarry Finger void (*read_efuse_byte)(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf); 2322f1d2b4d3SLarry Finger int (*adapter_start)(struct ieee80211_hw *hw); 2323f1d2b4d3SLarry Finger void (*adapter_stop)(struct ieee80211_hw *hw); 2324f1d2b4d3SLarry Finger bool (*check_buddy_priv)(struct ieee80211_hw *hw, 2325f1d2b4d3SLarry Finger struct rtl_priv **buddy_priv); 2326f1d2b4d3SLarry Finger 2327f1d2b4d3SLarry Finger int (*adapter_tx)(struct ieee80211_hw *hw, 2328f1d2b4d3SLarry Finger struct ieee80211_sta *sta, 2329f1d2b4d3SLarry Finger struct sk_buff *skb, 2330f1d2b4d3SLarry Finger struct rtl_tcb_desc *ptcb_desc); 2331f1d2b4d3SLarry Finger void (*flush)(struct ieee80211_hw *hw, u32 queues, bool drop); 2332f1d2b4d3SLarry Finger int (*reset_trx_ring)(struct ieee80211_hw *hw); 2333f1d2b4d3SLarry Finger bool (*waitq_insert)(struct ieee80211_hw *hw, 2334f1d2b4d3SLarry Finger struct ieee80211_sta *sta, 2335f1d2b4d3SLarry Finger struct sk_buff *skb); 2336f1d2b4d3SLarry Finger 2337f1d2b4d3SLarry Finger /*pci */ 2338f1d2b4d3SLarry Finger void (*disable_aspm)(struct ieee80211_hw *hw); 2339f1d2b4d3SLarry Finger void (*enable_aspm)(struct ieee80211_hw *hw); 2340f1d2b4d3SLarry Finger 2341f1d2b4d3SLarry Finger /*usb */ 2342f1d2b4d3SLarry Finger }; 2343f1d2b4d3SLarry Finger 2344f1d2b4d3SLarry Finger struct rtl_mod_params { 2345c34df318SLarry Finger /* default: 0,0 */ 2346c34df318SLarry Finger u64 debug_mask; 2347f1d2b4d3SLarry Finger /* default: 0 = using hardware encryption */ 2348f1d2b4d3SLarry Finger bool sw_crypto; 2349f1d2b4d3SLarry Finger 2350f1d2b4d3SLarry Finger /* default: 0 = DBG_EMERG (0)*/ 2351c34df318SLarry Finger int debug_level; 2352f1d2b4d3SLarry Finger 2353f1d2b4d3SLarry Finger /* default: 1 = using no linked power save */ 2354f1d2b4d3SLarry Finger bool inactiveps; 2355f1d2b4d3SLarry Finger 2356f1d2b4d3SLarry Finger /* default: 1 = using linked sw power save */ 2357f1d2b4d3SLarry Finger bool swctrl_lps; 2358f1d2b4d3SLarry Finger 2359f1d2b4d3SLarry Finger /* default: 1 = using linked fw power save */ 2360f1d2b4d3SLarry Finger bool fwctrl_lps; 2361f1d2b4d3SLarry Finger 2362f1d2b4d3SLarry Finger /* default: 0 = not using MSI interrupts mode 2363f1d2b4d3SLarry Finger * submodules should set their own default value 2364f1d2b4d3SLarry Finger */ 2365f1d2b4d3SLarry Finger bool msi_support; 2366f1d2b4d3SLarry Finger 23670c07bd74SPing-Ke Shih /* default: 0 = dma 32 */ 23680c07bd74SPing-Ke Shih bool dma64; 23690c07bd74SPing-Ke Shih 237084efbad4SPing-Ke Shih /* default: 1 = enable aspm */ 237184efbad4SPing-Ke Shih int aspm_support; 237284efbad4SPing-Ke Shih 2373f1d2b4d3SLarry Finger /* default 0: 1 means disable */ 2374f1d2b4d3SLarry Finger bool disable_watchdog; 2375d59542ddSDavid S. Miller 2376d59542ddSDavid S. Miller /* default 0: 1 means do not disable interrupts */ 2377d59542ddSDavid S. Miller bool int_clear; 2378c18d8f50SLarry Finger 2379c18d8f50SLarry Finger /* select antenna */ 2380c18d8f50SLarry Finger int ant_sel; 2381f1d2b4d3SLarry Finger }; 2382f1d2b4d3SLarry Finger 2383f1d2b4d3SLarry Finger struct rtl_hal_usbint_cfg { 2384f1d2b4d3SLarry Finger /* data - rx */ 2385f1d2b4d3SLarry Finger u32 in_ep_num; 2386f1d2b4d3SLarry Finger u32 rx_urb_num; 2387f1d2b4d3SLarry Finger u32 rx_max_size; 2388f1d2b4d3SLarry Finger 2389f1d2b4d3SLarry Finger /* op - rx */ 2390f1d2b4d3SLarry Finger void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *); 2391f1d2b4d3SLarry Finger void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *, 2392f1d2b4d3SLarry Finger struct sk_buff_head *); 2393f1d2b4d3SLarry Finger 2394f1d2b4d3SLarry Finger /* tx */ 2395f1d2b4d3SLarry Finger void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *); 2396f1d2b4d3SLarry Finger int (*usb_tx_post_hdl)(struct ieee80211_hw *, struct urb *, 2397f1d2b4d3SLarry Finger struct sk_buff *); 2398f1d2b4d3SLarry Finger struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *, 2399f1d2b4d3SLarry Finger struct sk_buff_head *); 2400f1d2b4d3SLarry Finger 2401f1d2b4d3SLarry Finger /* endpoint mapping */ 2402f1d2b4d3SLarry Finger int (*usb_endpoint_mapping)(struct ieee80211_hw *hw); 2403f1d2b4d3SLarry Finger u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index); 2404f1d2b4d3SLarry Finger }; 2405f1d2b4d3SLarry Finger 2406f1d2b4d3SLarry Finger struct rtl_hal_cfg { 2407f1d2b4d3SLarry Finger u8 bar_id; 2408f1d2b4d3SLarry Finger bool write_readback; 2409f1d2b4d3SLarry Finger char *name; 2410f1d2b4d3SLarry Finger char *alt_fw_name; 2411f1d2b4d3SLarry Finger struct rtl_hal_ops *ops; 2412f1d2b4d3SLarry Finger struct rtl_mod_params *mod_params; 2413f1d2b4d3SLarry Finger struct rtl_hal_usbint_cfg *usb_interface_cfg; 2414a75f3eebSPing-Ke Shih enum rtl_spec_ver spec_ver; 2415f1d2b4d3SLarry Finger 2416f1d2b4d3SLarry Finger /*this map used for some registers or vars 2417d3da329cSLarry Finger * defined int HAL but used in MAIN 2418d3da329cSLarry Finger */ 2419f1d2b4d3SLarry Finger u32 maps[RTL_VAR_MAP_MAX]; 2420f1d2b4d3SLarry Finger 2421f1d2b4d3SLarry Finger }; 2422f1d2b4d3SLarry Finger 2423f1d2b4d3SLarry Finger struct rtl_locks { 2424f1d2b4d3SLarry Finger /* mutex */ 2425f1d2b4d3SLarry Finger struct mutex conf_mutex; 2426a3fa3669SPing-Ke Shih struct mutex ips_mutex; /* mutex for enter/leave IPS */ 2427a3fa3669SPing-Ke Shih struct mutex lps_mutex; /* mutex for enter/leave LPS */ 2428f1d2b4d3SLarry Finger 2429f1d2b4d3SLarry Finger /*spin lock */ 2430f1d2b4d3SLarry Finger spinlock_t irq_th_lock; 2431f1d2b4d3SLarry Finger spinlock_t h2c_lock; 2432f1d2b4d3SLarry Finger spinlock_t rf_ps_lock; 2433f1d2b4d3SLarry Finger spinlock_t rf_lock; 2434f1d2b4d3SLarry Finger spinlock_t waitq_lock; 2435f1d2b4d3SLarry Finger spinlock_t entry_list_lock; 2436f1d2b4d3SLarry Finger spinlock_t usb_lock; 2437c76ab8e7SPing-Ke Shih spinlock_t scan_list_lock; /* lock for the scan list */ 2438f1d2b4d3SLarry Finger 2439f1d2b4d3SLarry Finger /*FW clock change */ 2440f1d2b4d3SLarry Finger spinlock_t fw_ps_lock; 2441f1d2b4d3SLarry Finger 2442f1d2b4d3SLarry Finger /*Dual mac*/ 2443f1d2b4d3SLarry Finger spinlock_t cck_and_rw_pagea_lock; 2444f1d2b4d3SLarry Finger 2445f1d2b4d3SLarry Finger spinlock_t iqk_lock; 2446f1d2b4d3SLarry Finger }; 2447f1d2b4d3SLarry Finger 2448f1d2b4d3SLarry Finger struct rtl_works { 2449f1d2b4d3SLarry Finger struct ieee80211_hw *hw; 2450f1d2b4d3SLarry Finger 2451f1d2b4d3SLarry Finger /*timer */ 2452f1d2b4d3SLarry Finger struct timer_list watchdog_timer; 2453f1d2b4d3SLarry Finger struct timer_list fw_clockoff_timer; 2454f1d2b4d3SLarry Finger struct timer_list fast_antenna_training_timer; 2455f1d2b4d3SLarry Finger /*task */ 2456f1d2b4d3SLarry Finger struct tasklet_struct irq_tasklet; 2457f1d2b4d3SLarry Finger struct tasklet_struct irq_prepare_bcn_tasklet; 2458f1d2b4d3SLarry Finger 2459f1d2b4d3SLarry Finger /*work queue */ 2460f1d2b4d3SLarry Finger struct workqueue_struct *rtl_wq; 2461f1d2b4d3SLarry Finger struct delayed_work watchdog_wq; 2462f1d2b4d3SLarry Finger struct delayed_work ips_nic_off_wq; 2463cceb0a59SPing-Ke Shih struct delayed_work c2hcmd_wq; 2464f1d2b4d3SLarry Finger 2465f1d2b4d3SLarry Finger /* For SW LPS */ 2466f1d2b4d3SLarry Finger struct delayed_work ps_work; 2467f1d2b4d3SLarry Finger struct delayed_work ps_rfon_wq; 2468f1d2b4d3SLarry Finger struct delayed_work fwevt_wq; 2469f1d2b4d3SLarry Finger 2470f1d2b4d3SLarry Finger struct work_struct lps_change_work; 2471f1d2b4d3SLarry Finger struct work_struct fill_h2c_cmd; 2472afda3349SPing-Ke Shih struct work_struct update_beacon_work; 2473f1d2b4d3SLarry Finger }; 2474f1d2b4d3SLarry Finger 2475610247f4SPing-Ke Shih struct rtl_debug { 2476610247f4SPing-Ke Shih /* add for debug */ 2477610247f4SPing-Ke Shih struct dentry *debugfs_dir; 2478610247f4SPing-Ke Shih char debugfs_name[20]; 2479610247f4SPing-Ke Shih }; 2480610247f4SPing-Ke Shih 2481f1d2b4d3SLarry Finger #define MIMO_PS_STATIC 0 2482f1d2b4d3SLarry Finger #define MIMO_PS_DYNAMIC 1 2483f1d2b4d3SLarry Finger #define MIMO_PS_NOLIMIT 3 2484f1d2b4d3SLarry Finger 2485f1d2b4d3SLarry Finger struct rtl_dmsp_ctl { 2486f1d2b4d3SLarry Finger bool activescan_for_slaveofdmsp; 2487f1d2b4d3SLarry Finger bool scan_for_anothermac_fordmsp; 2488f1d2b4d3SLarry Finger bool scan_for_itself_fordmsp; 2489f1d2b4d3SLarry Finger bool writedig_for_anothermacofdmsp; 2490f1d2b4d3SLarry Finger u32 curdigvalue_for_anothermacofdmsp; 2491f1d2b4d3SLarry Finger bool changecckpdstate_for_anothermacofdmsp; 2492f1d2b4d3SLarry Finger u8 curcckpdstate_for_anothermacofdmsp; 2493f1d2b4d3SLarry Finger bool changetxhighpowerlvl_for_anothermacofdmsp; 2494f1d2b4d3SLarry Finger u8 curtxhighlvl_for_anothermacofdmsp; 2495f1d2b4d3SLarry Finger long rssivalmin_for_anothermacofdmsp; 2496f1d2b4d3SLarry Finger }; 2497f1d2b4d3SLarry Finger 2498f1d2b4d3SLarry Finger struct ps_t { 2499f1d2b4d3SLarry Finger u8 pre_ccastate; 2500f1d2b4d3SLarry Finger u8 cur_ccasate; 2501f1d2b4d3SLarry Finger u8 pre_rfstate; 2502f1d2b4d3SLarry Finger u8 cur_rfstate; 2503f1d2b4d3SLarry Finger u8 initialize; 2504f1d2b4d3SLarry Finger long rssi_val_min; 2505f1d2b4d3SLarry Finger }; 2506f1d2b4d3SLarry Finger 2507f1d2b4d3SLarry Finger struct dig_t { 2508f1d2b4d3SLarry Finger u32 rssi_lowthresh; 2509f1d2b4d3SLarry Finger u32 rssi_highthresh; 2510f1d2b4d3SLarry Finger u32 fa_lowthresh; 2511f1d2b4d3SLarry Finger u32 fa_highthresh; 2512f1d2b4d3SLarry Finger long last_min_undec_pwdb_for_dm; 2513f1d2b4d3SLarry Finger long rssi_highpower_lowthresh; 2514f1d2b4d3SLarry Finger long rssi_highpower_highthresh; 2515f1d2b4d3SLarry Finger u32 recover_cnt; 2516f1d2b4d3SLarry Finger u32 pre_igvalue; 2517f1d2b4d3SLarry Finger u32 cur_igvalue; 2518f1d2b4d3SLarry Finger long rssi_val; 2519f1d2b4d3SLarry Finger u8 dig_enable_flag; 2520f1d2b4d3SLarry Finger u8 dig_ext_port_stage; 2521f1d2b4d3SLarry Finger u8 dig_algorithm; 2522f1d2b4d3SLarry Finger u8 dig_twoport_algorithm; 2523f1d2b4d3SLarry Finger u8 dig_dbgmode; 2524f1d2b4d3SLarry Finger u8 dig_slgorithm_switch; 2525f1d2b4d3SLarry Finger u8 cursta_cstate; 2526f1d2b4d3SLarry Finger u8 presta_cstate; 2527f1d2b4d3SLarry Finger u8 curmultista_cstate; 2528f1d2b4d3SLarry Finger u8 stop_dig; 252908aba42fSArnd Bergmann s8 back_val; 253008aba42fSArnd Bergmann s8 back_range_max; 253108aba42fSArnd Bergmann s8 back_range_min; 2532f1d2b4d3SLarry Finger u8 rx_gain_max; 2533f1d2b4d3SLarry Finger u8 rx_gain_min; 2534f1d2b4d3SLarry Finger u8 min_undec_pwdb_for_dm; 2535f1d2b4d3SLarry Finger u8 rssi_val_min; 2536f1d2b4d3SLarry Finger u8 pre_cck_cca_thres; 2537f1d2b4d3SLarry Finger u8 cur_cck_cca_thres; 2538f1d2b4d3SLarry Finger u8 pre_cck_pd_state; 2539f1d2b4d3SLarry Finger u8 cur_cck_pd_state; 2540f1d2b4d3SLarry Finger u8 pre_cck_fa_state; 2541f1d2b4d3SLarry Finger u8 cur_cck_fa_state; 2542f1d2b4d3SLarry Finger u8 pre_ccastate; 2543f1d2b4d3SLarry Finger u8 cur_ccasate; 2544f1d2b4d3SLarry Finger u8 large_fa_hit; 2545f1d2b4d3SLarry Finger u8 forbidden_igi; 2546f1d2b4d3SLarry Finger u8 dig_state; 2547f1d2b4d3SLarry Finger u8 dig_highpwrstate; 2548f1d2b4d3SLarry Finger u8 cur_sta_cstate; 2549f1d2b4d3SLarry Finger u8 pre_sta_cstate; 2550f1d2b4d3SLarry Finger u8 cur_ap_cstate; 2551f1d2b4d3SLarry Finger u8 pre_ap_cstate; 2552f1d2b4d3SLarry Finger u8 cur_pd_thstate; 2553f1d2b4d3SLarry Finger u8 pre_pd_thstate; 2554f1d2b4d3SLarry Finger u8 cur_cs_ratiostate; 2555f1d2b4d3SLarry Finger u8 pre_cs_ratiostate; 2556f1d2b4d3SLarry Finger u8 backoff_enable_flag; 255708aba42fSArnd Bergmann s8 backoffval_range_max; 255808aba42fSArnd Bergmann s8 backoffval_range_min; 2559f1d2b4d3SLarry Finger u8 dig_min_0; 2560f1d2b4d3SLarry Finger u8 dig_min_1; 2561f1d2b4d3SLarry Finger u8 bt30_cur_igi; 2562f1d2b4d3SLarry Finger bool media_connect_0; 2563f1d2b4d3SLarry Finger bool media_connect_1; 2564f1d2b4d3SLarry Finger 2565f1d2b4d3SLarry Finger u32 antdiv_rssi_max; 2566f1d2b4d3SLarry Finger u32 rssi_max; 2567f1d2b4d3SLarry Finger }; 2568f1d2b4d3SLarry Finger 2569f1d2b4d3SLarry Finger struct rtl_global_var { 2570f1d2b4d3SLarry Finger /* from this list we can get 2571d3da329cSLarry Finger * other adapter's rtl_priv 2572d3da329cSLarry Finger */ 2573f1d2b4d3SLarry Finger struct list_head glb_priv_list; 2574f1d2b4d3SLarry Finger spinlock_t glb_list_lock; 2575f1d2b4d3SLarry Finger }; 2576f1d2b4d3SLarry Finger 257711f35c95SPing-Ke Shih #define IN_4WAY_TIMEOUT_TIME (30 * MSEC_PER_SEC) /* 30 seconds */ 257811f35c95SPing-Ke Shih 2579f1d2b4d3SLarry Finger struct rtl_btc_info { 2580f1d2b4d3SLarry Finger u8 bt_type; 2581f1d2b4d3SLarry Finger u8 btcoexist; 2582f1d2b4d3SLarry Finger u8 ant_num; 2583db8cb009SPing-Ke Shih u8 single_ant_path; 2584f1cb27edSPing-Ke Shih 2585f1cb27edSPing-Ke Shih u8 ap_num; 258676f146b6SPing-Ke Shih bool in_4way; 258711f35c95SPing-Ke Shih unsigned long in_4way_ts; 2588f1d2b4d3SLarry Finger }; 2589f1d2b4d3SLarry Finger 2590f1d2b4d3SLarry Finger struct bt_coexist_info { 2591f1d2b4d3SLarry Finger struct rtl_btc_ops *btc_ops; 2592f1d2b4d3SLarry Finger struct rtl_btc_info btc_info; 259340d9dd4fSPing-Ke Shih /* btc context */ 259440d9dd4fSPing-Ke Shih void *btc_context; 25959177c336SPing-Ke Shih void *wifi_only_context; 2596f1d2b4d3SLarry Finger /* EEPROM BT info. */ 2597f1d2b4d3SLarry Finger u8 eeprom_bt_coexist; 2598f1d2b4d3SLarry Finger u8 eeprom_bt_type; 2599f1d2b4d3SLarry Finger u8 eeprom_bt_ant_num; 2600f1d2b4d3SLarry Finger u8 eeprom_bt_ant_isol; 2601f1d2b4d3SLarry Finger u8 eeprom_bt_radio_shared; 2602f1d2b4d3SLarry Finger 2603f1d2b4d3SLarry Finger u8 bt_coexistence; 2604f1d2b4d3SLarry Finger u8 bt_ant_num; 2605f1d2b4d3SLarry Finger u8 bt_coexist_type; 2606f1d2b4d3SLarry Finger u8 bt_state; 2607f1d2b4d3SLarry Finger u8 bt_cur_state; /* 0:on, 1:off */ 2608f1d2b4d3SLarry Finger u8 bt_ant_isolation; /* 0:good, 1:bad */ 2609f1d2b4d3SLarry Finger u8 bt_pape_ctrl; /* 0:SW, 1:SW/HW dynamic */ 2610f1d2b4d3SLarry Finger u8 bt_service; 2611f1d2b4d3SLarry Finger u8 bt_radio_shared_type; 2612f1d2b4d3SLarry Finger u8 bt_rfreg_origin_1e; 2613f1d2b4d3SLarry Finger u8 bt_rfreg_origin_1f; 2614f1d2b4d3SLarry Finger u8 bt_rssi_state; 2615f1d2b4d3SLarry Finger u32 ratio_tx; 2616f1d2b4d3SLarry Finger u32 ratio_pri; 2617f1d2b4d3SLarry Finger u32 bt_edca_ul; 2618f1d2b4d3SLarry Finger u32 bt_edca_dl; 2619f1d2b4d3SLarry Finger 2620f1d2b4d3SLarry Finger bool init_set; 2621f1d2b4d3SLarry Finger bool bt_busy_traffic; 2622f1d2b4d3SLarry Finger bool bt_traffic_mode_set; 2623f1d2b4d3SLarry Finger bool bt_non_traffic_mode_set; 2624f1d2b4d3SLarry Finger 2625f1d2b4d3SLarry Finger bool fw_coexist_all_off; 2626f1d2b4d3SLarry Finger bool sw_coexist_all_off; 2627f1d2b4d3SLarry Finger bool hw_coexist_all_off; 2628f1d2b4d3SLarry Finger u32 cstate; 2629f1d2b4d3SLarry Finger u32 previous_state; 2630f1d2b4d3SLarry Finger u32 cstate_h; 2631f1d2b4d3SLarry Finger u32 previous_state_h; 2632f1d2b4d3SLarry Finger 2633f1d2b4d3SLarry Finger u8 bt_pre_rssi_state; 2634f1d2b4d3SLarry Finger u8 bt_pre_rssi_state1; 2635f1d2b4d3SLarry Finger 2636f1d2b4d3SLarry Finger u8 reg_bt_iso; 2637f1d2b4d3SLarry Finger u8 reg_bt_sco; 2638f1d2b4d3SLarry Finger bool balance_on; 2639f1d2b4d3SLarry Finger u8 bt_active_zero_cnt; 2640f1d2b4d3SLarry Finger bool cur_bt_disabled; 2641f1d2b4d3SLarry Finger bool pre_bt_disabled; 2642f1d2b4d3SLarry Finger 2643f1d2b4d3SLarry Finger u8 bt_profile_case; 2644f1d2b4d3SLarry Finger u8 bt_profile_action; 2645f1d2b4d3SLarry Finger bool bt_busy; 2646f1d2b4d3SLarry Finger bool hold_for_bt_operation; 2647f1d2b4d3SLarry Finger u8 lps_counter; 2648f1d2b4d3SLarry Finger }; 2649f1d2b4d3SLarry Finger 2650f1d2b4d3SLarry Finger struct rtl_btc_ops { 2651f1d2b4d3SLarry Finger void (*btc_init_variables)(struct rtl_priv *rtlpriv); 26529177c336SPing-Ke Shih void (*btc_init_variables_wifi_only)(struct rtl_priv *rtlpriv); 265340d9dd4fSPing-Ke Shih void (*btc_deinit_variables)(struct rtl_priv *rtlpriv); 2654f1d2b4d3SLarry Finger void (*btc_init_hal_vars)(struct rtl_priv *rtlpriv); 2655a44709bbSPing-Ke Shih void (*btc_power_on_setting)(struct rtl_priv *rtlpriv); 2656f1d2b4d3SLarry Finger void (*btc_init_hw_config)(struct rtl_priv *rtlpriv); 26579177c336SPing-Ke Shih void (*btc_init_hw_config_wifi_only)(struct rtl_priv *rtlpriv); 2658f1d2b4d3SLarry Finger void (*btc_ips_notify)(struct rtl_priv *rtlpriv, u8 type); 2659f1d2b4d3SLarry Finger void (*btc_lps_notify)(struct rtl_priv *rtlpriv, u8 type); 2660f1d2b4d3SLarry Finger void (*btc_scan_notify)(struct rtl_priv *rtlpriv, u8 scantype); 26619177c336SPing-Ke Shih void (*btc_scan_notify_wifi_only)(struct rtl_priv *rtlpriv, 26629177c336SPing-Ke Shih u8 scantype); 2663f1d2b4d3SLarry Finger void (*btc_connect_notify)(struct rtl_priv *rtlpriv, u8 action); 2664f1d2b4d3SLarry Finger void (*btc_mediastatus_notify)(struct rtl_priv *rtlpriv, 2665f1d2b4d3SLarry Finger enum rt_media_status mstatus); 2666f1d2b4d3SLarry Finger void (*btc_periodical)(struct rtl_priv *rtlpriv); 266740d9dd4fSPing-Ke Shih void (*btc_halt_notify)(struct rtl_priv *rtlpriv); 2668f1d2b4d3SLarry Finger void (*btc_btinfo_notify)(struct rtl_priv *rtlpriv, 2669f1d2b4d3SLarry Finger u8 *tmp_buf, u8 length); 26706aad6075SPing-Ke Shih void (*btc_btmpinfo_notify)(struct rtl_priv *rtlpriv, 26716aad6075SPing-Ke Shih u8 *tmp_buf, u8 length); 2672f1d2b4d3SLarry Finger bool (*btc_is_limited_dig)(struct rtl_priv *rtlpriv); 2673f1d2b4d3SLarry Finger bool (*btc_is_disable_edca_turbo)(struct rtl_priv *rtlpriv); 2674f1d2b4d3SLarry Finger bool (*btc_is_bt_disabled)(struct rtl_priv *rtlpriv); 2675f1d2b4d3SLarry Finger void (*btc_special_packet_notify)(struct rtl_priv *rtlpriv, 2676f1d2b4d3SLarry Finger u8 pkt_type); 267717bf8510SPing-Ke Shih void (*btc_switch_band_notify)(struct rtl_priv *rtlpriv, u8 type, 267817bf8510SPing-Ke Shih bool scanning); 26799177c336SPing-Ke Shih void (*btc_switch_band_notify_wifi_only)(struct rtl_priv *rtlpriv, 26809177c336SPing-Ke Shih u8 type, bool scanning); 2681610247f4SPing-Ke Shih void (*btc_display_bt_coex_info)(struct rtl_priv *rtlpriv, 2682610247f4SPing-Ke Shih struct seq_file *m); 268354685f9cSPing-Ke Shih void (*btc_record_pwr_mode)(struct rtl_priv *rtlpriv, u8 *buf, u8 len); 268442213f2fSPing-Ke Shih u8 (*btc_get_lps_val)(struct rtl_priv *rtlpriv); 268542213f2fSPing-Ke Shih u8 (*btc_get_rpwm_val)(struct rtl_priv *rtlpriv); 268642213f2fSPing-Ke Shih bool (*btc_is_bt_ctrl_lps)(struct rtl_priv *rtlpriv); 26872635664eSPing-Ke Shih void (*btc_get_ampdu_cfg)(struct rtl_priv *rtlpriv, u8 *reject_agg, 26882635664eSPing-Ke Shih u8 *ctrl_agg_size, u8 *agg_size); 2689c692205dSPing-Ke Shih bool (*btc_is_bt_lps_on)(struct rtl_priv *rtlpriv); 2690f1d2b4d3SLarry Finger }; 2691f1d2b4d3SLarry Finger 2692f1d2b4d3SLarry Finger struct proxim { 2693f1d2b4d3SLarry Finger bool proxim_on; 2694f1d2b4d3SLarry Finger 2695f1d2b4d3SLarry Finger void *proximity_priv; 2696f1d2b4d3SLarry Finger int (*proxim_rx)(struct ieee80211_hw *hw, struct rtl_stats *status, 2697f1d2b4d3SLarry Finger struct sk_buff *skb); 2698f1d2b4d3SLarry Finger u8 (*proxim_get_var)(struct ieee80211_hw *hw, u8 type); 2699f1d2b4d3SLarry Finger }; 2700f1d2b4d3SLarry Finger 2701cceb0a59SPing-Ke Shih struct rtl_c2hcmd { 2702cceb0a59SPing-Ke Shih struct list_head list; 2703cceb0a59SPing-Ke Shih u8 tag; 2704cceb0a59SPing-Ke Shih u8 len; 2705cceb0a59SPing-Ke Shih u8 *val; 2706cceb0a59SPing-Ke Shih }; 2707cceb0a59SPing-Ke Shih 2708c76ab8e7SPing-Ke Shih struct rtl_bssid_entry { 2709c76ab8e7SPing-Ke Shih struct list_head list; 2710c76ab8e7SPing-Ke Shih u8 bssid[ETH_ALEN]; 2711f0fb62e0SDmitry Antipov unsigned long age; 2712c76ab8e7SPing-Ke Shih }; 2713c76ab8e7SPing-Ke Shih 2714c76ab8e7SPing-Ke Shih struct rtl_scan_list { 2715c76ab8e7SPing-Ke Shih int num; 2716c76ab8e7SPing-Ke Shih struct list_head list; /* sort by age */ 2717c76ab8e7SPing-Ke Shih }; 2718c76ab8e7SPing-Ke Shih 2719f1d2b4d3SLarry Finger struct rtl_priv { 2720f1d2b4d3SLarry Finger struct ieee80211_hw *hw; 2721f1d2b4d3SLarry Finger struct completion firmware_loading_complete; 2722f1d2b4d3SLarry Finger struct list_head list; 2723f1d2b4d3SLarry Finger struct rtl_priv *buddy_priv; 2724f1d2b4d3SLarry Finger struct rtl_global_var *glb_var; 2725f1d2b4d3SLarry Finger struct rtl_dmsp_ctl dmsp_ctl; 2726f1d2b4d3SLarry Finger struct rtl_locks locks; 2727f1d2b4d3SLarry Finger struct rtl_works works; 2728f1d2b4d3SLarry Finger struct rtl_mac mac80211; 2729f1d2b4d3SLarry Finger struct rtl_hal rtlhal; 2730f1d2b4d3SLarry Finger struct rtl_regulatory regd; 2731f1d2b4d3SLarry Finger struct rtl_rfkill rfkill; 2732f1d2b4d3SLarry Finger struct rtl_io io; 2733f1d2b4d3SLarry Finger struct rtl_phy phy; 2734f1d2b4d3SLarry Finger struct rtl_dm dm; 2735f1d2b4d3SLarry Finger struct rtl_security sec; 2736f1d2b4d3SLarry Finger struct rtl_efuse efuse; 2737d5efe153SLarry Finger struct rtl_led_ctl ledctl; 27388479580bSPing-Ke Shih struct rtl_tx_report tx_report; 2739c76ab8e7SPing-Ke Shih struct rtl_scan_list scan_list; 2740f1d2b4d3SLarry Finger 2741f1d2b4d3SLarry Finger struct rtl_ps_ctl psc; 2742f1d2b4d3SLarry Finger struct rate_adaptive ra; 2743f1d2b4d3SLarry Finger struct dynamic_primary_cca primarycca; 2744f1d2b4d3SLarry Finger struct wireless_stats stats; 2745f1d2b4d3SLarry Finger struct rt_link_detect link_info; 2746f1d2b4d3SLarry Finger struct false_alarm_statistics falsealm_cnt; 2747f1d2b4d3SLarry Finger 2748f1d2b4d3SLarry Finger struct rtl_rate_priv *rate_priv; 2749f1d2b4d3SLarry Finger 2750f1d2b4d3SLarry Finger /* sta entry list for ap adhoc or mesh */ 2751f1d2b4d3SLarry Finger struct list_head entry_list; 2752f1d2b4d3SLarry Finger 2753cceb0a59SPing-Ke Shih /* c2hcmd list for kthread level access */ 27549ae6ed27SPing-Ke Shih struct sk_buff_head c2hcmd_queue; 2755cceb0a59SPing-Ke Shih 2756610247f4SPing-Ke Shih struct rtl_debug dbg; 2757f1d2b4d3SLarry Finger int max_fw_size; 2758f1d2b4d3SLarry Finger 2759d3da329cSLarry Finger /* hal_cfg : for diff cards 2760f1d2b4d3SLarry Finger * intf_ops : for diff interrface usb/pcie 2761f1d2b4d3SLarry Finger */ 2762f1d2b4d3SLarry Finger struct rtl_hal_cfg *cfg; 27631bfcfdccSJulia Lawall const struct rtl_intf_ops *intf_ops; 2764f1d2b4d3SLarry Finger 2765f1d2b4d3SLarry Finger /* this var will be set by set_bit, 2766d3da329cSLarry Finger * and was used to indicate status of 2767d3da329cSLarry Finger * interface or hardware 2768d3da329cSLarry Finger */ 2769f1d2b4d3SLarry Finger unsigned long status; 2770f1d2b4d3SLarry Finger 2771f1d2b4d3SLarry Finger /* tables for dm */ 2772f1d2b4d3SLarry Finger struct dig_t dm_digtable; 2773f1d2b4d3SLarry Finger struct ps_t dm_pstable; 2774f1d2b4d3SLarry Finger 2775f1d2b4d3SLarry Finger u32 reg_874; 2776f1d2b4d3SLarry Finger u32 reg_c70; 2777f1d2b4d3SLarry Finger u32 reg_85c; 2778f1d2b4d3SLarry Finger u32 reg_a74; 2779f1d2b4d3SLarry Finger bool reg_init; /* true if regs saved */ 2780f1d2b4d3SLarry Finger bool bt_operation_on; 2781f1d2b4d3SLarry Finger __le32 *usb_data; 2782f1d2b4d3SLarry Finger int usb_data_index; 2783f1d2b4d3SLarry Finger bool initialized; 2784f1d2b4d3SLarry Finger bool enter_ps; /* true when entering PS */ 2785f1d2b4d3SLarry Finger u8 rate_mask[5]; 2786f1d2b4d3SLarry Finger 2787f1d2b4d3SLarry Finger /* intel Proximity, should be alloc mem 2788f1d2b4d3SLarry Finger * in intel Proximity module and can only 2789f1d2b4d3SLarry Finger * be used in intel Proximity mode 2790f1d2b4d3SLarry Finger */ 2791f1d2b4d3SLarry Finger struct proxim proximity; 2792f1d2b4d3SLarry Finger 2793f1d2b4d3SLarry Finger /*for bt coexist use*/ 2794f1d2b4d3SLarry Finger struct bt_coexist_info btcoexist; 2795f1d2b4d3SLarry Finger 2796f1d2b4d3SLarry Finger /* separate 92ee from other ICs, 2797f1d2b4d3SLarry Finger * 92ee use new trx flow. 2798f1d2b4d3SLarry Finger */ 2799f1d2b4d3SLarry Finger bool use_new_trx_flow; 2800f1d2b4d3SLarry Finger 2801f1d2b4d3SLarry Finger #ifdef CONFIG_PM 2802f1d2b4d3SLarry Finger struct wiphy_wowlan_support wowlan; 2803f1d2b4d3SLarry Finger #endif 2804f1d2b4d3SLarry Finger /* This must be the last item so 2805d3da329cSLarry Finger * that it points to the data allocated 2806d3da329cSLarry Finger * beyond this structure like: 2807d3da329cSLarry Finger * rtl_pci_priv or rtl_usb_priv 2808d3da329cSLarry Finger */ 280982d60779SGustavo A. R. Silva u8 priv[] __aligned(sizeof(void *)); 2810f1d2b4d3SLarry Finger }; 2811f1d2b4d3SLarry Finger 2812f1d2b4d3SLarry Finger #define rtl_priv(hw) (((struct rtl_priv *)(hw)->priv)) 2813f1d2b4d3SLarry Finger #define rtl_mac(rtlpriv) (&((rtlpriv)->mac80211)) 2814f1d2b4d3SLarry Finger #define rtl_hal(rtlpriv) (&((rtlpriv)->rtlhal)) 2815f1d2b4d3SLarry Finger #define rtl_efuse(rtlpriv) (&((rtlpriv)->efuse)) 2816f1d2b4d3SLarry Finger #define rtl_psc(rtlpriv) (&((rtlpriv)->psc)) 2817f1d2b4d3SLarry Finger 2818d3da329cSLarry Finger /* Bluetooth Co-existence Related */ 2819f1d2b4d3SLarry Finger 2820f1d2b4d3SLarry Finger enum bt_ant_num { 2821f1d2b4d3SLarry Finger ANT_X2 = 0, 2822f1d2b4d3SLarry Finger ANT_X1 = 1, 2823f1d2b4d3SLarry Finger }; 2824f1d2b4d3SLarry Finger 2825af8a41ccSPing-Ke Shih enum bt_ant_path { 2826af8a41ccSPing-Ke Shih ANT_MAIN = 0, 2827af8a41ccSPing-Ke Shih ANT_AUX = 1, 2828af8a41ccSPing-Ke Shih }; 2829af8a41ccSPing-Ke Shih 2830f1d2b4d3SLarry Finger enum bt_co_type { 2831f1d2b4d3SLarry Finger BT_2WIRE = 0, 2832f1d2b4d3SLarry Finger BT_ISSC_3WIRE = 1, 2833f1d2b4d3SLarry Finger BT_ACCEL = 2, 2834f1d2b4d3SLarry Finger BT_CSR_BC4 = 3, 2835f1d2b4d3SLarry Finger BT_CSR_BC8 = 4, 2836f1d2b4d3SLarry Finger BT_RTL8756 = 5, 2837f1d2b4d3SLarry Finger BT_RTL8723A = 6, 2838f1d2b4d3SLarry Finger BT_RTL8821A = 7, 2839f1d2b4d3SLarry Finger BT_RTL8723B = 8, 2840f1d2b4d3SLarry Finger BT_RTL8192E = 9, 2841f1d2b4d3SLarry Finger BT_RTL8812A = 11, 2842f1d2b4d3SLarry Finger }; 2843f1d2b4d3SLarry Finger 2844f1d2b4d3SLarry Finger enum bt_cur_state { 2845f1d2b4d3SLarry Finger BT_OFF = 0, 2846f1d2b4d3SLarry Finger BT_ON = 1, 2847f1d2b4d3SLarry Finger }; 2848f1d2b4d3SLarry Finger 2849f1d2b4d3SLarry Finger enum bt_service_type { 2850f1d2b4d3SLarry Finger BT_SCO = 0, 2851f1d2b4d3SLarry Finger BT_A2DP = 1, 2852f1d2b4d3SLarry Finger BT_HID = 2, 2853f1d2b4d3SLarry Finger BT_HID_IDLE = 3, 2854f1d2b4d3SLarry Finger BT_SCAN = 4, 2855f1d2b4d3SLarry Finger BT_IDLE = 5, 2856f1d2b4d3SLarry Finger BT_OTHER_ACTION = 6, 2857f1d2b4d3SLarry Finger BT_BUSY = 7, 2858f1d2b4d3SLarry Finger BT_OTHERBUSY = 8, 2859f1d2b4d3SLarry Finger BT_PAN = 9, 2860f1d2b4d3SLarry Finger }; 2861f1d2b4d3SLarry Finger 2862f1d2b4d3SLarry Finger enum bt_radio_shared { 2863f1d2b4d3SLarry Finger BT_RADIO_SHARED = 0, 2864f1d2b4d3SLarry Finger BT_RADIO_INDIVIDUAL = 1, 2865f1d2b4d3SLarry Finger }; 2866f1d2b4d3SLarry Finger 2867f1d2b4d3SLarry Finger /**************************************** 2868d3da329cSLarry Finger * mem access macro define start 2869d3da329cSLarry Finger * Call endian free function when 2870d3da329cSLarry Finger * 1. Read/write packet content. 2871d3da329cSLarry Finger * 2. Before write integer to IO. 2872d3da329cSLarry Finger * 3. After read integer from IO. 2873f1d2b4d3SLarry Finger ****************************************/ 2874f1d2b4d3SLarry Finger 2875f1d2b4d3SLarry Finger #define N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \ 2876f1d2b4d3SLarry Finger (__value) : (((__value + __aligment - 1) / __aligment) * __aligment)) 2877f1d2b4d3SLarry Finger 2878d3da329cSLarry Finger /* mem access macro define end */ 2879f1d2b4d3SLarry Finger 2880f1d2b4d3SLarry Finger #define byte(x, n) ((x >> (8 * n)) & 0xff) 2881f1d2b4d3SLarry Finger 2882f1d2b4d3SLarry Finger #define packet_get_type(_packet) (EF1BYTE((_packet).octet[0]) & 0xFC) 2883f1d2b4d3SLarry Finger #define RTL_WATCH_DOG_TIME 2000 2884f1d2b4d3SLarry Finger #define MSECS(t) msecs_to_jiffies(t) 2885f1d2b4d3SLarry Finger #define WLAN_FC_GET_VERS(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_VERS) 2886f1d2b4d3SLarry Finger #define WLAN_FC_GET_TYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE) 2887f1d2b4d3SLarry Finger #define WLAN_FC_GET_STYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE) 2888f1d2b4d3SLarry Finger #define WLAN_FC_MORE_DATA(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_MOREDATA) 2889f1d2b4d3SLarry Finger #define rtl_dm(rtlpriv) (&((rtlpriv)->dm)) 2890f1d2b4d3SLarry Finger 2891f1d2b4d3SLarry Finger #define RT_RF_OFF_LEVL_ASPM BIT(0) /*PCI ASPM */ 2892f1d2b4d3SLarry Finger #define RT_RF_OFF_LEVL_CLK_REQ BIT(1) /*PCI clock request */ 2893f1d2b4d3SLarry Finger #define RT_RF_OFF_LEVL_PCI_D3 BIT(2) /*PCI D3 mode */ 2894f1d2b4d3SLarry Finger /*NIC halt, re-initialize hw parameters*/ 2895f1d2b4d3SLarry Finger #define RT_RF_OFF_LEVL_HALT_NIC BIT(3) 2896f1d2b4d3SLarry Finger #define RT_RF_OFF_LEVL_FREE_FW BIT(4) /*FW free, re-download the FW */ 2897f1d2b4d3SLarry Finger #define RT_RF_OFF_LEVL_FW_32K BIT(5) /*FW in 32k */ 2898f1d2b4d3SLarry Finger /*Always enable ASPM and Clock Req in initialization.*/ 2899f1d2b4d3SLarry Finger #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6) 2900f1d2b4d3SLarry Finger /* no matter RFOFF or SLEEP we set PS_ASPM_LEVL*/ 2901f1d2b4d3SLarry Finger #define RT_PS_LEVEL_ASPM BIT(7) 2902f1d2b4d3SLarry Finger /*When LPS is on, disable 2R if no packet is received or transmittd.*/ 2903f1d2b4d3SLarry Finger #define RT_RF_LPS_DISALBE_2R BIT(30) 2904f1d2b4d3SLarry Finger #define RT_RF_LPS_LEVEL_ASPM BIT(31) /*LPS with ASPM */ 2905f1d2b4d3SLarry Finger #define RT_IN_PS_LEVEL(ppsc, _ps_flg) \ 2906f1d2b4d3SLarry Finger ((ppsc->cur_ps_level & _ps_flg) ? true : false) 2907f1d2b4d3SLarry Finger #define RT_CLEAR_PS_LEVEL(ppsc, _ps_flg) \ 2908f1d2b4d3SLarry Finger (ppsc->cur_ps_level &= (~(_ps_flg))) 2909f1d2b4d3SLarry Finger #define RT_SET_PS_LEVEL(ppsc, _ps_flg) \ 2910f1d2b4d3SLarry Finger (ppsc->cur_ps_level |= _ps_flg) 2911f1d2b4d3SLarry Finger 2912f1d2b4d3SLarry Finger #define FILL_OCTET_STRING(_os, _octet, _len) \ 2913f1d2b4d3SLarry Finger (_os).octet = (u8 *)(_octet); \ 2914f1d2b4d3SLarry Finger (_os).length = (_len); 2915f1d2b4d3SLarry Finger 2916f1d2b4d3SLarry Finger #define CP_MACADDR(des, src) \ 2917f1d2b4d3SLarry Finger ((des)[0] = (src)[0], (des)[1] = (src)[1],\ 2918f1d2b4d3SLarry Finger (des)[2] = (src)[2], (des)[3] = (src)[3],\ 2919f1d2b4d3SLarry Finger (des)[4] = (src)[4], (des)[5] = (src)[5]) 2920f1d2b4d3SLarry Finger 2921f1d2b4d3SLarry Finger #define LDPC_HT_ENABLE_RX BIT(0) 2922f1d2b4d3SLarry Finger #define LDPC_HT_ENABLE_TX BIT(1) 2923f1d2b4d3SLarry Finger #define LDPC_HT_TEST_TX_ENABLE BIT(2) 2924f1d2b4d3SLarry Finger #define LDPC_HT_CAP_TX BIT(3) 2925f1d2b4d3SLarry Finger 2926f1d2b4d3SLarry Finger #define STBC_HT_ENABLE_RX BIT(0) 2927f1d2b4d3SLarry Finger #define STBC_HT_ENABLE_TX BIT(1) 2928f1d2b4d3SLarry Finger #define STBC_HT_TEST_TX_ENABLE BIT(2) 2929f1d2b4d3SLarry Finger #define STBC_HT_CAP_TX BIT(3) 2930f1d2b4d3SLarry Finger 2931f1d2b4d3SLarry Finger #define LDPC_VHT_ENABLE_RX BIT(0) 2932f1d2b4d3SLarry Finger #define LDPC_VHT_ENABLE_TX BIT(1) 2933f1d2b4d3SLarry Finger #define LDPC_VHT_TEST_TX_ENABLE BIT(2) 2934f1d2b4d3SLarry Finger #define LDPC_VHT_CAP_TX BIT(3) 2935f1d2b4d3SLarry Finger 2936f1d2b4d3SLarry Finger #define STBC_VHT_ENABLE_RX BIT(0) 2937f1d2b4d3SLarry Finger #define STBC_VHT_ENABLE_TX BIT(1) 2938f1d2b4d3SLarry Finger #define STBC_VHT_TEST_TX_ENABLE BIT(2) 2939f1d2b4d3SLarry Finger #define STBC_VHT_CAP_TX BIT(3) 2940f1d2b4d3SLarry Finger 29419696a159SLarry Finger extern u8 channel5g[CHANNEL_MAX_NUMBER_5G]; 29429696a159SLarry Finger 29439696a159SLarry Finger extern u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M]; 29449696a159SLarry Finger 2945f1d2b4d3SLarry Finger static inline u8 rtl_read_byte(struct rtl_priv *rtlpriv, u32 addr) 2946f1d2b4d3SLarry Finger { 2947f1d2b4d3SLarry Finger return rtlpriv->io.read8_sync(rtlpriv, addr); 2948f1d2b4d3SLarry Finger } 2949f1d2b4d3SLarry Finger 2950f1d2b4d3SLarry Finger static inline u16 rtl_read_word(struct rtl_priv *rtlpriv, u32 addr) 2951f1d2b4d3SLarry Finger { 2952f1d2b4d3SLarry Finger return rtlpriv->io.read16_sync(rtlpriv, addr); 2953f1d2b4d3SLarry Finger } 2954f1d2b4d3SLarry Finger 2955f1d2b4d3SLarry Finger static inline u32 rtl_read_dword(struct rtl_priv *rtlpriv, u32 addr) 2956f1d2b4d3SLarry Finger { 2957f1d2b4d3SLarry Finger return rtlpriv->io.read32_sync(rtlpriv, addr); 2958f1d2b4d3SLarry Finger } 2959f1d2b4d3SLarry Finger 2960f1d2b4d3SLarry Finger static inline void rtl_write_byte(struct rtl_priv *rtlpriv, u32 addr, u8 val8) 2961f1d2b4d3SLarry Finger { 2962f1d2b4d3SLarry Finger rtlpriv->io.write8_async(rtlpriv, addr, val8); 2963f1d2b4d3SLarry Finger 2964f1d2b4d3SLarry Finger if (rtlpriv->cfg->write_readback) 2965f1d2b4d3SLarry Finger rtlpriv->io.read8_sync(rtlpriv, addr); 2966f1d2b4d3SLarry Finger } 2967f1d2b4d3SLarry Finger 296884d26fdaSPing-Ke Shih static inline void rtl_write_byte_with_val32(struct ieee80211_hw *hw, 296984d26fdaSPing-Ke Shih u32 addr, u32 val8) 297084d26fdaSPing-Ke Shih { 297184d26fdaSPing-Ke Shih struct rtl_priv *rtlpriv = rtl_priv(hw); 297284d26fdaSPing-Ke Shih 297384d26fdaSPing-Ke Shih rtl_write_byte(rtlpriv, addr, (u8)val8); 297484d26fdaSPing-Ke Shih } 297584d26fdaSPing-Ke Shih 2976f1d2b4d3SLarry Finger static inline void rtl_write_word(struct rtl_priv *rtlpriv, u32 addr, u16 val16) 2977f1d2b4d3SLarry Finger { 2978f1d2b4d3SLarry Finger rtlpriv->io.write16_async(rtlpriv, addr, val16); 2979f1d2b4d3SLarry Finger 2980f1d2b4d3SLarry Finger if (rtlpriv->cfg->write_readback) 2981f1d2b4d3SLarry Finger rtlpriv->io.read16_sync(rtlpriv, addr); 2982f1d2b4d3SLarry Finger } 2983f1d2b4d3SLarry Finger 2984f1d2b4d3SLarry Finger static inline void rtl_write_dword(struct rtl_priv *rtlpriv, 2985f1d2b4d3SLarry Finger u32 addr, u32 val32) 2986f1d2b4d3SLarry Finger { 2987f1d2b4d3SLarry Finger rtlpriv->io.write32_async(rtlpriv, addr, val32); 2988f1d2b4d3SLarry Finger 2989f1d2b4d3SLarry Finger if (rtlpriv->cfg->write_readback) 2990f1d2b4d3SLarry Finger rtlpriv->io.read32_sync(rtlpriv, addr); 2991f1d2b4d3SLarry Finger } 2992f1d2b4d3SLarry Finger 2993f1d2b4d3SLarry Finger static inline u32 rtl_get_bbreg(struct ieee80211_hw *hw, 2994f1d2b4d3SLarry Finger u32 regaddr, u32 bitmask) 2995f1d2b4d3SLarry Finger { 2996f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = hw->priv; 2997f1d2b4d3SLarry Finger 2998f1d2b4d3SLarry Finger return rtlpriv->cfg->ops->get_bbreg(hw, regaddr, bitmask); 2999f1d2b4d3SLarry Finger } 3000f1d2b4d3SLarry Finger 3001f1d2b4d3SLarry Finger static inline void rtl_set_bbreg(struct ieee80211_hw *hw, u32 regaddr, 3002f1d2b4d3SLarry Finger u32 bitmask, u32 data) 3003f1d2b4d3SLarry Finger { 3004f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = hw->priv; 3005f1d2b4d3SLarry Finger 3006f1d2b4d3SLarry Finger rtlpriv->cfg->ops->set_bbreg(hw, regaddr, bitmask, data); 3007f1d2b4d3SLarry Finger } 3008f1d2b4d3SLarry Finger 300984d26fdaSPing-Ke Shih static inline void rtl_set_bbreg_with_dwmask(struct ieee80211_hw *hw, 301084d26fdaSPing-Ke Shih u32 regaddr, u32 data) 301184d26fdaSPing-Ke Shih { 301284d26fdaSPing-Ke Shih rtl_set_bbreg(hw, regaddr, 0xffffffff, data); 301384d26fdaSPing-Ke Shih } 301484d26fdaSPing-Ke Shih 3015f1d2b4d3SLarry Finger static inline u32 rtl_get_rfreg(struct ieee80211_hw *hw, 3016f1d2b4d3SLarry Finger enum radio_path rfpath, u32 regaddr, 3017f1d2b4d3SLarry Finger u32 bitmask) 3018f1d2b4d3SLarry Finger { 3019f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = hw->priv; 3020f1d2b4d3SLarry Finger 3021f1d2b4d3SLarry Finger return rtlpriv->cfg->ops->get_rfreg(hw, rfpath, regaddr, bitmask); 3022f1d2b4d3SLarry Finger } 3023f1d2b4d3SLarry Finger 3024f1d2b4d3SLarry Finger static inline void rtl_set_rfreg(struct ieee80211_hw *hw, 3025f1d2b4d3SLarry Finger enum radio_path rfpath, u32 regaddr, 3026f1d2b4d3SLarry Finger u32 bitmask, u32 data) 3027f1d2b4d3SLarry Finger { 3028f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = hw->priv; 3029f1d2b4d3SLarry Finger 3030f1d2b4d3SLarry Finger rtlpriv->cfg->ops->set_rfreg(hw, rfpath, regaddr, bitmask, data); 3031f1d2b4d3SLarry Finger } 3032f1d2b4d3SLarry Finger 3033f1d2b4d3SLarry Finger static inline bool is_hal_stop(struct rtl_hal *rtlhal) 3034f1d2b4d3SLarry Finger { 3035f1d2b4d3SLarry Finger return (_HAL_STATE_STOP == rtlhal->state); 3036f1d2b4d3SLarry Finger } 3037f1d2b4d3SLarry Finger 3038f1d2b4d3SLarry Finger static inline void set_hal_start(struct rtl_hal *rtlhal) 3039f1d2b4d3SLarry Finger { 3040f1d2b4d3SLarry Finger rtlhal->state = _HAL_STATE_START; 3041f1d2b4d3SLarry Finger } 3042f1d2b4d3SLarry Finger 3043f1d2b4d3SLarry Finger static inline void set_hal_stop(struct rtl_hal *rtlhal) 3044f1d2b4d3SLarry Finger { 3045f1d2b4d3SLarry Finger rtlhal->state = _HAL_STATE_STOP; 3046f1d2b4d3SLarry Finger } 3047f1d2b4d3SLarry Finger 3048f1d2b4d3SLarry Finger static inline u8 get_rf_type(struct rtl_phy *rtlphy) 3049f1d2b4d3SLarry Finger { 3050f1d2b4d3SLarry Finger return rtlphy->rf_type; 3051f1d2b4d3SLarry Finger } 3052f1d2b4d3SLarry Finger 3053f1d2b4d3SLarry Finger static inline struct ieee80211_hdr *rtl_get_hdr(struct sk_buff *skb) 3054f1d2b4d3SLarry Finger { 3055f1d2b4d3SLarry Finger return (struct ieee80211_hdr *)(skb->data); 3056f1d2b4d3SLarry Finger } 3057f1d2b4d3SLarry Finger 3058f1d2b4d3SLarry Finger static inline __le16 rtl_get_fc(struct sk_buff *skb) 3059f1d2b4d3SLarry Finger { 3060f1d2b4d3SLarry Finger return rtl_get_hdr(skb)->frame_control; 3061f1d2b4d3SLarry Finger } 3062f1d2b4d3SLarry Finger 3063f1d2b4d3SLarry Finger static inline u16 rtl_get_tid(struct sk_buff *skb) 3064f1d2b4d3SLarry Finger { 3065987e9bcdSChristophe JAILLET return ieee80211_get_tid(rtl_get_hdr(skb)); 3066f1d2b4d3SLarry Finger } 3067f1d2b4d3SLarry Finger 3068f1d2b4d3SLarry Finger static inline struct ieee80211_sta *get_sta(struct ieee80211_hw *hw, 3069f1d2b4d3SLarry Finger struct ieee80211_vif *vif, 3070f1d2b4d3SLarry Finger const u8 *bssid) 3071f1d2b4d3SLarry Finger { 3072f1d2b4d3SLarry Finger return ieee80211_find_sta(vif, bssid); 3073f1d2b4d3SLarry Finger } 3074f1d2b4d3SLarry Finger 3075f1d2b4d3SLarry Finger static inline struct ieee80211_sta *rtl_find_sta(struct ieee80211_hw *hw, 3076f1d2b4d3SLarry Finger u8 *mac_addr) 3077f1d2b4d3SLarry Finger { 3078f1d2b4d3SLarry Finger struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 307993665097SLarry Finger 3080f1d2b4d3SLarry Finger return ieee80211_find_sta(mac->vif, mac_addr); 3081f1d2b4d3SLarry Finger } 3082f1d2b4d3SLarry Finger 3083f1d2b4d3SLarry Finger #endif 3084