1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
10 #define MAX_MP_XMITBUF_SZ 2048
11 #define NR_MP_XMITFRAME 8
13 struct mp_xmit_frame {
14 struct list_head list;
16 struct pkt_attrib attrib;
22 struct adapter *padapter;
24 uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
34 typedef void(*wi_act_func)(void* padapter);
40 struct pkt_attrib attrib;
41 /* struct tx_desc desc; */
46 u32 buf_size, write_size;
50 #define MP_MAX_LINES 1000
51 #define MP_MAX_LINES_BYTES 256
53 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
54 typedef struct _MPT_CONTEXT {
55 /* Indicate if we have started Mass Production Test. */
58 /* Indicate if the driver is unloading or unloaded. */
61 _timer MPh2c_timeout_timer;
62 /* Event used to sync H2c for BT control */
68 /* 8190 PCI does not support NDIS_WORK_ITEM. */
69 /* Work Item for Mass Production Test. */
70 /* NDIS_WORK_ITEM MptWorkItem; */
71 /* RT_WORK_ITEM MptWorkItem; */
72 /* Event used to sync the case unloading driver and MptWorkItem is still in progress. */
73 /* NDIS_EVENT MptWorkItemEvent; */
74 /* To protect the following variables. */
75 /* NDIS_SPIN_LOCK MptWorkItemSpinLock; */
76 /* Indicate a MptWorkItem is scheduled and not yet finished. */
77 bool bMptWorkItemInProgress;
78 /* An instance which implements function and context of MptWorkItem. */
79 MPT_WORK_ITEM_HANDLER CurrMptAct;
81 /* 1 =Start, 0 =Stop from UI. */
83 /* _TEST_MODE, defined in MPT_Req2.h */
85 /* Variable needed in each implementation of CurrMptAct. */
86 u32 MptActType; /* Type of action performed in CurrMptAct. */
87 /* The Offset of IO operation is depend of MptActType. */
89 /* The Value of IO operation is depend of MptActType. */
91 /* The RfPath of IO operation is depend of MptActType. */
94 enum WIRELESS_MODE MptWirelessModeToSw; /* Wireless mode to switch. */
95 u8 MptChannelToSw; /* Channel to switch. */
96 u8 MptInitGainToSet; /* Initial gain to set. */
97 u32 MptBandWidth; /* bandwidth to switch. */
98 u32 MptRateIndex; /* rate index. */
99 /* Register value kept for Single Carrier Tx test. */
101 /* Register value kept for Single Carrier Tx test. */
103 /* For MP Tx Power index */
104 u8 TxPwrLevel[2]; /* rf-A, rf-B */
106 /* Content of RCR Regsiter for Mass Production Test. */
108 /* true if we only receive packets with specific pattern. */
109 bool bMptFilterPattern;
110 /* Rx OK count, statistics used in Mass Production Test. */
112 /* Rx CRC32 error count, statistics used in Mass Production Test. */
115 bool bCckContTx; /* true if we are in CCK Continuous Tx test. */
116 bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */
117 bool bStartContTx; /* true if we have start Continuous Tx test. */
118 /* true if we are in Single Carrier Tx test. */
120 /* true if we are in Carrier Suppression Tx Test. */
121 bool bCarrierSuppression;
122 /* true if we are in Single Tone Tx test. */
125 /* ACK counter asked by K.Y.. */
126 bool bMptEnableAckCounter;
129 /* SD3 Willis For 8192S to save 1T/2T RF table for ACUT Only fro ACUT delete later ~~~! */
130 /* s8 BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT]; */
131 /* s8 BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES]; */
132 /* s32 RfReadLine[2]; */
134 u8 APK_bound[2]; /* for APK path A/path B */
153 } MPT_CONTEXT, *PMPT_CONTEXT;
157 #define EFUSE_MAP_SIZE 512
159 #define EFUSE_MAX_SIZE 512
162 /* define RTPRIV_IOCTL_MP (SIOCIWFIRSTPRIV + 0x17) */
192 MP_DISABLE_BT_COEXIST,
197 #ifdef CONFIG_AP_WOWLAN
205 struct adapter *papdater;
208 u32 mode;/* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */
212 /* OID cmd handler */
213 struct mp_wiparam workparam;
214 /* u8 act_in_progress; */
223 u32 rx_bssidpktcount;
225 u32 rx_pktcount_filter_out;
226 u32 rx_crcerrpktcount;
228 bool rx_bindicatePkt;
229 struct recv_stat rxstat;
234 u8 prime_channel_offset;
241 /* u32 curr_crystalcap; */
245 /* u8 curr_rfpath; */
250 /* uint ForcedDataRate; */
252 u8 mac_filter[ETH_ALEN];
255 struct wlan_network mp_network;
256 NDIS_802_11_MAC_ADDRESS network_macaddr;
258 u8 *pallocated_mp_xmitframe_buf;
259 u8 *pmp_xmtframe_buf;
260 struct __queue free_mp_xmitqueue;
261 u32 free_mp_xmitframe_cnt;
270 typedef struct _IOCMD_STRUCT_ {
276 struct rf_reg_param {
282 struct bb_reg_param {
290 /* Hardware Registers */
291 #define BB_REG_BASE_ADDR 0x800
299 MP_SINGLE_CARRIER_TX,
300 MP_CARRIER_SUPPRISSION_TX,
306 #define MAX_RF_PATH_NUMS RF_PATH_MAX
308 extern u8 mpdatarate[NumRates];
310 /* MP set force data rate base on the definition. */
311 enum MPT_RATE_INDEX {
313 MPT_RATE_1M = 0, /* 0 */
316 MPT_RATE_11M, /* 3 */
326 MPT_RATE_54M, /* 11 */
329 MPT_RATE_MCS0, /* 12 */
336 MPT_RATE_MCS7, /* 19 */
344 MPT_RATE_MCS15, /* 27 */
345 /* VHT rate. Total: 20*/
346 MPT_RATE_VHT1SS_MCS0 = 100,/* To reserve MCS16~MCS31, the index starts from #100. */
347 MPT_RATE_VHT1SS_MCS1, /* #101 */
348 MPT_RATE_VHT1SS_MCS2,
349 MPT_RATE_VHT1SS_MCS3,
350 MPT_RATE_VHT1SS_MCS4,
351 MPT_RATE_VHT1SS_MCS5,
352 MPT_RATE_VHT1SS_MCS6, /* #106 */
353 MPT_RATE_VHT1SS_MCS7,
354 MPT_RATE_VHT1SS_MCS8,
355 MPT_RATE_VHT1SS_MCS9,
356 MPT_RATE_VHT2SS_MCS0,
357 MPT_RATE_VHT2SS_MCS1, /* #111 */
358 MPT_RATE_VHT2SS_MCS2,
359 MPT_RATE_VHT2SS_MCS3,
360 MPT_RATE_VHT2SS_MCS4,
361 MPT_RATE_VHT2SS_MCS5,
362 MPT_RATE_VHT2SS_MCS6, /* #116 */
363 MPT_RATE_VHT2SS_MCS7,
364 MPT_RATE_VHT2SS_MCS8,
365 MPT_RATE_VHT2SS_MCS9,
369 #define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
376 /* The following enumeration is used to define the value of Reg0xD00[30:28] or JaguarReg0x914[18:16]. */
379 OFDM_ContinuousTx = 1,
380 OFDM_SingleCarrier = 2,
384 #define RX_PKT_BROADCAST 1
385 #define RX_PKT_DEST_ADDR 2
386 #define RX_PKT_PHY_MATCH 3
388 #define Mac_OFDM_OK 0x00000000
389 #define Mac_OFDM_Fail 0x10000000
390 #define Mac_OFDM_FasleAlarm 0x20000000
391 #define Mac_CCK_OK 0x30000000
392 #define Mac_CCK_Fail 0x40000000
393 #define Mac_CCK_FasleAlarm 0x50000000
394 #define Mac_HT_OK 0x60000000
395 #define Mac_HT_Fail 0x70000000
396 #define Mac_HT_FasleAlarm 0x90000000
397 #define Mac_DropPacket 0xA0000000
399 enum ENCRY_CTRL_STATE {
400 HW_CONTROL, /* hw encryption& decryption */
401 SW_CONTROL, /* sw encryption& decryption */
402 HW_ENCRY_SW_DECRY, /* hw encryption & sw decryption */
403 SW_ENCRY_HW_DECRY /* sw encryption & hw decryption */
408 MPT_OFDM, /* L and HT OFDM */
412 #define REG_RF_BB_GAIN_OFFSET 0x7f
413 #define RF_GAIN_OFFSET_MASK 0xfffff
416 /* struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv); */
417 /* int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe); */
419 s32 init_mp_priv(struct adapter *padapter);
420 void free_mp_priv(struct mp_priv *pmp_priv);
421 s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel);
422 void MPT_DeInitAdapter(struct adapter *padapter);
423 s32 mp_start_test(struct adapter *padapter);
424 void mp_stop_test(struct adapter *padapter);
426 u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask);
427 void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val);
429 u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz);
430 void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz);
431 u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask);
432 void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val);
433 u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr);
434 void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val);
436 void SetChannel(struct adapter *padapter);
437 void SetBandwidth(struct adapter *padapter);
438 int SetTxPower(struct adapter *padapter);
439 void SetAntennaPathPower(struct adapter *padapter);
440 void SetDataRate(struct adapter *padapter);
442 void SetAntenna(struct adapter *padapter);
444 s32 SetThermalMeter(struct adapter *padapter, u8 target_ther);
445 void GetThermalMeter(struct adapter *padapter, u8 *value);
447 void SetContinuousTx(struct adapter *padapter, u8 bStart);
448 void SetSingleCarrierTx(struct adapter *padapter, u8 bStart);
449 void SetSingleToneTx(struct adapter *padapter, u8 bStart);
450 void SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
451 void PhySetTxPowerLevel(struct adapter *padapter);
453 void fill_txdesc_for_mp(struct adapter *padapter, u8 *ptxdesc);
454 void SetPacketTx(struct adapter *padapter);
455 void SetPacketRx(struct adapter *padapter, u8 bStartRx);
457 void ResetPhyRxPktCount(struct adapter *padapter);
458 u32 GetPhyRxPktReceived(struct adapter *padapter);
459 u32 GetPhyRxPktCRC32Error(struct adapter *padapter);
461 s32 SetPowerTracking(struct adapter *padapter, u8 enable);
462 void GetPowerTracking(struct adapter *padapter, u8 *enable);
464 u32 mp_query_psd(struct adapter *padapter, u8 *data);
466 void Hal_SetAntenna(struct adapter *padapter);
467 void Hal_SetBandwidth(struct adapter *padapter);
469 void Hal_SetTxPower(struct adapter *padapter);
470 void Hal_SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
471 void Hal_SetSingleToneTx(struct adapter *padapter, u8 bStart);
472 void Hal_SetSingleCarrierTx(struct adapter *padapter, u8 bStart);
473 void Hal_SetContinuousTx(struct adapter *padapter, u8 bStart);
474 void Hal_SetBandwidth(struct adapter *padapter);
476 void Hal_SetDataRate(struct adapter *padapter);
477 void Hal_SetChannel(struct adapter *padapter);
478 void Hal_SetAntennaPathPower(struct adapter *padapter);
479 s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther);
480 s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable);
481 void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable);
482 void Hal_GetThermalMeter(struct adapter *padapter, u8 *value);
483 void Hal_mpt_SwitchRfSetting(struct adapter *padapter);
484 void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14);
485 void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *padapter, bool beven);
486 void Hal_SetCCKTxPower(struct adapter *padapter, u8 * TxPower);
487 void Hal_SetOFDMTxPower(struct adapter *padapter, u8 * TxPower);
488 void Hal_TriggerRFThermalMeter(struct adapter *padapter);
489 u8 Hal_ReadRFThermalMeter(struct adapter *padapter);
490 void Hal_SetCCKContinuousTx(struct adapter *padapter, u8 bStart);
491 void Hal_SetOFDMContinuousTx(struct adapter *padapter, u8 bStart);
492 void Hal_ProSetCrystalCap(struct adapter *padapter, u32 CrystalCapVal);
493 void MP_PHY_SetRFPathSwitch(struct adapter *padapter, bool bMain);
494 u32 mpt_ProQueryCalTxPower(struct adapter *padapter, u8 RfPath);
495 void MPT_PwrCtlDM(struct adapter *padapter, u32 bstart);
496 u8 MptToMgntRate(u32 MptRateIdx);
498 #endif /* _RTW_MP_H_ */