2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
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. *
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. *
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. *
25 *************************************************************************
31 Miniport generic portion header file
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
43 #include "spectrum_def.h"
44 #include "rtmp_dot11.h"
45 #include "rtmp_chip.h"
47 struct rt_rtmp_adapter;
51 /*#define DBG_DIAGNOSE 1 */
53 /*+++Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function */
54 #define MAX_DATAMM_RETRY 3
55 #define MGMT_USE_QUEUE_FLAG 0x80
56 /*---Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function */
58 #define MAXSEQ (0xFFF)
60 extern unsigned char SNAP_AIRONET[];
61 extern unsigned char CISCO_OUI[];
62 extern u8 BaSizeArray[4];
64 extern u8 BROADCAST_ADDR[MAC_ADDR_LEN];
65 extern u8 ZERO_MAC_ADDR[MAC_ADDR_LEN];
66 extern unsigned long BIT32[32];
68 extern char *CipherName[];
69 extern char *MCSToMbps[];
70 extern u8 RxwiMCSToOfdmRate[12];
71 extern u8 SNAP_802_1H[6];
72 extern u8 SNAP_BRIDGE_TUNNEL[6];
73 extern u8 SNAP_AIRONET[8];
74 extern u8 CKIP_LLC_SNAP[8];
75 extern u8 EAPOL_LLC_SNAP[8];
78 extern u8 APPLE_TALK[2];
79 extern u8 RateIdToPlcpSignal[12]; /* see IEEE802.11a-1999 p.14 */
80 extern u8 OfdmRateToRxwiMCS[];
81 extern u8 OfdmSignalToRateId[16];
82 extern u8 default_cwmin[4];
83 extern u8 default_cwmax[4];
84 extern u8 default_sta_aifsn[4];
85 extern u8 MapUserPriorityToAccessCategory[8];
87 extern u16 RateUpPER[];
88 extern u16 RateDownPER[];
89 extern u8 Phy11BNextRateDownward[];
90 extern u8 Phy11BNextRateUpward[];
91 extern u8 Phy11BGNextRateDownward[];
92 extern u8 Phy11BGNextRateUpward[];
93 extern u8 Phy11ANextRateDownward[];
94 extern u8 Phy11ANextRateUpward[];
95 extern char RssiSafeLevelForTxRate[];
96 extern u8 RateIdToMbps[];
97 extern u16 RateIdTo500Kbps[];
99 extern u8 CipherSuiteWpaNoneTkip[];
100 extern u8 CipherSuiteWpaNoneTkipLen;
102 extern u8 CipherSuiteWpaNoneAes[];
103 extern u8 CipherSuiteWpaNoneAesLen;
110 extern u8 AddHtInfoIe;
111 extern u8 NewExtChanIe;
124 extern u8 WAPI_OUI[];
125 extern u8 WME_INFO_ELEM[];
126 extern u8 WME_PARM_ELEM[];
127 extern u8 Ccx2QosInfo[];
128 extern u8 Ccx2IeInfo[];
129 extern u8 RALINK_OUI[];
130 extern u8 PowerConstraintIE[];
132 extern u8 RateSwitchTable[];
133 extern u8 RateSwitchTable11B[];
134 extern u8 RateSwitchTable11G[];
135 extern u8 RateSwitchTable11BG[];
137 extern u8 RateSwitchTable11BGN1S[];
138 extern u8 RateSwitchTable11BGN2S[];
139 extern u8 RateSwitchTable11BGN2SForABand[];
140 extern u8 RateSwitchTable11N1S[];
141 extern u8 RateSwitchTable11N2S[];
142 extern u8 RateSwitchTable11N2SForABand[];
144 extern u8 PRE_N_HT_OUI[];
146 struct rt_rssi_sample {
147 char LastRssi0; /* last received RSSI */
148 char LastRssi1; /* last received RSSI */
149 char LastRssi2; /* last received RSSI */
159 /* Queue structure and macros */
161 struct rt_queue_entry;
163 struct rt_queue_entry {
164 struct rt_queue_entry *Next;
167 /* Queue structure */
168 struct rt_queue_header {
169 struct rt_queue_entry *Head;
170 struct rt_queue_entry *Tail;
171 unsigned long Number;
174 #define InitializeQueueHeader(QueueHeader) \
176 (QueueHeader)->Head = (QueueHeader)->Tail = NULL; \
177 (QueueHeader)->Number = 0; \
180 #define RemoveHeadQueue(QueueHeader) \
181 (QueueHeader)->Head; \
183 struct rt_queue_entry *pNext; \
184 if ((QueueHeader)->Head != NULL) \
186 pNext = (QueueHeader)->Head->Next; \
187 (QueueHeader)->Head->Next = NULL; \
188 (QueueHeader)->Head = pNext; \
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); \
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); \
221 (QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry); \
222 (QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry); \
223 (QueueHeader)->Number++; \
227 /* Macros for flag and ref count operations */
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); \
293 /* MACRO for 32-bit PCI register read / write */
295 /* Usage : RTMP_IO_READ32( */
296 /* struct rt_rtmp_adapter *pAd, */
297 /* unsigned long Register_Offset, */
298 /* unsigned long * pValue) */
300 /* RTMP_IO_WRITE32( */
301 /* struct rt_rtmp_adapter *pAd, */
302 /* unsigned long Register_Offset, */
303 /* unsigned long Value) */
307 /* Common fragment list structure - Identical to the scatter gather frag list structure */
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 {
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];
326 /* Some utility macros */
329 #define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
333 #define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
336 #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))))
338 #define INC_COUNTER64(Val) (Val.QuadPart++)
340 #define INFRA_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_INFRA_ON))
341 #define ADHOC_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_ADHOC_ON))
342 #define MONITOR_ON(_p) (((_p)->StaCfg.BssType) == BSS_MONITOR)
343 #define IDLE_ON(_p) (!INFRA_ON(_p) && !ADHOC_ON(_p))
345 /* Check LEAP & CCKM flags */
346 #define LEAP_ON(_p) (((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP)
347 #define LEAP_CCKM_ON(_p) ((((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP) && ((_p)->StaCfg.LeapAuthInfo.CCKM == TRUE))
349 /* if orginal Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required */
350 #define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap) \
352 if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500) \
354 _pExtraLlcSnapEncap = SNAP_802_1H; \
355 if (NdisEqualMemory(IPX, _pBufVA + 12, 2) || \
356 NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2)) \
358 _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
363 _pExtraLlcSnapEncap = NULL; \
367 /* New Define for new Tx Path. */
368 #define EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(_pBufVA, _pExtraLlcSnapEncap) \
370 if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500) \
372 _pExtraLlcSnapEncap = SNAP_802_1H; \
373 if (NdisEqualMemory(IPX, _pBufVA, 2) || \
374 NdisEqualMemory(APPLE_TALK, _pBufVA, 2)) \
376 _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
381 _pExtraLlcSnapEncap = NULL; \
385 #define MAKE_802_3_HEADER(_p, _pMac1, _pMac2, _pType) \
387 NdisMoveMemory(_p, _pMac1, MAC_ADDR_LEN); \
388 NdisMoveMemory((_p + MAC_ADDR_LEN), _pMac2, MAC_ADDR_LEN); \
389 NdisMoveMemory((_p + MAC_ADDR_LEN * 2), _pType, LENGTH_802_3_TYPE); \
392 /* if pData has no LLC/SNAP (neither RFC1042 nor Bridge tunnel), keep it that way. */
393 /* else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field */
394 /* else remove the LLC/SNAP field from the result Ethernet frame */
395 /* Patch for WHQL only, which did not turn on Netbios but use IPX within its payload */
397 /* _pData & _DataSize may be altered (remove 8-byte LLC/SNAP) by this MACRO */
398 /* _pRemovedLLCSNAP: pointer to removed LLC/SNAP; NULL is not removed */
399 #define CONVERT_TO_802_3(_p8023hdr, _pDA, _pSA, _pData, _DataSize, _pRemovedLLCSNAP) \
403 _pRemovedLLCSNAP = NULL; \
404 if (NdisEqualMemory(SNAP_802_1H, _pData, 6) || \
405 NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6)) \
407 u8 *pProto = _pData + 6; \
409 if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) && \
410 NdisEqualMemory(SNAP_802_1H, _pData, 6)) \
412 LLC_Len[0] = (u8)(_DataSize / 256); \
413 LLC_Len[1] = (u8)(_DataSize % 256); \
414 MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
418 MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto); \
419 _pRemovedLLCSNAP = _pData; \
420 _DataSize -= LENGTH_802_1_H; \
421 _pData += LENGTH_802_1_H; \
426 LLC_Len[0] = (u8)(_DataSize / 256); \
427 LLC_Len[1] = (u8)(_DataSize % 256); \
428 MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
432 /* Enqueue this frame to MLME engine */
433 /* We need to enqueue the whole frame because MLME need to pass data type */
434 /* information from 802.11 header */
436 #define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
438 u32 High32TSF, Low32TSF; \
439 RTMP_IO_READ32(_pAd, TSF_TIMER_DW1, &High32TSF); \
440 RTMP_IO_READ32(_pAd, TSF_TIMER_DW0, &Low32TSF); \
441 MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1,(u8)_Rssi2,_FrameSize, _pFrame, (u8)_PlcpSignal); \
443 #endif /* RTMP_MAC_PCI // */
445 #define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
447 u32 High32TSF=0, Low32TSF=0; \
448 MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1,(u8)_Rssi2,_FrameSize, _pFrame, (u8)_PlcpSignal); \
450 #endif /* RTMP_MAC_USB // */
452 #define MAC_ADDR_EQUAL(pAddr1,pAddr2) RTMPEqualMemory((void *)(pAddr1), (void *)(pAddr2), MAC_ADDR_LEN)
453 #define SSID_EQUAL(ssid1, len1, ssid2, len2) ((len1==len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))
456 /* Check if it is Japan W53(ch52,56,60,64) channel. */
458 #define JapanChannelCheck(channel) ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
460 #define STA_EXTRA_SETTING(_pAd)
462 #define STA_PORT_SECURED(_pAd) \
465 (_pAd)->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
466 NdisAcquireSpinLock(&((_pAd)->MacTabLock)); \
467 (_pAd)->MacTab.Content[BSSID_WCID].PortSecured = (_pAd)->StaCfg.PortSecured; \
468 (_pAd)->MacTab.Content[BSSID_WCID].PrivacyFilter = Ndis802_11PrivFilterAcceptAll;\
469 NdisReleaseSpinLock(&(_pAd)->MacTabLock); \
470 RTMPCancelTimer(&((_pAd)->Mlme.LinkDownTimer), &Cancelled);\
471 STA_EXTRA_SETTING(_pAd); \
475 /* Data buffer for DMA operation, the buffer must be contiguous physical memory */
476 /* Both DMA to / from CPU use the same structure. */
478 struct rt_rtmp_dmabuf {
479 unsigned long AllocSize;
480 void *AllocVa; /* TxBuf virtual address */
481 dma_addr_t AllocPa; /* TxBuf physical address */
485 /* Control block (Descriptor) for all ring descriptor DMA operation, buffer must be */
486 /* contiguous physical memory. char stored the binding Rx packet descriptor */
487 /* which won't be released, driver has to wait until upper layer return the packet */
488 /* before giveing up this rx ring descriptor to ASIC. NDIS_BUFFER is assocaited pair */
489 /* to describe the packet buffer. For Tx, char stored the tx packet descriptor */
490 /* which driver should ACK upper layer when the tx is physically done or failed. */
492 struct rt_rtmp_dmacb {
493 unsigned long AllocSize; /* Control block size */
494 void *AllocVa; /* Control block virtual address */
495 dma_addr_t AllocPa; /* Control block physical address */
497 void *pNextNdisPacket;
499 struct rt_rtmp_dmabuf DmaBuf; /* Associated DMA buffer structure */
502 struct rt_rtmp_tx_ring {
503 struct rt_rtmp_dmacb Cell[TX_RING_SIZE];
506 u32 TxSwFreeIdx; /* software next free tx index */
509 struct rt_rtmp_rx_ring {
510 struct rt_rtmp_dmacb Cell[RX_RING_SIZE];
513 int RxSwReadIdx; /* software next read index */
516 struct rt_rtmp_mgmt_ring {
517 struct rt_rtmp_dmacb Cell[MGMT_RING_SIZE];
520 u32 TxSwFreeIdx; /* software next free tx index */
524 /* Statistic counter structure */
526 struct rt_counter_802_3 {
528 unsigned long GoodTransmits;
529 unsigned long GoodReceives;
530 unsigned long TxErrors;
531 unsigned long RxErrors;
532 unsigned long RxNoBuffer;
535 unsigned long RcvAlignmentErrors;
536 unsigned long OneCollision;
537 unsigned long MoreCollisions;
541 struct rt_counter_802_11 {
542 unsigned long Length;
543 LARGE_INTEGER LastTransmittedFragmentCount;
544 LARGE_INTEGER TransmittedFragmentCount;
545 LARGE_INTEGER MulticastTransmittedFrameCount;
546 LARGE_INTEGER FailedCount;
547 LARGE_INTEGER RetryCount;
548 LARGE_INTEGER MultipleRetryCount;
549 LARGE_INTEGER RTSSuccessCount;
550 LARGE_INTEGER RTSFailureCount;
551 LARGE_INTEGER ACKFailureCount;
552 LARGE_INTEGER FrameDuplicateCount;
553 LARGE_INTEGER ReceivedFragmentCount;
554 LARGE_INTEGER MulticastReceivedFrameCount;
555 LARGE_INTEGER FCSErrorCount;
558 struct rt_counter_ralink {
559 unsigned long TransmittedByteCount; /* both successful and failure, used to calculate TX throughput */
560 unsigned long ReceivedByteCount; /* both CRC okay and CRC error, used to calculate RX throughput */
561 unsigned long BeenDisassociatedCount;
562 unsigned long BadCQIAutoRecoveryCount;
563 unsigned long PoorCQIRoamingCount;
564 unsigned long MgmtRingFullCount;
565 unsigned long RxCountSinceLastNULL;
566 unsigned long RxCount;
567 unsigned long RxRingErrCount;
568 unsigned long KickTxCount;
569 unsigned long TxRingErrCount;
570 LARGE_INTEGER RealFcsErrCount;
571 unsigned long PendingNdisPacketCount;
573 unsigned long OneSecOsTxCount[NUM_OF_TX_RING];
574 unsigned long OneSecDmaDoneCount[NUM_OF_TX_RING];
575 u32 OneSecTxDoneCount;
576 unsigned long OneSecRxCount;
577 u32 OneSecTxAggregationCount;
578 u32 OneSecRxAggregationCount;
579 u32 OneSecReceivedByteCount;
580 u32 OneSecFrameDuplicateCount;
582 u32 OneSecTransmittedByteCount; /* both successful and failure, used to calculate TX throughput */
583 u32 OneSecTxNoRetryOkCount;
584 u32 OneSecTxRetryOkCount;
585 u32 OneSecTxFailCount;
586 u32 OneSecFalseCCACnt; /* CCA error count, for debug purpose, might move to global counter */
587 u32 OneSecRxOkCnt; /* RX without error */
588 u32 OneSecRxOkDataCnt; /* unicast-to-me DATA frame count */
589 u32 OneSecRxFcsErrCnt; /* CRC error */
590 u32 OneSecBeaconSentCnt;
591 u32 LastOneSecTotalTxCount; /* OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount */
592 u32 LastOneSecRxOkDataCnt; /* OneSecRxOkDataCnt */
593 unsigned long DuplicateRcv;
594 unsigned long TxAggCount;
595 unsigned long TxNonAggCount;
596 unsigned long TxAgg1MPDUCount;
597 unsigned long TxAgg2MPDUCount;
598 unsigned long TxAgg3MPDUCount;
599 unsigned long TxAgg4MPDUCount;
600 unsigned long TxAgg5MPDUCount;
601 unsigned long TxAgg6MPDUCount;
602 unsigned long TxAgg7MPDUCount;
603 unsigned long TxAgg8MPDUCount;
604 unsigned long TxAgg9MPDUCount;
605 unsigned long TxAgg10MPDUCount;
606 unsigned long TxAgg11MPDUCount;
607 unsigned long TxAgg12MPDUCount;
608 unsigned long TxAgg13MPDUCount;
609 unsigned long TxAgg14MPDUCount;
610 unsigned long TxAgg15MPDUCount;
611 unsigned long TxAgg16MPDUCount;
613 LARGE_INTEGER TransmittedOctetsInAMSDU;
614 LARGE_INTEGER TransmittedAMSDUCount;
615 LARGE_INTEGER ReceivedOctesInAMSDUCount;
616 LARGE_INTEGER ReceivedAMSDUCount;
617 LARGE_INTEGER TransmittedAMPDUCount;
618 LARGE_INTEGER TransmittedMPDUsInAMPDUCount;
619 LARGE_INTEGER TransmittedOctetsInAMPDUCount;
620 LARGE_INTEGER MPDUInReceivedAMPDUCount;
623 struct rt_counter_drs {
624 /* to record the each TX rate's quality. 0 is best, the bigger the worse. */
625 u16 TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
626 u8 PER[MAX_STEP_OF_TX_RATE_SWITCH];
627 u8 TxRateUpPenalty; /* extra # of second penalty due to last unstable condition */
628 unsigned long CurrTxRateStableTime; /* # of second in current TX rate */
629 BOOLEAN fNoisyEnvironment;
630 BOOLEAN fLastSecAccordingRSSI;
631 u8 LastSecTxRateChangeAction; /* 0: no change, 1:rate UP, 2:rate down */
632 u8 LastTimeTxRateChangeAction; /*Keep last time value of LastSecTxRateChangeAction */
633 unsigned long LastTxOkCount;
636 /***************************************************************************
637 * security key related data structure
638 **************************************************************************/
639 struct rt_cipher_key {
640 u8 Key[16]; /* right now we implement 4 keys, 128 bits max */
641 u8 RxMic[8]; /* make alignment */
643 u8 TxTsc[6]; /* 48bit TSC value */
644 u8 RxTsc[6]; /* 48bit TSC value */
645 u8 CipherAlg; /* 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128 */
648 /* Key length for each key, 0: entry is invalid */
649 u8 Type; /* Indicate Pairwise/Group when reporting MIC error */
652 /* structure to define WPA Group Key Rekey Interval */
653 struct PACKED rt_802_11_wpa_rekey {
654 unsigned long ReKeyMethod; /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
655 unsigned long ReKeyInterval; /* time-based: seconds, packet-based: kilo-packets */
659 /***************************************************************************
660 * RTUSB I/O related data structure
661 **************************************************************************/
662 struct rt_set_asic_wcid {
663 unsigned long WCID; /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
664 unsigned long SetTid; /* time-based: seconds, packet-based: kilo-packets */
665 unsigned long DeleteTid; /* time-based: seconds, packet-based: kilo-packets */
666 u8 Addr[MAC_ADDR_LEN]; /* avoid in interrupt when write key */
669 struct rt_set_asic_wcid_attri {
670 unsigned long WCID; /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
671 unsigned long Cipher; /* ASIC Cipher definition */
672 u8 Addr[ETH_LENGTH_OF_ADDRESS];
675 /* for USB interface, avoid in interrupt when write key */
676 struct rt_add_pairwise_key_entry {
678 u16 MacTabMatchWCID; /* ASIC */
679 struct rt_cipher_key CipherKey;
682 /* Cipher suite type for mixed mode group cipher, P802.11i-2004 */
683 typedef enum _RT_802_11_CIPHER_SUITE_TYPE {
690 } RT_802_11_CIPHER_SUITE_TYPE, *PRT_802_11_CIPHER_SUITE_TYPE;
691 #endif /* RTMP_MAC_USB // */
693 struct rt_rogueap_entry {
694 u8 Addr[MAC_ADDR_LEN];
695 u8 ErrorCode[2]; /*00 01-Invalid authentication type */
696 /*00 02-Authentication timeout */
697 /*00 03-Challenge from AP failed */
698 /*00 04-Challenge to AP failed */
702 struct rt_rogueap_table {
704 struct rt_rogueap_entry RogueApEntry[MAX_LEN_OF_BSS_TABLE];
708 /* Cisco IAPP format */
710 struct rt_cisco_iapp_content {
711 u16 Length; /*IAPP Length */
712 u8 MessageType; /*IAPP type */
713 u8 FunctionCode; /*IAPP function type */
714 u8 DestinaionMAC[MAC_ADDR_LEN];
715 u8 SourceMAC[MAC_ADDR_LEN];
716 u16 Tag; /*Tag(element IE) - Adjacent AP report */
717 u16 TagLength; /*Length of element not including 4 byte header */
718 u8 OUI[4]; /*0x00, 0x40, 0x96, 0x00 */
719 u8 PreviousAP[MAC_ADDR_LEN]; /*MAC Address of access point */
722 u8 Ssid[MAX_LEN_OF_SSID];
723 u16 Seconds; /*Seconds that the client has been disassociated. */
727 * Fragment Frame structure
729 struct rt_fragment_frame {
731 unsigned long RxSize;
734 unsigned long Flags; /* Some extra frame information. bit 0: LLC presented */
738 /* Packet information for NdisQueryPacket */
740 struct rt_packet_info {
741 u32 PhysicalBufferCount; /* Physical breaks of buffer descripor chained */
742 u32 BufferCount; /* Number of Buffer descriptor chained */
743 u32 TotalPacketLength; /* Self explained */
744 char *pFirstBuffer; /* Pointer to first buffer descriptor */
748 /* Arcfour Structure Added by PaulWu */
750 struct rt_arcfourcontext {
757 /* Tkip Key structure which RC4 key & MIC calculation */
759 struct rt_tkip_key_info {
760 u32 nBytesInM; /* # bytes in M for MICKEY */
763 unsigned long K0; /* for MICKEY Low */
764 unsigned long K1; /* for MICKEY Hig */
765 unsigned long L; /* Current state for MICKEY */
766 unsigned long R; /* Current state for MICKEY */
767 unsigned long M; /* Message accumulator for MICKEY */
773 /* Private / Misc data, counters for driver internal use */
776 u32 SystemResetCnt; /* System reset counter */
777 u32 TxRingFullCnt; /* Tx ring full occurrance number */
778 u32 PhyRxErrCnt; /* PHY Rx error count, for debug purpose, might move to global counter */
779 /* Variables for WEP encryption / decryption in rtmp_wep.c */
781 struct rt_arcfourcontext WEPCONTEXT;
783 struct rt_tkip_key_info Tx;
784 struct rt_tkip_key_info Rx;
787 /***************************************************************************
788 * Channel and BBP related data structures
789 **************************************************************************/
790 /* structure to tune BBP R66 (BBP TUNING) */
791 struct rt_bbp_r66_tuning {
793 u16 FalseCcaLowerThreshold; /* default 100 */
794 u16 FalseCcaUpperThreshold; /* default 512 */
797 BOOLEAN R66LowerUpperSelect; /*Before LinkUp, Used LowerBound or UpperBound as R66 value. */
800 /* structure to store channel TX power */
801 struct rt_channel_tx_power {
802 u16 RemainingTimeForUse; /*unit: sec */
810 /* structure to store 802.11j channel TX power */
811 struct rt_channel_11j_tx_power {
813 u8 BW; /* BW_10 or BW_20 */
816 u16 RemainingTimeForUse; /*unit: sec */
819 struct rt_soft_rx_ant_diversity {
820 u8 EvaluatePeriod; /* 0:not evalute status, 1: evaluate status, 2: switching status */
821 u8 EvaluateStableCnt;
822 u8 Pair1PrimaryRxAnt; /* 0:Ant-E1, 1:Ant-E2 */
823 u8 Pair1SecondaryRxAnt; /* 0:Ant-E1, 1:Ant-E2 */
824 u8 Pair2PrimaryRxAnt; /* 0:Ant-E3, 1:Ant-E4 */
825 u8 Pair2SecondaryRxAnt; /* 0:Ant-E3, 1:Ant-E4 */
826 short Pair1AvgRssi[2]; /* AvgRssi[0]:E1, AvgRssi[1]:E2 */
827 short Pair2AvgRssi[2]; /* AvgRssi[0]:E3, AvgRssi[1]:E4 */
828 short Pair1LastAvgRssi; /* */
829 short Pair2LastAvgRssi; /* */
830 unsigned long RcvPktNumWhenEvaluate;
831 BOOLEAN FirstPktArrivedWhenEvaluate;
832 struct rt_ralink_timer RxAntDiversityTimer;
835 /***************************************************************************
836 * structure for radar detection and channel switch
837 **************************************************************************/
838 struct rt_radar_detect {
839 /*BOOLEAN IEEE80211H; // 0: disable, 1: enable IEEE802.11h */
840 u8 CSCount; /*Channel switch counter */
841 u8 CSPeriod; /*Channel switch period (beacon count) */
842 u8 RDCount; /*Radar detection counter */
843 u8 RDMode; /*Radar Detection mode */
844 u8 RDDurRegion; /*Radar detection duration region */
851 unsigned long InServiceMonitorCount; /* unit: sec */
858 typedef enum _ABGBAND_STATE_ {
865 /* Power save method control */
866 typedef union _PS_CONTROL {
868 unsigned long EnablePSinIdle:1; /* Enable radio off when not connect to AP. radio on only when sitesurvey, */
869 unsigned long EnableNewPS:1; /* Enable new Chip power save fucntion . New method can only be applied in chip version after 2872. and PCIe. */
870 unsigned long rt30xxPowerMode:2; /* Power Level Mode for rt30xx chip */
871 unsigned long rt30xxFollowHostASPM:1; /* Card Follows Host's setting for rt30xx chip. */
872 unsigned long rt30xxForceASPMTest:1; /* Force enable L1 for rt30xx chip. This has higher priority than rt30xxFollowHostASPM Mode. */
873 unsigned long rsv:26; /* Radio Measurement Enable */
876 } PS_CONTROL, *PPS_CONTROL;
877 #endif /* RTMP_MAC_PCI // */
879 /***************************************************************************
880 * structure for MLME state machine
881 **************************************************************************/
883 /* STA state machines */
884 struct rt_state_machine CntlMachine;
885 struct rt_state_machine AssocMachine;
886 struct rt_state_machine AuthMachine;
887 struct rt_state_machine AuthRspMachine;
888 struct rt_state_machine SyncMachine;
889 struct rt_state_machine WpaPskMachine;
890 struct rt_state_machine LeapMachine;
891 STATE_MACHINE_FUNC AssocFunc[ASSOC_FUNC_SIZE];
892 STATE_MACHINE_FUNC AuthFunc[AUTH_FUNC_SIZE];
893 STATE_MACHINE_FUNC AuthRspFunc[AUTH_RSP_FUNC_SIZE];
894 STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE];
895 STATE_MACHINE_FUNC ActFunc[ACT_FUNC_SIZE];
897 struct rt_state_machine ActMachine;
899 /* common WPA state machine */
900 struct rt_state_machine WpaMachine;
901 STATE_MACHINE_FUNC WpaFunc[WPA_FUNC_SIZE];
903 unsigned long ChannelQuality; /* 0..100, Channel Quality Indication for Roaming */
904 unsigned long Now32; /* latch the value of NdisGetSystemUpTime() */
905 unsigned long LastSendNULLpsmTime;
909 struct rt_mlme_queue Queue;
913 struct rt_ralink_timer PeriodicTimer;
914 struct rt_ralink_timer APSDPeriodicTimer;
915 struct rt_ralink_timer LinkDownTimer;
916 struct rt_ralink_timer LinkUpTimer;
918 u8 bPsPollTimerRunning;
919 struct rt_ralink_timer PsPollTimer;
920 struct rt_ralink_timer RadioOnOffTimer;
921 #endif /* RTMP_MAC_PCI // */
922 unsigned long PeriodicRound;
923 unsigned long OneSecPeriodicRound;
926 BOOLEAN bLowThroughput;
927 BOOLEAN bEnableAutoAntennaCheck;
928 struct rt_ralink_timer RxAntEvalTimer;
933 #endif /* RT30xx // */
936 struct rt_ralink_timer AutoWakeupTimer;
937 BOOLEAN AutoWakeupTimerRunning;
938 #endif /* RTMP_MAC_USB // */
941 /***************************************************************************
942 * 802.11 N related data structures
943 **************************************************************************/
944 struct reordering_mpdu {
945 struct reordering_mpdu *next;
946 void *pPacket; /* coverted to 802.3 frame */
947 int Sequence; /* sequence number of MPDU */
951 struct reordering_list {
952 struct reordering_mpdu *next;
956 struct reordering_mpdu_pool {
959 struct reordering_list freelist;
962 typedef enum _REC_BLOCKACK_STATUS {
967 } REC_BLOCKACK_STATUS, *PREC_BLOCKACK_STATUS;
969 typedef enum _ORI_BLOCKACK_STATUS {
974 } ORI_BLOCKACK_STATUS, *PORI_BLOCKACK_STATUS;
976 struct rt_ba_ori_entry {
981 /* Sequence is to fill every outgoing QoS DATA frame's sequence field in 802.11 header. */
984 ORI_BLOCKACK_STATUS ORI_BA_Status;
985 struct rt_ralink_timer ORIBATimer;
989 struct rt_ba_rec_entry {
992 u8 BAWinSize; /* 7.3.1.14. each buffer is capable of holding a max AMSDU or MSDU. */
994 /*u8 Curindidx; // the head in the RX reordering buffer */
996 /* u16 LastIndSeqAtTimer; */
998 struct rt_ralink_timer RECBATimer;
999 unsigned long LastIndSeqAtTimer;
1000 unsigned long nDropPacket;
1001 unsigned long rcvSeq;
1002 REC_BLOCKACK_STATUS REC_BA_Status;
1003 /* u8 RxBufIdxUsed; */
1004 /* corresponding virtual address for RX reordering packet storage. */
1005 /*RTMP_REORDERDMABUF MAP_RXBuf[MAX_RX_REORDERBUF]; */
1006 spinlock_t RxReRingLock; /* Rx Ring spinlock */
1007 /* struct _BA_REC_ENTRY *pNext; */
1009 struct reordering_list list;
1012 struct rt_ba_table {
1013 unsigned long numAsRecipient; /* I am recipient of numAsRecipient clients. These client are in the BARecEntry[] */
1014 unsigned long numAsOriginator; /* I am originator of numAsOriginator clients. These clients are in the BAOriEntry[] */
1015 unsigned long numDoneOriginator; /* count Done Originator sessions */
1016 struct rt_ba_ori_entry BAOriEntry[MAX_LEN_OF_BA_ORI_TABLE];
1017 struct rt_ba_rec_entry BARecEntry[MAX_LEN_OF_BA_REC_TABLE];
1020 /*For QureyBATableOID use; */
1021 struct PACKED rt_oid_ba_rec_entry {
1022 u8 MACAddr[MAC_ADDR_LEN];
1023 u8 BaBitmap; /* if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize */
1026 REC_BLOCKACK_STATUS REC_BA_Status[8];
1029 /*For QureyBATableOID use; */
1030 struct PACKED rt_oid_ba_ori_entry {
1031 u8 MACAddr[MAC_ADDR_LEN];
1032 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 */
1035 ORI_BLOCKACK_STATUS ORI_BA_Status[8];
1038 struct rt_queryba_table {
1039 struct rt_oid_ba_ori_entry BAOriEntry[32];
1040 struct rt_oid_ba_rec_entry BARecEntry[32];
1041 u8 OriNum; /* Number of below BAOriEntry */
1042 u8 RecNum; /* Number of below BARecEntry */
1045 typedef union _BACAP_STRUC {
1049 u32 AutoBA:1; /* automatically BA */
1050 u32 Policy:2; /* 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use */
1052 u32 AmsduEnable:1; /*Enable AMSDU transmisstion */
1053 u32 AmsduSize:1; /* 0:3839, 1:7935 bytes. u32 MSDUSizeToBytes[] = { 3839, 7935}; */
1054 u32 MMPSmode:2; /* MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable */
1055 u32 bHtAdhoc:1; /* adhoc can use ht rate. */
1056 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. */
1060 } BACAP_STRUC, *PBACAP_STRUC;
1062 struct rt_oid_add_ba_entry {
1063 BOOLEAN IsRecipient;
1064 u8 MACAddr[MAC_ADDR_LEN];
1068 BOOLEAN bAllTid; /* If True, delete all TID for BA sessions with this MACaddr. */
1071 #define IS_HT_STA(_pMacEntry) \
1072 (_pMacEntry->MaxHTPhyMode.field.MODE >= MODE_HTMIX)
1074 #define IS_HT_RATE(_pMacEntry) \
1075 (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
1077 #define PEER_IS_HT_RATE(_pMacEntry) \
1078 (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
1080 /*This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second. (Details see MLMEPeriodic) */
1083 u8 ReorderTimeOutNum[MAX_LEN_OF_BA_REC_TABLE]; /* compare with threshold[0] */
1084 u8 RefreshNum[MAX_LEN_OF_BA_REC_TABLE]; /* compare with threshold[1] */
1085 unsigned long OneSecInWindowCount;
1086 unsigned long OneSecFrameDuplicateCount;
1087 unsigned long OneSecOutWindowCount;
1092 BOOLEAN bRTSLongProtOn;
1093 BOOLEAN bLastAtheros;
1094 BOOLEAN bCurrentAtheros;
1095 BOOLEAN bNowAtherosBurstOn;
1096 BOOLEAN bNextDisableRxBA;
1100 /* This is the registry setting for 802.11n transmit setting. Used in advanced page. */
1101 typedef union _REG_TRANSMIT_SETTING {
1104 /*u32 MCS:7; // MCS */
1107 u32 BW:1; /*channel bandwidth 20MHz or 40 MHz */
1109 u32 STBC:1; /*SPACE */
1116 } REG_TRANSMIT_SETTING, *PREG_TRANSMIT_SETTING;
1118 typedef union _DESIRED_TRANSMIT_SETTING {
1120 u16 MCS:7; /* MCS */
1122 u16 FixedTxMode:2; /* If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode. */
1126 } DESIRED_TRANSMIT_SETTING, *PDESIRED_TRANSMIT_SETTING;
1129 /***************************************************************************
1130 * USB-based chip Beacon related data structures
1131 **************************************************************************/
1132 #define BEACON_BITMAP_MASK 0xff
1133 struct rt_beacon_sync {
1134 u8 BeaconBuf[HW_BEACON_MAX_COUNT][HW_BEACON_OFFSET];
1135 u8 BeaconTxWI[HW_BEACON_MAX_COUNT][TXWI_SIZE];
1136 unsigned long TimIELocationInBeacon[HW_BEACON_MAX_COUNT];
1137 unsigned long CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT];
1138 BOOLEAN EnableBeacon; /* trigger to enable beacon transmission. */
1139 u8 BeaconBitMap; /* NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change. */
1140 u8 DtimBitOn; /* NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change. */
1142 #endif /* RTMP_MAC_USB // */
1144 /***************************************************************************
1145 * Multiple SSID related data structures
1146 **************************************************************************/
1147 #define WLAN_MAX_NUM_OF_TIM ((MAX_LEN_OF_MAC_TABLE >> 3) + 1) /* /8 + 1 */
1148 #define WLAN_CT_TIM_BCMC_OFFSET 0 /* unit: 32B */
1150 /* clear bcmc TIM bit */
1151 #define WLAN_MR_TIM_BCMC_CLEAR(apidx) \
1152 pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] &= ~BIT8[0];
1154 /* set bcmc TIM bit */
1155 #define WLAN_MR_TIM_BCMC_SET(apidx) \
1156 pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] |= BIT8[0];
1158 /* clear a station PS TIM bit */
1159 #define WLAN_MR_TIM_BIT_CLEAR(ad_p, apidx, wcid) \
1160 { u8 tim_offset = wcid >> 3; \
1161 u8 bit_offset = wcid & 0x7; \
1162 ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] &= (~BIT8[bit_offset]); }
1164 /* set a station PS TIM bit */
1165 #define WLAN_MR_TIM_BIT_SET(ad_p, apidx, wcid) \
1166 { u8 tim_offset = wcid >> 3; \
1167 u8 bit_offset = wcid & 0x7; \
1168 ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; }
1170 /* configuration common to OPMODE_AP as well as OPMODE_STA */
1171 struct rt_common_config {
1173 BOOLEAN bCountryFlag;
1176 u8 CountryRegion; /* Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel */
1177 u8 CountryRegionForABand; /* Enum of country region for A band */
1178 u8 PhyMode; /* PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED */
1179 u16 Dsifs; /* in units of usec */
1180 unsigned long PacketFilter; /* Packet filter for receiving */
1183 char Ssid[MAX_LEN_OF_SSID]; /* NOT NULL-terminated */
1184 u8 SsidLen; /* the actual ssid length in used */
1185 u8 LastSsidLen; /* the actual ssid length in used */
1186 char LastSsid[MAX_LEN_OF_SSID]; /* NOT NULL-terminated */
1187 u8 LastBssid[MAC_ADDR_LEN];
1189 u8 Bssid[MAC_ADDR_LEN];
1192 u8 CentralChannel; /* Central Channel when using 40MHz is indicating. not real channel. */
1194 u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES];
1196 u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
1198 u8 DesireRate[MAX_LEN_OF_SUPPORTED_RATES]; /* OID_802_11_DESIRED_RATES */
1200 u8 ExpectedACKRate[MAX_LEN_OF_SUPPORTED_RATES];
1202 unsigned long BasicRateBitmap; /* backup basic ratebitmap */
1204 BOOLEAN bAPSDCapable;
1205 BOOLEAN bInServicePeriod;
1211 /* because TSPEC can modify the APSD flag, we need to keep the APSD flag
1212 requested in association stage from the station;
1213 we need to recover the APSD flag after the TSPEC is deleted. */
1214 BOOLEAN bACMAPSDBackup[4]; /* for delivery-enabled & trigger-enabled both */
1215 BOOLEAN bACMAPSDTr[4]; /* no use */
1217 BOOLEAN bNeedSendTriggerFrame;
1218 BOOLEAN bAPSDForcePowerSave; /* Force power save mode, should only use in APSD-STAUT */
1219 unsigned long TriggerTimerCount;
1221 u8 BBPCurrentBW; /* BW_10, BW_20, BW_40 */
1222 /* move to MULTISSID_STRUCT for MBSS */
1223 /*HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI. */
1224 REG_TRANSMIT_SETTING RegTransmitSetting; /*registry transmit setting. this is for reading registry setting only. not useful. */
1225 /*u8 FixedTxMode; // Fixed Tx Mode (CCK, OFDM), for HT fixed tx mode (GF, MIX) , refer to RegTransmitSetting.field.HTMode */
1226 u8 TxRate; /* Same value to fill in TXD. TxRate is 6-bit */
1227 u8 MaxTxRate; /* RATE_1, RATE_2, RATE_5_5, RATE_11 */
1228 u8 TxRateIndex; /* Tx rate index in RateSwitchTable */
1229 u8 TxRateTableSize; /* Valid Tx rate table size in RateSwitchTable */
1230 /*BOOLEAN bAutoTxRateSwitch; */
1231 u8 MinTxRate; /* RATE_1, RATE_2, RATE_5_5, RATE_11 */
1232 u8 RtsRate; /* RATE_xxx */
1233 HTTRANSMIT_SETTING MlmeTransmit; /* MGMT frame PHY rate setting when operatin at Ht rate. */
1234 u8 MlmeRate; /* RATE_xxx, used to send MLME frames */
1235 u8 BasicMlmeRate; /* Default Rate for sending MLME frames */
1237 u16 RtsThreshold; /* in unit of BYTE */
1238 u16 FragmentThreshold; /* in unit of BYTE */
1240 u8 TxPower; /* in unit of mW */
1241 unsigned long TxPowerPercentage; /* 0~100 % */
1242 unsigned long TxPowerDefault; /* keep for TxPowerPercentage */
1245 BACAP_STRUC BACapability; /* NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0 */
1246 BACAP_STRUC REGBACapability; /* NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0 */
1248 struct rt_iot IOTestParm; /* 802.11n InterOpbility Test Parameter; */
1249 unsigned long TxPreamble; /* Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto */
1250 BOOLEAN bUseZeroToDisableFragment; /* Microsoft use 0 as disable */
1251 unsigned long UseBGProtection; /* 0: auto, 1: always use, 2: always not use */
1252 BOOLEAN bUseShortSlotTime; /* 0: disable, 1 - use short slot (9us) */
1253 BOOLEAN bEnableTxBurst; /* 1: enble TX PACKET BURST (when BA is established or AP is not a legacy WMM AP), 0: disable TX PACKET BURST */
1254 BOOLEAN bAggregationCapable; /* 1: enable TX aggregation when the peer supports it */
1255 BOOLEAN bPiggyBackCapable; /* 1: enable TX piggy-back according MAC's version */
1256 BOOLEAN bIEEE80211H; /* 1: enable IEEE802.11h spec. */
1257 unsigned long DisableOLBCDetect; /* 0: enable OLBC detect; 1 disable OLBC detect */
1261 BOOLEAN bWmmCapable; /* 0:disable WMM, 1:enable WMM */
1262 struct rt_qos_capability_parm APQosCapability; /* QOS capability of the current associated AP */
1263 struct rt_edca_parm APEdcaParm; /* EDCA parameters of the current associated AP */
1264 struct rt_qbss_load_parm APQbssLoad; /* QBSS load of the current associated AP */
1265 u8 AckPolicy[4]; /* ACK policy of the specified AC. see ACK_xxx */
1266 BOOLEAN bDLSCapable; /* 0:disable DLS, 1:enable DLS */
1267 /* a bitmap of BOOLEAN flags. each bit represent an operation status of a particular */
1268 /* BOOLEAN control, either ON or OFF. These flags should always be accessed via */
1269 /* OPSTATUS_TEST_FLAG(), OPSTATUS_SET_FLAG(), OP_STATUS_CLEAR_FLAG() macros. */
1270 /* see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition */
1271 unsigned long OpStatusFlags;
1273 BOOLEAN NdisRadioStateOff; /*For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff. */
1274 ABGBAND_STATE BandState; /* For setting BBP used on B/G or A mode. */
1276 /* IEEE802.11H--DFS. */
1277 struct rt_radar_detect RadarDetect;
1280 u8 BASize; /* USer desired BAWindowSize. Should not exceed our max capability */
1281 /*struct rt_ht_capability SupportedHtPhy; */
1282 struct rt_ht_capability DesiredHtPhy;
1283 struct rt_ht_capability_ie HtCapability;
1284 struct rt_add_ht_info_ie AddHTInfo; /* Useful as AP. */
1285 /*This IE is used with channel switch announcement element when changing to a new 40MHz. */
1286 /*This IE is included in channel switch ammouncement frames 7.4.1.5, beacons, probe Rsp. */
1287 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 */
1290 BOOLEAN bMIMOPSEnable;
1292 /*2008/11/05: KH add to support Antenna power-saving of AP<-- */
1293 BOOLEAN bGreenAPEnable;
1294 /*2008/11/05: KH add to support Antenna power-saving of AP--> */
1295 BOOLEAN bDisableReordering;
1296 BOOLEAN bForty_Mhz_Intolerant;
1297 BOOLEAN bExtChannelSwitchAnnouncement;
1298 BOOLEAN bRcvBSSWidthTriggerEvents;
1299 unsigned long LastRcvBSSWidthTriggerEventsTime;
1303 /* Enable wireless event */
1304 BOOLEAN bWirelessEvent;
1305 BOOLEAN bWiFiTest; /* Enable this parameter for WiFi test */
1307 /* Tx & Rx Stream number selection */
1311 BOOLEAN bHardwareRadio; /* Hardware controlled Radio enabled */
1314 BOOLEAN bMultipleIRP; /* Multiple Bulk IN flag */
1315 u8 NumOfBulkInIRP; /* if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1 */
1316 struct rt_ht_capability SupportedHtPhy;
1317 unsigned long MaxPktOneTxBulk;
1321 BOOLEAN IsUpdateBeacon;
1322 struct rt_beacon_sync *pBeaconSync;
1323 struct rt_ralink_timer BeaconUpdateTimer;
1327 #endif /* RTMP_MAC_USB // */
1329 spinlock_t MeasureReqTabLock;
1330 struct rt_measure_req_tab *pMeasureReqTab;
1332 spinlock_t TpcReqTabLock;
1333 struct rt_tpc_req_tab *pTpcReqTab;
1335 BOOLEAN PSPXlink; /* 0: Disable. 1: Enable */
1337 #if defined(RT305x)||defined(RT30xx)
1338 /* request by Gary, for High Power issue */
1339 u8 HighPowerPatchDisabled;
1342 BOOLEAN HT_DisallowTKIP; /* Restrict the encryption type in 11n HT mode */
1345 /* Modified by Wu Xi-Kun 4/21/2006 */
1346 /* STA configuration and status */
1347 struct rt_sta_admin_config {
1349 /* User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe */
1350 /* the user intended configuration, but not necessary fully equal to the final */
1351 /* settings in ACTIVE BSS after negotiation/compromize with the BSS holder (either */
1352 /* AP or IBSS holder). */
1353 /* Once initialized, user configuration can only be changed via OID_xxx */
1354 u8 BssType; /* BSS_INFRA or BSS_ADHOC */
1355 u16 AtimWin; /* used when starting a new IBSS */
1358 /* User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe */
1359 /* the user intended configuration, and should be always applied to the final */
1360 /* settings in ACTIVE BSS without compromising with the BSS holder. */
1361 /* Once initialized, user configuration can only be changed via OID_xxx */
1363 u8 RssiTriggerMode; /* RSSI_TRIGGERED_UPON_BELOW_THRESHOLD or RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD */
1364 u16 DefaultListenCount; /* default listen count; */
1365 unsigned long WindowsPowerMode; /* Power mode for AC power */
1366 unsigned long WindowsBatteryPowerMode; /* Power mode for battery if exists */
1367 BOOLEAN bWindowsACCAMEnable; /* Enable CAM power mode when AC on */
1368 BOOLEAN bAutoReconnect; /* Set to TRUE when setting OID_802_11_SSID with no matching BSSID */
1369 unsigned long WindowsPowerProfile; /* Windows power profile, for NDIS5.1 PnP */
1371 /* MIB:ieee802dot11.dot11smt(1).dot11StationConfigTable(1) */
1372 u16 Psm; /* power management mode (PWR_ACTIVE|PWR_SAVE) */
1374 u8 DisassocSta[MAC_ADDR_LEN];
1376 u8 DeauthSta[MAC_ADDR_LEN];
1378 u8 AuthFailSta[MAC_ADDR_LEN];
1380 NDIS_802_11_PRIVACY_FILTER PrivacyFilter; /* PrivacyFilter enum for 802.1X */
1381 NDIS_802_11_AUTHENTICATION_MODE AuthMode; /* This should match to whatever microsoft defined */
1382 NDIS_802_11_WEP_STATUS WepStatus;
1383 NDIS_802_11_WEP_STATUS OrigWepStatus; /* Original wep status set from OID */
1385 /* Add to support different cipher suite for WPA2/WPA mode */
1386 NDIS_802_11_ENCRYPTION_STATUS GroupCipher; /* Multicast cipher suite */
1387 NDIS_802_11_ENCRYPTION_STATUS PairCipher; /* Unicast cipher suite */
1388 BOOLEAN bMixCipher; /* Indicate current Pair & Group use different cipher suites */
1391 NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
1393 u8 WpaPassPhrase[64]; /* WPA PSK pass phrase */
1394 u32 WpaPassPhraseLen; /* the length of WPA PSK pass phrase */
1395 u8 PMK[32]; /* WPA PSK mode PMK */
1396 u8 PTK[64]; /* WPA PSK mode PTK */
1397 u8 GTK[32]; /* GTK from authenticator */
1398 struct rt_bssid_info SavedPMK[PMKID_NO];
1399 u32 SavedPMKNum; /* Saved PMKID number */
1403 /* WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED */
1406 /* For WPA countermeasures */
1407 unsigned long LastMicErrorTime; /* record last MIC error time */
1408 unsigned long MicErrCnt; /* Should be 0, 1, 2, then reset to zero (after disassoiciation). */
1409 BOOLEAN bBlockAssoc; /* Block associate attempt for 60 seconds after counter measure occurred. */
1410 /* For WPA-PSK supplicant state */
1411 WPA_STATE WpaState; /* Default is SS_NOTUSE and handled by microsoft 802.1x */
1412 u8 ReplayCounter[8];
1413 u8 ANonce[32]; /* ANonce for WPA-PSK from aurhenticator */
1414 u8 SNonce[32]; /* SNonce for WPA-PSK */
1416 u8 LastSNR0; /* last received BEACON's SNR */
1417 u8 LastSNR1; /* last received BEACON's SNR for 2nd antenna */
1418 struct rt_rssi_sample RssiSample;
1419 unsigned long NumOfAvgRssiSample;
1421 unsigned long LastBeaconRxTime; /* OS's timestamp of the last BEACON RX time */
1422 unsigned long Last11bBeaconRxTime; /* OS's timestamp of the last 11B BEACON RX time */
1423 unsigned long Last11gBeaconRxTime; /* OS's timestamp of the last 11G BEACON RX time */
1424 unsigned long Last20NBeaconRxTime; /* OS's timestamp of the last 20MHz N BEACON RX time */
1426 unsigned long LastScanTime; /* Record last scan time for issue BSSID_SCAN_LIST */
1427 unsigned long ScanCnt; /* Scan counts since most recent SSID, BSSID, SCAN OID request */
1428 BOOLEAN bSwRadio; /* Software controlled Radio On/Off, TRUE: On */
1429 BOOLEAN bHwRadio; /* Hardware controlled Radio On/Off, TRUE: On */
1430 BOOLEAN bRadio; /* Radio state, And of Sw & Hw radio state */
1431 BOOLEAN bHardwareRadio; /* Hardware controlled Radio enabled */
1432 BOOLEAN bShowHiddenSSID; /* Show all known SSID in SSID list get operation */
1434 /* New for WPA, windows want us to keep association information and */
1435 /* Fixed IEs from last association response */
1436 struct rt_ndis_802_11_association_information AssocInfo;
1437 u16 ReqVarIELen; /* Length of next VIE include EID & Length */
1438 u8 ReqVarIEs[MAX_VIE_LEN]; /* The content saved here should be little-endian format. */
1439 u16 ResVarIELen; /* Length of next VIE include EID & Length */
1440 u8 ResVarIEs[MAX_VIE_LEN];
1443 u8 RSN_IE[MAX_LEN_OF_RSNIE]; /* The content saved here should be little-endian format. */
1445 unsigned long CLBusyBytes; /* Save the total bytes received durning channel load scan time */
1446 u16 RPIDensity[8]; /* Array for RPI density collection */
1448 u8 RMReqCnt; /* Number of measurement request saved. */
1449 u8 CurrentRMReqIdx; /* Number of measurement request saved. */
1450 BOOLEAN ParallelReq; /* Parallel measurement, only one request performed, */
1451 /* It must be the same channel with maximum duration */
1452 u16 ParallelDuration; /* Maximum duration for parallel measurement */
1453 u8 ParallelChannel; /* Only one channel with parallel measurement */
1454 u16 IAPPToken; /* IAPP dialog token */
1455 /* Hack for channel load and noise histogram parameters */
1456 u8 NHFactor; /* Parameter for Noise histogram */
1457 u8 CLFactor; /* Parameter for channel load */
1459 struct rt_ralink_timer StaQuickResponeForRateUpTimer;
1460 BOOLEAN StaQuickResponeForRateUpTimerRunning;
1462 u8 DtimCount; /* 0.. DtimPeriod-1 */
1463 u8 DtimPeriod; /* default = 3 */
1465 /*////////////////////////////////////////////////////////////////////////////////////// */
1466 /* This is only for WHQL test. */
1468 /*////////////////////////////////////////////////////////////////////////////////////// */
1470 struct rt_ralink_timer WpaDisassocAndBlockAssocTimer;
1472 BOOLEAN bAutoRoaming; /* 0:disable auto roaming by RSSI, 1:enable auto roaming by RSSI */
1473 char dBmToRoam; /* the condition to roam when receiving Rssi less than this value. It's negative value. */
1476 BOOLEAN IEEE8021x_required_keys;
1477 struct rt_cipher_key DesireSharedKey[4]; /* Record user desired WEP keys */
1478 u8 DesireSharedKeyId;
1480 /* 0: driver ignores wpa_supplicant */
1481 /* 1: wpa_supplicant initiates scanning and AP selection */
1482 /* 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters */
1484 u8 WpaSupplicantScanCount;
1485 BOOLEAN bRSN_IE_FromWpaSupplicant;
1490 BOOLEAN bTGnWifiTest;
1491 BOOLEAN bScanReqIsFromWebUI;
1493 HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode; /* For transmit phy setting in TXWI. */
1494 DESIRED_TRANSMIT_SETTING DesiredTransmitSetting;
1495 struct rt_ht_phy_info DesiredHtPhyInfo;
1496 BOOLEAN bAutoTxRateSwitch;
1500 /* PS Control has 2 meanings for advanced power save function. */
1501 /* 1. EnablePSinIdle : When no connection, always radio off except need to do site survey. */
1502 /* 2. EnableNewPS : will save more current in sleep or radio off mode. */
1503 PS_CONTROL PSControl;
1504 #endif /* RTMP_MAC_PCI // */
1506 BOOLEAN bAutoConnectByBssid;
1507 unsigned long BeaconLostTime; /* seconds */
1508 BOOLEAN bForceTxBurst; /* 1: force enble TX PACKET BURST, 0: disable */
1511 /* This data structure keep the current active BSS/IBSS's configuration that this STA */
1512 /* had agreed upon joining the network. Which means these parameters are usually decided */
1513 /* by the BSS/IBSS creator instead of user configuration. Data in this data structurre */
1514 /* is valid only when either ADHOC_ON(pAd) or INFRA_ON(pAd) is TRUE. */
1515 /* Normally, after SCAN or failed roaming attempts, we need to recover back to */
1516 /* the current active settings. */
1517 struct rt_sta_active_config {
1519 u16 AtimWin; /* in kusec; IBSS parameter set element */
1524 /* Copy supported rate from desired AP's beacon. We are trying to match */
1525 /* AP's supported and extended rate settings. */
1526 u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES];
1527 u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
1530 /* Copy supported ht from desired AP's beacon. We are trying to match */
1531 struct rt_ht_phy_info SupportedPhyInfo;
1532 struct rt_ht_capability SupportedHtPhy;
1535 struct rt_mac_table_entry;
1537 struct rt_mac_table_entry {
1538 /*Choose 1 from ValidAsWDS and ValidAsCLI to validize. */
1539 BOOLEAN ValidAsCLI; /* Sta mode, set this TRUE after Linkup,too. */
1540 BOOLEAN ValidAsWDS; /* This is WDS Entry. only for AP mode. */
1541 BOOLEAN ValidAsApCli; /*This is a AP-Client entry, only for AP mode which enable AP-Client functions. */
1542 BOOLEAN ValidAsMesh;
1543 BOOLEAN ValidAsDls; /* This is DLS Entry. only for STA mode. */
1545 BOOLEAN bIAmBadAtheros; /* Flag if this is Atheros chip that has IOT problem. We need to turn on RTS/CTS protection. */
1547 u8 EnqueueEapolStartTimerRunning; /* Enqueue EAPoL-Start for triggering EAP SM */
1549 /* record which entry revoke MIC Failure , if it leaves the BSS itself, AP won't update aMICFailTime MIB */
1551 u8 apidx; /* MBSS number */
1553 u8 RSN_IE[MAX_LEN_OF_RSNIE];
1554 u8 ANonce[LEN_KEY_DESC_NONCE];
1555 u8 SNonce[LEN_KEY_DESC_NONCE];
1556 u8 R_Counter[LEN_KEY_DESC_REPLAY];
1559 struct rt_ralink_timer RetryTimer;
1560 struct rt_ralink_timer EnqueueStartForPSKTimer; /* A timer which enqueue EAPoL-Start for triggering PSK SM */
1561 NDIS_802_11_AUTHENTICATION_MODE AuthMode; /* This should match to whatever microsoft defined */
1562 NDIS_802_11_WEP_STATUS WepStatus;
1563 NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
1564 AP_WPA_STATE WpaState;
1567 NDIS_802_11_PRIVACY_FILTER PrivacyFilter; /* PrivacyFilter enum for 802.1X */
1568 struct rt_cipher_key PairwiseKey;
1571 u8 PMKID[LEN_PMKID];
1573 u8 Addr[MAC_ADDR_LEN];
1576 AUTH_STATE AuthState; /* for SHARED KEY authentication state machine used only */
1577 BOOLEAN IsReassocSta; /* Indicate whether this is a reassociation procedure */
1581 unsigned long NoDataIdleCount;
1582 u16 StationKeepAliveCount; /* unit: second */
1583 unsigned long PsQIdleCount;
1584 struct rt_queue_header PsQueue;
1586 u32 StaConnectTime; /* the live time of this station since associated with AP */
1589 u16 NoBADataCountDown;
1591 u32 CachedBuf[16]; /* u32 (4 bytes) for alignment */
1592 u32 TxBFCount; /* 3*3 */
1598 /*==================================================== */
1599 /*WDS entry needs these */
1600 /* if ValidAsWDS==TRUE, MatchWDSTabIdx is the index in WdsTab.MacTab */
1602 u8 MaxSupportedRate;
1605 /* to record the each TX rate's quality. 0 is best, the bigger the worse. */
1606 u16 TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
1607 /* u16 OneSecTxOkCount; */
1608 u32 OneSecTxNoRetryOkCount;
1609 u32 OneSecTxRetryOkCount;
1610 u32 OneSecTxFailCount;
1611 u32 ContinueTxFailCnt;
1612 u32 CurrTxRateStableTime; /* # of second in current TX rate */
1613 u8 TxRateUpPenalty; /* extra # of second penalty due to last unstable condition */
1614 /*==================================================== */
1616 BOOLEAN fNoisyEnvironment;
1617 BOOLEAN fLastSecAccordingRSSI;
1618 u8 LastSecTxRateChangeAction; /* 0: no change, 1:rate UP, 2:rate down */
1619 char LastTimeTxRateChangeAction; /*Keep last time value of LastSecTxRateChangeAction */
1620 unsigned long LastTxOkCount;
1621 u8 PER[MAX_STEP_OF_TX_RATE_SWITCH];
1623 /* a bitmap of BOOLEAN flags. each bit represent an operation status of a particular */
1624 /* BOOLEAN control, either ON or OFF. These flags should always be accessed via */
1625 /* CLIENT_STATUS_TEST_FLAG(), CLIENT_STATUS_SET_FLAG(), CLIENT_STATUS_CLEAR_FLAG() macros. */
1626 /* see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED */
1627 unsigned long ClientStatusFlags;
1629 HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode; /* For transmit phy setting in TXWI. */
1631 /* HT EWC MIMO-N used parameters */
1632 u16 RXBAbitmap; /* fill to on-chip RXWI_BA_BITMASK in 8.1.3RX attribute entry format */
1633 u16 TXBAbitmap; /* This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI */
1635 u16 BADeclineBitmap;
1636 u16 BARecWcidArray[NUM_OF_TID]; /* The mapping wcid of recipient session. if RXBAbitmap bit is masked */
1637 u16 BAOriWcidArray[NUM_OF_TID]; /* The mapping wcid of originator session. if TXBAbitmap bit is masked */
1638 u16 BAOriSequence[NUM_OF_TID]; /* The mapping wcid of originator session. if TXBAbitmap bit is masked */
1640 /* 802.11n features. */
1644 u8 MmpsMode; /* MIMO power save more. */
1646 struct rt_ht_capability_ie HTCapability;
1648 BOOLEAN bAutoTxRateSwitch;
1651 struct rt_mac_table_entry *pNext;
1652 u16 TxSeq[NUM_OF_TID];
1655 struct rt_rssi_sample RssiSample;
1657 u32 TXMCSExpected[16];
1658 u32 TXMCSSuccessful[16];
1659 u32 TXMCSFailed[16];
1660 u32 TXMCSAutoFallBack[16][16];
1662 unsigned long LastBeaconRxTime;
1664 unsigned long AssocDeadLine;
1667 struct rt_mac_table {
1669 struct rt_mac_table_entry *Hash[HASH_TABLE_SIZE];
1670 struct rt_mac_table_entry Content[MAX_LEN_OF_MAC_TABLE];
1671 struct rt_queue_header McastPsQueue;
1672 unsigned long PsQIdleCount;
1673 BOOLEAN fAnyStationInPsm;
1674 BOOLEAN fAnyStationBadAtheros; /* Check if any Station is atheros 802.11n Chip. We need to use RTS/CTS with Atheros 802,.11n chip. */
1675 BOOLEAN fAnyTxOPForceDisable; /* Check if it is necessary to disable BE TxOP */
1676 BOOLEAN fAllStationAsRalink; /* Check if all stations are ralink-chipset */
1677 BOOLEAN fAnyStationIsLegacy; /* Check if I use legacy rate to transmit to my BSS Station/ */
1678 BOOLEAN fAnyStationNonGF; /* Check if any Station can't support GF. */
1679 BOOLEAN fAnyStation20Only; /* Check if any Station can't support GF. */
1680 BOOLEAN fAnyStationMIMOPSDynamic; /* Check if any Station is MIMO Dynamic */
1681 BOOLEAN fAnyBASession; /* Check if there is BA session. Force turn on RTS/CTS */
1682 /*2008/10/28: KH add to support Antenna power-saving of AP<-- */
1683 /*2008/10/28: KH add to support Antenna power-saving of AP--> */
1688 BOOLEAN bGreenField;
1691 struct rt_rtmp_dev_info {
1693 RTMP_INF_TYPE infType;
1696 struct rt_rtmp_chip_op {
1697 /* Calibration access related callback functions */
1698 int (*eeinit) (struct rt_rtmp_adapter *pAd); /* int (*eeinit)(struct rt_rtmp_adapter *pAd); */
1699 int (*eeread) (struct rt_rtmp_adapter *pAd, u16 offset, u16 *pValue); /* int (*eeread)(struct rt_rtmp_adapter *pAd, int offset, u16 *pValue); */
1701 /* MCU related callback functions */
1702 int (*loadFirmware) (struct rt_rtmp_adapter *pAd); /* int (*loadFirmware)(struct rt_rtmp_adapter *pAd); */
1703 int (*eraseFirmware) (struct rt_rtmp_adapter *pAd); /* int (*eraseFirmware)(struct rt_rtmp_adapter *pAd); */
1704 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); */
1706 /* RF access related callback functions */
1707 struct rt_reg_pair *pRFRegTable;
1708 void (*AsicRfInit) (struct rt_rtmp_adapter *pAd);
1709 void (*AsicRfTurnOn) (struct rt_rtmp_adapter *pAd);
1710 void (*AsicRfTurnOff) (struct rt_rtmp_adapter *pAd);
1711 void (*AsicReverseRfFromSleepMode) (struct rt_rtmp_adapter *pAd);
1712 void (*AsicHaltAction) (struct rt_rtmp_adapter *pAd);
1716 /* The miniport adapter structure */
1718 struct rt_rtmp_adapter {
1719 void *OS_Cookie; /* save specific structure relative to OS */
1720 struct net_device *net_dev;
1721 unsigned long VirtualIfCnt;
1722 const struct firmware *firmware;
1724 struct rt_rtmp_chip_op chipOps;
1725 u16 ThisTbttNumToNextWakeUp;
1728 /*****************************************************************************************/
1729 /* PCI related parameters */
1730 /*****************************************************************************************/
1731 u8 *CSRBaseAddress; /* PCI MMIO Base Address, all access will use */
1732 unsigned int irq_num;
1735 u16 RLnkCtrlConfiguration;
1737 u16 HostLnkCtrlConfiguration;
1738 u16 HostLnkCtrlOffset;
1739 u16 PCIePowerSaveLevel;
1740 unsigned long Rt3xxHostLinkCtrl; /* USed for 3090F chip */
1741 unsigned long Rt3xxRalinkLinkCtrl; /* USed for 3090F chip */
1742 u16 DeviceID; /* Read from PCI config */
1743 unsigned long AccessBBPFailCount;
1744 BOOLEAN bPCIclkOff; /* flag that indicate if the PICE power status in Configuration SPace.. */
1745 BOOLEAN bPCIclkOffDisableTx; /* */
1747 BOOLEAN brt30xxBanMcuCmd; /*when = 0xff means all commands are ok to set . */
1748 BOOLEAN b3090ESpecialChip; /*3090E special chip that write EEPROM 0x24=0x9280. */
1749 unsigned long CheckDmaBusyCount; /* Check Interrupt Status Register Count. */
1752 u32 int_disable_mask;
1755 struct rt_rtmp_dmabuf TxBufSpace[NUM_OF_TX_RING]; /* Shared memory of all 1st pre-allocated TxBuf associated with each TXD */
1756 struct rt_rtmp_dmabuf RxDescRing; /* Shared memory for RX descriptors */
1757 struct rt_rtmp_dmabuf TxDescRing[NUM_OF_TX_RING]; /* Shared memory for Tx descriptors */
1758 struct rt_rtmp_tx_ring TxRing[NUM_OF_TX_RING]; /* AC0~4 + HCCA */
1759 #endif /* RTMP_MAC_PCI // */
1761 spinlock_t irq_lock;
1765 /*****************************************************************************************/
1766 /* USB related parameters */
1767 /*****************************************************************************************/
1768 struct usb_config_descriptor *config;
1769 u32 BulkInEpAddr; /* bulk-in endpoint address */
1770 u32 BulkOutEpAddr[6]; /* bulk-out endpoint address */
1773 u16 BulkOutMaxPacketSize;
1774 u16 BulkInMaxPacketSize;
1776 /*======Control Flags */
1777 long PendingIoCount;
1778 unsigned long BulkFlags;
1779 BOOLEAN bUsbTxBulkAggre; /* Flags for bulk out data priority */
1781 /*======Cmd Thread */
1782 struct rt_cmdq CmdQ;
1783 spinlock_t CmdQLock; /* CmdQLock spinlock */
1784 struct rt_rtmp_os_task cmdQTask;
1786 /*======Semaphores (event) */
1787 struct semaphore UsbVendorReq_semaphore;
1788 void *UsbVendorReqBuf;
1789 wait_queue_head_t *wait;
1790 #endif /* RTMP_MAC_USB // */
1792 /*****************************************************************************************/
1793 /* RBUS related parameters */
1794 /*****************************************************************************************/
1796 /*****************************************************************************************/
1797 /* Both PCI/USB related parameters */
1798 /*****************************************************************************************/
1799 /*struct rt_rtmp_dev_info chipInfo; */
1800 RTMP_INF_TYPE infType;
1802 /*****************************************************************************************/
1803 /* Driver Mgmt related parameters */
1804 /*****************************************************************************************/
1805 struct rt_rtmp_os_task mlmeTask;
1806 #ifdef RTMP_TIMER_TASK_SUPPORT
1807 /* If you want use timer task to handle the timer related jobs, enable this. */
1808 struct rt_rtmp_timer_task_queue TimerQ;
1809 spinlock_t TimerQLock;
1810 struct rt_rtmp_os_task timerTask;
1811 #endif /* RTMP_TIMER_TASK_SUPPORT // */
1813 /*****************************************************************************************/
1814 /* Tx related parameters */
1815 /*****************************************************************************************/
1816 BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; /* for ensuring RTUSBDeQueuePacket get call once */
1817 spinlock_t DeQueueLock[NUM_OF_TX_RING];
1820 /* Data related context and AC specified, 4 AC supported */
1821 spinlock_t BulkOutLock[6]; /* BulkOut spinlock for 4 ACs */
1822 spinlock_t MLMEBulkOutLock; /* MLME BulkOut lock */
1824 struct rt_ht_tx_context TxContext[NUM_OF_TX_RING];
1825 spinlock_t TxContextQueueLock[NUM_OF_TX_RING]; /* TxContextQueue spinlock */
1827 /* 4 sets of Bulk Out index and pending flag */
1828 u8 NextBulkOutIndex[4]; /* only used for 4 EDCA bulkout pipe */
1830 BOOLEAN BulkOutPending[6]; /* used for total 6 bulkout pipe */
1832 BOOLEAN MgmtBulkPending;
1833 unsigned long bulkResetReq[6];
1834 #endif /* RTMP_MAC_USB // */
1836 /* resource for software backlog queues */
1837 struct rt_queue_header TxSwQueue[NUM_OF_TX_RING]; /* 4 AC + 1 HCCA */
1838 spinlock_t TxSwQueueLock[NUM_OF_TX_RING]; /* TxSwQueue spinlock */
1840 struct rt_rtmp_dmabuf MgmtDescRing; /* Shared memory for MGMT descriptors */
1841 struct rt_rtmp_mgmt_ring MgmtRing;
1842 spinlock_t MgmtRingLock; /* Prio Ring spinlock */
1844 /*****************************************************************************************/
1845 /* Rx related parameters */
1846 /*****************************************************************************************/
1849 struct rt_rtmp_rx_ring RxRing;
1850 spinlock_t RxRingLock; /* Rx Ring spinlock */
1852 spinlock_t McuCmdLock; /*MCU Command Queue spinlock */
1853 #endif /* RT3090 // */
1854 #endif /* RTMP_MAC_PCI // */
1856 struct rt_rx_context RxContext[RX_RING_SIZE]; /* 1 for redundant multiple IRP bulk in. */
1857 spinlock_t BulkInLock; /* BulkIn spinlock for 4 ACs */
1858 u8 PendingRx; /* The Maximum pending Rx value should be RX_RING_SIZE. */
1859 u8 NextRxBulkInIndex; /* Indicate the current RxContext Index which hold by Host controller. */
1860 u8 NextRxBulkInReadIndex; /* Indicate the current RxContext Index which driver can read & process it. */
1861 unsigned long NextRxBulkInPosition; /* Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength. */
1862 unsigned long TransferBufferLength; /* current length of the packet buffer */
1863 unsigned long ReadPosition; /* current read position in a packet buffer */
1864 #endif /* RTMP_MAC_USB // */
1866 /*****************************************************************************************/
1867 /* ASIC related parameters */
1868 /*****************************************************************************************/
1869 u32 MACVersion; /* MAC version. Record rt2860C(0x28600100) or rt2860D (0x28600101).. */
1871 /* --------------------------- */
1873 /* --------------------------- */
1874 unsigned long EepromVersion; /* byte 0: version, byte 1: revision, byte 2~3: unused */
1875 unsigned long FirmwareVersion; /* byte 0: Minor version, byte 1: Major version, otherwise unused. */
1876 u16 EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS];
1877 u8 EEPROMAddressNum; /* 93c46=6 93c66=8 */
1878 BOOLEAN EepromAccess;
1881 /* --------------------------- */
1883 /* --------------------------- */
1884 u8 BbpWriteLatch[140]; /* record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID */
1885 char BbpRssiToDbmDelta; /* change from u8 to char for high power */
1886 struct rt_bbp_r66_tuning BbpTuning;
1888 /* ---------------------------- */
1890 /* ---------------------------- */
1891 u8 RfIcType; /* RFIC_xxx */
1892 unsigned long RfFreqOffset; /* Frequency offset for channel switching */
1893 struct rt_rtmp_rf_regs LatchRfRegs; /* latch th latest RF programming value since RF IC doesn't support READ */
1895 EEPROM_ANTENNA_STRUC Antenna; /* Since ANtenna definition is different for a & g. We need to save it for future reference. */
1896 EEPROM_NIC_CONFIG2_STRUC NicConfig2;
1898 /* This soft Rx Antenna Diversity mechanism is used only when user set */
1899 /* RX Antenna = DIVERSITY ON */
1900 struct rt_soft_rx_ant_diversity RxAnt;
1903 struct rt_channel_tx_power TxPower[MAX_NUM_OF_CHANNELS]; /* Store Tx power value for all channels. */
1904 struct rt_channel_tx_power ChannelList[MAX_NUM_OF_CHANNELS]; /* list all supported channels for site survey */
1905 struct rt_channel_11j_tx_power TxPower11J[MAX_NUM_OF_11JCHANNELS]; /* 802.11j channel and bw */
1906 struct rt_channel_11j_tx_power ChannelList11J[MAX_NUM_OF_11JCHANNELS]; /* list all supported channels for site survey */
1908 u8 ChannelListNum; /* number of channel in ChannelList[] */
1911 unsigned long Tx20MPwrCfgABand[5];
1912 unsigned long Tx20MPwrCfgGBand[5];
1913 unsigned long Tx40MPwrCfgABand[5];
1914 unsigned long Tx40MPwrCfgGBand[5];
1916 BOOLEAN bAutoTxAgcA; /* Enable driver auto Tx Agc control */
1917 u8 TssiRefA; /* Store Tssi reference value as 25 temperature. */
1918 u8 TssiPlusBoundaryA[5]; /* Tssi boundary for increase Tx power to compensate. */
1919 u8 TssiMinusBoundaryA[5]; /* Tssi boundary for decrease Tx power to compensate. */
1920 u8 TxAgcStepA; /* Store Tx TSSI delta increment / decrement value */
1921 char TxAgcCompensateA; /* Store the compensation (TxAgcStep * (idx-1)) */
1923 BOOLEAN bAutoTxAgcG; /* Enable driver auto Tx Agc control */
1924 u8 TssiRefG; /* Store Tssi reference value as 25 temperature. */
1925 u8 TssiPlusBoundaryG[5]; /* Tssi boundary for increase Tx power to compensate. */
1926 u8 TssiMinusBoundaryG[5]; /* Tssi boundary for decrease Tx power to compensate. */
1927 u8 TxAgcStepG; /* Store Tx TSSI delta increment / decrement value */
1928 char TxAgcCompensateG; /* Store the compensation (TxAgcStep * (idx-1)) */
1930 char BGRssiOffset0; /* Store B/G RSSI#0 Offset value on EEPROM 0x46h */
1931 char BGRssiOffset1; /* Store B/G RSSI#1 Offset value */
1932 char BGRssiOffset2; /* Store B/G RSSI#2 Offset value */
1934 char ARssiOffset0; /* Store A RSSI#0 Offset value on EEPROM 0x4Ah */
1935 char ARssiOffset1; /* Store A RSSI#1 Offset value */
1936 char ARssiOffset2; /* Store A RSSI#2 Offset value */
1938 char BLNAGain; /* Store B/G external LNA#0 value on EEPROM 0x44h */
1939 char ALNAGain0; /* Store A external LNA#0 value for ch36~64 */
1940 char ALNAGain1; /* Store A external LNA#1 value for ch100~128 */
1941 char ALNAGain2; /* Store A external LNA#2 value for ch132~165 */
1947 u8 TxMixerGain24G; /* Tx mixer gain value from EEPROM to improve Tx EVM / Tx DAC, 2.4G */
1949 #endif /* RT30xx // */
1950 /* ---------------------------- */
1952 /* ---------------------------- */
1953 MCU_LEDCS_STRUC LedCntl;
1954 u16 Led1; /* read from EEPROM 0x3c */
1955 u16 Led2; /* EEPROM 0x3e */
1956 u16 Led3; /* EEPROM 0x40 */
1957 u8 LedIndicatorStrength;
1958 u8 RssiSingalstrengthOffet;
1959 BOOLEAN bLedOnScanning;
1962 /*****************************************************************************************/
1963 /* 802.11 related parameters */
1964 /*****************************************************************************************/
1965 /* outgoing BEACON frame buffer and corresponding TXD */
1966 struct rt_txwi BeaconTxWI;
1968 u16 BeaconOffset[HW_BEACON_MAX_COUNT];
1970 /* pre-build PS-POLL and NULL frame upon link up. for efficiency purpose. */
1971 struct rt_pspoll_frame PsPollFrame;
1972 struct rt_header_802_11 NullFrame;
1975 struct rt_tx_context BeaconContext[BEACON_RING_SIZE];
1976 struct rt_tx_context NullContext;
1977 struct rt_tx_context PsPollContext;
1978 struct rt_tx_context RTSContext;
1979 #endif /* RTMP_MAC_USB // */
1981 /*=========AP=========== */
1983 /*=======STA=========== */
1984 /* ----------------------------------------------- */
1985 /* STA specific configuration & operation status */
1986 /* used only when pAd->OpMode == OPMODE_STA */
1987 /* ----------------------------------------------- */
1988 struct rt_sta_admin_config StaCfg; /* user desired settings */
1989 struct rt_sta_active_config StaActive; /* valid only when ADHOC_ON(pAd) || INFRA_ON(pAd) */
1990 char nickname[IW_ESSID_MAX_SIZE + 1]; /* nickname, only used in the iwconfig i/f */
1993 /*=======Common=========== */
1994 /* OP mode: either AP or STA */
1995 u8 OpMode; /* OPMODE_STA, OPMODE_AP */
1997 int IndicateMediaState; /* Base on Indication state, default is NdisMediaStateDisConnected */
1999 /* MAT related parameters */
2001 /* configuration: read from Registry & E2PROM */
2002 BOOLEAN bLocalAdminMAC; /* Use user changed MAC */
2003 u8 PermanentAddress[MAC_ADDR_LEN]; /* Factory default MAC address */
2004 u8 CurrentAddress[MAC_ADDR_LEN]; /* User changed MAC address */
2006 /* ------------------------------------------------------ */
2007 /* common configuration to both OPMODE_STA and OPMODE_AP */
2008 /* ------------------------------------------------------ */
2009 struct rt_common_config CommonCfg;
2010 struct rt_mlme Mlme;
2012 /* AP needs those vaiables for site survey feature. */
2013 struct rt_mlme_aux MlmeAux; /* temporary settings used during MLME state machine */
2014 struct rt_bss_table ScanTab; /* store the latest SCAN result */
2016 /*About MacTab, the sta driver will use #0 and #1 for multicast and AP. */
2017 struct rt_mac_table MacTab; /* ASIC on-chip WCID entry table. At TX, ASIC always use key according to this on-chip table. */
2018 spinlock_t MacTabLock;
2020 struct rt_ba_table BATable;
2022 spinlock_t BATabLock;
2023 struct rt_ralink_timer RECBATimer;
2025 /* encryption/decryption KEY tables */
2026 struct rt_cipher_key SharedKey[MAX_MBSSID_NUM][4]; /* STA always use SharedKey[BSS0][0..3] */
2028 /* RX re-assembly buffer for fragmentation */
2029 struct rt_fragment_frame FragFrame; /* Frame storage for fragment frame */
2031 /* various Counters */
2032 struct rt_counter_802_3 Counters8023; /* 802.3 counters */
2033 struct rt_counter_802_11 WlanCounters; /* 802.11 MIB counters */
2034 struct rt_counter_ralink RalinkCounters; /* Ralink propriety counters */
2035 struct rt_counter_drs DrsCounters; /* counters for Dynamic TX Rate Switching */
2036 struct rt_private PrivateInfo; /* Private information & counters */
2038 /* flags, see fRTMP_ADAPTER_xxx flags */
2039 unsigned long Flags; /* Represent current device status */
2040 unsigned long PSFlags; /* Power Save operation flag. */
2042 /* current TX sequence # */
2045 /* Control disconnect / connect event generation */
2046 /*+++Didn't used anymore */
2047 unsigned long LinkDownTime;
2049 unsigned long LastRxRate;
2050 unsigned long LastTxRate;
2051 /*+++Used only for Station */
2052 BOOLEAN bConfigChanged; /* Config Change flag for the same SSID setting */
2055 unsigned long ExtraInfo; /* Extra information for displaying status */
2056 unsigned long SystemErrorBitmap; /* b0: E2PROM version error */
2058 /*+++Didn't used anymore */
2059 unsigned long MacIcVersion; /* MAC/BBP serial interface issue solved after ver.D */
2062 /* --------------------------- */
2063 /* System event log */
2064 /* --------------------------- */
2065 struct rt_802_11_event_table EventTab;
2069 /*****************************************************************************************/
2070 /* Statistic related parameters */
2071 /*****************************************************************************************/
2073 unsigned long BulkOutDataOneSecCount;
2074 unsigned long BulkInDataOneSecCount;
2075 unsigned long BulkLastOneSecCount; /* BulkOutDataOneSecCount + BulkInDataOneSecCount */
2076 unsigned long watchDogRxCnt;
2077 unsigned long watchDogRxOverFlowCnt;
2078 unsigned long watchDogTxPendingCnt[NUM_OF_TX_RING];
2079 int TransferedLength[NUM_OF_TX_RING];
2080 #endif /* RTMP_MAC_USB // */
2082 BOOLEAN bUpdateBcnCntDone;
2083 unsigned long watchDogMacDeadlock; /* prevent MAC/BBP into deadlock condition */
2084 /* ---------------------------- */
2085 /* DEBUG paramerts */
2086 /* ---------------------------- */
2087 /*unsigned long DebugSetting[4]; */
2088 BOOLEAN bBanAllBaSetup;
2089 BOOLEAN bPromiscuous;
2091 /* ---------------------------- */
2092 /* rt2860c emulation-use Parameters */
2093 /* ---------------------------- */
2094 /*unsigned long rtsaccu[30]; */
2095 /*unsigned long ctsaccu[30]; */
2096 /*unsigned long cfendaccu[30]; */
2097 /*unsigned long bacontent[16]; */
2098 /*unsigned long rxint[RX_RING_SIZE+1]; */
2101 BOOLEAN bForcePrintTX;
2102 BOOLEAN bForcePrintRX;
2103 /*BOOLEAN bDisablescanning; //defined in RT2870 USB */
2104 BOOLEAN bStaFifoTest;
2105 BOOLEAN bProtectionTest;
2106 BOOLEAN bBroadComHT;
2107 /*+++Following add from RT2870 USB. */
2108 unsigned long BulkOutReq;
2109 unsigned long BulkOutComplete;
2110 unsigned long BulkOutCompleteOther;
2111 unsigned long BulkOutCompleteCancel; /* seems not use now? */
2112 unsigned long BulkInReq;
2113 unsigned long BulkInComplete;
2114 unsigned long BulkInCompleteFail;
2117 struct wificonf WIFItestbed;
2119 struct reordering_mpdu_pool mpdu_blk_pool;
2121 unsigned long OneSecondnonBEpackets; /* record non BE packets per second */
2124 struct iw_statistics iw_stats;
2126 struct net_device_stats stats;
2127 #endif /* LINUX // */
2129 unsigned long TbttTickCount;
2130 #ifdef PCI_MSI_SUPPORT
2132 #endif /* PCI_MSI_SUPPORT // */
2136 #define TIME_BASE (1000000/OS_HZ)
2137 #define TIME_ONE_SECOND (1000000/TIME_BASE)
2139 unsigned long be_adjust_last_time;
2145 #ifdef RTMP_EFUSE_SUPPORT
2147 u8 EEPROMImage[1024];
2148 #endif /* RTMP_EFUSE_SUPPORT // */
2149 #endif /* RT30xx // */
2152 #define DELAYINTMASK 0x0003fffb
2153 #define INTMASK 0x0003fffb
2154 #define IndMask 0x0003fffc
2155 #define RxINT 0x00000005 /* Delayed Rx or indivi rx */
2156 #define TxDataInt 0x000000fa /* Delayed Tx or indivi tx */
2157 #define TxMgmtInt 0x00000102 /* Delayed Tx or indivi tx */
2158 #define TxCoherent 0x00020000 /* tx coherent */
2159 #define RxCoherent 0x00010000 /* rx coherent */
2160 #define McuCommand 0x00000200 /* mcu */
2161 #define PreTBTTInt 0x00001000 /* Pre-TBTT interrupt */
2162 #define TBTTInt 0x00000800 /* TBTT interrupt */
2163 #define GPTimeOutInt 0x00008000 /* GPtimeout interrupt */
2164 #define AutoWakeupInt 0x00004000 /* AutoWakeupInt interrupt */
2165 #define FifoStaFullInt 0x00002000 /* fifo statistics full interrupt */
2167 /***************************************************************************
2168 * Rx Path software control block related data structures
2169 **************************************************************************/
2171 RT28XX_RXD_STRUC RxD;
2172 struct rt_rxwi * pRxWI;
2173 struct rt_header_802_11 * pHeader;
2178 u8 UserPriority; /* for calculate TKIP MIC using */
2181 #define RX_BLK_SET_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags |= _flag)
2182 #define RX_BLK_TEST_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags & _flag)
2183 #define RX_BLK_CLEAR_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags &= ~(_flag))
2185 #define fRX_WDS 0x0001
2186 #define fRX_AMSDU 0x0002
2187 #define fRX_ARALINK 0x0004
2188 #define fRX_HTC 0x0008
2189 #define fRX_PAD 0x0010
2190 #define fRX_AMPDU 0x0020
2191 #define fRX_QOS 0x0040
2192 #define fRX_INFRA 0x0080
2193 #define fRX_EAP 0x0100
2194 #define fRX_MESH 0x0200
2195 #define fRX_APCLI 0x0400
2196 #define fRX_DLS 0x0800
2197 #define fRX_WPI 0x1000
2199 #define LENGTH_AMSDU_SUBFRAMEHEAD 14
2200 #define LENGTH_ARALINK_SUBFRAMEHEAD 14
2201 #define LENGTH_ARALINK_HEADER_FIELD 2
2203 /***************************************************************************
2204 * Tx Path software control block related data structures
2205 **************************************************************************/
2206 #define TX_UNKOWN_FRAME 0x00
2207 #define TX_MCAST_FRAME 0x01
2208 #define TX_LEGACY_FRAME 0x02
2209 #define TX_AMPDU_FRAME 0x04
2210 #define TX_AMSDU_FRAME 0x08
2211 #define TX_RALINK_FRAME 0x10
2212 #define TX_FRAG_FRAME 0x20
2214 /* Currently the sizeof(struct rt_tx_blk) is 148 bytes. */
2217 u8 TxFrameType; /* Indicate the Transmission type of the all frames in one batch */
2218 u8 TotalFrameNum; /* Total frame number want to send-out in one batch */
2219 u16 TotalFragNum; /* Total frame fragments required in one batch */
2220 u16 TotalFrameLen; /* Total length of all frames want to send-out in one batch */
2222 struct rt_queue_header TxPacketList;
2223 struct rt_mac_table_entry *pMacEntry; /* NULL: packet with 802.11 RA field is multicast/broadcast address */
2224 HTTRANSMIT_SETTING *pTransmit;
2226 /* Following structure used for the characteristics of a specific packet. */
2228 u8 *pSrcBufHeader; /* Reference to the head of sk_buff->data */
2229 u8 *pSrcBufData; /* Reference to the sk_buff->data, will changed depends on hanlding progresss */
2230 u32 SrcBufLen; /* Length of packet payload which not including Layer 2 header */
2231 u8 *pExtraLlcSnapEncap; /* NULL means no extra LLC/SNAP is required */
2232 u8 HeaderBuf[128]; /* TempBuffer for TX_INFO + TX_WI + 802.11 Header + padding + AMSDU SubHeader + LLC/SNAP */
2233 /*RT2870 2.1.0.0 uses only 80 bytes */
2234 /*RT3070 2.1.1.0 uses only 96 bytes */
2235 /*RT3090 2.1.0.0 uses only 96 bytes */
2236 u8 MpduHeaderLen; /* 802.11 header length NOT including the padding */
2237 u8 HdrPadLen; /* recording Header Padding Length; */
2238 u8 apidx; /* The interface associated to this packet */
2239 u8 Wcid; /* The MAC entry associated to this packet */
2240 u8 UserPriority; /* priority class of packet */
2241 u8 FrameGap; /* what kind of IFS this packet use */
2242 u8 MpduReqNum; /* number of fragments of this frame */
2243 u8 TxRate; /* TODO: Obsoleted? Should change to MCS? */
2244 u8 CipherAlg; /* cipher alogrithm */
2245 struct rt_cipher_key *pKey;
2247 u16 Flags; /*See following definitions for detail. */
2249 /*YOU SHOULD NOT TOUCH IT! Following parameters are used for hardware-depended layer. */
2250 unsigned long Priv; /* Hardware specific value saved in here. */
2253 #define fTX_bRtsRequired 0x0001 /* Indicate if need send RTS frame for protection. Not used in RT2860/RT2870. */
2254 #define fTX_bAckRequired 0x0002 /* the packet need ack response */
2255 #define fTX_bPiggyBack 0x0004 /* Legacy device use Piggback or not */
2256 #define fTX_bHTRate 0x0008 /* allow to use HT rate */
2257 #define fTX_bForceNonQoS 0x0010 /* force to transmit frame without WMM-QoS in HT mode */
2258 #define fTX_bAllowFrag 0x0020 /* allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment */
2259 #define fTX_bMoreData 0x0040 /* there are more data packets in PowerSave Queue */
2260 #define fTX_bWMM 0x0080 /* QOS Data */
2261 #define fTX_bClearEAPFrame 0x0100
2263 #define TX_BLK_SET_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags |= _flag)
2264 #define TX_BLK_TEST_FLAG(_pTxBlk, _flag) (((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
2265 #define TX_BLK_CLEAR_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags &= ~(_flag))
2267 /***************************************************************************
2268 * Other static inline function definitions
2269 **************************************************************************/
2270 static inline void ConvertMulticastIP2MAC(u8 *pIpAddr,
2274 if (pIpAddr == NULL)
2277 if (ppMacAddr == NULL || *ppMacAddr == NULL)
2280 switch (ProtoType) {
2282 /* memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS); */
2283 *(*ppMacAddr) = 0x33;
2284 *(*ppMacAddr + 1) = 0x33;
2285 *(*ppMacAddr + 2) = pIpAddr[12];
2286 *(*ppMacAddr + 3) = pIpAddr[13];
2287 *(*ppMacAddr + 4) = pIpAddr[14];
2288 *(*ppMacAddr + 5) = pIpAddr[15];
2293 /* memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS); */
2294 *(*ppMacAddr) = 0x01;
2295 *(*ppMacAddr + 1) = 0x00;
2296 *(*ppMacAddr + 2) = 0x5e;
2297 *(*ppMacAddr + 3) = pIpAddr[1] & 0x7f;
2298 *(*ppMacAddr + 4) = pIpAddr[2];
2299 *(*ppMacAddr + 5) = pIpAddr[3];
2306 char *GetPhyMode(int Mode);
2307 char *GetBW(int BW);
2310 /* Private routines in rtmp_init.c */
2312 int RTMPAllocAdapterBlock(void *handle,
2313 struct rt_rtmp_adapter * * ppAdapter);
2315 int RTMPAllocTxRxRingMemory(struct rt_rtmp_adapter *pAd);
2317 void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd);
2319 int NICReadRegParameters(struct rt_rtmp_adapter *pAd,
2320 void *WrapperConfigurationContext);
2322 #ifdef RTMP_RF_RW_SUPPORT
2323 void NICInitRFRegisters(struct rt_rtmp_adapter *pAd);
2325 void RtmpChipOpsRFHook(struct rt_rtmp_adapter *pAd);
2327 int RT30xxWriteRFRegister(struct rt_rtmp_adapter *pAd,
2328 u8 regID, u8 value);
2330 int RT30xxReadRFRegister(struct rt_rtmp_adapter *pAd,
2331 u8 regID, u8 *pValue);
2332 #endif /* RTMP_RF_RW_SUPPORT // */
2334 void NICReadEEPROMParameters(struct rt_rtmp_adapter *pAd, u8 *mac_addr);
2336 void NICInitAsicFromEEPROM(struct rt_rtmp_adapter *pAd);
2338 int NICInitializeAdapter(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset);
2340 int NICInitializeAsic(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset);
2342 void NICIssueReset(struct rt_rtmp_adapter *pAd);
2344 void RTMPRingCleanUp(struct rt_rtmp_adapter *pAd, u8 RingType);
2346 void UserCfgInit(struct rt_rtmp_adapter *pAd);
2348 void NICResetFromError(struct rt_rtmp_adapter *pAd);
2350 int NICLoadFirmware(struct rt_rtmp_adapter *pAd);
2352 void NICEraseFirmware(struct rt_rtmp_adapter *pAd);
2354 int NICLoadRateSwitchingParams(struct rt_rtmp_adapter *pAd);
2356 BOOLEAN NICCheckForHang(struct rt_rtmp_adapter *pAd);
2358 void NICUpdateFifoStaCounters(struct rt_rtmp_adapter *pAd);
2360 void NICUpdateRawCounters(struct rt_rtmp_adapter *pAd);
2362 void RTMPZeroMemory(void *pSrc, unsigned long Length);
2364 unsigned long RTMPCompareMemory(void *pSrc1, void *pSrc2, unsigned long Length);
2366 void RTMPMoveMemory(void *pDest, void *pSrc, unsigned long Length);
2368 void AtoH(char *src, u8 *dest, int destlen);
2372 void RTMPPatchMacBbpBug(struct rt_rtmp_adapter *pAd);
2374 void RTMPInitTimer(struct rt_rtmp_adapter *pAd,
2375 struct rt_ralink_timer *pTimer,
2376 void *pTimerFunc, void *pData, IN BOOLEAN Repeat);
2378 void RTMPSetTimer(struct rt_ralink_timer *pTimer, unsigned long Value);
2380 void RTMPModTimer(struct rt_ralink_timer *pTimer, unsigned long Value);
2382 void RTMPCancelTimer(struct rt_ralink_timer *pTimer, OUT BOOLEAN * pCancelled);
2384 void RTMPSetLED(struct rt_rtmp_adapter *pAd, u8 Status);
2386 void RTMPSetSignalLED(struct rt_rtmp_adapter *pAd, IN NDIS_802_11_RSSI Dbm);
2388 void RTMPEnableRxTx(struct rt_rtmp_adapter *pAd);
2391 /* prototype in action.c */
2393 void ActionStateMachineInit(struct rt_rtmp_adapter *pAd,
2394 struct rt_state_machine *S,
2395 OUT STATE_MACHINE_FUNC Trans[]);
2397 void MlmeADDBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2399 void MlmeDELBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2401 void MlmeDLSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2403 void MlmeInvalidAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2405 void MlmeQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2407 void PeerAddBAReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2409 void PeerAddBARspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2411 void PeerDelBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2413 void PeerBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2415 void SendPSMPAction(struct rt_rtmp_adapter *pAd, u8 Wcid, u8 Psmp);
2417 void PeerRMAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2419 void PeerPublicAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2421 void PeerHTAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2423 void PeerQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2425 void RECBATimerTimeout(void *SystemSpecific1,
2426 void *FunctionContext,
2427 void *SystemSpecific2, void *SystemSpecific3);
2429 void ORIBATimerTimeout(struct rt_rtmp_adapter *pAd);
2431 void SendRefreshBAR(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
2433 void ActHeaderInit(struct rt_rtmp_adapter *pAd,
2434 struct rt_header_802_11 * pHdr80211,
2435 u8 *Addr1, u8 *Addr2, u8 *Addr3);
2437 void BarHeaderInit(struct rt_rtmp_adapter *pAd,
2438 struct rt_frame_bar * pCntlBar, u8 *pDA, u8 *pSA);
2440 void InsertActField(struct rt_rtmp_adapter *pAd,
2442 unsigned long *pFrameLen, u8 Category, u8 ActCode);
2444 BOOLEAN CntlEnqueueForRecv(struct rt_rtmp_adapter *pAd,
2446 unsigned long MsgLen, struct rt_frame_ba_req * pMsg);
2449 /* Private routines in rtmp_data.c */
2451 BOOLEAN RTMPHandleRxDoneInterrupt(struct rt_rtmp_adapter *pAd);
2453 BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd,
2454 INT_SOURCE_CSR_STRUC TxRingBitmap);
2456 void RTMPHandleMgmtRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd);
2458 void RTMPHandleTBTTInterrupt(struct rt_rtmp_adapter *pAd);
2460 void RTMPHandlePreTBTTInterrupt(struct rt_rtmp_adapter *pAd);
2462 void RTMPHandleTwakeupInterrupt(struct rt_rtmp_adapter *pAd);
2464 void RTMPHandleRxCoherentInterrupt(struct rt_rtmp_adapter *pAd);
2466 BOOLEAN TxFrameIsAggregatible(struct rt_rtmp_adapter *pAd,
2467 u8 *pPrevAddr1, u8 *p8023hdr);
2469 BOOLEAN PeerIsAggreOn(struct rt_rtmp_adapter *pAd,
2470 unsigned long TxRate, struct rt_mac_table_entry *pMacEntry);
2472 int Sniff2BytesFromNdisBuffer(char *pFirstBuffer,
2474 u8 *pByte0, u8 *pByte1);
2476 int STASendPacket(struct rt_rtmp_adapter *pAd, void *pPacket);
2478 void STASendPackets(void *MiniportAdapterContext,
2479 void **ppPacketArray, u32 NumberOfPackets);
2481 void RTMPDeQueuePacket(struct rt_rtmp_adapter *pAd,
2482 IN BOOLEAN bIntContext,
2483 u8 QueIdx, u8 Max_Tx_Packets);
2485 int RTMPHardTransmit(struct rt_rtmp_adapter *pAd,
2487 u8 QueIdx, unsigned long *pFreeTXDLeft);
2489 int STAHardTransmit(struct rt_rtmp_adapter *pAd,
2490 struct rt_tx_blk *pTxBlk, u8 QueIdx);
2492 void STARxEAPOLFrameIndicate(struct rt_rtmp_adapter *pAd,
2493 struct rt_mac_table_entry *pEntry,
2494 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
2496 int RTMPFreeTXDRequest(struct rt_rtmp_adapter *pAd,
2498 u8 NumberRequired, u8 *FreeNumberIs);
2500 int MlmeHardTransmit(struct rt_rtmp_adapter *pAd,
2501 u8 QueIdx, void *pPacket);
2503 int MlmeHardTransmitMgmtRing(struct rt_rtmp_adapter *pAd,
2504 u8 QueIdx, void *pPacket);
2507 int MlmeHardTransmitTxRing(struct rt_rtmp_adapter *pAd,
2508 u8 QueIdx, void *pPacket);
2510 int MlmeDataHardTransmit(struct rt_rtmp_adapter *pAd,
2511 u8 QueIdx, void *pPacket);
2513 void RTMPWriteTxDescriptor(struct rt_rtmp_adapter *pAd,
2514 struct rt_txd * pTxD, IN BOOLEAN bWIV, u8 QSEL);
2515 #endif /* RTMP_MAC_PCI // */
2517 u16 RTMPCalcDuration(struct rt_rtmp_adapter *pAd, u8 Rate, unsigned long Size);
2519 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. */
2522 unsigned long Length,
2527 IN BOOLEAN CfAck, IN HTTRANSMIT_SETTING * pTransmit);
2529 void RTMPWriteTxWI_Data(struct rt_rtmp_adapter *pAd,
2530 struct rt_txwi * pTxWI, struct rt_tx_blk *pTxBlk);
2532 void RTMPWriteTxWI_Cache(struct rt_rtmp_adapter *pAd,
2533 struct rt_txwi * pTxWI, struct rt_tx_blk *pTxBlk);
2535 void RTMPSuspendMsduTransmission(struct rt_rtmp_adapter *pAd);
2537 void RTMPResumeMsduTransmission(struct rt_rtmp_adapter *pAd);
2539 int MiniportMMRequest(struct rt_rtmp_adapter *pAd,
2540 u8 QueIdx, u8 *pData, u32 Length);
2542 /*+++mark by shiang, now this function merge to MiniportMMRequest() */
2543 /*---mark by shiang, now this function merge to MiniportMMRequest() */
2545 void RTMPSendNullFrame(struct rt_rtmp_adapter *pAd,
2546 u8 TxRate, IN BOOLEAN bQosNull);
2548 void RTMPSendDisassociationFrame(struct rt_rtmp_adapter *pAd);
2550 void RTMPSendRTSFrame(struct rt_rtmp_adapter *pAd,
2552 IN unsigned int NextMpduSize,
2556 u8 QueIdx, u8 FrameGap);
2558 struct rt_queue_header *RTMPCheckTxSwQueue(struct rt_rtmp_adapter *pAd, u8 * QueIdx);
2560 void RTMPReportMicError(struct rt_rtmp_adapter *pAd, struct rt_cipher_key *pWpaKey);
2562 void WpaMicFailureReportFrame(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2564 void WpaDisassocApAndBlockAssoc(void *SystemSpecific1,
2565 void *FunctionContext,
2566 void *SystemSpecific2,
2567 void *SystemSpecific3);
2569 void WpaStaPairwiseKeySetting(struct rt_rtmp_adapter *pAd);
2571 void WpaStaGroupKeySetting(struct rt_rtmp_adapter *pAd);
2573 int RTMPCloneNdisPacket(struct rt_rtmp_adapter *pAd,
2574 IN BOOLEAN pInsAMSDUHdr,
2576 void ** ppOutPacket);
2578 int RTMPAllocateNdisPacket(struct rt_rtmp_adapter *pAd,
2582 u8 *pData, u32 DataLen);
2584 void RTMPFreeNdisPacket(struct rt_rtmp_adapter *pAd, void *pPacket);
2586 BOOLEAN RTMPFreeTXDUponTxDmaDone(struct rt_rtmp_adapter *pAd, u8 QueIdx);
2588 BOOLEAN RTMPCheckDHCPFrame(struct rt_rtmp_adapter *pAd, void *pPacket);
2590 BOOLEAN RTMPCheckEtherType(struct rt_rtmp_adapter *pAd, void *pPacket);
2593 /* Private routines in rtmp_wep.c */
2595 void RTMPInitWepEngine(struct rt_rtmp_adapter *pAd,
2597 u8 KeyId, u8 KeyLen, u8 *pDest);
2599 void RTMPEncryptData(struct rt_rtmp_adapter *pAd,
2600 u8 *pSrc, u8 *pDest, u32 Len);
2602 BOOLEAN RTMPSoftDecryptWEP(struct rt_rtmp_adapter *pAd,
2604 unsigned long DataByteCnt, struct rt_cipher_key *pGroupKey);
2606 void RTMPSetICV(struct rt_rtmp_adapter *pAd, u8 *pDest);
2608 void ARCFOUR_INIT(struct rt_arcfourcontext *Ctx, u8 *pKey, u32 KeyLen);
2610 u8 ARCFOUR_BYTE(struct rt_arcfourcontext *Ctx);
2612 void ARCFOUR_DECRYPT(struct rt_arcfourcontext *Ctx,
2613 u8 *pDest, u8 *pSrc, u32 Len);
2615 void ARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
2616 u8 *pDest, u8 *pSrc, u32 Len);
2618 void WPAARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
2619 u8 *pDest, u8 *pSrc, u32 Len);
2621 u32 RTMP_CALC_FCS32(u32 Fcs, u8 *Cp, int Len);
2627 /* Asic/RF/BBP related functions */
2629 void AsicAdjustTxPower(struct rt_rtmp_adapter *pAd);
2631 void AsicUpdateProtect(struct rt_rtmp_adapter *pAd,
2634 IN BOOLEAN bDisableBGProtect, IN BOOLEAN bNonGFExist);
2636 void AsicSwitchChannel(struct rt_rtmp_adapter *pAd,
2637 u8 Channel, IN BOOLEAN bScan);
2639 void AsicLockChannel(struct rt_rtmp_adapter *pAd, u8 Channel);
2641 void AsicRfTuningExec(void *SystemSpecific1,
2642 void *FunctionContext,
2643 void *SystemSpecific2, void *SystemSpecific3);
2645 void AsicResetBBPAgent(struct rt_rtmp_adapter *pAd);
2647 void AsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
2648 u16 TbttNumToNextWakeUp);
2650 void AsicForceSleep(struct rt_rtmp_adapter *pAd);
2652 void AsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
2654 void AsicSetBssid(struct rt_rtmp_adapter *pAd, u8 *pBssid);
2656 void AsicSetMcastWC(struct rt_rtmp_adapter *pAd);
2658 void AsicDelWcidTab(struct rt_rtmp_adapter *pAd, u8 Wcid);
2660 void AsicEnableRDG(struct rt_rtmp_adapter *pAd);
2662 void AsicDisableRDG(struct rt_rtmp_adapter *pAd);
2664 void AsicDisableSync(struct rt_rtmp_adapter *pAd);
2666 void AsicEnableBssSync(struct rt_rtmp_adapter *pAd);
2668 void AsicEnableIbssSync(struct rt_rtmp_adapter *pAd);
2670 void AsicSetEdcaParm(struct rt_rtmp_adapter *pAd, struct rt_edca_parm *pEdcaParm);
2672 void AsicSetSlotTime(struct rt_rtmp_adapter *pAd, IN BOOLEAN bUseShortSlotTime);
2674 void AsicAddSharedKeyEntry(struct rt_rtmp_adapter *pAd,
2678 u8 *pKey, u8 *pTxMic, u8 *pRxMic);
2680 void AsicRemoveSharedKeyEntry(struct rt_rtmp_adapter *pAd,
2681 u8 BssIndex, u8 KeyIdx);
2683 void AsicUpdateWCIDAttribute(struct rt_rtmp_adapter *pAd,
2687 IN BOOLEAN bUsePairewiseKeyTable);
2689 void AsicUpdateWCIDIVEIV(struct rt_rtmp_adapter *pAd,
2690 u16 WCID, unsigned long uIV, unsigned long uEIV);
2692 void AsicUpdateRxWCIDTable(struct rt_rtmp_adapter *pAd,
2693 u16 WCID, u8 *pAddr);
2695 void AsicAddKeyEntry(struct rt_rtmp_adapter *pAd,
2699 struct rt_cipher_key *pCipherKey,
2700 IN BOOLEAN bUsePairewiseKeyTable, IN BOOLEAN bTxKey);
2702 void AsicAddPairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
2704 u8 WCID, struct rt_cipher_key *pCipherKey);
2706 void AsicRemovePairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
2707 u8 BssIdx, u8 Wcid);
2709 BOOLEAN AsicSendCommandToMcu(struct rt_rtmp_adapter *pAd,
2711 u8 Token, u8 Arg0, u8 Arg1);
2714 BOOLEAN AsicCheckCommanOk(struct rt_rtmp_adapter *pAd, u8 Command);
2715 #endif /* RTMP_MAC_PCI // */
2717 void MacAddrRandomBssid(struct rt_rtmp_adapter *pAd, u8 *pAddr);
2719 void MgtMacHeaderInit(struct rt_rtmp_adapter *pAd,
2720 struct rt_header_802_11 * pHdr80211,
2722 u8 ToDs, u8 *pDA, u8 *pBssid);
2724 void MlmeRadioOff(struct rt_rtmp_adapter *pAd);
2726 void MlmeRadioOn(struct rt_rtmp_adapter *pAd);
2728 void BssTableInit(struct rt_bss_table *Tab);
2730 void BATableInit(struct rt_rtmp_adapter *pAd, struct rt_ba_table *Tab);
2732 unsigned long BssTableSearch(struct rt_bss_table *Tab, u8 *pBssid, u8 Channel);
2734 unsigned long BssSsidTableSearch(struct rt_bss_table *Tab,
2736 u8 *pSsid, u8 SsidLen, u8 Channel);
2738 unsigned long BssTableSearchWithSSID(struct rt_bss_table *Tab,
2741 u8 SsidLen, u8 Channel);
2743 unsigned long BssSsidTableSearchBySSID(struct rt_bss_table *Tab,
2744 u8 *pSsid, u8 SsidLen);
2746 void BssTableDeleteEntry(struct rt_bss_table *pTab,
2747 u8 *pBssid, u8 Channel);
2749 void BATableDeleteORIEntry(struct rt_rtmp_adapter *pAd,
2750 struct rt_ba_ori_entry *pBAORIEntry);
2752 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 */
2755 u8 NewExtChanOffset,
2758 IN LARGE_INTEGER TimeStamp,
2760 struct rt_edca_parm *pEdcaParm,
2761 struct rt_qos_capability_parm *pQosCapability,
2762 struct rt_qbss_load_parm *pQbssLoad,
2763 u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE);
2765 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 */
2768 u8 NewExtChanOffset,
2771 IN LARGE_INTEGER TimeStamp,
2773 struct rt_edca_parm *pEdcaParm,
2774 struct rt_qos_capability_parm *pQosCapability,
2775 struct rt_qbss_load_parm *pQbssLoad,
2776 u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE);
2778 void BATableInsertEntry(struct rt_rtmp_adapter *pAd,
2784 u8 OriginatorStatus, IN BOOLEAN IsRecipient);
2786 void BssTableSsidSort(struct rt_rtmp_adapter *pAd,
2787 struct rt_bss_table *OutTab, char Ssid[], u8 SsidLen);
2789 void BssTableSortByRssi(struct rt_bss_table *OutTab);
2791 void BssCipherParse(struct rt_bss_entry *pBss);
2793 int MlmeQueueInit(struct rt_mlme_queue *Queue);
2795 void MlmeQueueDestroy(struct rt_mlme_queue *Queue);
2797 BOOLEAN MlmeEnqueue(struct rt_rtmp_adapter *pAd,
2798 unsigned long Machine,
2799 unsigned long MsgType, unsigned long MsgLen, void * Msg);
2801 BOOLEAN MlmeEnqueueForRecv(struct rt_rtmp_adapter *pAd,
2803 unsigned long TimeStampHigh,
2804 unsigned long TimeStampLow,
2808 unsigned long MsgLen, void *Msg, u8 Signal);
2810 BOOLEAN MlmeDequeue(struct rt_mlme_queue *Queue, struct rt_mlme_queue_elem ** Elem);
2812 void MlmeRestartStateMachine(struct rt_rtmp_adapter *pAd);
2814 BOOLEAN MlmeQueueEmpty(struct rt_mlme_queue *Queue);
2816 BOOLEAN MlmeQueueFull(struct rt_mlme_queue *Queue);
2818 BOOLEAN MsgTypeSubst(struct rt_rtmp_adapter *pAd,
2819 struct rt_frame_802_11 * pFrame,
2820 int * Machine, int * MsgType);
2822 void StateMachineInit(struct rt_state_machine *Sm,
2823 IN STATE_MACHINE_FUNC Trans[],
2825 unsigned long MsgNr,
2826 IN STATE_MACHINE_FUNC DefFunc,
2827 unsigned long InitState, unsigned long Base);
2829 void StateMachineSetAction(struct rt_state_machine *S,
2830 unsigned long St, unsigned long Msg, IN STATE_MACHINE_FUNC F);
2832 void StateMachinePerformAction(struct rt_rtmp_adapter *pAd,
2833 struct rt_state_machine *S, struct rt_mlme_queue_elem *Elem);
2835 void Drop(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2837 void AssocStateMachineInit(struct rt_rtmp_adapter *pAd,
2838 struct rt_state_machine *Sm,
2839 OUT STATE_MACHINE_FUNC Trans[]);
2841 void ReassocTimeout(void *SystemSpecific1,
2842 void *FunctionContext,
2843 void *SystemSpecific2, void *SystemSpecific3);
2845 void AssocTimeout(void *SystemSpecific1,
2846 void *FunctionContext,
2847 void *SystemSpecific2, void *SystemSpecific3);
2849 void DisassocTimeout(void *SystemSpecific1,
2850 void *FunctionContext,
2851 void *SystemSpecific2, void *SystemSpecific3);
2853 /*---------------------------------------------- */
2854 void MlmeAssocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2856 void MlmeReassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2858 void MlmeDisassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2860 void PeerAssocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2862 void PeerReassocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2864 void PeerDisassocAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2866 void DisassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2868 void AssocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2870 void ReassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2872 void Cls3errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr);
2874 void InvalidStateWhenAssoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2876 void InvalidStateWhenReassoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2878 void InvalidStateWhenDisassociate(struct rt_rtmp_adapter *pAd,
2879 struct rt_mlme_queue_elem *Elem);
2882 void MlmeCntlConfirm(struct rt_rtmp_adapter *pAd, unsigned long MsgType, u16 Msg);
2883 #endif /* RTMP_MAC_USB // */
2885 void ComposePsPoll(struct rt_rtmp_adapter *pAd);
2887 void ComposeNullFrame(struct rt_rtmp_adapter *pAd);
2889 void AssocPostProc(struct rt_rtmp_adapter *pAd,
2897 struct rt_edca_parm *pEdcaParm,
2898 struct rt_ht_capability_ie * pHtCapability,
2899 u8 HtCapabilityLen, struct rt_add_ht_info_ie * pAddHtInfo);
2901 void AuthStateMachineInit(struct rt_rtmp_adapter *pAd,
2902 struct rt_state_machine *sm, OUT STATE_MACHINE_FUNC Trans[]);
2904 void AuthTimeout(void *SystemSpecific1,
2905 void *FunctionContext,
2906 void *SystemSpecific2, void *SystemSpecific3);
2908 void MlmeAuthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2910 void PeerAuthRspAtSeq2Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2912 void PeerAuthRspAtSeq4Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2914 void AuthTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2916 void Cls2errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr);
2918 void MlmeDeauthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2920 void InvalidStateWhenAuth(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2922 /*============================================= */
2924 void AuthRspStateMachineInit(struct rt_rtmp_adapter *pAd,
2925 struct rt_state_machine *Sm,
2926 IN STATE_MACHINE_FUNC Trans[]);
2928 void PeerDeauthAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2930 void PeerAuthSimpleRspGenAndSend(struct rt_rtmp_adapter *pAd,
2931 struct rt_header_802_11 * pHdr80211,
2934 u16 Reason, u16 Status);
2937 /* Private routines in dls.c */
2940 /*======================================== */
2942 void SyncStateMachineInit(struct rt_rtmp_adapter *pAd,
2943 struct rt_state_machine *Sm,
2944 OUT STATE_MACHINE_FUNC Trans[]);
2946 void BeaconTimeout(void *SystemSpecific1,
2947 void *FunctionContext,
2948 void *SystemSpecific2, void *SystemSpecific3);
2950 void ScanTimeout(void *SystemSpecific1,
2951 void *FunctionContext,
2952 void *SystemSpecific2, void *SystemSpecific3);
2954 void InvalidStateWhenScan(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2956 void InvalidStateWhenJoin(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2958 void InvalidStateWhenStart(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2960 void EnqueueProbeRequest(struct rt_rtmp_adapter *pAd);
2962 BOOLEAN ScanRunning(struct rt_rtmp_adapter *pAd);
2963 /*========================================= */
2965 void MlmeCntlInit(struct rt_rtmp_adapter *pAd,
2966 struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[]);
2968 void MlmeCntlMachinePerformAction(struct rt_rtmp_adapter *pAd,
2969 struct rt_state_machine *S,
2970 struct rt_mlme_queue_elem *Elem);
2972 void CntlIdleProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2974 void CntlOidScanProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2976 void CntlOidSsidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2978 void CntlOidRTBssidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2980 void CntlMlmeRoamingProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2982 void CntlWaitDisassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2984 void CntlWaitJoinProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2986 void CntlWaitReassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2988 void CntlWaitStartProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2990 void CntlWaitAuthProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2992 void CntlWaitAuthProc2(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2994 void CntlWaitAssocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
2996 void LinkUp(struct rt_rtmp_adapter *pAd, u8 BssType);
2998 void LinkDown(struct rt_rtmp_adapter *pAd, IN BOOLEAN IsReqFromAP);
3000 void IterateOnBssTab(struct rt_rtmp_adapter *pAd);
3002 void IterateOnBssTab2(struct rt_rtmp_adapter *pAd);;
3004 void JoinParmFill(struct rt_rtmp_adapter *pAd,
3005 struct rt_mlme_join_req *JoinReq, unsigned long BssIdx);
3007 void AssocParmFill(struct rt_rtmp_adapter *pAd,
3008 struct rt_mlme_assoc_req *AssocReq,
3011 unsigned long Timeout, u16 ListenIntv);
3013 void ScanParmFill(struct rt_rtmp_adapter *pAd,
3014 struct rt_mlme_scan_req *ScanReq,
3016 u8 SsidLen, u8 BssType, u8 ScanType);
3018 void DisassocParmFill(struct rt_rtmp_adapter *pAd,
3019 struct rt_mlme_disassoc_req *DisassocReq,
3020 u8 *pAddr, u16 Reason);
3022 void StartParmFill(struct rt_rtmp_adapter *pAd,
3023 struct rt_mlme_start_req *StartReq,
3024 char Ssid[], u8 SsidLen);
3026 void AuthParmFill(struct rt_rtmp_adapter *pAd,
3027 struct rt_mlme_auth_req *AuthReq,
3028 u8 *pAddr, u16 Alg);
3030 void EnqueuePsPoll(struct rt_rtmp_adapter *pAd);
3032 void EnqueueBeaconFrame(struct rt_rtmp_adapter *pAd);
3034 void MlmeJoinReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3036 void MlmeScanReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3038 void MlmeStartReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3040 void ScanTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3042 void BeaconTimeoutAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3044 void PeerBeaconAtScanAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3046 void PeerBeaconAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3048 void PeerBeacon(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3050 void PeerProbeReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
3052 void ScanNextChannel(struct rt_rtmp_adapter *pAd);
3054 unsigned long MakeIbssBeacon(struct rt_rtmp_adapter *pAd);
3056 BOOLEAN MlmeScanReqSanity(struct rt_rtmp_adapter *pAd,
3058 unsigned long MsgLen,
3061 u8 * SsidLen, u8 * ScanType);
3063 BOOLEAN PeerBeaconAndProbeRspSanity(struct rt_rtmp_adapter *pAd,
3065 unsigned long MsgLen,
3072 u16 * pBeaconPeriod,
3075 OUT LARGE_INTEGER * pTimestamp,
3076 struct rt_cf_parm * pCfParm,
3078 u16 * pCapabilityInfo,
3089 u8 * pAironetCellPowerLimit,
3090 struct rt_edca_parm *pEdcaParm,
3091 struct rt_qbss_load_parm *pQbssLoad,
3092 struct rt_qos_capability_parm *pQosCapability,
3093 unsigned long * pRalinkIe,
3094 u8 * pHtCapabilityLen,
3095 u8 * pPreNHtCapabilityLen,
3096 struct rt_ht_capability_ie * pHtCapability,
3098 struct rt_add_ht_info_ie * AddHtInfo,
3101 struct rt_ndis_802_11_variable_ies *pVIE);
3103 BOOLEAN PeerAddBAReqActionSanity(struct rt_rtmp_adapter *pAd,
3105 unsigned long MsgLen, u8 *pAddr2);
3107 BOOLEAN PeerAddBARspActionSanity(struct rt_rtmp_adapter *pAd,
3108 void * pMsg, unsigned long MsgLen);
3110 BOOLEAN PeerDelBAActionSanity(struct rt_rtmp_adapter *pAd,
3111 u8 Wcid, void * pMsg, unsigned long MsgLen);
3113 BOOLEAN MlmeAssocReqSanity(struct rt_rtmp_adapter *pAd,
3115 unsigned long MsgLen,
3117 u16 * CapabilityInfo,
3118 unsigned long * Timeout, u16 * ListenIntv);
3120 BOOLEAN MlmeAuthReqSanity(struct rt_rtmp_adapter *pAd,
3122 unsigned long MsgLen,
3124 unsigned long * Timeout, u16 * Alg);
3126 BOOLEAN MlmeStartReqSanity(struct rt_rtmp_adapter *pAd,
3128 unsigned long MsgLen,
3129 char Ssid[], u8 * Ssidlen);
3131 BOOLEAN PeerAuthSanity(struct rt_rtmp_adapter *pAd,
3133 unsigned long MsgLen,
3137 u16 * Status, char ChlgText[]);
3139 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 */
3140 u8 * pHtCapabilityLen,
3142 u8 * pNewExtChannelOffset,
3143 struct rt_edca_parm *pEdcaParm, u8 * pCkipFlag);
3145 BOOLEAN PeerDisassocSanity(struct rt_rtmp_adapter *pAd,
3147 unsigned long MsgLen,
3148 u8 *pAddr2, u16 * Reason);
3150 BOOLEAN PeerWpaMessageSanity(struct rt_rtmp_adapter *pAd,
3151 struct rt_eapol_packet * pMsg,
3152 unsigned long MsgLen,
3153 u8 MsgType, struct rt_mac_table_entry *pEntry);
3155 BOOLEAN PeerDeauthSanity(struct rt_rtmp_adapter *pAd,
3157 unsigned long MsgLen,
3158 u8 *pAddr2, u16 * Reason);
3160 BOOLEAN PeerProbeReqSanity(struct rt_rtmp_adapter *pAd,
3162 unsigned long MsgLen,
3164 char Ssid[], u8 * pSsidLen);
3166 BOOLEAN GetTimBit(char * Ptr,
3171 u8 * DtimPeriod, u8 * MessageToMe);
3173 u8 ChannelSanity(struct rt_rtmp_adapter *pAd, u8 channel);
3175 NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(struct rt_bss_entry *pBss);
3177 BOOLEAN MlmeDelBAReqSanity(struct rt_rtmp_adapter *pAd,
3178 void * Msg, unsigned long MsgLen);
3180 BOOLEAN MlmeAddBAReqSanity(struct rt_rtmp_adapter *pAd,
3181 void * Msg, unsigned long MsgLen, u8 *pAddr2);
3183 unsigned long MakeOutgoingFrame(u8 * Buffer, unsigned long * Length, ...);
3185 void LfsrInit(struct rt_rtmp_adapter *pAd, unsigned long Seed);
3187 u8 RandomByte(struct rt_rtmp_adapter *pAd);
3189 void AsicUpdateAutoFallBackTable(struct rt_rtmp_adapter *pAd, u8 *pTxRate);
3191 void MlmePeriodicExec(void *SystemSpecific1,
3192 void *FunctionContext,
3193 void *SystemSpecific2, void *SystemSpecific3);
3195 void LinkDownExec(void *SystemSpecific1,
3196 void *FunctionContext,
3197 void *SystemSpecific2, void *SystemSpecific3);
3199 void STAMlmePeriodicExec(struct rt_rtmp_adapter *pAd);
3201 void MlmeAutoScan(struct rt_rtmp_adapter *pAd);
3203 void MlmeAutoReconnectLastSSID(struct rt_rtmp_adapter *pAd);
3205 BOOLEAN MlmeValidateSSID(u8 *pSsid, u8 SsidLen);
3207 void MlmeCheckForRoaming(struct rt_rtmp_adapter *pAd, unsigned long Now32);
3209 BOOLEAN MlmeCheckForFastRoaming(struct rt_rtmp_adapter *pAd);
3211 void MlmeDynamicTxRateSwitching(struct rt_rtmp_adapter *pAd);
3213 void MlmeSetTxRate(struct rt_rtmp_adapter *pAd,
3214 struct rt_mac_table_entry *pEntry, struct rt_rtmp_tx_rate_switch * pTxRate);
3216 void MlmeSelectTxRateTable(struct rt_rtmp_adapter *pAd,
3217 struct rt_mac_table_entry *pEntry,
3219 u8 *pTableSize, u8 *pInitTxRateIdx);
3221 void MlmeCalculateChannelQuality(struct rt_rtmp_adapter *pAd,
3222 struct rt_mac_table_entry *pMacEntry, unsigned long Now);
3224 void MlmeCheckPsmChange(struct rt_rtmp_adapter *pAd, unsigned long Now32);
3226 void MlmeSetPsmBit(struct rt_rtmp_adapter *pAd, u16 psm);
3228 void MlmeSetTxPreamble(struct rt_rtmp_adapter *pAd, u16 TxPreamble);
3230 void UpdateBasicRateBitmap(struct rt_rtmp_adapter *pAd);
3232 void MlmeUpdateTxRates(struct rt_rtmp_adapter *pAd,
3233 IN BOOLEAN bLinkUp, u8 apidx);
3235 void MlmeUpdateHtTxRates(struct rt_rtmp_adapter *pAd, u8 apidx);
3237 void RTMPCheckRates(struct rt_rtmp_adapter *pAd,
3238 IN u8 SupRate[], IN u8 * SupRateLen);
3240 BOOLEAN RTMPCheckChannel(struct rt_rtmp_adapter *pAd,
3241 u8 CentralChannel, u8 Channel);
3243 BOOLEAN RTMPCheckHt(struct rt_rtmp_adapter *pAd,
3245 struct rt_ht_capability_ie * pHtCapability,
3246 struct rt_add_ht_info_ie * pAddHtInfo);
3248 void StaQuickResponeForRateUpExec(void *SystemSpecific1,
3249 void *FunctionContext,
3250 void *SystemSpecific2,
3251 void *SystemSpecific3);
3253 void RTMPUpdateMlmeRate(struct rt_rtmp_adapter *pAd);
3255 char RTMPMaxRssi(struct rt_rtmp_adapter *pAd,
3256 char Rssi0, char Rssi1, char Rssi2);
3259 void AsicSetRxAnt(struct rt_rtmp_adapter *pAd, u8 Ant);
3261 void RTMPFilterCalibration(struct rt_rtmp_adapter *pAd);
3263 #ifdef RTMP_EFUSE_SUPPORT
3264 /*2008/09/11:KH add to support efuse<-- */
3265 int set_eFuseGetFreeBlockCount_Proc(struct rt_rtmp_adapter *pAd, char *arg);
3267 int set_eFusedump_Proc(struct rt_rtmp_adapter *pAd, char *arg);
3269 void eFusePhysicalReadRegisters(struct rt_rtmp_adapter *pAd,
3271 u16 Length, u16 * pData);
3273 int RtmpEfuseSupportCheck(struct rt_rtmp_adapter *pAd);
3275 void eFuseGetFreeBlockCount(struct rt_rtmp_adapter *pAd, u32 *EfuseFreeBlock);
3277 int eFuse_init(struct rt_rtmp_adapter *pAd);
3278 /*2008/09/11:KH add to support efuse--> */
3279 #endif /* RTMP_EFUSE_SUPPORT // */
3281 /* add by johnli, RF power sequence setup */
3282 void RT30xxLoadRFNormalModeSetup(struct rt_rtmp_adapter *pAd);
3284 void RT30xxLoadRFSleepModeSetup(struct rt_rtmp_adapter *pAd);
3286 void RT30xxReverseRFSleepModeSetup(struct rt_rtmp_adapter *pAd);
3290 void NICInitRT3070RFRegisters(struct rt_rtmp_adapter *pAd);
3291 #endif /* RT3070 // */
3293 void NICInitRT3090RFRegisters(struct rt_rtmp_adapter *pAd);
3294 #endif /* RT3090 // */
3296 void RT30xxHaltAction(struct rt_rtmp_adapter *pAd);
3298 void RT30xxSetRxAnt(struct rt_rtmp_adapter *pAd, u8 Ant);
3299 #endif /* RT30xx // */
3301 void AsicEvaluateRxAnt(struct rt_rtmp_adapter *pAd);
3303 void AsicRxAntEvalTimeout(void *SystemSpecific1,
3304 void *FunctionContext,
3305 void *SystemSpecific2, void *SystemSpecific3);
3307 void APSDPeriodicExec(void *SystemSpecific1,
3308 void *FunctionContext,
3309 void *SystemSpecific2, void *SystemSpecific3);
3311 BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(struct rt_rtmp_adapter *pAd,
3312 struct rt_mac_table_entry *pEntry);
3314 u8 RTMPStaFixedTxMode(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
3316 void RTMPUpdateLegacyTxSetting(u8 fixed_tx_mode, struct rt_mac_table_entry *pEntry);
3318 BOOLEAN RTMPAutoRateSwitchCheck(struct rt_rtmp_adapter *pAd);
3320 int MlmeInit(struct rt_rtmp_adapter *pAd);
3322 void MlmeHandler(struct rt_rtmp_adapter *pAd);
3324 void MlmeHalt(struct rt_rtmp_adapter *pAd);
3326 void MlmeResetRalinkCounters(struct rt_rtmp_adapter *pAd);
3328 void BuildChannelList(struct rt_rtmp_adapter *pAd);
3330 u8 FirstChannel(struct rt_rtmp_adapter *pAd);
3332 u8 NextChannel(struct rt_rtmp_adapter *pAd, u8 channel);
3334 void ChangeToCellPowerLimit(struct rt_rtmp_adapter *pAd,
3335 u8 AironetCellPowerLimit);
3338 /* Prototypes of function definition in rtmp_tkip.c */
3340 void RTMPInitTkipEngine(struct rt_rtmp_adapter *pAd,
3345 u8 *pTSC, unsigned long *pIV16, unsigned long *pIV32);
3347 void RTMPInitMICEngine(struct rt_rtmp_adapter *pAd,
3350 u8 *pSA, u8 UserPriority, u8 *pMICKey);
3352 BOOLEAN RTMPTkipCompareMICValue(struct rt_rtmp_adapter *pAd,
3357 u8 UserPriority, u32 Len);
3359 void RTMPCalculateMICValue(struct rt_rtmp_adapter *pAd,
3362 struct rt_cipher_key *pKey, u8 apidx);
3364 void RTMPTkipAppendByte(struct rt_tkip_key_info *pTkip, u8 uChar);
3366 void RTMPTkipAppend(struct rt_tkip_key_info *pTkip, u8 *pSrc, u32 nBytes);
3368 void RTMPTkipGetMIC(struct rt_tkip_key_info *pTkip);
3370 BOOLEAN RTMPSoftDecryptTKIP(struct rt_rtmp_adapter *pAd,
3372 unsigned long DataByteCnt,
3373 u8 UserPriority, struct rt_cipher_key *pWpaKey);
3375 BOOLEAN RTMPSoftDecryptAES(struct rt_rtmp_adapter *pAd,
3377 unsigned long DataByteCnt, struct rt_cipher_key *pWpaKey);
3380 /* Prototypes of function definition in cmm_info.c */
3382 int RT_CfgSetCountryRegion(struct rt_rtmp_adapter *pAd, char *arg, int band);
3384 int RT_CfgSetWirelessMode(struct rt_rtmp_adapter *pAd, char *arg);
3386 int RT_CfgSetShortSlot(struct rt_rtmp_adapter *pAd, char *arg);
3388 int RT_CfgSetWepKey(struct rt_rtmp_adapter *pAd,
3390 struct rt_cipher_key *pSharedKey, int keyIdx);
3392 int RT_CfgSetWPAPSKKey(struct rt_rtmp_adapter *pAd,
3395 int hashStrLen, u8 *pPMKBuf);
3398 /* Prototypes of function definition in cmm_info.c */
3400 void RTMPWPARemoveAllKeys(struct rt_rtmp_adapter *pAd);
3402 void RTMPSetPhyMode(struct rt_rtmp_adapter *pAd, unsigned long phymode);
3404 void RTMPUpdateHTIE(struct rt_ht_capability *pRtHt,
3406 struct rt_ht_capability_ie * pHtCapability,
3407 struct rt_add_ht_info_ie * pAddHtInfo);
3409 void RTMPAddWcidAttributeEntry(struct rt_rtmp_adapter *pAd,
3412 u8 CipherAlg, struct rt_mac_table_entry *pEntry);
3414 char *GetEncryptType(char enc);
3416 char *GetAuthMode(char auth);
3418 void RTMPSetHT(struct rt_rtmp_adapter *pAd, struct rt_oid_set_ht_phymode *pHTPhyMode);
3420 void RTMPSetIndividualHT(struct rt_rtmp_adapter *pAd, u8 apidx);
3422 void RTMPSendWirelessEvent(struct rt_rtmp_adapter *pAd,
3424 u8 *pAddr, u8 BssIdx, char Rssi);
3426 char ConvertToRssi(struct rt_rtmp_adapter *pAd, char Rssi, u8 RssiNumber);
3428 /*===================================
3429 Function prototype in cmm_wpa.c
3430 =================================== */
3431 void RTMPToWirelessSta(struct rt_rtmp_adapter *pAd,
3432 struct rt_mac_table_entry *pEntry,
3436 u32 DataLen, IN BOOLEAN bClearFrame);
3438 void WpaDerivePTK(struct rt_rtmp_adapter *pAd,
3443 u8 * SA, u8 * output, u32 len);
3445 void GenRandom(struct rt_rtmp_adapter *pAd, u8 * macAddr, u8 * random);
3447 BOOLEAN RTMPCheckWPAframe(struct rt_rtmp_adapter *pAd,
3448 struct rt_mac_table_entry *pEntry,
3450 unsigned long DataByteCount, u8 FromWhichBSSID);
3452 void AES_GTK_KEY_UNWRAP(u8 * key,
3454 u32 c_len, u8 * ciphertext);
3456 BOOLEAN RTMPParseEapolKeyData(struct rt_rtmp_adapter *pAd,
3461 IN BOOLEAN bWPA2, struct rt_mac_table_entry *pEntry);
3463 void ConstructEapolMsg(struct rt_mac_table_entry *pEntry,
3464 u8 GroupKeyWepStatus,
3471 u8 RSNIE_Len, struct rt_eapol_packet * pMsg);
3473 int RTMPSoftDecryptBroadCastData(struct rt_rtmp_adapter *pAd,
3474 struct rt_rx_blk *pRxBlk,
3475 IN NDIS_802_11_ENCRYPTION_STATUS
3477 struct rt_cipher_key *pShard_key);
3479 void RTMPMakeRSNIE(struct rt_rtmp_adapter *pAd,
3480 u32 AuthMode, u32 WepStatus, u8 apidx);
3483 /* function prototype in ap_wpa.c */
3485 void RTMPGetTxTscFromAsic(struct rt_rtmp_adapter *pAd,
3486 u8 apidx, u8 *pTxTsc);
3488 void APInstallPairwiseKey(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
3490 u32 APValidateRSNIE(struct rt_rtmp_adapter *pAd,
3491 struct rt_mac_table_entry *pEntry,
3492 u8 *pRsnIe, u8 rsnie_len);
3494 void HandleCounterMeasure(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
3496 void WPAStart4WayHS(struct rt_rtmp_adapter *pAd,
3497 struct rt_mac_table_entry *pEntry, unsigned long TimeInterval);
3499 void WPAStart2WayGroupHS(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
3501 void PeerPairMsg1Action(struct rt_rtmp_adapter *pAd,
3502 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3504 void PeerPairMsg2Action(struct rt_rtmp_adapter *pAd,
3505 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3507 void PeerPairMsg3Action(struct rt_rtmp_adapter *pAd,
3508 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3510 void PeerPairMsg4Action(struct rt_rtmp_adapter *pAd,
3511 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3513 void PeerGroupMsg1Action(struct rt_rtmp_adapter *pAd,
3514 struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
3516 void PeerGroupMsg2Action(struct rt_rtmp_adapter *pAd,
3517 struct rt_mac_table_entry *pEntry,
3518 void * Msg, u32 MsgLen);
3520 void WpaDeriveGTK(u8 * PMK,
3522 u8 * AA, u8 * output, u32 len);
3524 void AES_GTK_KEY_WRAP(u8 * key,
3526 u32 p_len, u8 * ciphertext);
3528 /*typedef void (*TIMER_FUNCTION)(unsigned long); */
3531 void RTMP_SetPeriodicTimer(struct timer_list * pTimer,
3532 IN unsigned long timeout);
3534 void RTMP_OS_Init_Timer(struct rt_rtmp_adapter *pAd,
3535 struct timer_list * pTimer,
3536 IN TIMER_FUNCTION function, void *data);
3538 void RTMP_OS_Add_Timer(struct timer_list * pTimer,
3539 IN unsigned long timeout);
3541 void RTMP_OS_Mod_Timer(struct timer_list * pTimer,
3542 IN unsigned long timeout);
3544 void RTMP_OS_Del_Timer(struct timer_list * pTimer,
3545 OUT BOOLEAN * pCancelled);
3547 void RTMP_OS_Release_Packet(struct rt_rtmp_adapter *pAd, struct rt_queue_entry *pEntry);
3549 void RTMPusecDelay(unsigned long usec);
3551 int os_alloc_mem(struct rt_rtmp_adapter *pAd,
3552 u8 ** mem, unsigned long size);
3554 int os_free_mem(struct rt_rtmp_adapter *pAd, void *mem);
3556 void RTMP_AllocateSharedMemory(struct rt_rtmp_adapter *pAd,
3557 unsigned long Length,
3559 void ** VirtualAddress,
3560 dma_addr_t *PhysicalAddress);
3562 void RTMPFreeTxRxRingMemory(struct rt_rtmp_adapter *pAd);
3564 int AdapterBlockAllocateMemory(void *handle, void ** ppAd);
3566 void RTMP_AllocateTxDescMemory(struct rt_rtmp_adapter *pAd,
3568 unsigned long Length,
3570 void ** VirtualAddress,
3571 dma_addr_t *PhysicalAddress);
3573 void RTMP_AllocateFirstTxBuffer(struct rt_rtmp_adapter *pAd,
3575 unsigned long Length,
3577 void ** VirtualAddress,
3578 dma_addr_t *PhysicalAddress);
3580 void RTMP_FreeFirstTxBuffer(struct rt_rtmp_adapter *pAd,
3581 unsigned long Length,
3583 void *VirtualAddress,
3584 dma_addr_t PhysicalAddress);
3586 void RTMP_AllocateMgmtDescMemory(struct rt_rtmp_adapter *pAd,
3587 unsigned long Length,
3589 void ** VirtualAddress,
3590 dma_addr_t *PhysicalAddress);
3592 void RTMP_AllocateRxDescMemory(struct rt_rtmp_adapter *pAd,
3593 unsigned long Length,
3595 void ** VirtualAddress,
3596 dma_addr_t *PhysicalAddress);
3598 void RTMP_FreeDescMemory(struct rt_rtmp_adapter *pAd,
3599 unsigned long Length,
3600 void *VirtualAddress,
3601 dma_addr_t PhysicalAddress);
3603 void *RtmpOSNetPktAlloc(struct rt_rtmp_adapter *pAd, IN int size);
3605 void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd,
3606 unsigned long Length,
3608 void ** VirtualAddress,
3612 void *RTMP_AllocateTxPacketBuffer(struct rt_rtmp_adapter *pAd,
3613 unsigned long Length,
3615 void ** VirtualAddress);
3617 void *RTMP_AllocateFragPacketBuffer(struct rt_rtmp_adapter *pAd,
3618 unsigned long Length);
3620 void RTMP_QueryPacketInfo(void *pPacket,
3621 struct rt_packet_info *pPacketInfo,
3622 u8 ** pSrcBufVA, u32 * pSrcBufLen);
3624 void RTMP_QueryNextPacketInfo(void ** ppPacket,
3625 struct rt_packet_info *pPacketInfo,
3626 u8 ** pSrcBufVA, u32 * pSrcBufLen);
3628 BOOLEAN RTMP_FillTxBlkInfo(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk);
3630 struct rt_rtmp_sg_list *
3631 rt_get_sg_list_from_packet(void *pPacket, struct rt_rtmp_sg_list *sg);
3633 void announce_802_3_packet(struct rt_rtmp_adapter *pAd, void *pPacket);
3635 u32 BA_Reorder_AMSDU_Annnounce(struct rt_rtmp_adapter *pAd, void *pPacket);
3637 struct net_device *get_netdev_from_bssid(struct rt_rtmp_adapter *pAd, u8 FromWhichBSSID);
3639 void *duplicate_pkt(struct rt_rtmp_adapter *pAd,
3643 unsigned long DataSize, u8 FromWhichBSSID);
3645 void *duplicate_pkt_with_TKIP_MIC(struct rt_rtmp_adapter *pAd,
3648 void ba_flush_reordering_timeout_mpdus(struct rt_rtmp_adapter *pAd,
3649 struct rt_ba_rec_entry *pBAEntry,
3650 unsigned long Now32);
3652 void BAOriSessionSetUp(struct rt_rtmp_adapter *pAd,
3653 struct rt_mac_table_entry *pEntry,
3656 unsigned long DelayTime, IN BOOLEAN isForced);
3658 void BASessionTearDownALL(struct rt_rtmp_adapter *pAd, u8 Wcid);
3660 BOOLEAN OS_Need_Clone_Packet(void);
3662 void build_tx_packet(struct rt_rtmp_adapter *pAd,
3664 u8 *pFrame, unsigned long FrameLen);
3666 void BAOriSessionTearDown(struct rt_rtmp_adapter *pAd,
3669 IN BOOLEAN bPassive, IN BOOLEAN bForceSend);
3671 void BARecSessionTearDown(struct rt_rtmp_adapter *pAd,
3672 u8 Wcid, u8 TID, IN BOOLEAN bPassive);
3674 BOOLEAN ba_reordering_resource_init(struct rt_rtmp_adapter *pAd, int num);
3675 void ba_reordering_resource_release(struct rt_rtmp_adapter *pAd);
3677 char *rstrtok(char *s, IN const char *ct);
3679 /*//////// common ioctl functions ////////// */
3680 int SetCommonHT(struct rt_rtmp_adapter *pAd);
3682 int WpaCheckEapCode(struct rt_rtmp_adapter *pAd,
3683 u8 *pFrame, u16 FrameLen, u16 OffSet);
3685 void WpaSendMicFailureToWpaSupplicant(struct rt_rtmp_adapter *pAd,
3686 IN BOOLEAN bUnicast);
3688 int wext_notify_event_assoc(struct rt_rtmp_adapter *pAd);
3690 BOOLEAN STARxDoneInterruptHandle(struct rt_rtmp_adapter *pAd, IN BOOLEAN argc);
3692 /* AMPDU packet indication */
3693 void Indicate_AMPDU_Packet(struct rt_rtmp_adapter *pAd,
3694 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3696 /* AMSDU packet indication */
3697 void Indicate_AMSDU_Packet(struct rt_rtmp_adapter *pAd,
3698 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3700 /* Normal legacy Rx packet indication */
3701 void Indicate_Legacy_Packet(struct rt_rtmp_adapter *pAd,
3702 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3704 void Indicate_EAPOL_Packet(struct rt_rtmp_adapter *pAd,
3705 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3707 void update_os_packet_info(struct rt_rtmp_adapter *pAd,
3708 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3710 void wlan_802_11_to_802_3_packet(struct rt_rtmp_adapter *pAd,
3711 struct rt_rx_blk *pRxBlk,
3715 /* remove LLC and get 802_3 Header */
3716 #define RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(_pRxBlk, _pHeader802_3) \
3718 u8 *_pRemovedLLCSNAP = NULL, *_pDA, *_pSA; \
3720 if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_MESH)) \
3722 _pDA = _pRxBlk->pHeader->Addr3; \
3723 _pSA = (u8 *)_pRxBlk->pHeader + sizeof(struct rt_header_802_11); \
3727 if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_INFRA)) \
3729 _pDA = _pRxBlk->pHeader->Addr1; \
3730 if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_DLS)) \
3731 _pSA = _pRxBlk->pHeader->Addr2; \
3733 _pSA = _pRxBlk->pHeader->Addr3; \
3737 _pDA = _pRxBlk->pHeader->Addr1; \
3738 _pSA = _pRxBlk->pHeader->Addr2; \
3742 CONVERT_TO_802_3(_pHeader802_3, _pDA, _pSA, _pRxBlk->pData, \
3743 _pRxBlk->DataSize, _pRemovedLLCSNAP); \
3746 void Sta_Announce_or_Forward_802_3_Packet(struct rt_rtmp_adapter *pAd,
3750 #define ANNOUNCE_OR_FORWARD_802_3_PACKET(_pAd, _pPacket, _FromWhichBSS)\
3751 Sta_Announce_or_Forward_802_3_Packet(_pAd, _pPacket, _FromWhichBSS);
3752 /*announce_802_3_packet(_pAd, _pPacket); */
3754 void *DuplicatePacket(struct rt_rtmp_adapter *pAd,
3755 void *pPacket, u8 FromWhichBSSID);
3757 void *ClonePacket(struct rt_rtmp_adapter *pAd,
3759 u8 *pData, unsigned long DataSize);
3761 /* Normal, AMPDU or AMSDU */
3762 void CmmRxnonRalinkFrameIndicate(struct rt_rtmp_adapter *pAd,
3763 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3765 void CmmRxRalinkFrameIndicate(struct rt_rtmp_adapter *pAd,
3766 struct rt_mac_table_entry *pEntry,
3767 struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
3769 void Update_Rssi_Sample(struct rt_rtmp_adapter *pAd,
3770 struct rt_rssi_sample *pRssi, struct rt_rxwi * pRxWI);
3772 void *GetPacketFromRxRing(struct rt_rtmp_adapter *pAd,
3773 OUT PRT28XX_RXD_STRUC pSaveRxD,
3774 OUT BOOLEAN * pbReschedule,
3775 IN u32 * pRxPending);
3777 void *RTMPDeFragmentDataFrame(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk);
3780 DIDmsg_lnxind_wlansniffrm = 0x00000044,
3781 DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044,
3782 DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044,
3783 DIDmsg_lnxind_wlansniffrm_channel = 0x00030044,
3784 DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044,
3785 DIDmsg_lnxind_wlansniffrm_sq = 0x00050044,
3786 DIDmsg_lnxind_wlansniffrm_signal = 0x00060044,
3787 DIDmsg_lnxind_wlansniffrm_noise = 0x00070044,
3788 DIDmsg_lnxind_wlansniffrm_rate = 0x00080044,
3789 DIDmsg_lnxind_wlansniffrm_istx = 0x00090044,
3790 DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044
3793 P80211ENUM_msgitem_status_no_value = 0x00
3796 P80211ENUM_truth_false = 0x00,
3797 P80211ENUM_truth_true = 0x01
3800 /* Definition from madwifi */
3801 struct rt_p80211item_uint32 {
3808 struct rt_wlan_ng_prism2_header {
3811 #define WLAN_DEVNAMELEN_MAX 16
3812 u8 devname[WLAN_DEVNAMELEN_MAX];
3813 struct rt_p80211item_uint32 hosttime;
3814 struct rt_p80211item_uint32 mactime;
3815 struct rt_p80211item_uint32 channel;
3816 struct rt_p80211item_uint32 rssi;
3817 struct rt_p80211item_uint32 sq;
3818 struct rt_p80211item_uint32 signal;
3819 struct rt_p80211item_uint32 noise;
3820 struct rt_p80211item_uint32 rate;
3821 struct rt_p80211item_uint32 istx;
3822 struct rt_p80211item_uint32 frmlen;
3825 /* The radio capture header precedes the 802.11 header. */
3826 struct PACKED rt_ieee80211_radiotap_header {
3827 u8 it_version; /* Version 0. Only increases
3828 * for drastic changes,
3829 * introduction of compatible
3830 * new fields does not count.
3833 u16 it_len; /* length of the whole
3834 * header in bytes, including
3835 * it_version, it_pad,
3836 * it_len, and data fields.
3838 u32 it_present; /* A bitmap telling which
3839 * fields are present. Set bit 31
3840 * (0x80000000) to extend the
3841 * bitmap by another 32 bits.
3842 * Additional extensions are made
3843 * by setting bit 31.
3847 enum ieee80211_radiotap_type {
3848 IEEE80211_RADIOTAP_TSFT = 0,
3849 IEEE80211_RADIOTAP_FLAGS = 1,
3850 IEEE80211_RADIOTAP_RATE = 2,
3851 IEEE80211_RADIOTAP_CHANNEL = 3,
3852 IEEE80211_RADIOTAP_FHSS = 4,
3853 IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
3854 IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
3855 IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
3856 IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
3857 IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
3858 IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
3859 IEEE80211_RADIOTAP_ANTENNA = 11,
3860 IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
3861 IEEE80211_RADIOTAP_DB_ANTNOISE = 13
3864 #define WLAN_RADIOTAP_PRESENT ( \
3865 (1 << IEEE80211_RADIOTAP_TSFT) | \
3866 (1 << IEEE80211_RADIOTAP_FLAGS) | \
3867 (1 << IEEE80211_RADIOTAP_RATE) | \
3870 struct rt_wlan_radiotap_header {
3871 struct rt_ieee80211_radiotap_header wt_ihdr;
3876 /* Definition from madwifi */
3878 void send_monitor_packets(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk);
3880 void RTMPSetDesiredRates(struct rt_rtmp_adapter *pAdapter, long Rates);
3882 int Set_FixedTxMode_Proc(struct rt_rtmp_adapter *pAd, char *arg);
3884 BOOLEAN RT28XXChipsetCheck(IN void *_dev_p);
3886 void RT28XXDMADisable(struct rt_rtmp_adapter *pAd);
3888 void RT28XXDMAEnable(struct rt_rtmp_adapter *pAd);
3890 void RT28xx_UpdateBeaconToAsic(struct rt_rtmp_adapter *pAd,
3892 unsigned long BeaconLen, unsigned long UpdatePos);
3894 int rt28xx_init(struct rt_rtmp_adapter *pAd,
3895 char *pDefaultMac, char *pHostName);
3897 int RtmpNetTaskInit(struct rt_rtmp_adapter *pAd);
3899 void RtmpNetTaskExit(struct rt_rtmp_adapter *pAd);
3901 int RtmpMgmtTaskInit(struct rt_rtmp_adapter *pAd);
3903 void RtmpMgmtTaskExit(struct rt_rtmp_adapter *pAd);
3905 void tbtt_tasklet(unsigned long data);
3907 struct net_device *RtmpPhyNetDevInit(struct rt_rtmp_adapter *pAd,
3908 struct rt_rtmp_os_netdev_op_hook *pNetHook);
3910 BOOLEAN RtmpPhyNetDevExit(struct rt_rtmp_adapter *pAd, struct net_device *net_dev);
3912 int RtmpRaDevCtrlInit(struct rt_rtmp_adapter *pAd, IN RTMP_INF_TYPE infType);
3914 BOOLEAN RtmpRaDevCtrlExit(struct rt_rtmp_adapter *pAd);
3918 /* Function Prototype in cmm_data_pci.c */
3920 u16 RtmpPCI_WriteTxResource(struct rt_rtmp_adapter *pAd,
3921 struct rt_tx_blk *pTxBlk,
3922 IN BOOLEAN bIsLast, u16 * FreeNumber);
3924 u16 RtmpPCI_WriteSingleTxResource(struct rt_rtmp_adapter *pAd,
3925 struct rt_tx_blk *pTxBlk,
3929 u16 RtmpPCI_WriteMultiTxResource(struct rt_rtmp_adapter *pAd,
3930 struct rt_tx_blk *pTxBlk,
3931 u8 frameNum, u16 * FreeNumber);
3933 u16 RtmpPCI_WriteFragTxResource(struct rt_rtmp_adapter *pAd,
3934 struct rt_tx_blk *pTxBlk,
3935 u8 fragNum, u16 * FreeNumber);
3937 u16 RtmpPCI_WriteSubTxResource(struct rt_rtmp_adapter *pAd,
3938 struct rt_tx_blk *pTxBlk,
3939 IN BOOLEAN bIsLast, u16 * FreeNumber);
3941 void RtmpPCI_FinalWriteTxResource(struct rt_rtmp_adapter *pAd,
3942 struct rt_tx_blk *pTxBlk,
3946 void RtmpPCIDataLastTxIdx(struct rt_rtmp_adapter *pAd,
3947 u8 QueIdx, u16 LastTxIdx);
3949 void RtmpPCIDataKickOut(struct rt_rtmp_adapter *pAd,
3950 struct rt_tx_blk *pTxBlk, u8 QueIdx);
3952 int RtmpPCIMgmtKickOut(struct rt_rtmp_adapter *pAd,
3955 u8 *pSrcBufVA, u32 SrcBufLen);
3957 int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
3958 struct rt_header_802_11 * pHeader,
3959 struct rt_rxwi * pRxWI, IN PRT28XX_RXD_STRUC pRxD);
3961 BOOLEAN RT28xxPciAsicRadioOff(struct rt_rtmp_adapter *pAd,
3962 u8 Level, u16 TbttNumToNextWakeUp);
3964 BOOLEAN RT28xxPciAsicRadioOn(struct rt_rtmp_adapter *pAd, u8 Level);
3966 void RTMPInitPCIeLinkCtrlValue(struct rt_rtmp_adapter *pAd);
3968 void RTMPFindHostPCIDev(struct rt_rtmp_adapter *pAd);
3970 void RTMPPCIeLinkCtrlValueRestore(struct rt_rtmp_adapter *pAd, u8 Level);
3972 void RTMPPCIeLinkCtrlSetting(struct rt_rtmp_adapter *pAd, u16 Max);
3974 void RTMPrt3xSetPCIePowerLinkCtrl(struct rt_rtmp_adapter *pAd);
3976 void PsPollWakeExec(void *SystemSpecific1,
3977 void *FunctionContext,
3978 void *SystemSpecific2, void *SystemSpecific3);
3980 void RadioOnExec(void *SystemSpecific1,
3981 void *FunctionContext,
3982 void *SystemSpecific2, void *SystemSpecific3);
3984 void RT28xxPciStaAsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
3986 void RT28xxPciStaAsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
3987 u16 TbttNumToNextWakeUp);
3989 void RT28xxPciMlmeRadioOn(struct rt_rtmp_adapter *pAd);
3991 void RT28xxPciMlmeRadioOFF(struct rt_rtmp_adapter *pAd);
3992 #endif /* RTMP_MAC_PCI // */
3996 /* Function Prototype in rtusb_bulk.c */
3998 void RTUSBInitTxDesc(struct rt_rtmp_adapter *pAd,
3999 struct rt_tx_context *pTxContext,
4000 u8 BulkOutPipeId, IN usb_complete_t Func);
4002 void RTUSBInitHTTxDesc(struct rt_rtmp_adapter *pAd,
4003 struct rt_ht_tx_context *pTxContext,
4005 unsigned long BulkOutSize, IN usb_complete_t Func);
4007 void RTUSBInitRxDesc(struct rt_rtmp_adapter *pAd, struct rt_rx_context *pRxContext);
4009 void RTUSBCleanUpDataBulkOutQueue(struct rt_rtmp_adapter *pAd);
4011 void RTUSBCancelPendingBulkOutIRP(struct rt_rtmp_adapter *pAd);
4013 void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd,
4014 u8 BulkOutPipeId, u8 Index);
4016 void RTUSBBulkOutNullFrame(struct rt_rtmp_adapter *pAd);
4018 void RTUSBBulkOutRTSFrame(struct rt_rtmp_adapter *pAd);
4020 void RTUSBCancelPendingBulkInIRP(struct rt_rtmp_adapter *pAd);
4022 void RTUSBCancelPendingIRPs(struct rt_rtmp_adapter *pAd);
4024 void RTUSBBulkOutMLMEPacket(struct rt_rtmp_adapter *pAd, u8 Index);
4026 void RTUSBBulkOutPsPoll(struct rt_rtmp_adapter *pAd);
4028 void RTUSBCleanUpMLMEBulkOutQueue(struct rt_rtmp_adapter *pAd);
4030 void RTUSBKickBulkOut(struct rt_rtmp_adapter *pAd);
4032 void RTUSBBulkReceive(struct rt_rtmp_adapter *pAd);
4034 void DoBulkIn(struct rt_rtmp_adapter *pAd);
4036 void RTUSBInitRxDesc(struct rt_rtmp_adapter *pAd, struct rt_rx_context *pRxContext);
4038 void RTUSBBulkRxHandle(IN unsigned long data);
4041 /* Function Prototype in rtusb_io.c */
4043 int RTUSBMultiRead(struct rt_rtmp_adapter *pAd,
4044 u16 Offset, u8 *pData, u16 length);
4046 int RTUSBMultiWrite(struct rt_rtmp_adapter *pAd,
4047 u16 Offset, const u8 *pData, u16 length);
4049 int RTUSBMultiWrite_OneByte(struct rt_rtmp_adapter *pAd,
4050 u16 Offset, const u8 *pData);
4052 int RTUSBReadBBPRegister(struct rt_rtmp_adapter *pAd,
4055 int RTUSBWriteBBPRegister(struct rt_rtmp_adapter *pAd,
4058 int RTUSBWriteRFRegister(struct rt_rtmp_adapter *pAd, u32 Value);
4060 int RTUSB_VendorRequest(struct rt_rtmp_adapter *pAd,
4066 void *TransferBuffer,
4067 u32 TransferBufferLength);
4069 int RTUSBReadEEPROM(struct rt_rtmp_adapter *pAd,
4070 u16 Offset, u8 *pData, u16 length);
4072 int RTUSBWriteEEPROM(struct rt_rtmp_adapter *pAd,
4073 u16 Offset, u8 *pData, u16 length);
4075 void RTUSBPutToSleep(struct rt_rtmp_adapter *pAd);
4077 int RTUSBWakeUp(struct rt_rtmp_adapter *pAd);
4079 void RTUSBInitializeCmdQ(struct rt_cmdq *cmdq);
4081 int RTUSBEnqueueCmdFromNdis(struct rt_rtmp_adapter *pAd,
4083 IN BOOLEAN SetInformation,
4084 void *pInformationBuffer,
4085 u32 InformationBufferLength);
4087 int RTUSBEnqueueInternalCmd(struct rt_rtmp_adapter *pAd,
4089 void *pInformationBuffer,
4090 u32 InformationBufferLength);
4092 void RTUSBDequeueCmd(struct rt_cmdq *cmdq, struct rt_cmdqelmt * * pcmdqelmt);
4094 int RTUSBCmdThread(IN void *Context);
4096 void RTUSBBssBeaconExit(struct rt_rtmp_adapter *pAd);
4098 void RTUSBBssBeaconStop(struct rt_rtmp_adapter *pAd);
4100 void RTUSBBssBeaconStart(struct rt_rtmp_adapter *pAd);
4102 void RTUSBBssBeaconInit(struct rt_rtmp_adapter *pAd);
4104 void RTUSBWatchDog(struct rt_rtmp_adapter *pAd);
4106 int RTUSBWriteMACRegister(struct rt_rtmp_adapter *pAd,
4107 u16 Offset, u32 Value);
4109 int RTUSBReadMACRegister(struct rt_rtmp_adapter *pAd,
4110 u16 Offset, u32 *pValue);
4112 int RTUSBSingleWrite(struct rt_rtmp_adapter *pAd,
4113 u16 Offset, u16 Value);
4115 int RTUSBFirmwareWrite(struct rt_rtmp_adapter *pAd,
4116 const u8 *pFwImage, unsigned long FwLen);
4118 int RTUSBVenderReset(struct rt_rtmp_adapter *pAd);
4120 int RTUSBSetHardWareRegister(struct rt_rtmp_adapter *pAdapter, void *pBuf);
4122 int RTUSBQueryHardWareRegister(struct rt_rtmp_adapter *pAdapter,
4125 void CMDHandler(struct rt_rtmp_adapter *pAd);
4127 int RTUSBWriteHWMACAddress(struct rt_rtmp_adapter *pAdapter);
4129 void MacTableInitialize(struct rt_rtmp_adapter *pAd);
4131 void MlmeSetPsm(struct rt_rtmp_adapter *pAd, u16 psm);
4133 int RTMPWPAAddKeyProc(struct rt_rtmp_adapter *pAd, void *pBuf);
4135 void AsicRxAntEvalAction(struct rt_rtmp_adapter *pAd);
4137 void append_pkt(struct rt_rtmp_adapter *pAd,
4141 unsigned long DataSize, void ** ppPacket);
4143 u32 deaggregate_AMSDU_announce(struct rt_rtmp_adapter *pAd,
4145 u8 *pData, unsigned long DataSize);
4147 int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
4148 struct rt_header_802_11 * pHeader,
4149 struct rt_rxwi * pRxWI,
4150 IN PRT28XX_RXD_STRUC pRxINFO);
4152 void RTUSBMlmeHardTransmit(struct rt_rtmp_adapter *pAd, struct rt_mgmt *pMgmt);
4154 int MlmeThread(void *Context);
4157 /* Function Prototype in rtusb_data.c */
4159 int RTUSBFreeDescriptorRequest(struct rt_rtmp_adapter *pAd,
4161 u32 NumberRequired);
4163 BOOLEAN RTUSBNeedQueueBackForAgg(struct rt_rtmp_adapter *pAd, u8 BulkOutPipeId);
4165 void RTMPWriteTxInfo(struct rt_rtmp_adapter *pAd,
4166 struct rt_txinfo *pTxInfo,
4169 u8 QueueSel, u8 NextValid, u8 TxBurst);
4172 /* Function Prototype in cmm_data_usb.c */
4174 u16 RtmpUSB_WriteSubTxResource(struct rt_rtmp_adapter *pAd,
4175 struct rt_tx_blk *pTxBlk,
4176 IN BOOLEAN bIsLast, u16 * FreeNumber);
4178 u16 RtmpUSB_WriteSingleTxResource(struct rt_rtmp_adapter *pAd,
4179 struct rt_tx_blk *pTxBlk,
4183 u16 RtmpUSB_WriteFragTxResource(struct rt_rtmp_adapter *pAd,
4184 struct rt_tx_blk *pTxBlk,
4185 u8 fragNum, u16 * FreeNumber);
4187 u16 RtmpUSB_WriteMultiTxResource(struct rt_rtmp_adapter *pAd,
4188 struct rt_tx_blk *pTxBlk,
4189 u8 frameNum, u16 * FreeNumber);
4191 void RtmpUSB_FinalWriteTxResource(struct rt_rtmp_adapter *pAd,
4192 struct rt_tx_blk *pTxBlk,
4193 u16 totalMPDUSize, u16 TxIdx);
4195 void RtmpUSBDataLastTxIdx(struct rt_rtmp_adapter *pAd,
4196 u8 QueIdx, u16 TxIdx);
4198 void RtmpUSBDataKickOut(struct rt_rtmp_adapter *pAd,
4199 struct rt_tx_blk *pTxBlk, u8 QueIdx);
4201 int RtmpUSBMgmtKickOut(struct rt_rtmp_adapter *pAd,
4204 u8 *pSrcBufVA, u32 SrcBufLen);
4206 void RtmpUSBNullFrameKickOut(struct rt_rtmp_adapter *pAd,
4208 u8 * pNullFrame, u32 frameLen);
4210 void RtmpUsbStaAsicForceWakeupTimeout(void *SystemSpecific1,
4211 void *FunctionContext,
4212 void *SystemSpecific2,
4213 void *SystemSpecific3);
4215 void RT28xxUsbStaAsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
4217 void RT28xxUsbStaAsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
4218 u16 TbttNumToNextWakeUp);
4220 void RT28xxUsbMlmeRadioOn(struct rt_rtmp_adapter *pAd);
4222 void RT28xxUsbMlmeRadioOFF(struct rt_rtmp_adapter *pAd);
4223 #endif /* RTMP_MAC_USB // */
4225 void AsicTurnOffRFClk(struct rt_rtmp_adapter *pAd, u8 Channel);
4227 void AsicTurnOnRFClk(struct rt_rtmp_adapter *pAd, u8 Channel);
4229 #ifdef RTMP_TIMER_TASK_SUPPORT
4230 int RtmpTimerQThread(IN void *Context);
4232 struct rt_rtmp_timer_task_entry *RtmpTimerQInsert(struct rt_rtmp_adapter *pAd,
4233 struct rt_ralink_timer *pTimer);
4235 BOOLEAN RtmpTimerQRemove(struct rt_rtmp_adapter *pAd,
4236 struct rt_ralink_timer *pTimer);
4238 void RtmpTimerQExit(struct rt_rtmp_adapter *pAd);
4240 void RtmpTimerQInit(struct rt_rtmp_adapter *pAd);
4241 #endif /* RTMP_TIMER_TASK_SUPPORT // */
4243 void AsicStaBbpTuning(struct rt_rtmp_adapter *pAd);
4245 BOOLEAN StaAddMacTableEntry(struct rt_rtmp_adapter *pAd,
4246 struct rt_mac_table_entry *pEntry,
4247 u8 MaxSupportedRateIn500Kbps,
4248 struct rt_ht_capability_ie * pHtCapability,
4250 struct rt_add_ht_info_ie * pAddHtInfo,
4251 u8 AddHtInfoLen, u16 CapabilityInfo);
4253 BOOLEAN AUTH_ReqSend(struct rt_rtmp_adapter *pAd,
4254 struct rt_mlme_queue_elem *pElem,
4255 struct rt_ralink_timer *pAuthTimer,
4258 u8 *pNewElement, unsigned long ElementLen);
4260 void RTMP_IndicateMediaState(struct rt_rtmp_adapter *pAd);
4262 void ReSyncBeaconTime(struct rt_rtmp_adapter *pAd);
4264 void RTMPSetAGCInitValue(struct rt_rtmp_adapter *pAd, u8 BandWidth);
4266 int rt28xx_close(struct net_device *dev);
4267 int rt28xx_open(struct net_device *dev);
4269 #define VIRTUAL_IF_INC(__pAd) ((__pAd)->VirtualIfCnt++)
4270 #define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--)
4271 #define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt)
4274 __inline int VIRTUAL_IF_UP(struct rt_rtmp_adapter *pAd)
4276 if (VIRTUAL_IF_NUM(pAd) == 0) {
4277 if (rt28xx_open(pAd->net_dev) != 0) {
4278 DBGPRINT(RT_DEBUG_TRACE,
4279 ("rt28xx_open return fail!\n"));
4284 VIRTUAL_IF_INC(pAd);
4288 __inline void VIRTUAL_IF_DOWN(struct rt_rtmp_adapter *pAd)
4290 VIRTUAL_IF_DEC(pAd);
4291 if (VIRTUAL_IF_NUM(pAd) == 0)
4292 rt28xx_close(pAd->net_dev);
4295 #endif /* LINUX // */
4298 OS Related funciton prototype definitions.
4299 TODO: Maybe we need to move these function prototypes to other proper place.
4301 int RtmpOSWrielessEventSend(struct rt_rtmp_adapter *pAd,
4305 u8 *pData, u32 dataLen);
4307 int RtmpOSNetDevAddrSet(struct net_device *pNetDev, u8 *pMacAddr);
4309 int RtmpOSNetDevAttach(struct net_device *pNetDev,
4310 struct rt_rtmp_os_netdev_op_hook *pDevOpHook);
4312 void RtmpOSNetDevClose(struct net_device *pNetDev);
4314 void RtmpOSNetDevDetach(struct net_device *pNetDev);
4316 int RtmpOSNetDevAlloc(struct net_device ** pNewNetDev, u32 privDataSize);
4318 void RtmpOSNetDevFree(struct net_device *pNetDev);
4320 struct net_device *RtmpOSNetDevGetByName(struct net_device *pNetDev, char *pDevName);
4322 void RtmpOSNetDeviceRefPut(struct net_device *pNetDev);
4324 struct net_device *RtmpOSNetDevCreate(struct rt_rtmp_adapter *pAd,
4327 int privMemSize, char *pNamePrefix);
4330 Task operation related function prototypes
4332 void RtmpOSTaskCustomize(struct rt_rtmp_os_task *pTask);
4334 int RtmpOSTaskNotifyToExit(struct rt_rtmp_os_task *pTask);
4336 int RtmpOSTaskKill(struct rt_rtmp_os_task *pTask);
4338 int RtmpOSTaskInit(struct rt_rtmp_os_task *pTask,
4339 char *pTaskName, void * pPriv);
4341 int RtmpOSTaskAttach(struct rt_rtmp_os_task *pTask,
4342 IN int (*fn) (void *), IN void *arg);
4345 File operation related function prototypes
4347 struct file *RtmpOSFileOpen(IN char *pPath, IN int flag, IN int mode);
4349 int RtmpOSFileClose(struct file *osfd);
4351 void RtmpOSFileSeek(struct file *osfd, IN int offset);
4353 int RtmpOSFileRead(struct file *osfd, IN char *pDataPtr, IN int readLen);
4355 int RtmpOSFileWrite(struct file *osfd, IN char *pDataPtr, IN int writeLen);
4357 #endif /* __RTMP_H__ */