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 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
25 #define STATUS_SUCCESS (0x00000000L)
26 #define STATUS_PENDING (0x00000103L)
28 #define STATUS_UNSUCCESSFUL (0xC0000001L)
29 #define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL)
30 #define STATUS_NOT_SUPPORTED (0xC00000BBL)
32 #define NDIS_STATUS_SUCCESS ((int)STATUS_SUCCESS)
33 #define NDIS_STATUS_PENDING ((int)STATUS_PENDING)
34 #define NDIS_STATUS_NOT_RECOGNIZED ((int)0x00010001L)
35 #define NDIS_STATUS_NOT_COPIED ((int)0x00010002L)
36 #define NDIS_STATUS_NOT_ACCEPTED ((int)0x00010003L)
37 #define NDIS_STATUS_CALL_ACTIVE ((int)0x00010007L)
39 #define NDIS_STATUS_FAILURE ((int)STATUS_UNSUCCESSFUL)
40 #define NDIS_STATUS_RESOURCES ((int)STATUS_INSUFFICIENT_RESOURCES)
41 #define NDIS_STATUS_CLOSING ((int)0xC0010002L)
42 #define NDIS_STATUS_BAD_VERSION ((int)0xC0010004L)
43 #define NDIS_STATUS_BAD_CHARACTERISTICS ((int)0xC0010005L)
44 #define NDIS_STATUS_ADAPTER_NOT_FOUND ((int)0xC0010006L)
45 #define NDIS_STATUS_OPEN_FAILED ((int)0xC0010007L)
46 #define NDIS_STATUS_DEVICE_FAILED ((int)0xC0010008L)
47 #define NDIS_STATUS_MULTICAST_FULL ((int)0xC0010009L)
48 #define NDIS_STATUS_MULTICAST_EXISTS ((int)0xC001000AL)
49 #define NDIS_STATUS_MULTICAST_NOT_FOUND ((int)0xC001000BL)
50 #define NDIS_STATUS_REQUEST_ABORTED ((int)0xC001000CL)
51 #define NDIS_STATUS_RESET_IN_PROGRESS ((int)0xC001000DL)
52 #define NDIS_STATUS_CLOSING_INDICATING ((int)0xC001000EL)
53 #define NDIS_STATUS_NOT_SUPPORTED ((int)STATUS_NOT_SUPPORTED)
54 #define NDIS_STATUS_INVALID_PACKET ((int)0xC001000FL)
55 #define NDIS_STATUS_OPEN_LIST_FULL ((int)0xC0010010L)
56 #define NDIS_STATUS_ADAPTER_NOT_READY ((int)0xC0010011L)
57 #define NDIS_STATUS_ADAPTER_NOT_OPEN ((int)0xC0010012L)
58 #define NDIS_STATUS_NOT_INDICATING ((int)0xC0010013L)
59 #define NDIS_STATUS_INVALID_LENGTH ((int)0xC0010014L)
60 #define NDIS_STATUS_INVALID_DATA ((int)0xC0010015L)
61 #define NDIS_STATUS_BUFFER_TOO_SHORT ((int)0xC0010016L)
62 #define NDIS_STATUS_INVALID_OID ((int)0xC0010017L)
63 #define NDIS_STATUS_ADAPTER_REMOVED ((int)0xC0010018L)
64 #define NDIS_STATUS_UNSUPPORTED_MEDIA ((int)0xC0010019L)
65 #define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((int)0xC001001AL)
66 #define NDIS_STATUS_FILE_NOT_FOUND ((int)0xC001001BL)
67 #define NDIS_STATUS_ERROR_READING_FILE ((int)0xC001001CL)
68 #define NDIS_STATUS_ALREADY_MAPPED ((int)0xC001001DL)
69 #define NDIS_STATUS_RESOURCE_CONFLICT ((int)0xC001001EL)
70 #define NDIS_STATUS_NO_CABLE ((int)0xC001001FL)
72 #define NDIS_STATUS_INVALID_SAP ((int)0xC0010020L)
73 #define NDIS_STATUS_SAP_IN_USE ((int)0xC0010021L)
74 #define NDIS_STATUS_INVALID_ADDRESS ((int)0xC0010022L)
75 #define NDIS_STATUS_VC_NOT_ACTIVATED ((int)0xC0010023L)
76 #define NDIS_STATUS_DEST_OUT_OF_ORDER ((int)0xC0010024L) /*cause 27*/
77 #define NDIS_STATUS_VC_NOT_AVAILABLE ((int)0xC0010025L) /*cause 35,45 */
78 #define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((int)0xC0010026L) /*cause 37*/
79 #define NDIS_STATUS_INCOMPATABLE_QOS ((int)0xC0010027L) /*cause 49*/
80 #define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((int)0xC0010028L) /*cause 93*/
81 #define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((int)0xC0010029L) /*cause 3 */
102 #define MAX_MP_XMITBUF_SZ 2048
103 #define NR_MP_XMITFRAME 8
105 struct mp_xmit_frame {
106 struct list_head list;
107 struct pkt_attrib attrib;
110 struct adapter *padapter;
111 struct urb *pxmit_urb[8];
112 /* insert urb, irp, and irpcnt info below... */
120 uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
130 typedef void(*wi_act_func)(void *padapter);
136 struct pkt_attrib attrib;
140 u32 buf_size, write_size;
144 #include <Hal8188EPhyCfg.h>
146 #define MP_MAX_LINES 1000
147 #define MP_MAX_LINES_BYTES 256
149 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
152 /* Indicate if we have started Mass Production Test. */
155 /* Indicate if the driver is unloading or unloaded. */
158 struct semaphore MPh2c_Sema;
159 struct timer_list MPh2c_timeout_timer;
160 /* Event used to sync H2c for BT control */
166 /* 8190 PCI does not support NDIS_WORK_ITEM. */
167 /* Work Item for Mass Production Test. */
168 /* Event used to sync the case unloading driver and MptWorkItem
169 * is still in progress. */
170 /* Indicate a MptWorkItem is scheduled and not yet finished. */
171 bool bMptWorkItemInProgress;
172 /* An instance which implements function and context of MptWorkItem. */
173 MPT_WORK_ITEM_HANDLER CurrMptAct;
175 /* 1=Start, 0=Stop from UI. */
177 /* _TEST_MODE, defined in MPT_Req2.h */
179 /* Variable needed in each implementation of CurrMptAct. */
180 u32 MptActType; /* Type of action performed in CurrMptAct. */
181 /* The Offset of IO operation is depend of MptActType. */
183 /* The Value of IO operation is depend of MptActType. */
185 /* The RfPath of IO operation is depend of MptActType. */
188 enum wireless_mode MptWirelessModeToSw; /* Wireless mode to switch. */
189 u8 MptChannelToSw; /* Channel to switch. */
190 u8 MptInitGainToSet; /* Initial gain to set. */
191 u32 MptBandWidth; /* bandwidth to switch. */
192 u32 MptRateIndex; /* rate index. */
193 /* Register value kept for Single Carrier Tx test. */
195 /* Register value kept for Single Carrier Tx test. */
197 /* For MP Tx Power index */
198 u8 TxPwrLevel[2]; /* rf-A, rf-B */
200 /* Content of RCR Regsiter for Mass Production Test. */
202 /* true if we only receive packets with specific pattern. */
203 bool bMptFilterPattern;
204 /* Rx OK count, statistics used in Mass Production Test. */
206 /* Rx CRC32 error count, statistics used in Mass Production Test. */
209 bool bCckContTx; /* true if we are in CCK Continuous Tx test. */
210 bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */
211 bool bStartContTx; /* true if we have start Continuous Tx test. */
212 /* true if we are in Single Carrier Tx test. */
214 /* true if we are in Carrier Suppression Tx Test. */
215 bool bCarrierSuppression;
216 /* true if we are in Single Tone Tx test. */
219 /* ACK counter asked by K.Y.. */
220 bool bMptEnableAckCounter;
223 u8 APK_bound[2]; /* for APK path A/path B */
273 struct adapter *papdater;
276 /* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */
281 /* OID cmd handler */
282 struct mp_wiparam workparam;
291 u32 rx_crcerrpktcount;
294 struct recv_stat rxstat;
299 u8 prime_channel_offset;
313 struct wlan_network mp_network;
314 unsigned char network_macaddr[ETH_ALEN];
316 u8 *pallocated_mp_xmitframe_buf;
317 u8 *pmp_xmtframe_buf;
318 struct __queue free_mp_xmitqueue;
319 u32 free_mp_xmitframe_cnt;
321 struct mpt_context MptCtx;
324 struct iocmd_struct {
330 struct rf_reg_param {
336 struct bb_reg_param {
345 /* Hardware Registers */
346 #define BB_REG_BASE_ADDR 0x800
354 MP_SINGLE_CARRIER_TX,
355 MP_CARRIER_SUPPRISSION_TX,
361 extern u8 mpdatarate[NumRates];
363 /* MP set force data rate base on the definition. */
364 enum mpt_rate_index {
369 MPT_RATE_11M, /* 3 */
379 MPT_RATE_54M, /* 11 */
382 MPT_RATE_MCS0, /* 12 */
389 MPT_RATE_MCS7, /* 19 */
397 MPT_RATE_MCS15, /* 27 */
401 #define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
408 #define RX_PKT_BROADCAST 1
409 #define RX_PKT_DEST_ADDR 2
410 #define RX_PKT_PHY_MATCH 3
412 enum encry_ctrl_state {
413 HW_CONTROL, /* hw encryption& decryption */
414 SW_CONTROL, /* sw encryption& decryption */
415 HW_ENCRY_SW_DECRY, /* hw encryption & sw decryption */
416 SW_ENCRY_HW_DECRY /* sw encryption & hw decryption */
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 void 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, struct tx_desc *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);
463 u32 mp_query_psd(struct adapter *pAdapter, u8 *data);
464 void Hal_SetAntenna(struct adapter *pAdapter);
465 void Hal_SetBandwidth(struct adapter *pAdapter);
466 void Hal_SetTxPower(struct adapter *pAdapter);
467 void Hal_SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart);
468 void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart);
469 void Hal_SetSingleCarrierTx (struct adapter *pAdapter, u8 bStart);
470 void Hal_SetContinuousTx (struct adapter *pAdapter, u8 bStart);
471 void Hal_SetBandwidth(struct adapter *pAdapter);
472 void Hal_SetDataRate(struct adapter *pAdapter);
473 void Hal_SetChannel(struct adapter *pAdapter);
474 void Hal_SetAntennaPathPower(struct adapter *pAdapter);
475 s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther);
476 s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable);
477 void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable);
478 void Hal_GetThermalMeter(struct adapter *pAdapter, u8 *value);
479 void Hal_mpt_SwitchRfSetting(struct adapter *pAdapter);
480 void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14);
481 void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven);
482 void Hal_SetCCKTxPower(struct adapter *pAdapter, u8 * TxPower);
483 void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 * TxPower);
484 void Hal_TriggerRFThermalMeter(struct adapter *pAdapter);
485 u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter);
486 void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart);
487 void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart);
488 void Hal_ProSetCrystalCap (struct adapter *pAdapter , u32 CrystalCapVal);
489 void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv);
490 void MP_PHY_SetRFPathSwitch(struct adapter *pAdapter ,bool bMain);
492 #endif /* _RTW_MP_H_ */