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 { 15 struct list_head list; 16 17 struct pkt_attrib attrib; 18 19 _pkt *pkt; 20 21 int frame_tag; 22 23 struct adapter *padapter; 24 25 uint mem[(MAX_MP_XMITBUF_SZ >> 2)]; 26 }; 27 28 struct mp_wiparam 29 { 30 u32 bcompleted; 31 u32 act_type; 32 u32 io_offset; 33 u32 io_value; 34 }; 35 36 typedef void(*wi_act_func)(void* padapter); 37 38 struct mp_tx 39 { 40 u8 stop; 41 u32 count, sended; 42 u8 payload; 43 struct pkt_attrib attrib; 44 /* struct tx_desc desc; */ 45 /* u8 resvdtx[7]; */ 46 u8 desc[TXDESC_SIZE]; 47 u8 *pallocated_buf; 48 u8 *buf; 49 u32 buf_size, write_size; 50 void *PktTxThread; 51 }; 52 53 #define MP_MAX_LINES 1000 54 #define MP_MAX_LINES_BYTES 256 55 56 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter); 57 typedef struct _MPT_CONTEXT 58 { 59 /* Indicate if we have started Mass Production Test. */ 60 bool bMassProdTest; 61 62 /* Indicate if the driver is unloading or unloaded. */ 63 bool bMptDrvUnload; 64 65 _sema MPh2c_Sema; 66 _timer MPh2c_timeout_timer; 67 /* Event used to sync H2c for BT control */ 68 69 bool MptH2cRspEvent; 70 bool MptBtC2hEvent; 71 bool bMPh2c_timeout; 72 73 /* 8190 PCI does not support NDIS_WORK_ITEM. */ 74 /* Work Item for Mass Production Test. */ 75 /* NDIS_WORK_ITEM MptWorkItem; */ 76 /* RT_WORK_ITEM MptWorkItem; */ 77 /* Event used to sync the case unloading driver and MptWorkItem is still in progress. */ 78 /* NDIS_EVENT MptWorkItemEvent; */ 79 /* To protect the following variables. */ 80 /* NDIS_SPIN_LOCK MptWorkItemSpinLock; */ 81 /* Indicate a MptWorkItem is scheduled and not yet finished. */ 82 bool bMptWorkItemInProgress; 83 /* An instance which implements function and context of MptWorkItem. */ 84 MPT_WORK_ITEM_HANDLER CurrMptAct; 85 86 /* 1 =Start, 0 =Stop from UI. */ 87 u32 MptTestStart; 88 /* _TEST_MODE, defined in MPT_Req2.h */ 89 u32 MptTestItem; 90 /* Variable needed in each implementation of CurrMptAct. */ 91 u32 MptActType; /* Type of action performed in CurrMptAct. */ 92 /* The Offset of IO operation is depend of MptActType. */ 93 u32 MptIoOffset; 94 /* The Value of IO operation is depend of MptActType. */ 95 u32 MptIoValue; 96 /* The RfPath of IO operation is depend of MptActType. */ 97 u32 MptRfPath; 98 99 enum WIRELESS_MODE MptWirelessModeToSw; /* Wireless mode to switch. */ 100 u8 MptChannelToSw; /* Channel to switch. */ 101 u8 MptInitGainToSet; /* Initial gain to set. */ 102 u32 MptBandWidth; /* bandwidth to switch. */ 103 u32 MptRateIndex; /* rate index. */ 104 /* Register value kept for Single Carrier Tx test. */ 105 u8 btMpCckTxPower; 106 /* Register value kept for Single Carrier Tx test. */ 107 u8 btMpOfdmTxPower; 108 /* For MP Tx Power index */ 109 u8 TxPwrLevel[2]; /* rf-A, rf-B */ 110 u32 RegTxPwrLimit; 111 /* Content of RCR Regsiter for Mass Production Test. */ 112 u32 MptRCR; 113 /* true if we only receive packets with specific pattern. */ 114 bool bMptFilterPattern; 115 /* Rx OK count, statistics used in Mass Production Test. */ 116 u32 MptRxOkCnt; 117 /* Rx CRC32 error count, statistics used in Mass Production Test. */ 118 u32 MptRxCrcErrCnt; 119 120 bool bCckContTx; /* true if we are in CCK Continuous Tx test. */ 121 bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */ 122 bool bStartContTx; /* true if we have start Continuous Tx test. */ 123 /* true if we are in Single Carrier Tx test. */ 124 bool bSingleCarrier; 125 /* true if we are in Carrier Suppression Tx Test. */ 126 bool bCarrierSuppression; 127 /* true if we are in Single Tone Tx test. */ 128 bool bSingleTone; 129 130 /* ACK counter asked by K.Y.. */ 131 bool bMptEnableAckCounter; 132 u32 MptAckCounter; 133 134 /* SD3 Willis For 8192S to save 1T/2T RF table for ACUT Only fro ACUT delete later ~~~! */ 135 /* s8 BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT]; */ 136 /* s8 BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES]; */ 137 /* s32 RfReadLine[2]; */ 138 139 u8 APK_bound[2]; /* for APK path A/path B */ 140 bool bMptIndexEven; 141 142 u8 backup0xc50; 143 u8 backup0xc58; 144 u8 backup0xc30; 145 u8 backup0x52_RF_A; 146 u8 backup0x52_RF_B; 147 148 u32 backup0x58_RF_A; 149 u32 backup0x58_RF_B; 150 151 u8 h2cReqNum; 152 u8 c2hBuf[32]; 153 154 u8 btInBuf[100]; 155 u32 mptOutLen; 156 u8 mptOutBuf[100]; 157 158 }MPT_CONTEXT, *PMPT_CONTEXT; 159 /* endif */ 160 161 /* E-Fuse */ 162 #define EFUSE_MAP_SIZE 512 163 164 #define EFUSE_MAX_SIZE 512 165 /* end of E-Fuse */ 166 167 /* define RTPRIV_IOCTL_MP (SIOCIWFIRSTPRIV + 0x17) */ 168 enum { 169 WRITE_REG = 1, 170 READ_REG, 171 WRITE_RF, 172 READ_RF, 173 MP_START, 174 MP_STOP, 175 MP_RATE, 176 MP_CHANNEL, 177 MP_BANDWIDTH, 178 MP_TXPOWER, 179 MP_ANT_TX, 180 MP_ANT_RX, 181 MP_CTX, 182 MP_QUERY, 183 MP_ARX, 184 MP_PSD, 185 MP_PWRTRK, 186 MP_THER, 187 MP_IOCTL, 188 EFUSE_GET, 189 EFUSE_SET, 190 MP_RESET_STATS, 191 MP_DUMP, 192 MP_PHYPARA, 193 MP_SetRFPathSwh, 194 MP_QueryDrvStats, 195 MP_SetBT, 196 CTA_TEST, 197 MP_DISABLE_BT_COEXIST, 198 MP_PwrCtlDM, 199 #ifdef CONFIG_WOWLAN 200 MP_WOW_ENABLE, 201 #endif 202 #ifdef CONFIG_AP_WOWLAN 203 MP_AP_WOW_ENABLE, 204 #endif 205 MP_NULL, 206 MP_GET_TXPOWER_INX, 207 }; 208 209 struct mp_priv 210 { 211 struct adapter *papdater; 212 213 /* Testing Flag */ 214 u32 mode;/* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */ 215 216 u32 prev_fw_state; 217 218 /* OID cmd handler */ 219 struct mp_wiparam workparam; 220 /* u8 act_in_progress; */ 221 222 /* Tx Section */ 223 u8 TID; 224 u32 tx_pktcount; 225 u32 pktInterval; 226 struct mp_tx tx; 227 228 /* Rx Section */ 229 u32 rx_bssidpktcount; 230 u32 rx_pktcount; 231 u32 rx_pktcount_filter_out; 232 u32 rx_crcerrpktcount; 233 u32 rx_pktloss; 234 bool rx_bindicatePkt; 235 struct recv_stat rxstat; 236 237 /* RF/BB relative */ 238 u8 channel; 239 u8 bandwidth; 240 u8 prime_channel_offset; 241 u8 txpoweridx; 242 u8 txpoweridx_b; 243 u8 rateidx; 244 u32 preamble; 245 /* u8 modem; */ 246 u32 CrystalCap; 247 /* u32 curr_crystalcap; */ 248 249 u16 antenna_tx; 250 u16 antenna_rx; 251 /* u8 curr_rfpath; */ 252 253 u8 check_mp_pkt; 254 255 u8 bSetTxPower; 256 /* uint ForcedDataRate; */ 257 u8 mp_dm; 258 u8 mac_filter[ETH_ALEN]; 259 u8 bmac_filter; 260 261 struct wlan_network mp_network; 262 NDIS_802_11_MAC_ADDRESS network_macaddr; 263 264 u8 *pallocated_mp_xmitframe_buf; 265 u8 *pmp_xmtframe_buf; 266 struct __queue free_mp_xmitqueue; 267 u32 free_mp_xmitframe_cnt; 268 bool bSetRxBssid; 269 bool bTxBufCkFail; 270 271 MPT_CONTEXT MptCtx; 272 273 u8 *TXradomBuffer; 274 }; 275 276 typedef struct _IOCMD_STRUCT_ { 277 u8 cmdclass; 278 u16 value; 279 u8 index; 280 }IOCMD_STRUCT; 281 282 struct rf_reg_param { 283 u32 path; 284 u32 offset; 285 u32 value; 286 }; 287 288 struct bb_reg_param { 289 u32 offset; 290 u32 value; 291 }; 292 293 #define LOWER true 294 #define RAISE false 295 296 /* Hardware Registers */ 297 #define BB_REG_BASE_ADDR 0x800 298 299 /* MP variables */ 300 enum MP_MODE { 301 MP_OFF, 302 MP_ON, 303 MP_ERR, 304 MP_CONTINUOUS_TX, 305 MP_SINGLE_CARRIER_TX, 306 MP_CARRIER_SUPPRISSION_TX, 307 MP_SINGLE_TONE_TX, 308 MP_PACKET_TX, 309 MP_PACKET_RX 310 }; 311 312 #define MAX_RF_PATH_NUMS RF_PATH_MAX 313 314 extern u8 mpdatarate[NumRates]; 315 316 /* MP set force data rate base on the definition. */ 317 enum MPT_RATE_INDEX { 318 /* CCK rate. */ 319 MPT_RATE_1M = 0 , /* 0 */ 320 MPT_RATE_2M, 321 MPT_RATE_55M, 322 MPT_RATE_11M, /* 3 */ 323 324 /* OFDM rate. */ 325 MPT_RATE_6M, /* 4 */ 326 MPT_RATE_9M, 327 MPT_RATE_12M, 328 MPT_RATE_18M, 329 MPT_RATE_24M, 330 MPT_RATE_36M, 331 MPT_RATE_48M, 332 MPT_RATE_54M, /* 11 */ 333 334 /* HT rate. */ 335 MPT_RATE_MCS0, /* 12 */ 336 MPT_RATE_MCS1, 337 MPT_RATE_MCS2, 338 MPT_RATE_MCS3, 339 MPT_RATE_MCS4, 340 MPT_RATE_MCS5, 341 MPT_RATE_MCS6, 342 MPT_RATE_MCS7, /* 19 */ 343 MPT_RATE_MCS8, 344 MPT_RATE_MCS9, 345 MPT_RATE_MCS10, 346 MPT_RATE_MCS11, 347 MPT_RATE_MCS12, 348 MPT_RATE_MCS13, 349 MPT_RATE_MCS14, 350 MPT_RATE_MCS15, /* 27 */ 351 /* VHT rate. Total: 20*/ 352 MPT_RATE_VHT1SS_MCS0 = 100,/* To reserve MCS16~MCS31, the index starts from #100. */ 353 MPT_RATE_VHT1SS_MCS1, /* #101 */ 354 MPT_RATE_VHT1SS_MCS2, 355 MPT_RATE_VHT1SS_MCS3, 356 MPT_RATE_VHT1SS_MCS4, 357 MPT_RATE_VHT1SS_MCS5, 358 MPT_RATE_VHT1SS_MCS6, /* #106 */ 359 MPT_RATE_VHT1SS_MCS7, 360 MPT_RATE_VHT1SS_MCS8, 361 MPT_RATE_VHT1SS_MCS9, 362 MPT_RATE_VHT2SS_MCS0, 363 MPT_RATE_VHT2SS_MCS1, /* #111 */ 364 MPT_RATE_VHT2SS_MCS2, 365 MPT_RATE_VHT2SS_MCS3, 366 MPT_RATE_VHT2SS_MCS4, 367 MPT_RATE_VHT2SS_MCS5, 368 MPT_RATE_VHT2SS_MCS6, /* #116 */ 369 MPT_RATE_VHT2SS_MCS7, 370 MPT_RATE_VHT2SS_MCS8, 371 MPT_RATE_VHT2SS_MCS9, 372 MPT_RATE_LAST 373 }; 374 375 #define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */ 376 377 enum POWER_MODE { 378 POWER_LOW = 0, 379 POWER_NORMAL 380 }; 381 382 /* The following enumeration is used to define the value of Reg0xD00[30:28] or JaguarReg0x914[18:16]. */ 383 enum OFDM_TX_MODE { 384 OFDM_ALL_OFF = 0, 385 OFDM_ContinuousTx = 1, 386 OFDM_SingleCarrier = 2, 387 OFDM_SingleTone = 4, 388 }; 389 390 #define RX_PKT_BROADCAST 1 391 #define RX_PKT_DEST_ADDR 2 392 #define RX_PKT_PHY_MATCH 3 393 394 #define Mac_OFDM_OK 0x00000000 395 #define Mac_OFDM_Fail 0x10000000 396 #define Mac_OFDM_FasleAlarm 0x20000000 397 #define Mac_CCK_OK 0x30000000 398 #define Mac_CCK_Fail 0x40000000 399 #define Mac_CCK_FasleAlarm 0x50000000 400 #define Mac_HT_OK 0x60000000 401 #define Mac_HT_Fail 0x70000000 402 #define Mac_HT_FasleAlarm 0x90000000 403 #define Mac_DropPacket 0xA0000000 404 405 enum ENCRY_CTRL_STATE { 406 HW_CONTROL, /* hw encryption& decryption */ 407 SW_CONTROL, /* sw encryption& decryption */ 408 HW_ENCRY_SW_DECRY, /* hw encryption & sw decryption */ 409 SW_ENCRY_HW_DECRY /* sw encryption & hw decryption */ 410 }; 411 412 enum MPT_TXPWR_DEF { 413 MPT_CCK, 414 MPT_OFDM, /* L and HT OFDM */ 415 MPT_VHT_OFDM 416 }; 417 418 #define REG_RF_BB_GAIN_OFFSET 0x7f 419 #define RF_GAIN_OFFSET_MASK 0xfffff 420 421 /* */ 422 /* struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv); */ 423 /* int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe); */ 424 425 s32 init_mp_priv(struct adapter *padapter); 426 void free_mp_priv(struct mp_priv *pmp_priv); 427 s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel); 428 void MPT_DeInitAdapter(struct adapter *padapter); 429 s32 mp_start_test(struct adapter *padapter); 430 void mp_stop_test(struct adapter *padapter); 431 432 u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask); 433 void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val); 434 435 u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz); 436 void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz); 437 u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask); 438 void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val); 439 u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr); 440 void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val); 441 442 void SetChannel(struct adapter *padapter); 443 void SetBandwidth(struct adapter *padapter); 444 int SetTxPower(struct adapter *padapter); 445 void SetAntennaPathPower(struct adapter *padapter); 446 void SetDataRate(struct adapter *padapter); 447 448 void SetAntenna(struct adapter *padapter); 449 450 s32 SetThermalMeter(struct adapter *padapter, u8 target_ther); 451 void GetThermalMeter(struct adapter *padapter, u8 *value); 452 453 void SetContinuousTx(struct adapter *padapter, u8 bStart); 454 void SetSingleCarrierTx(struct adapter *padapter, u8 bStart); 455 void SetSingleToneTx(struct adapter *padapter, u8 bStart); 456 void SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart); 457 void PhySetTxPowerLevel(struct adapter *padapter); 458 459 void fill_txdesc_for_mp(struct adapter *padapter, u8 *ptxdesc); 460 void SetPacketTx(struct adapter *padapter); 461 void SetPacketRx(struct adapter *padapter, u8 bStartRx); 462 463 void ResetPhyRxPktCount(struct adapter *padapter); 464 u32 GetPhyRxPktReceived(struct adapter *padapter); 465 u32 GetPhyRxPktCRC32Error(struct adapter *padapter); 466 467 s32 SetPowerTracking(struct adapter *padapter, u8 enable); 468 void GetPowerTracking(struct adapter *padapter, u8 *enable); 469 470 u32 mp_query_psd(struct adapter *padapter, u8 *data); 471 472 void Hal_SetAntenna(struct adapter *padapter); 473 void Hal_SetBandwidth(struct adapter *padapter); 474 475 void Hal_SetTxPower(struct adapter *padapter); 476 void Hal_SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart); 477 void Hal_SetSingleToneTx (struct adapter *padapter , u8 bStart); 478 void Hal_SetSingleCarrierTx (struct adapter *padapter, u8 bStart); 479 void Hal_SetContinuousTx (struct adapter *padapter, u8 bStart); 480 void Hal_SetBandwidth(struct adapter *padapter); 481 482 void Hal_SetDataRate(struct adapter *padapter); 483 void Hal_SetChannel(struct adapter *padapter); 484 void Hal_SetAntennaPathPower(struct adapter *padapter); 485 s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther); 486 s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable); 487 void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable); 488 void Hal_GetThermalMeter(struct adapter *padapter, u8 *value); 489 void Hal_mpt_SwitchRfSetting(struct adapter *padapter); 490 void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14); 491 void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *padapter, bool beven); 492 void Hal_SetCCKTxPower(struct adapter *padapter, u8 * TxPower); 493 void Hal_SetOFDMTxPower(struct adapter *padapter, u8 * TxPower); 494 void Hal_TriggerRFThermalMeter(struct adapter *padapter); 495 u8 Hal_ReadRFThermalMeter(struct adapter *padapter); 496 void Hal_SetCCKContinuousTx(struct adapter *padapter, u8 bStart); 497 void Hal_SetOFDMContinuousTx(struct adapter *padapter, u8 bStart); 498 void Hal_ProSetCrystalCap (struct adapter *padapter , u32 CrystalCapVal); 499 void MP_PHY_SetRFPathSwitch(struct adapter *padapter , bool bMain); 500 u32 mpt_ProQueryCalTxPower(struct adapter *padapter, u8 RfPath); 501 void MPT_PwrCtlDM(struct adapter *padapter, u32 bstart); 502 u8 MptToMgntRate(u32 MptRateIdx); 503 504 #endif /* _RTW_MP_H_ */ 505