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