1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /****************************************************************************** 3 * 4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 5 * 6 ******************************************************************************/ 7 #ifndef _RTW_MP_H_ 8 #define _RTW_MP_H_ 9 10 #define MAX_MP_XMITBUF_SZ 2048 11 #define NR_MP_XMITFRAME 8 12 13 struct mp_xmit_frame { 14 struct list_head list; 15 16 struct pkt_attrib attrib; 17 18 struct sk_buff *pkt; 19 20 int frame_tag; 21 22 struct adapter *padapter; 23 24 uint mem[(MAX_MP_XMITBUF_SZ >> 2)]; 25 }; 26 27 struct mp_wiparam { 28 u32 bcompleted; 29 u32 act_type; 30 u32 io_offset; 31 u32 io_value; 32 }; 33 34 struct mp_tx { 35 u8 stop; 36 u32 count, sended; 37 u8 payload; 38 struct pkt_attrib attrib; 39 /* struct tx_desc desc; */ 40 /* u8 resvdtx[7]; */ 41 u8 desc[TXDESC_SIZE]; 42 u8 *pallocated_buf; 43 u8 *buf; 44 u32 buf_size, write_size; 45 void *PktTxThread; 46 }; 47 48 #define MP_MAX_LINES 1000 49 #define MP_MAX_LINES_BYTES 256 50 51 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter); 52 struct mpt_context { 53 /* Indicate if we have started Mass Production Test. */ 54 bool bMassProdTest; 55 56 /* Indicate if the driver is unloading or unloaded. */ 57 bool bMptDrvUnload; 58 59 struct timer_list MPh2c_timeout_timer; 60 /* Event used to sync H2c for BT control */ 61 62 bool MptH2cRspEvent; 63 bool MptBtC2hEvent; 64 bool bMPh2c_timeout; 65 66 /* 8190 PCI does not support NDIS_WORK_ITEM. */ 67 /* Work Item for Mass Production Test. */ 68 /* NDIS_WORK_ITEM MptWorkItem; */ 69 /* RT_WORK_ITEM MptWorkItem; */ 70 /* Event used to sync the case unloading driver and MptWorkItem is still in progress. */ 71 /* NDIS_EVENT MptWorkItemEvent; */ 72 /* To protect the following variables. */ 73 /* NDIS_SPIN_LOCK MptWorkItemSpinLock; */ 74 /* Indicate a MptWorkItem is scheduled and not yet finished. */ 75 bool bMptWorkItemInProgress; 76 /* An instance which implements function and context of MptWorkItem. */ 77 MPT_WORK_ITEM_HANDLER CurrMptAct; 78 79 /* 1 =Start, 0 =Stop from UI. */ 80 u32 MptTestStart; 81 /* _TEST_MODE, defined in MPT_Req2.h */ 82 u32 MptTestItem; 83 /* Variable needed in each implementation of CurrMptAct. */ 84 u32 MptActType; /* Type of action performed in CurrMptAct. */ 85 /* The Offset of IO operation is depend of MptActType. */ 86 u32 MptIoOffset; 87 /* The Value of IO operation is depend of MptActType. */ 88 u32 MptIoValue; 89 /* The RfPath of IO operation is depend of MptActType. */ 90 u32 MptRfPath; 91 92 enum wireless_mode MptWirelessModeToSw; /* Wireless mode to switch. */ 93 u8 MptChannelToSw; /* Channel to switch. */ 94 u8 MptInitGainToSet; /* Initial gain to set. */ 95 u32 MptBandWidth; /* bandwidth to switch. */ 96 u32 MptRateIndex; /* rate index. */ 97 /* Register value kept for Single Carrier Tx test. */ 98 u8 btMpCckTxPower; 99 /* Register value kept for Single Carrier Tx test. */ 100 u8 btMpOfdmTxPower; 101 /* For MP Tx Power index */ 102 u8 TxPwrLevel[2]; /* rf-A, rf-B */ 103 u32 RegTxPwrLimit; 104 /* Content of RCR Register for Mass Production Test. */ 105 u32 MptRCR; 106 /* true if we only receive packets with specific pattern. */ 107 bool bMptFilterPattern; 108 /* Rx OK count, statistics used in Mass Production Test. */ 109 u32 MptRxOkCnt; 110 /* Rx CRC32 error count, statistics used in Mass Production Test. */ 111 u32 MptRxCrcErrCnt; 112 113 bool bCckContTx; /* true if we are in CCK Continuous Tx test. */ 114 bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */ 115 bool bStartContTx; /* true if we have start Continuous Tx test. */ 116 /* true if we are in Single Carrier Tx test. */ 117 bool bSingleCarrier; 118 /* true if we are in Carrier Suppression Tx Test. */ 119 bool bCarrierSuppression; 120 /* true if we are in Single Tone Tx test. */ 121 bool bSingleTone; 122 123 /* ACK counter asked by K.Y.. */ 124 bool bMptEnableAckCounter; 125 u32 MptAckCounter; 126 127 /* SD3 Willis For 8192S to save 1T/2T RF table for ACUT Only fro ACUT delete later ~~~! */ 128 /* s8 BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT]; */ 129 /* s8 BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES]; */ 130 /* s32 RfReadLine[2]; */ 131 132 u8 APK_bound[2]; /* for APK path A/path B */ 133 bool bMptIndexEven; 134 135 u8 backup0xc50; 136 u8 backup0xc58; 137 u8 backup0xc30; 138 u8 backup0x52_RF_A; 139 u8 backup0x52_RF_B; 140 141 u32 backup0x58_RF_A; 142 u32 backup0x58_RF_B; 143 144 u8 h2cReqNum; 145 u8 c2hBuf[32]; 146 147 u8 btInBuf[100]; 148 u32 mptOutLen; 149 u8 mptOutBuf[100]; 150 151 }; 152 /* endif */ 153 154 /* E-Fuse */ 155 #define EFUSE_MAP_SIZE 512 156 157 #define EFUSE_MAX_SIZE 512 158 /* end of E-Fuse */ 159 160 /* define RTPRIV_IOCTL_MP (SIOCIWFIRSTPRIV + 0x17) */ 161 enum { 162 WRITE_REG = 1, 163 READ_REG, 164 WRITE_RF, 165 READ_RF, 166 MP_START, 167 MP_STOP, 168 MP_RATE, 169 MP_CHANNEL, 170 MP_BANDWIDTH, 171 MP_TXPOWER, 172 MP_ANT_TX, 173 MP_ANT_RX, 174 MP_CTX, 175 MP_QUERY, 176 MP_ARX, 177 MP_PSD, 178 MP_PWRTRK, 179 MP_THER, 180 MP_IOCTL, 181 EFUSE_GET, 182 EFUSE_SET, 183 MP_RESET_STATS, 184 MP_DUMP, 185 MP_PHYPARA, 186 MP_SetRFPathSwh, 187 MP_QueryDrvStats, 188 MP_SetBT, 189 CTA_TEST, 190 MP_DISABLE_BT_COEXIST, 191 MP_PwrCtlDM, 192 MP_NULL, 193 MP_GET_TXPOWER_INX, 194 }; 195 196 struct mp_priv { 197 struct adapter *papdater; 198 199 /* Testing Flag */ 200 u32 mode;/* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */ 201 202 u32 prev_fw_state; 203 204 /* OID cmd handler */ 205 struct mp_wiparam workparam; 206 /* u8 act_in_progress; */ 207 208 /* Tx Section */ 209 u8 TID; 210 u32 tx_pktcount; 211 u32 pktInterval; 212 struct mp_tx tx; 213 214 /* Rx Section */ 215 u32 rx_bssidpktcount; 216 u32 rx_pktcount; 217 u32 rx_pktcount_filter_out; 218 u32 rx_crcerrpktcount; 219 u32 rx_pktloss; 220 bool rx_bindicatePkt; 221 struct recv_stat rxstat; 222 223 /* RF/BB relative */ 224 u8 channel; 225 u8 bandwidth; 226 u8 prime_channel_offset; 227 u8 txpoweridx; 228 u8 txpoweridx_b; 229 u8 rateidx; 230 u32 preamble; 231 /* u8 modem; */ 232 u32 CrystalCap; 233 /* u32 curr_crystalcap; */ 234 235 u16 antenna_tx; 236 u16 antenna_rx; 237 /* u8 curr_rfpath; */ 238 239 u8 check_mp_pkt; 240 241 u8 bSetTxPower; 242 /* uint ForcedDataRate; */ 243 u8 mp_dm; 244 u8 mac_filter[ETH_ALEN]; 245 u8 bmac_filter; 246 247 struct wlan_network mp_network; 248 NDIS_802_11_MAC_ADDRESS network_macaddr; 249 250 u8 *pallocated_mp_xmitframe_buf; 251 u8 *pmp_xmtframe_buf; 252 struct __queue free_mp_xmitqueue; 253 u32 free_mp_xmitframe_cnt; 254 bool bSetRxBssid; 255 bool bTxBufCkFail; 256 257 struct mpt_context MptCtx; 258 259 u8 *TXradomBuffer; 260 }; 261 262 #define LOWER true 263 #define RAISE false 264 265 /* Hardware Registers */ 266 #define BB_REG_BASE_ADDR 0x800 267 268 #define MAX_RF_PATH_NUMS RF_PATH_MAX 269 270 extern u8 mpdatarate[NumRates]; 271 272 #define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */ 273 274 #define RX_PKT_BROADCAST 1 275 #define RX_PKT_DEST_ADDR 2 276 #define RX_PKT_PHY_MATCH 3 277 278 #define Mac_OFDM_OK 0x00000000 279 #define Mac_OFDM_Fail 0x10000000 280 #define Mac_OFDM_FasleAlarm 0x20000000 281 #define Mac_CCK_OK 0x30000000 282 #define Mac_CCK_Fail 0x40000000 283 #define Mac_CCK_FasleAlarm 0x50000000 284 #define Mac_HT_OK 0x60000000 285 #define Mac_HT_Fail 0x70000000 286 #define Mac_HT_FasleAlarm 0x90000000 287 #define Mac_DropPacket 0xA0000000 288 289 #define REG_RF_BB_GAIN_OFFSET 0x7f 290 #define RF_GAIN_OFFSET_MASK 0xfffff 291 292 /* */ 293 /* struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv); */ 294 /* int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe); */ 295 296 s32 init_mp_priv(struct adapter *padapter); 297 void free_mp_priv(struct mp_priv *pmp_priv); 298 s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel); 299 void MPT_DeInitAdapter(struct adapter *padapter); 300 s32 mp_start_test(struct adapter *padapter); 301 void mp_stop_test(struct adapter *padapter); 302 303 u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask); 304 void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val); 305 306 u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz); 307 void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz); 308 u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask); 309 void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val); 310 u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr); 311 void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val); 312 313 void SetChannel(struct adapter *padapter); 314 void SetBandwidth(struct adapter *padapter); 315 int SetTxPower(struct adapter *padapter); 316 void SetAntennaPathPower(struct adapter *padapter); 317 void SetDataRate(struct adapter *padapter); 318 319 void SetAntenna(struct adapter *padapter); 320 321 s32 SetThermalMeter(struct adapter *padapter, u8 target_ther); 322 void GetThermalMeter(struct adapter *padapter, u8 *value); 323 324 void SetContinuousTx(struct adapter *padapter, u8 bStart); 325 void SetSingleCarrierTx(struct adapter *padapter, u8 bStart); 326 void SetSingleToneTx(struct adapter *padapter, u8 bStart); 327 void SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart); 328 void PhySetTxPowerLevel(struct adapter *padapter); 329 330 void fill_txdesc_for_mp(struct adapter *padapter, u8 *ptxdesc); 331 void SetPacketTx(struct adapter *padapter); 332 void SetPacketRx(struct adapter *padapter, u8 bStartRx); 333 334 void ResetPhyRxPktCount(struct adapter *padapter); 335 u32 GetPhyRxPktReceived(struct adapter *padapter); 336 u32 GetPhyRxPktCRC32Error(struct adapter *padapter); 337 338 s32 SetPowerTracking(struct adapter *padapter, u8 enable); 339 void GetPowerTracking(struct adapter *padapter, u8 *enable); 340 341 u32 mp_query_psd(struct adapter *padapter, u8 *data); 342 343 void Hal_SetAntenna(struct adapter *padapter); 344 void Hal_SetBandwidth(struct adapter *padapter); 345 346 void Hal_SetTxPower(struct adapter *padapter); 347 void Hal_SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart); 348 void Hal_SetSingleToneTx(struct adapter *padapter, u8 bStart); 349 void Hal_SetSingleCarrierTx(struct adapter *padapter, u8 bStart); 350 void Hal_SetContinuousTx(struct adapter *padapter, u8 bStart); 351 352 void Hal_SetDataRate(struct adapter *padapter); 353 void Hal_SetChannel(struct adapter *padapter); 354 void Hal_SetAntennaPathPower(struct adapter *padapter); 355 s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther); 356 s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable); 357 void Hal_GetPowerTracking(struct adapter *padapter, u8 *enable); 358 void Hal_GetThermalMeter(struct adapter *padapter, u8 *value); 359 void Hal_mpt_SwitchRfSetting(struct adapter *padapter); 360 void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14); 361 void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *padapter, bool beven); 362 void Hal_SetCCKTxPower(struct adapter *padapter, u8 *TxPower); 363 void Hal_SetOFDMTxPower(struct adapter *padapter, u8 *TxPower); 364 void Hal_TriggerRFThermalMeter(struct adapter *padapter); 365 u8 Hal_ReadRFThermalMeter(struct adapter *padapter); 366 void Hal_SetCCKContinuousTx(struct adapter *padapter, u8 bStart); 367 void Hal_SetOFDMContinuousTx(struct adapter *padapter, u8 bStart); 368 void Hal_ProSetCrystalCap(struct adapter *padapter, u32 CrystalCapVal); 369 void MP_PHY_SetRFPathSwitch(struct adapter *padapter, bool bMain); 370 u32 mpt_ProQueryCalTxPower(struct adapter *padapter, u8 RfPath); 371 void MPT_PwrCtlDM(struct adapter *padapter, u32 bstart); 372 u8 MptToMgntRate(u32 MptRateIdx); 373 374 #endif /* _RTW_MP_H_ */ 375