thp: clear_copy_huge_page
[linux/fpc-iii.git] / drivers / staging / rt2860 / rtmp.h
blob70daaa4f9ac25206b25911f62ea636138199e574
1 /*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
27 Module Name:
28 rtmp.h
30 Abstract:
31 Miniport generic portion header file
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Paul Lin 2002-08-01 created
37 James Tan 2002-09-06 modified (Revise NTCRegTable)
38 John Chang 2004-09-06 modified for RT2600
39 Justin P. Mattock 11/07/2010 Fix some typos
41 #ifndef __RTMP_H__
42 #define __RTMP_H__
44 #include "spectrum_def.h"
45 #include "rtmp_dot11.h"
46 #include "rtmp_chip.h"
48 struct rt_rtmp_adapter;
50 /*#define DBG 1 */
52 /*#define DBG_DIAGNOSE 1 */
54 /*+++Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function */
55 #define MAX_DATAMM_RETRY 3
56 #define MGMT_USE_QUEUE_FLAG 0x80
57 /*---Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function */
59 #define MAXSEQ (0xFFF)
61 extern unsigned char SNAP_AIRONET[];
62 extern unsigned char CISCO_OUI[];
63 extern u8 BaSizeArray[4];
65 extern u8 BROADCAST_ADDR[MAC_ADDR_LEN];
66 extern u8 ZERO_MAC_ADDR[MAC_ADDR_LEN];
67 extern unsigned long BIT32[32];
68 extern u8 BIT8[8];
69 extern char *CipherName[];
70 extern char *MCSToMbps[];
71 extern u8 RxwiMCSToOfdmRate[12];
72 extern u8 SNAP_802_1H[6];
73 extern u8 SNAP_BRIDGE_TUNNEL[6];
74 extern u8 SNAP_AIRONET[8];
75 extern u8 CKIP_LLC_SNAP[8];
76 extern u8 EAPOL_LLC_SNAP[8];
77 extern u8 EAPOL[2];
78 extern u8 IPX[2];
79 extern u8 APPLE_TALK[2];
80 extern u8 RateIdToPlcpSignal[12]; /* see IEEE802.11a-1999 p.14 */
81 extern u8 OfdmRateToRxwiMCS[];
82 extern u8 OfdmSignalToRateId[16];
83 extern u8 default_cwmin[4];
84 extern u8 default_cwmax[4];
85 extern u8 default_sta_aifsn[4];
86 extern u8 MapUserPriorityToAccessCategory[8];
88 extern u16 RateUpPER[];
89 extern u16 RateDownPER[];
90 extern u8 Phy11BNextRateDownward[];
91 extern u8 Phy11BNextRateUpward[];
92 extern u8 Phy11BGNextRateDownward[];
93 extern u8 Phy11BGNextRateUpward[];
94 extern u8 Phy11ANextRateDownward[];
95 extern u8 Phy11ANextRateUpward[];
96 extern char RssiSafeLevelForTxRate[];
97 extern u8 RateIdToMbps[];
98 extern u16 RateIdTo500Kbps[];
100 extern u8 CipherSuiteWpaNoneTkip[];
101 extern u8 CipherSuiteWpaNoneTkipLen;
103 extern u8 CipherSuiteWpaNoneAes[];
104 extern u8 CipherSuiteWpaNoneAesLen;
106 extern u8 SsidIe;
107 extern u8 SupRateIe;
108 extern u8 ExtRateIe;
110 extern u8 HtCapIe;
111 extern u8 AddHtInfoIe;
112 extern u8 NewExtChanIe;
114 extern u8 ErpIe;
115 extern u8 DsIe;
116 extern u8 TimIe;
117 extern u8 WpaIe;
118 extern u8 Wpa2Ie;
119 extern u8 IbssIe;
120 extern u8 Ccx2Ie;
121 extern u8 WapiIe;
123 extern u8 WPA_OUI[];
124 extern u8 RSN_OUI[];
125 extern u8 WAPI_OUI[];
126 extern u8 WME_INFO_ELEM[];
127 extern u8 WME_PARM_ELEM[];
128 extern u8 Ccx2QosInfo[];
129 extern u8 Ccx2IeInfo[];
130 extern u8 RALINK_OUI[];
131 extern u8 PowerConstraintIE[];
133 extern u8 RateSwitchTable[];
134 extern u8 RateSwitchTable11B[];
135 extern u8 RateSwitchTable11G[];
136 extern u8 RateSwitchTable11BG[];
138 extern u8 RateSwitchTable11BGN1S[];
139 extern u8 RateSwitchTable11BGN2S[];
140 extern u8 RateSwitchTable11BGN2SForABand[];
141 extern u8 RateSwitchTable11N1S[];
142 extern u8 RateSwitchTable11N2S[];
143 extern u8 RateSwitchTable11N2SForABand[];
145 extern u8 PRE_N_HT_OUI[];
147 struct rt_rssi_sample {
148 char LastRssi0; /* last received RSSI */
149 char LastRssi1; /* last received RSSI */
150 char LastRssi2; /* last received RSSI */
151 char AvgRssi0;
152 char AvgRssi1;
153 char AvgRssi2;
154 short AvgRssi0X8;
155 short AvgRssi1X8;
156 short AvgRssi2X8;
159 /* */
160 /* Queue structure and macros */
161 /* */
162 struct rt_queue_entry;
164 struct rt_queue_entry {
165 struct rt_queue_entry *Next;
168 /* Queue structure */
169 struct rt_queue_header {
170 struct rt_queue_entry *Head;
171 struct rt_queue_entry *Tail;
172 unsigned long Number;
175 #define InitializeQueueHeader(QueueHeader) \
177 (QueueHeader)->Head = (QueueHeader)->Tail = NULL; \
178 (QueueHeader)->Number = 0; \
181 #define RemoveHeadQueue(QueueHeader) \
182 (QueueHeader)->Head; \
184 struct rt_queue_entry *pNext; \
185 if ((QueueHeader)->Head != NULL) { \
186 pNext = (QueueHeader)->Head->Next; \
187 (QueueHeader)->Head->Next = NULL; \
188 (QueueHeader)->Head = pNext; \
189 if (pNext == NULL) \
190 (QueueHeader)->Tail = NULL; \
191 (QueueHeader)->Number--; \
195 #define InsertHeadQueue(QueueHeader, QueueEntry) \
197 ((struct rt_queue_entry *)QueueEntry)->Next = (QueueHeader)->Head; \
198 (QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry); \
199 if ((QueueHeader)->Tail == NULL) \
200 (QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry); \
201 (QueueHeader)->Number++; \
204 #define InsertTailQueue(QueueHeader, QueueEntry) \
206 ((struct rt_queue_entry *)QueueEntry)->Next = NULL; \
207 if ((QueueHeader)->Tail) \
208 (QueueHeader)->Tail->Next = (struct rt_queue_entry *)(QueueEntry); \
209 else \
210 (QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry); \
211 (QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry); \
212 (QueueHeader)->Number++; \
215 #define InsertTailQueueAc(pAd, pEntry, QueueHeader, QueueEntry) \
217 ((struct rt_queue_entry *)QueueEntry)->Next = NULL; \
218 if ((QueueHeader)->Tail) \
219 (QueueHeader)->Tail->Next = (struct rt_queue_entry *)(QueueEntry); \
220 else \
221 (QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry); \
222 (QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry); \
223 (QueueHeader)->Number++; \
226 /* */
227 /* Macros for flag and ref count operations */
228 /* */
229 #define RTMP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
230 #define RTMP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
231 #define RTMP_CLEAR_FLAGS(_M) ((_M)->Flags = 0)
232 #define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
233 #define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
234 /* Macro for power save flag. */
235 #define RTMP_SET_PSFLAG(_M, _F) ((_M)->PSFlags |= (_F))
236 #define RTMP_CLEAR_PSFLAG(_M, _F) ((_M)->PSFlags &= ~(_F))
237 #define RTMP_CLEAR_PSFLAGS(_M) ((_M)->PSFlags = 0)
238 #define RTMP_TEST_PSFLAG(_M, _F) (((_M)->PSFlags & (_F)) != 0)
239 #define RTMP_TEST_PSFLAGS(_M, _F) (((_M)->PSFlags & (_F)) == (_F))
241 #define OPSTATUS_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags |= (_F))
242 #define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F))
243 #define OPSTATUS_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.OpStatusFlags & (_F)) != 0)
245 #define CLIENT_STATUS_SET_FLAG(_pEntry, _F) ((_pEntry)->ClientStatusFlags |= (_F))
246 #define CLIENT_STATUS_CLEAR_FLAG(_pEntry, _F) ((_pEntry)->ClientStatusFlags &= ~(_F))
247 #define CLIENT_STATUS_TEST_FLAG(_pEntry, _F) (((_pEntry)->ClientStatusFlags & (_F)) != 0)
249 #define RX_FILTER_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter |= (_F))
250 #define RX_FILTER_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter &= ~(_F))
251 #define RX_FILTER_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.PacketFilter & (_F)) != 0)
253 #define STA_NO_SECURITY_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
254 #define STA_WEP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
255 #define STA_TKIP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
256 #define STA_AES_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
258 #define STA_TGN_WIFI_ON(_p) (_p->StaCfg.bTGnWifiTest == TRUE)
260 #define CKIP_KP_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x10) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
261 #define CKIP_CMIC_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x08) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
263 #define INC_RING_INDEX(_idx, _RingSize) \
265 (_idx) = (_idx+1) % (_RingSize); \
268 /* StaActive.SupportedHtPhy.MCSSet is copied from AP beacon. Don't need to update here. */
269 #define COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
271 _pAd->StaActive.SupportedHtPhy.ChannelWidth = _pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth; \
272 _pAd->StaActive.SupportedHtPhy.MimoPs = _pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs; \
273 _pAd->StaActive.SupportedHtPhy.GF = _pAd->MlmeAux.HtCapability.HtCapInfo.GF; \
274 _pAd->StaActive.SupportedHtPhy.ShortGIfor20 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20; \
275 _pAd->StaActive.SupportedHtPhy.ShortGIfor40 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40; \
276 _pAd->StaActive.SupportedHtPhy.TxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC; \
277 _pAd->StaActive.SupportedHtPhy.RxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC; \
278 _pAd->StaActive.SupportedHtPhy.ExtChanOffset = _pAd->MlmeAux.AddHtInfo.AddHtInfo.ExtChanOffset; \
279 _pAd->StaActive.SupportedHtPhy.RecomWidth = _pAd->MlmeAux.AddHtInfo.AddHtInfo.RecomWidth; \
280 _pAd->StaActive.SupportedHtPhy.OperaionMode = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode; \
281 _pAd->StaActive.SupportedHtPhy.NonGfPresent = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent; \
282 NdisMoveMemory((_pAd)->MacTab.Content[BSSID_WCID].HTCapability.MCSSet, (_pAd)->StaActive.SupportedPhyInfo.MCSSet, sizeof(u8) * 16);\
285 #define COPY_AP_HTSETTINGS_FROM_BEACON(_pAd, _pHtCapability) \
287 _pAd->MacTab.Content[BSSID_WCID].AMsduSize = (u8)(_pHtCapability->HtCapInfo.AMsduSize); \
288 _pAd->MacTab.Content[BSSID_WCID].MmpsMode = (u8)(_pHtCapability->HtCapInfo.MimoPs); \
289 _pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (u8)(_pHtCapability->HtCapParm.MaxRAmpduFactor); \
292 /* */
293 /* MACRO for 32-bit PCI register read / write */
294 /* */
295 /* Usage : RTMP_IO_READ32( */
296 /* struct rt_rtmp_adapter *pAd, */
297 /* unsigned long Register_Offset, */
298 /* unsigned long * pValue) */
299 /* */
300 /* RTMP_IO_WRITE32( */
301 /* struct rt_rtmp_adapter *pAd, */
302 /* unsigned long Register_Offset, */
303 /* unsigned long Value) */
304 /* */
306 /* */
307 /* Common fragment list structure - Identical to the scatter gather frag list structure */
308 /* */
309 /*#define struct rt_rtmp_sg_element SCATTER_GATHER_ELEMENT */
310 /*#define struct rt_rtmp_sg_element *PSCATTER_GATHER_ELEMENT */
311 #define NIC_MAX_PHYS_BUF_COUNT 8
313 struct rt_rtmp_sg_element {
314 void *Address;
315 unsigned long Length;
316 unsigned long *Reserved;
319 struct rt_rtmp_sg_list {
320 unsigned long NumberOfElements;
321 unsigned long *Reserved;
322 struct rt_rtmp_sg_element Elements[NIC_MAX_PHYS_BUF_COUNT];
325 /* */
326 /* Some utility macros */
327 /* */
328 #define GET_LNA_GAIN(_pAd) ((_pAd->LatchRfRegs.Channel <= 14) ? (_pAd->BLNAGain) : ((_pAd->LatchRfRegs.Channel <= 64) ? (_pAd->ALNAGain0) : ((_pAd->LatchRfRegs.Channel <= 128) ? (_pAd->ALNAGain1) : (_pAd->ALNAGain2))))
330 #define INC_COUNTER64(Val) (Val.QuadPart++)
332 #define INFRA_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_INFRA_ON))
333 #define ADHOC_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_ADHOC_ON))
334 #define MONITOR_ON(_p) (((_p)->StaCfg.BssType) == BSS_MONITOR)
335 #define IDLE_ON(_p) (!INFRA_ON(_p) && !ADHOC_ON(_p))
337 /* Check LEAP & CCKM flags */
338 #define LEAP_ON(_p) (((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP)
339 #define LEAP_CCKM_ON(_p) ((((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP) && ((_p)->StaCfg.LeapAuthInfo.CCKM == TRUE))
341 /* if original Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required */
342 #define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap) \
344 if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500) { \
345 _pExtraLlcSnapEncap = SNAP_802_1H; \
346 if (NdisEqualMemory(IPX, _pBufVA + 12, 2) || \
347 NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2)) { \
348 _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
351 else { \
352 _pExtraLlcSnapEncap = NULL; \
356 /* New Define for new Tx Path. */
357 #define EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(_pBufVA, _pExtraLlcSnapEncap) \
359 if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500) { \
360 _pExtraLlcSnapEncap = SNAP_802_1H; \
361 if (NdisEqualMemory(IPX, _pBufVA, 2) || \
362 NdisEqualMemory(APPLE_TALK, _pBufVA, 2)) { \
363 _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
366 else { \
367 _pExtraLlcSnapEncap = NULL; \
371 #define MAKE_802_3_HEADER(_p, _pMac1, _pMac2, _pType) \
373 NdisMoveMemory(_p, _pMac1, MAC_ADDR_LEN); \
374 NdisMoveMemory((_p + MAC_ADDR_LEN), _pMac2, MAC_ADDR_LEN); \
375 NdisMoveMemory((_p + MAC_ADDR_LEN * 2), _pType, LENGTH_802_3_TYPE); \
378 /* if pData has no LLC/SNAP (neither RFC1042 nor Bridge tunnel), keep it that way. */
379 /* else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field */
380 /* else remove the LLC/SNAP field from the result Ethernet frame */
381 /* Patch for WHQL only, which did not turn on Netbios but use IPX within its payload */
382 /* Note: */
383 /* _pData & _DataSize may be altered (remove 8-byte LLC/SNAP) by this MACRO */
384 /* _pRemovedLLCSNAP: pointer to removed LLC/SNAP; NULL is not removed */
385 #define CONVERT_TO_802_3(_p8023hdr, _pDA, _pSA, _pData, _DataSize, _pRemovedLLCSNAP) \
387 char LLC_Len[2]; \
389 _pRemovedLLCSNAP = NULL; \
390 if (NdisEqualMemory(SNAP_802_1H, _pData, 6) || \
391 NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6)) { \
392 u8 *pProto = _pData + 6; \
394 if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) && \
395 NdisEqualMemory(SNAP_802_1H, _pData, 6)) { \
396 LLC_Len[0] = (u8)(_DataSize / 256); \
397 LLC_Len[1] = (u8)(_DataSize % 256); \
398 MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
400 else { \
401 MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto); \
402 _pRemovedLLCSNAP = _pData; \
403 _DataSize -= LENGTH_802_1_H; \
404 _pData += LENGTH_802_1_H; \
407 else { \
408 LLC_Len[0] = (u8)(_DataSize / 256); \
409 LLC_Len[1] = (u8)(_DataSize % 256); \
410 MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
414 /* Enqueue this frame to MLME engine */
415 /* We need to enqueue the whole frame because MLME need to pass data type */
416 /* information from 802.11 header */
417 #ifdef RTMP_MAC_PCI
418 #define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
420 u32 High32TSF, Low32TSF; \
421 RTMP_IO_READ32(_pAd, TSF_TIMER_DW1, &High32TSF); \
422 RTMP_IO_READ32(_pAd, TSF_TIMER_DW0, &Low32TSF); \
423 MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1, (u8)_Rssi2, _FrameSize, _pFrame, (u8)_PlcpSignal); \
425 #endif /* RTMP_MAC_PCI // */
426 #ifdef RTMP_MAC_USB
427 #define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
429 u32 High32TSF = 0, Low32TSF = 0; \
430 MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1, (u8)_Rssi2, _FrameSize, _pFrame, (u8)_PlcpSignal); \
432 #endif /* RTMP_MAC_USB // */
434 #define MAC_ADDR_EQUAL(pAddr1, pAddr2) RTMPEqualMemory((void *)(pAddr1), (void *)(pAddr2), MAC_ADDR_LEN)
435 #define SSID_EQUAL(ssid1, len1, ssid2, len2) ((len1 == len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))
437 /* */
438 /* Check if it is Japan W53(ch52,56,60,64) channel. */
439 /* */
440 #define JapanChannelCheck(channel) ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
442 #define STA_EXTRA_SETTING(_pAd)
444 #define STA_PORT_SECURED(_pAd) \
446 BOOLEAN Cancelled; \
447 (_pAd)->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
448 NdisAcquireSpinLock(&((_pAd)->MacTabLock)); \
449 (_pAd)->MacTab.Content[BSSID_WCID].PortSecured = (_pAd)->StaCfg.PortSecured; \
450 (_pAd)->MacTab.Content[BSSID_WCID].PrivacyFilter = Ndis802_11PrivFilterAcceptAll;\
451 NdisReleaseSpinLock(&(_pAd)->MacTabLock); \
452 RTMPCancelTimer(&((_pAd)->Mlme.LinkDownTimer), &Cancelled);\
453 STA_EXTRA_SETTING(_pAd); \
456 /* */
457 /* Data buffer for DMA operation, the buffer must be contiguous physical memory */
458 /* Both DMA to / from CPU use the same structure. */
459 /* */
460 struct rt_rtmp_dmabuf {
461 unsigned long AllocSize;
462 void *AllocVa; /* TxBuf virtual address */
463 dma_addr_t AllocPa; /* TxBuf physical address */
466 /* */
467 /* Control block (Descriptor) for all ring descriptor DMA operation, buffer must be */
468 /* contiguous physical memory. char stored the binding Rx packet descriptor */
469 /* which won't be released, driver has to wait until upper layer return the packet */
470 /* before giving up this rx ring descriptor to ASIC. NDIS_BUFFER is associated pair */
471 /* to describe the packet buffer. For Tx, char stored the tx packet descriptor */
472 /* which driver should ACK upper layer when the tx is physically done or failed. */
473 /* */
474 struct rt_rtmp_dmacb {
475 unsigned long AllocSize; /* Control block size */
476 void *AllocVa; /* Control block virtual address */
477 dma_addr_t AllocPa; /* Control block physical address */
478 void *pNdisPacket;
479 void *pNextNdisPacket;
481 struct rt_rtmp_dmabuf DmaBuf; /* Associated DMA buffer structure */
484 struct rt_rtmp_tx_ring {
485 struct rt_rtmp_dmacb Cell[TX_RING_SIZE];
486 u32 TxCpuIdx;
487 u32 TxDmaIdx;
488 u32 TxSwFreeIdx; /* software next free tx index */
491 struct rt_rtmp_rx_ring {
492 struct rt_rtmp_dmacb Cell[RX_RING_SIZE];
493 u32 RxCpuIdx;
494 u32 RxDmaIdx;
495 int RxSwReadIdx; /* software next read index */
498 struct rt_rtmp_mgmt_ring {
499 struct rt_rtmp_dmacb Cell[MGMT_RING_SIZE];
500 u32 TxCpuIdx;
501 u32 TxDmaIdx;
502 u32 TxSwFreeIdx; /* software next free tx index */
505 /* */
506 /* Statistic counter structure */
507 /* */
508 struct rt_counter_802_3 {
509 /* General Stats */
510 unsigned long GoodTransmits;
511 unsigned long GoodReceives;
512 unsigned long TxErrors;
513 unsigned long RxErrors;
514 unsigned long RxNoBuffer;
516 /* Ethernet Stats */
517 unsigned long RcvAlignmentErrors;
518 unsigned long OneCollision;
519 unsigned long MoreCollisions;
523 struct rt_counter_802_11 {
524 unsigned long Length;
525 LARGE_INTEGER LastTransmittedFragmentCount;
526 LARGE_INTEGER TransmittedFragmentCount;
527 LARGE_INTEGER MulticastTransmittedFrameCount;
528 LARGE_INTEGER FailedCount;
529 LARGE_INTEGER RetryCount;
530 LARGE_INTEGER MultipleRetryCount;
531 LARGE_INTEGER RTSSuccessCount;
532 LARGE_INTEGER RTSFailureCount;
533 LARGE_INTEGER ACKFailureCount;
534 LARGE_INTEGER FrameDuplicateCount;
535 LARGE_INTEGER ReceivedFragmentCount;
536 LARGE_INTEGER MulticastReceivedFrameCount;
537 LARGE_INTEGER FCSErrorCount;
540 struct rt_counter_ralink {
541 unsigned long TransmittedByteCount; /* both successful and failure, used to calculate TX throughput */
542 unsigned long ReceivedByteCount; /* both CRC okay and CRC error, used to calculate RX throughput */
543 unsigned long BeenDisassociatedCount;
544 unsigned long BadCQIAutoRecoveryCount;
545 unsigned long PoorCQIRoamingCount;
546 unsigned long MgmtRingFullCount;
547 unsigned long RxCountSinceLastNULL;
548 unsigned long RxCount;
549 unsigned long RxRingErrCount;
550 unsigned long KickTxCount;
551 unsigned long TxRingErrCount;
552 LARGE_INTEGER RealFcsErrCount;
553 unsigned long PendingNdisPacketCount;
555 unsigned long OneSecOsTxCount[NUM_OF_TX_RING];
556 unsigned long OneSecDmaDoneCount[NUM_OF_TX_RING];
557 u32 OneSecTxDoneCount;
558 unsigned long OneSecRxCount;
559 u32 OneSecTxAggregationCount;
560 u32 OneSecRxAggregationCount;
561 u32 OneSecReceivedByteCount;
562 u32 OneSecFrameDuplicateCount;
564 u32 OneSecTransmittedByteCount; /* both successful and failure, used to calculate TX throughput */
565 u32 OneSecTxNoRetryOkCount;
566 u32 OneSecTxRetryOkCount;
567 u32 OneSecTxFailCount;
568 u32 OneSecFalseCCACnt; /* CCA error count, for debug purpose, might move to global counter */
569 u32 OneSecRxOkCnt; /* RX without error */
570 u32 OneSecRxOkDataCnt; /* unicast-to-me DATA frame count */
571 u32 OneSecRxFcsErrCnt; /* CRC error */
572 u32 OneSecBeaconSentCnt;
573 u32 LastOneSecTotalTxCount; /* OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount */
574 u32 LastOneSecRxOkDataCnt; /* OneSecRxOkDataCnt */
575 unsigned long DuplicateRcv;
576 unsigned long TxAggCount;
577 unsigned long TxNonAggCount;
578 unsigned long TxAgg1MPDUCount;
579 unsigned long TxAgg2MPDUCount;
580 unsigned long TxAgg3MPDUCount;
581 unsigned long TxAgg4MPDUCount;
582 unsigned long TxAgg5MPDUCount;
583 unsigned long TxAgg6MPDUCount;
584 unsigned long TxAgg7MPDUCount;
585 unsigned long TxAgg8MPDUCount;
586 unsigned long TxAgg9MPDUCount;
587 unsigned long TxAgg10MPDUCount;
588 unsigned long TxAgg11MPDUCount;
589 unsigned long TxAgg12MPDUCount;
590 unsigned long TxAgg13MPDUCount;
591 unsigned long TxAgg14MPDUCount;
592 unsigned long TxAgg15MPDUCount;
593 unsigned long TxAgg16MPDUCount;
595 LARGE_INTEGER TransmittedOctetsInAMSDU;
596 LARGE_INTEGER TransmittedAMSDUCount;
597 LARGE_INTEGER ReceivedOctesInAMSDUCount;
598 LARGE_INTEGER ReceivedAMSDUCount;
599 LARGE_INTEGER TransmittedAMPDUCount;
600 LARGE_INTEGER TransmittedMPDUsInAMPDUCount;
601 LARGE_INTEGER TransmittedOctetsInAMPDUCount;
602 LARGE_INTEGER MPDUInReceivedAMPDUCount;
605 struct rt_counter_drs {
606 /* record each TX rate's quality. 0 is best, the bigger the worse. */
607 u16 TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
608 u8 PER[MAX_STEP_OF_TX_RATE_SWITCH];
609 u8 TxRateUpPenalty; /* extra # of second penalty due to last unstable condition */
610 unsigned long CurrTxRateStableTime; /* # of second in current TX rate */
611 BOOLEAN fNoisyEnvironment;
612 BOOLEAN fLastSecAccordingRSSI;
613 u8 LastSecTxRateChangeAction; /* 0: no change, 1:rate UP, 2:rate down */
614 u8 LastTimeTxRateChangeAction; /*Keep last time value of LastSecTxRateChangeAction */
615 unsigned long LastTxOkCount;
618 /***************************************************************************
619 * security key related data structure
620 **************************************************************************/
621 struct rt_cipher_key {
622 u8 Key[16]; /* right now we implement 4 keys, 128 bits max */
623 u8 RxMic[8]; /* make alignment */
624 u8 TxMic[8];
625 u8 TxTsc[6]; /* 48bit TSC value */
626 u8 RxTsc[6]; /* 48bit TSC value */
627 u8 CipherAlg; /* 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128 */
628 u8 KeyLen;
629 u8 BssId[6];
630 /* Key length for each key, 0: entry is invalid */
631 u8 Type; /* Indicate Pairwise/Group when reporting MIC error */
634 /* structure to define WPA Group Key Rekey Interval */
635 struct PACKED rt_802_11_wpa_rekey {
636 unsigned long ReKeyMethod; /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
637 unsigned long ReKeyInterval; /* time-based: seconds, packet-based: kilo-packets */
640 #ifdef RTMP_MAC_USB
641 /***************************************************************************
642 * RTUSB I/O related data structure
643 **************************************************************************/
644 struct rt_set_asic_wcid {
645 unsigned long WCID; /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
646 unsigned long SetTid; /* time-based: seconds, packet-based: kilo-packets */
647 unsigned long DeleteTid; /* time-based: seconds, packet-based: kilo-packets */
648 u8 Addr[MAC_ADDR_LEN]; /* avoid in interrupt when write key */
651 struct rt_set_asic_wcid_attri {
652 unsigned long WCID; /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
653 unsigned long Cipher; /* ASIC Cipher definition */
654 u8 Addr[ETH_LENGTH_OF_ADDRESS];
657 /* for USB interface, avoid in interrupt when write key */
658 struct rt_add_pairwise_key_entry {
659 u8 MacAddr[6];
660 u16 MacTabMatchWCID; /* ASIC */
661 struct rt_cipher_key CipherKey;
664 /* Cipher suite type for mixed mode group cipher, P802.11i-2004 */
665 typedef enum _RT_802_11_CIPHER_SUITE_TYPE {
666 Cipher_Type_NONE,
667 Cipher_Type_WEP40,
668 Cipher_Type_TKIP,
669 Cipher_Type_RSVD,
670 Cipher_Type_CCMP,
671 Cipher_Type_WEP104
672 } RT_802_11_CIPHER_SUITE_TYPE, *PRT_802_11_CIPHER_SUITE_TYPE;
673 #endif /* RTMP_MAC_USB // */
675 struct rt_rogueap_entry {
676 u8 Addr[MAC_ADDR_LEN];
677 u8 ErrorCode[2]; /*00 01-Invalid authentication type */
678 /*00 02-Authentication timeout */
679 /*00 03-Challenge from AP failed */
680 /*00 04-Challenge to AP failed */
681 BOOLEAN Reported;
684 struct rt_rogueap_table {
685 u8 RogueApNr;
686 struct rt_rogueap_entry RogueApEntry[MAX_LEN_OF_BSS_TABLE];
689 /* */
690 /* Cisco IAPP format */
691 /* */
692 struct rt_cisco_iapp_content {
693 u16 Length; /*IAPP Length */
694 u8 MessageType; /*IAPP type */
695 u8 FunctionCode; /*IAPP function type */
696 u8 DestinaionMAC[MAC_ADDR_LEN];
697 u8 SourceMAC[MAC_ADDR_LEN];
698 u16 Tag; /*Tag(element IE) - Adjacent AP report */
699 u16 TagLength; /*Length of element not including 4 byte header */
700 u8 OUI[4]; /*0x00, 0x40, 0x96, 0x00 */
701 u8 PreviousAP[MAC_ADDR_LEN]; /*MAC Address of access point */
702 u16 Channel;
703 u16 SsidLen;
704 u8 Ssid[MAX_LEN_OF_SSID];
705 u16 Seconds; /*Seconds that the client has been disassociated. */
709 * Fragment Frame structure
711 struct rt_fragment_frame {
712 void *pFragPacket;
713 unsigned long RxSize;
714 u16 Sequence;
715 u16 LastFrag;
716 unsigned long Flags; /* Some extra frame information. bit 0: LLC presented */
719 /* */
720 /* Packet information for NdisQueryPacket */
721 /* */
722 struct rt_packet_info {
723 u32 PhysicalBufferCount; /* Physical breaks of buffer descriptor chained */
724 u32 BufferCount; /* Number of Buffer descriptor chained */
725 u32 TotalPacketLength; /* Self explained */
726 char *pFirstBuffer; /* Pointer to first buffer descriptor */
729 /* */
730 /* Arcfour Structure Added by PaulWu */
731 /* */
732 struct rt_arcfourcontext {
733 u32 X;
734 u32 Y;
735 u8 STATE[256];
738 /* */
739 /* Tkip Key structure which RC4 key & MIC calculation */
740 /* */
741 struct rt_tkip_key_info {
742 u32 nBytesInM; /* # bytes in M for MICKEY */
743 unsigned long IV16;
744 unsigned long IV32;
745 unsigned long K0; /* for MICKEY Low */
746 unsigned long K1; /* for MICKEY Hig */
747 unsigned long L; /* Current state for MICKEY */
748 unsigned long R; /* Current state for MICKEY */
749 unsigned long M; /* Message accumulator for MICKEY */
750 u8 RC4KEY[16];
751 u8 MIC[8];
754 /* */
755 /* Private / Misc data, counters for driver internal use */
756 /* */
757 struct rt_private {
758 u32 SystemResetCnt; /* System reset counter */
759 u32 TxRingFullCnt; /* Tx ring full occurrance number */
760 u32 PhyRxErrCnt; /* PHY Rx error count, for debug purpose, might move to global counter */
761 /* Variables for WEP encryption / decryption in rtmp_wep.c */
762 u32 FCSCRC32;
763 struct rt_arcfourcontext WEPCONTEXT;
764 /* Tkip stuff */
765 struct rt_tkip_key_info Tx;
766 struct rt_tkip_key_info Rx;
769 /***************************************************************************
770 * Channel and BBP related data structures
771 **************************************************************************/
772 /* structure to tune BBP R66 (BBP TUNING) */
773 struct rt_bbp_r66_tuning {
774 BOOLEAN bEnable;
775 u16 FalseCcaLowerThreshold; /* default 100 */
776 u16 FalseCcaUpperThreshold; /* default 512 */
777 u8 R66Delta;
778 u8 R66CurrentValue;
779 BOOLEAN R66LowerUpperSelect; /*Before LinkUp, Used LowerBound or UpperBound as R66 value. */
782 /* structure to store channel TX power */
783 struct rt_channel_tx_power {
784 u16 RemainingTimeForUse; /*unit: sec */
785 u8 Channel;
786 char Power;
787 char Power2;
788 u8 MaxTxPwr;
789 u8 DfsReq;
792 /* structure to store 802.11j channel TX power */
793 struct rt_channel_11j_tx_power {
794 u8 Channel;
795 u8 BW; /* BW_10 or BW_20 */
796 char Power;
797 char Power2;
798 u16 RemainingTimeForUse; /*unit: sec */
801 struct rt_soft_rx_ant_diversity {
802 u8 EvaluatePeriod; /* 0:not evalute status, 1: evaluate status, 2: switching status */
803 u8 EvaluateStableCnt;
804 u8 Pair1PrimaryRxAnt; /* 0:Ant-E1, 1:Ant-E2 */
805 u8 Pair1SecondaryRxAnt; /* 0:Ant-E1, 1:Ant-E2 */
806 u8 Pair2PrimaryRxAnt; /* 0:Ant-E3, 1:Ant-E4 */
807 u8 Pair2SecondaryRxAnt; /* 0:Ant-E3, 1:Ant-E4 */
808 short Pair1AvgRssi[2]; /* AvgRssi[0]:E1, AvgRssi[1]:E2 */
809 short Pair2AvgRssi[2]; /* AvgRssi[0]:E3, AvgRssi[1]:E4 */
810 short Pair1LastAvgRssi; /* */
811 short Pair2LastAvgRssi; /* */
812 unsigned long RcvPktNumWhenEvaluate;
813 BOOLEAN FirstPktArrivedWhenEvaluate;
814 struct rt_ralink_timer RxAntDiversityTimer;
817 /***************************************************************************
818 * structure for radar detection and channel switch
819 **************************************************************************/
820 struct rt_radar_detect {
821 /*BOOLEAN IEEE80211H; // 0: disable, 1: enable IEEE802.11h */
822 u8 CSCount; /*Channel switch counter */
823 u8 CSPeriod; /*Channel switch period (beacon count) */
824 u8 RDCount; /*Radar detection counter */
825 u8 RDMode; /*Radar Detection mode */
826 u8 RDDurRegion; /*Radar detection duration region */
827 u8 BBPR16;
828 u8 BBPR17;
829 u8 BBPR18;
830 u8 BBPR21;
831 u8 BBPR22;
832 u8 BBPR64;
833 unsigned long InServiceMonitorCount; /* unit: sec */
834 u8 DfsSessionTime;
835 BOOLEAN bFastDfs;
836 u8 ChMovingTime;
837 u8 LongPulseRadarTh;
840 typedef enum _ABGBAND_STATE_ {
841 UNKNOWN_BAND,
842 BG_BAND,
843 A_BAND,
844 } ABGBAND_STATE;
846 #ifdef RTMP_MAC_PCI
847 /* Power save method control */
848 typedef union _PS_CONTROL {
849 struct {
850 unsigned long EnablePSinIdle:1; /* Enable radio off when not connected to AP. radio on only when sitesurvey, */
851 unsigned long EnableNewPS:1; /* Enable new Chip power save function . New method can only be applied in chip version after 2872. and PCIe. */
852 unsigned long rt30xxPowerMode:2; /* Power Level Mode for rt30xx chip */
853 unsigned long rt30xxFollowHostASPM:1; /* Card Follows Host's setting for rt30xx chip. */
854 unsigned long rt30xxForceASPMTest:1; /* Force enable L1 for rt30xx chip. This has higher priority than rt30xxFollowHostASPM Mode. */
855 unsigned long rsv:26; /* Radio Measurement Enable */
856 } field;
857 unsigned long word;
858 } PS_CONTROL, *PPS_CONTROL;
859 #endif /* RTMP_MAC_PCI // */
861 /***************************************************************************
862 * structure for MLME state machine
863 **************************************************************************/
864 struct rt_mlme {
865 /* STA state machines */
866 struct rt_state_machine CntlMachine;
867 struct rt_state_machine AssocMachine;
868 struct rt_state_machine AuthMachine;
869 struct rt_state_machine AuthRspMachine;
870 struct rt_state_machine SyncMachine;
871 struct rt_state_machine WpaPskMachine;
872 struct rt_state_machine LeapMachine;
873 STATE_MACHINE_FUNC AssocFunc[ASSOC_FUNC_SIZE];
874 STATE_MACHINE_FUNC AuthFunc[AUTH_FUNC_SIZE];
875 STATE_MACHINE_FUNC AuthRspFunc[AUTH_RSP_FUNC_SIZE];
876 STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE];
877 STATE_MACHINE_FUNC ActFunc[ACT_FUNC_SIZE];
878 /* Action */
879 struct rt_state_machine ActMachine;
881 /* common WPA state machine */
882 struct rt_state_machine WpaMachine;
883 STATE_MACHINE_FUNC WpaFunc[WPA_FUNC_SIZE];
885 unsigned long ChannelQuality; /* 0..100, Channel Quality Indication for Roaming */
886 unsigned long Now32; /* latch the value of NdisGetSystemUpTime() */
887 unsigned long LastSendNULLpsmTime;
889 BOOLEAN bRunning;
890 spinlock_t TaskLock;
891 struct rt_mlme_queue Queue;
893 u32 ShiftReg;
895 struct rt_ralink_timer PeriodicTimer;
896 struct rt_ralink_timer APSDPeriodicTimer;
897 struct rt_ralink_timer LinkDownTimer;
898 struct rt_ralink_timer LinkUpTimer;
899 #ifdef RTMP_MAC_PCI
900 u8 bPsPollTimerRunning;
901 struct rt_ralink_timer PsPollTimer;
902 struct rt_ralink_timer RadioOnOffTimer;
903 #endif /* RTMP_MAC_PCI // */
904 unsigned long PeriodicRound;
905 unsigned long OneSecPeriodicRound;
907 u8 RealRxPath;
908 BOOLEAN bLowThroughput;
909 BOOLEAN bEnableAutoAntennaCheck;
910 struct rt_ralink_timer RxAntEvalTimer;
912 #ifdef RT30xx
913 u8 CaliBW40RfR24;
914 u8 CaliBW20RfR24;
915 #endif /* RT30xx // */
917 #ifdef RTMP_MAC_USB
918 struct rt_ralink_timer AutoWakeupTimer;
919 BOOLEAN AutoWakeupTimerRunning;
920 #endif /* RTMP_MAC_USB // */
923 /***************************************************************************
924 * 802.11 N related data structures
925 **************************************************************************/
926 struct reordering_mpdu {
927 struct reordering_mpdu *next;
928 void *pPacket; /* coverted to 802.3 frame */
929 int Sequence; /* sequence number of MPDU */
930 BOOLEAN bAMSDU;
933 struct reordering_list {
934 struct reordering_mpdu *next;
935 int qlen;
938 struct reordering_mpdu_pool {
939 void *mem;
940 spinlock_t lock;
941 struct reordering_list freelist;
944 typedef enum _REC_BLOCKACK_STATUS {
945 Recipient_NONE = 0,
946 Recipient_USED,
947 Recipient_HandleRes,
948 Recipient_Accept
949 } REC_BLOCKACK_STATUS, *PREC_BLOCKACK_STATUS;
951 typedef enum _ORI_BLOCKACK_STATUS {
952 Originator_NONE = 0,
953 Originator_USED,
954 Originator_WaitRes,
955 Originator_Done
956 } ORI_BLOCKACK_STATUS, *PORI_BLOCKACK_STATUS;
958 struct rt_ba_ori_entry {
959 u8 Wcid;
960 u8 TID;
961 u8 BAWinSize;
962 u8 Token;
963 /* Sequence is to fill every outgoing QoS DATA frame's sequence field in 802.11 header. */
964 u16 Sequence;
965 u16 TimeOutValue;
966 ORI_BLOCKACK_STATUS ORI_BA_Status;
967 struct rt_ralink_timer ORIBATimer;
968 void *pAdapter;
971 struct rt_ba_rec_entry {
972 u8 Wcid;
973 u8 TID;
974 u8 BAWinSize; /* 7.3.1.14. each buffer is capable of holding a max AMSDU or MSDU. */
975 /*u8 NumOfRxPkt; */
976 /*u8 Curindidx; // the head in the RX reordering buffer */
977 u16 LastIndSeq;
978 /* u16 LastIndSeqAtTimer; */
979 u16 TimeOutValue;
980 struct rt_ralink_timer RECBATimer;
981 unsigned long LastIndSeqAtTimer;
982 unsigned long nDropPacket;
983 unsigned long rcvSeq;
984 REC_BLOCKACK_STATUS REC_BA_Status;
985 /* u8 RxBufIdxUsed; */
986 /* corresponding virtual address for RX reordering packet storage. */
987 /*RTMP_REORDERDMABUF MAP_RXBuf[MAX_RX_REORDERBUF]; */
988 spinlock_t RxReRingLock; /* Rx Ring spinlock */
989 /* struct _BA_REC_ENTRY *pNext; */
990 void *pAdapter;
991 struct reordering_list list;
994 struct rt_ba_table {
995 unsigned long numAsRecipient; /* I am recipient of numAsRecipient clients. These client are in the BARecEntry[] */
996 unsigned long numAsOriginator; /* I am originator of numAsOriginator clients. These clients are in the BAOriEntry[] */
997 unsigned long numDoneOriginator; /* count Done Originator sessions */
998 struct rt_ba_ori_entry BAOriEntry[MAX_LEN_OF_BA_ORI_TABLE];
999 struct rt_ba_rec_entry BARecEntry[MAX_LEN_OF_BA_REC_TABLE];
1002 /*For QureyBATableOID use; */
1003 struct PACKED rt_oid_ba_rec_entry {
1004 u8 MACAddr[MAC_ADDR_LEN];
1005 u8 BaBitmap; /* if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize */
1006 u8 rsv;
1007 u8 BufSize[8];
1008 REC_BLOCKACK_STATUS REC_BA_Status[8];
1011 /*For QureyBATableOID use; */
1012 struct PACKED rt_oid_ba_ori_entry {
1013 u8 MACAddr[MAC_ADDR_LEN];
1014 u8 BaBitmap; /* if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize, read ORI_BA_Status[TID] for status */
1015 u8 rsv;
1016 u8 BufSize[8];
1017 ORI_BLOCKACK_STATUS ORI_BA_Status[8];
1020 struct rt_queryba_table {
1021 struct rt_oid_ba_ori_entry BAOriEntry[32];
1022 struct rt_oid_ba_rec_entry BARecEntry[32];
1023 u8 OriNum; /* Number of below BAOriEntry */
1024 u8 RecNum; /* Number of below BARecEntry */
1027 typedef union _BACAP_STRUC {
1028 struct {
1029 u32 RxBAWinLimit:8;
1030 u32 TxBAWinLimit:8;
1031 u32 AutoBA:1; /* automatically BA */
1032 u32 Policy:2; /* 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use */
1033 u32 MpduDensity:3;
1034 u32 AmsduEnable:1; /*Enable AMSDU transmisstion */
1035 u32 AmsduSize:1; /* 0:3839, 1:7935 bytes. u32 MSDUSizeToBytes[] = { 3839, 7935}; */
1036 u32 MMPSmode:2; /* MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable */
1037 u32 bHtAdhoc:1; /* adhoc can use ht rate. */
1038 u32 b2040CoexistScanSup:1; /*As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz. */
1039 u32: 4;
1040 } field;
1041 u32 word;
1042 } BACAP_STRUC, *PBACAP_STRUC;
1044 struct rt_oid_add_ba_entry {
1045 BOOLEAN IsRecipient;
1046 u8 MACAddr[MAC_ADDR_LEN];
1047 u8 TID;
1048 u8 nMSDU;
1049 u16 TimeOut;
1050 BOOLEAN bAllTid; /* If True, delete all TID for BA sessions with this MACaddr. */
1053 #define IS_HT_STA(_pMacEntry) \
1054 (_pMacEntry->MaxHTPhyMode.field.MODE >= MODE_HTMIX)
1056 #define IS_HT_RATE(_pMacEntry) \
1057 (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
1059 #define PEER_IS_HT_RATE(_pMacEntry) \
1060 (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
1062 /*This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second. (Details see MLMEPeriodic) */
1063 struct rt_iot {
1064 u8 Threshold[2];
1065 u8 ReorderTimeOutNum[MAX_LEN_OF_BA_REC_TABLE]; /* compare with threshold[0] */
1066 u8 RefreshNum[MAX_LEN_OF_BA_REC_TABLE]; /* compare with threshold[1] */
1067 unsigned long OneSecInWindowCount;
1068 unsigned long OneSecFrameDuplicateCount;
1069 unsigned long OneSecOutWindowCount;
1070 u8 DelOriAct;
1071 u8 DelRecAct;
1072 u8 RTSShortProt;
1073 u8 RTSLongProt;
1074 BOOLEAN bRTSLongProtOn;
1075 BOOLEAN bLastAtheros;
1076 BOOLEAN bCurrentAtheros;
1077 BOOLEAN bNowAtherosBurstOn;
1078 BOOLEAN bNextDisableRxBA;
1079 BOOLEAN bToggle;
1082 /* This is the registry setting for 802.11n transmit setting. Used in advanced page. */
1083 typedef union _REG_TRANSMIT_SETTING {
1084 struct {
1085 /*u32 PhyMode:4; */
1086 /*u32 MCS:7; // MCS */
1087 u32 rsv0:10;
1088 u32 TxBF:1;
1089 u32 BW:1; /*channel bandwidth 20MHz or 40 MHz */
1090 u32 ShortGI:1;
1091 u32 STBC:1; /*SPACE */
1092 u32 TRANSNO:2;
1093 u32 HTMODE:1;
1094 u32 EXTCHA:2;
1095 u32 rsv:13;
1096 } field;
1097 u32 word;
1098 } REG_TRANSMIT_SETTING, *PREG_TRANSMIT_SETTING;
1100 typedef union _DESIRED_TRANSMIT_SETTING {
1101 struct {
1102 u16 MCS:7; /* MCS */
1103 u16 PhyMode:4;
1104 u16 FixedTxMode:2; /* If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode. */
1105 u16 rsv:3;
1106 } field;
1107 u16 word;
1108 } DESIRED_TRANSMIT_SETTING, *PDESIRED_TRANSMIT_SETTING;
1110 #ifdef RTMP_MAC_USB
1111 /***************************************************************************
1112 * USB-based chip Beacon related data structures
1113 **************************************************************************/
1114 #define BEACON_BITMAP_MASK 0xff
1115 struct rt_beacon_sync {
1116 u8 BeaconBuf[HW_BEACON_MAX_COUNT][HW_BEACON_OFFSET];
1117 u8 BeaconTxWI[HW_BEACON_MAX_COUNT][TXWI_SIZE];
1118 unsigned long TimIELocationInBeacon[HW_BEACON_MAX_COUNT];
1119 unsigned long CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT];
1120 BOOLEAN EnableBeacon; /* trigger to enable beacon transmission. */
1121 u8 BeaconBitMap; /* NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter needs to change. */
1122 u8 DtimBitOn; /* NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter needs to change. */
1124 #endif /* RTMP_MAC_USB // */
1126 /***************************************************************************
1127 * Multiple SSID related data structures
1128 **************************************************************************/
1129 #define WLAN_MAX_NUM_OF_TIM ((MAX_LEN_OF_MAC_TABLE >> 3) + 1) /* /8 + 1 */
1130 #define WLAN_CT_TIM_BCMC_OFFSET 0 /* unit: 32B */
1132 /* clear bcmc TIM bit */
1133 #define WLAN_MR_TIM_BCMC_CLEAR(apidx) \
1134 pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] &= ~BIT8[0];
1136 /* set bcmc TIM bit */
1137 #define WLAN_MR_TIM_BCMC_SET(apidx) \
1138 pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] |= BIT8[0];
1140 /* clear a station PS TIM bit */
1141 #define WLAN_MR_TIM_BIT_CLEAR(ad_p, apidx, wcid) \
1142 { u8 tim_offset = wcid >> 3; \
1143 u8 bit_offset = wcid & 0x7; \
1144 ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] &= (~BIT8[bit_offset]); }
1146 /* set a station PS TIM bit */
1147 #define WLAN_MR_TIM_BIT_SET(ad_p, apidx, wcid) \
1148 { u8 tim_offset = wcid >> 3; \
1149 u8 bit_offset = wcid & 0x7; \
1150 ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; }
1152 /* configuration common to OPMODE_AP as well as OPMODE_STA */
1153 struct rt_common_config {
1155 BOOLEAN bCountryFlag;
1156 u8 CountryCode[3];
1157 u8 Geography;
1158 u8 CountryRegion; /* Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel */
1159 u8 CountryRegionForABand; /* Enum of country region for A band */
1160 u8 PhyMode; /* PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED */
1161 u16 Dsifs; /* in units of usec */
1162 unsigned long PacketFilter; /* Packet filter for receiving */
1163 u8 RegulatoryClass;
1165 char Ssid[MAX_LEN_OF_SSID]; /* NOT NULL-terminated */
1166 u8 SsidLen; /* the actual ssid length in used */
1167 u8 LastSsidLen; /* the actual ssid length in used */
1168 char LastSsid[MAX_LEN_OF_SSID]; /* NOT NULL-terminated */
1169 u8 LastBssid[MAC_ADDR_LEN];
1171 u8 Bssid[MAC_ADDR_LEN];
1172 u16 BeaconPeriod;
1173 u8 Channel;
1174 u8 CentralChannel; /* Central Channel when using 40MHz is indicating. not real channel. */
1176 u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES];
1177 u8 SupRateLen;
1178 u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
1179 u8 ExtRateLen;
1180 u8 DesireRate[MAX_LEN_OF_SUPPORTED_RATES]; /* OID_802_11_DESIRED_RATES */
1181 u8 MaxDesiredRate;
1182 u8 ExpectedACKRate[MAX_LEN_OF_SUPPORTED_RATES];
1184 unsigned long BasicRateBitmap; /* backup basic ratebitmap */
1186 BOOLEAN bAPSDCapable;
1187 BOOLEAN bInServicePeriod;
1188 BOOLEAN bAPSDAC_BE;
1189 BOOLEAN bAPSDAC_BK;
1190 BOOLEAN bAPSDAC_VI;
1191 BOOLEAN bAPSDAC_VO;
1193 /* because TSPEC can modify the APSD flag, we need to keep the APSD flag
1194 requested in association stage from the station;
1195 we need to recover the APSD flag after the TSPEC is deleted. */
1196 BOOLEAN bACMAPSDBackup[4]; /* for delivery-enabled & trigger-enabled both */
1197 BOOLEAN bACMAPSDTr[4]; /* no use */
1199 BOOLEAN bNeedSendTriggerFrame;
1200 BOOLEAN bAPSDForcePowerSave; /* Force power save mode, should only use in APSD-STAUT */
1201 unsigned long TriggerTimerCount;
1202 u8 MaxSPLength;
1203 u8 BBPCurrentBW; /* BW_10, BW_20, BW_40 */
1204 /* move to MULTISSID_STRUCT for MBSS */
1205 /*HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI. */
1206 REG_TRANSMIT_SETTING RegTransmitSetting; /*registry transmit setting. this is for reading registry setting only. not useful. */
1207 /*u8 FixedTxMode; // Fixed Tx Mode (CCK, OFDM), for HT fixed tx mode (GF, MIX) , refer to RegTransmitSetting.field.HTMode */
1208 u8 TxRate; /* Same value to fill in TXD. TxRate is 6-bit */
1209 u8 MaxTxRate; /* RATE_1, RATE_2, RATE_5_5, RATE_11 */
1210 u8 TxRateIndex; /* Tx rate index in RateSwitchTable */
1211 u8 TxRateTableSize; /* Valid Tx rate table size in RateSwitchTable */
1212 /*BOOLEAN bAutoTxRateSwitch; */
1213 u8 MinTxRate; /* RATE_1, RATE_2, RATE_5_5, RATE_11 */
1214 u8 RtsRate; /* RATE_xxx */
1215 HTTRANSMIT_SETTING MlmeTransmit; /* MGMT frame PHY rate setting when operation at Ht rate. */
1216 u8 MlmeRate; /* RATE_xxx, used to send MLME frames */
1217 u8 BasicMlmeRate; /* Default Rate for sending MLME frames */
1219 u16 RtsThreshold; /* in unit of BYTE */
1220 u16 FragmentThreshold; /* in unit of BYTE */
1222 u8 TxPower; /* in unit of mW */
1223 unsigned long TxPowerPercentage; /* 0~100 % */
1224 unsigned long TxPowerDefault; /* keep for TxPowerPercentage */
1225 u8 PwrConstraint;
1227 BACAP_STRUC BACapability; /* NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0 */
1228 BACAP_STRUC REGBACapability; /* NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0 */
1230 struct rt_iot IOTestParm; /* 802.11n InterOpbility Test Parameter; */
1231 unsigned long TxPreamble; /* Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto */
1232 BOOLEAN bUseZeroToDisableFragment; /* Microsoft use 0 as disable */
1233 unsigned long UseBGProtection; /* 0: auto, 1: always use, 2: always not use */
1234 BOOLEAN bUseShortSlotTime; /* 0: disable, 1 - use short slot (9us) */
1235 BOOLEAN bEnableTxBurst; /* 1: enble TX PACKET BURST (when BA is established or AP is not a legacy WMM AP), 0: disable TX PACKET BURST */
1236 BOOLEAN bAggregationCapable; /* 1: enable TX aggregation when the peer supports it */
1237 BOOLEAN bPiggyBackCapable; /* 1: enable TX piggy-back according MAC's version */
1238 BOOLEAN bIEEE80211H; /* 1: enable IEEE802.11h spec. */
1239 unsigned long DisableOLBCDetect; /* 0: enable OLBC detect; 1 disable OLBC detect */
1241 BOOLEAN bRdg;
1243 BOOLEAN bWmmCapable; /* 0:disable WMM, 1:enable WMM */
1244 struct rt_qos_capability_parm APQosCapability; /* QOS capability of the current associated AP */
1245 struct rt_edca_parm APEdcaParm; /* EDCA parameters of the current associated AP */
1246 struct rt_qbss_load_parm APQbssLoad; /* QBSS load of the current associated AP */
1247 u8 AckPolicy[4]; /* ACK policy of the specified AC. see ACK_xxx */
1248 BOOLEAN bDLSCapable; /* 0:disable DLS, 1:enable DLS */
1249 /* a bitmap of BOOLEAN flags. each bit represent an operation status of a particular */
1250 /* BOOLEAN control, either ON or OFF. These flags should always be accessed via */
1251 /* OPSTATUS_TEST_FLAG(), OPSTATUS_SET_FLAG(), OP_STATUS_CLEAR_FLAG() macros. */
1252 /* see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition */
1253 unsigned long OpStatusFlags;
1255 BOOLEAN NdisRadioStateOff; /*For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff. */
1256 ABGBAND_STATE BandState; /* For setting BBP used on B/G or A mode. */
1258 /* IEEE802.11H--DFS. */
1259 struct rt_radar_detect RadarDetect;
1261 /* HT */
1262 u8 BASize; /* USer desired BAWindowSize. Should not exceed our max capability */
1263 /*struct rt_ht_capability SupportedHtPhy; */
1264 struct rt_ht_capability DesiredHtPhy;
1265 struct rt_ht_capability_ie HtCapability;
1266 struct rt_add_ht_info_ie AddHTInfo; /* Useful as AP. */
1267 /*This IE is used with channel switch announcement element when changing to a new 40MHz. */
1268 /*This IE is included in channel switch announcement frames 7.4.1.5, beacons, probe Rsp. */
1269 struct rt_new_ext_chan_ie NewExtChanOffset; /*7.3.2.20A, 1 if extension channel is above the control channel, 3 if below, 0 if not present */
1271 BOOLEAN bHTProtect;
1272 BOOLEAN bMIMOPSEnable;
1273 BOOLEAN bBADecline;
1274 /*2008/11/05: KH add to support Antenna power-saving of AP<-- */
1275 BOOLEAN bGreenAPEnable;
1276 /*2008/11/05: KH add to support Antenna power-saving of AP--> */
1277 BOOLEAN bDisableReordering;
1278 BOOLEAN bForty_Mhz_Intolerant;
1279 BOOLEAN bExtChannelSwitchAnnouncement;
1280 BOOLEAN bRcvBSSWidthTriggerEvents;
1281 unsigned long LastRcvBSSWidthTriggerEventsTime;
1283 u8 TxBASize;
1285 /* Enable wireless event */
1286 BOOLEAN bWirelessEvent;
1287 BOOLEAN bWiFiTest; /* Enable this parameter for WiFi test */
1289 /* Tx & Rx Stream number selection */
1290 u8 TxStream;
1291 u8 RxStream;
1293 BOOLEAN bHardwareRadio; /* Hardware controlled Radio enabled */
1295 #ifdef RTMP_MAC_USB
1296 BOOLEAN bMultipleIRP; /* Multiple Bulk IN flag */
1297 u8 NumOfBulkInIRP; /* if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1 */
1298 struct rt_ht_capability SupportedHtPhy;
1299 unsigned long MaxPktOneTxBulk;
1300 u8 TxBulkFactor;
1301 u8 RxBulkFactor;
1303 BOOLEAN IsUpdateBeacon;
1304 struct rt_beacon_sync *pBeaconSync;
1305 struct rt_ralink_timer BeaconUpdateTimer;
1306 u32 BeaconAdjust;
1307 u32 BeaconFactor;
1308 u32 BeaconRemain;
1309 #endif /* RTMP_MAC_USB // */
1311 spinlock_t MeasureReqTabLock;
1312 struct rt_measure_req_tab *pMeasureReqTab;
1314 spinlock_t TpcReqTabLock;
1315 struct rt_tpc_req_tab *pTpcReqTab;
1317 BOOLEAN PSPXlink; /* 0: Disable. 1: Enable */
1319 #if defined(RT305x) || defined(RT30xx)
1320 /* request by Gary, for High Power issue */
1321 u8 HighPowerPatchDisabled;
1322 #endif
1324 BOOLEAN HT_DisallowTKIP; /* Restrict the encryption type in 11n HT mode */
1327 /* Modified by Wu Xi-Kun 4/21/2006 */
1328 /* STA configuration and status */
1329 struct rt_sta_admin_config {
1330 /* GROUP 1 - */
1331 /* User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe */
1332 /* the user intended configuration, but not necessary fully equal to the final */
1333 /* settings in ACTIVE BSS after negotiation/compromise with the BSS holder (either */
1334 /* AP or IBSS holder). */
1335 /* Once initialized, user configuration can only be changed via OID_xxx */
1336 u8 BssType; /* BSS_INFRA or BSS_ADHOC */
1337 u16 AtimWin; /* used when starting a new IBSS */
1339 /* GROUP 2 - */
1340 /* User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe */
1341 /* the user intended configuration, and should be always applied to the final */
1342 /* settings in ACTIVE BSS without compromising with the BSS holder. */
1343 /* Once initialized, user configuration can only be changed via OID_xxx */
1344 u8 RssiTrigger;
1345 u8 RssiTriggerMode; /* RSSI_TRIGGERED_UPON_BELOW_THRESHOLD or RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD */
1346 u16 DefaultListenCount; /* default listen count; */
1347 unsigned long WindowsPowerMode; /* Power mode for AC power */
1348 unsigned long WindowsBatteryPowerMode; /* Power mode for battery if exists */
1349 BOOLEAN bWindowsACCAMEnable; /* Enable CAM power mode when AC on */
1350 BOOLEAN bAutoReconnect; /* Set to TRUE when setting OID_802_11_SSID with no matching BSSID */
1351 unsigned long WindowsPowerProfile; /* Windows power profile, for NDIS5.1 PnP */
1353 /* MIB:ieee802dot11.dot11smt(1).dot11StationConfigTable(1) */
1354 u16 Psm; /* power management mode (PWR_ACTIVE|PWR_SAVE) */
1355 u16 DisassocReason;
1356 u8 DisassocSta[MAC_ADDR_LEN];
1357 u16 DeauthReason;
1358 u8 DeauthSta[MAC_ADDR_LEN];
1359 u16 AuthFailReason;
1360 u8 AuthFailSta[MAC_ADDR_LEN];
1362 NDIS_802_11_PRIVACY_FILTER PrivacyFilter; /* PrivacyFilter enum for 802.1X */
1363 NDIS_802_11_AUTHENTICATION_MODE AuthMode; /* This should match to whatever microsoft defined */
1364 NDIS_802_11_WEP_STATUS WepStatus;
1365 NDIS_802_11_WEP_STATUS OrigWepStatus; /* Original wep status set from OID */
1367 /* Add to support different cipher suite for WPA2/WPA mode */
1368 NDIS_802_11_ENCRYPTION_STATUS GroupCipher; /* Multicast cipher suite */
1369 NDIS_802_11_ENCRYPTION_STATUS PairCipher; /* Unicast cipher suite */
1370 BOOLEAN bMixCipher; /* Indicate current Pair & Group use different cipher suites */
1371 u16 RsnCapability;
1373 NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
1375 u8 WpaPassPhrase[64]; /* WPA PSK pass phrase */
1376 u32 WpaPassPhraseLen; /* the length of WPA PSK pass phrase */
1377 u8 PMK[32]; /* WPA PSK mode PMK */
1378 u8 PTK[64]; /* WPA PSK mode PTK */
1379 u8 GTK[32]; /* GTK from authenticator */
1380 struct rt_bssid_info SavedPMK[PMKID_NO];
1381 u32 SavedPMKNum; /* Saved PMKID number */
1383 u8 DefaultKeyId;
1385 /* WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED */
1386 u8 PortSecured;
1388 /* For WPA countermeasures */
1389 unsigned long LastMicErrorTime; /* record last MIC error time */
1390 unsigned long MicErrCnt; /* Should be 0, 1, 2, then reset to zero (after disassociation). */
1391 BOOLEAN bBlockAssoc; /* Block associate attempt for 60 seconds after counter measure occurred. */
1392 /* For WPA-PSK supplicant state */
1393 WPA_STATE WpaState; /* Default is SS_NOTUSE and handled by microsoft 802.1x */
1394 u8 ReplayCounter[8];
1395 u8 ANonce[32]; /* ANonce for WPA-PSK from auhenticator */
1396 u8 SNonce[32]; /* SNonce for WPA-PSK */
1398 u8 LastSNR0; /* last received BEACON's SNR */
1399 u8 LastSNR1; /* last received BEACON's SNR for 2nd antenna */
1400 struct rt_rssi_sample RssiSample;
1401 unsigned long NumOfAvgRssiSample;
1403 unsigned long LastBeaconRxTime; /* OS's timestamp of the last BEACON RX time */
1404 unsigned long Last11bBeaconRxTime; /* OS's timestamp of the last 11B BEACON RX time */
1405 unsigned long Last11gBeaconRxTime; /* OS's timestamp of the last 11G BEACON RX time */
1406 unsigned long Last20NBeaconRxTime; /* OS's timestamp of the last 20MHz N BEACON RX time */
1408 unsigned long LastScanTime; /* Record last scan time for issue BSSID_SCAN_LIST */
1409 unsigned long ScanCnt; /* Scan counts since most recent SSID, BSSID, SCAN OID request */
1410 BOOLEAN bSwRadio; /* Software controlled Radio On/Off, TRUE: On */
1411 BOOLEAN bHwRadio; /* Hardware controlled Radio On/Off, TRUE: On */
1412 BOOLEAN bRadio; /* Radio state, And of Sw & Hw radio state */
1413 BOOLEAN bHardwareRadio; /* Hardware controlled Radio enabled */
1414 BOOLEAN bShowHiddenSSID; /* Show all known SSID in SSID list get operation */
1416 /* New for WPA, windows want us to keep association information and */
1417 /* Fixed IEs from last association response */
1418 struct rt_ndis_802_11_association_information AssocInfo;
1419 u16 ReqVarIELen; /* Length of next VIE include EID & Length */
1420 u8 ReqVarIEs[MAX_VIE_LEN]; /* The content saved here should be little-endian format. */
1421 u16 ResVarIELen; /* Length of next VIE include EID & Length */
1422 u8 ResVarIEs[MAX_VIE_LEN];
1424 u8 RSNIE_Len;
1425 u8 RSN_IE[MAX_LEN_OF_RSNIE]; /* The content saved here should be little-endian format. */
1427 unsigned long CLBusyBytes; /* Save the total bytes received during channel load scan time */
1428 u16 RPIDensity[8]; /* Array for RPI density collection */
1430 u8 RMReqCnt; /* Number of measurement request saved. */
1431 u8 CurrentRMReqIdx; /* Number of measurement request saved. */
1432 BOOLEAN ParallelReq; /* Parallel measurement, only one request performed, */
1433 /* It must be the same channel with maximum duration */
1434 u16 ParallelDuration; /* Maximum duration for parallel measurement */
1435 u8 ParallelChannel; /* Only one channel with parallel measurement */
1436 u16 IAPPToken; /* IAPP dialog token */
1437 /* Hack for channel load and noise histogram parameters */
1438 u8 NHFactor; /* Parameter for Noise histogram */
1439 u8 CLFactor; /* Parameter for channel load */
1441 struct rt_ralink_timer StaQuickResponeForRateUpTimer;
1442 BOOLEAN StaQuickResponeForRateUpTimerRunning;
1444 u8 DtimCount; /* 0.. DtimPeriod-1 */
1445 u8 DtimPeriod; /* default = 3 */
1447 /*////////////////////////////////////////////////////////////////////////////////////// */
1448 /* This is only for WHQL test. */
1449 BOOLEAN WhqlTest;
1450 /*////////////////////////////////////////////////////////////////////////////////////// */
1452 struct rt_ralink_timer WpaDisassocAndBlockAssocTimer;
1453 /* Fast Roaming */
1454 BOOLEAN bAutoRoaming; /* 0:disable auto roaming by RSSI, 1:enable auto roaming by RSSI */
1455 char dBmToRoam; /* the condition to roam when receiving Rssi less than this value. It's negative value. */
1457 BOOLEAN IEEE8021X;
1458 BOOLEAN IEEE8021x_required_keys;
1459 struct rt_cipher_key DesireSharedKey[4]; /* Record user desired WEP keys */
1460 u8 DesireSharedKeyId;
1462 /* 0: driver ignores wpa_supplicant */
1463 /* 1: wpa_supplicant initiates scanning and AP selection */
1464 /* 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters */
1465 u8 WpaSupplicantUP;
1466 u8 WpaSupplicantScanCount;
1467 BOOLEAN bRSN_IE_FromWpaSupplicant;
1469 char dev_name[16];
1470 u16 OriDevType;
1472 BOOLEAN bTGnWifiTest;
1473 BOOLEAN bScanReqIsFromWebUI;
1475 HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode; /* For transmit phy setting in TXWI. */
1476 DESIRED_TRANSMIT_SETTING DesiredTransmitSetting;
1477 struct rt_ht_phy_info DesiredHtPhyInfo;
1478 BOOLEAN bAutoTxRateSwitch;
1480 #ifdef RTMP_MAC_PCI
1481 u8 BBPR3;
1482 /* PS Control has 2 meanings for advanced power save function. */
1483 /* 1. EnablePSinIdle : When no connection, always radio off except need to do site survey. */
1484 /* 2. EnableNewPS : will save more current in sleep or radio off mode. */
1485 PS_CONTROL PSControl;
1486 #endif /* RTMP_MAC_PCI // */
1488 BOOLEAN bAutoConnectByBssid;
1489 unsigned long BeaconLostTime; /* seconds */
1490 BOOLEAN bForceTxBurst; /* 1: force enble TX PACKET BURST, 0: disable */
1493 /* This data structure keeps the current active BSS/IBSS's configuration that this STA */
1494 /* had agreed upon joining the network. Which means these parameters are usually decided */
1495 /* by the BSS/IBSS creator instead of user configuration. Data in this data structure */
1496 /* is valid only when either ADHOC_ON(pAd) or INFRA_ON(pAd) is TRUE. */
1497 /* Normally, after SCAN or failed roaming attempts, we need to recover back to */
1498 /* the current active settings. */
1499 struct rt_sta_active_config {
1500 u16 Aid;
1501 u16 AtimWin; /* in kusec; IBSS parameter set element */
1502 u16 CapabilityInfo;
1503 u16 CfpMaxDuration;
1504 u16 CfpPeriod;
1506 /* Copy supported rate from desired AP's beacon. We are trying to match */
1507 /* AP's supported and extended rate settings. */
1508 u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES];
1509 u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
1510 u8 SupRateLen;
1511 u8 ExtRateLen;
1512 /* Copy supported ht from desired AP's beacon. We are trying to match */
1513 struct rt_ht_phy_info SupportedPhyInfo;
1514 struct rt_ht_capability SupportedHtPhy;
1517 struct rt_mac_table_entry;
1519 struct rt_mac_table_entry {
1520 /*Choose 1 from ValidAsWDS and ValidAsCLI to validize. */
1521 BOOLEAN ValidAsCLI; /* Sta mode, set this TRUE after Linkup,too. */
1522 BOOLEAN ValidAsWDS; /* This is WDS Entry. only for AP mode. */
1523 BOOLEAN ValidAsApCli; /* This is a AP-Client entry, only for AP mode which enable AP-Client functions. */
1524 BOOLEAN ValidAsMesh;
1525 BOOLEAN ValidAsDls; /* This is DLS Entry. only for STA mode. */
1526 BOOLEAN isCached;
1527 BOOLEAN bIAmBadAtheros; /* Flag if this is Atheros chip that has IOT problem. We need to turn on RTS/CTS protection. */
1529 u8 EnqueueEapolStartTimerRunning; /* Enqueue EAPoL-Start for triggering EAP SM */
1530 /*jan for wpa */
1531 /* record which entry revoke MIC Failure, if it leaves the BSS itself, AP won't update aMICFailTime MIB */
1532 u8 CMTimerRunning;
1533 u8 apidx; /* MBSS number */
1534 u8 RSNIE_Len;
1535 u8 RSN_IE[MAX_LEN_OF_RSNIE];
1536 u8 ANonce[LEN_KEY_DESC_NONCE];
1537 u8 SNonce[LEN_KEY_DESC_NONCE];
1538 u8 R_Counter[LEN_KEY_DESC_REPLAY];
1539 u8 PTK[64];
1540 u8 ReTryCounter;
1541 struct rt_ralink_timer RetryTimer;
1542 struct rt_ralink_timer EnqueueStartForPSKTimer; /* A timer which enqueue EAPoL-Start for triggering PSK SM */
1543 NDIS_802_11_AUTHENTICATION_MODE AuthMode; /* This should match to whatever microsoft defined */
1544 NDIS_802_11_WEP_STATUS WepStatus;
1545 NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
1546 AP_WPA_STATE WpaState;
1547 GTK_STATE GTKState;
1548 u16 PortSecured;
1549 NDIS_802_11_PRIVACY_FILTER PrivacyFilter; /* PrivacyFilter enum for 802.1X */
1550 struct rt_cipher_key PairwiseKey;
1551 void *pAd;
1552 int PMKID_CacheIdx;
1553 u8 PMKID[LEN_PMKID];
1555 u8 Addr[MAC_ADDR_LEN];
1556 u8 PsMode;
1557 SST Sst;
1558 AUTH_STATE AuthState; /* for SHARED KEY authentication state machine used only */
1559 BOOLEAN IsReassocSta; /* Indicate whether this is a reassociation procedure */
1560 u16 Aid;
1561 u16 CapabilityInfo;
1562 u8 LastRssi;
1563 unsigned long NoDataIdleCount;
1564 u16 StationKeepAliveCount; /* unit: second */
1565 unsigned long PsQIdleCount;
1566 struct rt_queue_header PsQueue;
1568 u32 StaConnectTime; /* the live time of this station since associated with AP */
1570 BOOLEAN bSendBAR;
1571 u16 NoBADataCountDown;
1573 u32 CachedBuf[16]; /* u32 (4 bytes) for alignment */
1574 u32 TxBFCount; /* 3*3 */
1575 u32 FIFOCount;
1576 u32 DebugFIFOCount;
1577 u32 DebugTxCount;
1578 BOOLEAN bDlsInit;
1580 /*==================================================== */
1581 /*WDS entry needs these */
1582 /* if ValidAsWDS==TRUE, MatchWDSTabIdx is the index in WdsTab.MacTab */
1583 u32 MatchWDSTabIdx;
1584 u8 MaxSupportedRate;
1585 u8 CurrTxRate;
1586 u8 CurrTxRateIndex;
1587 /* to record the each TX rate's quality. 0 is best, the bigger the worse. */
1588 u16 TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
1589 /* u16 OneSecTxOkCount; */
1590 u32 OneSecTxNoRetryOkCount;
1591 u32 OneSecTxRetryOkCount;
1592 u32 OneSecTxFailCount;
1593 u32 ContinueTxFailCnt;
1594 u32 CurrTxRateStableTime; /* # of second in current TX rate */
1595 u8 TxRateUpPenalty; /* extra # of second penalty due to last unstable condition */
1596 /*==================================================== */
1598 BOOLEAN fNoisyEnvironment;
1599 BOOLEAN fLastSecAccordingRSSI;
1600 u8 LastSecTxRateChangeAction; /* 0: no change, 1:rate UP, 2:rate down */
1601 char LastTimeTxRateChangeAction; /*Keep last time value of LastSecTxRateChangeAction */
1602 unsigned long LastTxOkCount;
1603 u8 PER[MAX_STEP_OF_TX_RATE_SWITCH];
1605 /* a bitmap of BOOLEAN flags. each bit represent an operation status of a particular */
1606 /* BOOLEAN control, either ON or OFF. These flags should always be accessed via */
1607 /* CLIENT_STATUS_TEST_FLAG(), CLIENT_STATUS_SET_FLAG(), CLIENT_STATUS_CLEAR_FLAG() macros. */
1608 /* see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED */
1609 unsigned long ClientStatusFlags;
1611 HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode; /* For transmit phy setting in TXWI. */
1613 /* HT EWC MIMO-N used parameters */
1614 u16 RXBAbitmap; /* fill to on-chip RXWI_BA_BITMASK in 8.1.3RX attribute entry format */
1615 u16 TXBAbitmap; /* This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI */
1616 u16 TXAutoBAbitmap;
1617 u16 BADeclineBitmap;
1618 u16 BARecWcidArray[NUM_OF_TID]; /* The mapping wcid of recipient session. if RXBAbitmap bit is masked */
1619 u16 BAOriWcidArray[NUM_OF_TID]; /* The mapping wcid of originator session. if TXBAbitmap bit is masked */
1620 u16 BAOriSequence[NUM_OF_TID]; /* The mapping wcid of originator session. if TXBAbitmap bit is masked */
1622 /* 802.11n features. */
1623 u8 MpduDensity;
1624 u8 MaxRAmpduFactor;
1625 u8 AMsduSize;
1626 u8 MmpsMode; /* MIMO power save more. */
1628 struct rt_ht_capability_ie HTCapability;
1630 BOOLEAN bAutoTxRateSwitch;
1632 u8 RateLen;
1633 struct rt_mac_table_entry *pNext;
1634 u16 TxSeq[NUM_OF_TID];
1635 u16 NonQosDataSeq;
1637 struct rt_rssi_sample RssiSample;
1639 u32 TXMCSExpected[16];
1640 u32 TXMCSSuccessful[16];
1641 u32 TXMCSFailed[16];
1642 u32 TXMCSAutoFallBack[16][16];
1644 unsigned long LastBeaconRxTime;
1646 unsigned long AssocDeadLine;
1649 struct rt_mac_table {
1650 u16 Size;
1651 struct rt_mac_table_entry *Hash[HASH_TABLE_SIZE];
1652 struct rt_mac_table_entry Content[MAX_LEN_OF_MAC_TABLE];
1653 struct rt_queue_header McastPsQueue;
1654 unsigned long PsQIdleCount;
1655 BOOLEAN fAnyStationInPsm;
1656 BOOLEAN fAnyStationBadAtheros; /* Check if any Station is atheros 802.11n Chip. We need to use RTS/CTS with Atheros 802,.11n chip. */
1657 BOOLEAN fAnyTxOPForceDisable; /* Check if it is necessary to disable BE TxOP */
1658 BOOLEAN fAllStationAsRalink; /* Check if all stations are ralink-chipset */
1659 BOOLEAN fAnyStationIsLegacy; /* Check if I use legacy rate to transmit to my BSS Station/ */
1660 BOOLEAN fAnyStationNonGF; /* Check if any Station can't support GF. */
1661 BOOLEAN fAnyStation20Only; /* Check if any Station can't support GF. */
1662 BOOLEAN fAnyStationMIMOPSDynamic; /* Check if any Station is MIMO Dynamic */
1663 BOOLEAN fAnyBASession; /* Check if there is BA session. Force turn on RTS/CTS */
1664 /*2008/10/28: KH add to support Antenna power-saving of AP<-- */
1665 /*2008/10/28: KH add to support Antenna power-saving of AP--> */
1668 struct wificonf {
1669 BOOLEAN bShortGI;
1670 BOOLEAN bGreenField;
1673 struct rt_rtmp_dev_info {
1674 u8 chipName[16];
1675 RTMP_INF_TYPE infType;
1678 struct rt_rtmp_chip_op {
1679 /* Calibration access related callback functions */
1680 int (*eeinit) (struct rt_rtmp_adapter *pAd); /* int (*eeinit)(struct rt_rtmp_adapter *pAd); */
1681 int (*eeread) (struct rt_rtmp_adapter *pAd, u16 offset, u16 *pValue); /* int (*eeread)(struct rt_rtmp_adapter *pAd, int offset, u16 *pValue); */
1683 /* MCU related callback functions */
1684 int (*loadFirmware) (struct rt_rtmp_adapter *pAd); /* int (*loadFirmware)(struct rt_rtmp_adapter *pAd); */
1685 int (*eraseFirmware) (struct rt_rtmp_adapter *pAd); /* int (*eraseFirmware)(struct rt_rtmp_adapter *pAd); */
1686 int (*sendCommandToMcu) (struct rt_rtmp_adapter *pAd, u8 cmd, u8 token, u8 arg0, u8 arg1);; /* int (*sendCommandToMcu)(struct rt_rtmp_adapter *pAd, u8 cmd, u8 token, u8 arg0, u8 arg1); */
1688 /* RF access related callback functions */
1689 struct rt_reg_pair *pRFRegTable;
1690 void (*AsicRfInit) (struct rt_rtmp_adapter *pAd);
1691 void (*AsicRfTurnOn) (struct rt_rtmp_adapter *pAd);
1692 void (*AsicRfTurnOff) (struct rt_rtmp_adapter *pAd);
1693 void (*AsicReverseRfFromSleepMode) (struct rt_rtmp_adapter *pAd);
1694 void (*AsicHaltAction) (struct rt_rtmp_adapter *pAd);
1697 /* */
1698 /* The miniport adapter structure */
1699 /* */
1700 struct rt_rtmp_adapter {
1701 void *OS_Cookie; /* save specific structure relative to OS */
1702 struct net_device *net_dev;
1703 unsigned long VirtualIfCnt;
1704 const struct firmware *firmware;
1706 struct rt_rtmp_chip_op chipOps;
1707 u16 ThisTbttNumToNextWakeUp;
1709 #ifdef RTMP_MAC_PCI
1710 /*****************************************************************************************/
1711 /* PCI related parameters */
1712 /*****************************************************************************************/
1713 u8 *CSRBaseAddress; /* PCI MMIO Base Address, all access will use */
1714 unsigned int irq_num;
1716 u16 LnkCtrlBitMask;
1717 u16 RLnkCtrlConfiguration;
1718 u16 RLnkCtrlOffset;
1719 u16 HostLnkCtrlConfiguration;
1720 u16 HostLnkCtrlOffset;
1721 u16 PCIePowerSaveLevel;
1722 unsigned long Rt3xxHostLinkCtrl; /* USed for 3090F chip */
1723 unsigned long Rt3xxRalinkLinkCtrl; /* USed for 3090F chip */
1724 u16 DeviceID; /* Read from PCI config */
1725 unsigned long AccessBBPFailCount;
1726 BOOLEAN bPCIclkOff; /* flag that indicates if the PICE power status in Configuration Space.. */
1727 BOOLEAN bPCIclkOffDisableTx; /* */
1729 BOOLEAN brt30xxBanMcuCmd; /*when = 0xff means all commands are ok to set . */
1730 BOOLEAN b3090ESpecialChip; /*3090E special chip that write EEPROM 0x24=0x9280. */
1731 unsigned long CheckDmaBusyCount; /* Check Interrupt Status Register Count. */
1733 u32 int_enable_reg;
1734 u32 int_disable_mask;
1735 u32 int_pending;
1737 struct rt_rtmp_dmabuf TxBufSpace[NUM_OF_TX_RING]; /* Shared memory of all 1st pre-allocated TxBuf associated with each TXD */
1738 struct rt_rtmp_dmabuf RxDescRing; /* Shared memory for RX descriptors */
1739 struct rt_rtmp_dmabuf TxDescRing[NUM_OF_TX_RING]; /* Shared memory for Tx descriptors */
1740 struct rt_rtmp_tx_ring TxRing[NUM_OF_TX_RING]; /* AC0~4 + HCCA */
1741 #endif /* RTMP_MAC_PCI // */
1743 spinlock_t irq_lock;
1744 u8 irq_disabled;
1746 #ifdef RTMP_MAC_USB
1747 /*****************************************************************************************/
1748 /* USB related parameters */
1749 /*****************************************************************************************/
1750 struct usb_config_descriptor *config;
1751 u32 BulkInEpAddr; /* bulk-in endpoint address */
1752 u32 BulkOutEpAddr[6]; /* bulk-out endpoint address */
1754 u32 NumberOfPipes;
1755 u16 BulkOutMaxPacketSize;
1756 u16 BulkInMaxPacketSize;
1758 /*======Control Flags */
1759 long PendingIoCount;
1760 unsigned long BulkFlags;
1761 BOOLEAN bUsbTxBulkAggre; /* Flags for bulk out data priority */
1763 /*======Cmd Thread */
1764 struct rt_cmdq CmdQ;
1765 spinlock_t CmdQLock; /* CmdQLock spinlock */
1766 struct rt_rtmp_os_task cmdQTask;
1768 /*======Semaphores (event) */
1769 struct semaphore UsbVendorReq_semaphore;
1770 void *UsbVendorReqBuf;
1771 wait_queue_head_t *wait;
1772 #endif /* RTMP_MAC_USB // */
1774 /*****************************************************************************************/
1775 /* RBUS related parameters */
1776 /*****************************************************************************************/
1778 /*****************************************************************************************/
1779 /* Both PCI/USB related parameters */
1780 /*****************************************************************************************/
1781 /*struct rt_rtmp_dev_info chipInfo; */
1782 RTMP_INF_TYPE infType;
1784 /*****************************************************************************************/
1785 /* Driver Mgmt related parameters */
1786 /*****************************************************************************************/
1787 struct rt_rtmp_os_task mlmeTask;
1788 #ifdef RTMP_TIMER_TASK_SUPPORT
1789 /* If you want use timer task to handle the timer related jobs, enable this. */
1790 struct rt_rtmp_timer_task_queue TimerQ;
1791 spinlock_t TimerQLock;
1792 struct rt_rtmp_os_task timerTask;
1793 #endif /* RTMP_TIMER_TASK_SUPPORT // */
1795 /*****************************************************************************************/
1796 /* Tx related parameters */
1797 /*****************************************************************************************/
1798 BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; /* for ensuring RTUSBDeQueuePacket get call once */
1799 spinlock_t DeQueueLock[NUM_OF_TX_RING];
1801 #ifdef RTMP_MAC_USB
1802 /* Data related context and AC specified, 4 AC supported */
1803 spinlock_t BulkOutLock[6]; /* BulkOut spinlock for 4 ACs */
1804 spinlock_t MLMEBulkOutLock; /* MLME BulkOut lock */
1806 struct rt_ht_tx_context TxContext[NUM_OF_TX_RING];
1807 spinlock_t TxContextQueueLock[NUM_OF_TX_RING]; /* TxContextQueue spinlock */
1809 /* 4 sets of Bulk Out index and pending flag */
1810 u8 NextBulkOutIndex[4]; /* only used for 4 EDCA bulkout pipe */
1812 BOOLEAN BulkOutPending[6]; /* used for total 6 bulkout pipe */
1813 u8 bulkResetPipeid;
1814 BOOLEAN MgmtBulkPending;
1815 unsigned long bulkResetReq[6];
1816 #endif /* RTMP_MAC_USB // */
1818 /* resource for software backlog queues */
1819 struct rt_queue_header TxSwQueue[NUM_OF_TX_RING]; /* 4 AC + 1 HCCA */
1820 spinlock_t TxSwQueueLock[NUM_OF_TX_RING]; /* TxSwQueue spinlock */
1822 struct rt_rtmp_dmabuf MgmtDescRing; /* Shared memory for MGMT descriptors */
1823 struct rt_rtmp_mgmt_ring MgmtRing;
1824 spinlock_t MgmtRingLock; /* Prio Ring spinlock */
1826 /*****************************************************************************************/
1827 /* Rx related parameters */
1828 /*****************************************************************************************/
1830 #ifdef RTMP_MAC_PCI
1831 struct rt_rtmp_rx_ring RxRing;
1832 spinlock_t RxRingLock; /* Rx Ring spinlock */
1833 #ifdef RT3090
1834 spinlock_t McuCmdLock; /*MCU Command Queue spinlock */
1835 #endif /* RT3090 // */
1836 #endif /* RTMP_MAC_PCI // */
1837 #ifdef RTMP_MAC_USB
1838 struct rt_rx_context RxContext[RX_RING_SIZE]; /* 1 for redundant multiple IRP bulk in. */
1839 spinlock_t BulkInLock; /* BulkIn spinlock for 4 ACs */
1840 u8 PendingRx; /* The Maximum pending Rx value should be RX_RING_SIZE. */
1841 u8 NextRxBulkInIndex; /* Indicate the current RxContext Index which hold by Host controller. */
1842 u8 NextRxBulkInReadIndex; /* Indicate the current RxContext Index which driver can read & process it. */
1843 unsigned long NextRxBulkInPosition; /* Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength. */
1844 unsigned long TransferBufferLength; /* current length of the packet buffer */
1845 unsigned long ReadPosition; /* current read position in a packet buffer */
1846 #endif /* RTMP_MAC_USB // */
1848 /*****************************************************************************************/
1849 /* ASIC related parameters */
1850 /*****************************************************************************************/
1851 u32 MACVersion; /* MAC version. Record rt2860C(0x28600100) or rt2860D (0x28600101).. */
1853 /* --------------------------- */
1854 /* E2PROM */
1855 /* --------------------------- */
1856 unsigned long EepromVersion; /* byte 0: version, byte 1: revision, byte 2~3: unused */
1857 unsigned long FirmwareVersion; /* byte 0: Minor version, byte 1: Major version, otherwise unused. */
1858 u16 EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS];
1859 u8 EEPROMAddressNum; /* 93c46=6 93c66=8 */
1860 BOOLEAN EepromAccess;
1861 u8 EFuseTag;
1863 /* --------------------------- */
1864 /* BBP Control */
1865 /* --------------------------- */
1866 u8 BbpWriteLatch[140]; /* record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID */
1867 char BbpRssiToDbmDelta; /* change from u8 to char for high power */
1868 struct rt_bbp_r66_tuning BbpTuning;
1870 /* ---------------------------- */
1871 /* RFIC control */
1872 /* ---------------------------- */
1873 u8 RfIcType; /* RFIC_xxx */
1874 unsigned long RfFreqOffset; /* Frequency offset for channel switching */
1875 struct rt_rtmp_rf_regs LatchRfRegs; /* latch the latest RF programming value since RF IC doesn't support READ */
1877 EEPROM_ANTENNA_STRUC Antenna; /* Since Antenna definition is different for a & g. We need to save it for future reference. */
1878 EEPROM_NIC_CONFIG2_STRUC NicConfig2;
1880 /* This soft Rx Antenna Diversity mechanism is used only when user set */
1881 /* RX Antenna = DIVERSITY ON */
1882 struct rt_soft_rx_ant_diversity RxAnt;
1884 u8 RFProgSeq;
1885 struct rt_channel_tx_power TxPower[MAX_NUM_OF_CHANNELS]; /* Store Tx power value for all channels. */
1886 struct rt_channel_tx_power ChannelList[MAX_NUM_OF_CHANNELS]; /* list all supported channels for site survey */
1887 struct rt_channel_11j_tx_power TxPower11J[MAX_NUM_OF_11JCHANNELS]; /* 802.11j channel and bw */
1888 struct rt_channel_11j_tx_power ChannelList11J[MAX_NUM_OF_11JCHANNELS]; /* list all supported channels for site survey */
1890 u8 ChannelListNum; /* number of channel in ChannelList[] */
1891 u8 Bbp94;
1892 BOOLEAN BbpForCCK;
1893 unsigned long Tx20MPwrCfgABand[5];
1894 unsigned long Tx20MPwrCfgGBand[5];
1895 unsigned long Tx40MPwrCfgABand[5];
1896 unsigned long Tx40MPwrCfgGBand[5];
1898 BOOLEAN bAutoTxAgcA; /* Enable driver auto Tx Agc control */
1899 u8 TssiRefA; /* Store Tssi reference value as 25 temperature. */
1900 u8 TssiPlusBoundaryA[5]; /* Tssi boundary for increase Tx power to compensate. */
1901 u8 TssiMinusBoundaryA[5]; /* Tssi boundary for decrease Tx power to compensate. */
1902 u8 TxAgcStepA; /* Store Tx TSSI delta increment / decrement value */
1903 char TxAgcCompensateA; /* Store the compensation (TxAgcStep * (idx-1)) */
1905 BOOLEAN bAutoTxAgcG; /* Enable driver auto Tx Agc control */
1906 u8 TssiRefG; /* Store Tssi reference value as 25 temperature. */
1907 u8 TssiPlusBoundaryG[5]; /* Tssi boundary for increase Tx power to compensate. */
1908 u8 TssiMinusBoundaryG[5]; /* Tssi boundary for decrease Tx power to compensate. */
1909 u8 TxAgcStepG; /* Store Tx TSSI delta increment / decrement value */
1910 char TxAgcCompensateG; /* Store the compensation (TxAgcStep * (idx-1)) */
1912 char BGRssiOffset0; /* Store B/G RSSI#0 Offset value on EEPROM 0x46h */
1913 char BGRssiOffset1; /* Store B/G RSSI#1 Offset value */
1914 char BGRssiOffset2; /* Store B/G RSSI#2 Offset value */
1916 char ARssiOffset0; /* Store A RSSI#0 Offset value on EEPROM 0x4Ah */
1917 char ARssiOffset1; /* Store A RSSI#1 Offset value */
1918 char ARssiOffset2; /* Store A RSSI#2 Offset value */
1920 char BLNAGain; /* Store B/G external LNA#0 value on EEPROM 0x44h */
1921 char ALNAGain0; /* Store A external LNA#0 value for ch36~64 */
1922 char ALNAGain1; /* Store A external LNA#1 value for ch100~128 */
1923 char ALNAGain2; /* Store A external LNA#2 value for ch132~165 */
1924 #ifdef RT30xx
1925 /* for 3572 */
1926 u8 Bbp25;
1927 u8 Bbp26;
1929 u8 TxMixerGain24G; /* Tx mixer gain value from EEPROM to improve Tx EVM / Tx DAC, 2.4G */
1930 u8 TxMixerGain5G;
1931 #endif /* RT30xx // */
1932 /* ---------------------------- */
1933 /* LED control */
1934 /* ---------------------------- */
1935 MCU_LEDCS_STRUC LedCntl;
1936 u16 Led1; /* read from EEPROM 0x3c */
1937 u16 Led2; /* EEPROM 0x3e */
1938 u16 Led3; /* EEPROM 0x40 */
1939 u8 LedIndicatorStrength;
1940 u8 RssiSingalstrengthOffet;
1941 BOOLEAN bLedOnScanning;
1942 u8 LedStatus;
1944 /*****************************************************************************************/
1945 /* 802.11 related parameters */
1946 /*****************************************************************************************/
1947 /* outgoing BEACON frame buffer and corresponding TXD */
1948 struct rt_txwi BeaconTxWI;
1949 u8 *BeaconBuf;
1950 u16 BeaconOffset[HW_BEACON_MAX_COUNT];
1952 /* pre-build PS-POLL and NULL frame upon link up. for efficiency purpose. */
1953 struct rt_pspoll_frame PsPollFrame;
1954 struct rt_header_802_11 NullFrame;
1956 #ifdef RTMP_MAC_USB
1957 struct rt_tx_context BeaconContext[BEACON_RING_SIZE];
1958 struct rt_tx_context NullContext;
1959 struct rt_tx_context PsPollContext;
1960 struct rt_tx_context RTSContext;
1961 #endif /* RTMP_MAC_USB // */
1963 /*=========AP=========== */
1965 /*=======STA=========== */
1966 /* ----------------------------------------------- */
1967 /* STA specific configuration & operation status */
1968 /* used only when pAd->OpMode == OPMODE_STA */
1969 /* ----------------------------------------------- */
1970 struct rt_sta_admin_config StaCfg; /* user desired settings */
1971 struct rt_sta_active_config StaActive; /* valid only when ADHOC_ON(pAd) || INFRA_ON(pAd) */
1972 char nickname[IW_ESSID_MAX_SIZE + 1]; /* nickname, only used in the iwconfig i/f */
1973 int PreMediaState;
1975 /*=======Common=========== */
1976 /* OP mode: either AP or STA */
1977 u8 OpMode; /* OPMODE_STA, OPMODE_AP */
1979 int IndicateMediaState; /* Base on Indication state, default is NdisMediaStateDisConnected */
1981 /* MAT related parameters */
1983 /* configuration: read from Registry & E2PROM */
1984 BOOLEAN bLocalAdminMAC; /* Use user changed MAC */
1985 u8 PermanentAddress[MAC_ADDR_LEN]; /* Factory default MAC address */
1986 u8 CurrentAddress[MAC_ADDR_LEN]; /* User changed MAC address */
1988 /* ------------------------------------------------------ */
1989 /* common configuration to both OPMODE_STA and OPMODE_AP */
1990 /* ------------------------------------------------------ */
1991 struct rt_common_config CommonCfg;
1992 struct rt_mlme Mlme;
1994 /* AP needs those variables for site survey feature. */
1995 struct rt_mlme_aux MlmeAux; /* temporary settings used during MLME state machine */
1996 struct rt_bss_table ScanTab; /* store the latest SCAN result */
1998 /*About MacTab, the sta driver will use #0 and #1 for multicast and AP. */
1999 struct rt_mac_table MacTab; /* ASIC on-chip WCID entry table. At TX, ASIC always use key according to this on-chip table. */
2000 spinlock_t MacTabLock;
2002 struct rt_ba_table BATable;
2004 spinlock_t BATabLock;
2005 struct rt_ralink_timer RECBATimer;
2007 /* encryption/decryption KEY tables */
2008 struct rt_cipher_key SharedKey[MAX_MBSSID_NUM][4]; /* STA always use SharedKey[BSS0][0..3] */
2010 /* RX re-assembly buffer for fragmentation */
2011 struct rt_fragment_frame FragFrame; /* Frame storage for fragment frame */
2013 /* various Counters */
2014 struct rt_counter_802_3 Counters8023; /* 802.3 counters */
2015 struct rt_counter_802_11 WlanCounters; /* 802.11 MIB counters */
2016 struct rt_counter_ralink RalinkCounters; /* Ralink proprietary counters */
2017 struct rt_counter_drs DrsCounters; /* counters for Dynamic TX Rate Switching */
2018 struct rt_private PrivateInfo; /* Private information & counters */
2020 /* flags, see fRTMP_ADAPTER_xxx flags */
2021 unsigned long Flags; /* Represent current device status */
2022 unsigned long PSFlags; /* Power Save operation flag. */
2024 /* current TX sequence # */
2025 u16 Sequence;
2027 /* Control disconnect / connect event generation */
2028 /*+++Not used anymore */
2029 unsigned long LinkDownTime;
2030 /*--- */
2031 unsigned long LastRxRate;
2032 unsigned long LastTxRate;
2033 /*+++Used only for Station */
2034 BOOLEAN bConfigChanged; /* Config Change flag for the same SSID setting */
2035 /*--- */
2037 unsigned long ExtraInfo; /* Extra information for displaying status */
2038 unsigned long SystemErrorBitmap; /* b0: E2PROM version error */
2040 /*+++Not used anymore */
2041 unsigned long MacIcVersion; /* MAC/BBP serial interface issue solved after ver.D */
2042 /*--- */
2044 /* --------------------------- */
2045 /* System event log */
2046 /* --------------------------- */
2047 struct rt_802_11_event_table EventTab;
2049 BOOLEAN HTCEnable;
2051 /*****************************************************************************************/
2052 /* Statistic related parameters */
2053 /*****************************************************************************************/
2054 #ifdef RTMP_MAC_USB
2055 unsigned long BulkOutDataOneSecCount;
2056 unsigned long BulkInDataOneSecCount;
2057 unsigned long BulkLastOneSecCount; /* BulkOutDataOneSecCount + BulkInDataOneSecCount */
2058 unsigned long watchDogRxCnt;
2059 unsigned long watchDogRxOverFlowCnt;
2060 unsigned long watchDogTxPendingCnt[NUM_OF_TX_RING];
2061 int TransferedLength[NUM_OF_TX_RING];
2062 #endif /* RTMP_MAC_USB // */
2064 BOOLEAN bUpdateBcnCntDone;
2065 unsigned long watchDogMacDeadlock; /* prevent MAC/BBP into deadlock condition */
2066 /* ---------------------------- */
2067 /* DEBUG paramerts */
2068 /* ---------------------------- */
2069 /*unsigned long DebugSetting[4]; */
2070 BOOLEAN bBanAllBaSetup;
2071 BOOLEAN bPromiscuous;
2073 /* ---------------------------- */
2074 /* rt2860c emulation-use Parameters */
2075 /* ---------------------------- */
2076 /*unsigned long rtsaccu[30]; */
2077 /*unsigned long ctsaccu[30]; */
2078 /*unsigned long cfendaccu[30]; */
2079 /*unsigned long bacontent[16]; */
2080 /*unsigned long rxint[RX_RING_SIZE+1]; */
2081 /*u8 rcvba[60]; */
2082 BOOLEAN bLinkAdapt;
2083 BOOLEAN bForcePrintTX;
2084 BOOLEAN bForcePrintRX;
2085 /*BOOLEAN bDisablescanning; //defined in RT2870 USB */
2086 BOOLEAN bStaFifoTest;
2087 BOOLEAN bProtectionTest;
2088 BOOLEAN bBroadComHT;
2089 /*+++Following add from RT2870 USB. */
2090 unsigned long BulkOutReq;
2091 unsigned long BulkOutComplete;
2092 unsigned long BulkOutCompleteOther;
2093 unsigned long BulkOutCompleteCancel; /* seems not used now? */
2094 unsigned long BulkInReq;
2095 unsigned long BulkInComplete;
2096 unsigned long BulkInCompleteFail;
2097 /*--- */
2099 struct wificonf WIFItestbed;
2101 struct reordering_mpdu_pool mpdu_blk_pool;
2103 unsigned long OneSecondnonBEpackets; /* record non BE packets per second */
2105 #ifdef LINUX
2106 struct iw_statistics iw_stats;
2108 struct net_device_stats stats;
2109 #endif /* LINUX // */
2111 unsigned long TbttTickCount;
2112 #ifdef PCI_MSI_SUPPORT
2113 BOOLEAN HaveMsi;
2114 #endif /* PCI_MSI_SUPPORT // */
2116 u8 is_on;
2118 #define TIME_BASE (1000000/OS_HZ)
2119 #define TIME_ONE_SECOND (1000000/TIME_BASE)
2120 u8 flg_be_adjust;
2121 unsigned long be_adjust_last_time;
2123 u8 FlgCtsEnabled;
2124 u8 PM_FlgSuspend;
2126 #ifdef RT30xx
2127 #ifdef RTMP_EFUSE_SUPPORT
2128 BOOLEAN bUseEfuse;
2129 u8 EEPROMImage[1024];
2130 #endif /* RTMP_EFUSE_SUPPORT // */
2131 #endif /* RT30xx // */
2134 #define DELAYINTMASK 0x0003fffb
2135 #define INTMASK 0x0003fffb
2136 #define IndMask 0x0003fffc
2137 #define RxINT 0x00000005 /* Delayed Rx or indivi rx */
2138 #define TxDataInt 0x000000fa /* Delayed Tx or indivi tx */
2139 #define TxMgmtInt 0x00000102 /* Delayed Tx or indivi tx */
2140 #define TxCoherent 0x00020000 /* tx coherent */
2141 #define RxCoherent 0x00010000 /* rx coherent */
2142 #define McuCommand 0x00000200 /* mcu */
2143 #define PreTBTTInt 0x00001000 /* Pre-TBTT interrupt */
2144 #define TBTTInt 0x00000800 /* TBTT interrupt */
2145 #define GPTimeOutInt 0x00008000 /* GPtimeout interrupt */
2146 #define AutoWakeupInt 0x00004000 /* AutoWakeupInt interrupt */
2147 #define FifoStaFullInt 0x00002000 /* fifo statistics full interrupt */
2149 /***************************************************************************
2150 * Rx Path software control block related data structures
2151 **************************************************************************/
2152 struct rt_rx_blk {
2153 RT28XX_RXD_STRUC RxD;
2154 struct rt_rxwi *pRxWI;
2155 struct rt_header_802_11 *pHeader;
2156 void *pRxPacket;
2157 u8 *pData;
2158 u16 DataSize;
2159 u16 Flags;
2160 u8 UserPriority; /* for calculate TKIP MIC using */
2163 #define RX_BLK_SET_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags |= _flag)
2164 #define RX_BLK_TEST_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags & _flag)
2165 #define RX_BLK_CLEAR_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags &= ~(_flag))
2167 #define fRX_WDS 0x0001
2168 #define fRX_AMSDU 0x0002
2169 #define fRX_ARALINK 0x0004
2170 #define fRX_HTC 0x0008
2171 #define fRX_PAD 0x0010
2172 #define fRX_AMPDU 0x0020
2173 #define fRX_QOS 0x0040
2174 #define fRX_INFRA 0x0080
2175 #define fRX_EAP 0x0100
2176 #define fRX_MESH 0x0200
2177 #define fRX_APCLI 0x0400
2178 #define fRX_DLS 0x0800
2179 #define fRX_WPI 0x1000
2181 #define LENGTH_AMSDU_SUBFRAMEHEAD 14
2182 #define LENGTH_ARALINK_SUBFRAMEHEAD 14
2183 #define LENGTH_ARALINK_HEADER_FIELD 2
2185 /***************************************************************************
2186 * Tx Path software control block related data structures
2187 **************************************************************************/
2188 #define TX_UNKOWN_FRAME 0x00
2189 #define TX_MCAST_FRAME 0x01
2190 #define TX_LEGACY_FRAME 0x02
2191 #define TX_AMPDU_FRAME 0x04
2192 #define TX_AMSDU_FRAME 0x08
2193 #define TX_RALINK_FRAME 0x10
2194 #define TX_FRAG_FRAME 0x20
2196 /* Currently the sizeof(struct rt_tx_blk) is 148 bytes. */
2197 struct rt_tx_blk {
2198 u8 QueIdx;
2199 u8 TxFrameType; /* Indicate the Transmission type of the all frames in one batch */
2200 u8 TotalFrameNum; /* Total frame number that wants to send-out in one batch */
2201 u16 TotalFragNum; /* Total frame fragments required in one batch */
2202 u16 TotalFrameLen; /* Total length of all frames that wants to send-out in one batch */
2204 struct rt_queue_header TxPacketList;
2205 struct rt_mac_table_entry *pMacEntry; /* NULL: packet with 802.11 RA field is multicast/broadcast address */
2206 HTTRANSMIT_SETTING *pTransmit;
2208 /* Following structure used for the characteristics of a specific packet. */
2209 void *pPacket;
2210 u8 *pSrcBufHeader; /* Reference to the head of sk_buff->data */
2211 u8 *pSrcBufData; /* Reference to the sk_buff->data, will change depending on the handling progresss */
2212 u32 SrcBufLen; /* Length of packet payload which not including Layer 2 header */
2213 u8 *pExtraLlcSnapEncap; /* NULL means no extra LLC/SNAP is required */
2214 u8 HeaderBuf[128]; /* TempBuffer for TX_INFO + TX_WI + 802.11 Header + padding + AMSDU SubHeader + LLC/SNAP */
2215 /*RT2870 2.1.0.0 uses only 80 bytes */
2216 /*RT3070 2.1.1.0 uses only 96 bytes */
2217 /*RT3090 2.1.0.0 uses only 96 bytes */
2218 u8 MpduHeaderLen; /* 802.11 header length NOT including the padding */
2219 u8 HdrPadLen; /* recording Header Padding Length; */
2220 u8 apidx; /* The interface associated to this packet */
2221 u8 Wcid; /* The MAC entry associated to this packet */
2222 u8 UserPriority; /* priority class of packet */
2223 u8 FrameGap; /* what kind of IFS does this packet use */
2224 u8 MpduReqNum; /* number of fragments of this frame */
2225 u8 TxRate; /* TODO: Obsoleted? Should change to MCS? */
2226 u8 CipherAlg; /* cipher alogrithm */
2227 struct rt_cipher_key *pKey;
2229 u16 Flags; /*See following definitions for detail. */
2231 /*YOU SHOULD NOT TOUCH IT! Following parameters are used for hardware-depended layer. */
2232 unsigned long Priv; /* Hardware specific value saved in here. */
2235 #define fTX_bRtsRequired 0x0001 /* Indicate if need send RTS frame for protection. Not used in RT2860/RT2870. */
2236 #define fTX_bAckRequired 0x0002 /* the packet need ack response */
2237 #define fTX_bPiggyBack 0x0004 /* Legacy device use Piggback or not */
2238 #define fTX_bHTRate 0x0008 /* allow to use HT rate */
2239 #define fTX_bForceNonQoS 0x0010 /* force to transmit frame without WMM-QoS in HT mode */
2240 #define fTX_bAllowFrag 0x0020 /* allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment */
2241 #define fTX_bMoreData 0x0040 /* there are more data packets in PowerSave Queue */
2242 #define fTX_bWMM 0x0080 /* QOS Data */
2243 #define fTX_bClearEAPFrame 0x0100
2245 #define TX_BLK_SET_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags |= _flag)
2246 #define TX_BLK_TEST_FLAG(_pTxBlk, _flag) (((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
2247 #define TX_BLK_CLEAR_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags &= ~(_flag))
2249 /***************************************************************************
2250 * Other static inline function definitions
2251 **************************************************************************/
2252 static inline void ConvertMulticastIP2MAC(u8 *pIpAddr,
2253 u8 **ppMacAddr,
2254 u16 ProtoType)
2256 if (pIpAddr == NULL)
2257 return;
2259 if (ppMacAddr == NULL || *ppMacAddr == NULL)
2260 return;
2262 switch (ProtoType) {
2263 case ETH_P_IPV6:
2264 /* memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS); */
2265 *(*ppMacAddr) = 0x33;
2266 *(*ppMacAddr + 1) = 0x33;
2267 *(*ppMacAddr + 2) = pIpAddr[12];
2268 *(*ppMacAddr + 3) = pIpAddr[13];
2269 *(*ppMacAddr + 4) = pIpAddr[14];
2270 *(*ppMacAddr + 5) = pIpAddr[15];
2271 break;
2273 case ETH_P_IP:
2274 default:
2275 /* memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS); */
2276 *(*ppMacAddr) = 0x01;
2277 *(*ppMacAddr + 1) = 0x00;
2278 *(*ppMacAddr + 2) = 0x5e;
2279 *(*ppMacAddr + 3) = pIpAddr[1] & 0x7f;
2280 *(*ppMacAddr + 4) = pIpAddr[2];
2281 *(*ppMacAddr + 5) = pIpAddr[3];
2282 break;
2285 return;
2288 char *GetPhyMode(int Mode);
2289 char *GetBW(int BW);
2291 /* */
2292 /* Private routines in rtmp_init.c */
2293 /* */
2294 int RTMPAllocAdapterBlock(void *handle,
2295 struct rt_rtmp_adapter **ppAdapter);
2297 int RTMPAllocTxRxRingMemory(struct rt_rtmp_adapter *pAd);
2299 void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd);
2301 int NICReadRegParameters(struct rt_rtmp_adapter *pAd,
2302 void *WrapperConfigurationContext);
2304 #ifdef RTMP_RF_RW_SUPPORT
2305 void NICInitRFRegisters(struct rt_rtmp_adapter *pAd);
2307 void RtmpChipOpsRFHook(struct rt_rtmp_adapter *pAd);
2309 int RT30xxWriteRFRegister(struct rt_rtmp_adapter *pAd,
2310 u8 regID, u8 value);
2312 int RT30xxReadRFRegister(struct rt_rtmp_adapter *pAd,
2313 u8 regID, u8 *pValue);
2314 #endif /* RTMP_RF_RW_SUPPORT // */
2316 void NICReadEEPROMParameters(struct rt_rtmp_adapter *pAd, u8 *mac_addr);
2318 void NICInitAsicFromEEPROM(struct rt_rtmp_adapter *pAd);
2320 int NICInitializeAdapter(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset);
2322 int NICInitializeAsic(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset);
2324 void NICIssueReset(struct rt_rtmp_adapter *pAd);
2326 void RTMPRingCleanUp(struct rt_rtmp_adapter *pAd, u8 RingType);
2328 void UserCfgInit(struct rt_rtmp_adapter *pAd);
2330 void NICResetFromError(struct rt_rtmp_adapter *pAd);
2332 int NICLoadFirmware(struct rt_rtmp_adapter *pAd);
2334 void NICEraseFirmware(struct rt_rtmp_adapter *pAd);
2336 int NICLoadRateSwitchingParams(struct rt_rtmp_adapter *pAd);
2338 BOOLEAN NICCheckForHang(struct rt_rtmp_adapter *pAd);
2340 void NICUpdateFifoStaCounters(struct rt_rtmp_adapter *pAd);
2342 void NICUpdateRawCounters(struct rt_rtmp_adapter *pAd);
2344 void RTMPZeroMemory(void *pSrc, unsigned long Length);
2346 unsigned long RTMPCompareMemory(void *pSrc1, void *pSrc2, unsigned long Length);
2348 void RTMPMoveMemory(void *pDest, void *pSrc, unsigned long Length);
2350 void AtoH(char *src, u8 *dest, int destlen);
2352 void RTMPPatchMacBbpBug(struct rt_rtmp_adapter *pAd);
2354 void RTMPInitTimer(struct rt_rtmp_adapter *pAd,
2355 struct rt_ralink_timer *pTimer,
2356 void *pTimerFunc, void *pData, IN BOOLEAN Repeat);
2358 void RTMPSetTimer(struct rt_ralink_timer *pTimer, unsigned long Value);
2360 void RTMPModTimer(struct rt_ralink_timer *pTimer, unsigned long Value);
2362 void RTMPCancelTimer(struct rt_ralink_timer *pTimer, OUT BOOLEAN * pCancelled);
2364 void RTMPSetLED(struct rt_rtmp_adapter *pAd, u8 Status);
2366 void RTMPSetSignalLED(struct rt_rtmp_adapter *pAd, IN NDIS_802_11_RSSI Dbm);
2368 void RTMPEnableRxTx(struct rt_rtmp_adapter *pAd);
2370 /* */
2371 /* prototype in action.c */
2372 /* */
2373 void ActionStateMachineInit(struct rt_rtmp_adapter *pAd,
2374 struct rt_state_machine *S,
2375 OUT STATE_MACHINE_FUNC Trans[]);
2377 void MlmeADDBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2379 void MlmeDELBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2381 void MlmeDLSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2383 void MlmeInvalidAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2385 void MlmeQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2387 void PeerAddBAReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2389 void PeerAddBARspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2391 void PeerDelBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2393 void PeerBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2395 void SendPSMPAction(struct rt_rtmp_adapter *pAd, u8 Wcid, u8 Psmp);
2397 void PeerRMAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2399 void PeerPublicAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2401 void PeerHTAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2403 void PeerQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2405 void RECBATimerTimeout(void *SystemSpecific1,
2406 void *FunctionContext,
2407 void *SystemSpecific2, void *SystemSpecific3);
2409 void ORIBATimerTimeout(struct rt_rtmp_adapter *pAd);
2411 void SendRefreshBAR(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
2413 void ActHeaderInit(struct rt_rtmp_adapter *pAd,
2414 struct rt_header_802_11 *pHdr80211,
2415 u8 *Addr1, u8 *Addr2, u8 *Addr3);
2417 void BarHeaderInit(struct rt_rtmp_adapter *pAd,
2418 struct rt_frame_bar *pCntlBar, u8 *pDA, u8 *pSA);
2420 void InsertActField(struct rt_rtmp_adapter *pAd,
2421 u8 *pFrameBuf,
2422 unsigned long *pFrameLen, u8 Category, u8 ActCode);
2424 BOOLEAN CntlEnqueueForRecv(struct rt_rtmp_adapter *pAd,
2425 unsigned long Wcid,
2426 unsigned long MsgLen, struct rt_frame_ba_req *pMsg);
2428 /* */
2429 /* Private routines in rtmp_data.c */
2430 /* */
2431 BOOLEAN RTMPHandleRxDoneInterrupt(struct rt_rtmp_adapter *pAd);
2433 BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd,
2434 INT_SOURCE_CSR_STRUC TxRingBitmap);
2436 void RTMPHandleMgmtRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd);
2438 void RTMPHandleTBTTInterrupt(struct rt_rtmp_adapter *pAd);
2440 void RTMPHandlePreTBTTInterrupt(struct rt_rtmp_adapter *pAd);
2442 void RTMPHandleTwakeupInterrupt(struct rt_rtmp_adapter *pAd);
2444 void RTMPHandleRxCoherentInterrupt(struct rt_rtmp_adapter *pAd);
2446 BOOLEAN TxFrameIsAggregatible(struct rt_rtmp_adapter *pAd,
2447 u8 *pPrevAddr1, u8 *p8023hdr);
2449 BOOLEAN PeerIsAggreOn(struct rt_rtmp_adapter *pAd,
2450 unsigned long TxRate, struct rt_mac_table_entry *pMacEntry);
2452 int Sniff2BytesFromNdisBuffer(char *pFirstBuffer,
2453 u8 DesiredOffset,
2454 u8 *pByte0, u8 *pByte1);
2456 int STASendPacket(struct rt_rtmp_adapter *pAd, void *pPacket);
2458 void STASendPackets(void *MiniportAdapterContext,
2459 void **ppPacketArray, u32 NumberOfPackets);
2461 void RTMPDeQueuePacket(struct rt_rtmp_adapter *pAd,
2462 IN BOOLEAN bIntContext,
2463 u8 QueIdx, u8 Max_Tx_Packets);
2465 int RTMPHardTransmit(struct rt_rtmp_adapter *pAd,
2466 void *pPacket,
2467 u8 QueIdx, unsigned long *pFreeTXDLeft);
2469 int STAHardTransmit(struct rt_rtmp_adapter *pAd,
2470 struct rt_tx_blk *pTxBlk, u8 QueIdx);
2472 void STARxEAPOLFrameIndicate(struct rt_rtmp_adapter *pAd,
2473 struct rt_mac_table_entry *pEntry,
2474 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
2476 int RTMPFreeTXDRequest(struct rt_rtmp_adapter *pAd,
2477 u8 RingType,
2478 u8 NumberRequired, u8 *FreeNumberIs);
2480 int MlmeHardTransmit(struct rt_rtmp_adapter *pAd,
2481 u8 QueIdx, void *pPacket);
2483 int MlmeHardTransmitMgmtRing(struct rt_rtmp_adapter *pAd,
2484 u8 QueIdx, void *pPacket);
2486 #ifdef RTMP_MAC_PCI
2487 int MlmeHardTransmitTxRing(struct rt_rtmp_adapter *pAd,
2488 u8 QueIdx, void *pPacket);
2490 int MlmeDataHardTransmit(struct rt_rtmp_adapter *pAd,
2491 u8 QueIdx, void *pPacket);
2493 void RTMPWriteTxDescriptor(struct rt_rtmp_adapter *pAd,
2494 struct rt_txd *pTxD, IN BOOLEAN bWIV, u8 QSEL);
2495 #endif /* RTMP_MAC_PCI // */
2497 u16 RTMPCalcDuration(struct rt_rtmp_adapter *pAd, u8 Rate, unsigned long Size);
2499 void RTMPWriteTxWI(struct rt_rtmp_adapter *pAd, struct rt_txwi * pTxWI, IN BOOLEAN FRAG, IN BOOLEAN CFACK, IN BOOLEAN InsTimestamp, IN BOOLEAN AMPDU, IN BOOLEAN Ack, IN BOOLEAN NSeq, /* HW new a sequence. */
2500 u8 BASize,
2501 u8 WCID,
2502 unsigned long Length,
2503 u8 PID,
2504 u8 TID,
2505 u8 TxRate,
2506 u8 Txopmode,
2507 IN BOOLEAN CfAck, IN HTTRANSMIT_SETTING *pTransmit);
2509 void RTMPWriteTxWI_Data(struct rt_rtmp_adapter *pAd,
2510 struct rt_txwi *pTxWI, struct rt_tx_blk *pTxBlk);
2512 void RTMPWriteTxWI_Cache(struct rt_rtmp_adapter *pAd,
2513 struct rt_txwi *pTxWI, struct rt_tx_blk *pTxBlk);
2515 void RTMPSuspendMsduTransmission(struct rt_rtmp_adapter *pAd);
2517 void RTMPResumeMsduTransmission(struct rt_rtmp_adapter *pAd);
2519 int MiniportMMRequest(struct rt_rtmp_adapter *pAd,
2520 u8 QueIdx, u8 *pData, u32 Length);
2522 /*+++mark by shiang, now this function merge to MiniportMMRequest() */
2523 /*---mark by shiang, now this function merge to MiniportMMRequest() */
2525 void RTMPSendNullFrame(struct rt_rtmp_adapter *pAd,
2526 u8 TxRate, IN BOOLEAN bQosNull);
2528 void RTMPSendDisassociationFrame(struct rt_rtmp_adapter *pAd);
2530 void RTMPSendRTSFrame(struct rt_rtmp_adapter *pAd,
2531 u8 *pDA,
2532 IN unsigned int NextMpduSize,
2533 u8 TxRate,
2534 u8 RTSRate,
2535 u16 AckDuration,
2536 u8 QueIdx, u8 FrameGap);
2538 struct rt_queue_header *RTMPCheckTxSwQueue(struct rt_rtmp_adapter *pAd, u8 * QueIdx);
2540 void RTMPReportMicError(struct rt_rtmp_adapter *pAd, struct rt_cipher_key *pWpaKey);
2542 void WpaMicFailureReportFrame(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2544 void WpaDisassocApAndBlockAssoc(void *SystemSpecific1,
2545 void *FunctionContext,
2546 void *SystemSpecific2,
2547 void *SystemSpecific3);
2549 void WpaStaPairwiseKeySetting(struct rt_rtmp_adapter *pAd);
2551 void WpaStaGroupKeySetting(struct rt_rtmp_adapter *pAd);
2553 int RTMPCloneNdisPacket(struct rt_rtmp_adapter *pAd,
2554 IN BOOLEAN pInsAMSDUHdr,
2555 void *pInPacket,
2556 void **ppOutPacket);
2558 int RTMPAllocateNdisPacket(struct rt_rtmp_adapter *pAd,
2559 void **pPacket,
2560 u8 *pHeader,
2561 u32 HeaderLen,
2562 u8 *pData, u32 DataLen);
2564 void RTMPFreeNdisPacket(struct rt_rtmp_adapter *pAd, void *pPacket);
2566 BOOLEAN RTMPFreeTXDUponTxDmaDone(struct rt_rtmp_adapter *pAd, u8 QueIdx);
2568 BOOLEAN RTMPCheckDHCPFrame(struct rt_rtmp_adapter *pAd, void *pPacket);
2570 BOOLEAN RTMPCheckEtherType(struct rt_rtmp_adapter *pAd, void *pPacket);
2572 /* */
2573 /* Private routines in rtmp_wep.c */
2574 /* */
2575 void RTMPInitWepEngine(struct rt_rtmp_adapter *pAd,
2576 u8 *pKey,
2577 u8 KeyId, u8 KeyLen, u8 *pDest);
2579 void RTMPEncryptData(struct rt_rtmp_adapter *pAd,
2580 u8 *pSrc, u8 *pDest, u32 Len);
2582 BOOLEAN RTMPSoftDecryptWEP(struct rt_rtmp_adapter *pAd,
2583 u8 *pData,
2584 unsigned long DataByteCnt, struct rt_cipher_key *pGroupKey);
2586 void RTMPSetICV(struct rt_rtmp_adapter *pAd, u8 *pDest);
2588 void ARCFOUR_INIT(struct rt_arcfourcontext *Ctx, u8 *pKey, u32 KeyLen);
2590 u8 ARCFOUR_BYTE(struct rt_arcfourcontext *Ctx);
2592 void ARCFOUR_DECRYPT(struct rt_arcfourcontext *Ctx,
2593 u8 *pDest, u8 *pSrc, u32 Len);
2595 void ARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
2596 u8 *pDest, u8 *pSrc, u32 Len);
2598 void WPAARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
2599 u8 *pDest, u8 *pSrc, u32 Len);
2601 u32 RTMP_CALC_FCS32(u32 Fcs, u8 *Cp, int Len);
2603 /* */
2604 /* MLME routines */
2605 /* */
2607 /* Asic/RF/BBP related functions */
2609 void AsicAdjustTxPower(struct rt_rtmp_adapter *pAd);
2611 void AsicUpdateProtect(struct rt_rtmp_adapter *pAd,
2612 u16 OperaionMode,
2613 u8 SetMask,
2614 IN BOOLEAN bDisableBGProtect, IN BOOLEAN bNonGFExist);
2616 void AsicSwitchChannel(struct rt_rtmp_adapter *pAd,
2617 u8 Channel, IN BOOLEAN bScan);
2619 void AsicLockChannel(struct rt_rtmp_adapter *pAd, u8 Channel);
2621 void AsicRfTuningExec(void *SystemSpecific1,
2622 void *FunctionContext,
2623 void *SystemSpecific2, void *SystemSpecific3);
2625 void AsicResetBBPAgent(struct rt_rtmp_adapter *pAd);
2627 void AsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
2628 u16 TbttNumToNextWakeUp);
2630 void AsicForceSleep(struct rt_rtmp_adapter *pAd);
2632 void AsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
2634 void AsicSetBssid(struct rt_rtmp_adapter *pAd, u8 *pBssid);
2636 void AsicSetMcastWC(struct rt_rtmp_adapter *pAd);
2638 void AsicDelWcidTab(struct rt_rtmp_adapter *pAd, u8 Wcid);
2640 void AsicEnableRDG(struct rt_rtmp_adapter *pAd);
2642 void AsicDisableRDG(struct rt_rtmp_adapter *pAd);
2644 void AsicDisableSync(struct rt_rtmp_adapter *pAd);
2646 void AsicEnableBssSync(struct rt_rtmp_adapter *pAd);
2648 void AsicEnableIbssSync(struct rt_rtmp_adapter *pAd);
2650 void AsicSetEdcaParm(struct rt_rtmp_adapter *pAd, struct rt_edca_parm *pEdcaParm);
2652 void AsicSetSlotTime(struct rt_rtmp_adapter *pAd, IN BOOLEAN bUseShortSlotTime);
2654 void AsicAddSharedKeyEntry(struct rt_rtmp_adapter *pAd,
2655 u8 BssIndex,
2656 u8 KeyIdx,
2657 u8 CipherAlg,
2658 u8 *pKey, u8 *pTxMic, u8 *pRxMic);
2660 void AsicRemoveSharedKeyEntry(struct rt_rtmp_adapter *pAd,
2661 u8 BssIndex, u8 KeyIdx);
2663 void AsicUpdateWCIDAttribute(struct rt_rtmp_adapter *pAd,
2664 u16 WCID,
2665 u8 BssIndex,
2666 u8 CipherAlg,
2667 IN BOOLEAN bUsePairewiseKeyTable);
2669 void AsicUpdateWCIDIVEIV(struct rt_rtmp_adapter *pAd,
2670 u16 WCID, unsigned long uIV, unsigned long uEIV);
2672 void AsicUpdateRxWCIDTable(struct rt_rtmp_adapter *pAd,
2673 u16 WCID, u8 *pAddr);
2675 void AsicAddKeyEntry(struct rt_rtmp_adapter *pAd,
2676 u16 WCID,
2677 u8 BssIndex,
2678 u8 KeyIdx,
2679 struct rt_cipher_key *pCipherKey,
2680 IN BOOLEAN bUsePairewiseKeyTable, IN BOOLEAN bTxKey);
2682 void AsicAddPairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
2683 u8 *pAddr,
2684 u8 WCID, struct rt_cipher_key *pCipherKey);
2686 void AsicRemovePairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
2687 u8 BssIdx, u8 Wcid);
2689 BOOLEAN AsicSendCommandToMcu(struct rt_rtmp_adapter *pAd,
2690 u8 Command,
2691 u8 Token, u8 Arg0, u8 Arg1);
2693 #ifdef RTMP_MAC_PCI
2694 BOOLEAN AsicCheckCommanOk(struct rt_rtmp_adapter *pAd, u8 Command);
2695 #endif /* RTMP_MAC_PCI // */
2697 void MacAddrRandomBssid(struct rt_rtmp_adapter *pAd, u8 *pAddr);
2699 void MgtMacHeaderInit(struct rt_rtmp_adapter *pAd,
2700 struct rt_header_802_11 *pHdr80211,
2701 u8 SubType,
2702 u8 ToDs, u8 *pDA, u8 *pBssid);
2704 void MlmeRadioOff(struct rt_rtmp_adapter *pAd);
2706 void MlmeRadioOn(struct rt_rtmp_adapter *pAd);
2708 void BssTableInit(struct rt_bss_table *Tab);
2710 void BATableInit(struct rt_rtmp_adapter *pAd, struct rt_ba_table *Tab);
2712 unsigned long BssTableSearch(struct rt_bss_table *Tab, u8 *pBssid, u8 Channel);
2714 unsigned long BssSsidTableSearch(struct rt_bss_table *Tab,
2715 u8 *pBssid,
2716 u8 *pSsid, u8 SsidLen, u8 Channel);
2718 unsigned long BssTableSearchWithSSID(struct rt_bss_table *Tab,
2719 u8 *Bssid,
2720 u8 *pSsid,
2721 u8 SsidLen, u8 Channel);
2723 unsigned long BssSsidTableSearchBySSID(struct rt_bss_table *Tab,
2724 u8 *pSsid, u8 SsidLen);
2726 void BssTableDeleteEntry(struct rt_bss_table *pTab,
2727 u8 *pBssid, u8 Channel);
2729 void BATableDeleteORIEntry(struct rt_rtmp_adapter *pAd,
2730 struct rt_ba_ori_entry *pBAORIEntry);
2732 void BssEntrySet(struct rt_rtmp_adapter *pAd, struct rt_bss_entry *pBss, u8 *pBssid, char Ssid[], u8 SsidLen, u8 BssType, u16 BeaconPeriod, struct rt_cf_parm * CfParm, u16 AtimWin, u16 CapabilityInfo, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo, /* AP might use this additional ht info IE */
2733 u8 HtCapabilityLen,
2734 u8 AddHtInfoLen,
2735 u8 NewExtChanOffset,
2736 u8 Channel,
2737 char Rssi,
2738 IN LARGE_INTEGER TimeStamp,
2739 u8 CkipFlag,
2740 struct rt_edca_parm *pEdcaParm,
2741 struct rt_qos_capability_parm *pQosCapability,
2742 struct rt_qbss_load_parm *pQbssLoad,
2743 u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE);
2745 unsigned long BssTableSetEntry(struct rt_rtmp_adapter *pAd, struct rt_bss_table *pTab, u8 *pBssid, char Ssid[], u8 SsidLen, u8 BssType, u16 BeaconPeriod, struct rt_cf_parm * CfParm, u16 AtimWin, u16 CapabilityInfo, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo, /* AP might use this additional ht info IE */
2746 u8 HtCapabilityLen,
2747 u8 AddHtInfoLen,
2748 u8 NewExtChanOffset,
2749 u8 Channel,
2750 char Rssi,
2751 IN LARGE_INTEGER TimeStamp,
2752 u8 CkipFlag,
2753 struct rt_edca_parm *pEdcaParm,
2754 struct rt_qos_capability_parm *pQosCapability,
2755 struct rt_qbss_load_parm *pQbssLoad,
2756 u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE);
2758 void BATableInsertEntry(struct rt_rtmp_adapter *pAd,
2759 u16 Aid,
2760 u16 TimeOutValue,
2761 u16 StartingSeq,
2762 u8 TID,
2763 u8 BAWinSize,
2764 u8 OriginatorStatus, IN BOOLEAN IsRecipient);
2766 void BssTableSsidSort(struct rt_rtmp_adapter *pAd,
2767 struct rt_bss_table *OutTab, char Ssid[], u8 SsidLen);
2769 void BssTableSortByRssi(struct rt_bss_table *OutTab);
2771 void BssCipherParse(struct rt_bss_entry *pBss);
2773 int MlmeQueueInit(struct rt_mlme_queue *Queue);
2775 void MlmeQueueDestroy(struct rt_mlme_queue *Queue);
2777 BOOLEAN MlmeEnqueue(struct rt_rtmp_adapter *pAd,
2778 unsigned long Machine,
2779 unsigned long MsgType, unsigned long MsgLen, void *Msg);
2781 BOOLEAN MlmeEnqueueForRecv(struct rt_rtmp_adapter *pAd,
2782 unsigned long Wcid,
2783 unsigned long TimeStampHigh,
2784 unsigned long TimeStampLow,
2785 u8 Rssi0,
2786 u8 Rssi1,
2787 u8 Rssi2,
2788 unsigned long MsgLen, void *Msg, u8 Signal);
2790 BOOLEAN MlmeDequeue(struct rt_mlme_queue *Queue, struct rt_mlme_queue_elem **Elem);
2792 void MlmeRestartStateMachine(struct rt_rtmp_adapter *pAd);
2794 BOOLEAN MlmeQueueEmpty(struct rt_mlme_queue *Queue);
2796 BOOLEAN MlmeQueueFull(struct rt_mlme_queue *Queue);
2798 BOOLEAN MsgTypeSubst(struct rt_rtmp_adapter *pAd,
2799 struct rt_frame_802_11 *pFrame,
2800 int *Machine, int *MsgType);
2802 void StateMachineInit(struct rt_state_machine *Sm,
2803 IN STATE_MACHINE_FUNC Trans[],
2804 unsigned long StNr,
2805 unsigned long MsgNr,
2806 IN STATE_MACHINE_FUNC DefFunc,
2807 unsigned long InitState, unsigned long Base);
2809 void StateMachineSetAction(struct rt_state_machine *S,
2810 unsigned long St, unsigned long Msg, IN STATE_MACHINE_FUNC F);
2812 void StateMachinePerformAction(struct rt_rtmp_adapter *pAd,
2813 struct rt_state_machine *S, struct rt_mlme_queue_elem *Elem);
2815 void Drop(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2817 void AssocStateMachineInit(struct rt_rtmp_adapter *pAd,
2818 struct rt_state_machine *Sm,
2819 OUT STATE_MACHINE_FUNC Trans[]);
2821 void ReassocTimeout(void *SystemSpecific1,
2822 void *FunctionContext,
2823 void *SystemSpecific2, void *SystemSpecific3);
2825 void AssocTimeout(void *SystemSpecific1,
2826 void *FunctionContext,
2827 void *SystemSpecific2, void *SystemSpecific3);
2829 void DisassocTimeout(void *SystemSpecific1,
2830 void *FunctionContext,
2831 void *SystemSpecific2, void *SystemSpecific3);
2833 /*---------------------------------------------- */
2834 void MlmeAssocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2836 void MlmeReassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2838 void MlmeDisassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2840 void PeerAssocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2842 void PeerReassocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2844 void PeerDisassocAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2846 void DisassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2848 void AssocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2850 void ReassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2852 void Cls3errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr);
2854 void InvalidStateWhenAssoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2856 void InvalidStateWhenReassoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2858 void InvalidStateWhenDisassociate(struct rt_rtmp_adapter *pAd,
2859 struct rt_mlme_queue_elem *Elem);
2861 #ifdef RTMP_MAC_USB
2862 void MlmeCntlConfirm(struct rt_rtmp_adapter *pAd, unsigned long MsgType, u16 Msg);
2863 #endif /* RTMP_MAC_USB // */
2865 void ComposePsPoll(struct rt_rtmp_adapter *pAd);
2867 void ComposeNullFrame(struct rt_rtmp_adapter *pAd);
2869 void AssocPostProc(struct rt_rtmp_adapter *pAd,
2870 u8 *pAddr2,
2871 u16 CapabilityInfo,
2872 u16 Aid,
2873 u8 SupRate[],
2874 u8 SupRateLen,
2875 u8 ExtRate[],
2876 u8 ExtRateLen,
2877 struct rt_edca_parm *pEdcaParm,
2878 struct rt_ht_capability_ie *pHtCapability,
2879 u8 HtCapabilityLen, struct rt_add_ht_info_ie *pAddHtInfo);
2881 void AuthStateMachineInit(struct rt_rtmp_adapter *pAd,
2882 struct rt_state_machine *sm, OUT STATE_MACHINE_FUNC Trans[]);
2884 void AuthTimeout(void *SystemSpecific1,
2885 void *FunctionContext,
2886 void *SystemSpecific2, void *SystemSpecific3);
2888 void MlmeAuthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2890 void PeerAuthRspAtSeq2Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2892 void PeerAuthRspAtSeq4Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2894 void AuthTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2896 void Cls2errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr);
2898 void MlmeDeauthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2900 void InvalidStateWhenAuth(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2902 /*============================================= */
2904 void AuthRspStateMachineInit(struct rt_rtmp_adapter *pAd,
2905 struct rt_state_machine *Sm,
2906 IN STATE_MACHINE_FUNC Trans[]);
2908 void PeerDeauthAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2910 void PeerAuthSimpleRspGenAndSend(struct rt_rtmp_adapter *pAd,
2911 struct rt_header_802_11 *pHdr80211,
2912 u16 Alg,
2913 u16 Seq,
2914 u16 Reason, u16 Status);
2916 /* */
2917 /* Private routines in dls.c */
2918 /* */
2920 /*======================================== */
2922 void SyncStateMachineInit(struct rt_rtmp_adapter *pAd,
2923 struct rt_state_machine *Sm,
2924 OUT STATE_MACHINE_FUNC Trans[]);
2926 void BeaconTimeout(void *SystemSpecific1,
2927 void *FunctionContext,
2928 void *SystemSpecific2, void *SystemSpecific3);
2930 void ScanTimeout(void *SystemSpecific1,
2931 void *FunctionContext,
2932 void *SystemSpecific2, void *SystemSpecific3);
2934 void InvalidStateWhenScan(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2936 void InvalidStateWhenJoin(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2938 void InvalidStateWhenStart(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2940 void EnqueueProbeRequest(struct rt_rtmp_adapter *pAd);
2942 BOOLEAN ScanRunning(struct rt_rtmp_adapter *pAd);
2943 /*========================================= */
2945 void MlmeCntlInit(struct rt_rtmp_adapter *pAd,
2946 struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[]);
2948 void MlmeCntlMachinePerformAction(struct rt_rtmp_adapter *pAd,
2949 struct rt_state_machine *S,
2950 struct rt_mlme_queue_elem *Elem);
2952 void CntlIdleProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2954 void CntlOidScanProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2956 void CntlOidSsidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2958 void CntlOidRTBssidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2960 void CntlMlmeRoamingProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2962 void CntlWaitDisassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2964 void CntlWaitJoinProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2966 void CntlWaitReassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2968 void CntlWaitStartProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2970 void CntlWaitAuthProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2972 void CntlWaitAuthProc2(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2974 void CntlWaitAssocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2976 void LinkUp(struct rt_rtmp_adapter *pAd, u8 BssType);
2978 void LinkDown(struct rt_rtmp_adapter *pAd, IN BOOLEAN IsReqFromAP);
2980 void IterateOnBssTab(struct rt_rtmp_adapter *pAd);
2982 void IterateOnBssTab2(struct rt_rtmp_adapter *pAd);
2984 void JoinParmFill(struct rt_rtmp_adapter *pAd,
2985 struct rt_mlme_join_req *JoinReq, unsigned long BssIdx);
2987 void AssocParmFill(struct rt_rtmp_adapter *pAd,
2988 struct rt_mlme_assoc_req *AssocReq,
2989 u8 *pAddr,
2990 u16 CapabilityInfo,
2991 unsigned long Timeout, u16 ListenIntv);
2993 void ScanParmFill(struct rt_rtmp_adapter *pAd,
2994 struct rt_mlme_scan_req *ScanReq,
2995 char Ssid[],
2996 u8 SsidLen, u8 BssType, u8 ScanType);
2998 void DisassocParmFill(struct rt_rtmp_adapter *pAd,
2999 struct rt_mlme_disassoc_req *DisassocReq,
3000 u8 *pAddr, u16 Reason);
3002 void StartParmFill(struct rt_rtmp_adapter *pAd,
3003 struct rt_mlme_start_req *StartReq,
3004 char Ssid[], u8 SsidLen);
3006 void AuthParmFill(struct rt_rtmp_adapter *pAd,
3007 struct rt_mlme_auth_req *AuthReq,
3008 u8 *pAddr, u16 Alg);
3010 void EnqueuePsPoll(struct rt_rtmp_adapter *pAd);
3012 void EnqueueBeaconFrame(struct rt_rtmp_adapter *pAd);
3014 void MlmeJoinReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3016 void MlmeScanReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3018 void MlmeStartReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3020 void ScanTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3022 void BeaconTimeoutAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3024 void PeerBeaconAtScanAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3026 void PeerBeaconAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3028 void PeerBeacon(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3030 void PeerProbeReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3032 void ScanNextChannel(struct rt_rtmp_adapter *pAd);
3034 unsigned long MakeIbssBeacon(struct rt_rtmp_adapter *pAd);
3036 BOOLEAN MlmeScanReqSanity(struct rt_rtmp_adapter *pAd,
3037 void *Msg,
3038 unsigned long MsgLen,
3039 u8 *BssType,
3040 char ssid[],
3041 u8 *SsidLen, u8 *ScanType);
3043 BOOLEAN PeerBeaconAndProbeRspSanity(struct rt_rtmp_adapter *pAd,
3044 void *Msg,
3045 unsigned long MsgLen,
3046 u8 MsgChannel,
3047 u8 *pAddr2,
3048 u8 *pBssid,
3049 char Ssid[],
3050 u8 *pSsidLen,
3051 u8 *pBssType,
3052 u16 *pBeaconPeriod,
3053 u8 *pChannel,
3054 u8 *pNewChannel,
3055 OUT LARGE_INTEGER *pTimestamp,
3056 struct rt_cf_parm *pCfParm,
3057 u16 *pAtimWin,
3058 u16 *pCapabilityInfo,
3059 u8 *pErp,
3060 u8 *pDtimCount,
3061 u8 *pDtimPeriod,
3062 u8 *pBcastFlag,
3063 u8 *pMessageToMe,
3064 u8 SupRate[],
3065 u8 *pSupRateLen,
3066 u8 ExtRate[],
3067 u8 *pExtRateLen,
3068 u8 *pCkipFlag,
3069 u8 *pAironetCellPowerLimit,
3070 struct rt_edca_parm *pEdcaParm,
3071 struct rt_qbss_load_parm *pQbssLoad,
3072 struct rt_qos_capability_parm *pQosCapability,
3073 unsigned long *pRalinkIe,
3074 u8 *pHtCapabilityLen,
3075 u8 *pPreNHtCapabilityLen,
3076 struct rt_ht_capability_ie *pHtCapability,
3077 u8 *AddHtInfoLen,
3078 struct rt_add_ht_info_ie *AddHtInfo,
3079 u8 *NewExtChannel,
3080 u16 *LengthVIE,
3081 struct rt_ndis_802_11_variable_ies *pVIE);
3083 BOOLEAN PeerAddBAReqActionSanity(struct rt_rtmp_adapter *pAd,
3084 void *pMsg,
3085 unsigned long MsgLen, u8 *pAddr2);
3087 BOOLEAN PeerAddBARspActionSanity(struct rt_rtmp_adapter *pAd,
3088 void *pMsg, unsigned long MsgLen);
3090 BOOLEAN PeerDelBAActionSanity(struct rt_rtmp_adapter *pAd,
3091 u8 Wcid, void *pMsg, unsigned long MsgLen);
3093 BOOLEAN MlmeAssocReqSanity(struct rt_rtmp_adapter *pAd,
3094 void *Msg,
3095 unsigned long MsgLen,
3096 u8 *pApAddr,
3097 u16 *CapabilityInfo,
3098 unsigned long *Timeout, u16 *ListenIntv);
3100 BOOLEAN MlmeAuthReqSanity(struct rt_rtmp_adapter *pAd,
3101 void *Msg,
3102 unsigned long MsgLen,
3103 u8 *pAddr,
3104 unsigned long *Timeout, u16 *Alg);
3106 BOOLEAN MlmeStartReqSanity(struct rt_rtmp_adapter *pAd,
3107 void *Msg,
3108 unsigned long MsgLen,
3109 char Ssid[], u8 *Ssidlen);
3111 BOOLEAN PeerAuthSanity(struct rt_rtmp_adapter *pAd,
3112 void *Msg,
3113 unsigned long MsgLen,
3114 u8 *pAddr,
3115 u16 *Alg,
3116 u16 *Seq,
3117 u16 *Status, char ChlgText[]);
3119 BOOLEAN PeerAssocRspSanity(struct rt_rtmp_adapter *pAd, void *pMsg, unsigned long MsgLen, u8 *pAddr2, u16 *pCapabilityInfo, u16 *pStatus, u16 *pAid, u8 SupRate[], u8 *pSupRateLen, u8 ExtRate[], u8 *pExtRateLen, struct rt_ht_capability_ie *pHtCapability, struct rt_add_ht_info_ie *pAddHtInfo, /* AP might use this additional ht info IE */
3120 u8 *pHtCapabilityLen,
3121 u8 *pAddHtInfoLen,
3122 u8 *pNewExtChannelOffset,
3123 struct rt_edca_parm *pEdcaParm, u8 *pCkipFlag);
3125 BOOLEAN PeerDisassocSanity(struct rt_rtmp_adapter *pAd,
3126 void *Msg,
3127 unsigned long MsgLen,
3128 u8 *pAddr2, u16 *Reason);
3130 BOOLEAN PeerWpaMessageSanity(struct rt_rtmp_adapter *pAd,
3131 struct rt_eapol_packet *pMsg,
3132 unsigned long MsgLen,
3133 u8 MsgType, struct rt_mac_table_entry *pEntry);
3135 BOOLEAN PeerDeauthSanity(struct rt_rtmp_adapter *pAd,
3136 void *Msg,
3137 unsigned long MsgLen,
3138 u8 *pAddr2, u16 *Reason);
3140 BOOLEAN PeerProbeReqSanity(struct rt_rtmp_adapter *pAd,
3141 void *Msg,
3142 unsigned long MsgLen,
3143 u8 *pAddr2,
3144 char Ssid[], u8 *pSsidLen);
3146 BOOLEAN GetTimBit(char *Ptr,
3147 u16 Aid,
3148 u8 *TimLen,
3149 u8 *BcastFlag,
3150 u8 *DtimCount,
3151 u8 *DtimPeriod, u8 *MessageToMe);
3153 u8 ChannelSanity(struct rt_rtmp_adapter *pAd, u8 channel);
3155 NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(struct rt_bss_entry *pBss);
3157 BOOLEAN MlmeDelBAReqSanity(struct rt_rtmp_adapter *pAd,
3158 void *Msg, unsigned long MsgLen);
3160 BOOLEAN MlmeAddBAReqSanity(struct rt_rtmp_adapter *pAd,
3161 void *Msg, unsigned long MsgLen, u8 *pAddr2);
3163 unsigned long MakeOutgoingFrame(u8 *Buffer, unsigned long *Length, ...);
3165 void LfsrInit(struct rt_rtmp_adapter *pAd, unsigned long Seed);
3167 u8 RandomByte(struct rt_rtmp_adapter *pAd);
3169 void AsicUpdateAutoFallBackTable(struct rt_rtmp_adapter *pAd, u8 *pTxRate);
3171 void MlmePeriodicExec(void *SystemSpecific1,
3172 void *FunctionContext,
3173 void *SystemSpecific2, void *SystemSpecific3);
3175 void LinkDownExec(void *SystemSpecific1,
3176 void *FunctionContext,
3177 void *SystemSpecific2, void *SystemSpecific3);
3179 void STAMlmePeriodicExec(struct rt_rtmp_adapter *pAd);
3181 void MlmeAutoScan(struct rt_rtmp_adapter *pAd);
3183 void MlmeAutoReconnectLastSSID(struct rt_rtmp_adapter *pAd);
3185 BOOLEAN MlmeValidateSSID(u8 *pSsid, u8 SsidLen);
3187 void MlmeCheckForRoaming(struct rt_rtmp_adapter *pAd, unsigned long Now32);
3189 BOOLEAN MlmeCheckForFastRoaming(struct rt_rtmp_adapter *pAd);
3191 void MlmeDynamicTxRateSwitching(struct rt_rtmp_adapter *pAd);
3193 void MlmeSetTxRate(struct rt_rtmp_adapter *pAd,
3194 struct rt_mac_table_entry *pEntry, struct rt_rtmp_tx_rate_switch * pTxRate);
3196 void MlmeSelectTxRateTable(struct rt_rtmp_adapter *pAd,
3197 struct rt_mac_table_entry *pEntry,
3198 u8 **ppTable,
3199 u8 *pTableSize, u8 *pInitTxRateIdx);
3201 void MlmeCalculateChannelQuality(struct rt_rtmp_adapter *pAd,
3202 struct rt_mac_table_entry *pMacEntry, unsigned long Now);
3204 void MlmeCheckPsmChange(struct rt_rtmp_adapter *pAd, unsigned long Now32);
3206 void MlmeSetPsmBit(struct rt_rtmp_adapter *pAd, u16 psm);
3208 void MlmeSetTxPreamble(struct rt_rtmp_adapter *pAd, u16 TxPreamble);
3210 void UpdateBasicRateBitmap(struct rt_rtmp_adapter *pAd);
3212 void MlmeUpdateTxRates(struct rt_rtmp_adapter *pAd,
3213 IN BOOLEAN bLinkUp, u8 apidx);
3215 void MlmeUpdateHtTxRates(struct rt_rtmp_adapter *pAd, u8 apidx);
3217 void RTMPCheckRates(struct rt_rtmp_adapter *pAd,
3218 IN u8 SupRate[], IN u8 *SupRateLen);
3220 BOOLEAN RTMPCheckChannel(struct rt_rtmp_adapter *pAd,
3221 u8 CentralChannel, u8 Channel);
3223 BOOLEAN RTMPCheckHt(struct rt_rtmp_adapter *pAd,
3224 u8 Wcid,
3225 struct rt_ht_capability_ie *pHtCapability,
3226 struct rt_add_ht_info_ie *pAddHtInfo);
3228 void StaQuickResponeForRateUpExec(void *SystemSpecific1,
3229 void *FunctionContext,
3230 void *SystemSpecific2,
3231 void *SystemSpecific3);
3233 void RTMPUpdateMlmeRate(struct rt_rtmp_adapter *pAd);
3235 char RTMPMaxRssi(struct rt_rtmp_adapter *pAd,
3236 char Rssi0, char Rssi1, char Rssi2);
3238 #ifdef RT30xx
3239 void AsicSetRxAnt(struct rt_rtmp_adapter *pAd, u8 Ant);
3241 void RTMPFilterCalibration(struct rt_rtmp_adapter *pAd);
3243 #ifdef RTMP_EFUSE_SUPPORT
3244 /*2008/09/11:KH add to support efuse<-- */
3245 int set_eFuseGetFreeBlockCount_Proc(struct rt_rtmp_adapter *pAd, char *arg);
3247 int set_eFusedump_Proc(struct rt_rtmp_adapter *pAd, char *arg);
3249 void eFusePhysicalReadRegisters(struct rt_rtmp_adapter *pAd,
3250 u16 Offset,
3251 u16 Length, u16 *pData);
3253 int RtmpEfuseSupportCheck(struct rt_rtmp_adapter *pAd);
3255 void eFuseGetFreeBlockCount(struct rt_rtmp_adapter *pAd, u32 *EfuseFreeBlock);
3257 int eFuse_init(struct rt_rtmp_adapter *pAd);
3258 /*2008/09/11:KH add to support efuse--> */
3259 #endif /* RTMP_EFUSE_SUPPORT // */
3261 /* add by johnli, RF power sequence setup */
3262 void RT30xxLoadRFNormalModeSetup(struct rt_rtmp_adapter *pAd);
3264 void RT30xxLoadRFSleepModeSetup(struct rt_rtmp_adapter *pAd);
3266 void RT30xxReverseRFSleepModeSetup(struct rt_rtmp_adapter *pAd);
3267 /* end johnli */
3269 #ifdef RT3070
3270 void NICInitRT3070RFRegisters(struct rt_rtmp_adapter *pAd);
3271 #endif /* RT3070 // */
3272 #ifdef RT3090
3273 void NICInitRT3090RFRegisters(struct rt_rtmp_adapter *pAd);
3274 #endif /* RT3090 // */
3276 void RT30xxHaltAction(struct rt_rtmp_adapter *pAd);
3278 void RT30xxSetRxAnt(struct rt_rtmp_adapter *pAd, u8 Ant);
3279 #endif /* RT30xx // */
3281 void AsicEvaluateRxAnt(struct rt_rtmp_adapter *pAd);
3283 void AsicRxAntEvalTimeout(void *SystemSpecific1,
3284 void *FunctionContext,
3285 void *SystemSpecific2, void *SystemSpecific3);
3287 void APSDPeriodicExec(void *SystemSpecific1,
3288 void *FunctionContext,
3289 void *SystemSpecific2, void *SystemSpecific3);
3291 BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(struct rt_rtmp_adapter *pAd,
3292 struct rt_mac_table_entry *pEntry);
3294 u8 RTMPStaFixedTxMode(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
3296 void RTMPUpdateLegacyTxSetting(u8 fixed_tx_mode, struct rt_mac_table_entry *pEntry);
3298 BOOLEAN RTMPAutoRateSwitchCheck(struct rt_rtmp_adapter *pAd);
3300 int MlmeInit(struct rt_rtmp_adapter *pAd);
3302 void MlmeHandler(struct rt_rtmp_adapter *pAd);
3304 void MlmeHalt(struct rt_rtmp_adapter *pAd);
3306 void MlmeResetRalinkCounters(struct rt_rtmp_adapter *pAd);
3308 void BuildChannelList(struct rt_rtmp_adapter *pAd);
3310 u8 FirstChannel(struct rt_rtmp_adapter *pAd);
3312 u8 NextChannel(struct rt_rtmp_adapter *pAd, u8 channel);
3314 void ChangeToCellPowerLimit(struct rt_rtmp_adapter *pAd,
3315 u8 AironetCellPowerLimit);
3317 /* */
3318 /* Prototypes of function definition in rtmp_tkip.c */
3319 /* */
3320 void RTMPInitTkipEngine(struct rt_rtmp_adapter *pAd,
3321 u8 *pTKey,
3322 u8 KeyId,
3323 u8 *pTA,
3324 u8 *pMICKey,
3325 u8 *pTSC, unsigned long *pIV16, unsigned long *pIV32);
3327 void RTMPInitMICEngine(struct rt_rtmp_adapter *pAd,
3328 u8 *pKey,
3329 u8 *pDA,
3330 u8 *pSA, u8 UserPriority, u8 *pMICKey);
3332 BOOLEAN RTMPTkipCompareMICValue(struct rt_rtmp_adapter *pAd,
3333 u8 *pSrc,
3334 u8 *pDA,
3335 u8 *pSA,
3336 u8 *pMICKey,
3337 u8 UserPriority, u32 Len);
3339 void RTMPCalculateMICValue(struct rt_rtmp_adapter *pAd,
3340 void *pPacket,
3341 u8 *pEncap,
3342 struct rt_cipher_key *pKey, u8 apidx);
3344 void RTMPTkipAppendByte(struct rt_tkip_key_info *pTkip, u8 uChar);
3346 void RTMPTkipAppend(struct rt_tkip_key_info *pTkip, u8 *pSrc, u32 nBytes);
3348 void RTMPTkipGetMIC(struct rt_tkip_key_info *pTkip);
3350 BOOLEAN RTMPSoftDecryptTKIP(struct rt_rtmp_adapter *pAd,
3351 u8 *pData,
3352 unsigned long DataByteCnt,
3353 u8 UserPriority, struct rt_cipher_key *pWpaKey);
3355 BOOLEAN RTMPSoftDecryptAES(struct rt_rtmp_adapter *pAd,
3356 u8 *pData,
3357 unsigned long DataByteCnt, struct rt_cipher_key *pWpaKey);
3359 /* */
3360 /* Prototypes of function definition in cmm_info.c */
3361 /* */
3362 int RT_CfgSetCountryRegion(struct rt_rtmp_adapter *pAd, char *arg, int band);
3364 int RT_CfgSetWirelessMode(struct rt_rtmp_adapter *pAd, char *arg);
3366 int RT_CfgSetShortSlot(struct rt_rtmp_adapter *pAd, char *arg);
3368 int RT_CfgSetWepKey(struct rt_rtmp_adapter *pAd,
3369 char *keyString,
3370 struct rt_cipher_key *pSharedKey, int keyIdx);
3372 int RT_CfgSetWPAPSKKey(struct rt_rtmp_adapter *pAd,
3373 char *keyString,
3374 u8 *pHashStr,
3375 int hashStrLen, u8 *pPMKBuf);
3377 /* */
3378 /* Prototypes of function definition in cmm_info.c */
3379 /* */
3380 void RTMPWPARemoveAllKeys(struct rt_rtmp_adapter *pAd);
3382 void RTMPSetPhyMode(struct rt_rtmp_adapter *pAd, unsigned long phymode);
3384 void RTMPUpdateHTIE(struct rt_ht_capability *pRtHt,
3385 u8 *pMcsSet,
3386 struct rt_ht_capability_ie *pHtCapability,
3387 struct rt_add_ht_info_ie *pAddHtInfo);
3389 void RTMPAddWcidAttributeEntry(struct rt_rtmp_adapter *pAd,
3390 u8 BssIdx,
3391 u8 KeyIdx,
3392 u8 CipherAlg, struct rt_mac_table_entry *pEntry);
3394 char *GetEncryptType(char enc);
3396 char *GetAuthMode(char auth);
3398 void RTMPSetHT(struct rt_rtmp_adapter *pAd, struct rt_oid_set_ht_phymode *pHTPhyMode);
3400 void RTMPSetIndividualHT(struct rt_rtmp_adapter *pAd, u8 apidx);
3402 void RTMPSendWirelessEvent(struct rt_rtmp_adapter *pAd,
3403 u16 Event_flag,
3404 u8 *pAddr, u8 BssIdx, char Rssi);
3406 char ConvertToRssi(struct rt_rtmp_adapter *pAd, char Rssi, u8 RssiNumber);
3408 /*===================================
3409 Function prototype in cmm_wpa.c
3410 =================================== */
3411 void RTMPToWirelessSta(struct rt_rtmp_adapter *pAd,
3412 struct rt_mac_table_entry *pEntry,
3413 u8 *pHeader802_3,
3414 u32 HdrLen,
3415 u8 *pData,
3416 u32 DataLen, IN BOOLEAN bClearFrame);
3418 void WpaDerivePTK(struct rt_rtmp_adapter *pAd,
3419 u8 *PMK,
3420 u8 *ANonce,
3421 u8 *AA,
3422 u8 *SNonce,
3423 u8 *SA, u8 *output, u32 len);
3425 void GenRandom(struct rt_rtmp_adapter *pAd, u8 *macAddr, u8 *random);
3427 BOOLEAN RTMPCheckWPAframe(struct rt_rtmp_adapter *pAd,
3428 struct rt_mac_table_entry *pEntry,
3429 u8 *pData,
3430 unsigned long DataByteCount, u8 FromWhichBSSID);
3432 void AES_GTK_KEY_UNWRAP(u8 *key,
3433 u8 *plaintext,
3434 u32 c_len, u8 *ciphertext);
3436 BOOLEAN RTMPParseEapolKeyData(struct rt_rtmp_adapter *pAd,
3437 u8 *pKeyData,
3438 u8 KeyDataLen,
3439 u8 GroupKeyIndex,
3440 u8 MsgType,
3441 IN BOOLEAN bWPA2, struct rt_mac_table_entry *pEntry);
3443 void ConstructEapolMsg(struct rt_mac_table_entry *pEntry,
3444 u8 GroupKeyWepStatus,
3445 u8 MsgType,
3446 u8 DefaultKeyIdx,
3447 u8 *KeyNonce,
3448 u8 *TxRSC,
3449 u8 *GTK,
3450 u8 *RSNIE,
3451 u8 RSNIE_Len, struct rt_eapol_packet *pMsg);
3453 int RTMPSoftDecryptBroadCastData(struct rt_rtmp_adapter *pAd,
3454 struct rt_rx_blk *pRxBlk,
3455 IN NDIS_802_11_ENCRYPTION_STATUS
3456 GroupCipher,
3457 struct rt_cipher_key *pShard_key);
3459 void RTMPMakeRSNIE(struct rt_rtmp_adapter *pAd,
3460 u32 AuthMode, u32 WepStatus, u8 apidx);
3462 /* */
3463 /* function prototype in ap_wpa.c */
3464 /* */
3465 void RTMPGetTxTscFromAsic(struct rt_rtmp_adapter *pAd,
3466 u8 apidx, u8 *pTxTsc);
3468 void APInstallPairwiseKey(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
3470 u32 APValidateRSNIE(struct rt_rtmp_adapter *pAd,
3471 struct rt_mac_table_entry *pEntry,
3472 u8 *pRsnIe, u8 rsnie_len);
3474 void HandleCounterMeasure(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
3476 void WPAStart4WayHS(struct rt_rtmp_adapter *pAd,
3477 struct rt_mac_table_entry *pEntry, unsigned long TimeInterval);
3479 void WPAStart2WayGroupHS(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
3481 void PeerPairMsg1Action(struct rt_rtmp_adapter *pAd,
3482 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3484 void PeerPairMsg2Action(struct rt_rtmp_adapter *pAd,
3485 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3487 void PeerPairMsg3Action(struct rt_rtmp_adapter *pAd,
3488 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3490 void PeerPairMsg4Action(struct rt_rtmp_adapter *pAd,
3491 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3493 void PeerGroupMsg1Action(struct rt_rtmp_adapter *pAd,
3494 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3496 void PeerGroupMsg2Action(struct rt_rtmp_adapter *pAd,
3497 struct rt_mac_table_entry *pEntry,
3498 void *Msg, u32 MsgLen);
3500 void WpaDeriveGTK(u8 *PMK,
3501 u8 *GNonce,
3502 u8 *AA, u8 *output, u32 len);
3504 void AES_GTK_KEY_WRAP(u8 *key,
3505 u8 *plaintext,
3506 u32 p_len, u8 *ciphertext);
3508 /*typedef void (*TIMER_FUNCTION)(unsigned long); */
3510 /* timeout -- ms */
3511 void RTMP_SetPeriodicTimer(struct timer_list *pTimer,
3512 IN unsigned long timeout);
3514 void RTMP_OS_Init_Timer(struct rt_rtmp_adapter *pAd,
3515 struct timer_list *pTimer,
3516 IN TIMER_FUNCTION function, void *data);
3518 void RTMP_OS_Add_Timer(struct timer_list *pTimer,
3519 IN unsigned long timeout);
3521 void RTMP_OS_Mod_Timer(struct timer_list *pTimer,
3522 IN unsigned long timeout);
3524 void RTMP_OS_Del_Timer(struct timer_list *pTimer,
3525 OUT BOOLEAN *pCancelled);
3527 void RTMP_OS_Release_Packet(struct rt_rtmp_adapter *pAd, struct rt_queue_entry *pEntry);
3529 void RTMPusecDelay(unsigned long usec);
3531 int os_alloc_mem(struct rt_rtmp_adapter *pAd,
3532 u8 **mem, unsigned long size);
3534 int os_free_mem(struct rt_rtmp_adapter *pAd, void *mem);
3536 void RTMP_AllocateSharedMemory(struct rt_rtmp_adapter *pAd,
3537 unsigned long Length,
3538 IN BOOLEAN Cached,
3539 void **VirtualAddress,
3540 dma_addr_t *PhysicalAddress);
3542 void RTMPFreeTxRxRingMemory(struct rt_rtmp_adapter *pAd);
3544 int AdapterBlockAllocateMemory(void *handle, void **ppAd);
3546 void RTMP_AllocateTxDescMemory(struct rt_rtmp_adapter *pAd,
3547 u32 Index,
3548 unsigned long Length,
3549 IN BOOLEAN Cached,
3550 void **VirtualAddress,
3551 dma_addr_t *PhysicalAddress);
3553 void RTMP_AllocateFirstTxBuffer(struct rt_rtmp_adapter *pAd,
3554 u32 Index,
3555 unsigned long Length,
3556 IN BOOLEAN Cached,
3557 void **VirtualAddress,
3558 dma_addr_t *PhysicalAddress);
3560 void RTMP_FreeFirstTxBuffer(struct rt_rtmp_adapter *pAd,
3561 unsigned long Length,
3562 IN BOOLEAN Cached,
3563 void *VirtualAddress,
3564 dma_addr_t PhysicalAddress);
3566 void RTMP_AllocateMgmtDescMemory(struct rt_rtmp_adapter *pAd,
3567 unsigned long Length,
3568 IN BOOLEAN Cached,
3569 void **VirtualAddress,
3570 dma_addr_t *PhysicalAddress);
3572 void RTMP_AllocateRxDescMemory(struct rt_rtmp_adapter *pAd,
3573 unsigned long Length,
3574 IN BOOLEAN Cached,
3575 void **VirtualAddress,
3576 dma_addr_t *PhysicalAddress);
3578 void RTMP_FreeDescMemory(struct rt_rtmp_adapter *pAd,
3579 unsigned long Length,
3580 void *VirtualAddress,
3581 dma_addr_t PhysicalAddress);
3583 void *RtmpOSNetPktAlloc(struct rt_rtmp_adapter *pAd, IN int size);
3585 void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd,
3586 unsigned long Length,
3587 IN BOOLEAN Cached,
3588 void **VirtualAddress,
3589 OUT dma_addr_t *PhysicalAddress);
3591 void *RTMP_AllocateTxPacketBuffer(struct rt_rtmp_adapter *pAd,
3592 unsigned long Length,
3593 IN BOOLEAN Cached,
3594 void **VirtualAddress);
3596 void *RTMP_AllocateFragPacketBuffer(struct rt_rtmp_adapter *pAd,
3597 unsigned long Length);
3599 void RTMP_QueryPacketInfo(void *pPacket,
3600 struct rt_packet_info *pPacketInfo,
3601 u8 **pSrcBufVA, u32 *pSrcBufLen);
3603 void RTMP_QueryNextPacketInfo(void **ppPacket,
3604 struct rt_packet_info *pPacketInfo,
3605 u8 **pSrcBufVA, u32 *pSrcBufLen);
3607 BOOLEAN RTMP_FillTxBlkInfo(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk);
3609 struct rt_rtmp_sg_list *rt_get_sg_list_from_packet(void *pPacket,
3610 struct rt_rtmp_sg_list *sg);
3612 void announce_802_3_packet(struct rt_rtmp_adapter *pAd, void *pPacket);
3614 u32 BA_Reorder_AMSDU_Annnounce(struct rt_rtmp_adapter *pAd, void *pPacket);
3616 struct net_device *get_netdev_from_bssid(struct rt_rtmp_adapter *pAd, u8 FromWhichBSSID);
3618 void *duplicate_pkt(struct rt_rtmp_adapter *pAd,
3619 u8 *pHeader802_3,
3620 u32 HdrLen,
3621 u8 *pData,
3622 unsigned long DataSize, u8 FromWhichBSSID);
3624 void *duplicate_pkt_with_TKIP_MIC(struct rt_rtmp_adapter *pAd,
3625 void *pOldPkt);
3627 void ba_flush_reordering_timeout_mpdus(struct rt_rtmp_adapter *pAd,
3628 struct rt_ba_rec_entry *pBAEntry,
3629 unsigned long Now32);
3631 void BAOriSessionSetUp(struct rt_rtmp_adapter *pAd,
3632 struct rt_mac_table_entry *pEntry,
3633 u8 TID,
3634 u16 TimeOut,
3635 unsigned long DelayTime, IN BOOLEAN isForced);
3637 void BASessionTearDownALL(struct rt_rtmp_adapter *pAd, u8 Wcid);
3639 BOOLEAN OS_Need_Clone_Packet(void);
3641 void build_tx_packet(struct rt_rtmp_adapter *pAd,
3642 void *pPacket,
3643 u8 *pFrame, unsigned long FrameLen);
3645 void BAOriSessionTearDown(struct rt_rtmp_adapter *pAd,
3646 u8 Wcid,
3647 u8 TID,
3648 IN BOOLEAN bPassive, IN BOOLEAN bForceSend);
3650 void BARecSessionTearDown(struct rt_rtmp_adapter *pAd,
3651 u8 Wcid, u8 TID, IN BOOLEAN bPassive);
3653 BOOLEAN ba_reordering_resource_init(struct rt_rtmp_adapter *pAd, int num);
3654 void ba_reordering_resource_release(struct rt_rtmp_adapter *pAd);
3656 char *rstrtok(char *s, IN const char *ct);
3658 /*//////// common ioctl functions ////////// */
3659 int SetCommonHT(struct rt_rtmp_adapter *pAd);
3661 int WpaCheckEapCode(struct rt_rtmp_adapter *pAd,
3662 u8 *pFrame, u16 FrameLen, u16 OffSet);
3664 void WpaSendMicFailureToWpaSupplicant(struct rt_rtmp_adapter *pAd,
3665 IN BOOLEAN bUnicast);
3667 int wext_notify_event_assoc(struct rt_rtmp_adapter *pAd);
3669 BOOLEAN STARxDoneInterruptHandle(struct rt_rtmp_adapter *pAd, IN BOOLEAN argc);
3671 /* AMPDU packet indication */
3672 void Indicate_AMPDU_Packet(struct rt_rtmp_adapter *pAd,
3673 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3675 /* AMSDU packet indication */
3676 void Indicate_AMSDU_Packet(struct rt_rtmp_adapter *pAd,
3677 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3679 /* Normal legacy Rx packet indication */
3680 void Indicate_Legacy_Packet(struct rt_rtmp_adapter *pAd,
3681 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3683 void Indicate_EAPOL_Packet(struct rt_rtmp_adapter *pAd,
3684 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3686 void update_os_packet_info(struct rt_rtmp_adapter *pAd,
3687 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3689 void wlan_802_11_to_802_3_packet(struct rt_rtmp_adapter *pAd,
3690 struct rt_rx_blk *pRxBlk,
3691 u8 *pHeader802_3,
3692 u8 FromWhichBSSID);
3694 /* remove LLC and get 802_3 Header */
3695 #define RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(_pRxBlk, _pHeader802_3) \
3697 u8 *_pRemovedLLCSNAP = NULL, *_pDA, *_pSA; \
3699 if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_MESH)) { \
3700 _pDA = _pRxBlk->pHeader->Addr3; \
3701 _pSA = (u8 *)_pRxBlk->pHeader + sizeof(struct rt_header_802_11); \
3703 else {\
3704 if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_INFRA)) {\
3705 _pDA = _pRxBlk->pHeader->Addr1; \
3706 if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_DLS)) \
3707 _pSA = _pRxBlk->pHeader->Addr2; \
3708 else \
3709 _pSA = _pRxBlk->pHeader->Addr3; \
3711 else { \
3712 _pDA = _pRxBlk->pHeader->Addr1; \
3713 _pSA = _pRxBlk->pHeader->Addr2; \
3717 CONVERT_TO_802_3(_pHeader802_3, _pDA, _pSA, _pRxBlk->pData, \
3718 _pRxBlk->DataSize, _pRemovedLLCSNAP); \
3721 void Sta_Announce_or_Forward_802_3_Packet(struct rt_rtmp_adapter *pAd,
3722 void *pPacket,
3723 u8 FromWhichBSSID);
3725 #define ANNOUNCE_OR_FORWARD_802_3_PACKET(_pAd, _pPacket, _FromWhichBSS)\
3726 Sta_Announce_or_Forward_802_3_Packet(_pAd, _pPacket, _FromWhichBSS);
3727 /*announce_802_3_packet(_pAd, _pPacket); */
3729 void *DuplicatePacket(struct rt_rtmp_adapter *pAd,
3730 void *pPacket, u8 FromWhichBSSID);
3732 void *ClonePacket(struct rt_rtmp_adapter *pAd,
3733 void *pPacket,
3734 u8 *pData, unsigned long DataSize);
3736 /* Normal, AMPDU or AMSDU */
3737 void CmmRxnonRalinkFrameIndicate(struct rt_rtmp_adapter *pAd,
3738 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3740 void CmmRxRalinkFrameIndicate(struct rt_rtmp_adapter *pAd,
3741 struct rt_mac_table_entry *pEntry,
3742 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3744 void Update_Rssi_Sample(struct rt_rtmp_adapter *pAd,
3745 struct rt_rssi_sample *pRssi, struct rt_rxwi * pRxWI);
3747 void *GetPacketFromRxRing(struct rt_rtmp_adapter *pAd,
3748 OUT PRT28XX_RXD_STRUC pSaveRxD,
3749 OUT BOOLEAN *pbReschedule,
3750 IN u32 *pRxPending);
3752 void *RTMPDeFragmentDataFrame(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk);
3754 enum {
3755 DIDmsg_lnxind_wlansniffrm = 0x00000044,
3756 DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044,
3757 DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044,
3758 DIDmsg_lnxind_wlansniffrm_channel = 0x00030044,
3759 DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044,
3760 DIDmsg_lnxind_wlansniffrm_sq = 0x00050044,
3761 DIDmsg_lnxind_wlansniffrm_signal = 0x00060044,
3762 DIDmsg_lnxind_wlansniffrm_noise = 0x00070044,
3763 DIDmsg_lnxind_wlansniffrm_rate = 0x00080044,
3764 DIDmsg_lnxind_wlansniffrm_istx = 0x00090044,
3765 DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044
3767 enum {
3768 P80211ENUM_msgitem_status_no_value = 0x00
3770 enum {
3771 P80211ENUM_truth_false = 0x00,
3772 P80211ENUM_truth_true = 0x01
3775 /* Definition from madwifi */
3776 struct rt_p80211item_uint32 {
3777 u32 did;
3778 u16 status;
3779 u16 len;
3780 u32 data;
3783 struct rt_wlan_ng_prism2_header {
3784 u32 msgcode;
3785 u32 msglen;
3786 #define WLAN_DEVNAMELEN_MAX 16
3787 u8 devname[WLAN_DEVNAMELEN_MAX];
3788 struct rt_p80211item_uint32 hosttime;
3789 struct rt_p80211item_uint32 mactime;
3790 struct rt_p80211item_uint32 channel;
3791 struct rt_p80211item_uint32 rssi;
3792 struct rt_p80211item_uint32 sq;
3793 struct rt_p80211item_uint32 signal;
3794 struct rt_p80211item_uint32 noise;
3795 struct rt_p80211item_uint32 rate;
3796 struct rt_p80211item_uint32 istx;
3797 struct rt_p80211item_uint32 frmlen;
3800 /* The radio capture header precedes the 802.11 header. */
3801 struct PACKED rt_ieee80211_radiotap_header {
3802 u8 it_version; /* Version 0. Only increases
3803 * for drastic changes,
3804 * introduction of compatible
3805 * new fields does not count.
3807 u8 it_pad;
3808 u16 it_len; /* length of the whole
3809 * header in bytes, including
3810 * it_version, it_pad,
3811 * it_len, and data fields.
3813 u32 it_present; /* A bitmap telling which
3814 * fields are present. Set bit 31
3815 * (0x80000000) to extend the
3816 * bitmap by another 32 bits.
3817 * Additional extensions are made
3818 * by setting bit 31.
3822 enum ieee80211_radiotap_type {
3823 IEEE80211_RADIOTAP_TSFT = 0,
3824 IEEE80211_RADIOTAP_FLAGS = 1,
3825 IEEE80211_RADIOTAP_RATE = 2,
3826 IEEE80211_RADIOTAP_CHANNEL = 3,
3827 IEEE80211_RADIOTAP_FHSS = 4,
3828 IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
3829 IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
3830 IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
3831 IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
3832 IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
3833 IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
3834 IEEE80211_RADIOTAP_ANTENNA = 11,
3835 IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
3836 IEEE80211_RADIOTAP_DB_ANTNOISE = 13
3839 #define WLAN_RADIOTAP_PRESENT ( \
3840 (1 << IEEE80211_RADIOTAP_TSFT) | \
3841 (1 << IEEE80211_RADIOTAP_FLAGS) | \
3842 (1 << IEEE80211_RADIOTAP_RATE) | \
3845 struct rt_wlan_radiotap_header {
3846 struct rt_ieee80211_radiotap_header wt_ihdr;
3847 long long wt_tsft;
3848 u8 wt_flags;
3849 u8 wt_rate;
3851 /* Definition from madwifi */
3853 void send_monitor_packets(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk);
3855 void RTMPSetDesiredRates(struct rt_rtmp_adapter *pAdapter, long Rates);
3857 int Set_FixedTxMode_Proc(struct rt_rtmp_adapter *pAd, char *arg);
3859 BOOLEAN RT28XXChipsetCheck(IN void *_dev_p);
3861 void RT28XXDMADisable(struct rt_rtmp_adapter *pAd);
3863 void RT28XXDMAEnable(struct rt_rtmp_adapter *pAd);
3865 void RT28xx_UpdateBeaconToAsic(struct rt_rtmp_adapter *pAd,
3866 int apidx,
3867 unsigned long BeaconLen, unsigned long UpdatePos);
3869 int rt28xx_init(struct rt_rtmp_adapter *pAd,
3870 char *pDefaultMac, char *pHostName);
3872 int RtmpNetTaskInit(struct rt_rtmp_adapter *pAd);
3874 void RtmpNetTaskExit(struct rt_rtmp_adapter *pAd);
3876 int RtmpMgmtTaskInit(struct rt_rtmp_adapter *pAd);
3878 void RtmpMgmtTaskExit(struct rt_rtmp_adapter *pAd);
3880 void tbtt_tasklet(unsigned long data);
3882 struct net_device *RtmpPhyNetDevInit(struct rt_rtmp_adapter *pAd,
3883 struct rt_rtmp_os_netdev_op_hook *pNetHook);
3885 BOOLEAN RtmpPhyNetDevExit(struct rt_rtmp_adapter *pAd, struct net_device *net_dev);
3887 int RtmpRaDevCtrlInit(struct rt_rtmp_adapter *pAd, IN RTMP_INF_TYPE infType);
3889 BOOLEAN RtmpRaDevCtrlExit(struct rt_rtmp_adapter *pAd);
3891 #ifdef RTMP_MAC_PCI
3892 /* */
3893 /* Function Prototype in cmm_data_pci.c */
3894 /* */
3895 u16 RtmpPCI_WriteTxResource(struct rt_rtmp_adapter *pAd,
3896 struct rt_tx_blk *pTxBlk,
3897 IN BOOLEAN bIsLast, u16 *FreeNumber);
3899 u16 RtmpPCI_WriteSingleTxResource(struct rt_rtmp_adapter *pAd,
3900 struct rt_tx_blk *pTxBlk,
3901 IN BOOLEAN bIsLast,
3902 u16 *FreeNumber);
3904 u16 RtmpPCI_WriteMultiTxResource(struct rt_rtmp_adapter *pAd,
3905 struct rt_tx_blk *pTxBlk,
3906 u8 frameNum, u16 *FreeNumber);
3908 u16 RtmpPCI_WriteFragTxResource(struct rt_rtmp_adapter *pAd,
3909 struct rt_tx_blk *pTxBlk,
3910 u8 fragNum, u16 *FreeNumber);
3912 u16 RtmpPCI_WriteSubTxResource(struct rt_rtmp_adapter *pAd,
3913 struct rt_tx_blk *pTxBlk,
3914 IN BOOLEAN bIsLast, u16 *FreeNumber);
3916 void RtmpPCI_FinalWriteTxResource(struct rt_rtmp_adapter *pAd,
3917 struct rt_tx_blk *pTxBlk,
3918 u16 totalMPDUSize,
3919 u16 FirstTxIdx);
3921 void RtmpPCIDataLastTxIdx(struct rt_rtmp_adapter *pAd,
3922 u8 QueIdx, u16 LastTxIdx);
3924 void RtmpPCIDataKickOut(struct rt_rtmp_adapter *pAd,
3925 struct rt_tx_blk *pTxBlk, u8 QueIdx);
3927 int RtmpPCIMgmtKickOut(struct rt_rtmp_adapter *pAd,
3928 u8 QueIdx,
3929 void *pPacket,
3930 u8 *pSrcBufVA, u32 SrcBufLen);
3932 int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
3933 struct rt_header_802_11 *pHeader,
3934 struct rt_rxwi *pRxWI, IN PRT28XX_RXD_STRUC pRxD);
3936 BOOLEAN RT28xxPciAsicRadioOff(struct rt_rtmp_adapter *pAd,
3937 u8 Level, u16 TbttNumToNextWakeUp);
3939 BOOLEAN RT28xxPciAsicRadioOn(struct rt_rtmp_adapter *pAd, u8 Level);
3941 void RTMPInitPCIeLinkCtrlValue(struct rt_rtmp_adapter *pAd);
3943 void RTMPFindHostPCIDev(struct rt_rtmp_adapter *pAd);
3945 void RTMPPCIeLinkCtrlValueRestore(struct rt_rtmp_adapter *pAd, u8 Level);
3947 void RTMPPCIeLinkCtrlSetting(struct rt_rtmp_adapter *pAd, u16 Max);
3949 void RTMPrt3xSetPCIePowerLinkCtrl(struct rt_rtmp_adapter *pAd);
3951 void PsPollWakeExec(void *SystemSpecific1,
3952 void *FunctionContext,
3953 void *SystemSpecific2, void *SystemSpecific3);
3955 void RadioOnExec(void *SystemSpecific1,
3956 void *FunctionContext,
3957 void *SystemSpecific2, void *SystemSpecific3);
3959 void RT28xxPciStaAsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
3961 void RT28xxPciStaAsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
3962 u16 TbttNumToNextWakeUp);
3964 void RT28xxPciMlmeRadioOn(struct rt_rtmp_adapter *pAd);
3966 void RT28xxPciMlmeRadioOFF(struct rt_rtmp_adapter *pAd);
3967 #endif /* RTMP_MAC_PCI // */
3969 #ifdef RTMP_MAC_USB
3970 /* */
3971 /* Function Prototype in rtusb_bulk.c */
3972 /* */
3973 void RTUSBInitTxDesc(struct rt_rtmp_adapter *pAd,
3974 struct rt_tx_context *pTxContext,
3975 u8 BulkOutPipeId, IN usb_complete_t Func);
3977 void RTUSBInitHTTxDesc(struct rt_rtmp_adapter *pAd,
3978 struct rt_ht_tx_context *pTxContext,
3979 u8 BulkOutPipeId,
3980 unsigned long BulkOutSize, IN usb_complete_t Func);
3982 void RTUSBInitRxDesc(struct rt_rtmp_adapter *pAd, struct rt_rx_context *pRxContext);
3984 void RTUSBCleanUpDataBulkOutQueue(struct rt_rtmp_adapter *pAd);
3986 void RTUSBCancelPendingBulkOutIRP(struct rt_rtmp_adapter *pAd);
3988 void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd,
3989 u8 BulkOutPipeId, u8 Index);
3991 void RTUSBBulkOutNullFrame(struct rt_rtmp_adapter *pAd);
3993 void RTUSBBulkOutRTSFrame(struct rt_rtmp_adapter *pAd);
3995 void RTUSBCancelPendingBulkInIRP(struct rt_rtmp_adapter *pAd);
3997 void RTUSBCancelPendingIRPs(struct rt_rtmp_adapter *pAd);
3999 void RTUSBBulkOutMLMEPacket(struct rt_rtmp_adapter *pAd, u8 Index);
4001 void RTUSBBulkOutPsPoll(struct rt_rtmp_adapter *pAd);
4003 void RTUSBCleanUpMLMEBulkOutQueue(struct rt_rtmp_adapter *pAd);
4005 void RTUSBKickBulkOut(struct rt_rtmp_adapter *pAd);
4007 void RTUSBBulkReceive(struct rt_rtmp_adapter *pAd);
4009 void DoBulkIn(struct rt_rtmp_adapter *pAd);
4011 void RTUSBInitRxDesc(struct rt_rtmp_adapter *pAd, struct rt_rx_context *pRxContext);
4013 void RTUSBBulkRxHandle(IN unsigned long data);
4015 /* */
4016 /* Function Prototype in rtusb_io.c */
4017 /* */
4018 int RTUSBMultiRead(struct rt_rtmp_adapter *pAd,
4019 u16 Offset, u8 *pData, u16 length);
4021 int RTUSBMultiWrite(struct rt_rtmp_adapter *pAd,
4022 u16 Offset, const u8 *pData, u16 length);
4024 int RTUSBMultiWrite_OneByte(struct rt_rtmp_adapter *pAd,
4025 u16 Offset, const u8 *pData);
4027 int RTUSBReadBBPRegister(struct rt_rtmp_adapter *pAd,
4028 u8 Id, u8 *pValue);
4030 int RTUSBWriteBBPRegister(struct rt_rtmp_adapter *pAd,
4031 u8 Id, u8 Value);
4033 int RTUSBWriteRFRegister(struct rt_rtmp_adapter *pAd, u32 Value);
4035 int RTUSB_VendorRequest(struct rt_rtmp_adapter *pAd,
4036 u32 TransferFlags,
4037 u8 ReservedBits,
4038 u8 Request,
4039 u16 Value,
4040 u16 Index,
4041 void *TransferBuffer,
4042 u32 TransferBufferLength);
4044 int RTUSBReadEEPROM(struct rt_rtmp_adapter *pAd,
4045 u16 Offset, u8 *pData, u16 length);
4047 int RTUSBWriteEEPROM(struct rt_rtmp_adapter *pAd,
4048 u16 Offset, u8 *pData, u16 length);
4050 void RTUSBPutToSleep(struct rt_rtmp_adapter *pAd);
4052 int RTUSBWakeUp(struct rt_rtmp_adapter *pAd);
4054 void RTUSBInitializeCmdQ(struct rt_cmdq *cmdq);
4056 int RTUSBEnqueueCmdFromNdis(struct rt_rtmp_adapter *pAd,
4057 IN NDIS_OID Oid,
4058 IN BOOLEAN SetInformation,
4059 void *pInformationBuffer,
4060 u32 InformationBufferLength);
4062 int RTUSBEnqueueInternalCmd(struct rt_rtmp_adapter *pAd,
4063 IN NDIS_OID Oid,
4064 void *pInformationBuffer,
4065 u32 InformationBufferLength);
4067 void RTUSBDequeueCmd(struct rt_cmdq *cmdq, struct rt_cmdqelmt * * pcmdqelmt);
4069 int RTUSBCmdThread(IN void *Context);
4071 void RTUSBBssBeaconExit(struct rt_rtmp_adapter *pAd);
4073 void RTUSBBssBeaconStop(struct rt_rtmp_adapter *pAd);
4075 void RTUSBBssBeaconStart(struct rt_rtmp_adapter *pAd);
4077 void RTUSBBssBeaconInit(struct rt_rtmp_adapter *pAd);
4079 void RTUSBWatchDog(struct rt_rtmp_adapter *pAd);
4081 int RTUSBWriteMACRegister(struct rt_rtmp_adapter *pAd,
4082 u16 Offset, u32 Value);
4084 int RTUSBReadMACRegister(struct rt_rtmp_adapter *pAd,
4085 u16 Offset, u32 *pValue);
4087 int RTUSBSingleWrite(struct rt_rtmp_adapter *pAd,
4088 u16 Offset, u16 Value);
4090 int RTUSBFirmwareWrite(struct rt_rtmp_adapter *pAd,
4091 const u8 *pFwImage, unsigned long FwLen);
4093 int RTUSBVenderReset(struct rt_rtmp_adapter *pAd);
4095 int RTUSBSetHardWareRegister(struct rt_rtmp_adapter *pAdapter, void *pBuf);
4097 int RTUSBQueryHardWareRegister(struct rt_rtmp_adapter *pAdapter,
4098 void *pBuf);
4100 void CMDHandler(struct rt_rtmp_adapter *pAd);
4102 int RTUSBWriteHWMACAddress(struct rt_rtmp_adapter *pAdapter);
4104 void MacTableInitialize(struct rt_rtmp_adapter *pAd);
4106 void MlmeSetPsm(struct rt_rtmp_adapter *pAd, u16 psm);
4108 int RTMPWPAAddKeyProc(struct rt_rtmp_adapter *pAd, void *pBuf);
4110 void AsicRxAntEvalAction(struct rt_rtmp_adapter *pAd);
4112 void append_pkt(struct rt_rtmp_adapter *pAd,
4113 u8 *pHeader802_3,
4114 u32 HdrLen,
4115 u8 *pData,
4116 unsigned long DataSize, void **ppPacket);
4118 u32 deaggregate_AMSDU_announce(struct rt_rtmp_adapter *pAd,
4119 void *pPacket,
4120 u8 *pData, unsigned long DataSize);
4122 int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
4123 struct rt_header_802_11 *pHeader,
4124 struct rt_rxwi *pRxWI,
4125 IN PRT28XX_RXD_STRUC pRxINFO);
4127 void RTUSBMlmeHardTransmit(struct rt_rtmp_adapter *pAd, struct rt_mgmt *pMgmt);
4129 int MlmeThread(void *Context);
4131 /* */
4132 /* Function Prototype in rtusb_data.c */
4133 /* */
4134 int RTUSBFreeDescriptorRequest(struct rt_rtmp_adapter *pAd,
4135 u8 BulkOutPipeId,
4136 u32 NumberRequired);
4138 BOOLEAN RTUSBNeedQueueBackForAgg(struct rt_rtmp_adapter *pAd, u8 BulkOutPipeId);
4140 void RTMPWriteTxInfo(struct rt_rtmp_adapter *pAd,
4141 struct rt_txinfo *pTxInfo,
4142 u16 USBDMApktLen,
4143 IN BOOLEAN bWiv,
4144 u8 QueueSel, u8 NextValid, u8 TxBurst);
4146 /* */
4147 /* Function Prototype in cmm_data_usb.c */
4148 /* */
4149 u16 RtmpUSB_WriteSubTxResource(struct rt_rtmp_adapter *pAd,
4150 struct rt_tx_blk *pTxBlk,
4151 IN BOOLEAN bIsLast, u16 *FreeNumber);
4153 u16 RtmpUSB_WriteSingleTxResource(struct rt_rtmp_adapter *pAd,
4154 struct rt_tx_blk *pTxBlk,
4155 IN BOOLEAN bIsLast,
4156 u16 *FreeNumber);
4158 u16 RtmpUSB_WriteFragTxResource(struct rt_rtmp_adapter *pAd,
4159 struct rt_tx_blk *pTxBlk,
4160 u8 fragNum, u16 *FreeNumber);
4162 u16 RtmpUSB_WriteMultiTxResource(struct rt_rtmp_adapter *pAd,
4163 struct rt_tx_blk *pTxBlk,
4164 u8 frameNum, u16 *FreeNumber);
4166 void RtmpUSB_FinalWriteTxResource(struct rt_rtmp_adapter *pAd,
4167 struct rt_tx_blk *pTxBlk,
4168 u16 totalMPDUSize, u16 TxIdx);
4170 void RtmpUSBDataLastTxIdx(struct rt_rtmp_adapter *pAd,
4171 u8 QueIdx, u16 TxIdx);
4173 void RtmpUSBDataKickOut(struct rt_rtmp_adapter *pAd,
4174 struct rt_tx_blk *pTxBlk, u8 QueIdx);
4176 int RtmpUSBMgmtKickOut(struct rt_rtmp_adapter *pAd,
4177 u8 QueIdx,
4178 void *pPacket,
4179 u8 *pSrcBufVA, u32 SrcBufLen);
4181 void RtmpUSBNullFrameKickOut(struct rt_rtmp_adapter *pAd,
4182 u8 QueIdx,
4183 u8 *pNullFrame, u32 frameLen);
4185 void RtmpUsbStaAsicForceWakeupTimeout(void *SystemSpecific1,
4186 void *FunctionContext,
4187 void *SystemSpecific2,
4188 void *SystemSpecific3);
4190 void RT28xxUsbStaAsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
4192 void RT28xxUsbStaAsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
4193 u16 TbttNumToNextWakeUp);
4195 void RT28xxUsbMlmeRadioOn(struct rt_rtmp_adapter *pAd);
4197 void RT28xxUsbMlmeRadioOFF(struct rt_rtmp_adapter *pAd);
4198 #endif /* RTMP_MAC_USB // */
4200 void AsicTurnOffRFClk(struct rt_rtmp_adapter *pAd, u8 Channel);
4202 void AsicTurnOnRFClk(struct rt_rtmp_adapter *pAd, u8 Channel);
4204 #ifdef RTMP_TIMER_TASK_SUPPORT
4205 int RtmpTimerQThread(IN void *Context);
4207 struct rt_rtmp_timer_task_entry *RtmpTimerQInsert(struct rt_rtmp_adapter *pAd,
4208 struct rt_ralink_timer *pTimer);
4210 BOOLEAN RtmpTimerQRemove(struct rt_rtmp_adapter *pAd,
4211 struct rt_ralink_timer *pTimer);
4213 void RtmpTimerQExit(struct rt_rtmp_adapter *pAd);
4215 void RtmpTimerQInit(struct rt_rtmp_adapter *pAd);
4216 #endif /* RTMP_TIMER_TASK_SUPPORT // */
4218 void AsicStaBbpTuning(struct rt_rtmp_adapter *pAd);
4220 BOOLEAN StaAddMacTableEntry(struct rt_rtmp_adapter *pAd,
4221 struct rt_mac_table_entry *pEntry,
4222 u8 MaxSupportedRateIn500Kbps,
4223 struct rt_ht_capability_ie *pHtCapability,
4224 u8 HtCapabilityLen,
4225 struct rt_add_ht_info_ie *pAddHtInfo,
4226 u8 AddHtInfoLen, u16 CapabilityInfo);
4228 BOOLEAN AUTH_ReqSend(struct rt_rtmp_adapter *pAd,
4229 struct rt_mlme_queue_elem *pElem,
4230 struct rt_ralink_timer *pAuthTimer,
4231 char *pSMName,
4232 u16 SeqNo,
4233 u8 *pNewElement, unsigned long ElementLen);
4235 void RTMP_IndicateMediaState(struct rt_rtmp_adapter *pAd);
4237 void ReSyncBeaconTime(struct rt_rtmp_adapter *pAd);
4239 void RTMPSetAGCInitValue(struct rt_rtmp_adapter *pAd, u8 BandWidth);
4241 int rt28xx_close(struct net_device *dev);
4242 int rt28xx_open(struct net_device *dev);
4244 #define VIRTUAL_IF_INC(__pAd) ((__pAd)->VirtualIfCnt++)
4245 #define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--)
4246 #define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt)
4248 #ifdef LINUX
4249 __inline int VIRTUAL_IF_UP(struct rt_rtmp_adapter *pAd)
4251 if (VIRTUAL_IF_NUM(pAd) == 0) {
4252 if (rt28xx_open(pAd->net_dev) != 0) {
4253 DBGPRINT(RT_DEBUG_TRACE,
4254 ("rt28xx_open return fail!\n"));
4255 return -1;
4257 } else {
4259 VIRTUAL_IF_INC(pAd);
4260 return 0;
4263 __inline void VIRTUAL_IF_DOWN(struct rt_rtmp_adapter *pAd)
4265 VIRTUAL_IF_DEC(pAd);
4266 if (VIRTUAL_IF_NUM(pAd) == 0)
4267 rt28xx_close(pAd->net_dev);
4268 return;
4270 #endif /* LINUX // */
4273 OS Related funciton prototype definitions.
4274 TODO: Maybe we need to move these function prototypes to other proper place.
4276 int RtmpOSWrielessEventSend(struct rt_rtmp_adapter *pAd,
4277 u32 eventType,
4278 int flags,
4279 u8 *pSrcMac,
4280 u8 *pData, u32 dataLen);
4282 int RtmpOSNetDevAddrSet(struct net_device *pNetDev, u8 *pMacAddr);
4284 int RtmpOSNetDevAttach(struct net_device *pNetDev,
4285 struct rt_rtmp_os_netdev_op_hook *pDevOpHook);
4287 void RtmpOSNetDevClose(struct net_device *pNetDev);
4289 void RtmpOSNetDevDetach(struct net_device *pNetDev);
4291 int RtmpOSNetDevAlloc(struct net_device **pNewNetDev, u32 privDataSize);
4293 void RtmpOSNetDevFree(struct net_device *pNetDev);
4295 struct net_device *RtmpOSNetDevGetByName(struct net_device *pNetDev, char *pDevName);
4297 void RtmpOSNetDeviceRefPut(struct net_device *pNetDev);
4299 struct net_device *RtmpOSNetDevCreate(struct rt_rtmp_adapter *pAd,
4300 int devType,
4301 int devNum,
4302 int privMemSize, char *pNamePrefix);
4305 Task operation related function prototypes
4307 void RtmpOSTaskCustomize(struct rt_rtmp_os_task *pTask);
4309 int RtmpOSTaskNotifyToExit(struct rt_rtmp_os_task *pTask);
4311 int RtmpOSTaskKill(struct rt_rtmp_os_task *pTask);
4313 int RtmpOSTaskInit(struct rt_rtmp_os_task *pTask,
4314 char *pTaskName, void * pPriv);
4316 int RtmpOSTaskAttach(struct rt_rtmp_os_task *pTask,
4317 IN int (*fn) (void *), IN void *arg);
4320 File operation related function prototypes
4322 struct file *RtmpOSFileOpen(IN char *pPath, IN int flag, IN int mode);
4324 int RtmpOSFileClose(struct file *osfd);
4326 void RtmpOSFileSeek(struct file *osfd, IN int offset);
4328 int RtmpOSFileRead(struct file *osfd, IN char *pDataPtr, IN int readLen);
4330 int RtmpOSFileWrite(struct file *osfd, IN char *pDataPtr, IN int writeLen);
4332 #endif /* __RTMP_H__ */