Staging: rt28x0: remove typedefs (part three)
[deliverable/linux.git] / drivers / staging / rt2860 / common / action.c
CommitLineData
91980990
GKH
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 action.c
29
30 Abstract:
31 Handle association related requests either from WSTA or from local MLME
32
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Jan Lee 2006 created for rt2860
37 */
38
39#include "../rt_config.h"
40#include "action.h"
41
62eb734b 42static void ReservedAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
91980990
GKH
43
44/*
45 ==========================================================================
46 Description:
47 association state machine init, including state transition and timer init
48 Parameters:
49 S - pointer to the association state machine
50 Note:
51 The state machine looks like the following
52
53 ASSOC_IDLE
54 MT2_MLME_DISASSOC_REQ mlme_disassoc_req_action
55 MT2_PEER_DISASSOC_REQ peer_disassoc_action
56 MT2_PEER_ASSOC_REQ drop
57 MT2_PEER_REASSOC_REQ drop
58 MT2_CLS3ERR cls3err_action
59 ==========================================================================
60 */
62eb734b
BZ
61void ActionStateMachineInit(struct rt_rtmp_adapter *pAd,
62 struct rt_state_machine *S,
96b3c83d 63 OUT STATE_MACHINE_FUNC Trans[])
91980990 64{
96b3c83d
BZ
65 StateMachineInit(S, (STATE_MACHINE_FUNC *) Trans, MAX_ACT_STATE,
66 MAX_ACT_MSG, (STATE_MACHINE_FUNC) Drop, ACT_IDLE,
67 ACT_MACHINE_BASE);
68
69 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_SPECTRUM_CATE,
70 (STATE_MACHINE_FUNC) PeerSpectrumAction);
71 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE,
72 (STATE_MACHINE_FUNC) PeerQOSAction);
73
74 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE,
75 (STATE_MACHINE_FUNC) ReservedAction);
76
77 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE,
78 (STATE_MACHINE_FUNC) PeerBAAction);
79 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_HT_CATE,
80 (STATE_MACHINE_FUNC) PeerHTAction);
81 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ADD_BA_CATE,
82 (STATE_MACHINE_FUNC) MlmeADDBAAction);
83 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ORI_DELBA_CATE,
84 (STATE_MACHINE_FUNC) MlmeDELBAAction);
85 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_REC_DELBA_CATE,
86 (STATE_MACHINE_FUNC) MlmeDELBAAction);
87
88 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE,
89 (STATE_MACHINE_FUNC) PeerPublicAction);
90 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE,
91 (STATE_MACHINE_FUNC) PeerRMAction);
92
93 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_QOS_CATE,
94 (STATE_MACHINE_FUNC) MlmeQOSAction);
95 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_DLS_CATE,
96 (STATE_MACHINE_FUNC) MlmeDLSAction);
97 StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID,
98 (STATE_MACHINE_FUNC) MlmeInvalidAction);
91980990
GKH
99}
100
62eb734b 101void MlmeADDBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990 102{
62eb734b 103 struct rt_mlme_addba_req *pInfo;
51126deb
BZ
104 u8 Addr[6];
105 u8 *pOutBuffer = NULL;
106 int NStatus;
107 unsigned long Idx;
62eb734b 108 struct rt_frame_addba_req Frame;
51126deb 109 unsigned long FrameLen;
62eb734b 110 struct rt_ba_ori_entry *pBAEntry = NULL;
96b3c83d 111
62eb734b
BZ
112 pInfo = (struct rt_mlme_addba_req *)Elem->Msg;
113 NdisZeroMemory(&Frame, sizeof(struct rt_frame_addba_req));
91980990 114
96b3c83d 115 if (MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr)) {
ec278fa2 116 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
96b3c83d
BZ
117 if (NStatus != NDIS_STATUS_SUCCESS) {
118 DBGPRINT(RT_DEBUG_TRACE,
119 ("BA - MlmeADDBAAction() allocate memory failed \n"));
91980990
GKH
120 return;
121 }
ec278fa2 122 /* 1. find entry */
96b3c83d
BZ
123 Idx =
124 pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
125 if (Idx == 0) {
91980990 126 MlmeFreeMemory(pAd, pOutBuffer);
96b3c83d
BZ
127 DBGPRINT(RT_DEBUG_ERROR,
128 ("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
91980990 129 return;
96b3c83d
BZ
130 } else {
131 pBAEntry = &pAd->BATable.BAOriEntry[Idx];
91980990
GKH
132 }
133
91980990
GKH
134 {
135 if (ADHOC_ON(pAd))
96b3c83d
BZ
136 ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr,
137 pAd->CurrentAddress,
138 pAd->CommonCfg.Bssid);
91980990 139 else
96b3c83d
BZ
140 ActHeaderInit(pAd, &Frame.Hdr,
141 pAd->CommonCfg.Bssid,
142 pAd->CurrentAddress,
143 pInfo->pAddr);
91980990 144 }
91980990
GKH
145
146 Frame.Category = CATEGORY_BA;
147 Frame.Action = ADDBA_REQ;
148 Frame.BaParm.AMSDUSupported = 0;
149 Frame.BaParm.BAPolicy = IMMED_BA;
150 Frame.BaParm.TID = pInfo->TID;
151 Frame.BaParm.BufSize = pInfo->BaBufSize;
152 Frame.Token = pInfo->Token;
153 Frame.TimeOutValue = pInfo->TimeOutValue;
154 Frame.BaStartSeq.field.FragNum = 0;
96b3c83d
BZ
155 Frame.BaStartSeq.field.StartSeq =
156 pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];
91980990 157
51126deb
BZ
158 *(u16 *) (&Frame.BaParm) =
159 cpu2le16(*(u16 *) (&Frame.BaParm));
91980990
GKH
160 Frame.TimeOutValue = cpu2le16(Frame.TimeOutValue);
161 Frame.BaStartSeq.word = cpu2le16(Frame.BaStartSeq.word);
162
96b3c83d 163 MakeOutgoingFrame(pOutBuffer, &FrameLen,
62eb734b 164 sizeof(struct rt_frame_addba_req), &Frame, END_OF_ARGS);
ca97b838 165
96b3c83d
BZ
166 MiniportMMRequest(pAd,
167 (MGMT_USE_QUEUE_FLAG |
168 MapUserPriorityToAccessCategory[pInfo->TID]),
169 pOutBuffer, FrameLen);
ca97b838 170
91980990
GKH
171 MlmeFreeMemory(pAd, pOutBuffer);
172
96b3c83d
BZ
173 DBGPRINT(RT_DEBUG_TRACE,
174 ("BA - Send ADDBA request. StartSeq = %x, FrameLen = %ld. BufSize = %d\n",
175 Frame.BaStartSeq.field.StartSeq, FrameLen,
176 Frame.BaParm.BufSize));
177 }
91980990
GKH
178}
179
180/*
181 ==========================================================================
182 Description:
183 send DELBA and delete BaEntry if any
184 Parametrs:
62eb734b 185 Elem - MLME message struct rt_mlme_delba_req
91980990
GKH
186
187 IRQL = DISPATCH_LEVEL
188
189 ==========================================================================
190 */
62eb734b 191void MlmeDELBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990 192{
62eb734b 193 struct rt_mlme_delba_req *pInfo;
51126deb
BZ
194 u8 *pOutBuffer = NULL;
195 u8 *pOutBuffer2 = NULL;
196 int NStatus;
197 unsigned long Idx;
62eb734b 198 struct rt_frame_delba_req Frame;
51126deb 199 unsigned long FrameLen;
62eb734b 200 struct rt_frame_bar FrameBar;
96b3c83d 201
62eb734b 202 pInfo = (struct rt_mlme_delba_req *)Elem->Msg;
ec278fa2 203 /* must send back DELBA */
62eb734b 204 NdisZeroMemory(&Frame, sizeof(struct rt_frame_delba_req));
96b3c83d
BZ
205 DBGPRINT(RT_DEBUG_TRACE,
206 ("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
207
208 if (MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen)) {
ec278fa2 209 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
96b3c83d
BZ
210 if (NStatus != NDIS_STATUS_SUCCESS) {
211 DBGPRINT(RT_DEBUG_ERROR,
212 ("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
91980990
GKH
213 return;
214 }
215
ec278fa2 216 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); /*Get an unused nonpaged memory */
96b3c83d 217 if (NStatus != NDIS_STATUS_SUCCESS) {
91980990 218 MlmeFreeMemory(pAd, pOutBuffer);
96b3c83d
BZ
219 DBGPRINT(RT_DEBUG_ERROR,
220 ("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
91980990
GKH
221 return;
222 }
ec278fa2 223 /* SEND BAR (Send BAR to refresh peer reordering buffer.) */
96b3c83d
BZ
224 Idx =
225 pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
226
227 BarHeaderInit(pAd, &FrameBar,
228 pAd->MacTab.Content[pInfo->Wcid].Addr,
229 pAd->CurrentAddress);
230
ec278fa2
BZ
231 FrameBar.StartingSeq.field.FragNum = 0; /* make sure sequence not clear in DEL funciton. */
232 FrameBar.StartingSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID]; /* make sure sequence not clear in DEL funciton. */
233 FrameBar.BarControl.TID = pInfo->TID; /* make sure sequence not clear in DEL funciton. */
234 FrameBar.BarControl.ACKPolicy = IMMED_BA; /* make sure sequence not clear in DEL funciton. */
235 FrameBar.BarControl.Compressed = 1; /* make sure sequence not clear in DEL funciton. */
236 FrameBar.BarControl.MTID = 0; /* make sure sequence not clear in DEL funciton. */
96b3c83d
BZ
237
238 MakeOutgoingFrame(pOutBuffer2, &FrameLen,
62eb734b 239 sizeof(struct rt_frame_bar), &FrameBar, END_OF_ARGS);
91980990
GKH
240 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
241 MlmeFreeMemory(pAd, pOutBuffer2);
96b3c83d
BZ
242 DBGPRINT(RT_DEBUG_TRACE,
243 ("BA - MlmeDELBAAction() . Send BAR to refresh peer reordering buffer \n"));
91980990 244
ec278fa2 245 /* SEND DELBA FRAME */
91980990 246 FrameLen = 0;
6a28a69a 247
91980990
GKH
248 {
249 if (ADHOC_ON(pAd))
96b3c83d
BZ
250 ActHeaderInit(pAd, &Frame.Hdr,
251 pAd->MacTab.Content[pInfo->Wcid].
252 Addr, pAd->CurrentAddress,
253 pAd->CommonCfg.Bssid);
91980990 254 else
96b3c83d
BZ
255 ActHeaderInit(pAd, &Frame.Hdr,
256 pAd->CommonCfg.Bssid,
257 pAd->CurrentAddress,
258 pAd->MacTab.Content[pInfo->Wcid].
259 Addr);
91980990 260 }
6a28a69a 261
91980990
GKH
262 Frame.Category = CATEGORY_BA;
263 Frame.Action = DELBA;
264 Frame.DelbaParm.Initiator = pInfo->Initiator;
265 Frame.DelbaParm.TID = pInfo->TID;
ec278fa2 266 Frame.ReasonCode = 39; /* Time Out */
51126deb
BZ
267 *(u16 *) (&Frame.DelbaParm) =
268 cpu2le16(*(u16 *) (&Frame.DelbaParm));
91980990
GKH
269 Frame.ReasonCode = cpu2le16(Frame.ReasonCode);
270
96b3c83d 271 MakeOutgoingFrame(pOutBuffer, &FrameLen,
62eb734b 272 sizeof(struct rt_frame_delba_req), &Frame, END_OF_ARGS);
91980990
GKH
273 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
274 MlmeFreeMemory(pAd, pOutBuffer);
96b3c83d
BZ
275 DBGPRINT(RT_DEBUG_TRACE,
276 ("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n",
277 pInfo->Initiator));
278 }
91980990 279}
91980990 280
62eb734b 281void MlmeQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990
GKH
282{
283}
284
62eb734b 285void MlmeDLSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990
GKH
286{
287}
288
62eb734b 289void MlmeInvalidAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990 290{
51126deb 291 /*u8 * pOutBuffer = NULL; */
ec278fa2 292 /*Return the receiving frame except the MSB of category filed set to 1. 7.3.1.11 */
91980990
GKH
293}
294
62eb734b 295void PeerQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990
GKH
296{
297}
298
62eb734b 299void PeerBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990 300{
51126deb 301 u8 Action = Elem->Msg[LENGTH_802_11 + 1];
96b3c83d
BZ
302
303 switch (Action) {
304 case ADDBA_REQ:
305 PeerAddBAReqAction(pAd, Elem);
306 break;
307 case ADDBA_RESP:
308 PeerAddBARspAction(pAd, Elem);
309 break;
310 case DELBA:
311 PeerDelBAAction(pAd, Elem);
312 break;
91980990
GKH
313 }
314}
91980990 315
62eb734b 316void PeerPublicAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990 317{
91980990
GKH
318 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
319 return;
91980990
GKH
320}
321
62eb734b 322static void ReservedAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990 323{
51126deb 324 u8 Category;
91980990 325
96b3c83d 326 if (Elem->MsgLen <= LENGTH_802_11) {
91980990
GKH
327 return;
328 }
329
330 Category = Elem->Msg[LENGTH_802_11];
96b3c83d
BZ
331 DBGPRINT(RT_DEBUG_TRACE,
332 ("Rcv reserved category(%d) Action Frame\n", Category));
91980990
GKH
333 hex_dump("Reserved Action Frame", &Elem->Msg[0], Elem->MsgLen);
334}
335
62eb734b 336void PeerRMAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990
GKH
337{
338 return;
339}
340
62eb734b
BZ
341static void respond_ht_information_exchange_action(struct rt_rtmp_adapter *pAd,
342 struct rt_mlme_queue_elem *Elem)
91980990 343{
51126deb
BZ
344 u8 *pOutBuffer = NULL;
345 int NStatus;
346 unsigned long FrameLen;
62eb734b 347 struct rt_frame_ht_info HTINFOframe, *pFrame;
51126deb 348 u8 *pAddr;
91980990 349
ec278fa2
BZ
350 /* 2. Always send back ADDBA Response */
351 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
91980990 352
96b3c83d
BZ
353 if (NStatus != NDIS_STATUS_SUCCESS) {
354 DBGPRINT(RT_DEBUG_TRACE,
355 ("ACTION - respond_ht_information_exchange_action() allocate memory failed \n"));
91980990
GKH
356 return;
357 }
ec278fa2 358 /* get RA */
62eb734b 359 pFrame = (struct rt_frame_ht_info *) & Elem->Msg[0];
91980990
GKH
360 pAddr = pFrame->Hdr.Addr2;
361
62eb734b 362 NdisZeroMemory(&HTINFOframe, sizeof(struct rt_frame_ht_info));
ec278fa2 363 /* 2-1. Prepare ADDBA Response frame. */
91980990
GKH
364 {
365 if (ADHOC_ON(pAd))
96b3c83d
BZ
366 ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr,
367 pAd->CurrentAddress,
368 pAd->CommonCfg.Bssid);
91980990 369 else
96b3c83d
BZ
370 ActHeaderInit(pAd, &HTINFOframe.Hdr,
371 pAd->CommonCfg.Bssid, pAd->CurrentAddress,
372 pAddr);
91980990 373 }
91980990
GKH
374
375 HTINFOframe.Category = CATEGORY_HT;
376 HTINFOframe.Action = HT_INFO_EXCHANGE;
377 HTINFOframe.HT_Info.Request = 0;
96b3c83d
BZ
378 HTINFOframe.HT_Info.Forty_MHz_Intolerant =
379 pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant;
380 HTINFOframe.HT_Info.STA_Channel_Width =
381 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
91980990 382
96b3c83d 383 MakeOutgoingFrame(pOutBuffer, &FrameLen,
62eb734b 384 sizeof(struct rt_frame_ht_info), &HTINFOframe, END_OF_ARGS);
91980990
GKH
385
386 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
387 MlmeFreeMemory(pAd, pOutBuffer);
388}
389
62eb734b 390void PeerHTAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
91980990 391{
51126deb 392 u8 Action = Elem->Msg[LENGTH_802_11 + 1];
91980990
GKH
393
394 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
395 return;
396
96b3c83d
BZ
397 switch (Action) {
398 case NOTIFY_BW_ACTION:
399 DBGPRINT(RT_DEBUG_TRACE,
400 ("ACTION - HT Notify Channel bandwidth action----> \n"));
401
402 if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) {
ec278fa2
BZ
403 /* Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps */
404 /* sending BW_Notify Action frame, and cause us to linkup and linkdown. */
405 /* In legacy mode, don't need to parse HT action frame. */
96b3c83d
BZ
406 DBGPRINT(RT_DEBUG_TRACE,
407 ("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n",
408 Elem->Msg[LENGTH_802_11 + 2]));
91980990 409 break;
96b3c83d 410 }
91980990 411
ec278fa2 412 if (Elem->Msg[LENGTH_802_11 + 2] == 0) /* 7.4.8.2. if value is 1, keep the same as supported channel bandwidth. */
96b3c83d
BZ
413 pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
414
415 break;
416 case SMPS_ACTION:
ec278fa2 417 /* 7.3.1.25 */
96b3c83d
BZ
418 DBGPRINT(RT_DEBUG_TRACE, ("ACTION - SMPS action----> \n"));
419 if (((Elem->Msg[LENGTH_802_11 + 2] & 0x1) == 0)) {
420 pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_ENABLE;
421 } else if (((Elem->Msg[LENGTH_802_11 + 2] & 0x2) == 0)) {
422 pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_STATIC;
423 } else {
424 pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_DYNAMIC;
425 }
91980990 426
96b3c83d
BZ
427 DBGPRINT(RT_DEBUG_TRACE,
428 ("Aid(%d) MIMO PS = %d\n", Elem->Wcid,
429 pAd->MacTab.Content[Elem->Wcid].MmpsMode));
ec278fa2 430 /* rt2860c : add something for smps change. */
96b3c83d
BZ
431 break;
432
433 case SETPCO_ACTION:
434 break;
435 case MIMO_CHA_MEASURE_ACTION:
436 break;
437 case HT_INFO_EXCHANGE:
438 {
62eb734b 439 struct rt_ht_information_octet *pHT_info;
96b3c83d
BZ
440
441 pHT_info =
62eb734b 442 (struct rt_ht_information_octet *) & Elem->Msg[LENGTH_802_11 +
96b3c83d 443 2];
ec278fa2 444 /* 7.4.8.10 */
96b3c83d
BZ
445 DBGPRINT(RT_DEBUG_TRACE,
446 ("ACTION - HT Information Exchange action----> \n"));
447 if (pHT_info->Request) {
448 respond_ht_information_exchange_action(pAd,
449 Elem);
91980990 450 }
96b3c83d
BZ
451 }
452 break;
91980990
GKH
453 }
454}
455
91980990
GKH
456/*
457 ==========================================================================
458 Description:
459 Retry sending ADDBA Reqest.
460
461 IRQL = DISPATCH_LEVEL
462
463 Parametrs:
464 p8023Header: if this is already 802.3 format, p8023Header is NULL
465
466 Return : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
467 FALSE , then continue indicaterx at this moment.
468 ==========================================================================
469 */
62eb734b 470void ORIBATimerTimeout(struct rt_rtmp_adapter *pAd)
91980990 471{
62eb734b 472 struct rt_mac_table_entry *pEntry;
51126deb
BZ
473 int i, total;
474 u8 TID;
91980990 475
91980990
GKH
476 total = pAd->MacTab.Size * NUM_OF_TID;
477
96b3c83d
BZ
478 for (i = 1; ((i < MAX_LEN_OF_BA_ORI_TABLE) && (total > 0)); i++) {
479 if (pAd->BATable.BAOriEntry[i].ORI_BA_Status == Originator_Done) {
480 pEntry =
481 &pAd->MacTab.Content[pAd->BATable.BAOriEntry[i].
482 Wcid];
91980990
GKH
483 TID = pAd->BATable.BAOriEntry[i].TID;
484
96b3c83d
BZ
485 ASSERT(pAd->BATable.BAOriEntry[i].Wcid <
486 MAX_LEN_OF_MAC_TABLE);
91980990 487 }
96b3c83d 488 total--;
91980990
GKH
489 }
490}
491
62eb734b 492void SendRefreshBAR(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry)
91980990 493{
62eb734b 494 struct rt_frame_bar FrameBar;
51126deb
BZ
495 unsigned long FrameLen;
496 int NStatus;
497 u8 *pOutBuffer = NULL;
498 u16 Sequence;
499 u8 i, TID;
500 u16 idx;
62eb734b 501 struct rt_ba_ori_entry *pBAEntry;
96b3c83d
BZ
502
503 for (i = 0; i < NUM_OF_TID; i++) {
91980990 504 idx = pEntry->BAOriWcidArray[i];
96b3c83d 505 if (idx == 0) {
91980990
GKH
506 continue;
507 }
508 pBAEntry = &pAd->BATable.BAOriEntry[idx];
509
96b3c83d 510 if (pBAEntry->ORI_BA_Status == Originator_Done) {
91980990
GKH
511 TID = pBAEntry->TID;
512
513 ASSERT(pBAEntry->Wcid < MAX_LEN_OF_MAC_TABLE);
514
ec278fa2 515 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
96b3c83d
BZ
516 if (NStatus != NDIS_STATUS_SUCCESS) {
517 DBGPRINT(RT_DEBUG_ERROR,
518 ("BA - MlmeADDBAAction() allocate memory failed \n"));
91980990
GKH
519 return;
520 }
521
522 Sequence = pEntry->TxSeq[TID];
6a28a69a 523
96b3c83d
BZ
524 BarHeaderInit(pAd, &FrameBar, pEntry->Addr,
525 pAd->CurrentAddress);
91980990 526
ec278fa2
BZ
527 FrameBar.StartingSeq.field.FragNum = 0; /* make sure sequence not clear in DEL function. */
528 FrameBar.StartingSeq.field.StartSeq = Sequence; /* make sure sequence not clear in DEL funciton. */
529 FrameBar.BarControl.TID = TID; /* make sure sequence not clear in DEL funciton. */
91980990 530
96b3c83d 531 MakeOutgoingFrame(pOutBuffer, &FrameLen,
62eb734b 532 sizeof(struct rt_frame_bar), &FrameBar,
96b3c83d 533 END_OF_ARGS);
ec278fa2
BZ
534 /*if (!(CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_RALINK_CHIPSET))) */
535 if (1) /* Now we always send BAR. */
ca97b838 536 {
ec278fa2 537 /*MiniportMMRequestUnlock(pAd, 0, pOutBuffer, FrameLen); */
96b3c83d
BZ
538 MiniportMMRequest(pAd,
539 (MGMT_USE_QUEUE_FLAG |
540 MapUserPriorityToAccessCategory
541 [TID]), pOutBuffer,
542 FrameLen);
59fe2d89 543
ca97b838 544 }
91980990
GKH
545 MlmeFreeMemory(pAd, pOutBuffer);
546 }
547 }
548}
91980990 549
62eb734b
BZ
550void ActHeaderInit(struct rt_rtmp_adapter *pAd,
551 struct rt_header_802_11 * pHdr80211,
51126deb 552 u8 *Addr1, u8 *Addr2, u8 *Addr3)
91980990 553{
62eb734b 554 NdisZeroMemory(pHdr80211, sizeof(struct rt_header_802_11));
96b3c83d
BZ
555 pHdr80211->FC.Type = BTYPE_MGMT;
556 pHdr80211->FC.SubType = SUBTYPE_ACTION;
91980990 557
96b3c83d 558 COPY_MAC_ADDR(pHdr80211->Addr1, Addr1);
91980990 559 COPY_MAC_ADDR(pHdr80211->Addr2, Addr2);
96b3c83d 560 COPY_MAC_ADDR(pHdr80211->Addr3, Addr3);
91980990
GKH
561}
562
62eb734b
BZ
563void BarHeaderInit(struct rt_rtmp_adapter *pAd,
564 struct rt_frame_bar * pCntlBar, u8 *pDA, u8 *pSA)
91980990 565{
62eb734b 566 NdisZeroMemory(pCntlBar, sizeof(struct rt_frame_bar));
91980990
GKH
567 pCntlBar->FC.Type = BTYPE_CNTL;
568 pCntlBar->FC.SubType = SUBTYPE_BLOCK_ACK_REQ;
96b3c83d 569 pCntlBar->BarControl.MTID = 0;
91980990
GKH
570 pCntlBar->BarControl.Compressed = 1;
571 pCntlBar->BarControl.ACKPolicy = 0;
572
96b3c83d 573 pCntlBar->Duration =
62eb734b 574 16 + RTMPCalcDuration(pAd, RATE_1, sizeof(struct rt_frame_ba));
91980990
GKH
575
576 COPY_MAC_ADDR(pCntlBar->Addr1, pDA);
577 COPY_MAC_ADDR(pCntlBar->Addr2, pSA);
578}
579
91980990
GKH
580/*
581 ==========================================================================
582 Description:
583 Insert Category and action code into the action frame.
584
585 Parametrs:
586 1. frame buffer pointer.
587 2. frame length.
588 3. category code of the frame.
589 4. action code of the frame.
590
591 Return : None.
592 ==========================================================================
593 */
62eb734b 594void InsertActField(struct rt_rtmp_adapter *pAd,
51126deb
BZ
595 u8 *pFrameBuf,
596 unsigned long *pFrameLen, u8 Category, u8 ActCode)
91980990 597{
51126deb 598 unsigned long TempLen;
91980990 599
96b3c83d
BZ
600 MakeOutgoingFrame(pFrameBuf, &TempLen,
601 1, &Category, 1, &ActCode, END_OF_ARGS);
91980990
GKH
602
603 *pFrameLen = *pFrameLen + TempLen;
604
605 return;
606}
This page took 0.151566 seconds and 5 git commands to generate.