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 */
103 #define MAX_MP_XMITBUF_SZ 2048
104 #define NR_MP_XMITFRAME 8
106 struct mp_xmit_frame {
107 struct list_head list;
108 struct pkt_attrib attrib;
111 struct adapter *padapter;
112 struct urb *pxmit_urb[8];
113 /* insert urb, irp, and irpcnt info below... */
121 uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
131 typedef void(*wi_act_func)(void *padapter);
137 struct pkt_attrib attrib;
141 u32 buf_size, write_size;
145 #include <Hal8188EPhyCfg.h>
147 #define MP_MAX_LINES 1000
148 #define MP_MAX_LINES_BYTES 256
150 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
153 /* Indicate if we have started Mass Production Test. */
156 /* Indicate if the driver is unloading or unloaded. */
159 struct semaphore MPh2c_Sema;
160 struct timer_list MPh2c_timeout_timer;
161 /* Event used to sync H2c for BT control */
167 /* 8190 PCI does not support NDIS_WORK_ITEM. */
168 /* Work Item for Mass Production Test. */
169 /* Event used to sync the case unloading driver and MptWorkItem
170 * is still in progress. */
171 /* Indicate a MptWorkItem is scheduled and not yet finished. */
172 bool bMptWorkItemInProgress;
173 /* An instance which implements function and context of MptWorkItem. */
174 MPT_WORK_ITEM_HANDLER CurrMptAct;
176 /* 1=Start, 0=Stop from UI. */
178 /* _TEST_MODE, defined in MPT_Req2.h */
180 /* Variable needed in each implementation of CurrMptAct. */
181 u32 MptActType; /* Type of action performed in CurrMptAct. */
182 /* The Offset of IO operation is depend of MptActType. */
184 /* The Value of IO operation is depend of MptActType. */
186 /* The RfPath of IO operation is depend of MptActType. */
189 enum wireless_mode MptWirelessModeToSw; /* Wireless mode to switch. */
190 u8 MptChannelToSw; /* Channel to switch. */
191 u8 MptInitGainToSet; /* Initial gain to set. */
192 u32 MptBandWidth; /* bandwidth to switch. */
193 u32 MptRateIndex; /* rate index. */
194 /* Register value kept for Single Carrier Tx test. */
196 /* Register value kept for Single Carrier Tx test. */
198 /* For MP Tx Power index */
199 u8 TxPwrLevel[2]; /* rf-A, rf-B */
201 /* Content of RCR Regsiter for Mass Production Test. */
203 /* true if we only receive packets with specific pattern. */
204 bool bMptFilterPattern;
205 /* Rx OK count, statistics used in Mass Production Test. */
207 /* Rx CRC32 error count, statistics used in Mass Production Test. */
210 bool bCckContTx; /* true if we are in CCK Continuous Tx test. */
211 bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */
212 bool bStartContTx; /* true if we have start Continuous Tx test. */
213 /* true if we are in Single Carrier Tx test. */
215 /* true if we are in Carrier Suppression Tx Test. */
216 bool bCarrierSuppression;
217 /* true if we are in Single Tone Tx test. */
220 /* ACK counter asked by K.Y.. */
221 bool bMptEnableAckCounter;
224 u8 APK_bound[2]; /* for APK path A/path B */
274 struct adapter *papdater;
277 /* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */
282 /* OID cmd handler */
283 struct mp_wiparam workparam;
292 u32 rx_crcerrpktcount;
295 struct recv_stat rxstat;
300 u8 prime_channel_offset;
314 struct wlan_network mp_network;
315 unsigned char network_macaddr[ETH_ALEN];
317 u8 *pallocated_mp_xmitframe_buf;
318 u8 *pmp_xmtframe_buf;
319 struct __queue free_mp_xmitqueue;
320 u32 free_mp_xmitframe_cnt;
322 struct mpt_context MptCtx;
325 struct iocmd_struct {
331 struct rf_reg_param {
337 struct bb_reg_param {
346 /* Hardware Registers */
347 #define BB_REG_BASE_ADDR 0x800
355 MP_SINGLE_CARRIER_TX,
356 MP_CARRIER_SUPPRISSION_TX,
362 #define MAX_RF_PATH_NUMS RF_PATH_MAX
364 extern u8 mpdatarate[NumRates];
366 /* MP set force data rate base on the definition. */
367 enum mpt_rate_index {
372 MPT_RATE_11M, /* 3 */
382 MPT_RATE_54M, /* 11 */
385 MPT_RATE_MCS0, /* 12 */
392 MPT_RATE_MCS7, /* 19 */
400 MPT_RATE_MCS15, /* 27 */
404 #define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
411 #define RX_PKT_BROADCAST 1
412 #define RX_PKT_DEST_ADDR 2
413 #define RX_PKT_PHY_MATCH 3
415 enum encry_ctrl_state {
416 HW_CONTROL, /* hw encryption& decryption */
417 SW_CONTROL, /* sw encryption& decryption */
418 HW_ENCRY_SW_DECRY, /* hw encryption & sw decryption */
419 SW_ENCRY_HW_DECRY /* sw encryption & hw decryption */
422 s32 init_mp_priv(struct adapter *padapter);
423 void free_mp_priv(struct mp_priv *pmp_priv);
424 s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel);
425 void MPT_DeInitAdapter(struct adapter *padapter);
426 s32 mp_start_test(struct adapter *padapter);
427 void mp_stop_test(struct adapter *padapter);
429 u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask);
430 void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val);
432 u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz);
433 void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz);
434 u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask);
435 void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val);
436 u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr);
437 void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val);
439 void SetChannel(struct adapter *pAdapter);
440 void SetBandwidth(struct adapter *pAdapter);
441 void SetTxPower(struct adapter *pAdapter);
442 void SetAntennaPathPower(struct adapter *pAdapter);
443 void SetDataRate(struct adapter *pAdapter);
445 void SetAntenna(struct adapter *pAdapter);
447 s32 SetThermalMeter(struct adapter *pAdapter, u8 target_ther);
448 void GetThermalMeter(struct adapter *pAdapter, u8 *value);
450 void SetContinuousTx(struct adapter *pAdapter, u8 bStart);
451 void SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart);
452 void SetSingleToneTx(struct adapter *pAdapter, u8 bStart);
453 void SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart);
454 void PhySetTxPowerLevel(struct adapter *pAdapter);
456 void fill_txdesc_for_mp(struct adapter *padapter, struct tx_desc *ptxdesc);
457 void SetPacketTx(struct adapter *padapter);
458 void SetPacketRx(struct adapter *pAdapter, u8 bStartRx);
460 void ResetPhyRxPktCount(struct adapter *pAdapter);
461 u32 GetPhyRxPktReceived(struct adapter *pAdapter);
462 u32 GetPhyRxPktCRC32Error(struct adapter *pAdapter);
464 s32 SetPowerTracking(struct adapter *padapter, u8 enable);
465 void GetPowerTracking(struct adapter *padapter, u8 *enable);
466 u32 mp_query_psd(struct adapter *pAdapter, u8 *data);
467 void Hal_SetAntenna(struct adapter *pAdapter);
468 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);
475 void Hal_SetDataRate(struct adapter *pAdapter);
476 void Hal_SetChannel(struct adapter *pAdapter);
477 void Hal_SetAntennaPathPower(struct adapter *pAdapter);
478 s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther);
479 s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable);
480 void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable);
481 void Hal_GetThermalMeter(struct adapter *pAdapter, u8 *value);
482 void Hal_mpt_SwitchRfSetting(struct adapter *pAdapter);
483 void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14);
484 void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven);
485 void Hal_SetCCKTxPower(struct adapter *pAdapter, u8 * TxPower);
486 void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 * TxPower);
487 void Hal_TriggerRFThermalMeter(struct adapter *pAdapter);
488 u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter);
489 void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart);
490 void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart);
491 void Hal_ProSetCrystalCap (struct adapter *pAdapter , u32 CrystalCapVal);
492 void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv);
493 void MP_PHY_SetRFPathSwitch(struct adapter *pAdapter ,bool bMain);
495 #endif /* _RTW_MP_H_ */