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
15 struct list_head list;
17 struct pkt_attrib attrib;
23 struct adapter *padapter;
25 uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
36 typedef void(*wi_act_func)(void* padapter);
43 struct pkt_attrib attrib;
44 /* struct tx_desc desc; */
49 u32 buf_size, write_size;
53 #define MP_MAX_LINES 1000
54 #define MP_MAX_LINES_BYTES 256
56 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
57 typedef struct _MPT_CONTEXT
59 /* Indicate if we have started Mass Production Test. */
62 /* Indicate if the driver is unloading or unloaded. */
65 _timer MPh2c_timeout_timer;
66 /* Event used to sync H2c for BT control */
72 /* 8190 PCI does not support NDIS_WORK_ITEM. */
73 /* Work Item for Mass Production Test. */
74 /* NDIS_WORK_ITEM MptWorkItem; */
75 /* RT_WORK_ITEM MptWorkItem; */
76 /* Event used to sync the case unloading driver and MptWorkItem is still in progress. */
77 /* NDIS_EVENT MptWorkItemEvent; */
78 /* To protect the following variables. */
79 /* NDIS_SPIN_LOCK MptWorkItemSpinLock; */
80 /* Indicate a MptWorkItem is scheduled and not yet finished. */
81 bool bMptWorkItemInProgress;
82 /* An instance which implements function and context of MptWorkItem. */
83 MPT_WORK_ITEM_HANDLER CurrMptAct;
85 /* 1 =Start, 0 =Stop from UI. */
87 /* _TEST_MODE, defined in MPT_Req2.h */
89 /* Variable needed in each implementation of CurrMptAct. */
90 u32 MptActType; /* Type of action performed in CurrMptAct. */
91 /* The Offset of IO operation is depend of MptActType. */
93 /* The Value of IO operation is depend of MptActType. */
95 /* The RfPath of IO operation is depend of MptActType. */
98 enum WIRELESS_MODE MptWirelessModeToSw; /* Wireless mode to switch. */
99 u8 MptChannelToSw; /* Channel to switch. */
100 u8 MptInitGainToSet; /* Initial gain to set. */
101 u32 MptBandWidth; /* bandwidth to switch. */
102 u32 MptRateIndex; /* rate index. */
103 /* Register value kept for Single Carrier Tx test. */
105 /* Register value kept for Single Carrier Tx test. */
107 /* For MP Tx Power index */
108 u8 TxPwrLevel[2]; /* rf-A, rf-B */
110 /* Content of RCR Regsiter for Mass Production Test. */
112 /* true if we only receive packets with specific pattern. */
113 bool bMptFilterPattern;
114 /* Rx OK count, statistics used in Mass Production Test. */
116 /* Rx CRC32 error count, statistics used in Mass Production Test. */
119 bool bCckContTx; /* true if we are in CCK Continuous Tx test. */
120 bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */
121 bool bStartContTx; /* true if we have start Continuous Tx test. */
122 /* true if we are in Single Carrier Tx test. */
124 /* true if we are in Carrier Suppression Tx Test. */
125 bool bCarrierSuppression;
126 /* true if we are in Single Tone Tx test. */
129 /* ACK counter asked by K.Y.. */
130 bool bMptEnableAckCounter;
133 /* SD3 Willis For 8192S to save 1T/2T RF table for ACUT Only fro ACUT delete later ~~~! */
134 /* s8 BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT]; */
135 /* s8 BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES]; */
136 /* s32 RfReadLine[2]; */
138 u8 APK_bound[2]; /* for APK path A/path B */
157 }MPT_CONTEXT, *PMPT_CONTEXT;
161 #define EFUSE_MAP_SIZE 512
163 #define EFUSE_MAX_SIZE 512
166 /* define RTPRIV_IOCTL_MP (SIOCIWFIRSTPRIV + 0x17) */
196 MP_DISABLE_BT_COEXIST,
201 #ifdef CONFIG_AP_WOWLAN
210 struct adapter *papdater;
213 u32 mode;/* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */
217 /* OID cmd handler */
218 struct mp_wiparam workparam;
219 /* u8 act_in_progress; */
228 u32 rx_bssidpktcount;
230 u32 rx_pktcount_filter_out;
231 u32 rx_crcerrpktcount;
233 bool rx_bindicatePkt;
234 struct recv_stat rxstat;
239 u8 prime_channel_offset;
246 /* u32 curr_crystalcap; */
250 /* u8 curr_rfpath; */
255 /* uint ForcedDataRate; */
257 u8 mac_filter[ETH_ALEN];
260 struct wlan_network mp_network;
261 NDIS_802_11_MAC_ADDRESS network_macaddr;
263 u8 *pallocated_mp_xmitframe_buf;
264 u8 *pmp_xmtframe_buf;
265 struct __queue free_mp_xmitqueue;
266 u32 free_mp_xmitframe_cnt;
275 typedef struct _IOCMD_STRUCT_ {
281 struct rf_reg_param {
287 struct bb_reg_param {
295 /* Hardware Registers */
296 #define BB_REG_BASE_ADDR 0x800
304 MP_SINGLE_CARRIER_TX,
305 MP_CARRIER_SUPPRISSION_TX,
311 #define MAX_RF_PATH_NUMS RF_PATH_MAX
313 extern u8 mpdatarate[NumRates];
315 /* MP set force data rate base on the definition. */
316 enum MPT_RATE_INDEX {
318 MPT_RATE_1M = 0 , /* 0 */
321 MPT_RATE_11M, /* 3 */
331 MPT_RATE_54M, /* 11 */
334 MPT_RATE_MCS0, /* 12 */
341 MPT_RATE_MCS7, /* 19 */
349 MPT_RATE_MCS15, /* 27 */
350 /* VHT rate. Total: 20*/
351 MPT_RATE_VHT1SS_MCS0 = 100,/* To reserve MCS16~MCS31, the index starts from #100. */
352 MPT_RATE_VHT1SS_MCS1, /* #101 */
353 MPT_RATE_VHT1SS_MCS2,
354 MPT_RATE_VHT1SS_MCS3,
355 MPT_RATE_VHT1SS_MCS4,
356 MPT_RATE_VHT1SS_MCS5,
357 MPT_RATE_VHT1SS_MCS6, /* #106 */
358 MPT_RATE_VHT1SS_MCS7,
359 MPT_RATE_VHT1SS_MCS8,
360 MPT_RATE_VHT1SS_MCS9,
361 MPT_RATE_VHT2SS_MCS0,
362 MPT_RATE_VHT2SS_MCS1, /* #111 */
363 MPT_RATE_VHT2SS_MCS2,
364 MPT_RATE_VHT2SS_MCS3,
365 MPT_RATE_VHT2SS_MCS4,
366 MPT_RATE_VHT2SS_MCS5,
367 MPT_RATE_VHT2SS_MCS6, /* #116 */
368 MPT_RATE_VHT2SS_MCS7,
369 MPT_RATE_VHT2SS_MCS8,
370 MPT_RATE_VHT2SS_MCS9,
374 #define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
381 /* The following enumeration is used to define the value of Reg0xD00[30:28] or JaguarReg0x914[18:16]. */
384 OFDM_ContinuousTx = 1,
385 OFDM_SingleCarrier = 2,
389 #define RX_PKT_BROADCAST 1
390 #define RX_PKT_DEST_ADDR 2
391 #define RX_PKT_PHY_MATCH 3
393 #define Mac_OFDM_OK 0x00000000
394 #define Mac_OFDM_Fail 0x10000000
395 #define Mac_OFDM_FasleAlarm 0x20000000
396 #define Mac_CCK_OK 0x30000000
397 #define Mac_CCK_Fail 0x40000000
398 #define Mac_CCK_FasleAlarm 0x50000000
399 #define Mac_HT_OK 0x60000000
400 #define Mac_HT_Fail 0x70000000
401 #define Mac_HT_FasleAlarm 0x90000000
402 #define Mac_DropPacket 0xA0000000
404 enum ENCRY_CTRL_STATE {
405 HW_CONTROL, /* hw encryption& decryption */
406 SW_CONTROL, /* sw encryption& decryption */
407 HW_ENCRY_SW_DECRY, /* hw encryption & sw decryption */
408 SW_ENCRY_HW_DECRY /* sw encryption & hw decryption */
413 MPT_OFDM, /* L and HT OFDM */
417 #define REG_RF_BB_GAIN_OFFSET 0x7f
418 #define RF_GAIN_OFFSET_MASK 0xfffff
421 /* struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv); */
422 /* int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe); */
424 s32 init_mp_priv(struct adapter *padapter);
425 void free_mp_priv(struct mp_priv *pmp_priv);
426 s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel);
427 void MPT_DeInitAdapter(struct adapter *padapter);
428 s32 mp_start_test(struct adapter *padapter);
429 void mp_stop_test(struct adapter *padapter);
431 u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask);
432 void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val);
434 u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz);
435 void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz);
436 u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask);
437 void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val);
438 u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr);
439 void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val);
441 void SetChannel(struct adapter *padapter);
442 void SetBandwidth(struct adapter *padapter);
443 int SetTxPower(struct adapter *padapter);
444 void SetAntennaPathPower(struct adapter *padapter);
445 void SetDataRate(struct adapter *padapter);
447 void SetAntenna(struct adapter *padapter);
449 s32 SetThermalMeter(struct adapter *padapter, u8 target_ther);
450 void GetThermalMeter(struct adapter *padapter, u8 *value);
452 void SetContinuousTx(struct adapter *padapter, u8 bStart);
453 void SetSingleCarrierTx(struct adapter *padapter, u8 bStart);
454 void SetSingleToneTx(struct adapter *padapter, u8 bStart);
455 void SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
456 void PhySetTxPowerLevel(struct adapter *padapter);
458 void fill_txdesc_for_mp(struct adapter *padapter, u8 *ptxdesc);
459 void SetPacketTx(struct adapter *padapter);
460 void SetPacketRx(struct adapter *padapter, u8 bStartRx);
462 void ResetPhyRxPktCount(struct adapter *padapter);
463 u32 GetPhyRxPktReceived(struct adapter *padapter);
464 u32 GetPhyRxPktCRC32Error(struct adapter *padapter);
466 s32 SetPowerTracking(struct adapter *padapter, u8 enable);
467 void GetPowerTracking(struct adapter *padapter, u8 *enable);
469 u32 mp_query_psd(struct adapter *padapter, u8 *data);
471 void Hal_SetAntenna(struct adapter *padapter);
472 void Hal_SetBandwidth(struct adapter *padapter);
474 void Hal_SetTxPower(struct adapter *padapter);
475 void Hal_SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
476 void Hal_SetSingleToneTx (struct adapter *padapter , u8 bStart);
477 void Hal_SetSingleCarrierTx (struct adapter *padapter, u8 bStart);
478 void Hal_SetContinuousTx (struct adapter *padapter, u8 bStart);
479 void Hal_SetBandwidth(struct adapter *padapter);
481 void Hal_SetDataRate(struct adapter *padapter);
482 void Hal_SetChannel(struct adapter *padapter);
483 void Hal_SetAntennaPathPower(struct adapter *padapter);
484 s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther);
485 s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable);
486 void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable);
487 void Hal_GetThermalMeter(struct adapter *padapter, u8 *value);
488 void Hal_mpt_SwitchRfSetting(struct adapter *padapter);
489 void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14);
490 void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *padapter, bool beven);
491 void Hal_SetCCKTxPower(struct adapter *padapter, u8 * TxPower);
492 void Hal_SetOFDMTxPower(struct adapter *padapter, u8 * TxPower);
493 void Hal_TriggerRFThermalMeter(struct adapter *padapter);
494 u8 Hal_ReadRFThermalMeter(struct adapter *padapter);
495 void Hal_SetCCKContinuousTx(struct adapter *padapter, u8 bStart);
496 void Hal_SetOFDMContinuousTx(struct adapter *padapter, u8 bStart);
497 void Hal_ProSetCrystalCap (struct adapter *padapter , u32 CrystalCapVal);
498 void MP_PHY_SetRFPathSwitch(struct adapter *padapter , bool bMain);
499 u32 mpt_ProQueryCalTxPower(struct adapter *padapter, u8 RfPath);
500 void MPT_PwrCtlDM(struct adapter *padapter, u32 bstart);
501 u8 MptToMgntRate(u32 MptRateIdx);
503 #endif /* _RTW_MP_H_ */