2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 Handle association related requests either from WSTA or from local MLME
35 -------- ---------- ----------------------------------------------
36 Jan Lee 2006 created for rt2860
39 #include "../rt_config.h"
40 #include "../action.h"
43 static VOID ReservedAction(
45 IN MLME_QUEUE_ELEM *Elem);
48 ==========================================================================
50 association state machine init, including state transition and timer init
52 S - pointer to the association state machine
54 The state machine looks like the following
57 MT2_MLME_DISASSOC_REQ mlme_disassoc_req_action
58 MT2_PEER_DISASSOC_REQ peer_disassoc_action
59 MT2_PEER_ASSOC_REQ drop
60 MT2_PEER_REASSOC_REQ drop
61 MT2_CLS3ERR cls3err_action
62 ==========================================================================
64 VOID ActionStateMachineInit(
67 OUT STATE_MACHINE_FUNC Trans[])
69 StateMachineInit(S, (STATE_MACHINE_FUNC *)Trans, MAX_ACT_STATE, MAX_ACT_MSG, (STATE_MACHINE_FUNC)Drop, ACT_IDLE, ACT_MACHINE_BASE);
71 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_SPECTRUM_CATE, (STATE_MACHINE_FUNC)PeerSpectrumAction);
72 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE, (STATE_MACHINE_FUNC)PeerQOSAction);
74 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)ReservedAction);
76 #ifdef DOT11_N_SUPPORT
77 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE, (STATE_MACHINE_FUNC)PeerBAAction);
78 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_HT_CATE, (STATE_MACHINE_FUNC)PeerHTAction);
79 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ADD_BA_CATE, (STATE_MACHINE_FUNC)MlmeADDBAAction);
80 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ORI_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
81 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_REC_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
82 #endif // DOT11_N_SUPPORT //
84 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE, (STATE_MACHINE_FUNC)PeerPublicAction);
85 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE, (STATE_MACHINE_FUNC)PeerRMAction);
87 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_QOS_CATE, (STATE_MACHINE_FUNC)MlmeQOSAction);
88 StateMachineSetAction(S, ACT_IDLE, MT2_MLME_DLS_CATE, (STATE_MACHINE_FUNC)MlmeDLSAction);
89 StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID, (STATE_MACHINE_FUNC)MlmeInvalidAction);
92 #ifdef DOT11_N_SUPPORT
95 IN MLME_QUEUE_ELEM *Elem)
98 MLME_ADDBA_REQ_STRUCT *pInfo;
100 PUCHAR pOutBuffer = NULL;
103 FRAME_ADDBA_REQ Frame;
105 BA_ORI_ENTRY *pBAEntry = NULL;
107 pInfo = (MLME_ADDBA_REQ_STRUCT *)Elem->Msg;
108 NdisZeroMemory(&Frame, sizeof(FRAME_ADDBA_REQ));
110 if(MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr))
112 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
113 if(NStatus != NDIS_STATUS_SUCCESS)
115 DBGPRINT(RT_DEBUG_TRACE,("BA - MlmeADDBAAction() allocate memory failed \n"));
119 Idx = pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
122 MlmeFreeMemory(pAd, pOutBuffer);
123 DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
128 pBAEntry =&pAd->BATable.BAOriEntry[Idx];
131 #ifdef CONFIG_STA_SUPPORT
132 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
135 ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
137 ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pInfo->pAddr);
140 #endif // CONFIG_STA_SUPPORT //
142 Frame.Category = CATEGORY_BA;
143 Frame.Action = ADDBA_REQ;
144 Frame.BaParm.AMSDUSupported = 0;
145 Frame.BaParm.BAPolicy = IMMED_BA;
146 Frame.BaParm.TID = pInfo->TID;
147 Frame.BaParm.BufSize = pInfo->BaBufSize;
148 Frame.Token = pInfo->Token;
149 Frame.TimeOutValue = pInfo->TimeOutValue;
150 Frame.BaStartSeq.field.FragNum = 0;
151 Frame.BaStartSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];
153 *(USHORT *)(&Frame.BaParm) = cpu2le16(*(USHORT *)(&Frame.BaParm));
154 Frame.TimeOutValue = cpu2le16(Frame.TimeOutValue);
155 Frame.BaStartSeq.word = cpu2le16(Frame.BaStartSeq.word);
157 MakeOutgoingFrame(pOutBuffer, &FrameLen,
158 sizeof(FRAME_ADDBA_REQ), &Frame,
160 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
161 //MiniportDataMMRequest(pAd, MapUserPriorityToAccessCategory[pInfo->TID], pOutBuffer, FrameLen);
162 MlmeFreeMemory(pAd, pOutBuffer);
164 DBGPRINT(RT_DEBUG_TRACE, ("BA - Send ADDBA request. StartSeq = %x, FrameLen = %ld. BufSize = %d\n", Frame.BaStartSeq.field.StartSeq, FrameLen, Frame.BaParm.BufSize));
169 ==========================================================================
171 send DELBA and delete BaEntry if any
173 Elem - MLME message MLME_DELBA_REQ_STRUCT
175 IRQL = DISPATCH_LEVEL
177 ==========================================================================
179 VOID MlmeDELBAAction(
180 IN PRTMP_ADAPTER pAd,
181 IN MLME_QUEUE_ELEM *Elem)
183 MLME_DELBA_REQ_STRUCT *pInfo;
184 PUCHAR pOutBuffer = NULL;
185 PUCHAR pOutBuffer2 = NULL;
188 FRAME_DELBA_REQ Frame;
192 pInfo = (MLME_DELBA_REQ_STRUCT *)Elem->Msg;
193 // must send back DELBA
194 NdisZeroMemory(&Frame, sizeof(FRAME_DELBA_REQ));
195 DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
197 if(MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen))
199 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
200 if(NStatus != NDIS_STATUS_SUCCESS)
202 DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
206 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); //Get an unused nonpaged memory
207 if(NStatus != NDIS_STATUS_SUCCESS)
209 MlmeFreeMemory(pAd, pOutBuffer);
210 DBGPRINT(RT_DEBUG_ERROR, ("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
214 // SEND BAR (Send BAR to refresh peer reordering buffer.)
215 Idx = pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
217 #ifdef CONFIG_STA_SUPPORT
218 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
219 BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress);
220 #endif // CONFIG_STA_SUPPORT //
222 FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL funciton.
223 FrameBar.StartingSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID]; // make sure sequence not clear in DEL funciton.
224 FrameBar.BarControl.TID = pInfo->TID; // make sure sequence not clear in DEL funciton.
225 FrameBar.BarControl.ACKPolicy = IMMED_BA; // make sure sequence not clear in DEL funciton.
226 FrameBar.BarControl.Compressed = 1; // make sure sequence not clear in DEL funciton.
227 FrameBar.BarControl.MTID = 0; // make sure sequence not clear in DEL funciton.
229 MakeOutgoingFrame(pOutBuffer2, &FrameLen,
230 sizeof(FRAME_BAR), &FrameBar,
232 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
233 MlmeFreeMemory(pAd, pOutBuffer2);
234 DBGPRINT(RT_DEBUG_TRACE,("BA - MlmeDELBAAction() . Send BAR to refresh peer reordering buffer \n"));
238 #ifdef CONFIG_STA_SUPPORT
239 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
242 ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
244 ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->MacTab.Content[pInfo->Wcid].Addr);
246 #endif // CONFIG_STA_SUPPORT //
247 Frame.Category = CATEGORY_BA;
248 Frame.Action = DELBA;
249 Frame.DelbaParm.Initiator = pInfo->Initiator;
250 Frame.DelbaParm.TID = pInfo->TID;
251 Frame.ReasonCode = 39; // Time Out
252 *(USHORT *)(&Frame.DelbaParm) = cpu2le16(*(USHORT *)(&Frame.DelbaParm));
253 Frame.ReasonCode = cpu2le16(Frame.ReasonCode);
255 MakeOutgoingFrame(pOutBuffer, &FrameLen,
256 sizeof(FRAME_DELBA_REQ), &Frame,
258 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
259 MlmeFreeMemory(pAd, pOutBuffer);
260 DBGPRINT(RT_DEBUG_TRACE, ("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n", pInfo->Initiator));
263 #endif // DOT11_N_SUPPORT //
266 IN PRTMP_ADAPTER pAd,
267 IN MLME_QUEUE_ELEM *Elem)
272 IN PRTMP_ADAPTER pAd,
273 IN MLME_QUEUE_ELEM *Elem)
277 VOID MlmeInvalidAction(
278 IN PRTMP_ADAPTER pAd,
279 IN MLME_QUEUE_ELEM *Elem)
281 //PUCHAR pOutBuffer = NULL;
282 //Return the receiving frame except the MSB of category filed set to 1. 7.3.1.11
286 IN PRTMP_ADAPTER pAd,
287 IN MLME_QUEUE_ELEM *Elem)
291 #ifdef DOT11_N_SUPPORT
293 IN PRTMP_ADAPTER pAd,
294 IN MLME_QUEUE_ELEM *Elem)
296 UCHAR Action = Elem->Msg[LENGTH_802_11+1];
301 PeerAddBAReqAction(pAd,Elem);
304 PeerAddBARspAction(pAd,Elem);
307 PeerDelBAAction(pAd,Elem);
315 #ifdef CONFIG_STA_SUPPORT
316 VOID StaPublicAction(
317 IN PRTMP_ADAPTER pAd,
318 IN UCHAR Bss2040Coexist)
320 BSS_2040_COEXIST_IE BssCoexist;
321 MLME_SCAN_REQ_STRUCT ScanReq;
323 BssCoexist.word = Bss2040Coexist;
324 // AP asks Station to return a 20/40 BSS Coexistence mgmt frame. So we first starts a scan, then send back 20/40 BSS Coexistence mgmt frame
325 if ((BssCoexist.field.InfoReq == 1) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040)))
327 // Clear record first. After scan , will update those bit and send back to transmiter.
328 pAd->CommonCfg.BSSCoexist2040.field.InfoReq = 1;
329 pAd->CommonCfg.BSSCoexist2040.field.Intolerant40 = 0;
330 pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq = 0;
331 // Fill out stuff for scan request
332 ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_2040_BSS_COEXIST);
333 MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
334 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
340 Description : Build Intolerant Channel Rerpot from Trigger event table.
341 return : how many bytes copied.
343 ULONG BuildIntolerantChannelRep(
344 IN PRTMP_ADAPTER pAd,
348 ULONG ReadOffset = 0;
350 UCHAR LastRegClass = 0xff;
353 for ( i = 0;i < MAX_TRIGGER_EVENT;i++)
355 if (pAd->CommonCfg.TriggerEventTab.EventA[i].bValid == TRUE)
357 if (pAd->CommonCfg.TriggerEventTab.EventA[i].RegClass == LastRegClass)
359 *(pDest + ReadOffset) = (UCHAR)pAd->CommonCfg.TriggerEventTab.EventA[i].Channel;
366 *(pDest + ReadOffset) = IE_2040_BSS_INTOLERANT_REPORT; // IE
367 *(pDest + ReadOffset + 1) = 2; // Len = RegClass byte + channel byte.
368 pLen = pDest + ReadOffset + 1;
369 LastRegClass = pAd->CommonCfg.TriggerEventTab.EventA[i].RegClass;
370 *(pDest + ReadOffset + 2) = LastRegClass; // Len = RegClass byte + channel byte.
371 *(pDest + ReadOffset + 3) = (UCHAR)pAd->CommonCfg.TriggerEventTab.EventA[i].Channel;
383 Description : Send 20/40 BSS Coexistence Action frame If one trigger event is triggered.
385 VOID Send2040CoexistAction(
386 IN PRTMP_ADAPTER pAd,
388 IN BOOLEAN bAddIntolerantCha)
390 PUCHAR pOutBuffer = NULL;
392 FRAME_ACTION_HDR Frame;
394 ULONG IntolerantChaRepLen;
396 IntolerantChaRepLen = 0;
397 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
398 if(NStatus != NDIS_STATUS_SUCCESS)
400 DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction() allocate memory failed \n"));
403 ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[Wcid].Addr, pAd->CommonCfg.Bssid);
404 Frame.Category = CATEGORY_PUBLIC;
405 Frame.Action = ACTION_BSS_2040_COEXIST;
407 MakeOutgoingFrame(pOutBuffer, &FrameLen,
408 sizeof(FRAME_ACTION_HDR), &Frame,
411 *(pOutBuffer + FrameLen) = pAd->CommonCfg.BSSCoexist2040.word;
414 if (bAddIntolerantCha == TRUE)
415 IntolerantChaRepLen = BuildIntolerantChannelRep(pAd, pOutBuffer + FrameLen);
417 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen + IntolerantChaRepLen);
418 DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction( BSSCoexist2040 = 0x%x ) \n", pAd->CommonCfg.BSSCoexist2040.word));
424 ==========================================================================
426 After scan, Update 20/40 BSS Coexistence IE and send out.
427 According to 802.11n D3.03 11.14.10
430 ==========================================================================
432 VOID Update2040CoexistFrameAndNotify(
433 IN PRTMP_ADAPTER pAd,
435 IN BOOLEAN bAddIntolerantCha)
437 BSS_2040_COEXIST_IE OldValue;
439 OldValue.word = pAd->CommonCfg.BSSCoexist2040.word;
440 if ((pAd->CommonCfg.TriggerEventTab.EventANo > 0) || (pAd->CommonCfg.TriggerEventTab.EventBCountDown > 0))
441 pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq = 1;
443 // Need to check !!!!
444 // How STA will set Intolerant40 if implementation dependent. Now we don't set this bit first.!!!!!
445 // So Only check BSS20WidthReq change.
446 if (OldValue.field.BSS20WidthReq != pAd->CommonCfg.BSSCoexist2040.field.BSS20WidthReq)
448 Send2040CoexistAction(pAd, Wcid, bAddIntolerantCha);
451 #endif // CONFIG_STA_SUPPORT //
454 BOOLEAN ChannelSwitchSanityCheck(
455 IN PRTMP_ADAPTER pAd,
462 if (Wcid >= MAX_LEN_OF_MAC_TABLE)
465 if ((NewChannel > 7) && (Secondary == 1))
468 if ((NewChannel < 5) && (Secondary == 3))
471 // 0. Check if new channel is in the channellist.
472 for (i = 0;i < pAd->ChannelListNum;i++)
474 if (pAd->ChannelList[i].Channel == NewChannel)
480 if (i == pAd->ChannelListNum)
487 VOID ChannelSwitchAction(
488 IN PRTMP_ADAPTER pAd,
496 DBGPRINT(RT_DEBUG_TRACE,("SPECTRUM - ChannelSwitchAction(NewChannel = %d , Secondary = %d) \n", NewChannel, Secondary));
498 if (ChannelSwitchSanityCheck(pAd, Wcid, NewChannel, Secondary) == FALSE)
501 // 1. Switches to BW = 20.
504 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
506 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
507 if (pAd->MACVersion == 0x28600100)
509 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
510 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);
511 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
512 DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
514 pAd->CommonCfg.BBPCurrentBW = BW_20;
515 pAd->CommonCfg.Channel = NewChannel;
516 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
517 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel,FALSE);
518 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
519 pAd->MacTab.Content[Wcid].HTPhyMode.field.BW = 0;
520 DBGPRINT(RT_DEBUG_TRACE, ("!!!20MHz !!! \n" ));
522 // 1. Switches to BW = 40 And Station supports BW = 40.
523 else if (((Secondary == 1) || (Secondary == 3)) && (pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth == 1))
525 pAd->CommonCfg.Channel = NewChannel;
530 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
531 RTMP_IO_READ32(pAd, TX_BAND_CFG, &MACValue);
533 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, MACValue);
534 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
537 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
538 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPValue);
540 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPValue);
541 DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));
546 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
547 RTMP_IO_READ32(pAd, TX_BAND_CFG, &MACValue);
550 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, MACValue);
551 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
554 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
555 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPValue);
558 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPValue);
559 DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel ));
561 pAd->CommonCfg.BBPCurrentBW = BW_40;
562 AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
563 AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
564 pAd->MacTab.Content[Wcid].HTPhyMode.field.BW = 1;
567 #endif // DOT11N_DRAFT3 //
568 #endif // DOT11_N_SUPPORT //
570 VOID PeerPublicAction(
571 IN PRTMP_ADAPTER pAd,
572 IN MLME_QUEUE_ELEM *Elem)
575 UCHAR Action = Elem->Msg[LENGTH_802_11+1];
576 #endif // DOT11N_DRAFT3 //
578 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
584 case ACTION_BSS_2040_COEXIST: // Format defined in IEEE 7.4.7a.1 in 11n Draf3.03
587 BSS_2040_COEXIST_ELEMENT *pCoexistInfo;
588 BSS_2040_COEXIST_IE *pBssCoexistIe;
589 BSS_2040_INTOLERANT_CH_REPORT *pIntolerantReport = NULL;
591 if (Elem->MsgLen <= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT)) )
593 DBGPRINT(RT_DEBUG_ERROR, ("ACTION - 20/40 BSS Coexistence Management Frame length too short! len = %ld!\n", Elem->MsgLen));
596 DBGPRINT(RT_DEBUG_TRACE, ("ACTION - 20/40 BSS Coexistence Management action----> \n"));
597 hex_dump("CoexistenceMgmtFrame", Elem->Msg, Elem->MsgLen);
600 pCoexistInfo = (BSS_2040_COEXIST_ELEMENT *) &Elem->Msg[LENGTH_802_11+2];
601 //hex_dump("CoexistInfo", (PUCHAR)pCoexistInfo, sizeof(BSS_2040_COEXIST_ELEMENT));
602 if (Elem->MsgLen >= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT) + sizeof(BSS_2040_INTOLERANT_CH_REPORT)))
604 pIntolerantReport = (BSS_2040_INTOLERANT_CH_REPORT *)((PUCHAR)pCoexistInfo + sizeof(BSS_2040_COEXIST_ELEMENT));
606 //hex_dump("IntolerantReport ", (PUCHAR)pIntolerantReport, sizeof(BSS_2040_INTOLERANT_CH_REPORT));
608 pBssCoexistIe = (BSS_2040_COEXIST_IE *)(&pCoexistInfo->BssCoexistIe);
610 #ifdef CONFIG_STA_SUPPORT
611 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
615 StaPublicAction(pAd, pCoexistInfo);
618 #endif // CONFIG_STA_SUPPORT //
624 #endif // DOT11N_DRAFT3 //
629 static VOID ReservedAction(
630 IN PRTMP_ADAPTER pAd,
631 IN MLME_QUEUE_ELEM *Elem)
635 if (Elem->MsgLen <= LENGTH_802_11)
640 Category = Elem->Msg[LENGTH_802_11];
641 DBGPRINT(RT_DEBUG_TRACE,("Rcv reserved category(%d) Action Frame\n", Category));
642 hex_dump("Reserved Action Frame", &Elem->Msg[0], Elem->MsgLen);
646 IN PRTMP_ADAPTER pAd,
647 IN MLME_QUEUE_ELEM *Elem)
653 #ifdef DOT11_N_SUPPORT
654 static VOID respond_ht_information_exchange_action(
655 IN PRTMP_ADAPTER pAd,
656 IN MLME_QUEUE_ELEM *Elem)
658 PUCHAR pOutBuffer = NULL;
661 FRAME_HT_INFO HTINFOframe, *pFrame;
665 // 2. Always send back ADDBA Response
666 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
668 if (NStatus != NDIS_STATUS_SUCCESS)
670 DBGPRINT(RT_DEBUG_TRACE,("ACTION - respond_ht_information_exchange_action() allocate memory failed \n"));
675 pFrame = (FRAME_HT_INFO *) &Elem->Msg[0];
676 pAddr = pFrame->Hdr.Addr2;
678 NdisZeroMemory(&HTINFOframe, sizeof(FRAME_HT_INFO));
679 // 2-1. Prepare ADDBA Response frame.
680 #ifdef CONFIG_STA_SUPPORT
681 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
684 ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
686 ActHeaderInit(pAd, &HTINFOframe.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAddr);
688 #endif // CONFIG_STA_SUPPORT //
690 HTINFOframe.Category = CATEGORY_HT;
691 HTINFOframe.Action = HT_INFO_EXCHANGE;
692 HTINFOframe.HT_Info.Request = 0;
693 HTINFOframe.HT_Info.Forty_MHz_Intolerant = pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant;
694 HTINFOframe.HT_Info.STA_Channel_Width = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
696 MakeOutgoingFrame(pOutBuffer, &FrameLen,
697 sizeof(FRAME_HT_INFO), &HTINFOframe,
700 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
701 MlmeFreeMemory(pAd, pOutBuffer);
706 VOID SendNotifyBWActionFrame(
707 IN PRTMP_ADAPTER pAd,
711 PUCHAR pOutBuffer = NULL;
713 FRAME_ACTION_HDR Frame;
718 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
719 if(NStatus != NDIS_STATUS_SUCCESS)
721 DBGPRINT(RT_DEBUG_ERROR,("ACT - SendNotifyBWAction() allocate memory failed \n"));
725 if (Wcid == MCAST_WCID)
726 pAddr1 = &BROADCAST_ADDR[0];
728 pAddr1 = pAd->MacTab.Content[Wcid].Addr;
729 ActHeaderInit(pAd, &Frame.Hdr, pAddr1, pAd->ApCfg.MBSSID[apidx].Bssid, pAd->ApCfg.MBSSID[apidx].Bssid);
731 Frame.Category = CATEGORY_HT;
732 Frame.Action = NOTIFY_BW_ACTION;
734 MakeOutgoingFrame(pOutBuffer, &FrameLen,
735 sizeof(FRAME_ACTION_HDR), &Frame,
738 *(pOutBuffer + FrameLen) = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
742 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
743 DBGPRINT(RT_DEBUG_TRACE,("ACT - SendNotifyBWAction(NotifyBW= %d)!\n", pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth));
746 #endif // DOT11N_DRAFT3 //
750 IN PRTMP_ADAPTER pAd,
751 IN MLME_QUEUE_ELEM *Elem)
753 UCHAR Action = Elem->Msg[LENGTH_802_11+1];
755 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
760 case NOTIFY_BW_ACTION:
761 DBGPRINT(RT_DEBUG_TRACE,("ACTION - HT Notify Channel bandwidth action----> \n"));
762 #ifdef CONFIG_STA_SUPPORT
763 if(pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
765 // Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps
766 // sending BW_Notify Action frame, and cause us to linkup and linkdown.
767 // In legacy mode, don't need to parse HT action frame.
768 DBGPRINT(RT_DEBUG_TRACE,("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n",
769 Elem->Msg[LENGTH_802_11+2] ));
772 #endif // CONFIG_STA_SUPPORT //
774 if (Elem->Msg[LENGTH_802_11+2] == 0) // 7.4.8.2. if value is 1, keep the same as supported channel bandwidth.
775 pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
781 DBGPRINT(RT_DEBUG_TRACE,("ACTION - SMPS action----> \n"));
782 if (((Elem->Msg[LENGTH_802_11+2]&0x1) == 0))
784 pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_ENABLE;
786 else if (((Elem->Msg[LENGTH_802_11+2]&0x2) == 0))
788 pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_STATIC;
792 pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_DYNAMIC;
795 DBGPRINT(RT_DEBUG_TRACE,("Aid(%d) MIMO PS = %d\n", Elem->Wcid, pAd->MacTab.Content[Elem->Wcid].MmpsMode));
796 // rt2860c : add something for smps change.
802 case MIMO_CHA_MEASURE_ACTION:
805 case HT_INFO_EXCHANGE:
807 HT_INFORMATION_OCTET *pHT_info;
809 pHT_info = (HT_INFORMATION_OCTET *) &Elem->Msg[LENGTH_802_11+2];
811 DBGPRINT(RT_DEBUG_TRACE,("ACTION - HT Information Exchange action----> \n"));
812 if (pHT_info->Request)
814 respond_ht_information_exchange_action(pAd, Elem);
823 ==========================================================================
825 Retry sending ADDBA Reqest.
827 IRQL = DISPATCH_LEVEL
830 p8023Header: if this is already 802.3 format, p8023Header is NULL
832 Return : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
833 FALSE , then continue indicaterx at this moment.
834 ==========================================================================
836 VOID ORIBATimerTimeout(
837 IN PRTMP_ADAPTER pAd)
839 MAC_TABLE_ENTRY *pEntry;
841 // FRAME_BAR FrameBar;
843 // NDIS_STATUS NStatus;
844 // PUCHAR pOutBuffer = NULL;
848 total = pAd->MacTab.Size * NUM_OF_TID;
850 for (i = 1; ((i <MAX_LEN_OF_BA_ORI_TABLE) && (total > 0)) ; i++)
852 if (pAd->BATable.BAOriEntry[i].ORI_BA_Status == Originator_Done)
854 pEntry = &pAd->MacTab.Content[pAd->BATable.BAOriEntry[i].Wcid];
855 TID = pAd->BATable.BAOriEntry[i].TID;
857 ASSERT(pAd->BATable.BAOriEntry[i].Wcid < MAX_LEN_OF_MAC_TABLE);
865 IN PRTMP_ADAPTER pAd,
866 IN MAC_TABLE_ENTRY *pEntry)
871 PUCHAR pOutBuffer = NULL;
875 BA_ORI_ENTRY *pBAEntry;
877 for (i = 0; i <NUM_OF_TID; i++)
879 idx = pEntry->BAOriWcidArray[i];
884 pBAEntry = &pAd->BATable.BAOriEntry[idx];
886 if (pBAEntry->ORI_BA_Status == Originator_Done)
890 ASSERT(pBAEntry->Wcid < MAX_LEN_OF_MAC_TABLE);
892 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
893 if(NStatus != NDIS_STATUS_SUCCESS)
895 DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() allocate memory failed \n"));
899 Sequence = pEntry->TxSeq[TID];
902 #ifdef CONFIG_STA_SUPPORT
903 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
904 BarHeaderInit(pAd, &FrameBar, pEntry->Addr, pAd->CurrentAddress);
905 #endif // CONFIG_STA_SUPPORT //
907 FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL function.
908 FrameBar.StartingSeq.field.StartSeq = Sequence; // make sure sequence not clear in DEL funciton.
909 FrameBar.BarControl.TID = TID; // make sure sequence not clear in DEL funciton.
911 MakeOutgoingFrame(pOutBuffer, &FrameLen,
912 sizeof(FRAME_BAR), &FrameBar,
914 //if (!(CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_RALINK_CHIPSET)))
915 if (1) // Now we always send BAR.
917 //MiniportMMRequestUnlock(pAd, 0, pOutBuffer, FrameLen);
918 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
919 //MiniportDataMMRequest(pAd, MapUserPriorityToAccessCategory[TID], pOutBuffer, FrameLen);
921 MlmeFreeMemory(pAd, pOutBuffer);
925 #endif // DOT11_N_SUPPORT //
928 IN PRTMP_ADAPTER pAd,
929 IN OUT PHEADER_802_11 pHdr80211,
934 NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
935 pHdr80211->FC.Type = BTYPE_MGMT;
936 pHdr80211->FC.SubType = SUBTYPE_ACTION;
938 COPY_MAC_ADDR(pHdr80211->Addr1, Addr1);
939 COPY_MAC_ADDR(pHdr80211->Addr2, Addr2);
940 COPY_MAC_ADDR(pHdr80211->Addr3, Addr3);
944 IN PRTMP_ADAPTER pAd,
945 IN OUT PFRAME_BAR pCntlBar,
951 NdisZeroMemory(pCntlBar, sizeof(FRAME_BAR));
952 pCntlBar->FC.Type = BTYPE_CNTL;
953 pCntlBar->FC.SubType = SUBTYPE_BLOCK_ACK_REQ;
954 pCntlBar->BarControl.MTID = 0;
955 pCntlBar->BarControl.Compressed = 1;
956 pCntlBar->BarControl.ACKPolicy = 0;
959 pCntlBar->Duration = 16 + RTMPCalcDuration(pAd, RATE_1, sizeof(FRAME_BA));
961 COPY_MAC_ADDR(pCntlBar->Addr1, pDA);
962 COPY_MAC_ADDR(pCntlBar->Addr2, pSA);
967 ==========================================================================
969 Insert Category and action code into the action frame.
972 1. frame buffer pointer.
974 3. category code of the frame.
975 4. action code of the frame.
978 ==========================================================================
981 IN PRTMP_ADAPTER pAd,
982 OUT PUCHAR pFrameBuf,
983 OUT PULONG pFrameLen,
989 MakeOutgoingFrame( pFrameBuf, &TempLen,
994 *pFrameLen = *pFrameLen + TempLen;