1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
18 #define MAX_MP_XMITBUF_SZ 2048
19 #define NR_MP_XMITFRAME 8
23 struct list_head list;
25 struct pkt_attrib attrib;
31 struct adapter *padapter;
33 uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
44 typedef void(*wi_act_func)(void* padapter);
51 struct pkt_attrib attrib;
52 /* struct tx_desc desc; */
57 u32 buf_size, write_size;
61 #define MP_MAX_LINES 1000
62 #define MP_MAX_LINES_BYTES 256
64 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
65 typedef struct _MPT_CONTEXT
67 /* Indicate if we have started Mass Production Test. */
70 /* Indicate if the driver is unloading or unloaded. */
74 _timer MPh2c_timeout_timer;
75 /* Event used to sync H2c for BT control */
81 /* 8190 PCI does not support NDIS_WORK_ITEM. */
82 /* Work Item for Mass Production Test. */
83 /* NDIS_WORK_ITEM MptWorkItem; */
84 /* RT_WORK_ITEM MptWorkItem; */
85 /* Event used to sync the case unloading driver and MptWorkItem is still in progress. */
86 /* NDIS_EVENT MptWorkItemEvent; */
87 /* To protect the following variables. */
88 /* NDIS_SPIN_LOCK MptWorkItemSpinLock; */
89 /* Indicate a MptWorkItem is scheduled and not yet finished. */
90 bool bMptWorkItemInProgress;
91 /* An instance which implements function and context of MptWorkItem. */
92 MPT_WORK_ITEM_HANDLER CurrMptAct;
94 /* 1 =Start, 0 =Stop from UI. */
96 /* _TEST_MODE, defined in MPT_Req2.h */
98 /* Variable needed in each implementation of CurrMptAct. */
99 u32 MptActType; /* Type of action performed in CurrMptAct. */
100 /* The Offset of IO operation is depend of MptActType. */
102 /* The Value of IO operation is depend of MptActType. */
104 /* The RfPath of IO operation is depend of MptActType. */
107 enum WIRELESS_MODE MptWirelessModeToSw; /* Wireless mode to switch. */
108 u8 MptChannelToSw; /* Channel to switch. */
109 u8 MptInitGainToSet; /* Initial gain to set. */
110 u32 MptBandWidth; /* bandwidth to switch. */
111 u32 MptRateIndex; /* rate index. */
112 /* Register value kept for Single Carrier Tx test. */
114 /* Register value kept for Single Carrier Tx test. */
116 /* For MP Tx Power index */
117 u8 TxPwrLevel[2]; /* rf-A, rf-B */
119 /* Content of RCR Regsiter for Mass Production Test. */
121 /* true if we only receive packets with specific pattern. */
122 bool bMptFilterPattern;
123 /* Rx OK count, statistics used in Mass Production Test. */
125 /* Rx CRC32 error count, statistics used in Mass Production Test. */
128 bool bCckContTx; /* true if we are in CCK Continuous Tx test. */
129 bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */
130 bool bStartContTx; /* true if we have start Continuous Tx test. */
131 /* true if we are in Single Carrier Tx test. */
133 /* true if we are in Carrier Suppression Tx Test. */
134 bool bCarrierSuppression;
135 /* true if we are in Single Tone Tx test. */
138 /* ACK counter asked by K.Y.. */
139 bool bMptEnableAckCounter;
142 /* SD3 Willis For 8192S to save 1T/2T RF table for ACUT Only fro ACUT delete later ~~~! */
143 /* s8 BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT]; */
144 /* s8 BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES]; */
145 /* s32 RfReadLine[2]; */
147 u8 APK_bound[2]; /* for APK path A/path B */
166 }MPT_CONTEXT, *PMPT_CONTEXT;
170 #define EFUSE_MAP_SIZE 512
172 #define EFUSE_MAX_SIZE 512
175 /* define RTPRIV_IOCTL_MP (SIOCIWFIRSTPRIV + 0x17) */
205 MP_DISABLE_BT_COEXIST,
210 #ifdef CONFIG_AP_WOWLAN
219 struct adapter *papdater;
222 u32 mode;/* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */
226 /* OID cmd handler */
227 struct mp_wiparam workparam;
228 /* u8 act_in_progress; */
237 u32 rx_bssidpktcount;
239 u32 rx_pktcount_filter_out;
240 u32 rx_crcerrpktcount;
242 bool rx_bindicatePkt;
243 struct recv_stat rxstat;
248 u8 prime_channel_offset;
255 /* u32 curr_crystalcap; */
259 /* u8 curr_rfpath; */
264 /* uint ForcedDataRate; */
266 u8 mac_filter[ETH_ALEN];
269 struct wlan_network mp_network;
270 NDIS_802_11_MAC_ADDRESS network_macaddr;
272 u8 *pallocated_mp_xmitframe_buf;
273 u8 *pmp_xmtframe_buf;
274 struct __queue free_mp_xmitqueue;
275 u32 free_mp_xmitframe_cnt;
284 typedef struct _IOCMD_STRUCT_ {
290 struct rf_reg_param {
296 struct bb_reg_param {
304 /* Hardware Registers */
305 #define BB_REG_BASE_ADDR 0x800
313 MP_SINGLE_CARRIER_TX,
314 MP_CARRIER_SUPPRISSION_TX,
320 #define MAX_RF_PATH_NUMS RF_PATH_MAX
322 extern u8 mpdatarate[NumRates];
324 /* MP set force data rate base on the definition. */
325 enum MPT_RATE_INDEX {
327 MPT_RATE_1M = 0 , /* 0 */
330 MPT_RATE_11M, /* 3 */
340 MPT_RATE_54M, /* 11 */
343 MPT_RATE_MCS0, /* 12 */
350 MPT_RATE_MCS7, /* 19 */
358 MPT_RATE_MCS15, /* 27 */
359 /* VHT rate. Total: 20*/
360 MPT_RATE_VHT1SS_MCS0 = 100,/* To reserve MCS16~MCS31, the index starts from #100. */
361 MPT_RATE_VHT1SS_MCS1, /* #101 */
362 MPT_RATE_VHT1SS_MCS2,
363 MPT_RATE_VHT1SS_MCS3,
364 MPT_RATE_VHT1SS_MCS4,
365 MPT_RATE_VHT1SS_MCS5,
366 MPT_RATE_VHT1SS_MCS6, /* #106 */
367 MPT_RATE_VHT1SS_MCS7,
368 MPT_RATE_VHT1SS_MCS8,
369 MPT_RATE_VHT1SS_MCS9,
370 MPT_RATE_VHT2SS_MCS0,
371 MPT_RATE_VHT2SS_MCS1, /* #111 */
372 MPT_RATE_VHT2SS_MCS2,
373 MPT_RATE_VHT2SS_MCS3,
374 MPT_RATE_VHT2SS_MCS4,
375 MPT_RATE_VHT2SS_MCS5,
376 MPT_RATE_VHT2SS_MCS6, /* #116 */
377 MPT_RATE_VHT2SS_MCS7,
378 MPT_RATE_VHT2SS_MCS8,
379 MPT_RATE_VHT2SS_MCS9,
383 #define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
390 /* The following enumeration is used to define the value of Reg0xD00[30:28] or JaguarReg0x914[18:16]. */
393 OFDM_ContinuousTx = 1,
394 OFDM_SingleCarrier = 2,
398 #define RX_PKT_BROADCAST 1
399 #define RX_PKT_DEST_ADDR 2
400 #define RX_PKT_PHY_MATCH 3
402 #define Mac_OFDM_OK 0x00000000
403 #define Mac_OFDM_Fail 0x10000000
404 #define Mac_OFDM_FasleAlarm 0x20000000
405 #define Mac_CCK_OK 0x30000000
406 #define Mac_CCK_Fail 0x40000000
407 #define Mac_CCK_FasleAlarm 0x50000000
408 #define Mac_HT_OK 0x60000000
409 #define Mac_HT_Fail 0x70000000
410 #define Mac_HT_FasleAlarm 0x90000000
411 #define Mac_DropPacket 0xA0000000
413 enum ENCRY_CTRL_STATE {
414 HW_CONTROL, /* hw encryption& decryption */
415 SW_CONTROL, /* sw encryption& decryption */
416 HW_ENCRY_SW_DECRY, /* hw encryption & sw decryption */
417 SW_ENCRY_HW_DECRY /* sw encryption & hw decryption */
422 MPT_OFDM, /* L and HT OFDM */
426 #define REG_RF_BB_GAIN_OFFSET 0x7f
427 #define RF_GAIN_OFFSET_MASK 0xfffff
430 /* struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv); */
431 /* int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe); */
433 s32 init_mp_priv(struct adapter *padapter);
434 void free_mp_priv(struct mp_priv *pmp_priv);
435 s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel);
436 void MPT_DeInitAdapter(struct adapter *padapter);
437 s32 mp_start_test(struct adapter *padapter);
438 void mp_stop_test(struct adapter *padapter);
440 u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask);
441 void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val);
443 u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz);
444 void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz);
445 u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask);
446 void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val);
447 u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr);
448 void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val);
450 void SetChannel(struct adapter *padapter);
451 void SetBandwidth(struct adapter *padapter);
452 int SetTxPower(struct adapter *padapter);
453 void SetAntennaPathPower(struct adapter *padapter);
454 void SetDataRate(struct adapter *padapter);
456 void SetAntenna(struct adapter *padapter);
458 s32 SetThermalMeter(struct adapter *padapter, u8 target_ther);
459 void GetThermalMeter(struct adapter *padapter, u8 *value);
461 void SetContinuousTx(struct adapter *padapter, u8 bStart);
462 void SetSingleCarrierTx(struct adapter *padapter, u8 bStart);
463 void SetSingleToneTx(struct adapter *padapter, u8 bStart);
464 void SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
465 void PhySetTxPowerLevel(struct adapter *padapter);
467 void fill_txdesc_for_mp(struct adapter *padapter, u8 *ptxdesc);
468 void SetPacketTx(struct adapter *padapter);
469 void SetPacketRx(struct adapter *padapter, u8 bStartRx);
471 void ResetPhyRxPktCount(struct adapter *padapter);
472 u32 GetPhyRxPktReceived(struct adapter *padapter);
473 u32 GetPhyRxPktCRC32Error(struct adapter *padapter);
475 s32 SetPowerTracking(struct adapter *padapter, u8 enable);
476 void GetPowerTracking(struct adapter *padapter, u8 *enable);
478 u32 mp_query_psd(struct adapter *padapter, u8 *data);
480 void Hal_SetAntenna(struct adapter *padapter);
481 void Hal_SetBandwidth(struct adapter *padapter);
483 void Hal_SetTxPower(struct adapter *padapter);
484 void Hal_SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
485 void Hal_SetSingleToneTx (struct adapter *padapter , u8 bStart);
486 void Hal_SetSingleCarrierTx (struct adapter *padapter, u8 bStart);
487 void Hal_SetContinuousTx (struct adapter *padapter, u8 bStart);
488 void Hal_SetBandwidth(struct adapter *padapter);
490 void Hal_SetDataRate(struct adapter *padapter);
491 void Hal_SetChannel(struct adapter *padapter);
492 void Hal_SetAntennaPathPower(struct adapter *padapter);
493 s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther);
494 s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable);
495 void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable);
496 void Hal_GetThermalMeter(struct adapter *padapter, u8 *value);
497 void Hal_mpt_SwitchRfSetting(struct adapter *padapter);
498 void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14);
499 void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *padapter, bool beven);
500 void Hal_SetCCKTxPower(struct adapter *padapter, u8 * TxPower);
501 void Hal_SetOFDMTxPower(struct adapter *padapter, u8 * TxPower);
502 void Hal_TriggerRFThermalMeter(struct adapter *padapter);
503 u8 Hal_ReadRFThermalMeter(struct adapter *padapter);
504 void Hal_SetCCKContinuousTx(struct adapter *padapter, u8 bStart);
505 void Hal_SetOFDMContinuousTx(struct adapter *padapter, u8 bStart);
506 void Hal_ProSetCrystalCap (struct adapter *padapter , u32 CrystalCapVal);
507 void MP_PHY_SetRFPathSwitch(struct adapter *padapter , bool bMain);
508 u32 mpt_ProQueryCalTxPower(struct adapter *padapter, u8 RfPath);
509 void MPT_PwrCtlDM(struct adapter *padapter, u32 bstart);
510 u8 MptToMgntRate(u32 MptRateIdx);
512 #endif /* _RTW_MP_H_ */