/* ======================================================================== Routine Description: Close a virtual network interface. Arguments: pDev which WLAN network interface Return Value: 0: close successfully otherwise: close fail Note: ======================================================================== */ INT MBSS_Close(PNET_DEV pDev) { PRTMP_ADAPTER pAd; INT BssId; pAd = RTMP_OS_NETDEV_GET_PRIV(pDev); BssId = RT28xx_MBSS_IdxGet(pAd, pDev); if (BssId < 0) return -1; RTMP_OS_NETDEV_STOP_QUEUE(pDev); /* kick out all stas behind the Bss */ MbssKickOutStas(pAd, BssId, REASON_DISASSOC_INACTIVE); pAd->ApCfg.MBSSID[BssId].bBcnSntReq = FALSE; APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #ifdef MESH_SUPPORT MeshMakeBeacon(pAd, MESH_BEACON_IDX(pAd)); MeshUpdateBeaconFrame(pAd, MESH_BEACON_IDX(pAd)); #endif /* MESH_SUPPORT */ return 0; }
/* ======================================================================== Routine Description: Close a virtual network interface. Arguments: pDev which WLAN network interface Return Value: 0: close successfully otherwise: close fail Note: ======================================================================== */ INT MBSS_VirtualIF_Close( IN PNET_DEV pDev) { PRTMP_ADAPTER pAd; INT BssId; DBGPRINT(RT_DEBUG_TRACE, ("%s: ===> MBSSVirtualIF_close\n", RTMP_OS_NETDEV_GET_DEVNAME(pDev))); pAd = RTMP_OS_NETDEV_GET_PRIV(pDev); BssId = RT28xx_MBSS_IdxGet(pAd, pDev); if (BssId < 0) return -1; RTMP_OS_NETDEV_STOP_QUEUE(pDev); /* kick out all stas behind the Bss */ MbssKickOutStas(pAd, BssId, REASON_DISASSOC_INACTIVE); pAd->ApCfg.MBSSID[BssId].bBcnSntReq = FALSE; APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); VIRTUAL_IF_DOWN(pAd); RT_MOD_DEC_USE_COUNT(); return 0; } /* End of MBSS_VirtualIF_Close */
/* ======================================================================== Routine Description: Close raxx interface. Arguments: *net_dev the raxx interface pointer Return Value: 0 Open OK otherwise Open Fail Note: 1. if open fail, kernel will not call the close function. 2. Free memory for (1) Mlme Memory Handler: MlmeHalt() (2) TX & RX: RTMPFreeTxRxRingMemory() (3) BA Reordering: ba_reordering_resource_release() ======================================================================== */ int MainVirtualIF_close(IN struct net_device *net_dev) { RTMP_ADAPTER *pAd = NULL; GET_PAD_FROM_NET_DEV(pAd, net_dev); // Sanity check for pAd if (pAd == NULL) return 0; // close ok netif_carrier_off(pAd->net_dev); netif_stop_queue(pAd->net_dev); #ifdef CONFIG_AP_SUPPORT pAd->ApCfg.MBSSID[MAIN_MBSSID].bBcnSntReq = FALSE; IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { // kick out all STAs behind the bss. MbssKickOutStas(pAd, MAIN_MBSSID, REASON_DISASSOC_INACTIVE); } APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif // CONFIG_AP_SUPPORT // VIRTUAL_IF_DOWN(pAd); RT_MOD_DEC_USE_COUNT(); return 0; // close ok }
INT Set_NfcConfigurationToken_Proc( IN RTMP_ADAPTER *pAd, IN PSTRING arg) { POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; PWSC_CTRL pWscCtrl = &pAd->ApCfg.MBSSID[pObj->ioctl_if].WscControl; PUCHAR pBuf = NULL; USHORT BufLen = 0; /* Action: b¡¦<7:6>: 0x00 ¡V Request, 0x01 ¡V Notify b¡¦<5:0>: 0x00 ¡V Get, 0x01 - Set */ UCHAR action = 1, type = TYPE_CONFIGURATION; os_alloc_mem(pAd, (UCHAR **)&pBuf, (NFC_WSC_TLV_SIZE*sizeof(UCHAR))); if (pBuf == NULL) { return FALSE; } NfcBuildWscProfileTLV(pAd, pWscCtrl, pBuf, &BufLen); if (pBuf && (BufLen != 0)) { NfcCommand(pAd, action, type, BufLen, pBuf); os_free_mem(NULL, pBuf); } if ((pAd->OpMode == OPMODE_AP) && (pWscCtrl->WscConfStatus == WSC_SCSTATE_UNCONFIGURED)) { pWscCtrl->WscConfStatus = WSC_SCSTATE_CONFIGURED; WscBuildBeaconIE(pAd, WSC_SCSTATE_CONFIGURED, FALSE, 0, 0, 0, NULL, 0,AP_MODE); WscBuildProbeRespIE(pAd, WSC_MSGTYPE_AP_WLAN_MGR, WSC_SCSTATE_CONFIGURED, FALSE, 0, 0, 0, NULL, 0,AP_MODE); APUpdateAllBeaconFrame(pAd); } if (pWscCtrl->WscUpdatePortCfgTimerRunning) { BOOLEAN bCancel; RTMPCancelTimer(&pWscCtrl->WscUpdatePortCfgTimer, &bCancel); } else pWscCtrl->WscUpdatePortCfgTimerRunning = TRUE; RTMPSetTimer(&pWscCtrl->WscUpdatePortCfgTimer, 1000); return TRUE; }
/* ======================================================================== Routine Description: Arguments: pAd Pointer to our adapter. Rewrite beacon content before next send-out. IRQL = DISPATCH_LEVEL ======================================================================== */ VOID RTMPHandlePreTBTTInterrupt( IN PRTMP_ADAPTER pAd) { #ifdef CONFIG_AP_SUPPORT if (pAd->OpMode == OPMODE_AP) { APUpdateAllBeaconFrame(pAd); } else #endif // CONFIG_AP_SUPPORT // { if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) { DBGPRINT(RT_DEBUG_TRACE, ("RTMPHandlePreTBTTInterrupt...\n")); } } }
/* ======================================================================== Routine Description: Close a virtual network interface. Arguments: pDev which WLAN network interface Return Value: 0: close successfully otherwise: close fail Note: ======================================================================== */ int MBSS_Close( IN PNET_DEV pDev) { PRTMP_ADAPTER pAd; int BssId; pAd = RTMP_OS_NETDEV_GET_PRIV(pDev); BssId = RT28xx_MBSS_IdxGet(pAd, pDev); if (BssId < 0) return -1; RTMP_OS_NETDEV_STOP_QUEUE(pDev); /* kick out all stas behind the Bss */ MbssKickOutStas(pAd, BssId, REASON_DISASSOC_INACTIVE); pAd->ApCfg.MBSSID[BssId].bBcnSntReq = FALSE; APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); return 0; }
/* ========================================================================== Description: This routine is executed every second - 1. Decide the overall channel quality 2. Check if need to upgrade the TX rate to any client 3. perform MAC table maintenance, including ageout no-traffic clients, and release packet buffer in PSQ is fail to TX in time. ========================================================================== */ VOID APMlmePeriodicExec( PRTMP_ADAPTER pAd) { /* Reqeust by David 2005/05/12 It make sense to disable Adjust Tx Power on AP mode, since we can't take care all of the client's situation ToDo: need to verify compatibility issue with WiFi product. */ #ifdef CARRIER_DETECTION_SUPPORT if (isCarrierDetectExist(pAd) == TRUE) { PCARRIER_DETECTION_STRUCT pCarrierDetect = &pAd->CommonCfg.CarrierDetect; if (pCarrierDetect->OneSecIntCount < pCarrierDetect->CarrierGoneThreshold) { pCarrierDetect->CD_State = CD_NORMAL; pCarrierDetect->recheck = pCarrierDetect->recheck1; if (pCarrierDetect->Debug != RT_DEBUG_TRACE) { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); /* start all TX actions. */ APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); AsicEnableBssSync(pAd); } else { printk("Carrier gone\n"); } } pCarrierDetect->OneSecIntCount = 0; } #endif /* CARRIER_DETECTION_SUPPORT */ RTMP_CHIP_HIGH_POWER_TUNING(pAd, &pAd->ApCfg.RssiSample); /* Disable Adjust Tx Power for WPA WiFi-test. */ /* Because high TX power results in the abnormal disconnection of Intel BG-STA. */ /*#ifndef WIFI_TEST */ /* if (pAd->CommonCfg.bWiFiTest == FALSE) */ /* for SmartBit 64-byte stream test */ /* removed based on the decision of Ralink congress at 2011/7/06 */ /* if (pAd->MacTab.Size > 0) */ AsicAdjustTxPower(pAd); /*#endif // WIFI_TEST */ #ifdef RTMP_TEMPERATURE_COMPENSATION MT76x0_TemperatureCompensation(pAd); #endif /* RTMP_TEMPERATURE_COMPENSATION */ /* BBP TUNING: dynamic tune BBP R66 to find a balance between sensibility and noise isolation */ /* AsicBbpTuning2(pAd); */ /* walk through MAC table, see if switching TX rate is required */ /* MAC table maintenance */ if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE == 0) { /* one second timer */ MacTableMaintenance(pAd); #ifdef FPGA_MODE if (pAd->fpga_tr_stop) { UINT32 mac_val; /* enable/disable tx/rx*/ RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &mac_val); switch (pAd->fpga_tr_stop) { case 3: //stop tx + rx mac_val &= (~0xc); break; case 2: // stop rx mac_val &= (~0x8); break; case 1: // stop tx mac_val &= (~0x4); break; case 4: default: mac_val |= 0x0c; break; } RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, mac_val); } #endif /* FGPA_MODE */ RTMPMaintainPMKIDCache(pAd); #ifdef WDS_SUPPORT WdsTableMaintenance(pAd); #endif /* WDS_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabMaintain(pAd); #endif /* CLIENT_WDS */ } APUpdateCapabilityAndErpIe(pAd); #ifdef APCLI_SUPPORT if (pAd->Mlme.OneSecPeriodicRound % 2 == 0) ApCliIfMonitor(pAd); if (pAd->Mlme.OneSecPeriodicRound % 2 == 1) ApCliIfUp(pAd); { INT loop; ULONG Now32; UINT32 MaxWcidNum = MAX_LEN_OF_MAC_TABLE; #ifdef MAC_REPEATER_SUPPORT if (pAd->ApCfg.bMACRepeaterEn) { MaxWcidNum = MAX_MAC_TABLE_SIZE_WITH_REPEATER; #ifdef APCLI_AUTO_CONNECT_SUPPORT RTMPRepeaterReconnectionCheck(pAd); #endif /* APCLI_AUTO_CONNECT_SUPPORT */ } #endif /* MAC_REPEATER_SUPPORT */ NdisGetSystemUpTime(&Now32); for (loop = 0; loop < MAX_APCLI_NUM; loop++) { PAPCLI_STRUCT pApCliEntry = &pAd->ApCfg.ApCliTab[loop]; if ((pApCliEntry->Valid == TRUE) && (pApCliEntry->MacTabWCID < MaxWcidNum)) { /* update channel quality for Roaming and UI LinkQuality display */ MlmeCalculateChannelQuality(pAd, &pAd->MacTab.Content[pApCliEntry->MacTabWCID], Now32); } } } #endif /* APCLI_SUPPORT */ #ifdef DOT11_N_SUPPORT if (pAd->CommonCfg.bHTProtect) { /*APUpdateCapabilityAndErpIe(pAd); */ APUpdateOperationMode(pAd); if (pAd->CommonCfg.IOTestParm.bRTSLongProtOn == FALSE) { AsicUpdateProtect(pAd, (USHORT)pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, pAd->MacTab.fAnyStationNonGF); } } #endif /* DOT11_N_SUPPORT */ #ifdef A_BAND_SUPPORT if ( (pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == 1) ) { #ifdef DFS_SUPPORT ApRadarDetectPeriodic(pAd); #else pAd->Dot11_H.InServiceMonitorCount++; if (pAd->Dot11_H.RDMode == RD_SILENCE_MODE) { if (pAd->Dot11_H.RDCount++ > pAd->Dot11_H.ChMovingTime) { AsicEnableBssSync(pAd); pAd->Dot11_H.RDMode = RD_NORMAL_MODE; } } #endif /* !DFS_SUPPORT */ } #endif /* A_BAND_SUPPORT */ /* resume Improved Scanning*/ if ((pAd->ApCfg.bImprovedScan) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) && (pAd->Mlme.ApSyncMachine.CurrState == AP_SCAN_PENDING)) { MLME_SCAN_REQ_STRUCT ScanReq; AsicDisableSync(pAd); RTMPZeroMemory(ScanReq.Ssid, MAX_LEN_OF_SSID); ScanReq.SsidLen = pAd->MlmeAux.SsidLen; NdisMoveMemory(ScanReq.Ssid, pAd->MlmeAux.Ssid, ScanReq.SsidLen); ScanReq.BssType = BSS_ANY; #ifdef APCLI_CONNECTION_TRIAL ScanReq.ScanType = FAST_SCAN_ACTIVE; #else ScanReq.ScanType = SCAN_ACTIVE; #endif /* APCLI_CONNECTION_TRIAL */ MlmeEnqueue(pAd, AP_SYNC_STATE_MACHINE, APMT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq, 0); RTMP_MLME_HANDLER(pAd); DBGPRINT(RT_DEBUG_TRACE, ("bImprovedScan ............. Resume for bImprovedScan, SCAN_PENDING .............. \n")); } }
/* ========================================================================== Description: This routine is executed every second - 1. Decide the overall channel quality 2. Check if need to upgrade the TX rate to any client 3. perform MAC table maintenance, including ageout no-traffic clients, and release packet buffer in PSQ is fail to TX in time. ========================================================================== */ VOID APMlmePeriodicExec( PRTMP_ADAPTER pAd) { /* Reqeust by David 2005/05/12 It make sense to disable Adjust Tx Power on AP mode, since we can't take care all of the client's situation ToDo: need to verify compatibility issue with WiFi product. */ /* We return here in ATE mode, because the statistics that ATE need are not collected via this routine. */ #ifdef RALINK_ATE if (ATE_ON(pAd)) return; #endif /* RALINK_ATE */ #ifdef CARRIER_DETECTION_SUPPORT if (isCarrierDetectExist(pAd) == TRUE) { if (pAd->CommonCfg.CarrierDetect.OneSecIntCount < pAd->CommonCfg.CarrierDetect.CarrierGoneThreshold) { pAd->CommonCfg.CarrierDetect.CD_State = CD_NORMAL; pAd->CommonCfg.CarrierDetect.recheck = pAd->CommonCfg.CarrierDetect.recheck1; if (pAd->CommonCfg.CarrierDetect.Debug != RT_DEBUG_TRACE) { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); /* start all TX actions. */ APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); AsicEnableBssSync(pAd); } else { printk("Carrier gone\n"); } } } pAd->CommonCfg.CarrierDetect.OneSecIntCount = 0; #endif /* CARRIER_DETECTION_SUPPORT */ RTMP_CHIP_HIGH_POWER_TUNING(pAd, &pAd->ApCfg.RssiSample); /* Disable Adjust Tx Power for WPA WiFi-test. */ /* Because high TX power results in the abnormal disconnection of Intel BG-STA. */ /*#ifndef WIFI_TEST */ /* if (pAd->CommonCfg.bWiFiTest == FALSE) */ /* for SmartBit 64-byte stream test */ /* removed based on the decision of Ralink congress at 2011/7/06 */ /* if (pAd->MacTab.Size > 0) */ AsicAdjustTxPower(pAd); /*#endif // WIFI_TEST */ /* BBP TUNING: dynamic tune BBP R66 to find a balance between sensibility and noise isolation */ /* AsicBbpTuning2(pAd); */ /* walk through MAC table, see if switching TX rate is required */ /* MAC table maintenance */ if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE == 0) { /* one second timer */ MacTableMaintenance(pAd); RTMPMaintainPMKIDCache(pAd); #ifdef WDS_SUPPORT WdsTableMaintenance(pAd); #endif /* WDS_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabMaintain(pAd); #endif /* CLIENT_WDS */ } APUpdateCapabilityAndErpIe(pAd); #ifdef APCLI_SUPPORT if (pAd->Mlme.OneSecPeriodicRound % 2 == 0) ApCliIfMonitor(pAd); if (pAd->Mlme.OneSecPeriodicRound % 2 == 1) ApCliIfUp(pAd); { INT loop; ULONG Now32; NdisGetSystemUpTime(&Now32); for (loop = 0; loop < MAX_APCLI_NUM; loop++) { PAPCLI_STRUCT pApCliEntry = &pAd->ApCfg.ApCliTab[loop]; if ((pApCliEntry->Valid == TRUE) && (pApCliEntry->MacTabWCID < MAX_LEN_OF_MAC_TABLE)) { /* update channel quality for Roaming and UI LinkQuality display */ MlmeCalculateChannelQuality(pAd, &pAd->MacTab.Content[pApCliEntry->MacTabWCID], Now32); } } } #endif /* APCLI_SUPPORT */ #ifdef DOT11_N_SUPPORT if (pAd->CommonCfg.bHTProtect) { /*APUpdateCapabilityAndErpIe(pAd); */ APUpdateOperationMode(pAd); if (pAd->CommonCfg.IOTestParm.bRTSLongProtOn == FALSE) { AsicUpdateProtect(pAd, (USHORT)pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, pAd->MacTab.fAnyStationNonGF); } } #endif /* DOT11_N_SUPPORT */ #ifdef A_BAND_SUPPORT if ( (pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == 1) ) { #ifdef DFS_SUPPORT ApRadarDetectPeriodic(pAd); #else pAd->CommonCfg.InServiceMonitorCount++; if (pAd->CommonCfg.RDMode == RD_SILENCE_MODE) { if (pAd->CommonCfg.RDCount++ > pAd->CommonCfg.ChMovingTime) { AsicEnableBssSync(pAd); pAd->CommonCfg.RDMode = RD_NORMAL_MODE; } } #endif /* DFS_SUPPORT */ } #endif /* A_BAND_SUPPORT */ }
VOID NfcParseRspCommand( IN PRTMP_ADAPTER pAd, IN PUCHAR pData, IN USHORT DataLen) { NFC_CMD_INFO *pNfcCmdInfo = NULL; BOOLEAN bSetFromNfc = FALSE; PWSC_CTRL pWscCtrl = &pAd->ApCfg.MBSSID[0].WscControl; DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__)); hex_dump("Packet", pData, DataLen); os_alloc_mem(pAd, (UCHAR **)&pNfcCmdInfo, (DataLen*sizeof(UCHAR))); if (pNfcCmdInfo) { NdisMoveMemory(pNfcCmdInfo, pData, DataLen); hex_dump("Packet", &pNfcCmdInfo->data[0], pNfcCmdInfo->data_len); bSetFromNfc = ((pNfcCmdInfo->action & 0x41) == 0x41); DBGPRINT(RT_DEBUG_TRACE, ("==> vendor_id: 0x%04x, action = 0x%0x, type = %d, data_len = %u, bSetFromNfc = %d\n", pNfcCmdInfo->vendor_id, pNfcCmdInfo->action, pNfcCmdInfo->type, pNfcCmdInfo->data_len, bSetFromNfc)); switch(pNfcCmdInfo->type) { case TYPE_CMD_RESULT: DBGPRINT(RT_DEBUG_TRACE, ("TYPE_CMD_RESULT(=%d): Command result = %d\n", pNfcCmdInfo->type, pNfcCmdInfo->data[0])); break; case TYPE_CONFIGURATION: DBGPRINT(RT_DEBUG_TRACE, ("TYPE_CONFIGURATION(=%d)\n", pNfcCmdInfo->type)); if (bSetFromNfc) { if (pNfcCmdInfo->data_len != 1) { /* Receive Configuration from NFC daemon. */ if (WscProcessCredential(pAd, &pNfcCmdInfo->data[0], pNfcCmdInfo->data_len, pWscCtrl) == FALSE) { DBGPRINT(RT_DEBUG_TRACE, ("ProcessCredential fail..\n")); } else { if ((pAd->OpMode == OPMODE_AP) && (pWscCtrl->WscConfStatus == WSC_SCSTATE_UNCONFIGURED)) { pWscCtrl->WscConfStatus = WSC_SCSTATE_CONFIGURED; WscBuildBeaconIE(pAd, WSC_SCSTATE_CONFIGURED, FALSE, 0, 0, 0, NULL, 0, AP_MODE); WscBuildProbeRespIE(pAd, WSC_MSGTYPE_AP_WLAN_MGR, WSC_SCSTATE_CONFIGURED, FALSE, 0, 0, 0, NULL, 0, AP_MODE); APUpdateAllBeaconFrame(pAd); } if (pWscCtrl->WscUpdatePortCfgTimerRunning) { BOOLEAN bCancel; RTMPCancelTimer(&pWscCtrl->WscUpdatePortCfgTimer, &bCancel); } else pWscCtrl->WscUpdatePortCfgTimerRunning = TRUE; RTMPSetTimer(&pWscCtrl->WscUpdatePortCfgTimer, 1000); } } } else { Set_NfcConfigurationToken_Proc(pAd, "1"); } break; case TYPE_PASSWORD: DBGPRINT(RT_DEBUG_TRACE, ("TYPE_PASSWORD(=%d)\n", pNfcCmdInfo->type)); if (bSetFromNfc) { if (pNfcCmdInfo->data_len != 1) { /* Receive Passwd from NFC daemon. */ NfcProcessPasswdTV(pAd, &pNfcCmdInfo->data[0], pNfcCmdInfo->data_len, pWscCtrl, FALSE); WscGetConfWithoutTrigger(pAd, pWscCtrl, FALSE); pWscCtrl->bTriggerByNFC = TRUE; pWscCtrl->NfcModel = MODEL_PASSWORD_TOKEN; } } else { Set_NfcPasswdToken_Proc(pAd, "1"); } break; /* New type for Handover */ case TYPE_PASSWDHO_S: DBGPRINT(RT_DEBUG_TRACE, ("TYPE_PASSWDHO_S(=%d)\n", pNfcCmdInfo->type)); if (bSetFromNfc) { if (pNfcCmdInfo->data_len != 1) { /* Receive Passwd from NFC daemon. "So far" no this case. Due to AP always as Registrar in handover procedure, AP only receive "Handover Request Message". */ NfcProcessPasswdTV(pAd, &pNfcCmdInfo->data[0], pNfcCmdInfo->data_len, pWscCtrl, TRUE); WscGetConfWithoutTrigger(pAd, pWscCtrl, FALSE); pWscCtrl->bTriggerByNFC = TRUE; pWscCtrl->NfcModel = MODEL_HANDOVER; /* 2 */ } } else { Set_NfcPasswdToken_Proc(pAd, "2"); } break; case TYPE_PASSWDHO_R: DBGPRINT(RT_DEBUG_TRACE, ("TYPE_PASSWDHO_R(=%d)\n", pNfcCmdInfo->type)); if (bSetFromNfc) { if (pNfcCmdInfo->data_len != 1) { /* Receive Passwd from NFC daemon. */ NfcProcessPasswdTV(pAd, &pNfcCmdInfo->data[0], pNfcCmdInfo->data_len, pWscCtrl, TRUE); WscGetConfWithoutTrigger(pAd, pWscCtrl, FALSE); pWscCtrl->bTriggerByNFC = TRUE; pWscCtrl->NfcModel = MODEL_HANDOVER; /* 2 */ } } else { /* "So far" no this case. Due to AP always as Registrar in handover procedure, AP only send "Handover Select Message". */ Set_NfcPasswdToken_Proc(pAd, "3"); } break; case TYPE_NFC_STATUS: DBGPRINT(RT_DEBUG_TRACE, ("TYPE_NFC_STATUS(=%d): NFC Status = %d\n", pNfcCmdInfo->type, pNfcCmdInfo->data[0])); pWscCtrl->NfcStatus = pNfcCmdInfo->data[0]; break; case TYPE_WIFI_RADIO_STATUS: DBGPRINT(RT_DEBUG_TRACE, ("TYPE_WIFI_RADIO_STATUS(=%d)\n", pNfcCmdInfo->type)); if (bSetFromNfc) { if (pNfcCmdInfo->data[0] == 1) MlmeRadioOn(pAd); else MlmeRadioOff(pAd); } else { UCHAR RadioStatus = 0; if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) RadioStatus = 0; else RadioStatus = 1; NfcCommand(pAd, 0x01, TYPE_WIFI_RADIO_STATUS, 1, &RadioStatus); } break; default: DBGPRINT(RT_DEBUG_TRACE, ("Unknow type(=%d)\n", pNfcCmdInfo->type)); break; } os_free_mem(NULL, pNfcCmdInfo); } DBGPRINT(RT_DEBUG_TRACE, ("<==== %s\n", __FUNCTION__)); return; }
/* ========================================================================== Description: This routine is executed every second - 1. Decide the overall channel quality 2. Check if need to upgrade the TX rate to any client 3. perform MAC table maintenance, including ageout no-traffic clients, and release packet buffer in PSQ is fail to TX in time. ========================================================================== */ VOID APMlmePeriodicExec( PRTMP_ADAPTER pAd) { /* Reqeust by David 2005/05/12 It make sense to disable Adjust Tx Power on AP mode, since we can't take care all of the client's situation ToDo: need to verify compatibility issue with WiFi product. */ #ifdef CARRIER_DETECTION_SUPPORT if (isCarrierDetectExist(pAd) == TRUE) { PCARRIER_DETECTION_STRUCT pCarrierDetect = &pAd->CommonCfg.CarrierDetect; if (pCarrierDetect->OneSecIntCount < pCarrierDetect->CarrierGoneThreshold) { pCarrierDetect->CD_State = CD_NORMAL; pCarrierDetect->recheck = pCarrierDetect->recheck1; if (pCarrierDetect->Debug != RT_DEBUG_TRACE) { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); /* start all TX actions. */ APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); AsicEnableBssSync(pAd); } else { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); } } pCarrierDetect->OneSecIntCount = 0; } #endif /* CARRIER_DETECTION_SUPPORT */ RTMP_CHIP_HIGH_POWER_TUNING(pAd, &pAd->ApCfg.RssiSample); /* Disable Adjust Tx Power for WPA WiFi-test. */ /* Because high TX power results in the abnormal disconnection of Intel BG-STA. */ /*#ifndef WIFI_TEST */ /* if (pAd->CommonCfg.bWiFiTest == FALSE) */ /* for SmartBit 64-byte stream test */ /* removed based on the decision of Ralink congress at 2011/7/06 */ /* if (pAd->MacTab.Size > 0) */ #ifdef RT6352 if (IS_RT6352(pAd)) RT6352_AsicAdjustTxPower(pAd); else #endif /* RT6352 */ AsicAdjustTxPower(pAd); /*#endif // WIFI_TEST */ #ifdef THERMAL_PROTECT_SUPPORT thermal_protection(pAd); #endif /* THERMAL_PROTECT_SUPPORT */ RTMP_CHIP_ASIC_TEMPERATURE_COMPENSATION(pAd); /* walk through MAC table, see if switching TX rate is required */ /* MAC table maintenance */ if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE == 0) { /* one second timer */ MacTableMaintenance(pAd); #ifdef CONFIG_FPGA_MODE if (pAd->fpga_ctl.fpga_tr_stop) { UINT32 mac_val; /* enable/disable tx/rx*/ RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &mac_val); switch (pAd->fpga_ctl.fpga_tr_stop) { case 3: //stop tx + rx mac_val &= (~0xc); break; case 2: // stop rx mac_val &= (~0x8); break; case 1: // stop tx mac_val &= (~0x4); break; case 4: default: mac_val |= 0x0c; break; } RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, mac_val); } #endif /* CONFIG_FPGA_MODE */ RTMPMaintainPMKIDCache(pAd); #ifdef WDS_SUPPORT WdsTableMaintenance(pAd); #endif /* WDS_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabMaintain(pAd); #endif /* CLIENT_WDS */ } #ifdef AP_SCAN_SUPPORT AutoChannelSelCheck(pAd); #endif /* AP_SCAN_SUPPORT */ APUpdateCapabilityAndErpIe(pAd); #ifdef APCLI_SUPPORT if (pAd->Mlme.OneSecPeriodicRound % 2 == 0) ApCliIfMonitor(pAd); if (pAd->Mlme.OneSecPeriodicRound % 2 == 1) #ifdef APCLI_AUTO_CONNECT_SUPPORT if (pAd->ApCfg.ApCliAutoConnectChannelSwitching == FALSE) #endif /* APCLI_AUTO_CONNECT_SUPPORT */ ApCliIfUp(pAd); { INT loop; ULONG Now32; #ifdef APCLI_CERT_SUPPORT BOOLEAN IsUseBA = TRUE; #endif /* APCLI_CERT_SUPPORT */ #ifdef MAC_REPEATER_SUPPORT if (pAd->ApCfg.bMACRepeaterEn == TRUE) { #ifdef APCLI_AUTO_CONNECT_SUPPORT RTMPRepeaterReconnectionCheck(pAd); #endif /* APCLI_AUTO_CONNECT_SUPPORT */ } #endif /* MAC_REPEATER_SUPPORT */ NdisGetSystemUpTime(&Now32); for (loop = 0; loop < MAX_APCLI_NUM; loop++) { PAPCLI_STRUCT pApCliEntry = &pAd->ApCfg.ApCliTab[loop]; if (pAd->ApCfg.ApCliTab[loop].bBlockAssoc ==TRUE && pAd->ApCfg.ApCliTab[loop].bBlockAssoc && RTMP_TIME_AFTER(Now32, pAd->ApCfg.ApCliTab[loop].LastMicErrorTime + (60*OS_HZ))) pAd->ApCfg.ApCliTab[loop].bBlockAssoc = FALSE; if ((pApCliEntry->Valid == TRUE) && (pApCliEntry->MacTabWCID < MAX_LEN_OF_MAC_TABLE)) { /* update channel quality for Roaming and UI LinkQuality display */ MlmeCalculateChannelQuality(pAd, &pAd->MacTab.Content[pApCliEntry->MacTabWCID], Now32); /* WPA MIC error should block association attempt for 60 seconds*/ #ifdef APCLI_CERT_SUPPORT if (pAd->bApCliCertTest == TRUE) { PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[pApCliEntry->MacTabWCID]; struct wifi_dev *wdev = NULL; wdev = &pApCliEntry->wdev; if (pEntry->RXBAbitmap == 0 && pEntry->TXBAbitmap == 0) IsUseBA = FALSE; if( wdev->DesiredHtPhyInfo.bHtEnable && IsUseBA == FALSE ) { EDCA_AC_CFG_STRUC Ac2Cfg, Ac1Cfg; RTMP_IO_READ32(pAd, EDCA_AC2_CFG, &Ac2Cfg.word); RTMP_IO_READ32(pAd, EDCA_AC1_CFG, &Ac1Cfg.word); if ((pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] == 0) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] >= 1000) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] == 0)) { /*5.2.27 T7 */ if (Ac1Cfg.field.Aifsn!=0x1) { Ac1Cfg.field.Aifsn = 0x1; RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word); printk("Change EDCA_AC1_CFG to %x \n", Ac1Cfg.word); } } else if ((pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] == 0) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] == 0) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] == 0) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BE] < 10)) { /* restore default parameter of BK*/ if (Ac1Cfg.field.Aifsn!=0x7) { Ac1Cfg.field.Aifsn = 0x7; RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word); printk("Restore EDCA_AC1_CFG to %x \n", Ac1Cfg.word); } } pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BE] = 0; pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] = 0; pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] = 0; pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] = 0; } } #endif /* APCLI_CERT_SUPPORT */ } } } #endif /* APCLI_SUPPORT */ #ifdef DOT11_N_SUPPORT if (pAd->CommonCfg.bHTProtect) { /*APUpdateCapabilityAndErpIe(pAd); */ APUpdateOperationMode(pAd); if (pAd->CommonCfg.IOTestParm.bRTSLongProtOn == FALSE) { AsicUpdateProtect(pAd, (USHORT)pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, pAd->MacTab.fAnyStationNonGF); } } #endif /* DOT11_N_SUPPORT */ #ifdef A_BAND_SUPPORT if ( (pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == 1) ) { #ifdef DFS_SUPPORT ApRadarDetectPeriodic(pAd); #else pAd->Dot11_H.InServiceMonitorCount++; if (pAd->Dot11_H.RDMode == RD_SILENCE_MODE) { if (pAd->Dot11_H.RDCount++ > pAd->Dot11_H.ChMovingTime) { AsicEnableBssSync(pAd); pAd->Dot11_H.RDMode = RD_NORMAL_MODE; } } #endif /* !DFS_SUPPORT */ } #endif /* A_BAND_SUPPORT */ #ifdef APCLI_SUPPORT #ifdef DOT11_N_SUPPORT #ifdef DOT11N_DRAFT3 #ifdef APCLI_CERT_SUPPORT /* Perform 20/40 BSS COEX scan every Dot11BssWidthTriggerScanInt */ if (APCLI_IF_UP_CHECK(pAd, 0) && (pAd->bApCliCertTest == TRUE)) { if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040)) && (pAd->CommonCfg.Dot11BssWidthTriggerScanInt != 0) && ((pAd->Mlme.OneSecPeriodicRound % pAd->CommonCfg.Dot11BssWidthTriggerScanInt) == (pAd->CommonCfg.Dot11BssWidthTriggerScanInt-1))) { DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - LastOneSecTotalTxCount/LastOneSecRxOkDataCnt = %d/%d \n", pAd->RalinkCounters.LastOneSecTotalTxCount, pAd->RalinkCounters.LastOneSecRxOkDataCnt)); /* Check last scan time at least 30 seconds from now. */ /* Check traffic is less than about 1.5~2Mbps.*/ /* it might cause data lost if we enqueue scanning.*/ /* This criteria needs to be considered*/ if ((pAd->RalinkCounters.LastOneSecTotalTxCount < 70) && (pAd->RalinkCounters.LastOneSecRxOkDataCnt < 70) /*&& ((pAd->StaCfg.LastScanTime + 10 * OS_HZ) < pAd->Mlme.Now32) */) { MLME_SCAN_REQ_STRUCT ScanReq; /* Fill out stuff for scan request and kick to scan*/ ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_2040_BSS_COEXIST); /* Before scan, reset trigger event table. */ TriEventInit(pAd); MlmeEnqueue(pAd, AP_SYNC_STATE_MACHINE, APMT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq, 0); /* Set InfoReq = 1, So after scan , alwats sebd 20/40 Coexistence frame to AP*/ pAd->CommonCfg.BSSCoexist2040.field.InfoReq = 1; RTMP_MLME_HANDLER(pAd); } DBGPRINT(RT_DEBUG_TRACE, (" LastOneSecTotalTxCount/LastOneSecRxOkDataCnt = %d/%d \n", pAd->RalinkCounters.LastOneSecTotalTxCount, pAd->RalinkCounters.LastOneSecRxOkDataCnt)); } } #endif /* APCLI_CERT_SUPPORT */ #endif /* DOT11N_DRAFT3 */ #endif /* DOT11_N_SUPPORT */ #endif /* APCLI_SUPPORT */ }
INT RTMP_COM_IoctlHandle( IN VOID *pAdSrc, IN RTMP_IOCTL_INPUT_STRUCT *wrq, IN INT cmd, IN USHORT subcmd, IN VOID *pData, IN ULONG Data) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie; INT Status = NDIS_STATUS_SUCCESS, i; pObj = pObj; /* avoid compile warning */ switch(cmd) { case CMD_RTPRIV_IOCTL_NETDEV_GET: /* get main net_dev */ { VOID **ppNetDev = (VOID **)pData; *ppNetDev = (VOID *)(pAd->net_dev); } break; case CMD_RTPRIV_IOCTL_NETDEV_SET: { struct wifi_dev *wdev = NULL; /* set main net_dev */ pAd->net_dev = pData; #ifdef CONFIG_AP_SUPPORT if (pAd->OpMode == OPMODE_AP) { pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev.if_dev = (void *)pData; pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev.func_dev = (void *)&pAd->ApCfg.MBSSID[MAIN_MBSSID]; pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev.sys_handle = (void *)pAd; RTMP_OS_NETDEV_SET_WDEV(pData, &pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev); wdev = &pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev; } #endif /* CONFIG_AP_SUPPORT */ if (wdev) { if (rtmp_wdev_idx_reg(pAd, wdev) < 0) { DBGPRINT(RT_DEBUG_ERROR, ("Assign wdev idx for %s failed, free net device!\n", RTMP_OS_NETDEV_GET_DEVNAME(pAd->net_dev))); RtmpOSNetDevFree(pAd->net_dev); } } break; } case CMD_RTPRIV_IOCTL_OPMODE_GET: /* get Operation Mode */ *(ULONG *)pData = pAd->OpMode; break; case CMD_RTPRIV_IOCTL_TASK_LIST_GET: /* get all Tasks */ { RT_CMD_WAIT_QUEUE_LIST *pList = (RT_CMD_WAIT_QUEUE_LIST *)pData; pList->pMlmeTask = &pAd->mlmeTask; #ifdef RTMP_TIMER_TASK_SUPPORT pList->pTimerTask = &pAd->timerTask; #endif /* RTMP_TIMER_TASK_SUPPORT */ pList->pCmdQTask = &pAd->cmdQTask; #ifdef WSC_INCLUDED pList->pWscTask = &pAd->wscTask; #endif /* WSC_INCLUDED */ } break; #ifdef RTMP_MAC_PCI case CMD_RTPRIV_IOCTL_IRQ_INIT: /* init IRQ */ rtmp_irq_init(pAd); break; #endif /* RTMP_MAC_PCI */ case CMD_RTPRIV_IOCTL_IRQ_RELEASE: /* release IRQ */ RTMP_OS_IRQ_RELEASE(pAd, pAd->net_dev); break; #ifdef RTMP_MAC_PCI case CMD_RTPRIV_IOCTL_MSI_ENABLE: /* enable MSI */ RTMP_MSI_ENABLE(pAd); *(ULONG **)pData = (ULONG *)(pObj->pci_dev); break; #endif /* RTMP_MAC_PCI */ case CMD_RTPRIV_IOCTL_NIC_NOT_EXIST: /* set driver state to fRTMP_ADAPTER_NIC_NOT_EXIST */ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST); break; case CMD_RTPRIV_IOCTL_MCU_SLEEP_CLEAR: RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_MCU_SLEEP); break; case CMD_RTPRIV_IOCTL_SANITY_CHECK: /* sanity check before IOCTL */ if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) #ifdef IFUP_IN_PROBE || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) #endif /* IFUP_IN_PROBE */ ) { if(pData == NULL || RT_isLegalCmdBeforeInfUp((PSTRING) pData) == FALSE) return NDIS_STATUS_FAILURE; } break; case CMD_RTPRIV_IOCTL_SIOCGIWFREQ: /* get channel number */ *(ULONG *)pData = pAd->CommonCfg.Channel; break; #ifdef CONFIG_SNIFFER_SUPPORT case CMD_RTPRIV_IOCTL_SNIFF_INIT: Monitor_Init(pAd, pData); break; case CMD_RTPRIV_IOCTL_SNIFF_OPEN: if (Monitor_Open(pAd, pData) != TRUE) return NDIS_STATUS_FAILURE; break; case CMD_RTPRIV_IOCTL_SNIFF_CLOSE: if (Monitor_Close(pAd, pData) != TRUE) return NDIS_STATUS_FAILURE; break; case CMD_RTPRIV_IOCTL_SNIFF_REMOVE: Monitor_Remove(pAd); break; #endif /*CONFIG_SNIFFER_SUPPORT*/ case CMD_RTPRIV_IOCTL_BEACON_UPDATE: /* update all beacon contents */ #ifdef CONFIG_AP_SUPPORT APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif /* CONFIG_AP_SUPPORT */ break; case CMD_RTPRIV_IOCTL_RXPATH_GET: /* get the number of rx path */ *(ULONG *)pData = pAd->Antenna.field.RxPath; break; case CMD_RTPRIV_IOCTL_CHAN_LIST_NUM_GET: *(ULONG *)pData = pAd->ChannelListNum; break; case CMD_RTPRIV_IOCTL_CHAN_LIST_GET: { UINT32 i; UCHAR *pChannel = (UCHAR *)pData; for (i = 1; i <= pAd->ChannelListNum; i++) { *pChannel = pAd->ChannelList[i-1].Channel; pChannel ++; } } break; case CMD_RTPRIV_IOCTL_FREQ_LIST_GET: { UINT32 i; UINT32 *pFreq = (UINT32 *)pData; UINT32 m; for (i = 1; i <= pAd->ChannelListNum; i++) { m = 2412000; MAP_CHANNEL_ID_TO_KHZ(pAd->ChannelList[i-1].Channel, m); (*pFreq) = m; pFreq ++; } } break; #ifdef EXT_BUILD_CHANNEL_LIST case CMD_RTPRIV_SET_PRECONFIG_VALUE: /* Set some preconfigured value before interface up*/ pAd->CommonCfg.DfsType = MAX_RD_REGION; break; #endif /* EXT_BUILD_CHANNEL_LIST */ #ifdef RTMP_PCI_SUPPORT case CMD_RTPRIV_IOCTL_PCI_SUSPEND: RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); break; case CMD_RTPRIV_IOCTL_PCI_RESUME: RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); break; case CMD_RTPRIV_IOCTL_PCI_CSR_SET: pAd->CSRBaseAddress = (PUCHAR)Data; DBGPRINT(RT_DEBUG_ERROR, ("pAd->CSRBaseAddress =0x%lx, csr_addr=0x%lx!\n", (ULONG)pAd->CSRBaseAddress, (ULONG)Data)); break; case CMD_RTPRIV_IOCTL_PCIE_INIT: RTMPInitPCIeDevice(pData, pAd); break; #endif /* RTMP_PCI_SUPPORT */ #ifdef RT_CFG80211_SUPPORT case CMD_RTPRIV_IOCTL_CFG80211_CFG_START: RT_CFG80211_REINIT(pAd); RT_CFG80211_CRDA_REG_RULE_APPLY(pAd); break; #endif /* RT_CFG80211_SUPPORT */ #ifdef INF_PPA_SUPPORT case CMD_RTPRIV_IOCTL_INF_PPA_INIT: os_alloc_mem(NULL, (UCHAR **)&(pAd->pDirectpathCb), sizeof(PPA_DIRECTPATH_CB)); break; case CMD_RTPRIV_IOCTL_INF_PPA_EXIT: if (ppa_hook_directpath_register_dev_fn && (pAd->PPAEnable == TRUE)) { UINT status; status = ppa_hook_directpath_register_dev_fn(&pAd->g_if_id, pAd->net_dev, NULL, 0); DBGPRINT(RT_DEBUG_TRACE, ("Unregister PPA::status=%d, if_id=%d\n", status, pAd->g_if_id)); } os_free_mem(NULL, pAd->pDirectpathCb); break; #endif /* INF_PPA_SUPPORT*/ case CMD_RTPRIV_IOCTL_VIRTUAL_INF_UP: /* interface up */ { RT_CMD_INF_UP_DOWN *pInfConf = (RT_CMD_INF_UP_DOWN *)pData; if (VIRTUAL_IF_NUM(pAd) == 0) { if (pInfConf->rt28xx_open(pAd->net_dev) != 0) { DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_open return fail!\n")); return NDIS_STATUS_FAILURE; } } else { #ifdef CONFIG_AP_SUPPORT extern VOID APMakeAllBssBeacon(IN PRTMP_ADAPTER pAd); extern VOID APUpdateAllBeaconFrame(IN PRTMP_ADAPTER pAd); APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif /* CONFIG_AP_SUPPORT */ } VIRTUAL_IF_INC(pAd); } break; case CMD_RTPRIV_IOCTL_VIRTUAL_INF_DOWN: /* interface down */ { RT_CMD_INF_UP_DOWN *pInfConf = (RT_CMD_INF_UP_DOWN *)pData; VIRTUAL_IF_DEC(pAd); if (VIRTUAL_IF_NUM(pAd) == 0) pInfConf->rt28xx_close(pAd->net_dev); } break; case CMD_RTPRIV_IOCTL_VIRTUAL_INF_GET: /* get virtual interface number */ *(ULONG *)pData = VIRTUAL_IF_NUM(pAd); break; case CMD_RTPRIV_IOCTL_INF_TYPE_GET: /* get current interface type */ *(ULONG *)pData = pAd->infType; break; case CMD_RTPRIV_IOCTL_INF_STATS_GET: /* get statistics */ { RT_CMD_STATS *pStats = (RT_CMD_STATS *)pData; pStats->pStats = pAd->stats; if(pAd->OpMode == OPMODE_STA) { pStats->rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart; pStats->tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart; pStats->rx_bytes = pAd->RalinkCounters.ReceivedByteCount; pStats->tx_bytes = pAd->RalinkCounters.TransmittedByteCount; pStats->rx_errors = pAd->Counters8023.RxErrors; pStats->tx_errors = pAd->Counters8023.TxErrors; pStats->multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; /* multicast packets received*/ pStats->collisions = 0; /* Collision packets*/ pStats->rx_over_errors = pAd->Counters8023.RxNoBuffer; /* receiver ring buff overflow*/ pStats->rx_crc_errors = 0;/*pAd->WlanCounters.FCSErrorCount; recved pkt with crc error*/ pStats->rx_frame_errors = 0; /* recv'd frame alignment error*/ pStats->rx_fifo_errors = pAd->Counters8023.RxNoBuffer; /* recv'r fifo overrun*/ } #ifdef CONFIG_AP_SUPPORT else if(pAd->OpMode == OPMODE_AP) { INT index; for(index = 0; index < MAX_MBSSID_NUM(pAd); index++) { if (pAd->ApCfg.MBSSID[index].wdev.if_dev == (PNET_DEV)(pStats->pNetDev)) { break; } } if(index >= MAX_MBSSID_NUM(pAd)) { //reset counters pStats->rx_packets = 0; pStats->tx_packets = 0; pStats->rx_bytes = 0; pStats->tx_bytes = 0; pStats->rx_errors = 0; pStats->tx_errors = 0; pStats->multicast = 0; /* multicast packets received*/ pStats->collisions = 0; /* Collision packets*/ pStats->rx_over_errors = 0; /* receiver ring buff overflow*/ pStats->rx_crc_errors = 0; /* recved pkt with crc error*/ pStats->rx_frame_errors = 0; /* recv'd frame alignment error*/ pStats->rx_fifo_errors = 0; /* recv'r fifo overrun*/ DBGPRINT(RT_DEBUG_ERROR, ("CMD_RTPRIV_IOCTL_INF_STATS_GET: can not find mbss I/F\n")); return NDIS_STATUS_FAILURE; } pStats->rx_packets = pAd->ApCfg.MBSSID[index].RxCount; pStats->tx_packets = pAd->ApCfg.MBSSID[index].TxCount; pStats->rx_bytes = pAd->ApCfg.MBSSID[index].ReceivedByteCount; pStats->tx_bytes = pAd->ApCfg.MBSSID[index].TransmittedByteCount; pStats->rx_errors = pAd->ApCfg.MBSSID[index].RxErrorCount; pStats->tx_errors = pAd->ApCfg.MBSSID[index].TxErrorCount; pStats->multicast = pAd->ApCfg.MBSSID[index].mcPktsRx; /* multicast packets received */ pStats->collisions = 0; /* Collision packets*/ pStats->rx_over_errors = 0; /* receiver ring buff overflow*/ pStats->rx_crc_errors = 0;/* recved pkt with crc error*/ pStats->rx_frame_errors = 0; /* recv'd frame alignment error*/ pStats->rx_fifo_errors = 0; /* recv'r fifo overrun*/ } #endif } break; case CMD_RTPRIV_IOCTL_INF_IW_STATUS_GET: /* get wireless statistics */ { UCHAR CurOpMode = OPMODE_AP; #ifdef CONFIG_AP_SUPPORT PMAC_TABLE_ENTRY pMacEntry = NULL; #endif /* CONFIG_AP_SUPPORT */ RT_CMD_IW_STATS *pStats = (RT_CMD_IW_STATS *)pData; pStats->qual = 0; pStats->level = 0; pStats->noise = 0; pStats->pStats = pAd->iw_stats; /*check if the interface is down*/ if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) return NDIS_STATUS_FAILURE; #ifdef CONFIG_AP_SUPPORT if (CurOpMode == OPMODE_AP) { #ifdef APCLI_SUPPORT if ((pStats->priv_flags == INT_APCLI) ) { INT ApCliIdx = ApCliIfLookUp(pAd, (PUCHAR)pStats->dev_addr); if ((ApCliIdx >= 0) && VALID_WCID(pAd->ApCfg.ApCliTab[ApCliIdx].MacTabWCID)) pMacEntry = &pAd->MacTab.Content[pAd->ApCfg.ApCliTab[ApCliIdx].MacTabWCID]; } else #endif /* APCLI_SUPPORT */ { /* only AP client support wireless stats function. return NULL pointer for all other cases. */ pMacEntry = NULL; } } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_AP_SUPPORT if (CurOpMode == OPMODE_AP) { if (pMacEntry != NULL) pStats->qual = ((pMacEntry->ChannelQuality * 12)/10 + 10); else pStats->qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10); } #endif /* CONFIG_AP_SUPPORT */ if (pStats->qual > 100) pStats->qual = 100; #ifdef CONFIG_AP_SUPPORT if (CurOpMode == OPMODE_AP) { if (pMacEntry != NULL) pStats->level = RTMPMaxRssi(pAd, pMacEntry->RssiSample.AvgRssi0, pMacEntry->RssiSample.AvgRssi1, pMacEntry->RssiSample.AvgRssi2); } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_AP_SUPPORT pStats->noise = RTMPMaxRssi(pAd, pAd->ApCfg.RssiSample.AvgRssi0, pAd->ApCfg.RssiSample.AvgRssi1, pAd->ApCfg.RssiSample.AvgRssi2) - RTMPMinSnr(pAd, pAd->ApCfg.RssiSample.AvgSnr0, pAd->ApCfg.RssiSample.AvgSnr1); #endif /* CONFIG_AP_SUPPORT */ } break; case CMD_RTPRIV_IOCTL_INF_MAIN_CREATE: *(VOID **)pData = RtmpPhyNetDevMainCreate(pAd); break; case CMD_RTPRIV_IOCTL_INF_MAIN_ID_GET: *(ULONG *)pData = INT_MAIN; break; case CMD_RTPRIV_IOCTL_INF_MAIN_CHECK: if (Data != INT_MAIN) return NDIS_STATUS_FAILURE; break; case CMD_RTPRIV_IOCTL_INF_P2P_CHECK: if (Data != INT_P2P) return NDIS_STATUS_FAILURE; break; #ifdef WDS_SUPPORT case CMD_RTPRIV_IOCTL_WDS_INIT: WDS_Init(pAd, pData); break; case CMD_RTPRIV_IOCTL_WDS_REMOVE: WDS_Remove(pAd); break; case CMD_RTPRIV_IOCTL_WDS_STATS_GET: if (Data == INT_WDS) { if (WDS_StatsGet(pAd, pData) != TRUE) return NDIS_STATUS_FAILURE; } else return NDIS_STATUS_FAILURE; break; #endif /* WDS_SUPPORT */ #ifdef RALINK_ATE #ifdef RALINK_QA case CMD_RTPRIV_IOCTL_ATE: RtmpDoAte(pAd, wrq, pData); break; #endif /* RALINK_QA */ #endif /* RALINK_ATE */ case CMD_RTPRIV_IOCTL_MAC_ADDR_GET: { UCHAR mac_addr[MAC_ADDR_LEN]; USHORT Addr01, Addr23, Addr45; RT28xx_EEPROM_READ16(pAd, 0x04, Addr01); RT28xx_EEPROM_READ16(pAd, 0x06, Addr23); RT28xx_EEPROM_READ16(pAd, 0x08, Addr45); mac_addr[0] = (UCHAR)(Addr01 & 0xff); mac_addr[1] = (UCHAR)(Addr01 >> 8); mac_addr[2] = (UCHAR)(Addr23 & 0xff); mac_addr[3] = (UCHAR)(Addr23 >> 8); mac_addr[4] = (UCHAR)(Addr45 & 0xff); mac_addr[5] = (UCHAR)(Addr45 >> 8); for(i=0; i<6; i++) *(UCHAR *)(pData+i) = mac_addr[i]; break; } #ifdef CONFIG_AP_SUPPORT case CMD_RTPRIV_IOCTL_AP_SIOCGIWRATEQ: /* handle for SIOCGIWRATEQ */ { RT_CMD_IOCTL_RATE *pRate = (RT_CMD_IOCTL_RATE *)pData; HTTRANSMIT_SETTING HtPhyMode; UINT8 BW = 0, GI = 0, MCS = 0; #ifdef APCLI_SUPPORT if (pRate->priv_flags == INT_APCLI) memcpy(&HtPhyMode, &pAd->ApCfg.ApCliTab[pObj->ioctl_if].wdev.HTPhyMode, sizeof(HTTRANSMIT_SETTING)); else #endif /* APCLI_SUPPORT */ #ifdef WDS_SUPPORT if (pRate->priv_flags == INT_WDS) memcpy(&HtPhyMode, &pAd->WdsTab.WdsEntry[pObj->ioctl_if].wdev.HTPhyMode, sizeof(HTTRANSMIT_SETTING)); else #endif /* WDS_SUPPORT */ { memcpy(&HtPhyMode, &pAd->ApCfg.MBSSID[pObj->ioctl_if].wdev.HTPhyMode, sizeof(HTTRANSMIT_SETTING)); #ifdef MBSS_SUPPORT /* reset phy mode for MBSS */ MBSS_PHY_MODE_RESET(pObj->ioctl_if, HtPhyMode); #endif /* MBSS_SUPPORT */ } #ifdef DOT11_VHT_AC if (HtPhyMode.field.BW == BW_40 && pAd->CommonCfg.vht_bw == VHT_BW_80 && HtPhyMode.field.MODE >= MODE_VHT) { BW = 2; GI = pAd->CommonCfg.vht_sgi_80; } else #endif /* DOT11_VHT_AC */ { BW = HtPhyMode.field.BW; GI = HtPhyMode.field.ShortGI; } RtmpDrvRateGet(pAd, HtPhyMode.field.MODE, GI, BW, HtPhyMode.field.MCS, pAd->Antenna.field.TxPath, (UINT32 *)&pRate->BitRate); } break; #endif /* CONFIG_AP_SUPPORT */ case CMD_RTPRIV_IOCTL_SIOCGIWNAME: RtmpIoctl_rt_ioctl_giwname(pAd, pData, 0); break; } #ifdef RT_CFG80211_SUPPORT if ((CMD_RTPRIV_IOCTL_80211_START <= cmd) && (cmd <= CMD_RTPRIV_IOCTL_80211_END)) { Status = CFG80211DRV_IoctlHandle(pAd, wrq, cmd, subcmd, pData, Data); } #endif /* RT_CFG80211_SUPPORT */ if (cmd >= CMD_RTPRIV_IOCTL_80211_COM_LATEST_ONE) return NDIS_STATUS_FAILURE; return Status; }
/* ======================================================================== Routine Description: Close raxx interface. Arguments: *net_dev the raxx interface pointer Return Value: 0 Open OK otherwise Open Fail Note: 1. if open fail, kernel will not call the close function. 2. Free memory for (1) Mlme Memory Handler: MlmeHalt() (2) TX & RX: RTMPFreeTxRxRingMemory() (3) BA Reordering: ba_reordering_resource_release() ======================================================================== */ int MainVirtualIF_close(IN struct net_device *net_dev) { RTMP_ADAPTER *pAd = NULL; GET_PAD_FROM_NET_DEV(pAd, net_dev); // Sanity check for pAd if (pAd == NULL) return 0; // close ok netif_carrier_off(pAd->net_dev); netif_stop_queue(pAd->net_dev); #ifdef CONFIG_AP_SUPPORT pAd->ApCfg.MBSSID[MAIN_MBSSID].bBcnSntReq = FALSE; IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { // kick out all STAs behind the bss. MbssKickOutStas(pAd, MAIN_MBSSID, REASON_DISASSOC_INACTIVE); } APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif // CONFIG_AP_SUPPORT // #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { #ifdef QOS_DLS_SUPPORT // send DLS-TEAR_DOWN message, if (pAd->CommonCfg.bDLSCapable) { UCHAR i; // tear down local dls table entry for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) { if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) { RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; pAd->StaCfg.DLSEntry[i].Valid = FALSE; } } // tear down peer dls table entry for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) { if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) { RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; pAd->StaCfg.DLSEntry[i].Valid = FALSE; } } RTMP_MLME_HANDLER(pAd); } #endif // QOS_DLS_SUPPORT // if (INFRA_ON(pAd) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) { MLME_DISASSOC_REQ_STRUCT DisReq; MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG); if (MsgElem) { COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid); DisReq.Reason = REASON_DEAUTH_STA_LEAVING; MsgElem->Machine = ASSOC_STATE_MACHINE; MsgElem->MsgType = MT2_MLME_DISASSOC_REQ; MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT); NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT)); // Prevent to connect AP again in STAMlmePeriodicExec pAd->MlmeAux.AutoReconnectSsidLen= 32; NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen); pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC; MlmeDisassocReqAction(pAd, MsgElem); kfree(MsgElem); } RTMPusecDelay(1000); } #ifdef WPA_SUPPLICANT_SUPPORT #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT // send wireless event to wpa_supplicant for infroming interface down. RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_INTERFACE_DOWN, NULL, NULL, 0); #endif // NATIVE_WPA_SUPPLICANT_SUPPORT // if (pAd->StaCfg.pWpsProbeReqIe) { kfree(pAd->StaCfg.pWpsProbeReqIe); pAd->StaCfg.pWpsProbeReqIe = NULL; pAd->StaCfg.WpsProbeReqIeLen = 0; } if (pAd->StaCfg.pWpaAssocIe) { kfree(pAd->StaCfg.pWpaAssocIe); pAd->StaCfg.pWpaAssocIe = NULL; pAd->StaCfg.WpaAssocIeLen = 0; } #endif // WPA_SUPPLICANT_SUPPORT // } #endif // CONFIG_STA_SUPPORT // VIRTUAL_IF_DOWN(pAd); RT_MOD_DEC_USE_COUNT(); return 0; // close ok }
RTMP_BUILD_DRV_OPS_FUNCTION_BODY #endif /* OS_ABL_FUNC_SUPPORT */ #endif /* LINUX */ int rt28xx_init( IN VOID *pAdSrc, IN PSTRING pDefaultMac, IN PSTRING pHostName) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; UINT index; UCHAR TmpPhy; NDIS_STATUS Status; if (pAd == NULL) return FALSE; #ifdef RT3290 DBGPRINT(RT_DEBUG_OFF, ("MACVersion=0x%x\n", pAd->MACVersion)); if (IS_RT3290(pAd)) { UINT32 MacRegValue; OSCCTL_STRUC osCtrl = {.word = 0}; CMB_CTRL_STRUC cmbCtrl = {.word = 0}; WLAN_FUN_CTRL_STRUC WlanFunCtrl = {.word = 0}; RTMPEnableWlan(pAd, TRUE, TRUE); // // Too much time for reading efuse(enter/exit L1), and our device will hang up // Disable L1 // RTMP_IO_READ32(pAd, WLAN_FUN_CTRL, &WlanFunCtrl.word); if (WlanFunCtrl.field.WLAN_EN == TRUE) { WlanFunCtrl.field.PCIE_APP0_CLK_REQ = TRUE; RTMP_IO_WRITE32(pAd, WLAN_FUN_CTRL, WlanFunCtrl.word); } //Enable ROSC_EN first then CAL_REQ RTMP_IO_READ32(pAd, OSCCTL, &osCtrl.word); osCtrl.field.ROSC_EN = TRUE; //HW force RTMP_IO_WRITE32(pAd, OSCCTL, osCtrl.word); osCtrl.field.ROSC_EN = TRUE; //HW force osCtrl.field.CAL_REQ = TRUE; osCtrl.field.REF_CYCLE = 0x27; RTMP_IO_WRITE32(pAd, OSCCTL, osCtrl.word); RTMP_IO_READ32(pAd, CMB_CTRL, &cmbCtrl.word); pAd->CmbCtrl.word = cmbCtrl.word; // Overwrite default Coex Parameter RTMP_IO_READ32(pAd, COEXCFG0, &MacRegValue); MacRegValue &= ~(0xFF000000); MacRegValue |= 0x5E000000; RTMP_IO_WRITE32(pAd, COEXCFG0, MacRegValue); } if (IS_RT3290LE(pAd)) { PLL_CTRL_STRUC PllCtrl; RTMP_IO_READ32(pAd, PLL_CTRL, &PllCtrl.word); PllCtrl.field.VCO_FIXED_CURRENT_CONTROL = 0x1; RTMP_IO_WRITE32(pAd, PLL_CTRL, PllCtrl.word); } #endif /* RT3290 */ #ifdef CONFIG_STA_SUPPORT #ifdef PCIE_PS_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { /* If dirver doesn't wake up firmware here,*/ /* NICLoadFirmware will hang forever when interface is up again.*/ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) { AUTO_WAKEUP_STRUC AutoWakeupCfg; AsicForceWakeup(pAd, TRUE); AutoWakeupCfg.word = 0; RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word); OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE); } } #endif /* PCIE_PS_SUPPORT */ #endif /* CONFIG_STA_SUPPORT */ /* reset Adapter flags*/ RTMP_CLEAR_FLAGS(pAd); /* Init BssTab & ChannelInfo tabbles for auto channel select.*/ #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { /*#ifdef AUTO_CH_SELECT_ENHANCE*/ AutoChBssTableInit(pAd); ChannelInfoInit(pAd); /*#endif AUTO_CH_SELECT_ENHANCE */ } #endif /* CONFIG_AP_SUPPORT */ #ifdef DOT11_N_SUPPORT /* Allocate BA Reordering memory*/ if (ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM) != TRUE) goto err1; #endif /* DOT11_N_SUPPORT */ /* Make sure MAC gets ready.*/ index = 0; if (WaitForAsicReady(pAd) != TRUE) goto err1; DBGPRINT(RT_DEBUG_TRACE, ("MAC[Ver:Rev=0x%08x]\n", pAd->MACVersion)); if (MAX_LEN_OF_MAC_TABLE > MAX_AVAILABLE_CLIENT_WCID(pAd)) { DBGPRINT(RT_DEBUG_ERROR, ("MAX_LEN_OF_MAC_TABLE can not be larger than MAX_AVAILABLE_CLIENT_WCID!!!!\n")); goto err1; } /* Disable DMA*/ RT28XXDMADisable(pAd); /* Load 8051 firmware*/ Status = NICLoadFirmware(pAd); if (Status != NDIS_STATUS_SUCCESS) { DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", Status)); goto err1; } NICLoadRateSwitchingParams(pAd); /* Disable interrupts here which is as soon as possible*/ /* This statement should never be true. We might consider to remove it later*/ #ifdef RESOURCE_PRE_ALLOC Status = RTMPInitTxRxRingMemory(pAd); #else Status = RTMPAllocTxRxRingMemory(pAd); #endif /* RESOURCE_PRE_ALLOC */ if (Status != NDIS_STATUS_SUCCESS) { DBGPRINT_ERR(("RTMPAllocTxRxMemory failed, Status[=0x%08x]\n", Status)); goto err2; } RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); /* initialize MLME*/ Status = RtmpMgmtTaskInit(pAd); if (Status != NDIS_STATUS_SUCCESS) goto err3; Status = MlmeInit(pAd); if (Status != NDIS_STATUS_SUCCESS) { DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status)); goto err4; } #ifdef RMTP_RBUS_SUPPORT #ifdef VIDEO_TURBINE_SUPPORT VideoConfigInit(pAd); #endif /* VIDEO_TURBINE_SUPPORT */ #endif /* RMTP_RBUS_SUPPORT */ /* Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default*/ UserCfgInit(pAd); Status = RtmpNetTaskInit(pAd); if (Status != NDIS_STATUS_SUCCESS) goto err5; /* COPY_MAC_ADDR(pAd->ApCfg.MBSSID[apidx].Bssid, netif->hwaddr);*/ /* pAd->bForcePrintTX = TRUE;*/ CfgInitHook(pAd); #ifdef CONFIG_AP_SUPPORT if ((pAd->OpMode == OPMODE_AP) #ifdef P2P_SUPPORT || TRUE #endif /* P2P_SUPPORT */ ) APInitialize(pAd); #endif /* CONFIG_AP_SUPPORT */ #ifdef BLOCK_NET_IF initblockQueueTab(pAd); #endif /* BLOCK_NET_IF */ Status = MeasureReqTabInit(pAd); if (Status != NDIS_STATUS_SUCCESS) { DBGPRINT_ERR(("MeasureReqTabInit failed, Status[=0x%08x]\n",Status)); goto err6; } Status = TpcReqTabInit(pAd); if (Status != NDIS_STATUS_SUCCESS) { DBGPRINT_ERR(("TpcReqTabInit failed, Status[=0x%08x]\n",Status)); goto err6; } /* Init the hardware, we need to init asic before read registry, otherwise mac register will be reset*/ Status = NICInitializeAdapter(pAd, TRUE); if (Status != NDIS_STATUS_SUCCESS) { DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status)); if (Status != NDIS_STATUS_SUCCESS) goto err6; } #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { } #endif /* CONFIG_AP_SUPPORT */ /* Read parameters from Config File */ /* unknown, it will be updated in NICReadEEPROMParameters */ pAd->RfIcType = RFIC_UNKNOWN; Status = RTMPReadParametersHook(pAd); #ifdef CONFIG_STA_SUPPORT #ifdef CREDENTIAL_STORE RecoverConnectInfo(pAd); #endif /* CREDENTIAL_STORE */ #endif /* CONFIG_STA_SUPPORT */ DBGPRINT(RT_DEBUG_OFF, ("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode)); if (Status != NDIS_STATUS_SUCCESS) { DBGPRINT_ERR(("RTMPReadParametersHook failed, Status[=0x%08x]\n",Status)); goto err6; } #ifdef RTMP_MAC_USB pAd->CommonCfg.bMultipleIRP = FALSE; if (pAd->CommonCfg.bMultipleIRP) pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE; else pAd->CommonCfg.NumOfBulkInIRP = 1; #endif /* RTMP_MAC_USB */ #ifdef DOT11_N_SUPPORT /*Init Ba Capability parameters.*/ /* RT28XX_BA_INIT(pAd);*/ pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity; pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable; pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize; pAd->CommonCfg.DesiredHtPhy.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode; /* UPdata to HT IE*/ pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode; pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize; pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity; #endif /* DOT11_N_SUPPORT */ /* after reading Registry, we now know if in AP mode or STA mode*/ /* Load 8051 firmware; crash when FW image not existent*/ /* Status = NICLoadFirmware(pAd);*/ /* if (Status != NDIS_STATUS_SUCCESS)*/ /* break;*/ DBGPRINT(RT_DEBUG_OFF, ("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode)); /* We should read EEPROM for all cases. rt2860b*/ NICReadEEPROMParameters(pAd, (PSTRING)pDefaultMac); #ifdef CONFIG_STA_SUPPORT #endif /* CONFIG_STA_SUPPORT */ DBGPRINT(RT_DEBUG_OFF, ("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode)); #ifdef LED_CONTROL_SUPPORT /* Send LED Setting to MCU */ RTMPInitLEDMode(pAd); #endif /* LED_CONTROL_SUPPORT */ NICInitAsicFromEEPROM(pAd); /* rt2860b */ #ifdef RALINK_ATE if (ATEInit(pAd) != NDIS_STATUS_SUCCESS) { DBGPRINT(RT_DEBUG_ERROR, ("%s(): ATE initialization failed !\n", __FUNCTION__)); goto err6; } #endif /* RALINK_ATE */ #ifdef RTMP_FREQ_CALIBRATION_SUPPORT #ifdef CONFIG_STA_SUPPORT /* Initialize the frequency calibration*/ if (pAd->chipCap.FreqCalibrationSupport) FrequencyCalibration(pAd); #endif /* CONFIG_STA_SUPPORT */ #endif /* RTMP_FREQ_CALIBRATION_SUPPORT */ #ifdef RTMP_INTERNAL_TX_ALC /* Initialize the desired TSSI table*/ RTMP_CHIP_ASIC_TSSI_TABLE_INIT(pAd); #endif /* RTMP_INTERNAL_TX_ALC */ #ifdef RTMP_TEMPERATURE_COMPENSATION /* Temperature compensation, initialize the lookup table */ DBGPRINT(RT_DEBUG_OFF, ("bAutoTxAgcG = %d\n", pAd->bAutoTxAgcG)); if (pAd->chipCap.bTempCompTxALC && pAd->bAutoTxAgcG) InitLookupTable(pAd); #endif /* RTMP_TEMPERATURE_COMPENSATION */ #ifdef RTMP_FREQ_CALIBRATION_SUPPORT #ifdef CONFIG_STA_SUPPORT if (pAd->chipCap.FreqCalibrationSupport) InitFrequencyCalibration(pAd); #endif /* CONFIG_STA_SUPPORT */ #endif /* RTMP_FREQ_CALIBRATION_SUPPORT */ /* Set PHY to appropriate mode*/ TmpPhy = pAd->CommonCfg.PhyMode; pAd->CommonCfg.PhyMode = 0xff; RTMPSetPhyMode(pAd, TmpPhy); #ifdef DOT11_N_SUPPORT SetCommonHT(pAd); #endif /* DOT11_N_SUPPORT */ /* No valid channels.*/ if (pAd->ChannelListNum == 0) { DBGPRINT(RT_DEBUG_ERROR, ("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n")); goto err6; } #ifdef DOT11_N_SUPPORT DBGPRINT(RT_DEBUG_OFF, ("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0], pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2], pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4])); #endif /* DOT11_N_SUPPORT */ #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef AP_QLOAD_SUPPORT /* init QBSS Element */ QBSS_LoadInit(pAd); #endif /* AP_QLOAD_SUPPORT */ } #endif /* CONFIG_AP_SUPPORT */ /* APInitialize(pAd);*/ #ifdef IKANOS_VX_1X0 VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress); #endif /* IKANOS_VX_1X0 */ #ifdef RTMP_MAC_USB AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02, FALSE); RTMPusecDelay(10000); #endif /* RTMP_MAC_USB */ #ifdef RALINK_ATE #ifdef RT5592 #ifdef RTMP_RF_RW_SUPPORT /* both for RT5572 and RT5592 */ if (IS_RT5592(pAd)) { RT55x2ATEFilterCalibration(pAd); } #endif /* RTMP_RF_RW_SUPPORT */ #endif /* RT5592 */ #endif /* RALINK_ATE */ #ifdef CONFIG_AP_SUPPORT /* Initialize RF register to default value*/ if (pAd->OpMode == OPMODE_AP) { AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE); AsicLockChannel(pAd, pAd->CommonCfg.Channel); } #endif /* CONFIG_AP_SUPPORT */ /* Some modules init must be called before APStartUp(). Or APStartUp() will make up beacon content and call other modules API to get some information to fill. */ #ifdef CONFIG_TSO_SUPPORT if (RTMP_TEST_MORE_FLAG(pAd, fRTMP_ADAPTER_TSO_SUPPORT)) RTMPTsoEnable(pAd); #endif /* CONFIG_TSO_SUPPORT */ if (pAd && (Status != NDIS_STATUS_SUCCESS)) { /* Undo everything if it failed*/ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { /* NdisMDeregisterInterrupt(&pAd->Interrupt);*/ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); } /* RTMPFreeAdapter(pAd); we will free it in disconnect()*/ } else if (pAd) { /* Microsoft HCT require driver send a disconnect event after driver initialization.*/ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); OPSTATUS_CLEAR_FLAG(pAd, fOP_AP_STATUS_MEDIA_STATE_CONNECTED); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE); DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n")); #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { if (pAd->ApCfg.bAutoChannelAtBootup || (pAd->CommonCfg.Channel == 0)) { UINT8 BBPValue = 0; /* Enable Interrupt first due to we need to scan channel to receive beacons.*/ RTMP_IRQ_ENABLE(pAd); #ifdef RTMP_MAC_USB RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS); /* Support multiple BulkIn IRP,*/ /* the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1.*/ for(index=0; index<pAd->CommonCfg.NumOfBulkInIRP; index++) { RTUSBBulkReceive(pAd); DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" )); } #endif /* RTMP_MAC_USB */ /* Now Enable RxTx*/ RTMPEnableRxTx(pAd); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP); /* Let BBP register at 20MHz to do scan */ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue); BBPValue &= (~0x18); RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue); DBGPRINT(RT_DEBUG_ERROR, ("SYNC - BBP R4 to 20MHz.l\n")); /* Now we can receive the beacon and do the listen beacon*/ /* use default BW to select channel*/ pAd->CommonCfg.Channel = AP_AUTO_CH_SEL(pAd, pAd->ApCfg.AutoChannelAlg); pAd->ApCfg.bAutoChannelAtBootup = FALSE; } #ifdef DOT11_N_SUPPORT /* If phymode > PHY_11ABGN_MIXED and BW=40 check extension channel, after select channel */ N_ChannelCheck(pAd); #ifdef DOT11N_DRAFT3 /* We only do this Overlapping BSS Scan when system up, for the other situation of channel changing, we depends on station's report to adjust ourself. */ if (pAd->CommonCfg.bForty_Mhz_Intolerant == TRUE) { DBGPRINT(RT_DEBUG_TRACE, ("Disable 20/40 BSSCoex Channel Scan(BssCoex=%d, 40MHzIntolerant=%d)\n", pAd->CommonCfg.bBssCoexEnable, pAd->CommonCfg.bForty_Mhz_Intolerant)); } else if(pAd->CommonCfg.bBssCoexEnable == TRUE) { DBGPRINT(RT_DEBUG_TRACE, ("Enable 20/40 BSSCoex Channel Scan(BssCoex=%d)\n", pAd->CommonCfg.bBssCoexEnable)); APOverlappingBSSScan(pAd); } RTMP_11N_D3_TimerInit(pAd); /* RTMPInitTimer(pAd, &pAd->CommonCfg.Bss2040CoexistTimer, GET_TIMER_FUNCTION(Bss2040CoexistTimeOut), pAd, FALSE);*/ #endif /* DOT11N_DRAFT3 */ #endif /* DOT11_N_SUPPORT */ APStartUp(pAd); DBGPRINT(RT_DEBUG_OFF, ("Main bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", PRINT_MAC(pAd->ApCfg.MBSSID[BSS0].Bssid))); } #endif /* CONFIG_AP_SUPPORT */ #ifdef RTMP_MAC_USB RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS); /* Support multiple BulkIn IRP,*/ /* the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1.*/ for(index=0; index<pAd->CommonCfg.NumOfBulkInIRP; index++) { RTUSBBulkReceive(pAd); DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" )); } #endif /* RTMP_MAC_USB */ }/* end of else*/ /* Set up the Mac address*/ #ifdef CONFIG_AP_SUPPORT #ifndef P2P_APCLI_SUPPORT RtmpOSNetDevAddrSet(pAd->OpMode, pAd->net_dev, &pAd->CurrentAddress[0], NULL); #endif /* P2P_APCLI_SUPPORT */ #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT RtmpOSNetDevAddrSet(pAd->OpMode, pAd->net_dev, &pAd->CurrentAddress[0], (PUCHAR)(pAd->StaCfg.dev_name)); #endif /* CONFIG_STA_SUPPORT */ /* Various AP function init*/ #ifdef CONFIG_AP_SUPPORT #ifdef P2P_SUPPORT #else IF_DEV_CONFIG_OPMODE_ON_AP(pAd) #endif /* P2P_SUPPORT */ { #ifdef MBSS_SUPPORT /* the function can not be moved to RT2860_probe() even register_netdev() is changed as register_netdevice(). Or in some PC, kernel will panic (Fedora 4) */ /* RT28xx_MBSS_Init(pAd, pAd->net_dev); os abl move to rt_main_dev.c*/ #endif /* MBSS_SUPPORT */ #ifdef APCLI_SUPPORT /* RT28xx_ApCli_Init(pAd, pAd->net_dev);*/ #endif /* APCLI_SUPPORT */ } #endif /* CONFIG_AP_SUPPORT */ #ifdef UAPSD_SUPPORT UAPSD_Init(pAd); #endif /* UAPSD_SUPPORT */ /* assign function pointers*/ #ifdef MAT_SUPPORT /* init function pointers, used in OS_ABL */ RTMP_MATOpsInit(pAd); #endif /* MAT_SUPPORT */ #ifdef P2P_SUPPORT /* RTMP_P2P_Init(pAd, pAd->net_dev); */ #endif /* P2P_SUPPORT */ #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef MAT_SUPPORT MATEngineInit(pAd); #endif /* MAT_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabInit(pAd); #endif /* CLIENT_WDS */ } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { #ifdef DOT11Z_TDLS_SUPPORT TDLS_Table_Init(pAd); #endif /* DOT11Z_TDLS_SUPPORT */ #ifdef WPA_SUPPLICANT_SUPPORT #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT /* send wireless event to wpa_supplicant for infroming interface up.*/ RtmpOSWrielessEventSend(pAd->net_dev, RT_WLAN_EVENT_CUSTOM, RT_INTERFACE_UP, NULL, NULL, 0); #endif /* NATIVE_WPA_SUPPLICANT_SUPPORT */ #endif /* WPA_SUPPLICANT_SUPPORT */ } #endif /* CONFIG_STA_SUPPORT */ /* auto-fall back settings */ #ifdef RANGE_EXTEND RTMP_IO_WRITE32(pAd, HT_FBK_CFG1, 0xedcba980); #endif // RANGE_EXTEND // #ifdef DOT11N_SS3_SUPPORT if (pAd->CommonCfg.TxStream >= 3) { RTMP_IO_WRITE32(pAd, TX_FBK_CFG_3S_0, 0x12111008); RTMP_IO_WRITE32(pAd, TX_FBK_CFG_3S_1, 0x16151413); } #endif /* DOT11N_SS3_SUPPORT */ #ifdef STREAM_MODE_SUPPORT RtmpStreamModeInit(pAd); #endif /* STREAM_MODE_SUPPORT */ #ifdef DOT11_N_SUPPORT #endif /* DOT11_N_SUPPORT */ #ifdef RT3290 if (IS_RT3290(pAd)) { WLAN_FUN_CTRL_STRUC WlanFunCtrl = {.word = 0}; RTMP_MAC_PWRSV_EN(pAd, TRUE, TRUE); // // Too much time for reading efuse(enter/exit L1), and our device will hang up // Enable L1 // RTMP_IO_READ32(pAd, WLAN_FUN_CTRL, &WlanFunCtrl.word); if (WlanFunCtrl.field.WLAN_EN == TRUE) { WlanFunCtrl.field.PCIE_APP0_CLK_REQ = FALSE; RTMP_IO_WRITE32(pAd, WLAN_FUN_CTRL, WlanFunCtrl.word); } } #endif /* RT3290 */ DBGPRINT_S(Status, ("<==== rt28xx_init, Status=%x\n", Status)); return TRUE; /*err7: APStop(pAd);*/ err6: #ifdef IGMP_SNOOP_SUPPORT MultiCastFilterTableReset(&pAd->pMulticastFilterTable); #endif /* IGMP_SNOOP_SUPPORT */ MeasureReqTabExit(pAd); TpcReqTabExit(pAd); err5: RtmpNetTaskExit(pAd); UserCfgExit(pAd); err4: MlmeHalt(pAd); RTMP_TimerListRelease(pAd); err3: RtmpMgmtTaskExit(pAd); #ifdef RTMP_TIMER_TASK_SUPPORT NdisFreeSpinLock(&pAd->TimerQLock); #endif /* RTMP_TIMER_TASK_SUPPORT */ err2: #ifdef RESOURCE_PRE_ALLOC RTMPResetTxRxRingMemory(pAd); #else RTMPFreeTxRxRingMemory(pAd); #endif /* RESOURCE_PRE_ALLOC */ err1: #ifdef CONFIG_AP_SUPPORT /* Free BssTab & ChannelInfo tabbles.*/ AutoChBssTableDestroy(pAd); ChannelInfoDestroy(pAd); #endif /* CONFIG_AP_SUPPORT */ #ifdef RT3290 if (IS_RT3290(pAd)) RTMPEnableWlan(pAd, FALSE, FALSE); #endif /* RT3290 */ #ifdef DOT11_N_SUPPORT if(pAd->mpdu_blk_pool.mem) os_free_mem(pAd, pAd->mpdu_blk_pool.mem); /* free BA pool*/ #endif /* DOT11_N_SUPPORT */ /* shall not set priv to NULL here because the priv didn't been free yet.*/ /*net_dev->priv = 0;*/ #ifdef INF_AMAZON_SE err0: #endif /* INF_AMAZON_SE */ #ifdef ST err0: #endif /* ST */ DBGPRINT(RT_DEBUG_ERROR, ("!!! rt28xx Initialized fail !!!\n")); return FALSE; } VOID RTMPDrvOpen( IN VOID *pAdSrc) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; #ifdef CONFIG_STA_SUPPORT #endif /* CONFIG_STA_SUPPORT */ /* Enable Interrupt*/ RTMP_IRQ_ENABLE(pAd); /* Now Enable RxTx*/ RTMPEnableRxTx(pAd); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP); { UINT32 reg = 0; RTMP_IO_READ32(pAd, 0x1300, ®); /* clear garbage interrupts*/ printk("0x1300 = %08x\n", reg); } { /* u32 reg;*/ /* UINT8 byte;*/ /* u16 tmp;*/ /* RTMP_IO_READ32(pAd, XIFS_TIME_CFG, ®);*/ /* tmp = 0x0805;*/ /* reg = (reg & 0xffff0000) | tmp;*/ /* RTMP_IO_WRITE32(pAd, XIFS_TIME_CFG, reg);*/ } #ifdef CONFIG_STA_SUPPORT #ifdef PCIE_PS_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) RTMPInitPCIeLinkCtrlValue(pAd); #endif /* PCIE_PS_SUPPORT */ #endif /* CONFIG_STA_SUPPORT */ #ifdef CONFIG_AP_SUPPORT #ifdef BG_FT_SUPPORT BG_FTPH_Init(); #endif /* BG_FT_SUPPORT */ #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT /* To reduce connection time, do auto reconnect here instead of waiting STAMlmePeriodicExec to do auto reconnect. */ if (pAd->OpMode == OPMODE_STA) MlmeAutoReconnectLastSSID(pAd); #endif /* CONFIG_STA_SUPPORT */ #ifdef CONFIG_STA_SUPPORT #endif /* CONFIG_STA_SUPPORT */ #ifdef WSC_INCLUDED #ifdef CONFIG_AP_SUPPORT if ((pAd->OpMode == OPMODE_AP) #ifdef P2P_SUPPORT /* P2P will use ApCfg.MBSSID and ApCfg.ApCliTab also. */ || TRUE #endif /* P2P_SUPPORT */ ) { int index; for (index = 0; index < pAd->ApCfg.BssidNum; index++) { #ifdef HOSTAPD_SUPPORT if (pAd->ApCfg.MBSSID[index].Hostapd == TRUE) { DBGPRINT(RT_DEBUG_TRACE, ("WPS is control by hostapd now.\n")); } else #endif /*HOSTAPD_SUPPORT*/ { PWSC_CTRL pWscControl; UCHAR zeros16[16]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; pWscControl = &pAd->ApCfg.MBSSID[index].WscControl; DBGPRINT(RT_DEBUG_TRACE, ("Generate UUID for apidx(%d)\n", index)); if (NdisEqualMemory(&pWscControl->Wsc_Uuid_E[0], zeros16, UUID_LEN_HEX)) WscGenerateUUID(pAd, &pWscControl->Wsc_Uuid_E[0], &pWscControl->Wsc_Uuid_Str[0], index, FALSE); WscInit(pAd, FALSE, index); } } #ifdef APCLI_SUPPORT for(index = 0; index < MAX_APCLI_NUM; index++) { PWSC_CTRL pWpsCtrl = &pAd->ApCfg.ApCliTab[index].WscControl; pWpsCtrl->pAd = pAd; NdisZeroMemory(pWpsCtrl->EntryAddr, MAC_ADDR_LEN); pWpsCtrl->WscConfigMethods= 0x018C; RTMP_AP_IoctlHandle(pAd, NULL, CMD_RTPRIV_IOCTL_WSC_INIT, 0, (VOID *)&pAd->ApCfg.ApCliTab[index], index); } #endif /* APCLI_SUPPORT */ } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { PWSC_CTRL pWscControl = &pAd->StaCfg.WscControl; WscGenerateUUID(pAd, &pWscControl->Wsc_Uuid_E[0], &pWscControl->Wsc_Uuid_Str[0], 0, FALSE); WscInit(pAd, FALSE, BSS0); #ifdef WSC_V2_SUPPORT WscInitRegistrarPair(pAd, &pAd->StaCfg.WscControl, BSS0); #endif /* WSC_V2_SUPPORT */ } #endif /* CONFIG_STA_SUPPORT */ /* WSC hardware push button function 0811 */ WSC_HDR_BTN_Init(pAd); #endif /* WSC_INCLUDED */ } VOID RTMPDrvClose( IN VOID *pAdSrc, IN VOID *net_dev) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; BOOLEAN Cancelled; UINT32 i = 0; Cancelled = FALSE; #ifdef CONFIG_STA_SUPPORT #ifdef CREDENTIAL_STORE if (pAd->IndicateMediaState == NdisMediaStateConnected) { StoreConnectInfo(pAd); } else { RTMP_SEM_LOCK(&pAd->StaCtIf.Lock); pAd->StaCtIf.Changeable = FALSE; RTMP_SEM_UNLOCK(&pAd->StaCtIf.Lock); } #endif /* CREDENTIAL_STORE */ #endif /* CONFIG_STA_SUPPORT */ #ifdef CONFIG_AP_SUPPORT #ifdef BG_FT_SUPPORT BG_FTPH_Remove(); #endif /* BG_FT_SUPPORT */ #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { #ifdef PCIE_PS_SUPPORT RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_CLOSE); #endif /* PCIE_PS_SUPPORT */ /* If dirver doesn't wake up firmware here,*/ /* NICLoadFirmware will hang forever when interface is up again.*/ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) { AsicForceWakeup(pAd, TRUE); } #ifdef RTMP_MAC_USB RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS); #endif /* RTMP_MAC_USB */ } #endif /* CONFIG_STA_SUPPORT */ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); #ifdef EXT_BUILD_CHANNEL_LIST if (pAd->CommonCfg.pChDesp != NULL) os_free_mem(NULL, pAd->CommonCfg.pChDesp); pAd->CommonCfg.pChDesp = NULL; pAd->CommonCfg.DfsType = MAX_RD_REGION; pAd->CommonCfg.bCountryFlag = 0; #endif /* EXT_BUILD_CHANNEL_LIST */ for (i = 0 ; i < NUM_OF_TX_RING; i++) { while (pAd->DeQueueRunning[i] == TRUE) { DBGPRINT(RT_DEBUG_TRACE, ("Waiting for TxQueue[%d] done..........\n", i)); RTMPusecDelay(1000); } } #ifdef RTMP_MAC_USB RtmpOsUsbEmptyUrbCheck(&pAd->wait, &pAd->BulkInLock, &pAd->PendingRx); #endif /* RTMP_MAC_USB */ #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef RTMP_MAC_USB RTMPCancelTimer(&pAd->CommonCfg.BeaconUpdateTimer, &Cancelled); #endif /* RTMP_MAC_USB */ #ifdef DOT11N_DRAFT3 if (pAd->CommonCfg.Bss2040CoexistFlag & BSS_2040_COEXIST_TIMER_FIRED) { RTMPCancelTimer(&pAd->CommonCfg.Bss2040CoexistTimer, &Cancelled); pAd->CommonCfg.Bss2040CoexistFlag = 0; } #endif /* DOT11N_DRAFT3 */ /* PeriodicTimer already been canceled by MlmeHalt() API.*/ /*RTMPCancelTimer(&pAd->PeriodicTimer, &Cancelled);*/ } #endif /* CONFIG_AP_SUPPORT */ /* Stop Mlme state machine*/ MlmeHalt(pAd); /* Close net tasklets*/ RtmpNetTaskExit(pAd); #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { MacTableReset(pAd); #ifdef MAT_SUPPORT MATEngineExit(pAd); #endif /* MAT_SUPPORT */ #if defined(WOW_SUPPORT) && defined(RTMP_MAC_USB) && defined(WOW_IFDOWN_SUPPORT) if (pAd->WOW_Cfg.bEnable == TRUE) RT28xxUsbAsicWOWEnable(pAd); else #endif /* WOW_SUPPORT */ MlmeRadioOff(pAd); } #endif /* CONFIG_STA_SUPPORT */ #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef MAT_SUPPORT MATEngineExit(pAd); #endif /* MAT_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabDestory(pAd); #endif /* CLIENT_WDS */ /* Shutdown Access Point function, release all related resources */ APShutdown(pAd); /*#ifdef AUTO_CH_SELECT_ENHANCE*/ /* Free BssTab & ChannelInfo tabbles.*/ /* AutoChBssTableDestroy(pAd); */ /* ChannelInfoDestroy(pAd); */ /*#endif AUTO_CH_SELECT_ENHANCE */ } #endif /* CONFIG_AP_SUPPORT */ MeasureReqTabExit(pAd); TpcReqTabExit(pAd); #ifdef LED_CONTROL_SUPPORT RTMPExitLEDMode(pAd); #endif // LED_CONTROL_SUPPORT /* Close kernel threads*/ RtmpMgmtTaskExit(pAd); #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { /* must after RtmpMgmtTaskExit(); Or pAd->pChannelInfo will be NULL */ /* Free BssTab & ChannelInfo tabbles.*/ AutoChBssTableDestroy(pAd); ChannelInfoDestroy(pAd); } #endif /* CONFIG_AP_SUPPORT */ /* Free IRQ*/ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); } /* Free Ring or USB buffers*/ #ifdef RESOURCE_PRE_ALLOC RTMPResetTxRxRingMemory(pAd); #else /* Free Ring or USB buffers*/ RTMPFreeTxRxRingMemory(pAd); #endif /* RESOURCE_PRE_ALLOC */ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); #ifdef DOT11_N_SUPPORT /* Free BA reorder resource*/ ba_reordering_resource_release(pAd); #endif /* DOT11_N_SUPPORT */ UserCfgExit(pAd); /* must after ba_reordering_resource_release */ #ifdef CONFIG_STA_SUPPORT #endif /* CONFIG_STA_SUPPORT */ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP); /*+++Modify by woody to solve the bulk fail+++*/ #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { #ifdef RT35xx if (IS_RT3572(pAd)) { RT30xxWriteRFRegister(pAd, RF_R08, 0x00); AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02, FALSE); } #endif /* RT35xx */ #ifdef DOT11Z_TDLS_SUPPORT TDLS_Table_Destory(pAd); #ifdef TDLS_AUTOLINK_SUPPORT TDLS_ClearEntryList(&pAd->StaCfg.TdlsInfo.TdlsDiscovPeerList); NdisFreeSpinLock(&pAd->StaCfg.TdlsInfo.TdlsDiscovPeerListSemLock); TDLS_ClearEntryList(&pAd->StaCfg.TdlsInfo.TdlsBlackList); NdisFreeSpinLock(&pAd->StaCfg.TdlsInfo.TdlsBlackListSemLock); #endif /* TDLS_AUTOLINK_SUPPORT */ #endif /* DOT11Z_TDLS_SUPPORT */ } #endif /* CONFIG_STA_SUPPORT */ /* clear MAC table */ /* TODO: do not clear spin lock, such as fLastChangeAccordingMfbLock */ NdisZeroMemory(&pAd->MacTab, sizeof(MAC_TABLE)); /* release all timers */ RTMPusecDelay(2000); RTMP_TimerListRelease(pAd); #ifdef RTMP_TIMER_TASK_SUPPORT NdisFreeSpinLock(&pAd->TimerQLock); #endif /* RTMP_TIMER_TASK_SUPPORT */ } VOID RTMPInfClose( IN VOID *pAdSrc) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; #ifdef CONFIG_AP_SUPPORT pAd->ApCfg.MBSSID[MAIN_MBSSID].bBcnSntReq = FALSE; IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { /* kick out all STAs behind the bss.*/ MbssKickOutStas(pAd, MAIN_MBSSID, REASON_DISASSOC_INACTIVE); } #ifdef RT_CFG80211_SUPPORT #else APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif /* RT_CFG80211_SUPPORT */ #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { #ifdef PROFILE_STORE WriteDatThread(pAd); RTMPusecDelay(1000); #endif /* PROFILE_STORE */ #ifdef QOS_DLS_SUPPORT /* send DLS-TEAR_DOWN message, */ if (pAd->CommonCfg.bDLSCapable) { UCHAR i; /* tear down local dls table entry*/ for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) { if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) { RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; pAd->StaCfg.DLSEntry[i].Valid = FALSE; } } /* tear down peer dls table entry*/ for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) { if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) { RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; pAd->StaCfg.DLSEntry[i].Valid = FALSE; } } RTMP_MLME_HANDLER(pAd); } #endif /* QOS_DLS_SUPPORT */ if (INFRA_ON(pAd) && #if defined(WOW_SUPPORT) && defined(RTMP_MAC_USB) && defined(WOW_IFDOWN_SUPPORT) /* In WOW state, can't issue disassociation reqeust */ pAd->WOW_Cfg.bEnable == FALSE && #endif /* WOW_SUPPORT */ (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) { MLME_DISASSOC_REQ_STRUCT DisReq; MLME_QUEUE_ELEM *MsgElem;/* = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);*/ os_alloc_mem(NULL, (UCHAR **)&MsgElem, sizeof(MLME_QUEUE_ELEM)); if (MsgElem) { COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid); DisReq.Reason = REASON_DEAUTH_STA_LEAVING; MsgElem->Machine = ASSOC_STATE_MACHINE; MsgElem->MsgType = MT2_MLME_DISASSOC_REQ; MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT); NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT)); /* Prevent to connect AP again in STAMlmePeriodicExec*/ pAd->MlmeAux.AutoReconnectSsidLen= 32; NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen); pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC; MlmeDisassocReqAction(pAd, MsgElem); /* kfree(MsgElem);*/ os_free_mem(NULL, MsgElem); } RTMPusecDelay(1000); } #ifdef WPA_SUPPLICANT_SUPPORT #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT /* send wireless event to wpa_supplicant for infroming interface down.*/ RtmpOSWrielessEventSend(pAd->net_dev, RT_WLAN_EVENT_CUSTOM, RT_INTERFACE_DOWN, NULL, NULL, 0); #endif /* NATIVE_WPA_SUPPLICANT_SUPPORT */ if (pAd->StaCfg.pWpsProbeReqIe) { /* kfree(pAd->StaCfg.pWpsProbeReqIe);*/ os_free_mem(NULL, pAd->StaCfg.pWpsProbeReqIe); pAd->StaCfg.pWpsProbeReqIe = NULL; pAd->StaCfg.WpsProbeReqIeLen = 0; } if (pAd->StaCfg.pWpaAssocIe) { /* kfree(pAd->StaCfg.pWpaAssocIe);*/ os_free_mem(NULL, pAd->StaCfg.pWpaAssocIe); pAd->StaCfg.pWpaAssocIe = NULL; pAd->StaCfg.WpaAssocIeLen = 0; } #endif /* WPA_SUPPLICANT_SUPPORT */ } #endif /* CONFIG_STA_SUPPORT */ } PNET_DEV RtmpPhyNetDevMainCreate( IN VOID *pAdSrc) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; PNET_DEV pDevNew; UINT32 MC_RowID = 0, IoctlIF = 0; pAd = pAd; #ifdef MULTIPLE_CARD_SUPPORT MC_RowID = pAd->MC_RowID; #endif /* MULTIPLE_CARD_SUPPORT */ #ifdef HOSTAPD_SUPPORT IoctlIF = pAd->IoctlIF; #endif /* HOSTAPD_SUPPORT */ pDevNew = RtmpOSNetDevCreate((INT32)MC_RowID, (UINT32 *)&IoctlIF, INT_MAIN, 0, sizeof(PRTMP_ADAPTER), INF_MAIN_DEV_NAME); #ifdef HOSTAPD_SUPPORT pAd->IoctlIF = IoctlIF; #endif /* HOSTAPD_SUPPORT */ return pDevNew; }
VOID RTMPInfClose( IN VOID *pAdSrc) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; #ifdef CONFIG_AP_SUPPORT pAd->ApCfg.MBSSID[MAIN_MBSSID].bBcnSntReq = FALSE; IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { /* kick out all STAs behind the bss.*/ MbssKickOutStas(pAd, MAIN_MBSSID, REASON_DISASSOC_INACTIVE); } APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { #ifdef PROFILE_STORE WriteDatThread(pAd); RTMPusecDelay(1000); #endif /* PROFILE_STORE */ #ifdef QOS_DLS_SUPPORT /* send DLS-TEAR_DOWN message, */ if (pAd->CommonCfg.bDLSCapable) { UCHAR i; /* tear down local dls table entry*/ for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) { if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) { RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; pAd->StaCfg.DLSEntry[i].Valid = FALSE; } } /* tear down peer dls table entry*/ for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) { if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) { RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; pAd->StaCfg.DLSEntry[i].Valid = FALSE; } } RTMP_MLME_HANDLER(pAd); } #endif /* QOS_DLS_SUPPORT */ if (INFRA_ON(pAd) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) { MLME_DISASSOC_REQ_STRUCT DisReq; MLME_QUEUE_ELEM *MsgElem;/* = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);*/ os_alloc_mem(NULL, (UCHAR **)&MsgElem, sizeof(MLME_QUEUE_ELEM)); if (MsgElem) { COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid); DisReq.Reason = REASON_DEAUTH_STA_LEAVING; MsgElem->Machine = ASSOC_STATE_MACHINE; MsgElem->MsgType = MT2_MLME_DISASSOC_REQ; MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT); NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT)); /* Prevent to connect AP again in STAMlmePeriodicExec*/ pAd->MlmeAux.AutoReconnectSsidLen= 32; NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen); pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC; MlmeDisassocReqAction(pAd, MsgElem); /* kfree(MsgElem);*/ os_free_mem(NULL, MsgElem); } RTMPusecDelay(1000); } #ifdef WPA_SUPPLICANT_SUPPORT /* send wireless event to wpa_supplicant for infroming interface down.*/ RtmpOSWrielessEventSend(pAd->net_dev, RT_WLAN_EVENT_CUSTOM, RT_INTERFACE_DOWN, NULL, NULL, 0); if (pAd->StaCfg.pWpsProbeReqIe) { /* kfree(pAd->StaCfg.pWpsProbeReqIe);*/ os_free_mem(NULL, pAd->StaCfg.pWpsProbeReqIe); pAd->StaCfg.pWpsProbeReqIe = NULL; pAd->StaCfg.WpsProbeReqIeLen = 0; } if (pAd->StaCfg.pWpaAssocIe) { /* kfree(pAd->StaCfg.pWpaAssocIe);*/ os_free_mem(NULL, pAd->StaCfg.pWpaAssocIe); pAd->StaCfg.pWpaAssocIe = NULL; pAd->StaCfg.WpaAssocIeLen = 0; } #endif /* WPA_SUPPLICANT_SUPPORT */ } #endif /* CONFIG_STA_SUPPORT */ }
INT RTMP_COM_IoctlHandle( IN VOID *pAdSrc, IN RTMP_IOCTL_INPUT_STRUCT *wrq, IN INT cmd, IN USHORT subcmd, IN VOID *pData, IN ULONG Data) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie; INT Status = NDIS_STATUS_SUCCESS, i; UCHAR PermanentAddress[MAC_ADDR_LEN]; USHORT Addr01, Addr23, Addr45; pObj = pObj; /* avoid compile warning */ switch(cmd) { case CMD_RTPRIV_IOCTL_NETDEV_GET: /* get main net_dev */ { VOID **ppNetDev = (VOID **)pData; *ppNetDev = (VOID *)(pAd->net_dev); } break; case CMD_RTPRIV_IOCTL_NETDEV_SET: /* set main net_dev */ pAd->net_dev = pData; #ifdef CONFIG_AP_SUPPORT pAd->ApCfg.MBSSID[MAIN_MBSSID].MSSIDDev = pData; #endif /* CONFIG_AP_SUPPORT */ break; case CMD_RTPRIV_IOCTL_OPMODE_GET: /* get Operation Mode */ *(ULONG *)pData = pAd->OpMode; break; case CMD_RTPRIV_IOCTL_TASK_LIST_GET: /* get all Tasks */ { RT_CMD_WAIT_QUEUE_LIST *pList = (RT_CMD_WAIT_QUEUE_LIST *)pData; pList->pMlmeTask = &pAd->mlmeTask; #ifdef RTMP_TIMER_TASK_SUPPORT pList->pTimerTask = &pAd->timerTask; #endif /* RTMP_TIMER_TASK_SUPPORT */ pList->pCmdQTask = &pAd->cmdQTask; #ifdef WSC_INCLUDED pList->pWscTask = &pAd->wscTask; #endif /* WSC_INCLUDED */ } break; case CMD_RTPRIV_IOCTL_IRQ_INIT: /* init IRQ */ RTMP_IRQ_INIT(pAd); break; case CMD_RTPRIV_IOCTL_IRQ_RELEASE: /* release IRQ */ RTMP_OS_IRQ_RELEASE(pAd, pAd->net_dev); break; case CMD_RTPRIV_IOCTL_NIC_NOT_EXIST: /* set driver state to fRTMP_ADAPTER_NIC_NOT_EXIST */ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST); break; case CMD_RTPRIV_IOCTL_MCU_SLEEP_CLEAR: RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_MCU_SLEEP); break; #ifdef CONFIG_APSTA_MIXED_SUPPORT case CMD_RTPRIV_IOCTL_MAX_IN_BIT: /* set MAX_IN_BIT for WMM */ CW_MAX_IN_BITS = Data; break; #endif /* CONFIG_APSTA_MIXED_SUPPORT */ case CMD_RTPRIV_IOCTL_ADAPTER_SUSPEND_SET: /* set driver state to fRTMP_ADAPTER_SUSPEND */ RTMP_SET_FLAG(pAd,fRTMP_ADAPTER_SUSPEND); break; case CMD_RTPRIV_IOCTL_ADAPTER_SUSPEND_CLEAR: /* clear driver state to fRTMP_ADAPTER_SUSPEND */ RTMP_CLEAR_FLAG(pAd,fRTMP_ADAPTER_SUSPEND); break; case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_USB_ASICRADIO_OFF: /* RT28xxUsbAsicRadioOff */ //RT28xxUsbAsicRadioOff(pAd); ASIC_RADIO_OFF(pAd, SUSPEND_RADIO_OFF); break; case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_USB_ASICRADIO_ON: /* RT28xxUsbAsicRadioOn */ //RT28xxUsbAsicRadioOn(pAd); ASIC_RADIO_ON(pAd, RESUME_RADIO_ON); break; case CMD_RTPRIV_IOCTL_SANITY_CHECK: /* sanity check before IOCTL */ if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) #ifdef IFUP_IN_PROBE || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) #endif /* IFUP_IN_PROBE */ ) { if(pData == NULL || RT_isLegalCmdBeforeInfUp((PSTRING) pData) == FALSE) return NDIS_STATUS_FAILURE; } break; case CMD_RTPRIV_IOCTL_SIOCGIWFREQ: /* get channel number */ *(ULONG *)pData = pAd->CommonCfg.Channel; break; case CMD_RTPRIV_IOCTL_BEACON_UPDATE: /* update all beacon contents */ #ifdef CONFIG_AP_SUPPORT APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif /* CONFIG_AP_SUPPORT */ break; case CMD_RTPRIV_IOCTL_RXPATH_GET: /* get the number of rx path */ *(ULONG *)pData = pAd->Antenna.field.RxPath; break; case CMD_RTPRIV_IOCTL_CHAN_LIST_NUM_GET: *(ULONG *)pData = pAd->ChannelListNum; break; case CMD_RTPRIV_IOCTL_CHAN_LIST_GET: { UINT32 i; UCHAR *pChannel = (UCHAR *)pData; for (i = 1; i <= pAd->ChannelListNum; i++) { *pChannel = pAd->ChannelList[i-1].Channel; pChannel ++; } } break; case CMD_RTPRIV_IOCTL_FREQ_LIST_GET: { UINT32 i; UINT32 *pFreq = (UINT32 *)pData; UINT32 m; for (i = 1; i <= pAd->ChannelListNum; i++) { m = 2412000; MAP_CHANNEL_ID_TO_KHZ(pAd->ChannelList[i-1].Channel, m); (*pFreq) = m; pFreq++; } } break; #ifdef EXT_BUILD_CHANNEL_LIST case CMD_RTPRIV_SET_PRECONFIG_VALUE: /* Set some preconfigured value before interface up*/ pAd->CommonCfg.DfsType = MAX_RD_REGION; break; #endif /* EXT_BUILD_CHANNEL_LIST */ #ifdef RTMP_USB_SUPPORT case CMD_RTPRIV_IOCTL_USB_MORE_FLAG_SET: { RT_CMD_USB_MORE_FLAG_CONFIG *pConfig; UINT32 VendorID, ProductID; pConfig = (RT_CMD_USB_MORE_FLAG_CONFIG *)pData; VendorID = pConfig->VendorID; ProductID = pConfig->ProductID; if (VendorID == 0x0DB0) { if ((ProductID == 0x871C) || (ProductID == 0x822C)) RTMP_SET_MORE_FLAG(pAd, (fRTMP_ADAPTER_DISABLE_DOT_11N | fRTMP_ADAPTER_WSC_PBC_PIN0)); if ((ProductID == 0x871A) || (ProductID == 0x822A)) RTMP_SET_MORE_FLAG(pAd, fRTMP_ADAPTER_DISABLE_DOT_11N); if ((ProductID == 0x871B) || (ProductID == 0x822B)) RTMP_SET_MORE_FLAG(pAd, fRTMP_ADAPTER_WSC_PBC_PIN0); } if (VendorID == 0x07D1) { if (ProductID == 0x3C0F) RTMP_SET_MORE_FLAG(pAd, fRTMP_ADAPTER_DISABLE_DOT_11N); } } break; case CMD_RTPRIV_IOCTL_USB_CONFIG_INIT: { RT_CMD_USB_DEV_CONFIG *pConfig; UINT32 i; pConfig = (RT_CMD_USB_DEV_CONFIG *)pData; pAd->NumberOfPipes = pConfig->NumberOfPipes; pAd->BulkInMaxPacketSize = pConfig->BulkInMaxPacketSize; pAd->BulkOutMaxPacketSize = pConfig->BulkOutMaxPacketSize; for (i = 0; i < 6; i++) { pAd->BulkOutEpAddr[i] = pConfig->BulkOutEpAddr[i]; DBGPRINT(RT_DEBUG_OFF, ("%s():pAd->BulkOutEpAddr=0x%x\n", __FUNCTION__, pAd->BulkOutEpAddr[i])); } for (i = 0; i < 2; i++) pAd->BulkInEpAddr[i] = pConfig->BulkInEpAddr[i]; pAd->config = pConfig->pConfig; } break; case CMD_RTPRIV_IOCTL_USB_SUSPEND: pAd->PM_FlgSuspend = 1; if (Data) { RTUSBCancelPendingBulkInIRP(pAd); RTUSBCancelPendingBulkOutIRP(pAd); } break; case CMD_RTPRIV_IOCTL_USB_RESUME: pAd->PM_FlgSuspend = 0; break; #endif /* RTMP_USB_SUPPORT */ #ifdef RT_CFG80211_SUPPORT case CMD_RTPRIV_IOCTL_CFG80211_CFG_START: RT_CFG80211_REINIT(pAd); RT_CFG80211_CRDA_REG_RULE_APPLY(pAd); break; #endif /* RT_CFG80211_SUPPORT */ #ifdef INF_PPA_SUPPORT case CMD_RTPRIV_IOCTL_INF_PPA_INIT: os_alloc_mem(NULL, (UCHAR **)&(pAd->pDirectpathCb), sizeof(PPA_DIRECTPATH_CB)); break; case CMD_RTPRIV_IOCTL_INF_PPA_EXIT: if (ppa_hook_directpath_register_dev_fn && pAd->PPAEnable==TRUE) { UINT status; status=ppa_hook_directpath_register_dev_fn(&pAd->g_if_id, pAd->net_dev, NULL, 0); DBGPRINT(RT_DEBUG_TRACE, ("unregister PPA:g_if_id=%d status=%d\n",pAd->g_if_id,status)); } os_free_mem(NULL, pAd->pDirectpathCb); break; #endif /* INF_PPA_SUPPORT*/ case CMD_RTPRIV_IOCTL_VIRTUAL_INF_UP: /* interface up */ { RT_CMD_INF_UP_DOWN *pInfConf = (RT_CMD_INF_UP_DOWN *)pData; if (VIRTUAL_IF_NUM(pAd) == 0) { if (pInfConf->rt28xx_open(pAd->net_dev) != 0) { DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_open return fail!\n")); return NDIS_STATUS_FAILURE; } } #ifdef CONFIG_AP_SUPPORT else { extern VOID APMakeAllBssBeacon(IN PRTMP_ADAPTER pAd); extern VOID APUpdateAllBeaconFrame(IN PRTMP_ADAPTER pAd); APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif /* CONFIG_AP_SUPPORT */ } VIRTUAL_IF_INC(pAd); } break; case CMD_RTPRIV_IOCTL_VIRTUAL_INF_DOWN: /* interface down */ { RT_CMD_INF_UP_DOWN *pInfConf = (RT_CMD_INF_UP_DOWN *)pData; VIRTUAL_IF_DEC(pAd); if (VIRTUAL_IF_NUM(pAd) == 0) pInfConf->rt28xx_close(pAd->net_dev); } break; case CMD_RTPRIV_IOCTL_VIRTUAL_INF_GET: /* get virtual interface number */ *(ULONG *)pData = VIRTUAL_IF_NUM(pAd); break; case CMD_RTPRIV_IOCTL_INF_TYPE_GET: /* get current interface type */ *(ULONG *)pData = pAd->infType; break; case CMD_RTPRIV_IOCTL_INF_STATS_GET: /* get statistics */ { RT_CMD_STATS *pStats = (RT_CMD_STATS *)pData; pStats->pStats = pAd->stats; if(pAd->OpMode == OPMODE_STA) { pStats->rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart; pStats->tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart; pStats->rx_bytes = pAd->RalinkCounters.ReceivedByteCount; pStats->tx_bytes = pAd->RalinkCounters.TransmittedByteCount; pStats->rx_errors = pAd->Counters8023.RxErrors; pStats->tx_errors = pAd->Counters8023.TxErrors; pStats->multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; /* multicast packets received*/ pStats->collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions; /* Collision packets*/ pStats->rx_over_errors = pAd->Counters8023.RxNoBuffer; /* receiver ring buff overflow*/ pStats->rx_crc_errors = 0;/*pAd->WlanCounters.FCSErrorCount; recved pkt with crc error*/ pStats->rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors; /* recv'd frame alignment error*/ pStats->rx_fifo_errors = pAd->Counters8023.RxNoBuffer; /* recv'r fifo overrun*/ } #ifdef CONFIG_AP_SUPPORT else if (pAd->OpMode == OPMODE_AP) { INT index; for(index = 0; index < MAX_MBSSID_NUM(pAd); index++) { if (pAd->ApCfg.MBSSID[index].MSSIDDev == (PNET_DEV)(pStats->pNetDev)) break; } if (index >= MAX_MBSSID_NUM(pAd)) { //reset counters pStats->rx_packets = 0; pStats->tx_packets = 0; pStats->rx_bytes = 0; pStats->tx_bytes = 0; pStats->rx_errors = 0; pStats->tx_errors = 0; pStats->multicast = 0; /* multicast packets received*/ pStats->collisions = 0; /* Collision packets*/ pStats->rx_over_errors = 0; /* receiver ring buff overflow*/ pStats->rx_crc_errors = 0; /* recved pkt with crc error*/ pStats->rx_frame_errors = 0; /* recv'd frame alignment error*/ pStats->rx_fifo_errors = 0; /* recv'r fifo overrun*/ DBGPRINT(RT_DEBUG_ERROR, ("CMD_RTPRIV_IOCTL_INF_STATS_GET: can not find mbss I/F\n")); return NDIS_STATUS_FAILURE; } pStats->rx_packets = pAd->ApCfg.MBSSID[index].RxCount; pStats->tx_packets = pAd->ApCfg.MBSSID[index].TxCount; pStats->rx_bytes = pAd->ApCfg.MBSSID[index].ReceivedByteCount; pStats->tx_bytes = pAd->ApCfg.MBSSID[index].TransmittedByteCount; pStats->rx_errors = pAd->ApCfg.MBSSID[index].RxErrorCount; pStats->tx_errors = pAd->ApCfg.MBSSID[index].TxErrorCount; pStats->multicast = pAd->ApCfg.MBSSID[index].mcPktsRx; /* multicast packets received */ pStats->collisions = 0; /* Collision packets*/ pStats->rx_over_errors = 0; /* receiver ring buff overflow*/ pStats->rx_crc_errors = 0; /* recved pkt with crc error*/ pStats->rx_frame_errors = 0; /* recv'd frame alignment error*/ pStats->rx_fifo_errors = 0; /* recv'r fifo overrun*/ } #endif } break; case CMD_RTPRIV_IOCTL_INF_IW_STATUS_GET: /* get wireless statistics */ { UCHAR CurOpMode = OPMODE_AP; #ifdef CONFIG_AP_SUPPORT PMAC_TABLE_ENTRY pMacEntry = NULL; #endif /* CONFIG_AP_SUPPORT */ RT_CMD_IW_STATS *pStats = (RT_CMD_IW_STATS *)pData; pStats->qual = 0; pStats->level = 0; pStats->noise = 0; pStats->pStats = pAd->iw_stats; /*check if the interface is down*/ if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) return NDIS_STATUS_FAILURE; #ifdef CONFIG_AP_SUPPORT if (CurOpMode == OPMODE_AP) { #ifdef APCLI_SUPPORT if ((pStats->priv_flags == INT_APCLI)) { INT ApCliIdx = ApCliIfLookUp(pAd, (PUCHAR)pStats->dev_addr); if ((ApCliIdx >= 0) && VALID_WCID(pAd->ApCfg.ApCliTab[ApCliIdx].MacTabWCID)) pMacEntry = &pAd->MacTab.Content[pAd->ApCfg.ApCliTab[ApCliIdx].MacTabWCID]; } else #endif /* APCLI_SUPPORT */ { /* only AP client support wireless stats function. return NULL pointer for all other cases. */ pMacEntry = NULL; } } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_AP_SUPPORT if (CurOpMode == OPMODE_AP) { if (pMacEntry != NULL) pStats->qual = ((pMacEntry->ChannelQuality * 12) / 10 + 10); else pStats->qual = ((pAd->Mlme.ChannelQuality * 12) / 10 + 10); } #endif /* CONFIG_AP_SUPPORT */ if (pStats->qual > 100) pStats->qual = 100; #ifdef CONFIG_AP_SUPPORT if (CurOpMode == OPMODE_AP) { if (pMacEntry != NULL) pStats->level = RTMPMaxRssi(pAd, pMacEntry->RssiSample.AvgRssi0, pMacEntry->RssiSample.AvgRssi1, pMacEntry->RssiSample.AvgRssi2); } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_AP_SUPPORT pStats->noise = RTMPMaxRssi(pAd, pAd->ApCfg.RssiSample.AvgRssi0, pAd->ApCfg.RssiSample.AvgRssi1, pAd->ApCfg.RssiSample.AvgRssi2) - RTMPMinSnr(pAd, pAd->ApCfg.RssiSample.AvgSnr0, pAd->ApCfg.RssiSample.AvgSnr1); #endif /* CONFIG_AP_SUPPORT */ } break; case CMD_RTPRIV_IOCTL_INF_MAIN_CREATE: *(VOID **)pData = RtmpPhyNetDevMainCreate(pAd); break; case CMD_RTPRIV_IOCTL_INF_MAIN_ID_GET: *(ULONG *)pData = INT_MAIN; break; case CMD_RTPRIV_IOCTL_INF_MAIN_CHECK: if (Data != INT_MAIN) return NDIS_STATUS_FAILURE; break; case CMD_RTPRIV_IOCTL_INF_P2P_CHECK: if (Data != INT_P2P) return NDIS_STATUS_FAILURE; break; #ifdef WDS_SUPPORT case CMD_RTPRIV_IOCTL_WDS_INIT: WDS_Init(pAd, pData); break; case CMD_RTPRIV_IOCTL_WDS_REMOVE: WDS_Remove(pAd); break; case CMD_RTPRIV_IOCTL_WDS_STATS_GET: if (Data == INT_WDS) { if (WDS_StatsGet(pAd, pData) != TRUE) return NDIS_STATUS_FAILURE; } else return NDIS_STATUS_FAILURE; break; #endif /* WDS_SUPPORT */ #ifdef RALINK_ATE #ifdef RALINK_QA case CMD_RTPRIV_IOCTL_ATE: RtmpDoAte(pAd, wrq, pData); break; #endif /* RALINK_QA */ #endif /* RALINK_ATE */ case CMD_RTPRIV_IOCTL_MAC_ADDR_GET: RT28xx_EEPROM_READ16(pAd, 0x04, Addr01); RT28xx_EEPROM_READ16(pAd, 0x06, Addr23); RT28xx_EEPROM_READ16(pAd, 0x08, Addr45); PermanentAddress[0] = (UCHAR)(Addr01 & 0xff); PermanentAddress[1] = (UCHAR)(Addr01 >> 8); PermanentAddress[2] = (UCHAR)(Addr23 & 0xff); PermanentAddress[3] = (UCHAR)(Addr23 >> 8); PermanentAddress[4] = (UCHAR)(Addr45 & 0xff); PermanentAddress[5] = (UCHAR)(Addr45 >> 8); for(i = 0; i < 6; i++) *(UCHAR *)(pData+i) = PermanentAddress[i]; break; #ifdef CONFIG_AP_SUPPORT case CMD_RTPRIV_IOCTL_AP_SIOCGIWRATEQ: /* handle for SIOCGIWRATEQ */ { RT_CMD_IOCTL_RATE *pRate = (RT_CMD_IOCTL_RATE *)pData; HTTRANSMIT_SETTING HtPhyMode; #ifdef APCLI_SUPPORT if (pRate->priv_flags == INT_APCLI) HtPhyMode = pAd->ApCfg.ApCliTab[pObj->ioctl_if].HTPhyMode; else #endif /* APCLI_SUPPORT */ #ifdef WDS_SUPPORT if (pRate->priv_flags == INT_WDS) HtPhyMode = pAd->WdsTab.WdsEntry[pObj->ioctl_if].HTPhyMode; else #endif /* WDS_SUPPORT */ { HtPhyMode = pAd->ApCfg.MBSSID[pObj->ioctl_if].HTPhyMode; #ifdef MBSS_SUPPORT /* reset phy mode for MBSS */ MBSS_PHY_MODE_RESET(pObj->ioctl_if, HtPhyMode); #endif /* MBSS_SUPPORT */ } RtmpDrvMaxRateGet(pAd, HtPhyMode.field.MODE, HtPhyMode.field.ShortGI, HtPhyMode.field.BW, HtPhyMode.field.MCS, (UINT32 *)&pRate->BitRate); } break; #endif /* CONFIG_AP_SUPPORT */ case CMD_RTPRIV_IOCTL_SIOCGIWNAME: RtmpIoctl_rt_ioctl_giwname(pAd, pData, 0); break; #if defined(CONFIG_CSO_SUPPORT) || defined(CONFIG_RX_CSO_SUPPORT) case CMD_RTPRIV_IOCTL_ADAPTER_CSO_SUPPORT_TEST: *(UCHAR *)pData = (pAd->MoreFlags & fASIC_CAP_CSO) ? 1:0; break; #endif /* defined(CONFIG_CSO_SUPPORT) || defined(CONFIG_RX_CSO_SUPPORT) */ } #ifdef RT_CFG80211_SUPPORT if ((CMD_RTPRIV_IOCTL_80211_START <= cmd) && (cmd <= CMD_RTPRIV_IOCTL_80211_END)) CFG80211DRV_IoctlHandle(pAd, wrq, cmd, subcmd, pData, Data); #endif /* RT_CFG80211_SUPPORT */ if (cmd >= CMD_RTPRIV_IOCTL_80211_COM_LATEST_ONE) return NDIS_STATUS_FAILURE; return Status; }
/* ========================================================================== Description: This routine is executed every second - 1. Decide the overall channel quality 2. Check if need to upgrade the TX rate to any client 3. perform MAC table maintenance, including ageout no-traffic clients, and release packet buffer in PSQ is fail to TX in time. ========================================================================== */ VOID APMlmePeriodicExec( PRTMP_ADAPTER pAd) { /* Reqeust by David 2005/05/12 It make sense to disable Adjust Tx Power on AP mode, since we can't take care all of the client's situation ToDo: need to verify compatibility issue with WiFi product. */ #ifdef CARRIER_DETECTION_SUPPORT if (isCarrierDetectExist(pAd) == TRUE) { PCARRIER_DETECTION_STRUCT pCarrierDetect = &pAd->CommonCfg.CarrierDetect; if (pCarrierDetect->OneSecIntCount < pCarrierDetect->CarrierGoneThreshold) { pCarrierDetect->CD_State = CD_NORMAL; pCarrierDetect->recheck = pCarrierDetect->recheck1; if (pCarrierDetect->Debug != RT_DEBUG_TRACE) { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); /* start all TX actions. */ APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); AsicEnableBssSync(pAd, pAd->CommonCfg.BeaconPeriod); } else { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); } } pCarrierDetect->OneSecIntCount = 0; } #endif /* CARRIER_DETECTION_SUPPORT */ RTMP_CHIP_HIGH_POWER_TUNING(pAd, &pAd->ApCfg.RssiSample); /* Disable Adjust Tx Power for WPA WiFi-test. */ /* Because high TX power results in the abnormal disconnection of Intel BG-STA. */ /*#ifndef WIFI_TEST */ /* if (pAd->CommonCfg.bWiFiTest == FALSE) */ /* for SmartBit 64-byte stream test */ /* removed based on the decision of Ralink congress at 2011/7/06 */ /* if (pAd->MacTab.Size > 0) */ RTMP_CHIP_ASIC_ADJUST_TX_POWER(pAd); /*#endif // WIFI_TEST */ RTMP_CHIP_ASIC_TEMPERATURE_COMPENSATION(pAd); /* walk through MAC table, see if switching TX rate is required */ /* MAC table maintenance */ if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE == 0) { /* one second timer */ MacTableMaintenance(pAd); #ifdef CONFIG_FPGA_MODE if (pAd->fpga_ctl.fpga_tr_stop) { INT enable = FALSE, ctrl_type; /* enable/disable tx/rx*/ switch (pAd->fpga_ctl.fpga_tr_stop) { case 3: //stop tx + rx ctrl_type = ASIC_MAC_TXRX; break; case 2: // stop rx ctrl_type = ASIC_MAC_RX; break; case 1: // stop tx ctrl_type = ASIC_MAC_TX; break; case 4: default: enable = TRUE; ctrl_type = ASIC_MAC_TXRX; break; } AsicSetMacTxRx(pAd, ctrl_type, enable); } #endif /* CONFIG_FPGA_MODE */ RTMPMaintainPMKIDCache(pAd); #ifdef WDS_SUPPORT WdsTableMaintenance(pAd); #endif /* WDS_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabMaintain(pAd); #endif /* CLIENT_WDS */ } #ifdef AP_SCAN_SUPPORT AutoChannelSelCheck(pAd); #endif /* AP_SCAN_SUPPORT */ APUpdateCapabilityAndErpIe(pAd); #ifdef APCLI_SUPPORT if (pAd->Mlme.OneSecPeriodicRound % 2 == 0) ApCliIfMonitor(pAd); if (pAd->Mlme.OneSecPeriodicRound % 2 == 1 #ifdef APCLI_AUTO_CONNECT_SUPPORT && (pAd->ApCfg.ApCliAutoConnectChannelSwitching == FALSE) #endif /* APCLI_AUTO_CONNECT_SUPPORT */ ) { ApCliIfUp(pAd); } { INT loop; ULONG Now32; #ifdef MAC_REPEATER_SUPPORT if (pAd->ApCfg.bMACRepeaterEn) { RTMPRepeaterReconnectionCheck(pAd); } #endif /* MAC_REPEATER_SUPPORT */ NdisGetSystemUpTime(&Now32); for (loop = 0; loop < MAX_APCLI_NUM; loop++) { PAPCLI_STRUCT pApCliEntry = &pAd->ApCfg.ApCliTab[loop]; if ((pApCliEntry->Valid == TRUE) && (pApCliEntry->MacTabWCID < MAX_LEN_OF_MAC_TABLE)) { /* update channel quality for Roaming and UI LinkQuality display */ MlmeCalculateChannelQuality(pAd, &pAd->MacTab.Content[pApCliEntry->MacTabWCID], Now32); } } } #endif /* APCLI_SUPPORT */ #ifdef DOT11_N_SUPPORT if (pAd->CommonCfg.bHTProtect) { /*APUpdateCapabilityAndErpIe(pAd); */ APUpdateOperationMode(pAd); if (pAd->CommonCfg.IOTestParm.bRTSLongProtOn == FALSE) AsicUpdateProtect(pAd, (USHORT)pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, pAd->MacTab.fAnyStationNonGF); } #endif /* DOT11_N_SUPPORT */ #ifdef A_BAND_SUPPORT if ( (pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == 1)) { #ifdef DFS_SUPPORT ApRadarDetectPeriodic(pAd); #else pAd->Dot11_H.InServiceMonitorCount++; if (pAd->Dot11_H.RDMode == RD_SILENCE_MODE) { if (pAd->Dot11_H.RDCount++ > pAd->Dot11_H.ChMovingTime) { AsicEnableBssSync(pAd, pAd->CommonCfg.BeaconPeriod); pAd->Dot11_H.RDMode = RD_NORMAL_MODE; } } #endif /* !DFS_SUPPORT */ } #endif /* A_BAND_SUPPORT */ }
INT RTMP_COM_IoctlHandle( IN VOID *pAdSrc, IN RTMP_IOCTL_INPUT_STRUCT *wrq, IN INT cmd, IN USHORT subcmd, IN VOID *pData, IN ULONG Data) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie; INT Status = NDIS_STATUS_SUCCESS, i; pObj = pObj; /* avoid compile warning */ switch(cmd) { case CMD_RTPRIV_IOCTL_NETDEV_GET: /* get main net_dev */ { VOID **ppNetDev = (VOID **)pData; *ppNetDev = (VOID *)(pAd->net_dev); } break; case CMD_RTPRIV_IOCTL_NETDEV_SET: { struct wifi_dev *wdev = NULL; /* set main net_dev */ pAd->net_dev = pData; #ifdef CONFIG_AP_SUPPORT if (pAd->OpMode == OPMODE_AP) { pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev.if_dev = (void *)pData; pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev.func_dev = (void *)&pAd->ApCfg.MBSSID[MAIN_MBSSID]; pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev.sys_handle = (void *)pAd; RTMP_OS_NETDEV_SET_WDEV(pData, &pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev); wdev = &pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev; } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT if (pAd->OpMode == OPMODE_STA) { pAd->StaCfg.wdev.if_dev = pData; pAd->StaCfg.wdev.func_dev = (void *)&pAd->StaCfg; pAd->StaCfg.wdev.sys_handle = (void *)pAd; RTMP_OS_NETDEV_SET_WDEV(pData, &pAd->StaCfg.wdev); wdev = &pAd->StaCfg.wdev; } #endif /* CONFIG_STA_SUPPORT */ if (wdev) { if (rtmp_wdev_idx_reg(pAd, wdev) < 0) { DBGPRINT(RT_DEBUG_ERROR, ("Assign wdev idx for %s failed, free net device!\n", RTMP_OS_NETDEV_GET_DEVNAME(pAd->net_dev))); RtmpOSNetDevFree(pAd->net_dev); } } break; } case CMD_RTPRIV_IOCTL_OPMODE_GET: /* get Operation Mode */ *(ULONG *)pData = pAd->OpMode; break; case CMD_RTPRIV_IOCTL_TASK_LIST_GET: /* get all Tasks */ { RT_CMD_WAIT_QUEUE_LIST *pList = (RT_CMD_WAIT_QUEUE_LIST *)pData; pList->pMlmeTask = &pAd->mlmeTask; #ifdef RTMP_TIMER_TASK_SUPPORT pList->pTimerTask = &pAd->timerTask; #endif /* RTMP_TIMER_TASK_SUPPORT */ pList->pCmdQTask = &pAd->cmdQTask; } break; case CMD_RTPRIV_IOCTL_IRQ_RELEASE: /* release IRQ */ RTMP_OS_IRQ_RELEASE(pAd, pAd->net_dev); break; case CMD_RTPRIV_IOCTL_NIC_NOT_EXIST: /* set driver state to fRTMP_ADAPTER_NIC_NOT_EXIST */ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST); break; case CMD_RTPRIV_IOCTL_MCU_SLEEP_CLEAR: RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_MCU_SLEEP); break; #ifdef CONFIG_STA_SUPPORT #ifdef CONFIG_PM #ifdef USB_SUPPORT_SELECTIVE_SUSPEND case CMD_RTPRIV_IOCTL_USB_DEV_GET: /* get USB DEV */ { VOID **ppUsb_Dev = (VOID **)pData; *ppUsb_Dev = (VOID *)(pObj->pUsb_Dev); } break; case CMD_RTPRIV_IOCTL_USB_INTF_GET: /* get USB INTF */ { VOID **ppINTF = (VOID **)pData; *ppINTF = (VOID *)(pObj->intf); } break; case CMD_RTPRIV_IOCTL_ADAPTER_SUSPEND_SET: /* set driver state to fRTMP_ADAPTER_SUSPEND */ RTMP_SET_FLAG(pAd,fRTMP_ADAPTER_SUSPEND); break; case CMD_RTPRIV_IOCTL_ADAPTER_SUSPEND_CLEAR: /* clear driver state to fRTMP_ADAPTER_SUSPEND */ RTMP_CLEAR_FLAG(pAd,fRTMP_ADAPTER_SUSPEND); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_MCU_SEND_IN_BAND_CMD); RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_MCU_SLEEP); break; case CMD_RTPRIV_IOCTL_ADAPTER_SEND_DISSASSOCIATE: /* clear driver state to fRTMP_ADAPTER_SUSPEND */ if (INFRA_ON(pAd) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) { MLME_DISASSOC_REQ_STRUCT DisReq; MLME_QUEUE_ELEM *MsgElem; os_alloc_mem(NULL, (UCHAR **)&MsgElem, sizeof(MLME_QUEUE_ELEM)); if (MsgElem) { COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid); DisReq.Reason = REASON_DEAUTH_STA_LEAVING; MsgElem->Machine = ASSOC_STATE_MACHINE; MsgElem->MsgType = MT2_MLME_DISASSOC_REQ; MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT); NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT)); /* Prevent to connect AP again in STAMlmePeriodicExec*/ pAd->MlmeAux.AutoReconnectSsidLen= 32; NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen); pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC; MlmeDisassocReqAction(pAd, MsgElem); os_free_mem(NULL, MsgElem); } /* RtmpusecDelay(1000);*/ RtmpOSWrielessEventSend(pAd->net_dev, RT_WLAN_EVENT_CGIWAP, -1, NULL, NULL, 0); } break; case CMD_RTPRIV_IOCTL_ADAPTER_SUSPEND_TEST: /* test driver state to fRTMP_ADAPTER_SUSPEND */ *(UCHAR *)pData = RTMP_TEST_FLAG(pAd,fRTMP_ADAPTER_SUSPEND); break; case CMD_RTPRIV_IOCTL_ADAPTER_IDLE_RADIO_OFF_TEST: /* test driver state to fRTMP_ADAPTER_IDLE_RADIO_OFF */ *(UCHAR *)pData = RTMP_TEST_FLAG(pAd,fRTMP_ADAPTER_IDLE_RADIO_OFF); break; case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_USB_ASICRADIO_OFF: ASIC_RADIO_OFF(pAd, SUSPEND_RADIO_OFF); break; case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_USB_ASICRADIO_ON: ASIC_RADIO_ON(pAd, RESUME_RADIO_ON); break; #endif /* USB_SUPPORT_SELECTIVE_SUSPEND */ #if (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_WOW_STATUS: *(UCHAR *)pData = (UCHAR)pAd->WOW_Cfg.bEnable; break; case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_WOW_ENABLE: ASIC_WOW_ENABLE(pAd); break; case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_WOW_DISABLE: ASIC_WOW_DISABLE(pAd); break; #endif /* (defined(WOW_SUPPORT) && defined(RTMP_MAC_USB)) || defined(NEW_WOW_SUPPORT) */ #endif /* CONFIG_PM */ case CMD_RTPRIV_IOCTL_AP_BSSID_GET: if (pAd->StaCfg.wdev.PortSecured == WPA_802_1X_PORT_NOT_SECURED) NdisCopyMemory(pData, pAd->MlmeAux.Bssid, 6); else return NDIS_STATUS_FAILURE; break; case CMD_RTPRIV_IOCTL_ADAPTER_SUSPEND_SET: /* set driver state to fRTMP_ADAPTER_SUSPEND */ RTMP_SET_FLAG(pAd,fRTMP_ADAPTER_SUSPEND); break; case CMD_RTPRIV_IOCTL_ADAPTER_SUSPEND_CLEAR: /* clear driver state to fRTMP_ADAPTER_SUSPEND */ RTMP_CLEAR_FLAG(pAd,fRTMP_ADAPTER_SUSPEND); break; case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_USB_ASICRADIO_OFF: /* RT28xxUsbAsicRadioOff */ //RT28xxUsbAsicRadioOff(pAd); ASIC_RADIO_OFF(pAd, SUSPEND_RADIO_OFF); break; case CMD_RTPRIV_IOCTL_ADAPTER_RT28XX_USB_ASICRADIO_ON: /* RT28xxUsbAsicRadioOn */ //RT28xxUsbAsicRadioOn(pAd); ASIC_RADIO_ON(pAd, RESUME_RADIO_ON); break; #endif /* CONFIG_STA_SUPPORT */ case CMD_RTPRIV_IOCTL_SANITY_CHECK: /* sanity check before IOCTL */ if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) #ifdef IFUP_IN_PROBE || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) #endif /* IFUP_IN_PROBE */ ) { if(pData == NULL || RT_isLegalCmdBeforeInfUp((PSTRING) pData) == FALSE) return NDIS_STATUS_FAILURE; } break; case CMD_RTPRIV_IOCTL_SIOCGIWFREQ: /* get channel number */ *(ULONG *)pData = pAd->CommonCfg.Channel; break; case CMD_RTPRIV_IOCTL_BEACON_UPDATE: /* update all beacon contents */ #ifdef CONFIG_AP_SUPPORT APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif /* CONFIG_AP_SUPPORT */ break; case CMD_RTPRIV_IOCTL_RXPATH_GET: /* get the number of rx path */ *(ULONG *)pData = pAd->Antenna.field.RxPath; break; case CMD_RTPRIV_IOCTL_CHAN_LIST_NUM_GET: *(ULONG *)pData = pAd->ChannelListNum; break; case CMD_RTPRIV_IOCTL_CHAN_LIST_GET: { UINT32 i; UCHAR *pChannel = (UCHAR *)pData; for (i = 1; i <= pAd->ChannelListNum; i++) { *pChannel = pAd->ChannelList[i-1].Channel; pChannel ++; } } break; case CMD_RTPRIV_IOCTL_FREQ_LIST_GET: { UINT32 i; UINT32 *pFreq = (UINT32 *)pData; UINT32 m; for (i = 1; i <= pAd->ChannelListNum; i++) { m = 2412000; MAP_CHANNEL_ID_TO_KHZ(pAd->ChannelList[i-1].Channel, m); (*pFreq) = m; pFreq ++; } } break; #ifdef EXT_BUILD_CHANNEL_LIST case CMD_RTPRIV_SET_PRECONFIG_VALUE: /* Set some preconfigured value before interface up*/ pAd->CommonCfg.DfsType = MAX_RD_REGION; break; #endif /* EXT_BUILD_CHANNEL_LIST */ #ifdef RTMP_USB_SUPPORT case CMD_RTPRIV_IOCTL_USB_MORE_FLAG_SET: { RT_CMD_USB_MORE_FLAG_CONFIG *pConfig; UINT32 VendorID, ProductID; pConfig = (RT_CMD_USB_MORE_FLAG_CONFIG *)pData; VendorID = pConfig->VendorID; ProductID = pConfig->ProductID; if (VendorID == 0x0DB0) { if ((ProductID == 0x871C) || (ProductID == 0x822C)) { RTMP_SET_MORE_FLAG(pAd, (fRTMP_ADAPTER_DISABLE_DOT_11N | fRTMP_ADAPTER_WSC_PBC_PIN0)); } if ((ProductID == 0x871A) || (ProductID == 0x822A)) { RTMP_SET_MORE_FLAG(pAd, fRTMP_ADAPTER_DISABLE_DOT_11N); } if ((ProductID == 0x871B) || (ProductID == 0x822B)) { RTMP_SET_MORE_FLAG(pAd, fRTMP_ADAPTER_WSC_PBC_PIN0); } } if (VendorID == 0x07D1) { if (ProductID == 0x3C0F) RTMP_SET_MORE_FLAG(pAd, fRTMP_ADAPTER_DISABLE_DOT_11N); } } break; case CMD_RTPRIV_IOCTL_USB_CONFIG_INIT: { RT_CMD_USB_DEV_CONFIG *pConfig; UINT32 i; pConfig = (RT_CMD_USB_DEV_CONFIG *)pData; pAd->NumberOfPipes = pConfig->NumberOfPipes; pAd->BulkInMaxPacketSize = pConfig->BulkInMaxPacketSize; pAd->BulkOutMaxPacketSize = pConfig->BulkOutMaxPacketSize; for (i = 0; i < 6; i++) pAd->BulkOutEpAddr[i] = pConfig->BulkOutEpAddr[i]; for (i = 0; i < 2; i++) pAd->BulkInEpAddr[i] = pConfig->BulkInEpAddr[i]; pAd->config = pConfig->pConfig; } break; case CMD_RTPRIV_IOCTL_USB_SUSPEND: pAd->PM_FlgSuspend = 1; if (Data) { RTUSBCancelPendingBulkInIRP(pAd); RTUSBCancelPendingBulkOutIRP(pAd); } break; case CMD_RTPRIV_IOCTL_USB_RESUME: pAd->PM_FlgSuspend = 0; break; case CMD_RTPRIV_IOCTL_USB_INIT: InitUSBDevice(pData, pAd); break; #endif /* RTMP_USB_SUPPORT */ #ifdef RT_CFG80211_SUPPORT case CMD_RTPRIV_IOCTL_CFG80211_CFG_START: RT_CFG80211_REINIT(pAd); RT_CFG80211_CRDA_REG_RULE_APPLY(pAd); break; #endif /* RT_CFG80211_SUPPORT */ #ifdef INF_PPA_SUPPORT case CMD_RTPRIV_IOCTL_INF_PPA_INIT: os_alloc_mem(NULL, (UCHAR **)&(pAd->pDirectpathCb), sizeof(PPA_DIRECTPATH_CB)); break; case CMD_RTPRIV_IOCTL_INF_PPA_EXIT: if (ppa_hook_directpath_register_dev_fn && (pAd->PPAEnable == TRUE)) { UINT status; status = ppa_hook_directpath_register_dev_fn(&pAd->g_if_id, pAd->net_dev, NULL, 0); DBGPRINT(RT_DEBUG_TRACE, ("Unregister PPA::status=%d, if_id=%d\n", status, pAd->g_if_id)); } os_free_mem(NULL, pAd->pDirectpathCb); break; #endif /* INF_PPA_SUPPORT*/ case CMD_RTPRIV_IOCTL_VIRTUAL_INF_UP: /* interface up */ { RT_CMD_INF_UP_DOWN *pInfConf = (RT_CMD_INF_UP_DOWN *)pData; if (VIRTUAL_IF_NUM(pAd) == 0) { if (pInfConf->rt28xx_open(pAd->net_dev) != 0) { DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_open return fail!\n")); return NDIS_STATUS_FAILURE; } } else { #ifdef CONFIG_AP_SUPPORT extern VOID APMakeAllBssBeacon(IN PRTMP_ADAPTER pAd); extern VOID APUpdateAllBeaconFrame(IN PRTMP_ADAPTER pAd); APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); #endif /* CONFIG_AP_SUPPORT */ } VIRTUAL_IF_INC(pAd); } break; case CMD_RTPRIV_IOCTL_VIRTUAL_INF_DOWN: /* interface down */ { RT_CMD_INF_UP_DOWN *pInfConf = (RT_CMD_INF_UP_DOWN *)pData; VIRTUAL_IF_DEC(pAd); if (VIRTUAL_IF_NUM(pAd) == 0) pInfConf->rt28xx_close(pAd->net_dev); } break; case CMD_RTPRIV_IOCTL_VIRTUAL_INF_GET: /* get virtual interface number */ *(ULONG *)pData = VIRTUAL_IF_NUM(pAd); break; case CMD_RTPRIV_IOCTL_INF_TYPE_GET: /* get current interface type */ *(ULONG *)pData = pAd->infType; break; case CMD_RTPRIV_IOCTL_INF_STATS_GET: /* get statistics */ { RT_CMD_STATS *pStats = (RT_CMD_STATS *)pData; pStats->pStats = pAd->stats; if(pAd->OpMode == OPMODE_STA) { pStats->rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart; pStats->tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart; pStats->rx_bytes = pAd->RalinkCounters.ReceivedByteCount; pStats->tx_bytes = pAd->RalinkCounters.TransmittedByteCount; pStats->rx_errors = pAd->Counters8023.RxErrors; pStats->tx_errors = pAd->Counters8023.TxErrors; pStats->multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; /* multicast packets received*/ pStats->collisions = 0; /* Collision packets*/ pStats->rx_over_errors = pAd->Counters8023.RxNoBuffer; /* receiver ring buff overflow*/ pStats->rx_crc_errors = 0;/*pAd->WlanCounters.FCSErrorCount; recved pkt with crc error*/ pStats->rx_frame_errors = 0; /* recv'd frame alignment error*/ pStats->rx_fifo_errors = pAd->Counters8023.RxNoBuffer; /* recv'r fifo overrun*/ } #ifdef CONFIG_AP_SUPPORT else if(pAd->OpMode == OPMODE_AP) { INT index; for(index = 0; index < MAX_MBSSID_NUM(pAd); index++) { if (pAd->ApCfg.MBSSID[index].wdev.if_dev == (PNET_DEV)(pStats->pNetDev)) { break; } } if(index >= MAX_MBSSID_NUM(pAd)) { //reset counters pStats->rx_packets = 0; pStats->tx_packets = 0; pStats->rx_bytes = 0; pStats->tx_bytes = 0; pStats->rx_errors = 0; pStats->tx_errors = 0; pStats->multicast = 0; /* multicast packets received*/ pStats->collisions = 0; /* Collision packets*/ pStats->rx_over_errors = 0; /* receiver ring buff overflow*/ pStats->rx_crc_errors = 0; /* recved pkt with crc error*/ pStats->rx_frame_errors = 0; /* recv'd frame alignment error*/ pStats->rx_fifo_errors = 0; /* recv'r fifo overrun*/ DBGPRINT(RT_DEBUG_ERROR, ("CMD_RTPRIV_IOCTL_INF_STATS_GET: can not find mbss I/F\n")); return NDIS_STATUS_FAILURE; } pStats->rx_packets = pAd->ApCfg.MBSSID[index].RxCount; pStats->tx_packets = pAd->ApCfg.MBSSID[index].TxCount; pStats->rx_bytes = pAd->ApCfg.MBSSID[index].ReceivedByteCount; pStats->tx_bytes = pAd->ApCfg.MBSSID[index].TransmittedByteCount; pStats->rx_errors = pAd->ApCfg.MBSSID[index].RxErrorCount; pStats->tx_errors = pAd->ApCfg.MBSSID[index].TxErrorCount; pStats->multicast = pAd->ApCfg.MBSSID[index].mcPktsRx; /* multicast packets received */ pStats->collisions = 0; /* Collision packets*/ pStats->rx_over_errors = 0; /* receiver ring buff overflow*/ pStats->rx_crc_errors = 0;/* recved pkt with crc error*/ pStats->rx_frame_errors = 0; /* recv'd frame alignment error*/ pStats->rx_fifo_errors = 0; /* recv'r fifo overrun*/ } #endif } break; case CMD_RTPRIV_IOCTL_INF_IW_STATUS_GET: /* get wireless statistics */ { UCHAR CurOpMode = OPMODE_AP; #ifdef CONFIG_AP_SUPPORT PMAC_TABLE_ENTRY pMacEntry = NULL; #endif /* CONFIG_AP_SUPPORT */ RT_CMD_IW_STATS *pStats = (RT_CMD_IW_STATS *)pData; pStats->qual = 0; pStats->level = 0; pStats->noise = 0; pStats->pStats = pAd->iw_stats; #ifdef CONFIG_STA_SUPPORT if (pAd->OpMode == OPMODE_STA) { CurOpMode = OPMODE_STA; } #endif /* CONFIG_STA_SUPPORT */ /*check if the interface is down*/ if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) return NDIS_STATUS_FAILURE; #ifdef CONFIG_AP_SUPPORT if (CurOpMode == OPMODE_AP) { #ifdef APCLI_SUPPORT if ((pStats->priv_flags == INT_APCLI) ) { INT ApCliIdx = ApCliIfLookUp(pAd, (PUCHAR)pStats->dev_addr); if ((ApCliIdx >= 0) && VALID_WCID(pAd->ApCfg.ApCliTab[ApCliIdx].MacTabWCID)) pMacEntry = &pAd->MacTab.Content[pAd->ApCfg.ApCliTab[ApCliIdx].MacTabWCID]; } else #endif /* APCLI_SUPPORT */ { /* only AP client support wireless stats function. return NULL pointer for all other cases. */ pMacEntry = NULL; } } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT if (CurOpMode == OPMODE_STA) pStats->qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10); #endif /* CONFIG_STA_SUPPORT */ #ifdef CONFIG_AP_SUPPORT if (CurOpMode == OPMODE_AP) { if (pMacEntry != NULL) pStats->qual = ((pMacEntry->ChannelQuality * 12)/10 + 10); else pStats->qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10); } #endif /* CONFIG_AP_SUPPORT */ if (pStats->qual > 100) pStats->qual = 100; #ifdef CONFIG_STA_SUPPORT if (CurOpMode == OPMODE_STA) { pStats->level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.AvgRssi0, pAd->StaCfg.RssiSample.AvgRssi1, pAd->StaCfg.RssiSample.AvgRssi2); } #endif /* CONFIG_STA_SUPPORT */ #ifdef CONFIG_AP_SUPPORT if (CurOpMode == OPMODE_AP) { if (pMacEntry != NULL) pStats->level = RTMPMaxRssi(pAd, pMacEntry->RssiSample.AvgRssi0, pMacEntry->RssiSample.AvgRssi1, pMacEntry->RssiSample.AvgRssi2); } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_AP_SUPPORT pStats->noise = RTMPMaxRssi(pAd, pAd->ApCfg.RssiSample.AvgRssi0, pAd->ApCfg.RssiSample.AvgRssi1, pAd->ApCfg.RssiSample.AvgRssi2) - RTMPMinSnr(pAd, pAd->ApCfg.RssiSample.AvgSnr0, pAd->ApCfg.RssiSample.AvgSnr1); #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT pStats->noise = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.AvgRssi0, pAd->StaCfg.RssiSample.AvgRssi1, pAd->StaCfg.RssiSample.AvgRssi2) - RTMPMinSnr(pAd, pAd->StaCfg.RssiSample.AvgSnr0, pAd->StaCfg.RssiSample.AvgSnr1); #endif /* CONFIG_STA_SUPPORT */ } break; case CMD_RTPRIV_IOCTL_INF_MAIN_CREATE: *(VOID **)pData = RtmpPhyNetDevMainCreate(pAd); break; case CMD_RTPRIV_IOCTL_INF_MAIN_ID_GET: *(ULONG *)pData = INT_MAIN; break; case CMD_RTPRIV_IOCTL_INF_MAIN_CHECK: if (Data != INT_MAIN) return NDIS_STATUS_FAILURE; break; case CMD_RTPRIV_IOCTL_INF_P2P_CHECK: if (Data != INT_P2P) return NDIS_STATUS_FAILURE; break; #ifdef RALINK_ATE #endif /* RALINK_ATE */ case CMD_RTPRIV_IOCTL_MAC_ADDR_GET: { UCHAR mac_addr[MAC_ADDR_LEN]; USHORT Addr01, Addr23, Addr45; RT28xx_EEPROM_READ16(pAd, 0x04, Addr01); RT28xx_EEPROM_READ16(pAd, 0x06, Addr23); RT28xx_EEPROM_READ16(pAd, 0x08, Addr45); mac_addr[0] = (UCHAR)(Addr01 & 0xff); mac_addr[1] = (UCHAR)(Addr01 >> 8); mac_addr[2] = (UCHAR)(Addr23 & 0xff); mac_addr[3] = (UCHAR)(Addr23 >> 8); mac_addr[4] = (UCHAR)(Addr45 & 0xff); mac_addr[5] = (UCHAR)(Addr45 >> 8); for(i=0; i<6; i++) *(UCHAR *)(pData+i) = mac_addr[i]; break; } #ifdef CONFIG_AP_SUPPORT case CMD_RTPRIV_IOCTL_AP_SIOCGIWRATEQ: /* handle for SIOCGIWRATEQ */ { RT_CMD_IOCTL_RATE *pRate = (RT_CMD_IOCTL_RATE *)pData; HTTRANSMIT_SETTING HtPhyMode; UINT8 BW = 0, GI = 0, MCS = 0; #ifdef APCLI_SUPPORT if (pRate->priv_flags == INT_APCLI) memcpy(&HtPhyMode, &pAd->ApCfg.ApCliTab[pObj->ioctl_if].wdev.HTPhyMode, sizeof(HTTRANSMIT_SETTING)); else #endif /* APCLI_SUPPORT */ { memcpy(&HtPhyMode, &pAd->ApCfg.MBSSID[pObj->ioctl_if].wdev.HTPhyMode, sizeof(HTTRANSMIT_SETTING)); #ifdef MBSS_SUPPORT /* reset phy mode for MBSS */ MBSS_PHY_MODE_RESET(pObj->ioctl_if, HtPhyMode); #endif /* MBSS_SUPPORT */ } #ifdef DOT11_VHT_AC if (HtPhyMode.field.BW == BW_40 && pAd->CommonCfg.vht_bw == VHT_BW_80 && HtPhyMode.field.MODE >= MODE_VHT) { BW = 2; GI = pAd->CommonCfg.vht_sgi_80; } else #endif /* DOT11_VHT_AC */ { BW = HtPhyMode.field.BW; GI = HtPhyMode.field.ShortGI; } RtmpDrvRateGet(pAd, HtPhyMode.field.MODE, GI, BW, HtPhyMode.field.MCS, pAd->Antenna.field.TxPath, (UINT32 *)&pRate->BitRate); } break; #endif /* CONFIG_AP_SUPPORT */ case CMD_RTPRIV_IOCTL_SIOCGIWNAME: RtmpIoctl_rt_ioctl_giwname(pAd, pData, 0); break; } #ifdef RT_CFG80211_SUPPORT if ((CMD_RTPRIV_IOCTL_80211_START <= cmd) && (cmd <= CMD_RTPRIV_IOCTL_80211_END)) { Status = CFG80211DRV_IoctlHandle(pAd, wrq, cmd, subcmd, pData, Data); } #endif /* RT_CFG80211_SUPPORT */ if (cmd >= CMD_RTPRIV_IOCTL_80211_COM_LATEST_ONE) return NDIS_STATUS_FAILURE; return Status; }