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)];
38 struct pkt_attrib attrib;
39 /* struct tx_desc desc; */
44 u32 buf_size, write_size;
48 #define MP_MAX_LINES 1000
49 #define MP_MAX_LINES_BYTES 256
51 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
53 /* Indicate if we have started Mass Production Test. */
56 /* Indicate if the driver is unloading or unloaded. */
59 struct timer_list MPh2c_timeout_timer;
60 /* Event used to sync H2c for BT control */
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;
79 /* 1 =Start, 0 =Stop from UI. */
81 /* _TEST_MODE, defined in MPT_Req2.h */
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. */
87 /* The Value of IO operation is depend of MptActType. */
89 /* The RfPath of IO operation is depend of MptActType. */
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. */
99 /* Register value kept for Single Carrier Tx test. */
101 /* For MP Tx Power index */
102 u8 TxPwrLevel[2]; /* rf-A, rf-B */
104 /* Content of RCR Register for Mass Production Test. */
106 /* true if we only receive packets with specific pattern. */
107 bool bMptFilterPattern;
108 /* Rx OK count, statistics used in Mass Production Test. */
110 /* Rx CRC32 error count, statistics used in Mass Production Test. */
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. */
118 /* true if we are in Carrier Suppression Tx Test. */
119 bool bCarrierSuppression;
120 /* true if we are in Single Tone Tx test. */
123 /* ACK counter asked by K.Y.. */
124 bool bMptEnableAckCounter;
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]; */
132 u8 APK_bound[2]; /* for APK path A/path B */
155 #define EFUSE_MAP_SIZE 512
157 #define EFUSE_MAX_SIZE 512
160 /* define RTPRIV_IOCTL_MP (SIOCIWFIRSTPRIV + 0x17) */
190 MP_DISABLE_BT_COEXIST,
197 struct adapter *papdater;
200 u32 mode;/* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */
204 /* OID cmd handler */
205 struct mp_wiparam workparam;
206 /* u8 act_in_progress; */
215 u32 rx_bssidpktcount;
217 u32 rx_pktcount_filter_out;
218 u32 rx_crcerrpktcount;
220 bool rx_bindicatePkt;
221 struct recv_stat rxstat;
226 u8 prime_channel_offset;
233 /* u32 curr_crystalcap; */
237 /* u8 curr_rfpath; */
242 /* uint ForcedDataRate; */
244 u8 mac_filter[ETH_ALEN];
247 struct wlan_network mp_network;
248 NDIS_802_11_MAC_ADDRESS network_macaddr;
250 u8 *pallocated_mp_xmitframe_buf;
251 u8 *pmp_xmtframe_buf;
252 struct __queue free_mp_xmitqueue;
253 u32 free_mp_xmitframe_cnt;
257 struct mpt_context MptCtx;
265 /* Hardware Registers */
266 #define BB_REG_BASE_ADDR 0x800
268 #define MAX_RF_PATH_NUMS RF_PATH_MAX
270 extern u8 mpdatarate[NumRates];
272 #define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
274 #define RX_PKT_BROADCAST 1
275 #define RX_PKT_DEST_ADDR 2
276 #define RX_PKT_PHY_MATCH 3
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
289 #define REG_RF_BB_GAIN_OFFSET 0x7f
290 #define RF_GAIN_OFFSET_MASK 0xfffff
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); */
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);
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);
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);
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);
319 void SetAntenna(struct adapter *padapter);
321 s32 SetThermalMeter(struct adapter *padapter, u8 target_ther);
322 void GetThermalMeter(struct adapter *padapter, u8 *value);
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);
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);
334 void ResetPhyRxPktCount(struct adapter *padapter);
335 u32 GetPhyRxPktReceived(struct adapter *padapter);
336 u32 GetPhyRxPktCRC32Error(struct adapter *padapter);
338 s32 SetPowerTracking(struct adapter *padapter, u8 enable);
339 void GetPowerTracking(struct adapter *padapter, u8 *enable);
341 u32 mp_query_psd(struct adapter *padapter, u8 *data);
343 void Hal_SetAntenna(struct adapter *padapter);
344 void Hal_SetBandwidth(struct adapter *padapter);
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);
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);
374 #endif /* _RTW_MP_H_ */