Ejemplo n.º 1
0
/*
========================================================================
Routine Description:
	Handle a alarm.

Arguments:
	pAd					- WLAN control block pointer

Return Value:
	None

Note:
	You can use different methods to handle QBSS Load alarm here.

	Current methods are:
	1. Change 20/40 to 20-only.
	2. Change channel to the clear channel.
========================================================================
*/
static VOID QBSS_LoadAlarm(
    IN		RTMP_ADAPTER	*pAd)
{
    /* suspend alarm until channel switch */
    QBSS_LoadAlarmSuspend(pAd);

    pAd->QloadAlarmNumber ++;

    /* check if we have already been 20M bandwidth */
#ifdef DOT11_N_SUPPORT
#ifdef DOT11N_DRAFT3
    if ((pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset != 0) &&
            (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth != 0))
    {
        MAC_TABLE *pMacTable;
        UINT32 StaId;


        DBGPRINT(RT_DEBUG_TRACE, ("qbss> Alarm! Change to 20 bw...\n"));

        /* disassociate stations without D3 2040Coexistence function */
        pMacTable = &pAd->MacTab;

        for(StaId=1; StaId<MAX_LEN_OF_MAC_TABLE; StaId++)
        {
            MAC_TABLE_ENTRY *pEntry = &pMacTable->Content[StaId];
            BOOLEAN bDisconnectSta = FALSE;

            if (!IS_ENTRY_CLIENT(pEntry))
                continue;
            /* End of if */

            if (pEntry->Sst != SST_ASSOC)
                continue;
            /* End of if */

            if (pEntry->BSS2040CoexistenceMgmtSupport)
                bDisconnectSta = TRUE;
            /* End of if */

            if (bDisconnectSta)
            {
                /* send wireless event - for ageout */
                RTMPSendWirelessEvent(pAd, IW_AGEOUT_EVENT_FLAG, pEntry->Addr, 0, 0);

                {
                    PUCHAR      pOutBuffer = NULL;
                    NDIS_STATUS NStatus;
                    ULONG       FrameLen = 0;
                    HEADER_802_11 DeAuthHdr;
                    USHORT      Reason;

                    /*  send out a DISASSOC request frame */
                    NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
                    if (NStatus != NDIS_STATUS_SUCCESS)
                    {
                        DBGPRINT(RT_DEBUG_TRACE, (" MlmeAllocateMemory fail  ..\n"));
                        /*NdisReleaseSpinLock(&pAd->MacTabLock); */
                        continue;
                    }

                    Reason = REASON_DEAUTH_STA_LEAVING;
                    MgtMacHeaderInit(pAd, &DeAuthHdr, SUBTYPE_DEAUTH, 0,
                                     pEntry->Addr,
#ifdef P2P_SUPPORT
                                     pAd->ApCfg.MBSSID[pEntry->apidx].Bssid,
#endif /* P2P_SUPPORT */
                                     pAd->ApCfg.MBSSID[pEntry->apidx].Bssid);
                    MakeOutgoingFrame(pOutBuffer,            &FrameLen,
                                      sizeof(HEADER_802_11), &DeAuthHdr,
                                      2,                     &Reason,
                                      END_OF_ARGS);
                    MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
                    MlmeFreeMemory(pAd, pOutBuffer);
                }

                DBGPRINT(RT_DEBUG_TRACE, ("qbss> Alarm! Deauth the station "
                                          "%02x:%02x:%02x:%02x:%02x:%02x\n",
                                          pEntry->Addr[0], pEntry->Addr[1],
                                          pEntry->Addr[2], pEntry->Addr[3],
                                          pEntry->Addr[4], pEntry->Addr[5]));

                MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr);
                continue;
            } /* End of if */
        } /* End of for */

        /* for 11n */
        pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
        pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = 0;

        /* always 20M */
        pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;

        /* mark alarm flag */
        pAd->FlgQloadAlarm = TRUE;

        QBSS_LoadAlarmResume(pAd);
    }
    else
