blob: 8928ee742676754f89536b66d4596fd67552fbeb [file] [log] [blame]
Greg Kroah-Hartman91980992008-10-28 14:48:09 -07001/*
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
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -080042static void ReservedAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070043
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 */
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -080061void ActionStateMachineInit(IN PRTMP_ADAPTER pAd,
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -080062 IN STATE_MACHINE * S,
63 OUT STATE_MACHINE_FUNC Trans[])
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070064{
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -080065 StateMachineInit(S, (STATE_MACHINE_FUNC *) Trans, MAX_ACT_STATE,
66 MAX_ACT_MSG, (STATE_MACHINE_FUNC) Drop, ACT_IDLE,
67 ACT_MACHINE_BASE);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070068
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -080069 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);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070073
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -080074 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE,
75 (STATE_MACHINE_FUNC) ReservedAction);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070076
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -080077 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);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070087
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -080088 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);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070092
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -080093 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);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -070099}
100
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800101void MlmeADDBAAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700102{
103 MLME_ADDBA_REQ_STRUCT *pInfo;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800104 u8 Addr[6];
105 u8 *pOutBuffer = NULL;
106 int NStatus;
107 unsigned long Idx;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800108 FRAME_ADDBA_REQ Frame;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800109 unsigned long FrameLen;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800110 BA_ORI_ENTRY *pBAEntry = NULL;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700111
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800112 pInfo = (MLME_ADDBA_REQ_STRUCT *) Elem->Msg;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700113 NdisZeroMemory(&Frame, sizeof(FRAME_ADDBA_REQ));
114
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800115 if (MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr)) {
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800116 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800117 if (NStatus != NDIS_STATUS_SUCCESS) {
118 DBGPRINT(RT_DEBUG_TRACE,
119 ("BA - MlmeADDBAAction() allocate memory failed \n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700120 return;
121 }
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800122 /* 1. find entry */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800123 Idx =
124 pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
125 if (Idx == 0) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700126 MlmeFreeMemory(pAd, pOutBuffer);
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800127 DBGPRINT(RT_DEBUG_ERROR,
128 ("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700129 return;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800130 } else {
131 pBAEntry = &pAd->BATable.BAOriEntry[Idx];
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700132 }
133
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700134 {
135 if (ADHOC_ON(pAd))
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800136 ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr,
137 pAd->CurrentAddress,
138 pAd->CommonCfg.Bssid);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700139 else
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800140 ActHeaderInit(pAd, &Frame.Hdr,
141 pAd->CommonCfg.Bssid,
142 pAd->CurrentAddress,
143 pInfo->pAddr);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700144 }
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700145
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;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800155 Frame.BaStartSeq.field.StartSeq =
156 pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700157
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800158 *(u16 *) (&Frame.BaParm) =
159 cpu2le16(*(u16 *) (&Frame.BaParm));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700160 Frame.TimeOutValue = cpu2le16(Frame.TimeOutValue);
161 Frame.BaStartSeq.word = cpu2le16(Frame.BaStartSeq.word);
162
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800163 MakeOutgoingFrame(pOutBuffer, &FrameLen,
164 sizeof(FRAME_ADDBA_REQ), &Frame, END_OF_ARGS);
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200165
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800166 MiniportMMRequest(pAd,
167 (MGMT_USE_QUEUE_FLAG |
168 MapUserPriorityToAccessCategory[pInfo->TID]),
169 pOutBuffer, FrameLen);
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200170
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700171 MlmeFreeMemory(pAd, pOutBuffer);
172
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800173 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 }
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700178}
179
180/*
181 ==========================================================================
182 Description:
183 send DELBA and delete BaEntry if any
184 Parametrs:
185 Elem - MLME message MLME_DELBA_REQ_STRUCT
186
187 IRQL = DISPATCH_LEVEL
188
189 ==========================================================================
190 */
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800191void MlmeDELBAAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700192{
193 MLME_DELBA_REQ_STRUCT *pInfo;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800194 u8 *pOutBuffer = NULL;
195 u8 *pOutBuffer2 = NULL;
196 int NStatus;
197 unsigned long Idx;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800198 FRAME_DELBA_REQ Frame;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800199 unsigned long FrameLen;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800200 FRAME_BAR FrameBar;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700201
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800202 pInfo = (MLME_DELBA_REQ_STRUCT *) Elem->Msg;
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800203 /* must send back DELBA */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700204 NdisZeroMemory(&Frame, sizeof(FRAME_DELBA_REQ));
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800205 DBGPRINT(RT_DEBUG_TRACE,
206 ("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700207
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800208 if (MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen)) {
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800209 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800210 if (NStatus != NDIS_STATUS_SUCCESS) {
211 DBGPRINT(RT_DEBUG_ERROR,
212 ("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700213 return;
214 }
215
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800216 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); /*Get an unused nonpaged memory */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800217 if (NStatus != NDIS_STATUS_SUCCESS) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700218 MlmeFreeMemory(pAd, pOutBuffer);
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800219 DBGPRINT(RT_DEBUG_ERROR,
220 ("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700221 return;
222 }
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800223 /* SEND BAR (Send BAR to refresh peer reordering buffer.) */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800224 Idx =
225 pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
Bartlomiej Zolnierkiewicz6a28a69a2009-04-26 16:05:46 +0200226
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800227 BarHeaderInit(pAd, &FrameBar,
228 pAd->MacTab.Content[pInfo->Wcid].Addr,
229 pAd->CurrentAddress);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700230
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800231 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. */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700237
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800238 MakeOutgoingFrame(pOutBuffer2, &FrameLen,
239 sizeof(FRAME_BAR), &FrameBar, END_OF_ARGS);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700240 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
241 MlmeFreeMemory(pAd, pOutBuffer2);
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800242 DBGPRINT(RT_DEBUG_TRACE,
243 ("BA - MlmeDELBAAction() . Send BAR to refresh peer reordering buffer \n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700244
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800245 /* SEND DELBA FRAME */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700246 FrameLen = 0;
Bartlomiej Zolnierkiewicz6a28a69a2009-04-26 16:05:46 +0200247
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700248 {
249 if (ADHOC_ON(pAd))
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800250 ActHeaderInit(pAd, &Frame.Hdr,
251 pAd->MacTab.Content[pInfo->Wcid].
252 Addr, pAd->CurrentAddress,
253 pAd->CommonCfg.Bssid);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700254 else
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800255 ActHeaderInit(pAd, &Frame.Hdr,
256 pAd->CommonCfg.Bssid,
257 pAd->CurrentAddress,
258 pAd->MacTab.Content[pInfo->Wcid].
259 Addr);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700260 }
Bartlomiej Zolnierkiewicz6a28a69a2009-04-26 16:05:46 +0200261
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700262 Frame.Category = CATEGORY_BA;
263 Frame.Action = DELBA;
264 Frame.DelbaParm.Initiator = pInfo->Initiator;
265 Frame.DelbaParm.TID = pInfo->TID;
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800266 Frame.ReasonCode = 39; /* Time Out */
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800267 *(u16 *) (&Frame.DelbaParm) =
268 cpu2le16(*(u16 *) (&Frame.DelbaParm));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700269 Frame.ReasonCode = cpu2le16(Frame.ReasonCode);
270
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800271 MakeOutgoingFrame(pOutBuffer, &FrameLen,
272 sizeof(FRAME_DELBA_REQ), &Frame, END_OF_ARGS);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700273 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
274 MlmeFreeMemory(pAd, pOutBuffer);
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800275 DBGPRINT(RT_DEBUG_TRACE,
276 ("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n",
277 pInfo->Initiator));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700278 }
279}
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700280
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800281void MlmeQOSAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800282{
283}
284
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800285void MlmeDLSAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800286{
287}
288
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800289void MlmeInvalidAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800290{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800291 /*u8 * pOutBuffer = NULL; */
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800292 /*Return the receiving frame except the MSB of category filed set to 1. 7.3.1.11 */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800293}
294
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800295void PeerQOSAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800296{
297}
298
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800299void PeerBAAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800300{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800301 u8 Action = Elem->Msg[LENGTH_802_11 + 1];
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800302
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;
313 }
314}
315
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800316void PeerPublicAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700317{
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700318 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
319 return;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700320}
321
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800322static void ReservedAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700323{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800324 u8 Category;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700325
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800326 if (Elem->MsgLen <= LENGTH_802_11) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700327 return;
328 }
329
330 Category = Elem->Msg[LENGTH_802_11];
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800331 DBGPRINT(RT_DEBUG_TRACE,
332 ("Rcv reserved category(%d) Action Frame\n", Category));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700333 hex_dump("Reserved Action Frame", &Elem->Msg[0], Elem->MsgLen);
334}
335
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800336void PeerRMAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700337{
338 return;
339}
340
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800341static void respond_ht_information_exchange_action(IN PRTMP_ADAPTER pAd,
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800342 IN MLME_QUEUE_ELEM * Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700343{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800344 u8 *pOutBuffer = NULL;
345 int NStatus;
346 unsigned long FrameLen;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800347 FRAME_HT_INFO HTINFOframe, *pFrame;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800348 u8 *pAddr;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700349
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800350 /* 2. Always send back ADDBA Response */
351 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700352
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800353 if (NStatus != NDIS_STATUS_SUCCESS) {
354 DBGPRINT(RT_DEBUG_TRACE,
355 ("ACTION - respond_ht_information_exchange_action() allocate memory failed \n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700356 return;
357 }
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800358 /* get RA */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800359 pFrame = (FRAME_HT_INFO *) & Elem->Msg[0];
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700360 pAddr = pFrame->Hdr.Addr2;
361
362 NdisZeroMemory(&HTINFOframe, sizeof(FRAME_HT_INFO));
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800363 /* 2-1. Prepare ADDBA Response frame. */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700364 {
365 if (ADHOC_ON(pAd))
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800366 ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr,
367 pAd->CurrentAddress,
368 pAd->CommonCfg.Bssid);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700369 else
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800370 ActHeaderInit(pAd, &HTINFOframe.Hdr,
371 pAd->CommonCfg.Bssid, pAd->CurrentAddress,
372 pAddr);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700373 }
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700374
375 HTINFOframe.Category = CATEGORY_HT;
376 HTINFOframe.Action = HT_INFO_EXCHANGE;
377 HTINFOframe.HT_Info.Request = 0;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800378 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;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700382
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800383 MakeOutgoingFrame(pOutBuffer, &FrameLen,
384 sizeof(FRAME_HT_INFO), &HTINFOframe, END_OF_ARGS);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700385
386 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
387 MlmeFreeMemory(pAd, pOutBuffer);
388}
389
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800390void PeerHTAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700391{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800392 u8 Action = Elem->Msg[LENGTH_802_11 + 1];
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700393
394 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
395 return;
396
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800397 switch (Action) {
398 case NOTIFY_BW_ACTION:
399 DBGPRINT(RT_DEBUG_TRACE,
400 ("ACTION - HT Notify Channel bandwidth action----> \n"));
Bartlomiej Zolnierkiewicz6a28a69a2009-04-26 16:05:46 +0200401
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800402 if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) {
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800403 /* 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. */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800406 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]));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700409 break;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800410 }
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700411
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800412 if (Elem->Msg[LENGTH_802_11 + 2] == 0) /* 7.4.8.2. if value is 1, keep the same as supported channel bandwidth. */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800413 pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700414
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800415 break;
416 case SMPS_ACTION:
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800417 /* 7.3.1.25 */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800418 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 }
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700426
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800427 DBGPRINT(RT_DEBUG_TRACE,
428 ("Aid(%d) MIMO PS = %d\n", Elem->Wcid,
429 pAd->MacTab.Content[Elem->Wcid].MmpsMode));
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800430 /* rt2860c : add something for smps change. */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800431 break;
432
433 case SETPCO_ACTION:
434 break;
435 case MIMO_CHA_MEASURE_ACTION:
436 break;
437 case HT_INFO_EXCHANGE:
438 {
439 HT_INFORMATION_OCTET *pHT_info;
440
441 pHT_info =
442 (HT_INFORMATION_OCTET *) & Elem->Msg[LENGTH_802_11 +
443 2];
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800444 /* 7.4.8.10 */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800445 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);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700450 }
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800451 }
452 break;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700453 }
454}
455
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700456/*
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 */
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800470void ORIBATimerTimeout(IN PRTMP_ADAPTER pAd)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700471{
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800472 MAC_TABLE_ENTRY *pEntry;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800473 int i, total;
474 u8 TID;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700475
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700476 total = pAd->MacTab.Size * NUM_OF_TID;
477
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800478 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];
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700483 TID = pAd->BATable.BAOriEntry[i].TID;
484
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800485 ASSERT(pAd->BATable.BAOriEntry[i].Wcid <
486 MAX_LEN_OF_MAC_TABLE);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700487 }
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800488 total--;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700489 }
490}
491
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800492void SendRefreshBAR(IN PRTMP_ADAPTER pAd, IN MAC_TABLE_ENTRY * pEntry)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700493{
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800494 FRAME_BAR FrameBar;
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800495 unsigned long FrameLen;
496 int NStatus;
497 u8 *pOutBuffer = NULL;
498 u16 Sequence;
499 u8 i, TID;
500 u16 idx;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800501 BA_ORI_ENTRY *pBAEntry;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700502
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800503 for (i = 0; i < NUM_OF_TID; i++) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700504 idx = pEntry->BAOriWcidArray[i];
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800505 if (idx == 0) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700506 continue;
507 }
508 pBAEntry = &pAd->BATable.BAOriEntry[idx];
509
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800510 if (pBAEntry->ORI_BA_Status == Originator_Done) {
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700511 TID = pBAEntry->TID;
512
513 ASSERT(pBAEntry->Wcid < MAX_LEN_OF_MAC_TABLE);
514
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800515 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800516 if (NStatus != NDIS_STATUS_SUCCESS) {
517 DBGPRINT(RT_DEBUG_ERROR,
518 ("BA - MlmeADDBAAction() allocate memory failed \n"));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700519 return;
520 }
521
522 Sequence = pEntry->TxSeq[TID];
Bartlomiej Zolnierkiewicz6a28a69a2009-04-26 16:05:46 +0200523
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800524 BarHeaderInit(pAd, &FrameBar, pEntry->Addr,
525 pAd->CurrentAddress);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700526
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800527 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. */
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700530
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800531 MakeOutgoingFrame(pOutBuffer, &FrameLen,
532 sizeof(FRAME_BAR), &FrameBar,
533 END_OF_ARGS);
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800534 /*if (!(CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_RALINK_CHIPSET))) */
535 if (1) /* Now we always send BAR. */
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200536 {
Bartlomiej Zolnierkiewiczec278fa2009-12-11 12:23:15 -0800537 /*MiniportMMRequestUnlock(pAd, 0, pOutBuffer, FrameLen); */
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800538 MiniportMMRequest(pAd,
539 (MGMT_USE_QUEUE_FLAG |
540 MapUserPriorityToAccessCategory
541 [TID]), pOutBuffer,
542 FrameLen);
Bartlomiej Zolnierkiewicz59fe2d82009-04-26 16:06:28 +0200543
Bartlomiej Zolnierkiewiczca97b832009-09-22 20:44:07 +0200544 }
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700545 MlmeFreeMemory(pAd, pOutBuffer);
546 }
547 }
548}
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700549
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800550void ActHeaderInit(IN PRTMP_ADAPTER pAd,
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800551 IN OUT PHEADER_802_11 pHdr80211,
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800552 u8 *Addr1, u8 *Addr2, u8 *Addr3)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700553{
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800554 NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
555 pHdr80211->FC.Type = BTYPE_MGMT;
556 pHdr80211->FC.SubType = SUBTYPE_ACTION;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700557
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800558 COPY_MAC_ADDR(pHdr80211->Addr1, Addr1);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700559 COPY_MAC_ADDR(pHdr80211->Addr2, Addr2);
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800560 COPY_MAC_ADDR(pHdr80211->Addr3, Addr3);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700561}
562
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800563void BarHeaderInit(IN PRTMP_ADAPTER pAd,
564 IN OUT PFRAME_BAR pCntlBar, u8 *pDA, u8 *pSA)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700565{
566 NdisZeroMemory(pCntlBar, sizeof(FRAME_BAR));
567 pCntlBar->FC.Type = BTYPE_CNTL;
568 pCntlBar->FC.SubType = SUBTYPE_BLOCK_ACK_REQ;
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800569 pCntlBar->BarControl.MTID = 0;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700570 pCntlBar->BarControl.Compressed = 1;
571 pCntlBar->BarControl.ACKPolicy = 0;
572
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800573 pCntlBar->Duration =
574 16 + RTMPCalcDuration(pAd, RATE_1, sizeof(FRAME_BA));
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700575
576 COPY_MAC_ADDR(pCntlBar->Addr1, pDA);
577 COPY_MAC_ADDR(pCntlBar->Addr2, pSA);
578}
579
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700580/*
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 */
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800594void InsertActField(IN PRTMP_ADAPTER pAd,
595 u8 *pFrameBuf,
596 unsigned long *pFrameLen, u8 Category, u8 ActCode)
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700597{
Bartlomiej Zolnierkiewicz51126de2009-12-11 12:23:15 -0800598 unsigned long TempLen;
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700599
Bartlomiej Zolnierkiewicz96b3c83d2009-12-11 12:23:13 -0800600 MakeOutgoingFrame(pFrameBuf, &TempLen,
601 1, &Category, 1, &ActCode, END_OF_ARGS);
Greg Kroah-Hartman91980992008-10-28 14:48:09 -0700602
603 *pFrameLen = *pFrameLen + TempLen;
604
605 return;
606}