#endif /* DOT11N_DRAFT3 */
#endif /* DOT11_N_SUPPORT */
    {
        /* we are in 20MHz bandwidth so try to switch channel */
        DBGPRINT(RT_DEBUG_TRACE, ("qbss> Alarm! Switch channel...\n"));

        /* send command to switch channel */
        RTEnqueueInternalCmd(pAd, CMDTHREAD_CHAN_RESCAN, NULL, 0);
    } /* End of if */
} /* End of QBSS_LoadAlarm */
Ejemplo n.º 2
0
/*
========================================================================
Routine Description:
	Handle a alarm.

Arguments:
	pAd					- WLAN control block pointer

Return Value:
	None

Note:
	You can use different methods to handle QBSS Load alarm here.

	Current methods are:
	1. Change 20/40 to 20-only.
	2. Change channel to the clear channel.
========================================================================
*/
static VOID QBSS_LoadAlarm(
 	IN		struct rtmp_adapter *pAd)
{
	/* suspend alarm until channel switch */
	QBSS_LoadAlarmSuspend(pAd);

	pAd->QloadAlarmNumber ++;

	/* check if we have already been 20M bandwidth */
	if ((pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset != 0) &&
		(pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth != 0))
	{
		struct mt7612u_mac_table *pMacTable;
		uint32_t StaId;


		DBGPRINT(RT_DEBUG_TRACE, ("qbss> Alarm! Change to 20 bw...\n"));

		/* disassociate stations without D3 2040Coexistence function */
		pMacTable = &pAd->MacTab;

		for(StaId=1; StaId<MAX_LEN_OF_MAC_TABLE; StaId++)
		{
			MAC_TABLE_ENTRY *pEntry = &pMacTable->Content[StaId];
			bool bDisconnectSta = false;

			if (!IS_ENTRY_CLIENT(pEntry))
				continue;

			if (pEntry->Sst != SST_ASSOC)
				continue;

			if (pEntry->BSS2040CoexistenceMgmtSupport)
				bDisconnectSta = true;

			if (bDisconnectSta)
			{
				/* send wireless event - for ageout */
				RTMPSendWirelessEvent(pAd, IW_AGEOUT_EVENT_FLAG, pEntry->Addr, 0, 0);

				{
					u8 *pOutBuffer = NULL;
					int NStatus;
					ULONG FrameLen = 0;
					HEADER_802_11 DeAuthHdr;
					unsigned short Reason;

					/*  send out a DISASSOC request frame */
					pOutBuffer = kmalloc(MGMT_DMA_BUFFER_SIZE, GFP_ATOMIC);
					if (pOutBuffer == NULL)
					{
						DBGPRINT(RT_DEBUG_TRACE, (" kmalloc fail  ..\n"));
						/*NdisReleaseSpinLock(&pAd->MacTabLock); */
						continue;
					}

					Reason = REASON_DEAUTH_STA_LEAVING;
					MgtMacHeaderInit(pAd, &DeAuthHdr, SUBTYPE_DEAUTH, 0,
									pEntry->Addr,
									pAd->ApCfg.MBSSID[pEntry->apidx].wdev.if_addr,
									pAd->ApCfg.MBSSID[pEntry->apidx].wdev.bssid);
				    	MakeOutgoingFrame(pOutBuffer, &FrameLen,
				    	                  sizeof(HEADER_802_11), &DeAuthHdr,
				    	                  2,                     &Reason,
				    	                  END_OF_ARGS);
				    	MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
				    	kfree(pOutBuffer);
				}

				DBGPRINT(RT_DEBUG_TRACE, ("qbss> Alarm! Deauth the station "
						"%02x:%02x:%02x:%02x:%02x:%02x\n",
						PRINT_MAC(pEntry->Addr)));

				MacTableDeleteEntry(pAd, pEntry->wcid, pEntry->Addr);
				continue;
			}
		}

		/* for 11n */
		pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
		pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = 0;

		/* always 20M */
		pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;

		/* mark alarm flag */
		pAd->FlgQloadAlarm = true;

		QBSS_LoadAlarmResume(pAd);
	}
	else
	{
		/* we are in 20MHz bandwidth so try to switch channel */
		DBGPRINT(RT_DEBUG_TRACE, ("qbss> Alarm! Switch channel...\n"));

		/* send command to switch channel */
		RTEnqueueInternalCmd(pAd, CMDTHREAD_CHAN_RESCAN, NULL, 0);
	}
}