mt-drivers: remove conflict packages

This commit is contained in:
hanwckf 2022-10-17 20:46:13 +08:00
parent 52742eaedb
commit f7d434c528
727 changed files with 0 additions and 673654 deletions

View File

@ -1,219 +0,0 @@
# All rights reserved.
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=mt7615d
PKG_VERSION:=5.1.0.0
P4REV:=8
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)
PKG_KCONFIG:= \
SUPPORT_OPENWRT \
WIFI_DRIVER \
FIRST_IF_MT7615E \
FIRST_IF_MT7622 \
FIRST_IF_MT7626 \
FIRST_IF_NONE \
SECOND_IF_NONE \
SECOND_IF_MT7615E \
THIRD_IF_NONE \
THIRD_IF_MT7615E \
RT_FIRST_CARD \
RT_SECOND_CARD \
RT_THIRD_CARD \
RT_FIRST_IF_RF_OFFSET \
RT_SECOND_IF_RF_OFFSET \
RT_THIRD_IF_RF_OFFSET \
MT_WIFI \
MT_WIFI_PATH \
FIRST_IF_EEPROM_FLASH \
FIRST_IF_EEPROM_PROM \
FIRST_IF_EEPROM_EFUSE \
RT_FIRST_CARD_EEPROM \
SECOND_IF_EEPROM_FLASH \
SECOND_IF_EEPROM_PROM \
SECOND_IF_EEPROM_EFUSE \
RT_SECOND_CARD_EEPROM \
THIRD_IF_EEPROM_FLASH \
THIRD_IF_EEPROM_PROM \
THIRD_IF_EEPROM_EFUSE \
RT_THIRD_CARD_EEPROM \
MULTI_INF_SUPPORT \
WIFI_BASIC_FUNC \
DOT11_N_SUPPORT \
DOT11_VHT_AC \
G_BAND_256QAM_SUPPORT \
TPC_SUPPORT \
ICAP_SUPPORT \
SPECTRUM_SUPPORT \
BACKGROUND_SCAN_SUPPORT \
SMART_CARRIER_SENSE_SUPPORT \
MT_DFS_SUPPORT \
OFFCHANNEL_SCAN_FEATURE \
DPP_SUPPORT \
HDR_TRANS_TX_SUPPORT \
HDR_TRANS_RX_SUPPORT \
DBDC_MODE \
MULTI_PROFILE_SUPPORT \
DEFAULT_5G_PROFILE \
WSC_INCLUDED \
WSC_V2_SUPPORT \
DOT11W_PMF_SUPPORT \
TXBF_SUPPORT \
FAST_NAT_SUPPORT \
WHNAT_SUPPORT \
FTM_SUPPORT \
MBO_SUPPORT \
IGMP_SNOOP_SUPPORT \
RTMP_FLASH_SUPPORT \
PRE_CAL_TRX_SET1_SUPPORT \
RLM_CAL_CACHE_SUPPORT \
PRE_CAL_TRX_SET2_SUPPORT \
RF_LOCKDOWN_SUPPORT \
LINK_TEST_SUPPORT \
ATE_SUPPORT \
PASSPOINT_R2 \
UAPSD \
TCP_RACK_SUPPORT \
RED_SUPPORT \
FDB_SUPPORT \
FIRST_IF_IPAILNA \
FIRST_IF_IPAELNA \
FIRST_IF_EPAELNA \
SECOND_IF_IPAILNA \
SECOND_IF_IPAELNA \
SECOND_IF_EPAELNA \
THIRD_IF_EPAELNA \
THIRD_IF_IPAILNA \
THIRD_IF_IPAELNA \
RLT_MAC \
RLT_BBP \
RLT_RF \
RTMP_MAC \
RTMP_BBP \
RTMP_RF \
RTMP_PCI_SUPPORT \
RTMP_USB_SUPPORT \
RTMP_RBUS_SUPPORT \
WIFI_MODE_AP \
WIFI_MODE_STA \
WIFI_MODE_BOTH \
MT_AP_SUPPORT \
WDS_SUPPORT \
WIFI_EAP_FEATURE \
VLAN_SUPPORT \
MLME_MULTI_QUEUE_SUPPORT \
TXRX_STAT_SUPPORT \
SNIFFER_SUPPORT \
ANTENNA_CONTROL_SUPPORT \
MGMT_TXPWR_CTRL \
CHUTIL_SUPPORT \
NF_SUPPORT \
RA_PHY_RATE_SUPPORT \
AMPDU_CONF_SUPPORT \
ACK_CTS_TIMEOUT_SUPPORT \
MBSS_SUPPORT \
APCLI_SUPPORT \
APCLI_CERT_SUPPORT \
MAC_REPEATER_SUPPORT \
MWDS \
MUMIMO_SUPPORT \
MU_RA_SUPPORT \
DOT11R_FT_SUPPORT \
DOT11K_RRM_SUPPORT \
INTERWORKING \
MAP_SUPPORT \
MAP_R2_VER_SUPPORT \
OFFCHANNEL_SCAN_FEATURE \
OCE_SUPPORT \
DPP_FEATURE \
ENTERPRISE_AP_SUPPORT \
DYNAMIC_VLAN_SUPPORT \
CFG80211_SUPPORT \
CUSTOMISED_HOSTAPD_SUPPORT \
APCLI_STA_SUPPORT \
WDS_STA_SUPPORT \
MBSS_AS_WDS_AP_SUPPORT \
DSCP_QOS_MAP_SUPPORT \
DSCP_PRI_SUPPORT \
HOSTAPD_MAP_SUPPORT \
MIN_PHY_RATE_SUPPORT \
FAST_UP_RATE_SUPPORT \
RADIUS_MAC_AUTH_SUPPORT \
CON_WPS_SUPPORT \
MCAST_RATE_SPECIFIC \
VOW_SUPPORT \
FQ_SCH_SUPPORT \
BAND_STEERING \
LED_CONTROL_SUPPORT \
WLAN_HOOK \
RADIUS_ACCOUNTING_SUPPORT \
GREENAP_SUPPORT \
PCIE_ASPM_DYM_CTRL_SUPPORT \
COEX_SUPPORT \
EASY_SETUP_SUPPORT \
EVENT_NOTIFIER_SUPPORT \
AIR_MONITOR \
WNM_SUPPORT \
WIFI_MSI_SUPPORT \
WPA3_SUPPORT \
OWE_SUPPORT \
VENDOR_FEATURE10_SUPPORT \
VENDOR_FEATURE11_SUPPORT \
RCSA_SUPPORT \
ETH_CONVERT_SUPPORT \
WIFI_MT_MAC \
RLT_MAC \
RTMP_MAC \
MT_MAC \
CHIP_MT7603E \
CHIP_MT7615E \
CHIP_MT7622 \
CHIP_MT7663E \
CHIP_MT7626
PKG_CONFIG_DEPENDS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_MTK_$c),CONFIG_$(c)))
include $(INCLUDE_DIR)/package.mk
TAR_CMD=$(HOST_TAR) -C $(1)/ $(TAR_OPTIONS)
define KernelPackage/mt7615d
CATEGORY:=Kernel modules
TITLE:=MTK wifi AP driver
DEPENDS:=@TARGET_ramips
KCONFIG:= \
CONFIG_PCI_MSI=y \
CONFIG_NET_SCH_FQ=y
ifneq ($(CONFIG_MTK_WHNAT_SUPPORT),)
FILES:=$(PKG_BUILD_DIR)/mt_wifi_ap/mt_wifi.ko \
$(PKG_BUILD_DIR)/mt_wifi/embedded/plug_in/whnat/mt_whnat.ko
else
FILES:=$(PKG_BUILD_DIR)/mt_wifi_ap/mt_wifi.ko
endif
SUBMENU:=Wireless Drivers
MENU:=1
endef
define KernelPackage/mt7615d/config
source "$(SOURCE)/config.in"
endef
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" V=1 \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
M="$(PKG_BUILD_DIR)/mt_wifi_ap" \
$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_MTK_$c),CONFIG_$(c)=$(CONFIG_MTK_$(c)))) \
modules
endef
define KernelPackage/mt7615d/install
$(INSTALL_DIR) $(1)/etc/wireless/mt7615
endef
$(eval $(call KernelPackage,mt7615d))

File diff suppressed because it is too large Load Diff

View File

@ -1,821 +0,0 @@
#if defined(COMPOS_TESTMODE_WIN)
#include "config.h"
#else
#include "rt_config.h"
#endif
#if defined(RTMP_USB_SUPPORT) || defined(RTMP_PCI_SUPPORT) || \
defined(MTK_UART_SUPPORT)
INT32 ATECheckFWROMWiFiSysOn(RTMP_ADAPTER *pAd)
{
INT32 ntStatus = STATUS_SUCCESS;
UINT32 loop = 0;
UINT32 value = 0;
/* Step 1 polling 0x81021250 to 0 */
/* poll SW_SYN0 == 0 */
loop = 0;
do {
value = MtAsicGetFwSyncValue(pAd);
if (value == 0x0)
break;
os_msec_delay(1);
loop++;
} while (loop <= 500);
if (loop > 500) {
MTWF_LOG(
DBG_CAT_FW, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s: 2. SW_SYN0 is not at init. state (SW_SYN0 = %d)\n",
__func__, value));
ntStatus = STATUS_UNSUCCESSFUL;
}
/* power on WiFi SYS*/
MTWF_LOG(DBG_CAT_FW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s: 2. power on WiFi SYS\n", __func__));
ntStatus = MtCmdPowerOnWiFiSys(pAd);
if (ntStatus)
ntStatus = STATUS_UNSUCCESSFUL;
/* poll SW_SYN0 == 1*/
loop = 0;
do {
value = MtAsicGetFwSyncValue(pAd);
if (value == 0x1)
break;
os_msec_delay(1);
loop++;
} while (loop <= 500);
if (loop > 500) {
MTWF_LOG(DBG_CAT_FW, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s: SW_SYN0 is not at init. state (SW_SYN0 = %d)\n",
__func__, value));
ntStatus = STATUS_UNSUCCESSFUL;
}
return ntStatus;
}
#endif
INT32 CheckFWROMWiFiSysOn(IN RTMP_ADAPTER *pAd)
{
INT32 ntStatus = STATUS_SUCCESS;
#if defined(RTMP_USB_SUPPORT) || defined(RTMP_PCI_SUPPORT) || \
defined(MTK_UART_SUPPORT)
ntStatus = ATECheckFWROMWiFiSysOn(pAd);
#endif
return ntStatus;
}
INT32 FWSwitchToROM(IN RTMP_ADAPTER *pAd)
{
INT32 ntStatus = STATUS_SUCCESS;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s\n", __func__));
#ifdef COMPOS_TESTMODE_WIN /* Linux ready in FWRAM */
if (pAd->FWMode == FWROM)
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s: FWMode is already ROM\n", __func__));
else if (pAd->FWMode == FWRAM)
#endif
{
/* Step 1 set firmware to ROM mode */
/* ntStatus = FirmwareCommnadRestartDownloadFW(pAd); */
/* if(ntStatus != STATUS_SUCCESS) */
/* { */
/* MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,("%s, RestartDownloadFW cmd failed\n",__FUNCTION__)); */
/* } */
NICRestartFirmware(pAd);
ntStatus = CheckFWROMWiFiSysOn(pAd);
if (ntStatus != STATUS_SUCCESS)
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s, CheckFWROMWiFiSysOn failed\n",
__func__));
}
return ntStatus;
}
void LoopBack_Start(RTMP_ADAPTER *pAd, struct _LOOPBACK_SETTING *pSetting)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
/* UINT16 BreakCount = 0; */
#ifdef COMPOS_TESTMODE_WIN /* TODO::Fix the strcture */
#endif
/* UINT32 Length = 0; */
/* UINT32 RepeatIdx = 0; */
UINT32 RxQ = 1;
/* RtlCopyMemory(&pAd->LoopBackSetting, pSetting,sizeof(struct _LOOPBACK_SETTING)); */
os_move_mem(&pAd->LbCtrl.LoopBackSetting, pSetting,
sizeof(struct _LOOPBACK_SETTING));
/* RtlZeroMemory(&pAd->LoopBackTxRaw, LOOPBACK_SIZE); */
os_zero_mem(&pAd->LbCtrl.LoopBackTxRaw, LOOPBACK_SIZE);
/* RtlZeroMemory(&pAd->LoopBackRxRaw, LOOPBACK_SIZE); */
os_zero_mem(&pAd->LbCtrl.LoopBackRxRaw, LOOPBACK_SIZE);
/* RtlZeroMemory(&pAd->LoopBackResult, sizeof(struct _LOOPBACK_RESULT)); */
os_zero_mem(&pAd->LbCtrl.LoopBackResult,
sizeof(struct _LOOPBACK_RESULT));
if (pSetting->StartLen < sizeof(TMAC_TXD_L)) {
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("%s startLength(0x%x) is shorter than sizeof(TMAC_TXD_L) (0x%lx)\n",
__func__, pSetting->StartLen,
(ULONG)sizeof(TMAC_TXD_L)));
return;
}
OS_SPIN_LOCK(&pAd->LbCtrl.LoopBackLock);
pAd->LbCtrl.LoopBackWaitRx = FALSE;
OS_SPIN_UNLOCK(&pAd->LbCtrl.LoopBackLock);
pAd->LbCtrl.LoopBackRunning = TRUE;
pAd->LbCtrl.LoopBackResult.Status = RUNNING;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s\n", __func__));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("IsDefaultPattern %d\n", pSetting->IsDefaultPattern));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("RepeatTimes %u, %u\n", pSetting->RepeatTimes,
pAd->LbCtrl.LoopBackSetting.RepeatTimes));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("StartLen %d\n", pSetting->StartLen));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("StopLen %d\n", pSetting->StopLen));
pAd->LbCtrl.LoopBackDefaultPattern =
(BOOLEAN)pSetting->IsDefaultPattern;
if (pAd->LbCtrl.DebugMode) {
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("In LoopBack Debug Mode\n"));
goto ATE_LPBK_DEBUG;
}
if (!pAd->LbCtrl.LoopBackUDMA) {
ntStatus = FWSwitchToROM(pAd);
if (ntStatus != STATUS_SUCCESS)
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s, Switch to ROM failed (0x%x)\n", __func__,
ntStatus));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s FWSwitchToROM\n", __func__));
}
if (!pAd->LbCtrl.LoopBackUDMA)
MtCmdHIFLoopBackTest(pAd, 1, (UINT8)RxQ);
ATE_LPBK_DEBUG:
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("***************************************%s @#@# Rx[%d]***************************************\n",
__func__, RxQ));
/* pAd->LbCtrl.LoopBackTxThread = NULL; */
/*
* ntStatus = PsCreateSystemThread(&pAd->LbCtrl.LoopBackTxTask.hThread,
* (ACCESS_MASK) 0L,
* NULL,
* NULL,
* NULL,
* LoopBack_TxThread,
* pAd);
*/
ntStatus =
RtmpOSTaskAttach(&pAd->LbCtrl.LoopBackTxTask, LoopBack_TxThread,
(ULONG)&pAd->LbCtrl.LoopBackTxTask);
if (ntStatus != STATUS_SUCCESS)
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s, thread create fail\n", __func__));
}
void LoopBack_Stop(RTMP_ADAPTER *pAd)
{
UINT32 BreakCount = 0;
while (pAd->LbCtrl.LoopBackWaitRx == TRUE) {
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, @#@#BreakCount = %d\n", __func__, BreakCount));
if (BreakCount > 100)
break;
#ifdef COMPOS_TESTMODE_WIN
RTMPusecDelay(300);
#else
RtmpusecDelay(300);
#endif
BreakCount++;
}
if (RtmpOSTaskKill(&pAd->LbCtrl.LoopBackTxTask) == NDIS_STATUS_FAILURE)
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("kill LoopBackTxTask task failed!\n"));
if (pAd->LbCtrl.LoopBackResult.Status == RUNNING) {
pAd->LbCtrl.LoopBackResult.Status = PASS;
pAd->LbCtrl.LoopBackResult.FailReason = NO_ERROR;
}
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("***************************************%s @#@#***************************************\n",
__func__));
pAd->LbCtrl.LoopBackRunning = FALSE;
if (pAd->LbCtrl.DebugMode)
goto ATE_LB_DEBUG_STOP;
if (!pAd->LbCtrl.LoopBackUDMA)
MtCmdHIFLoopBackTest(pAd, 0, 0);
ATE_LB_DEBUG_STOP:
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s,\n", __func__));
}
void LoopBack_Status(RTMP_ADAPTER *pAd, struct _LOOPBACK_RESULT *pResult)
{
os_move_mem(pResult, &pAd->LbCtrl.LoopBackResult,
sizeof(struct _LOOPBACK_RESULT));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s\n", __func__));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, Status: %d\n", __func__,
pAd->LbCtrl.LoopBackResult.Status));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, FailReason: %d\n", __func__,
pAd->LbCtrl.LoopBackResult.FailReason));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, RxByteCount: %d\n", __func__,
pAd->LbCtrl.LoopBackResult.RxByteCount));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, RxPktCount: %d\n", __func__,
pAd->LbCtrl.LoopBackResult.RxPktCount));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, TxByteCount: %d\n", __func__,
pAd->LbCtrl.LoopBackResult.TxByteCount));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, TxPktCount: %d\n", __func__,
pAd->LbCtrl.LoopBackResult.TxPktCount));
}
void LoopBack_RawData(RTMP_ADAPTER *pAd, UINT32 *pLength, BOOLEAN IsTx,
UCHAR *RawData)
{
if (*pLength > LOOPBACK_SIZE) {
*pLength = LOOPBACK_SIZE;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, max length is %d\n", __func__, LOOPBACK_SIZE));
}
if (IsTx) {
*pLength = pAd->LbCtrl.LoopBackTxRawLen;
/* RtlCopyMemory(RawData, &pAd->LoopBackTxRaw,*pLength); */
os_move_mem(RawData, &pAd->LbCtrl.LoopBackTxRaw, *pLength);
} else {
*pLength = pAd->LbCtrl.LoopBackRxRawLen;
/* RtlCopyMemory(RawData, &pAd->LoopBackRxRaw,*pLength); */
os_move_mem(RawData, &pAd->LbCtrl.LoopBackRxRaw, *pLength);
}
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, Length = 0x%x\n", __func__, *pLength));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, LoopBackRxRawLen = 0x%x\n", __func__,
pAd->LbCtrl.LoopBackRxRawLen));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, LoopBackTxRawLen = 0x%x\n", __func__,
pAd->LbCtrl.LoopBackTxRawLen));
}
void LoopBack_ExpectRx(RTMP_ADAPTER *pAd, UINT32 Length, UINT8 *pRawData)
{
PULONG ptr;
UINT8 i = 0;
if (Length > LOOPBACK_SIZE) {
Length = LOOPBACK_SIZE;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, max length is %d\n", __func__, LOOPBACK_SIZE));
}
/* (&pAd->LbCtrl.LoopBackExpectRx, pRawData, Length); */
os_move_mem(&pAd->LbCtrl.LoopBackExpectRx, pRawData, Length);
ptr = (PULONG)(&pAd->LbCtrl.LoopBackExpectRx);
/* Length = ptr[0] & 0xffff; */
pAd->LbCtrl.LoopBackExpectRxLen = Length;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, Length = %d\n", __func__, Length));
for (i = 0; i < 20; i++)
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("TXD(TXWI) %d 0x%08lX\n", i, *(ptr + i)));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s,\n", __func__));
}
void LoopBack_ExpectTx(RTMP_ADAPTER *pAd, UINT32 Length, UINT8 *pRawData)
{
PULONG ptr;
UINT8 i = 0;
if (Length > LOOPBACK_SIZE) {
Length = LOOPBACK_SIZE;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, max length is %d\n", __func__, LOOPBACK_SIZE));
}
/* RtlCopyMemory(&pAd->LoopBackExpectTx, pRawData, Length); */
os_move_mem(&pAd->LbCtrl.LoopBackExpectTx, pRawData, Length);
ptr = (PULONG)(&pAd->LbCtrl.LoopBackExpectTx);
/* Length = ptr[0] & 0xffff; */
pAd->LbCtrl.LoopBackExpectTxLen = Length;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, Length = %d\n", __func__, Length));
for (i = 0; i < 20; i++)
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("TXD(TXWI) %d 0x%08lX\n", i, *(ptr + i)));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s,\n", __func__));
}
void LoopBack_Run(RTMP_ADAPTER *pAd, struct _LOOPBACK_SETTING *pSetting,
UINT32 Length)
{
if (Length > LOOPBACK_SIZE) {
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, LOOPBACK length too long\n", __func__));
return;
}
#ifdef _RTMP_PCI_SUPPORT
PCILoopBack_Run(pAd, pSetting, Length);
#endif
}
void LoopBack_BitTrueCheck(RTMP_ADAPTER *pAd)
{
if (!pAd->LbCtrl.LoopBackDefaultPattern) { /* Rx compare expect Rx */
if (pAd->LbCtrl.LoopBackExpectRxLen !=
pAd->LbCtrl.LoopBackRxRawLen) {
LoopBack_Fail(pAd, BIT_TRUE_FAIL);
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, ####################### TX/RX Length not equal ####################\n",
__func__));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, ExpectRxLen = %d, RxRawLen = %d\n",
__func__, pAd->LbCtrl.LoopBackExpectRxLen,
pAd->LbCtrl.LoopBackRxRawLen));
} else if (RTMPEqualMemory((PVOID)&pAd->LbCtrl.LoopBackExpectRx,
(PVOID)&pAd->LbCtrl.LoopBackRxRaw,
pAd->LbCtrl.LoopBackRxRawLen) == 0) {
if (pAd->LbCtrl.DebugMode) {
UINT32 j = 0;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_OFF,
("RxExpect Dump(%u): ",
pAd->LbCtrl.LoopBackRxRawLen));
for (j = 0; j < pAd->LbCtrl.LoopBackRxRawLen;
j++)
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_OFF,
("%02x",
pAd->LbCtrl
.LoopBackExpectRx[j]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_OFF, ("\n"));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_OFF, ("RxBackRaw Dump: "));
for (j = 0; j < pAd->LbCtrl.LoopBackRxRawLen;
j++)
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_OFF,
("%02x",
pAd->LbCtrl.LoopBackRxRaw[j]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_OFF, ("\n"));
}
LoopBack_Fail(pAd, BIT_TRUE_FAIL);
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, ####################### BIT_TRUE_FAIL ####################\n",
__func__));
} else
pAd->LbCtrl.LoopBackResult.FailReason = NO_ERROR;
} else { /* Rx compare Tx */
if (pAd->LbCtrl.LoopBackTxRawLen !=
pAd->LbCtrl.LoopBackRxRawLen) {
LoopBack_Fail(pAd, BIT_TRUE_FAIL);
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, ####################### TX/RX Length not equal ####################\n",
__func__));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, TxRawLen = %d, RxRawLen = %d\n",
__func__, pAd->LbCtrl.LoopBackTxRawLen,
pAd->LbCtrl.LoopBackRxRawLen));
} else if (RTMPEqualMemory((PVOID)&pAd->LbCtrl.LoopBackTxRaw,
(PVOID)&pAd->LbCtrl.LoopBackRxRaw,
pAd->LbCtrl.LoopBackTxRawLen) == 0) {
if (pAd->LbCtrl.DebugMode) {
UINT32 j = 0;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("TxExpect Dump(%u): ",
pAd->LbCtrl.LoopBackTxRawLen));
for (j = 0; j < pAd->LbCtrl.LoopBackRxRawLen;
j++)
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("%02x",
pAd->LbCtrl.LoopBackTxRaw[j]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_TRACE, ("\n"));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_TRACE, ("RxBackRaw Dump: "));
for (j = 0; j < pAd->LbCtrl.LoopBackRxRawLen;
j++)
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("%02x",
pAd->LbCtrl.LoopBackRxRaw[j]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_TRACE, ("\n"));
}
LoopBack_Fail(pAd, BIT_TRUE_FAIL);
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, ####################### BIT_TRUE_FAIL ####################\n",
__func__));
} else {
pAd->LbCtrl.LoopBackResult.FailReason = NO_ERROR;
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, ####################### BIT_TRUE OK ####################\n",
__func__));
}
}
}
void LoopBack_Fail(RTMP_ADAPTER *pAd, enum _LOOPBACK_FAIL FailNum)
{
if (pAd->LbCtrl.LoopBackResult.Status == RUNNING) {
pAd->LbCtrl.LoopBackResult.FailReason = FailNum;
pAd->LbCtrl.LoopBackResult.Status = FAIL;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, FailReason = %d\n", __func__, FailNum));
}
}
#ifdef COMPOS_TESTMODE_WIN
INT LoopBack_TxThread(IN OUT PVOID Context)
#else
INT LoopBack_TxThread(ULONG Context)
#endif
{
#ifdef COMPOS_TESTMODE_WIN
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)Context;
#else
RTMP_OS_TASK *pTask = (RTMP_OS_TASK *)Context;
RTMP_ADAPTER *pAd = (PRTMP_ADAPTER)RTMP_OS_TASK_DATA_GET(pTask);
#endif
struct _LOOPBACK_SETTING *pSetting = &pAd->LbCtrl.LoopBackSetting;
UINT32 RepeatIdx = 0;
UINT32 Length = 0;
UINT32 BreakCount = 0;
UINT32 DbgCount = 0;
/* KIRQL Irql; */
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, Repeat:%u\n", __func__, pSetting->RepeatTimes));
if (pSetting->RepeatTimes == 0)
pSetting->RepeatTimes = 0xffffffff;
for (RepeatIdx = 0; RepeatIdx < pSetting->RepeatTimes; RepeatIdx++) {
if (pSetting->RepeatTimes == 0xffffffff)
RepeatIdx = 0;
for (Length = pSetting->StartLen; Length <= pSetting->StopLen;
Length++) {
while (pAd->LbCtrl.LoopBackWaitRx) {
BreakCount++;
#ifdef COMPOS_TESTMODE_WIN
RTMPusecDelay(50);
#else
RtmpusecDelay(50);
#endif
if (BreakCount > 2000) {
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_ERROR,
("%s, no Rx come back Stop1!!!\n",
__func__));
break;
}
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_ERROR,
("%s, no Rx BreakCount = %d\n",
__func__, BreakCount));
}
if (BreakCount > 2000) {
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_ERROR,
("%s, no Rx come back Stop2!!!\n",
__func__));
LoopBack_Fail(pAd, RX_TIMEOUT);
break;
}
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s, Length = %d\n", __func__, Length));
BreakCount = 0;
if (pAd->LbCtrl.LoopBackRunning == FALSE ||
pAd->LbCtrl.LoopBackResult.Status != RUNNING)
break;
if (!pSetting->IsDefaultPattern)
Length = pAd->LbCtrl.LoopBackExpectTxLen;
if (pAd->LbCtrl.LoopBackResult.Status == RUNNING) {
/* KeAcquireSpinLock(&pAd->LoopBackLock, &Irql); */
OS_SPIN_LOCK(&pAd->LbCtrl.LoopBackLock);
pAd->LbCtrl.LoopBackWaitRx = TRUE;
/* KeReleaseSpinLock(&pAd->LoopBackLock, Irql); */
OS_SPIN_UNLOCK(&pAd->LbCtrl.LoopBackLock);
LoopBack_Run(pAd, pSetting, Length);
if (pAd->LbCtrl.LoopBackRunning == FALSE ||
pAd->LbCtrl.LoopBackResult.Status !=
RUNNING)
break;
}
#ifdef COMPOS_TESTMODE_WIN
RTMPusecDelay(200);
#else
RtmpusecDelay(200);
#endif
DbgCount++;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s, DbgCount = %d\n", __func__, DbgCount));
if (!pSetting->IsDefaultPattern) {
/* use script file does not need to auto increase length */
break;
}
}
if (pAd->LbCtrl.LoopBackRunning == FALSE ||
pAd->LbCtrl.LoopBackResult.Status != RUNNING)
break;
}
if (pAd->LbCtrl.LoopBackRunning)
LoopBack_Stop(pAd);
/* pAd->LbCtrl.LoopBackTxThread = NULL; */
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_INFO,
("+ + + + Control Thread Terminated + + + +\n"));
/* DecrementIoCount(pAd); */
/* PsTerminateSystemThread(STATUS_SUCCESS); */
RtmpOSTaskNotifyToExit(&pAd->LbCtrl.LoopBackTxTask);
return 0;
}
VOID LoopBack_Rx(RTMP_ADAPTER *pAd, UINT32 pktlen, UINT8 *pData)
{
if (!pAd->LbCtrl.LoopBackRunning && !pAd->LbCtrl.LoopBackWaitRx)
return;
{
UINT32 LPLength = 0;
INT32 TotalLength = (INT32)pktlen;
UINT8 *ptr = pData;
EVENT_RXD EvnRxD;
/* FwCMDRspTxD_STRUC FwCMDRspTxD; */
if (pAd->LbCtrl.DebugMode) {
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, Debug Mode, Total Len:%d\n", __func__,
TotalLength));
LPLength = pktlen;
} else {
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Driver Rx LoopBackRunning\n"));
/* os_move_mem(&FwCMDRspTxD,ptr,sizeof(FwCMDRspTxD)); */
os_move_mem(&EvnRxD, ptr, sizeof(EvnRxD));
/* LPLength = FwCMDRspTxD.FwEventTxD.u2RxByteCount; */
LPLength = EvnRxD.fw_rxd_0.field.length;
if (LPLength > LOOPBACK_SIZE) {
LPLength = LOOPBACK_SIZE;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("%s, max length is %d\n", __func__,
LOOPBACK_SIZE));
}
}
{
#ifdef COMPOS_TESTMODE_WIN /* Windows First -4 for padding bits and then add back here,Linux(?) */
if (!pAd->LbCtrl.LoopBackSetting.IsDefaultPattern)
LPLength = TotalLength + 4;
#endif
/* RtlCopyMemory(&FwCMDRspTxD,ptr,sizeof(FwCMDRspTxD)); */
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, Total Length = %d, LPLength is %d, bytecount = %d\n",
__func__, TotalLength, LPLength,
EvnRxD.fw_rxd_0.field.length));
/* LPLength = FwCMDRspTxD.FwEventTxD.u2RxByteCount; */
pAd->LbCtrl.LoopBackResult.RxByteCount += LPLength;
pAd->LbCtrl.LoopBackResult.RxPktCount++;
os_move_mem(&pAd->LbCtrl.LoopBackRxRaw, ptr, LPLength);
pAd->LbCtrl.LoopBackRxRawLen = LPLength;
}
if (pAd->LbCtrl.LoopBackUDMA == FALSE)
LoopBack_BitTrueCheck(pAd);
/* KeAcquireSpinLock(&pAdapter->LoopBackLock, &Irql); */
OS_SPIN_LOCK(&pAd->LbCtrl.LoopBackLock);
pAd->LbCtrl.LoopBackWaitRx = FALSE;
/* KeReleaseSpinLock(&pAdapter->LoopBackLock, Irql); */
OS_SPIN_UNLOCK(&pAd->LbCtrl.LoopBackLock);
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, RxPktCount = %d\n", __func__,
pAd->LbCtrl.LoopBackResult.RxPktCount));
}
}
/* currently not implement PCIE loopback */
#ifdef _RTMP_PCI_SUPPORT
void PCILoopBack_Run(RTMP_ADAPTER *pAd, struct _LOOPBACK_SETTING *pSetting,
UINT32 length)
{
UINT32 count = 0;
TMAC_TXD_L TxD;
PUCHAR ptr;
UINT8 alignment = 0;
/* UINT32 TimeOut1Second = 100; */
UCHAR *TxDataBuffer = NULL;
UINT32 *TxDataBufferLength;
UINT32 BUF_SIZE = 0;
#ifdef COMPOS_TESTMODE_WIN
TxDataBuffer = pAd->TxDataBuffer;
BUF_SIZE = BUFFER_SIZE;
TxDataBufferLength = &pAd->TxDataBufferLength;
#else
struct _ATE_CTRL *ate_ctrl = &(pAd->ATECtrl);
TxDataBuffer = pAd->ATECtrl.pate_pkt;
BUF_SIZE = ATE_TESTPKT_LEN;
TxDataBufferLength = &pAd->ATECtrl.TxLength;
#endif
/* length = 1024; */
if (pSetting->IsDefaultPattern) {
os_zero_mem(TxDataBuffer, BUF_SIZE);
os_zero_mem(&TxD, sizeof(TxD));
ptr = TxDataBuffer + sizeof(TxD);
for (count = 0; count < length - sizeof(TxD); count++)
ptr[count] = count % 16;
/* set pkt content */
TxD.TxD0.TxByteCount = length;
#ifndef MT7615
TxD.TxD0.PIdx = 1;
TxD.TxD0.QIdx = 0;
TxD.TxD1.TxDFmt = 1;
TxD.TxD1.HdrFmt = 1;
#endif
os_move_mem(TxDataBuffer, &TxD, sizeof(TxD));
os_move_mem(&pAd->LbCtrl.LoopBackTxRaw, TxDataBuffer,
LOOPBACK_SIZE);
pAd->LbCtrl.LoopBackTxRawLen = length;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, length = %d\n", __func__, length));
if (length > 32) {
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("===buffer===\n"));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("0x%x 0x%x 0x%x 0x%x\n", TxDataBuffer[3],
TxDataBuffer[2], TxDataBuffer[1],
TxDataBuffer[0]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("0x%x 0x%x 0x%x 0x%x\n", TxDataBuffer[7],
TxDataBuffer[6], TxDataBuffer[5],
TxDataBuffer[4]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("0x%x 0x%x 0x%x 0x%x\n", TxDataBuffer[11],
TxDataBuffer[10], TxDataBuffer[9],
TxDataBuffer[8]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("0x%x 0x%x 0x%x 0x%x\n", TxDataBuffer[15],
TxDataBuffer[14], TxDataBuffer[13],
TxDataBuffer[12]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("0x%x 0x%x 0x%x 0x%x\n", TxDataBuffer[19],
TxDataBuffer[18], TxDataBuffer[17],
TxDataBuffer[16]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("0x%x 0x%x 0x%x 0x%x\n", TxDataBuffer[23],
TxDataBuffer[22], TxDataBuffer[21],
TxDataBuffer[20]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("0x%x 0x%x 0x%x 0x%x\n", TxDataBuffer[27],
TxDataBuffer[26], TxDataBuffer[25],
TxDataBuffer[24]));
}
if (length % 4 != 0)
alignment = 4 - (length % 4);
if (pAd->LbCtrl.DebugMode) {
int j = 0;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Tx Dump: "));
for (j = 0; j < length; j++)
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("%02x", TxDataBuffer[j]));
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("\n"));
}
/* pAd->TxDataBufferLength = length + alignment + 4 ; */
*TxDataBufferLength = length + alignment + 4;
} else {
os_move_mem(TxDataBuffer, &pAd->LbCtrl.LoopBackExpectTx,
pAd->LbCtrl.LoopBackExpectTxLen);
os_zero_mem(TxDataBuffer + length,
pAd->LbCtrl.LoopBackExpectTxLen - length);
os_move_mem(&pAd->LbCtrl.LoopBackTxRaw, TxDataBuffer, length);
pAd->LbCtrl.LoopBackTxRawLen = pAd->LbCtrl.LoopBackExpectTxLen;
/* pAd->LoopBackExpectRxLen = length; */
}
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, LP length = %d, alignment = %d\n", __func__, length,
alignment));
pAd->LbCtrl.LoopBackResult.TxByteCount += length;
pAd->LbCtrl.LoopBackResult.TxPktCount++;
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, RxPktCount = %d\n", __func__,
pAd->LbCtrl.LoopBackResult.RxPktCount));
#ifdef COMPOS_TESTMODE_WIN
StartTx(pAd, 1, 0);
#else
ate_ctrl->TxLength = length;
MT_ATETxPkt(pAd, TESTMODE_BAND0);
#endif
/* cannot pass UINT32 TimeOut1Second = 100; to wait_event, it will not wait.. workaround use 0 (1second instead of TimeOut1Second) */
if (!pAd->LbCtrl.DebugMode)
if (RTMP_OS_WAIT_FOR_COMPLETION_TIMEOUT(
&pAd->LbCtrl.LoopBackPCITxEvent, 0) !=
STATUS_SUCCESS) {
LoopBack_Fail(pAd, TX_TIMEOUT);
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s, ####################### TX_TIMEOUT ####################3\n",
__func__));
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,96 +0,0 @@
#ifndef _LOOPBACK_H_
#define _LOOPBACK_H_
#define LOOPBACK_SIZE (10240 * 6)
enum _LOOPBACK_STATUS { RUNNING = 0, PASS, FAIL };
enum _LOOPBACK_FAIL { NO_ERROR = 0, TX_TIMEOUT, RX_TIMEOUT, BIT_TRUE_FAIL };
struct _LOOPBACK_SETTING {
UINT32 StartLen;
UINT32 StopLen;
UINT32 RepeatTimes; /* 0 = infinite */
UINT32 IsDefaultPattern;
/* #ifdef RTMP_USB_SUPPORT */
UINT32 BulkOutNumber;
UINT32 BulkInNumber;
UINT32 TxAggNumber;
UINT32 RxAggPktLmt; /* pkt numbers */
UINT32 RxAggLmt; /* pkt size */
UINT32 RxAggTO; /* timeout (us) */
UINT32 RxAggEnable;
/* #endif */
};
/* TODO:Unify */
#if !defined(COMPOS_TESTMODE_WIN)
#define MAX_TX_BULK_PIPE_NUM 6
#define MAX_RX_BULK_PIPE_NUM 2
#endif
struct _LOOPBACK_RESULT {
UINT32 Status; /* 0 running, 1 pass , 2 fail */
UINT32 FailReason; /* 0 no error, 1 TX timeout, 2 RX timeout, 3 bit true fail */
UINT32 TxPktCount;
UINT32 RxPktCount;
UINT32 TxByteCount; /* 0 = infinite */
UINT32 RxByteCount;
/* #ifdef RTMP_USB_SUPPORT */
UINT32 LastBulkOut;
/* #endif */
};
struct _LOOPBACK_CTRL {
BOOLEAN DebugMode;
BOOLEAN LoopBackRunning;
BOOLEAN LoopBackWaitRx;
struct _LOOPBACK_RESULT LoopBackResult;
struct _LOOPBACK_SETTING LoopBackSetting;
UINT8 LoopBackBulkoutNumber;
UCHAR LoopBackTxRaw[LOOPBACK_SIZE];
UCHAR LoopBackRxRaw[LOOPBACK_SIZE];
UINT32 LoopBackTxRawLen;
UINT32 LoopBackRxRawLen;
UINT32 LoopBackExpectTxLen;
UINT32 LoopBackExpectRxLen;
UCHAR LoopBackExpectTx[LOOPBACK_SIZE];
UCHAR LoopBackExpectRx[LOOPBACK_SIZE];
NDIS_SPIN_LOCK LoopBackLock;
BOOLEAN LoopBackDefaultPattern;
RTMP_OS_TASK LoopBackTxTask;
RTMP_OS_COMPLETION LoopBackEvent;
BOOLEAN LoopBackUDMA;
#ifdef RTMP_PCI_SUPPORT
RTMP_OS_COMPLETION LoopBackPCITxEvent;
#endif
};
INT32 CheckFWROMWiFiSysOn(struct _RTMP_ADAPTER *pAd);
void LoopBack_Start(struct _RTMP_ADAPTER *pAd,
struct _LOOPBACK_SETTING *pSetting);
void LoopBack_Stop(struct _RTMP_ADAPTER *pAd);
void LoopBack_Status(struct _RTMP_ADAPTER *pAd,
struct _LOOPBACK_RESULT *pResult);
void LoopBack_RawData(struct _RTMP_ADAPTER *pAd, UINT32 *pLength, BOOLEAN IsTx,
UINT8 *pRawData);
void LoopBack_ExpectRx(struct _RTMP_ADAPTER *pAd, UINT32 Length,
UINT8 *pRawData);
void LoopBack_ExpectTx(struct _RTMP_ADAPTER *pAd, UINT32 Length,
UINT8 *pRawData);
void LoopBack_Run(struct _RTMP_ADAPTER *pAd, struct _LOOPBACK_SETTING *pSetting,
UINT32 length);
void LoopBack_BitTrueCheck(struct _RTMP_ADAPTER *pAd);
void LoopBack_Fail(struct _RTMP_ADAPTER *pAd, enum _LOOPBACK_FAIL FailNum);
#ifdef COMPOS_TESTMODE_WIN /* TODO::Unify thread parameter */
INT LoopBack_TxThread(IN OUT PVOID Context);
#else
INT LoopBack_TxThread(ULONG Context);
#endif
void LoopBack_Rx(struct _RTMP_ADAPTER *pAd, UINT32 pktlen, UINT8 *pData);
#ifdef RTMP_PCI_SUPPORT
void PCILoopBack_Run(struct _RTMP_ADAPTER *pAd,
struct _LOOPBACK_SETTING *pSetting, UINT32 length);
INT32 ATECheckFWROMWiFiSysOn(struct _RTMP_ADAPTER *pAd);
#endif
#endif /* _LOOPBACK_H_ */

View File

@ -1,725 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
ate.h
*/
#ifndef __ATE_H__
#define __ATE_H__
#include "LoopBack.h"
#ifdef MT7615
#define ARBITRARY_CCK_OFDM_TX 1
#endif
#ifndef COMPOS_TESTMODE_WIN
/* #define LOGDUMP_TO_FILE 1 */
#define ATE_TXTHREAD 1
#endif
#define IOCTLBUFF 2048
#define ATE_ON(_p) ((((_p)->ATECtrl.Mode) & ATE_START) == ATE_START)
INT32 ATEInit(struct _RTMP_ADAPTER *pAd);
INT32 ATEExit(struct _RTMP_ADAPTER *pAd);
#define FREQ_OFFSET_MANUAL_ENABLE 0x81021238
#define FREQ_OFFSET_MANUAL_VALUE 0x81021234
/* For CA53 GPIO CR remap usage */
#define CA53_GPIO_REMAP_SIZE 0x10
#ifdef ARBITRARY_CCK_OFDM_TX
/* MCU PTA CR */
#define ANT_SWITCH_CON2 0x810600CC
#define ANT_SWITCH_CON3 0x810600D0
#define ANT_SWITCH_CON4 0x810600D4
#define ANT_SWITCH_CON6 0x810600DC
#define ANT_SWITCH_CON7 0x810600E0
#define ANT_SWITCH_CON8 0x810600E4
#endif
/*
* Use bitmap to allow coexist of ATE_TXFRAME
* and ATE_RXFRAME(i.e.,to support LoopBack mode).
*/
#define fATE_IDLE (1 << 0)
#define fATE_TX_ENABLE (1 << 1)
#define fATE_RX_ENABLE (1 << 2)
#define fATE_TXCONT_ENABLE (1 << 3)
#define fATE_TXCARR_ENABLE (1 << 4)
#define fATE_TXCARRSUPP_ENABLE (1 << 5)
#define fATE_MPS (1 << 6)
#define fATE_FFT_ENABLE (1 << 7)
#define fATE_EXIT (1 << 8)
#define fATE_IN_RFTEST (1 << 9)
#define fATE_IN_BF (1 << 10)
#define fATE_IN_ICAPOVERLAP (1 << 11)
/* Stop Transmission */
#define ATE_TXSTOP \
((~(fATE_TX_ENABLE)) & (~(fATE_TXCONT_ENABLE)) & \
(~(fATE_TXCARR_ENABLE)) & (~(fATE_TXCARRSUPP_ENABLE)) & \
(~(fATE_MPS)))
/* Stop Receiving Frames */
#define ATE_RXSTOP (~(fATE_RX_ENABLE))
/* Enter/Reset ATE */
#define ATE_START (fATE_IDLE)
/* Stop/Exit ATE */
#define ATE_STOP (fATE_EXIT)
/* Continuous Transmit Frames (without time gap) */
#define ATE_TXCONT ((fATE_TX_ENABLE) | (fATE_TXCONT_ENABLE))
/* Transmit Carrier */
#define ATE_TXCARR ((fATE_TX_ENABLE) | (fATE_TXCARR_ENABLE))
/* Transmit Carrier Suppression (information without carrier) */
#define ATE_TXCARRSUPP ((fATE_TX_ENABLE) | (fATE_TXCARRSUPP_ENABLE))
/* Transmit Frames */
#define ATE_TXFRAME (fATE_TX_ENABLE)
/* Receive Frames */
#define ATE_RXFRAME (fATE_RX_ENABLE)
/* MPS */
#define ATE_MPS ((fATE_TX_ENABLE) | (fATE_MPS))
#define ATE_FFT ((fATE_FFT_ENABLE) | (fATE_IN_RFTEST))
#define BULK_OUT_LOCK(pLock, IrqFlags) RTMP_IRQ_LOCK((pLock), IrqFlags)
#define BULK_OUT_UNLOCK(pLock, IrqFlags) RTMP_IRQ_UNLOCK((pLock), IrqFlags)
/* WiFi PHY mode capability */
#define PHYMODE_CAP_24G (WMODE_B | WMODE_G | WMODE_GN)
#define PHYMODE_CAP_5G (WMODE_A | WMODE_AN | WMODE_AC)
#define PHYMODE_CAP_DUAL_BAND (PHYMODE_CAP_24G | PHYMODE_CAP_5G)
/* ContiTxTone */
#define WF0_TX_ONE_TONE_5M 0x0
#define WF0_TX_TWO_TONE_5M 0x1
#define WF1_TX_ONE_TONE_5M 0x2
#define WF1_TX_TWO_TONE_5M 0x3
#define WF0_TX_ONE_TONE_10M 0x4
#define WF1_TX_ONE_TONE_10M 0x5
#define WF0_TX_ONE_TONE_DC 0x6
#define WF1_TX_ONE_TONE_DC 0x7
#define MAX_TEST_PKT_LEN 1496
#define MIN_TEST_PKT_LEN 25
#define MAX_TEST_BKCR_NUM 30
/* For packet tx time, in unit of byte */
#define MAX_HT_AMPDU_LEN 65000
#define MAX_VHT_MPDU_LEN 6700 /* 11454 */
#define DEFAULT_MPDU_LEN 4096
#define MAX_MSDU_LEN 2304
#define MIN_MSDU_LEN 22
#define DEFAULT_MAC_HDR_LEN 24
#define QOS_MAC_HDR_LEN 26
/* For ipg and duty cycle, in unit of us */
#define SIG_EXTENSION 6
#define DEFAULT_SLOT_TIME 9
#define DEFAULT_SIFS_TIME 10
#define MAX_SIFS_TIME \
127 /* ICR has 7-bit only */ /* For the ATCR/TRCR limitation 8-bit/9-bit only*/
#define MAX_AIFSN 0xF
#define MIN_AIFSN 0x1
#define MAX_CW 0x10
#define MIN_CW 0x0
#define NORMAL_CLOCK_TIME 50 /* in uint of ns */
#define BBP_PROCESSING_TIME 1500 /* in uint of ns */
/* The expected enqueue packet number in one time RX event trigger */
#define ATE_ENQUEUE_PACKET_NUM 100
#if defined(MT7615) || defined(MT7622)
#define ATE_TESTPKT_LEN 13311 /* Setting max packet length to 13311 on MT7615 */
#else
#define ATE_TESTPKT_LEN 4095 /* AMPDU delimiter 12 bit, maximum 4095 */
#endif
#define ATE_MAX_PATTERN_SIZE 128
#define TESTMODE_BAND0 0
#define TESTMODE_BAND1 1
#define ATE_BF_WCID 1
#define ATE_BFMU_NUM 4
struct _RTMP_ADAPTER;
struct _RX_BLK;
#ifdef DBDC_MODE
#define IS_ATE_DBDC(_pAd) _pAd->CommonCfg.dbdc_mode
#define TESTMODE_BAND_NUM 2
#else
#define IS_ATE_DBDC(_pAd) FALSE
#define TESTMODE_BAND_NUM 1
#endif
/* Antenna mode */
#define ANT_MODE_DEFAULT 0
#define ANT_MODE_SPE_IDX 1
#if !defined(COMPOS_TESTMODE_WIN)
/* Allow Sleep */
#define TESTMODE_SEM struct semaphore
#define TESTMODE_SEM_INIT(_psem, _val) sema_init(_psem, _val)
#define TESTMODE_SEM_DOWN(_psem) down(_psem)
#define TESTMODE_SEM_DOWN_INTERRUPTIBLE(_psem) down_interruptible(_psem)
#define TESTMODE_SEM_DOWN_TRYLOCK(_psem) down_trylock(_psem)
#define TESTMODE_SEM_UP(_psem) up(_psem)
#endif
enum _TESTMODE_MODE { HQA_VERIFY, ATE_LOOPBACK, MODE_NUM };
enum _MPS_PARAM_TYPE {
MPS_SEQDATA,
MPS_PHYMODE,
MPS_PATH,
MPS_RATE,
MPS_PAYLOAD_LEN,
MPS_TX_COUNT,
MPS_PWR_GAIN,
MPS_PARAM_NUM,
MPS_NSS,
MPS_PKT_BW,
};
struct _ATE_OPERATION {
INT32 (*ATEStart)(struct _RTMP_ADAPTER *pAd);
INT32 (*ATEStop)(struct _RTMP_ADAPTER *pAd);
INT32 (*StartTx)(struct _RTMP_ADAPTER *pAd);
INT32 (*StartRx)(struct _RTMP_ADAPTER *pAd);
INT32 (*StopTx)(struct _RTMP_ADAPTER *pAd);
INT32 (*StopRx)(struct _RTMP_ADAPTER *pAd);
INT32 (*SetTxPath)(struct _RTMP_ADAPTER *pAd);
INT32 (*SetRxPath)(struct _RTMP_ADAPTER *pAd);
INT32(*SetTxPower0)
(struct _RTMP_ADAPTER *pAd, struct _ATE_TXPOWER TxPower);
INT32(*SetTxPower1)
(struct _RTMP_ADAPTER *pAd, struct _ATE_TXPOWER TxPower);
INT32(*SetTxPower2)
(struct _RTMP_ADAPTER *pAd, struct _ATE_TXPOWER TxPower);
INT32(*SetTxPower3)
(struct _RTMP_ADAPTER *pAd, struct _ATE_TXPOWER TxPower);
INT32(*SetTxForceTxPower)
(struct _RTMP_ADAPTER *pAd, INT8 cTxPower, UINT8 ucPhyMode,
UINT8 ucTxRate, UINT8 ucBW);
INT32(*SetTxPowerX)
(struct _RTMP_ADAPTER *pAd, struct _ATE_TXPOWER TxPower);
INT32 (*SetTxAntenna)(struct _RTMP_ADAPTER *pAd, UINT32 Ant);
INT32 (*SetRxAntenna)(struct _RTMP_ADAPTER *pAd, UINT32 Ant);
INT32 (*SetTxFreqOffset)(struct _RTMP_ADAPTER *pAd, UINT32 FreqOffset);
INT32 (*GetTxFreqOffset)(struct _RTMP_ADAPTER *pAd, UINT32 *FreqOffset);
INT32(*SetChannel)
(struct _RTMP_ADAPTER *pAd, INT16 Value, UINT32 pri_sel, UINT32 reason,
UINT32 Ch_Band);
INT32(*SetBW)
(struct _RTMP_ADAPTER *pAd, UINT16 system_bw, UINT16 per_pkt_bw);
INT32 (*SetDutyCycle)(struct _RTMP_ADAPTER *pAd, UINT32 value);
INT32 (*SetPktTxTime)(struct _RTMP_ADAPTER *pAd, UINT32 value);
INT32 (*SampleRssi)(struct _RTMP_ADAPTER *pAd, struct _RX_BLK *pRxBlk);
INT32 (*SetIPG)(struct _RTMP_ADAPTER *pAd, UINT32 value);
INT32(*SetSlotTime)
(struct _RTMP_ADAPTER *pAd, UINT32 SlotTime, UINT32 SifsTime);
INT32 (*SetAIFS)(struct _RTMP_ADAPTER *pAd, CHAR Value);
INT32(*SetPowerDropLevel)
(struct _RTMP_ADAPTER *pAd, UINT32 PowerDropLevel);
INT32 (*SetTSSI)(struct _RTMP_ADAPTER *pAd, CHAR WFSel, CHAR Setting);
INT32 (*LowPower)(struct _RTMP_ADAPTER *pAd, UINT32 Control);
INT32 (*SetDPD)(struct _RTMP_ADAPTER *pAd, CHAR WFSel, CHAR Setting);
INT32 (*StartTxTone)(struct _RTMP_ADAPTER *pAd, UINT32 Mode);
INT32(*SetTxTonePower)
(struct _RTMP_ADAPTER *pAd, INT32 pwr1, INT pwr2);
INT32(*SetDBDCTxTonePower)
(struct _RTMP_ADAPTER *pAd, INT32 pwr1, INT pwr2, UINT32 AntIdx);
INT32 (*StopTxTone)(struct _RTMP_ADAPTER *pAd);
INT32(*StartContinousTx)
(struct _RTMP_ADAPTER *pAd, CHAR WFSel, UINT32 TxfdMode);
INT32 (*StopContinousTx)(struct _RTMP_ADAPTER *pAd, UINT32 TxfdMode);
INT32(*EfuseGetFreeBlock)
(struct _RTMP_ADAPTER *pAd, UINT32 GetFreeBlock, UINT32 *Value);
INT32(*EfuseAccessCheck)
(struct _RTMP_ADAPTER *pAd, UINT32 offset, PUCHAR pData);
INT32(*RfRegWrite)
(struct _RTMP_ADAPTER *pAd, UINT32 WFSel, UINT32 Offset, UINT32 Value);
INT32(*RfRegRead)
(struct _RTMP_ADAPTER *pAd, UINT32 WFSel, UINT32 Offset, UINT32 *Value);
INT32 (*GetFWInfo)(struct _RTMP_ADAPTER *pAd, UCHAR *FWInfo);
#ifdef PRE_CAL_MT7622_SUPPORT
INT32 (*TxDPDTest7622)(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
#endif /*PRE_CAL_MT7622_SUPPORT*/
#ifdef PRE_CAL_TRX_SET1_SUPPORT
INT32 (*RxSelfTest)(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 (*TxDPDTest)(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
#endif /* PRE_CAL_TRX_SET1_SUPPORT */
#ifdef PRE_CAL_TRX_SET2_SUPPORT
INT32(*PreCalTest)
(struct _RTMP_ADAPTER *pAd, UINT8 CalId, UINT32 ChGrpId);
#endif /* PRE_CAL_TRX_SET2_SUPPORT */
#if defined(CAL_BIN_FILE_SUPPORT) && defined(MT7615)
INT32 (*PATrim)(struct _RTMP_ADAPTER *pAd, PUINT32 pData);
#endif /* CAL_BIN_FILE_SUPPORT */
#if defined(TXBF_SUPPORT) && defined(MT_MAC)
INT32(*SetATETxSoundingProc)
(struct _RTMP_ADAPTER *pAd, UCHAR SoundingMode);
INT32 (*StartTxSKB)(struct _RTMP_ADAPTER *pAd);
#endif /* TXBF_SUPPORT && MT_MAC */
INT32(*MPSSetParm)
(struct _RTMP_ADAPTER *pAd, enum _MPS_PARAM_TYPE data_type, INT32 items,
UINT32 *data);
INT32 (*MPSTxStart)(struct _RTMP_ADAPTER *pAd);
INT32 (*MPSTxStop)(struct _RTMP_ADAPTER *pAd);
INT32 (*SetAutoResp)(struct _RTMP_ADAPTER *pAd, UCHAR *mac, UCHAR mode);
INT32 (*SetFFTMode)(struct _RTMP_ADAPTER *pAd, UINT32 mode);
INT32(*onOffRDD)
(struct _RTMP_ADAPTER *pAd, UINT32 rdd_num, UINT32 rdd_in_sel,
UINT32 is_start);
INT32(*SetCfgOnOff)
(struct _RTMP_ADAPTER *pAd, UINT32 Type, UINT32 Enable);
INT32(*GetCfgOnOff)
(struct _RTMP_ADAPTER *pAd, UINT32 Type, UINT32 *Result);
INT32(*SetRXFilterPktLen)
(struct _RTMP_ADAPTER *pAd, UINT32 Enable, UINT32 RxPktLen);
#ifdef TXPWRMANUAL
INT32(*SetTxPwrManual)
(struct _RTMP_ADAPTER *pAd, BOOLEAN fgPwrManCtrl,
UINT8 u1TxPwrModeManual, UINT8 u1TxPwrBwManual,
UINT8 u1TxPwrRateManual, INT8 i1TxPwrValueManual, UCHAR Band);
#endif
INT32(*DBDCTxTone)
(struct _RTMP_ADAPTER *pAd, UINT32 Control, UINT32 AntIndex,
UINT32 ToneType, UINT32 ToneFreq, INT32 DcOffset_I, INT32 DcOffset_Q,
UINT32 Band);
INT32 (*TxCWTone)(struct _RTMP_ADAPTER *pAd, UINT32 Control);
INT32(*GetTxPower)
(struct _RTMP_ADAPTER *pAd, UINT32 Enable, UINT32 Ch_Band,
UINT32 *EfuseAddr, UINT32 *Power);
INT32(*BssInfoUpdate)
(struct _RTMP_ADAPTER *pAd, UINT32 OwnMacIdx, UINT32 BssIdx,
UCHAR *Bssid);
INT32(*DevInfoUpdate)
(struct _RTMP_ADAPTER *pAd, UINT32 OwnMacIdx, UCHAR *Bssid);
INT32(*LogOnOff)
(struct _RTMP_ADAPTER *pAd, UINT32 type, UINT32 on_off, UINT32 num_log);
INT32(*SetICapStart)
(struct _RTMP_ADAPTER *pAd, BOOLEAN Trigger, BOOLEAN RingCapEn,
UINT32 Event, UINT32 Node, UINT32 Len, UINT32 StopCycle, UINT32 BW,
UINT32 MACTriggerEvent, UINT32 SourceAddrLSB, UINT32 SourceAddrMSB,
UINT32 Band);
INT32 (*GetICapStatus)(struct _RTMP_ADAPTER *pAd);
INT32(*GetICapIQData)
(struct _RTMP_ADAPTER *pAd, PINT32 pData, PINT32 pDataLen,
UINT32 IQ_Type, UINT32 WF_Num);
INT32(*SetAntennaPort)
(struct _RTMP_ADAPTER *pAd, UINT32 RfModeMask, UINT32 RfPortMask,
UINT32 AntPortMask);
INT32 (*ClockSwitchDisable)(struct _RTMP_ADAPTER *pAd, UINT8 isDisable);
};
struct _ATE_IF_OPERATION {
INT32 (*init)(struct _RTMP_ADAPTER *pAd);
INT32 (*clean_trx_q)(struct _RTMP_ADAPTER *pAd);
INT32 (*setup_frame)(struct _RTMP_ADAPTER *pAd, UINT32 q_idx);
INT32 (*test_frame_tx)(struct _RTMP_ADAPTER *pAd);
INT32 (*test_frame_rx)(struct _RTMP_ADAPTER *pAd);
INT32 (*ate_leave)(struct _RTMP_ADAPTER *pAd);
};
struct _HQA_MPS_SETTING {
UINT32 phy;
UINT32 pkt_len;
UINT32 pkt_cnt;
UINT32 pwr;
UINT32 nss;
UINT32 pkt_bw;
};
enum _TEST_BK_CR_TYPE {
TEST_EMPTY_BKCR = 0,
TEST_MAC_BKCR,
TEST_HIF_BKCR,
TEST_PHY_BKCR,
TEST_HW_BKCR,
TEST_MCU_BKCR,
TEST_BKCR_TYPE_NUM,
};
struct _TESTMODE_BK_CR {
ULONG offset;
UINT32 val;
enum _TEST_BK_CR_TYPE type;
};
struct _ATE_RXV_LOG {
RX_VECTOR1_1ST_CYCLE rxv1_1st;
RX_VECTOR1_2ND_CYCLE rxv1_2nd;
RX_VECTOR1_3TH_CYCLE rxv1_3rd;
RX_VECTOR1_4TH_CYCLE rxv1_4th;
RX_VECTOR1_5TH_CYCLE rxv1_5th;
RX_VECTOR1_6TH_CYCLE rxv1_6th;
RX_VECTOR2_1ST_CYCLE rxv2_1st;
RX_VECTOR2_2ND_CYCLE rxv2_2nd;
RX_VECTOR2_3TH_CYCLE rxv2_3rd;
};
#define ATE_RDD_LOG_SIZE 8 /* Pulse size * num of pulse = 8 * 32 for one event*/
struct _ATE_RDD_LOG {
UINT32 u4Prefix;
UINT32 u4Count;
UINT8 byPass;
UINT8 aucBuffer[ATE_RDD_LOG_SIZE];
};
#define ATE_RECAL_LOG_SIZE (CAL_ALL_LEN >> 3)
struct _ATE_LOG_RECAL {
UINT32 cal_idx;
UINT32 cal_type;
UINT32 cr_addr;
UINT32 cr_val;
};
enum {
ATE_LOG_RXV = 1,
ATE_LOG_RDD,
ATE_LOG_RE_CAL,
ATE_LOG_TYPE_NUM,
ATE_LOG_RXINFO,
ATE_LOG_TXDUMP,
ATE_LOG_TEST,
};
enum {
ATE_LOG_OFF,
ATE_LOG_ON,
ATE_LOG_DUMP,
ATE_LOG_CTRL_NUM,
};
#define fATE_LOG_RXV (1 << ATE_LOG_RXV)
#define fATE_LOG_RDD (1 << ATE_LOG_RDD)
#define fATE_LOG_RE_CAL (1 << ATE_LOG_RE_CAL)
#define fATE_LOG_RXINFO (1 << ATE_LOG_RXINFO)
#define fATE_LOG_TXDUMP (1 << ATE_LOG_TXDUMP)
#define fATE_LOG_TEST (1 << ATE_LOG_TEST)
struct _ATE_LOG_DUMP_ENTRY {
UINT32 log_type;
UINT8 un_dumped;
union {
struct _ATE_RXV_LOG rxv;
struct _ATE_RDD_LOG rdd;
struct _ATE_LOG_RECAL re_cal;
} log;
};
struct _ATE_LOG_DUMP_CB {
NDIS_SPIN_LOCK lock;
UINT8 overwritable;
UINT8 is_dumping;
UINT8 is_overwritten;
INT32 idx;
INT32 len;
UINT32 recal_curr_type;
#ifdef LOGDUMP_TO_FILE
INT32 file_idx;
RTMP_OS_FD_EXT fd;
#endif
struct _ATE_LOG_DUMP_ENTRY *entry;
};
#define ATE_MPS_ITEM_RUNNING (1 << 0)
struct _HQA_MPS_CB {
NDIS_SPIN_LOCK lock;
UINT32 mps_cnt;
UINT32 band_idx;
UINT32 stat;
BOOLEAN setting_inuse;
UINT32 ref_idx;
struct _HQA_MPS_SETTING *mps_setting;
};
struct _ATE_PFMU_INFO {
UCHAR wcid;
UCHAR bss_idx;
UCHAR up;
UCHAR addr[MAC_ADDR_LEN];
};
#define ATE_RXV_SIZE 9
#define ATE_ANT_NUM 4
struct _ATE_RX_STATISTIC {
INT32 FreqOffsetFromRx;
UINT32 RxTotalCnt[TESTMODE_BAND_NUM];
UINT32 NumOfAvgRssiSample;
UINT32 RxMacFCSErrCount;
UINT32 RxMacMdrdyCount;
UINT32 RxMacFCSErrCount_band1;
UINT32 RxMacMdrdyCount_band1;
CHAR LastSNR[ATE_ANT_NUM]; /* last received SNR */
CHAR LastRssi[ATE_ANT_NUM]; /* last received RSSI */
CHAR AvgRssi[ATE_ANT_NUM]; /* last 8 frames' average RSSI */
CHAR MaxRssi[ATE_ANT_NUM];
CHAR MinRssi[ATE_ANT_NUM];
SHORT AvgRssiX8[ATE_ANT_NUM]; /* sum of last 8 frames' RSSI */
UINT32 RSSI[ATE_ANT_NUM];
UINT32 SNR[ATE_ANT_NUM];
UINT32 RCPI[ATE_ANT_NUM];
UINT32 FAGC_RSSI_IB[ATE_ANT_NUM];
UINT32 FAGC_RSSI_WB[ATE_ANT_NUM];
#ifdef CFG_SUPPORT_MU_MIMO
UINT32 RxMacMuPktCount;
#endif
UINT32 SIG_MCS;
UINT32 SINR;
UINT32 RXVRSSI;
};
struct _ATE_TX_TIME_PARAM {
BOOLEAN pkt_tx_time_en; /* The packet transmission time feature enable or disable */
UINT32 pkt_tx_time; /* The target packet transmission time */
UINT32 pkt_tx_len;
UINT32 pkt_msdu_len;
UINT32 pkt_hdr_len;
UINT32 pkt_ampdu_cnt;
UINT8 pkt_need_qos;
UINT8 pkt_need_amsdu;
UINT8 pkt_need_ampdu;
};
struct _ATE_IPG_PARAM {
UINT32 ipg; /* The target idle time */
UINT8 sig_ext; /* Only OFDM/HT/VHT need to consider sig_ext */
UINT16 slot_time;
UINT16 sifs_time;
UINT8 ac_num; /* 0: AC_BK, 1: AC_BE, 2: AC_VI, 3: AC_VO */
UINT8 aifsn;
UINT16 cw;
UINT16 txop;
};
#ifdef DBDC_MODE
struct _BAND_INFO {
UCHAR *pate_pkt; /* Buffer for TestPkt */
PNDIS_PACKET pkt_skb;
UINT32 is_alloc_skb;
RTMP_OS_COMPLETION tx_wait;
UCHAR TxStatus; /* TxStatus : 0 --> task is idle, 1 --> task is running */
UINT32 Mode;
UINT32 TxAntennaSel;
UINT32 RxAntennaSel;
UCHAR backup_channel;
UCHAR backup_phymode;
UCHAR wdev_idx;
UCHAR wmm_idx;
USHORT QID;
UCHAR Channel;
UCHAR Ch_Band;
UCHAR ControlChl;
UCHAR PriSel;
UINT32 OutBandFreq;
UCHAR Nss;
UCHAR BW;
UCHAR PerPktBW;
UCHAR PrimaryBWSel;
UCHAR PhyMode;
UCHAR Stbc;
UCHAR Ldpc; /* 0:BCC 1:LDPC */
UCHAR Sgi;
UCHAR Mcs;
UCHAR Preamble;
UINT32 FixedPayload; /* Normal:0,Repeat:1,Random:2 */
UINT32 TxLength;
UINT32 TxCount;
UINT32 TxDoneCount; /* Tx DMA Done */
UINT32 TxedCount;
UINT32 RFFreqOffset;
UINT32 thermal_val;
UINT32 duty_cycle;
struct _ATE_TX_TIME_PARAM tx_time_param;
struct _ATE_IPG_PARAM ipg_param;
#ifdef TXBF_SUPPORT
UCHAR eTxBf;
UCHAR iTxBf;
#endif
#ifdef DOT11_VHT_AC
UCHAR Channel_2nd;
#endif
UCHAR FAGC_Path;
/* Tx frame */
UCHAR TemplateFrame[32];
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
UCHAR Addr3[MAC_ADDR_LEN];
UCHAR payload[ATE_MAX_PATTERN_SIZE];
UINT32 pl_len;
USHORT HLen; /* Header Length */
USHORT seq;
struct _HQA_MPS_CB mps_cb;
BOOLEAN fgTxPowerSKUEn; /* SKU On/Off status */
BOOLEAN fgTxPowerPercentageEn; /* Power Percentage On/Off status */
BOOLEAN fgTxPowerBFBackoffEn; /* BF Backoff On/Off status */
UINT32 PercentageLevel; /* TxPower Percentage Level */
INT32 RF_Power;
INT32 Digital_Power;
INT32 DcOffset_I;
INT32 DcOffset_Q;
};
#endif
#ifdef ATE_TXTHREAD
#define ATE_THREAD_NUM 1
struct _ATE_TXTHREAD_CB {
BOOLEAN is_init;
RTMP_OS_TASK task;
NDIS_SPIN_LOCK lock;
UINT32 tx_cnt;
UINT32 txed_cnt;
UCHAR service_stat;
};
#endif
struct _ATE_CTRL {
struct _ATE_OPERATION *ATEOp;
struct _ATE_IF_OPERATION *ATEIfOps;
enum _TESTMODE_MODE verify_mode;
struct _HQA_MPS_CB mps_cb;
UINT32 en_log;
#ifdef ATE_TXTHREAD
struct _ATE_TXTHREAD_CB tx_thread[1];
UINT32 current_init_thread;
INT32 deq_cnt;
#endif
#ifdef DBDC_MODE
struct _BAND_INFO band_ext[1];
#endif
UCHAR *pate_pkt; /* Buffer for TestPkt */
PNDIS_PACKET pkt_skb;
UINT32 is_alloc_skb;
UINT32 Mode;
CHAR TxPower0;
CHAR TxPower1;
CHAR TxPower2;
CHAR TxPower3;
UINT32 TxAntennaSel; /* band0 => TX0/TX1 , band1 => TX2/TX3 */
UINT32 RxAntennaSel;
UCHAR backup_channel; /* Backup normal driver's channel for recovering */
UCHAR backup_phymode; /* Backup normal driver's phymode for recovering */
UCHAR wdev_idx;
UCHAR wmm_idx;
USHORT QID;
UCHAR Channel;
UCHAR Ch_Band;
UCHAR ControlChl;
UCHAR PriSel;
UINT32 OutBandFreq;
UCHAR Nss;
UCHAR BW;
UCHAR PerPktBW;
UCHAR PrimaryBWSel;
UCHAR PhyMode;
UCHAR Stbc;
UCHAR Ldpc; /* 0:BCC 1:LDPC */
UCHAR Sgi;
UCHAR Mcs;
UCHAR Preamble;
UCHAR Payload; /* Payload pattern */
UINT32 FixedPayload;
UINT32 TxLength;
UINT32 TxCount;
UINT32 TxDoneCount; /* Tx DMA Done */
UINT32 TxedCount;
UINT32 RFFreqOffset;
UINT32 thermal_val;
UINT32 duty_cycle;
struct _ATE_TX_TIME_PARAM tx_time_param;
struct _ATE_IPG_PARAM ipg_param;
#ifdef TXBF_SUPPORT
BOOLEAN fgEBfEverEnabled;
BOOLEAN fgBw160;
UCHAR eTxBf;
UCHAR iTxBf;
UCHAR *txbf_info;
UINT32 txbf_info_len;
UCHAR iBFCalStatus;
#endif
#ifdef INTERNAL_CAPTURE_SUPPORT
EXT_EVENT_RBIST_ADDR_T icap_info;
#endif /* INTERNAL_CAPTURE_SUPPORT */
#ifdef DOT11_VHT_AC
UCHAR Channel_2nd;
#endif
/* Common part */
UCHAR control_band_idx; /* The band_idx which user wants to control currently */
/* Tx frame */
UCHAR *TemplateFrame;
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
UCHAR Addr3[MAC_ADDR_LEN];
UCHAR payload[ATE_MAX_PATTERN_SIZE];
UINT32 pl_len;
USHORT HLen; /* Header Length */
USHORT seq;
/* MU Related */
BOOLEAN mu_enable;
UINT32 mu_usrs;
UINT8 wcid_ref;
struct _ATE_PFMU_INFO pfmu_info[ATE_BFMU_NUM];
/* counters */
UINT32 num_rxv;
UINT32 num_rxdata;
UINT32 num_rxv_fcs;
UINT32 num_rxdata_fcs;
struct _ATE_RX_STATISTIC rx_stat;
struct _ATE_LOG_DUMP_CB log_dump[ATE_LOG_TYPE_NUM];
UCHAR FAGC_Path;
/* Flag */
BOOLEAN txs_enable;
BOOLEAN bQAEnabled; /* QA is used. */
BOOLEAN bQATxStart; /* Have compiled QA in and use it to ATE tx. */
BOOLEAN bQARxStart; /* Have compiled QA in and use it to ATE rx. */
BOOLEAN need_set_pwr; /* For MPS switch power in right context */
UCHAR TxStatus; /* TxStatus : 0 --> task is idle, 1 --> task is running */
UCHAR did_tx;
UCHAR did_rx;
UCHAR en_man_set_freq;
/* Restore CR */
struct _TESTMODE_BK_CR bk_cr[MAX_TEST_BKCR_NUM];
/* OS related */
RTMP_OS_COMPLETION tx_wait;
RTMP_OS_COMPLETION cmd_done;
ULONG cmd_expire;
#if !defined(COMPOS_TESTMODE_WIN)
RALINK_TIMER_STRUCT PeriodicTimer;
ULONG OneSecPeriodicRound;
ULONG PeriodicRound;
OS_NDIS_SPIN_LOCK TssiSemLock;
#endif
BOOLEAN fgTxPowerSKUEn; /* SKU On/Off status */
BOOLEAN fgTxPowerPercentageEn; /* Power Percentage On/Off status */
BOOLEAN fgTxPowerBFBackoffEn; /* BF Backoff On/Off status */
UINT32 PercentageLevel; /* TxPower Percentage Level */
INT32 RF_Power;
INT32 Digital_Power;
INT32 DcOffset_I;
INT32 DcOffset_Q;
};
#if !defined(COMPOS_TESTMODE_WIN)
VOID RtmpDmaEnable(RTMP_ADAPTER *pAd, INT Enable);
VOID ATE_RTUSBBulkOutDataPacket(IN PRTMP_ADAPTER pAd, IN UCHAR BulkOutPipeId);
VOID ATE_RTUSBCancelPendingBulkInIRP(IN PRTMP_ADAPTER pAd);
#endif
INT MtATESetMacTxRx(struct _RTMP_ADAPTER *pAd, INT32 TxRx, BOOLEAN Enable,
UCHAR BandIdx);
#if defined(TXBF_SUPPORT) && defined(MT_MAC)
INT SetATEApplyStaToMacTblEntry(RTMP_ADAPTER *pAd);
INT SetATEApplyStaToAsic(RTMP_ADAPTER *pAd);
#endif
#endif /* __ATE_H__ */

View File

@ -1,167 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
ate_agent.h
*/
#ifndef __ATE_AGENT_H__
#define __ATE_AGENT_H__
struct _RTMP_ADAPTER;
INT32 SetTxStop(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetRxStop(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
#ifdef DBG
VOID ATE_QA_Statistics(struct _RTMP_ADAPTER *pAd, RXWI_STRUC *pRxWI,
RXINFO_STRUC *pRxInfo, PHEADER_802_11 pHeader);
#ifdef CONFIG_QA
INT32 RtmpDoAte(struct _RTMP_ADAPTER *pAd, RTMP_IOCTL_INPUT_STRUCT *wrq,
RTMP_STRING *wrq_name);
#endif
#ifdef WCX_SUPPORT
INT32 do_meta_cmd(int ioctl_cmd, PRTMP_ADAPTER pAd,
RTMP_IOCTL_INPUT_STRUCT *WRQ, RTMP_STRING *wrq_name);
#endif
INT32 SetEERead(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetEEWrite(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetBBPRead(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetBBPWrite(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetRFWrite(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
#endif /* DBG */
VOID rt_ee_read_all(struct _RTMP_ADAPTER *pAd, UINT16 *Data);
VOID rt_ee_write_all(struct _RTMP_ADAPTER pAd, UINT16 *Data);
VOID rt_ee_write_bulk(struct _RTMP_ADAPTER pAd, UINT16 *Data, UINT16 offset,
UINT16 length);
INT32 SetATEQid(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEDeqCnt(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEMPSDump(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATEMPSPhyMode(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATEMPSRate(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATEMPSPath(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATEMPSPayloadLen(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATEMPSPktCnt(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATEMPSPwr(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATEMPSNss(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATEMPSPktBw(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATEMPSStart(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 SetATELOGEnable(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATELOGDump(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxSEnable(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATERxFilter(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATERxStream(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxStream(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEMACTRx(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATELOGDisable(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEDa(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATESa(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEBssid(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEInitChan(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetADCDump(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxPower0(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxPower1(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxPower2(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxPower3(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEForceTxPower(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxPowerEvaluation(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxAntenna(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATERxAntenna(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATERFPower(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEDigitalPower(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEDCOffset_I(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEDCOffset_Q(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 Default_Set_ATE_TX_FREQ_OFFSET_Proc(struct _RTMP_ADAPTER *pAd,
RTMP_STRING *Arg);
INT32 SetATETxFreqOffset(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 Default_Set_ATE_TX_BW_Proc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxLength(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxCount(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxMcs(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEVhtNss(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxLdpc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxStbc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxMode(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxGi(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATERxFer(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEReadRF(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATELoadE2p(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
#ifdef RTMP_EFUSE_SUPPORT
INT32 SetATELoadE2pFromBuf(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
#endif /* RTMP_EFUSE_SUPPORT */
INT32 SetATEReadE2p(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEAutoAlc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxGi(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETempSensor(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEIpg(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEPayload(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEFixedPayload(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEAssocProc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
#if defined(TXBF_SUPPORT) && defined(MT_MAC)
INT32 SetATETxBfDutInitProc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxBfGdInitProc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxPacketWithBf(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxBfChanProfileUpdate(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxBfProfileRead(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETXBFProc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxSoundingProc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEIBfGdCal(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEIBfInstCal(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEIBfProfileUpdate(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEEBfProfileConfig(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEIBfPhaseComp(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEIBfPhaseVerify(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxBfLnaGain(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxBfPhaseE2pUpdate(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEConTxETxBfGdProc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEConTxETxBfInitProc(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATESpeIdx(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEEBfTx(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEEBFCE(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEEBFCEInfo(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEEBFCEHelp(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 MT_ATEGenPkt(struct _RTMP_ADAPTER *pAd, UCHAR *buf, UINT32 band_idx);
#endif /* TXBF_SUPPORT && MT_MAC */
INT32 SetATETtr(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEShow(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEHelp(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 ATESampleRssi(struct _RTMP_ADAPTER *pAd, RXWI_STRUC *pRxWI);
VOID ATEPeriodicExec(PVOID SystemSpecific1, PVOID FunctionContext,
PVOID SystemSpecific2, PVOID SystemSpecific3);
INT32 SetATE(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEChannel(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 set_ate_duty_cycle(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 set_ate_pkt_tx_time(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 set_ate_control_band_idx(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
#ifdef MT7615
INT32 set_ate_channel_ext(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT32 set_ate_start_tx_ext(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
#endif /* MT7615 */
INT32 SetATETxBw(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 MT_ATEInit(struct _RTMP_ADAPTER *pAd);
INT32 MT_ATEExit(struct _RTMP_ADAPTER *pAd);
PNDIS_PACKET ATEPayloadInit(struct _RTMP_ADAPTER *pAd, UINT32 TxIdx);
INT32 ATEPayloadAlloc(struct _RTMP_ADAPTER *pAd, UINT32 Index);
VOID EEReadAll(struct _RTMP_ADAPTER *pAd, UINT16 *Data, UINT16 size);
VOID rtmp_ate_init(struct _RTMP_ADAPTER *pAd);
VOID RTMPCfgTssiGainFromEEPROM(struct _RTMP_ADAPTER *pAd);
#ifdef SINGLE_SKU_V2
INT32 SetATESingleSKUEn(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
#endif /* SINGLE_SKU_V2 */
INT32 SetATEBFBackoffMode(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETempCompEn(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEPowerPercentEn(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEPowerPercentCtrl(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATEBFBackoffEn(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETSSIEn(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
INT32 SetATETxPowerCtrlEn(struct _RTMP_ADAPTER *pAd, RTMP_STRING *Arg);
#endif

View File

@ -1,94 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
qa_agent.h
*/
#ifndef __META_AGENT_H__
#define __META_AGENT_H__
extern CH_FREQ_MAP CH_HZ_ID_MAP[];
extern int CH_HZ_ID_MAP_NUM;
/*
* struct for command formats
*/
struct GNU_PACKED _META_CMD_HDR {
UINT32 oid;
UINT32 len_in; /* For set */
UINT32 len_out; /* For query */
UCHAR data[2048];
};
struct GNU_PACKED _PARAM_MTK_WIFI_TEST {
UINT32 idx;
UINT32 data;
};
struct GNU_PACKED _PARAM_CUSTOM_EFUSE_RW {
UINT32 offset;
UINT32 data;
};
struct GNU_PACKED _PARAM_CUSTOM_EEPROM_RW {
UINT8 method;
UINT8 idx;
UINT8 reserved;
UINT16 data;
};
struct GNU_PACKED _PARAM_CUSTOM_MCR_RW {
UINT32 offset;
UINT32 data;
};
typedef INT32 (*META_CMD_HANDLER)(int ioctl_cmd, struct _RTMP_ADAPTER *pAd,
RTMP_IOCTL_INPUT_STRUCT *wrq,
META_CMD_HDR *cmd_hdr);
INT Set_Sdio_Bist_Write(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT Set_Sdio_Bist_Read(struct _RTMP_ADAPTER *pAd, RTMP_STRING *arg);
/*
* define for command oid
*/
#define MT_META_WIFI_TEST_TABLE_VER 0x01180000
#define OID_CUSTOM_IF_VER 0xFFA0C000
#define OID_CUSTOM_MCR_RW 0xFFA0C801
#define OID_CUSTOM_EEPROM_RW 0xFFA0C803
#define OID_CUSTOM_EFUSE_RW 0xFFA0C805
#define OID_CUSTOM_TEST_MODE 0xFFA0C901
#define OID_CUSTOM_ABORT_TEST_MODE 0xFFA0C906
#define OID_CUSTOM_MTK_WIFI_TEST 0xFFA0C911
/* NVRAM */
#define OID_CUSTOM_MTK_NVRAM_RW 0xFFA0C941
#define OID_CUSTOM_CFG_SRC_TYPE 0xFFA0C942
#define OID_CUSTOM_EEPROM_TYPE 0xFFA0C943
#define MT_META_WIFI_TEST_CMD_MASK 0x0000001F /* 32 cmd for 1 set, 0x1F=31*/
#define MT_META_WIFI_TEST_SET_MASK 0x0EFFFFFF /* 32 bits width, rest 27 bits*/
#define SLOT_TIME_SHORT 9
#define PARAM_EEPROM_READ_METHOD_READ 1
#define PARAM_EEPROM_READ_METHOD_GETSIZE 0
/*
* MACRO
*/
#define FUNC_IDX_GET_IDX(__idx, __func_idx) (__func_idx = __idx & 0x000000FF)
#define FUNC_IDX_GET_SUBFIELD(__idx, __sub) \
(__sub = ((__idx & 0xff000000) >> 24) & 0x000000ff)
/* TODO: Need to put into include/rt_os.h when merge the file */
#define MTPRIV_IOCTL_META_SET (SIOCIWFIRSTPRIV + 0x08)
#define MTPRIV_IOCTL_META_QUERY (SIOCIWFIRSTPRIV + 0x09)
#endif /* __META_AGENT_H__ */

View File

@ -1,234 +0,0 @@
#ifndef _MT_TESTMODE_H
#define _MT_TESTMODE_H
#include "mt_testmode_dmac.h"
#define TESTMODE_WCID_BAND0 2
#define TESTMODE_WCID_BAND1 3
#define ATE_SINGLE_BAND 1
#define ATE_DUAL_BAND 2
#define ATE_GBAND_TYPE 1
#define ATE_ABAND_TYPE 2
#define ATE_BAND_WIDTH_20 0
#define ATE_BAND_WIDTH_40 1
#define ATE_BAND_WIDTH_80 2
#define ATE_BAND_WIDTH_10 3
#define ATE_BAND_WIDTH_5 4
#define ATE_BAND_WIDTH_160 5
#define ATE_BAND_WIDTH_8080 6
enum {
ATE_USER_PAYLOAD,
ATE_FIXED_PAYLOAD,
ATE_RANDOM_PAYLOAD,
};
struct _ATE_DATA_RATE_MAP {
UCHAR mcs; /* MCS index */
UINT32 tx_data_rate; /* Data rate in K Bit */
};
struct _ATE_ANT_MAP {
UINT32 ant_sel;
UINT32 spe_idx;
};
struct _ATE_TXPWR_GROUP_MAP {
UINT32 start;
UINT32 end;
UINT32 group[4];
};
struct _ATE_CH_KHZ_MAP {
UINT32 Channel;
UINT32 Freq;
};
#if defined(COMPOS_TESTMODE_WIN) /* for MT_testmode.c */
#define INC_RING_INDEX(_idx, _RingSize) \
do { \
(_idx)++; \
if ((_idx) >= (_RingSize)) \
_idx = 0; \
} while (0)
#define BAND_WIDTH_20 0
#define BAND_WIDTH_40 1
#define BAND_WIDTH_80 2
#define BAND_WIDTH_160 3
#define BAND_WIDTH_10 \
4 /* 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field. */
#define BAND_WIDTH_BOTH 5 /* BW20 + BW40 */
#define BAND_WIDTH_5 6
#define BAND_WIDTH_8080 7
#define TX1_G_BAND_TARGET_PWR 0x5E
#define TX0_G_BAND_TARGET_PWR 0x58
enum {
PDMA_TX,
PDMA_RX,
PDMA_TX_RX,
};
#define TESTMODE_GET_PADDR(_pstruct, _band, _member) (&_pstruct->_member)
#define TESTMODE_GET_PARAM(_pstruct, _band, _member) (_pstruct->_member)
#define TESTMODE_SET_PARAM(_pstruct, _band, _member, _val) \
(_pstruct->_member = _val)
#ifndef COMPOS_TESTMODE_WIN /* NDIS only */
#define MAC_ADDR_LEN 6
/* 2-byte Frame control field */
struct _QAFRAME_CONTROL {
UINT16 Ver : 2;
UINT16 Type : 2;
UINT16 SubType : 4;
UINT16 ToDs : 1;
UINT16 FrDs : 1;
UINT16 MoreFrag : 1;
UINT16 Retry : 1;
UINT16 PwrMgmt : 1;
UINT16 MoreData : 1;
UINT16 Wep : 1;
UINT16 Order : 1;
};
struct _QAHEADER_802_11 {
struct _QAFRAME_CONTROL FC;
UINT16 Duration;
UCHAR Addr1[MAC_ADDR_LEN];
UCHAR Addr2[MAC_ADDR_LEN];
UCHAR Addr3[MAC_ADDR_LEN];
UINT16 Frag : 4;
UINT16 Sequence : 12;
};
#endif /* NOT COMPOS_TESTMODE_WIN */
#else
#ifdef DBDC_MODE
#define TESTMODE_GET_PARAM(_pstruct, _band, _member) \
((_band) ? _pstruct->band_ext[_band - 1]._member : _pstruct->_member)
#define TESTMODE_GET_PADDR(_pstruct, _band, _member) \
((_band) ? &_pstruct->band_ext[_band - 1]._member : &_pstruct->_member)
#define TESTMODE_SET_PARAM(_pstruct, _band, _member, _val) \
({ \
UINT32 _ret = _val; \
if (_band) { \
struct _BAND_INFO *_info = \
&(_pstruct->band_ext[_band - 1]); \
_info->_member = _val; \
} else \
_pstruct->_member = _val; \
_ret; \
})
#else
#define TESTMODE_GET_PADDR(_pstruct, _band, _member) (&_pstruct->_member)
#define TESTMODE_GET_PARAM(_pstruct, _band, _member) (_pstruct->_member)
#define TESTMODE_SET_PARAM(_pstruct, _band, _member, _val) \
({ \
UINT32 _ret = _val; \
_pstruct->_member = _val; \
_ret; \
})
#endif /* DBDC_MODE */
#endif /* defined(COMPOS_TESTMODE_WIN) */
enum _TESTMODE_STAT_TYPE {
TESTMODE_RXV,
TESTMODE_PER_PKT,
TESTMODE_RESET_CNT,
TESTMODE_COUNTER_802_11,
TESTMODE_STAT_TYPE_NUM,
};
struct _RATE_TO_BE_FIX {
UINT32 TXRate : 6;
UINT32 TXMode : 3;
UINT32 Nsts : 2;
UINT32 STBC : 1;
UINT32 Reserved : 20;
};
struct rssi_offset_eeprom {
UINT32 **rssi_eeprom_band_offset;
UINT32 *n_band_offset;
UINT32 n_band;
};
INT32 MT_ATERFTestCB(struct _RTMP_ADAPTER *pAd, UINT8 *Data, UINT32 Length);
INT32 MT_SetATEMPSDump(struct _RTMP_ADAPTER *pAd, UINT32 band_idx);
INT32 MtTestModeInit(struct _RTMP_ADAPTER *pAd);
INT32 MtTestModeExit(struct _RTMP_ADAPTER *pAd);
INT MtTestModeBkCr(struct _RTMP_ADAPTER *pAd, ULONG offset,
enum _TEST_BK_CR_TYPE type);
INT MtTestModeRestoreCr(struct _RTMP_ADAPTER *pAd, ULONG offset);
INT32 MT_ATETxControl(struct _RTMP_ADAPTER *pAd, UINT32 band_idx,
PNDIS_PACKET pkt);
VOID MT_ATEUpdateRxStatistic(struct _RTMP_ADAPTER *pAd,
enum _TESTMODE_STAT_TYPE type, VOID *data);
INT Mt_TestModeInsertPeer(struct _RTMP_ADAPTER *pAd, UINT32 band_ext, CHAR *da,
CHAR *sa, CHAR *bss);
INT32 MT_ATETxPkt(struct _RTMP_ADAPTER *pAd,
UINT32 band_idx); /* Export for Loopback */
INT MtATESetMacTxRx(struct _RTMP_ADAPTER *pAd, INT32 TxRx, BOOLEAN Enable,
UCHAR BandIdx);
INT MtATESetTxStream(struct _RTMP_ADAPTER *pAd, UINT32 StreamNums,
UCHAR BandIdx);
INT MtATESetRxPath(struct _RTMP_ADAPTER *pAd, UINT32 RxPathSel, UCHAR BandIdx);
INT MtATESetRxFilter(struct _RTMP_ADAPTER *pAd, MT_RX_FILTER_CTRL_T filter);
INT MtATESetCleanPerStaTxQueue(struct _RTMP_ADAPTER *pAd,
BOOLEAN sta_pause_enable);
INT32 MT_ATEDumpLog(struct _RTMP_ADAPTER *pAd, struct _ATE_LOG_DUMP_CB *log_cb,
UINT32 log_type);
VOID MtCmdATETestResp(struct cmd_msg *msg, char *data, UINT16 len);
INT32 MtATECh2Freq(UINT32 Channel, UINT32 band_idx);
INT32 MtATEGetTxPwrGroup(UINT32 Channel, UINT32 band_idx, UINT32 Ant_idx);
INT32 MT_ATEInsertLog(struct _RTMP_ADAPTER *pAd, UCHAR *log, UINT32 log_type,
UINT32 len);
#if !defined(COMPOS_TESTMODE_WIN) /* for MT_testmode.c */
INT MT_ATERxDoneHandle(struct _RTMP_ADAPTER *pAd, RX_BLK *pRxBlk);
#endif
INT32 MtATERSSIOffset(struct _RTMP_ADAPTER *pAd, INT32 RSSI_org,
UINT32 RSSI_idx, INT32 Ch_Band);
INT32 MtATETssiTrainingProc(struct _RTMP_ADAPTER *pAd, UCHAR ucBW,
UCHAR ucBandIdx);
#ifdef PRE_CAL_MT7622_SUPPORT
INT MtATE_DPD_Cal_Store_Proc_7622(RTMP_ADAPTER *pAd, RTMP_STRING *arg);
#endif /*PRE_CAL_MT7622_SUPPORT*/
#ifdef PRE_CAL_TRX_SET1_SUPPORT
INT MtATE_DPD_Cal_Store_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg);
INT MtATE_DCOC_Cal_Store_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg);
#endif /* PRE_CAL_TRX_SET1_SUPPORT */
#ifdef PRE_CAL_TRX_SET2_SUPPORT
INT MtATE_Pre_Cal_Proc(RTMP_ADAPTER *pAd, UINT8 CalId, UINT32 ChGrpId);
#endif /* PRE_CAL_TRX_SET2_SUPPORT */
INT32 mt_ate_tx(RTMP_ADAPTER *pAd, struct wifi_dev *wdev,
struct _TX_BLK *tx_blk);
INT TxPowerManualCtrl(PRTMP_ADAPTER pAd, BOOLEAN fgPwrManCtrl,
UINT8 u1TxPwrModeManual, UINT8 u1TxPwrBwManual,
UINT8 u1TxPwrRateManual, INT8 i1TxPwrValueManual,
UCHAR ucBandIdx);
#if defined(COMPOS_TESTMODE_WIN)
#endif
#if defined(CAL_BIN_FILE_SUPPORT) && defined(MT7615)
INT MtATE_PA_Trim_Proc(RTMP_ADAPTER *pAd, PUINT32 pData);
#endif /* CAL_BIN_FILE_SUPPORT */
#define MT_ATEInit(_pAd) \
({ \
UINT32 _ret; \
_ret = MtTestModeInit(_pAd); \
_ret; \
})
#define MT_ATEExit(_pAd) \
({ \
UINT32 _ret; \
_ret = MtTestModeExit(_pAd); \
_ret; \
})
#endif /* _MT_TESTMODE_H */

View File

@ -1,26 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
mt_testmode_dmac.h
*/
#ifndef __MT_TESTMODE_DMAC_H__
#define __MT_TESTMODE_DMAC_H__
INT mt_ate_mac_cr_restore(struct _RTMP_ADAPTER *pAd);
INT mt_ate_mac_cr_backup_and_set(struct _RTMP_ADAPTER *pAd);
INT mt_ate_ampdu_ba_limit(struct _RTMP_ADAPTER *pAd, UINT32 band_idx,
UINT8 agg_limit);
INT mt_ate_set_sta_pause_cr(struct _RTMP_ADAPTER *pAd, UINT32 band_idx);
#endif /* __MT_TESTMODE_DMAC_H__ */

View File

@ -1,23 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
mt_testmode_smac.h
*/
#ifndef __MT_TESTMODE_SMAC_H__
#define __MT_TESTMODE_SMAC_H__
INT mt_ate_mac_cr_restore(struct _RTMP_ADAPTER *pAd);
INT mt_ate_mac_cr_backup_and_set(struct _RTMP_ADAPTER *pAd);
#endif /* __MT_TESTMODE_SMAC_H__ */

View File

@ -1,81 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
qa_agent.h
*/
#ifndef __QA_AGENT_H__
#define __QA_AGENT_H__
#define HQA_CMD_MAGIC_NO 0x18142880
/* RX STAT */
#define HQA_RX_STAT_MACFCSERRCNT 0x1
#define HQA_RX_STAT_MAC_MDRDYCNT 0x2
#define HQA_RX_STAT_PHY_MDRDYCNT 0x3
#define HQA_RX_STAT_PHY_FCSERRCNT 0x4
#define HQA_RX_STAT_PD 0x5
#define HQA_RX_STAT_CCK_SIG_SFD 0x6
#define HQA_RX_STAT_OFDM_SIG_TAG 0x7
#define HQA_RX_STAT_RSSI 0x8
#define HQA_RX_RESET_PHY_COUNT 0x9
#define HQA_RX_RESET_MAC_COUNT 0xa
/* FW Event Callback */
VOID HQA_GetThermalValue_CB(struct cmd_msg *msg, char *Data, UINT16 Len);
struct GNU_PACKED _HQA_CMD_FRAME {
UINT32 MagicNo;
UINT16 Type;
UINT16 Id;
UINT16 Length;
UINT16 Sequence;
UCHAR Data[2048];
};
typedef INT32 (*HQA_CMD_HANDLER)(struct _RTMP_ADAPTER *pAd,
RTMP_IOCTL_INPUT_STRUCT *wrq,
struct GNU_PACKED _HQA_CMD_FRAME *HqaCmdFrame);
struct _HQA_CMD_TABLE {
HQA_CMD_HANDLER *CmdSet;
UINT32 CmdSetSize;
UINT32 CmdOffset;
};
struct GNU_PACKED _HQA_RX_STAT {
UINT32 mac_rx_fcs_err_cnt;
UINT32 mac_rx_mdrdy_cnt;
UINT32 phy_rx_fcs_err_cnt_cck;
UINT32 phy_rx_fcs_err_cnt_ofdm;
UINT32 phy_rx_pd_cck;
UINT32 phy_rx_pd_ofdm;
UINT32 phy_rx_sig_err_cck;
UINT32 phy_rx_sfd_err_cck;
UINT32 phy_rx_sig_err_ofdm;
UINT32 phy_rx_tag_err_ofdm;
UINT32 WB_RSSSI0;
UINT32 IB_RSSSI0;
UINT32 WB_RSSSI1;
UINT32 IB_RSSSI1;
UINT32 phy_rx_mdrdy_cnt_cck;
UINT32 phy_rx_mdrdy_cnt_ofdm;
UINT32 DriverRxCount;
UINT32 RCPI0;
UINT32 RCPI1;
UINT32 FreqOffsetFromRX;
UINT32 RSSI0;
UINT32 RSSI1;
};
#endif /* __QA_AGENT_H__ */

View File

@ -1,47 +0,0 @@
#ifndef _TESTMODE_COMMON_H
#define _TESTMODE_COMMON_H
#ifndef COMPOS_TESTMODE_WIN
enum _EPQID {
EP4QID = 0,
EP5QID,
EP6QID,
EP7QID,
EP8QID = 8,
EP9QID,
EPALLQID
};
#endif
/*test mode common*/
/* */
/* Scheduler Register 4 (offset: 0x0594, default: 0x0000_0000) */
/* Note: */
/* 1. DW : double word */
/* */
union _SCHEDULER_REGISTER4 {
struct {
/* DW0 */
ULONG ForceQid : 4;
ULONG ForceMode : 1;
ULONG BypassMode : 1;
ULONG HybridMode : 1;
ULONG RgPredictNoMask : 1;
ULONG RgResetScheduler : 1;
ULONG RgDoneClearHeader : 1;
ULONG SwMode : 1;
ULONG Reserves0 : 5;
ULONG RgRateMap : 14;
ULONG Reserves1 : 2;
} Default;
ULONG word;
};
/* MT7637 for Band display */
#define MT7367_RO_AGC_DEBUG_2 (WF_PHY_BASE + 0x0584)
#define CR_ACI_HIT (WF_PHY_BASE + 0x0594)
/* MT7637 for Band display end */
/*~test mode common*/
#endif /* _TESTMODE_COMMON_H */

View File

@ -1,531 +0,0 @@
#ifndef _TESTMODE_IOCTL_H
#define _TESTMODE_IOCTL_H
#define TM_STATUS_NOTSUPPORT 0x01
#if defined(COMPOS_TESTMODE_WIN)
#define PKTL_TRAN_TO_NET(_Val) _Val
#define PKTL_TRAN_TO_HOST(_Val) _Val
#define PKTS_TRAN_TO_NET(_Val) _Val
#define PKTS_TRAN_TO_HOST(_Val) _Val
#define PKTLA_TRAN_TO_HOST(_len, _byte_array) _byte_array
#define PKTLA_TRAN_TO_NET(_len, _byte_array) _byte_array
#define PKTLA_DUMP(_lvl, _len, _byte_arrary) _byte_array
#define PKTUC_DUMP(_lvl, _len, _byte_arrary) _byte_array
#else
#define PKTL_TRAN_TO_NET(_Val) OS_HTONL(_Val)
#define PKTL_TRAN_TO_HOST(_Val) OS_NTOHL(_Val)
#define PKTS_TRAN_TO_NET(_Val) OS_HTONS(_Val)
#define PKTS_TRAN_TO_HOST(_Val) OS_NTOHS(_Val)
#define PKTLA_TRAN_TO_HOST(_len, _byte_array) \
({ \
INT _cnt = 0; \
UINT32 *_arr = (UINT32 *)_byte_array; \
for (_cnt = 0; _cnt < _len; _cnt++) \
_arr[_cnt] = OS_NTOHL(_arr[_cnt]); \
_byte_array; \
});
#define PKTLA_TRAN_TO_NET(_len, _byte_array) \
({ \
INT _cnt = 0; \
UINT32 *_arr = (UINT32 *)_byte_array; \
for (_cnt = 0; _cnt < _len; _cnt++) \
_arr[_cnt] = OS_HTONL(_arr[_cnt]); \
_byte_array; \
});
#define PKTLA_DUMP(_lvl, _len, _byte_array) \
({ \
INT _cnt = 0; \
UINT32 *_arr = (UINT32 *)_byte_array; \
for (_cnt = 0; _cnt < _len; _cnt++) \
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, _lvl, \
("DWORD%d:%08x\n", _cnt, _arr[_cnt])); \
_len; \
});
#define PKTUC_DUMP(_lvl, _len, _byte_array) \
({ \
INT _cnt = 0; \
UCHAR *_arr = (UCHAR *)_byte_array; \
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, _lvl, \
("PKTUC_DUMP(%x): ", _len)); \
for (_cnt = 0; _cnt < _len; _cnt++) \
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, _lvl, \
("%02x", _arr[_cnt])); \
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, _lvl, ("\n")); \
_len; \
});
#endif
#if defined(COMPOS_TESTMODE_WIN)
/***********************************************************************************
* IOCTL related definitions and data structures.
**********************************************************************************/
typedef struct __RTMP_IOCTL_INPUT_STRUCT {
UINT32 InBufLen;
PVOID InBuf;
UINT32 OutBufLen;
PVOID OutBuf;
UINT32 *BytesRet;
} RTMP_IOCTL_INPUT_STRUCT;
BOOLEAN mt_mac_cr_range_mapping(struct _RTMP_ADAPTER *pAd, UINT32 *mac_addr);
UINT32 mt_physical_addr_map(UINT32 addr);
#define RTMP_IO_EFAULT 30002
#define EFAULT (-RTMP_IO_EFAULT)
#endif /* TODO: Add lack of structure for Linux temporarily, fix during merge */
VOID HQA_GetThermalValue_CB(struct cmd_msg *msg, char *Data, UINT16 Len);
#ifdef TXBF_SUPPORT
VOID HQA_BF_INFO_CB(RTMP_ADAPTER *pAd, unsigned char *data, UINT32 len);
#endif
/*
* #if defined(COMPOS_TESTMODE_WIN)
* #define OS_ENDIANSWAP(_Val) _Val;
* #else
* //#define OS_ENDIANSWAP(_Val) PKTL_TRAN_TO_HOST(_Val);
* #endif
*/
/* Common Part, TODO: Only common part after merge */
/* Structure for TxBF*/
#define HQA_BF_STR_SIZE 512
#pragma pack(1)
struct GNU_PACKED _HQA_HIFTestParam {
UINT32 start_len;
UINT32 stop_len;
UINT32 repeat_time;
UINT32 is_def_pattern;
UINT32 bulkout_num;
UINT32 bulkin_num;
UINT32 txagg_num;
UINT32 rxagg_limit;
UINT32 rxagg_lm;
UINT32 rxagg_to;
UINT32 enable_rxagg;
};
#ifdef TXBF_SUPPORT
struct GNU_PACKED _HQA_BF_TAG_ALLOC {
UINT32 col_idx0;
UINT32 row_idx0;
UINT32 col_idx1;
UINT32 row_idx1;
UINT32 col_idx2;
UINT32 row_idx2;
UINT32 col_idx3;
UINT32 row_idx3;
};
struct GNU_PACKED _HQA_BF_TAG_MATRIX {
UINT32 nrow;
UINT32 ncol;
UINT32 ngroup;
UINT32 LM;
UINT32 code_book;
UINT32 htc_exist;
};
struct GNU_PACKED _HQA_BF_TAG_SNR {
UINT32 snr_sts0;
UINT32 snr_sts1;
UINT32 snr_sts2;
UINT32 snr_sts3;
};
struct GNU_PACKED _HQA_BF_TAG_MCS_THRD {
UINT32 mcs_lss0;
UINT32 mcs_sss0;
UINT32 mcs_lss1;
UINT32 mcs_sss1;
UINT32 mcs_lss2;
UINT32 mcs_sss2;
};
struct GNU_PACKED _HQA_BF_TAG_INFO {
/* Tag 1 */
UINT32 profile; /* [6:0] : 0 ~ 63 */
UINT32 tx_bf; /* [7] : 0: iBF, 1: eBF */
UINT32 dbw; /* [9:8] : 0/1/2/3: DW20/40/80/160NC */
UINT32 su_mu; /* [10] : 0:SU, 1: MU */
UINT32 invalid; /* [11] : 0:default, 1: This profile number is invalid by SW */
UINT32 rmsd; /* [14:12] : RMSD value from CE */
UINT32 addr1_col_idx; /* [17 : 15] : column index : 0 ~ 5 */
UINT32 addr1_row_idx; /* [23 : 18] : row index : 0 ~ 63 */
UINT32 addr2_col_idx; /* [26 : 24] : column index : 0 ~ 5 */
UINT32 addr2_row_idx; /* [31 : 27] : row index : 0 ~ 63, [32]: MSB of row index */
UINT32 addr3_col_idx; /* [35 : 33] : column index : 0 ~ 5 */
UINT32 addr3_row_idx; /* [41 : 36] : row index : 0 ~ 63 */
UINT32 addr4_col_idx; /* [44 : 42] : column index : 0 ~ 5 */
UINT32 addr4_row_idx; /* [50 : 45] : row index : 0 ~ 63 */
UINT32 reserved1; /* [51] : Reserved */
UINT32 nrow; /* [53 : 52] : Nrow */
UINT32 ncol; /* [55 : 54] : Ncol */
UINT32 ngroup; /* [57 : 56] : Ngroup */
UINT32 LM; /* [59 : 58] : 0/1/2 */
UINT32 code_book; /* [61:60] : Code book */
UINT32 htc_exist; /* [62] : HtcExist */
UINT32 reserved2; /* [63] : Reserved */
UINT32 snr_sts0; /* [71:64] : SNR_STS0 */
UINT32 snr_sts1; /* [79:72] : SNR_STS1 */
UINT32 snr_sts2; /* [87:80] : SNR_STS2 */
UINT32 snr_sts3; /* [95:88] : SNR_STS3 */
UINT32 ibf_lanidx; /* [103:96] : iBF LNA index */
/* Tag 2 */
UINT32 smt_ant; /* [11:0] : Smart Ant config */
UINT32 reserved3; /* [14:12] : Reserved */
UINT32 se_idx; /* [19:15] : SE index */
UINT32 rmsd_thrd; /* [22:20] : RMSD Threshold */
UINT32 reserved4; /* [23] : Reserved */
UINT32 mcs_thrd_l1ss; /* [27:24] : MCS TH long 1SS */
UINT32 mcs_thrd_s1ss; /* [31:28] : MCS TH short 1SS */
UINT32 mcs_thrd_l2ss; /* [35:32] : MCS TH long 2SS */
UINT32 mcs_thrd_s2ss; /* [39:36] : MCS TH short 2SS */
UINT32 mcs_thrd_l3ss; /* [43:40] : MCS TH long 3SS */
UINT32 mcs_thrd_s3ss; /* [47:44] : MCS TH short 3SS */
UINT32 bf_tout; /* [55:48] : iBF timeout limit */
UINT32 reserved5; /* [63:56] : Reserved */
UINT32 reserved6; /* [71:64] : Reserved */
UINT32 reserved7; /* [79:72] : Reserved */
UINT32 ibf_dbw; /* [81:80] : iBF desired DBW 0/1/2/3 : BW20/40/80/160NC */
UINT32 ibf_ncol; /* [83:82] : iBF desired Ncol = 1 ~ 3 */
UINT32 ibf_nrow; /* [85:84] : iBF desired Nrow = 1 ~ 4 */
UINT32 reserved8; /* [95:86] : Reserved */
};
struct GNU_PACKED _HQA_BF_STA_CMM_REC {
UINT32 wlan_idx;
UINT32 bss_idx;
UINT32 aid;
UCHAR mac[MAC_ADDR_LEN];
};
enum _HQA_BF_CMD_ID {
ATE_TXBF_INIT = 1,
ATE_CHANNEL,
ATE_TX_MCS,
ATE_TX_POW0,
ATE_TX_ANT,
ATE_RX_FRAME,
ATE_RX_ANT,
ATE_TXBF_LNA_GAIN,
ATE_IBF_PHASE_COMP,
ATE_IBF_TX,
ATE_IBF_PROF_UPDATE,
ATE_EBF_PROF_UPDATE,
ATE_IBF_INST_CAL,
ATE_IBF_INST_VERIFY,
ATE_TXBF_GD_INIT,
ATE_IBF_PHASE_E2P_UPDATE
};
struct GNU_PACKED _HQA_BF_STA_REC {
UINT32 wlan_idx;
UINT32 bss_idx;
UINT32 PfmuId;
UINT32 su_mu;
UINT32 etxbf_cap;
UINT32 ndpa_rate;
UINT32 ndp_rate;
UINT32 report_poll_rate;
UINT32 tx_mode;
UINT32 nc;
UINT32 nr;
UINT32 cbw;
UINT32 spe_idx;
UINT32 tot_mem_req;
UINT32 mem_req_20m;
UINT32 mem_row0;
UINT32 mem_col0;
UINT32 mem_row1;
UINT32 mem_col1;
UINT32 mem_row2;
UINT32 mem_col2;
UINT32 mem_row3;
UINT32 mem_col3;
};
struct GNU_PACKED _HQA_BF_STA_PROFILE {
UINT32 pfmuid;
UINT32 subcarrier;
UINT32 phi11;
UINT32 psi21;
UINT32 phi21;
UINT32 psi31;
UINT32 phi31;
UINT32 psi41;
UINT32 phi22;
UINT32 psi32;
UINT32 phi32;
UINT32 psi42;
UINT32 phi33;
UINT32 psi43;
UINT32 snr00;
UINT32 snr01;
UINT32 snr02;
UINT32 snr03;
};
struct GNU_PACKED _HQA_BF_SOUNDING {
UINT32 su_mu;
UINT32 mu_num;
UINT32 snd_interval;
UINT32 wlan_id0;
UINT32 wlan_id1;
UINT32 wlan_id2;
UINT32 wlan_id3;
UINT32 band_idx;
};
struct GNU_PACKED _HQA_BF_MANUAL_CONN {
UCHAR mac[MAC_ADDR_LEN];
UINT32 type;
UINT32 wtbl_idx;
UINT32 ownmac_idx;
UINT32 phymode;
UINT32 bw;
UINT32 pfmuid;
UINT32 marate_mode;
UINT32 marate_mcs;
UINT32 nss;
UINT32 spe_idx;
UINT32 rca2;
UINT32 rv;
UINT32 aid;
};
struct GNU_PACKED _HQA_PWR_MANUAL {
UINT32 u4PwrManCtrl;
UINT32 u4TxPwrModeManual;
UINT32 u4TxPwrBwManual;
UINT32 u4TxPwrRateManual;
UINT32 i4TxPwrValueManual;
UINT32 u4Band;
};
#ifdef CFG_SUPPORT_MU_MIMO
/* Structure for MU-MIMO */
struct _HQA_MU_STA_PARAM {
UINT32 gid[2];
UINT32 up[4];
};
struct _HQA_MU_TBL {
UINT32 su_mu;
UCHAR tbl[0];
};
struct GNU_PACKED _HQA_MU_USR_INIT_MCS {
UINT32 user0;
UINT32 user1;
UINT32 user2;
UINT32 user3;
};
struct GNU_PACKED _HQA_MU_USR_LQ {
UINT32 usr0_bpsk;
UINT32 usr0_qpsk;
UINT32 usr0_16qam;
UINT32 usr0_64qam;
UINT32 usr0_256qam;
UINT32 usr1_bpsk;
UINT32 usr1_qpsk;
UINT32 usr1_16qam;
UINT32 usr1_64qam;
UINT32 usr1_256qam;
UINT32 usr2_bpsk;
UINT32 usr2_qpsk;
UINT32 usr2_16qam;
UINT32 usr2_64qam;
UINT32 usr2_256qam;
UINT32 usr3_bpsk;
UINT32 usr3_qpsk;
UINT32 usr3_16qam;
UINT32 usr3_64qam;
UINT32 usr3_256qam;
};
struct GNU_PACKED _HQA_MU_GRP_INFO {
UINT32 grp_idx;
UINT32 num_usr;
UINT32 usr0_ldpc;
UINT32 usr1_ldpc;
UINT32 usr2_ldpc;
UINT32 usr3_ldpc;
UINT32 usr0_nss;
UINT32 usr1_nss;
UINT32 usr2_nss;
UINT32 usr3_nss;
UINT32 gid;
UINT32 usr0_up;
UINT32 usr1_up;
UINT32 usr2_up;
UINT32 usr3_up;
UINT32 usr0_pfmu_id;
UINT32 usr1_pfmu_id;
UINT32 usr2_pfmu_id;
UINT32 usr3_pfmu_id;
UINT32 initMCS0;
UINT32 initMCS1;
UINT32 initMCS2;
UINT32 initMCS3;
UCHAR usr0_mac[MAC_ADDR_LEN];
UCHAR usr1_mac[MAC_ADDR_LEN];
UCHAR usr2_mac[MAC_ADDR_LEN];
UCHAR usr3_mac[MAC_ADDR_LEN];
};
#endif /* CFG_SUPPORT_MU_MIMO */
#endif /* TXBF_SUPPORT */
#pragma pack()
/* DBDC Tx Ext */
#pragma pack(1)
struct GNU_PACKED _HQA_EXT_SET_CH {
UINT32 ext_id;
UINT32 num_param;
UINT32 band_idx;
UINT32 central_ch0;
UINT32 central_ch1;
UINT32 sys_bw;
UINT32 perpkt_bw;
UINT32 pri_sel;
UINT32 reason;
UINT32 ch_band;
UINT32 out_band_freq;
};
struct GNU_PACKED _HQA_EXT_TX_CONTENT {
UINT32 ext_id;
UINT32 num_param;
UINT32 band_idx;
UINT32 FC;
UINT32 dur;
UINT32 seq;
UINT32 gen_payload_rule; /* Normal:0,Repeat:1,Random:2 */
UINT32 txlen;
UINT32 payload_len;
UCHAR addr1[MAC_ADDR_LEN];
UCHAR addr2[MAC_ADDR_LEN];
UCHAR addr3[MAC_ADDR_LEN];
UCHAR payload[0];
};
struct GNU_PACKED _HQA_EXT_TXV {
UINT32 ext_id;
UINT32 num_param;
UINT32 band_idx;
UINT32 pkt_cnt;
UINT32 phymode;
UINT32 rate;
UINT32 pwr;
UINT32 stbc;
UINT32 ldpc;
UINT32 ibf;
UINT32 ebf;
UINT32 wlan_id;
UINT32 aifs;
UINT32 gi;
UINT32 tx_path;
UINT32 nss;
};
struct GNU_PACKED _HQA_CMD_FRAME {
UINT32 MagicNo;
UINT16 Type;
UINT16 Id;
UINT16 Length;
UINT16 Sequence;
UINT8 Data[IOCTLBUFF];
};
#pragma pack()
typedef INT32 (*HQA_CMD_HANDLER)(struct _RTMP_ADAPTER *pAd,
struct __RTMP_IOCTL_INPUT_STRUCT *wrq,
struct _HQA_CMD_FRAME *HqaCmdFrame);
struct _HQA_CMD_TABLE {
HQA_CMD_HANDLER *CmdSet;
UINT32 CmdSetSize;
UINT32 CmdOffset;
};
struct GNU_PACKED _HQA_RX_STAT {
UINT32 mac_rx_fcs_err_cnt;
UINT32 mac_rx_mdrdy_cnt;
UINT32 phy_rx_fcs_err_cnt_cck;
UINT32 phy_rx_fcs_err_cnt_ofdm;
UINT32 phy_rx_pd_cck;
UINT32 phy_rx_pd_ofdm;
UINT32 phy_rx_sig_err_cck;
UINT32 phy_rx_sfd_err_cck;
UINT32 phy_rx_sig_err_ofdm;
UINT32 phy_rx_tag_err_ofdm;
UINT32 WB_RSSSI0;
UINT32 IB_RSSSI0;
UINT32 WB_RSSSI1;
UINT32 IB_RSSSI1;
UINT32 phy_rx_mdrdy_cnt_cck;
UINT32 phy_rx_mdrdy_cnt_ofdm;
UINT32 DriverRxCount;
UINT32 RCPI0;
UINT32 RCPI1;
INT32 FreqOffsetFromRX;
UINT32 RSSI0;
UINT32 RSSI1;
UINT32 rx_fifo_full;
/* #ifdef MT7615 */
UINT32 mac_rx_len_mismatch;
UINT32 mac_rx_fcs_err_cnt_band1;
UINT32 mac_rx_mdrdy_cnt_band1;
UINT32 FAGC_IB_RSSSI[4];
UINT32 FAGC_WB_RSSSI[4];
UINT32 Inst_IB_RSSSI[4];
UINT32 Inst_WB_RSSSI[4];
UINT32 ACIHitLow;
UINT32 ACIHitHigh;
UINT32 DriverRxCount1;
UINT32 RCPI2;
UINT32 RCPI3;
UINT32 RSSI2;
UINT32 RSSI3;
UINT32 SNR0;
UINT32 SNR1;
UINT32 SNR2;
UINT32 SNR3;
UINT32 rx_fifo_full_band1;
UINT32 mac_rx_len_mismatch_band1;
UINT32 phy_rx_pd_cck_band1;
UINT32 phy_rx_pd_ofdm_band1;
UINT32 phy_rx_sig_err_cck_band1;
UINT32 phy_rx_sfd_err_cck_band1;
UINT32 phy_rx_sig_err_ofdm_band1;
UINT32 phy_rx_tag_err_ofdm_band1;
UINT32 phy_rx_mdrdy_cnt_cck_band1;
UINT32 phy_rx_mdrdy_cnt_ofdm_band1;
UINT32 phy_rx_fcs_err_cnt_cck_band1;
UINT32 phy_rx_fcs_err_cnt_ofdm_band1;
UINT32 MuPktCount;
UINT32 SIG_MCS;
UINT32 SINR;
UINT32 RXVRSSI;
/* #endif */
UINT32 mac_rx_fcs_ok_cnt; /* MT7622 only */
};
UINT32 HQA_CMDHandler(struct _RTMP_ADAPTER *pAd,
struct __RTMP_IOCTL_INPUT_STRUCT *Wrq,
struct _HQA_CMD_FRAME *HqaCmdFrame);
#define TM_CMDREQ 0x0008
#define TM_CMDRSP 0x8008
#define HQA_CMD_MAGIC_NO 0x18142880
#define HQA_CMD_REQ 0x0005
#define HQA_CMD_RSP 0x8005
#define TMR_HW_VER_100 100
#define TMR_HW_VER_150 150
#define TMR_HW_VER_200 200
#define HQA_CMD_MAGIC_NO 0x18142880
#define EFUSE_ADDR_FREQUENCY_OFFSET_MT7637 0xF4 /* MT7637 */
#endif /* _TESTMODE_IOCTL_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,213 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
mt_testmode_dmac.c
*/
#ifdef COMPOS_TESTMODE_WIN
#include "config.h"
#else
#include "rt_config.h"
#endif
INT mt_ate_mac_cr_restore(RTMP_ADAPTER *pAd)
{
#if defined(MT7615) || defined(MT7622)
if (IS_MT7615(pAd) || IS_MT7622(pAd)) {
/* Data frame protection CR recover */
MtTestModeRestoreCr(pAd, AGG_PCR);
/* RTS threshold CR recover */
MtTestModeRestoreCr(pAd, AGG_PCR1);
#ifdef DBDC_MODE
if (IS_ATE_DBDC(pAd)) {
MtTestModeRestoreCr(pAd, AGG_PCR2);
}
#endif /* DBDC_MODE */
/* BA related CR recover */
MtTestModeRestoreCr(pAd, AGG_AALCR0);
MtTestModeRestoreCr(pAd, AGG_AALCR1);
MtTestModeRestoreCr(pAd, AGG_AALCR2);
MtTestModeRestoreCr(pAd, AGG_AALCR3);
MtTestModeRestoreCr(pAd, AGG_AWSCR0);
MtTestModeRestoreCr(pAd, AGG_AWSCR1);
/* Station pause CR recover */
MtTestModeRestoreCr(pAd, STATION_PAUSE0);
MtTestModeRestoreCr(pAd, STATION_PAUSE1);
MtTestModeRestoreCr(pAd, STATION_PAUSE2);
MtTestModeRestoreCr(pAd, STATION_PAUSE3);
/* Enable HW BAR feature */
MtTestModeRestoreCr(pAd, AGG_MRCR);
/* IPG related CR recover */
MtTestModeRestoreCr(pAd, TMAC_TRCR0);
MtTestModeRestoreCr(pAd, TMAC_ICR_BAND_0);
MtTestModeRestoreCr(pAd, ARB_DRNGR0);
MtTestModeRestoreCr(pAd, ARB_DRNGR1);
MtTestModeRestoreCr(pAd, ARB_WMMAC01);
MtTestModeRestoreCr(pAd, ARB_WMMAC11);
MtTestModeRestoreCr(pAd, ARB_WMMAC21);
MtTestModeRestoreCr(pAd, ARB_WMMAC31);
MtTestModeRestoreCr(pAd, ARB_WMMALTX0);
#ifdef DBDC_MODE
if (IS_ATE_DBDC(pAd)) {
MtTestModeRestoreCr(pAd, TMAC_TRCR1);
MtTestModeRestoreCr(pAd, TMAC_ICR_BAND_1);
MtTestModeRestoreCr(pAd, ARB_WMMALTX1);
}
#endif /* DBDC_MODE */
}
#endif /* defined(MT7615) || defined(MT7622) */
return 0;
}
INT mt_ate_mac_cr_backup_and_set(RTMP_ADAPTER *pAd)
{
struct _ATE_CTRL *ATECtrl = &pAd->ATECtrl;
NdisZeroMemory(&ATECtrl->bk_cr,
sizeof(struct _TESTMODE_BK_CR) * MAX_TEST_BKCR_NUM);
#if defined(MT7615) || defined(MT7622)
/* TODO: check if following operation also need to do for other chips */
if (IS_MT7615(pAd) || IS_MT7622(pAd)) {
UINT32 val = 0;
/* Enable data frame protection for test mode */
MtTestModeBkCr(pAd, AGG_PCR, TEST_MAC_BKCR);
MAC_IO_READ32(pAd, AGG_PCR, &val);
val = 0x80008;
MAC_IO_WRITE32(pAd, AGG_PCR, val);
/* RTS threshold need to change to 1 for test mode */
MtTestModeBkCr(pAd, AGG_PCR1, TEST_MAC_BKCR);
MAC_IO_READ32(pAd, AGG_PCR1, &val);
/* val &= 0x0FFFFFFF; */
/* val |= 0x10000000; */
/* Setting RTS threshold to max value to aviod send RTS in test mode */
val = 0xFE0FFFFF;
MAC_IO_WRITE32(pAd, AGG_PCR1, val);
#ifdef DBDC_MODE
/* RTS threshold disable for band1 */
if (IS_ATE_DBDC(pAd)) {
MtTestModeBkCr(pAd, AGG_PCR2, TEST_MAC_BKCR);
MAC_IO_READ32(pAd, AGG_PCR2, &val);
val = 0xFE0FFFFF;
MAC_IO_WRITE32(pAd, AGG_PCR2, val);
}
#endif /* DBDC_MODE */
/* BA related CR backup */
MtTestModeBkCr(pAd, AGG_AALCR0, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, AGG_AALCR1, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, AGG_AALCR2, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, AGG_AALCR3, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, AGG_AWSCR0, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, AGG_AWSCR1, TEST_MAC_BKCR);
/* Station pause CR backup for TX after reset WTBL */
MtTestModeBkCr(pAd, STATION_PAUSE0, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, STATION_PAUSE1, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, STATION_PAUSE2, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, STATION_PAUSE3, TEST_MAC_BKCR);
/* HW BAR feature */
MtTestModeBkCr(pAd, AGG_MRCR, TEST_MAC_BKCR);
MAC_IO_READ32(pAd, AGG_MRCR, &val);
val &= ~BAR_TX_CNT_LIMIT_MASK;
val |= BAR_TX_CNT_LIMIT(0);
MAC_IO_WRITE32(pAd, AGG_MRCR, val);
/* IPG related CR back up */
MtTestModeBkCr(pAd, TMAC_TRCR0, TEST_MAC_BKCR);
MtTestModeBkCr(
pAd, TMAC_ICR_BAND_0,
TEST_MAC_BKCR); /* IFS CR, for SIFS/SLOT time control */
MtTestModeBkCr(
pAd, ARB_DRNGR0,
TEST_MAC_BKCR); /* For fixing backoff random number */
MtTestModeBkCr(pAd, ARB_DRNGR1, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, ARB_WMMAC01, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, ARB_WMMAC11, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, ARB_WMMAC21, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, ARB_WMMAC31, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, ARB_WMMALTX0, TEST_MAC_BKCR);
#ifdef DBDC_MODE
if (IS_ATE_DBDC(pAd)) {
MtTestModeBkCr(pAd, TMAC_TRCR1, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, TMAC_ICR_BAND_1, TEST_MAC_BKCR);
MtTestModeBkCr(pAd, ARB_WMMALTX1, TEST_MAC_BKCR);
}
#endif /* DBDC_MODE */
}
#endif /* defined(MT7615) || defined(MT7622) */
return 0;
}
UINT32 agg_cnt_array[] = { AGG_AALCR0, AGG_AALCR1, AGG_AALCR2, AGG_AALCR3 };
INT mt_ate_ampdu_ba_limit(RTMP_ADAPTER *pAd, UINT32 band_idx, UINT8 agg_limit)
{
struct _ATE_CTRL *ATECtrl = &pAd->ATECtrl;
UINT32 value;
INT wdev_idx = 0;
UCHAR WmmIdx = 0xFF;
#if !defined(COMPOS_TESTMODE_WIN)
struct wifi_dev *pWdev = NULL;
wdev_idx = TESTMODE_GET_PARAM(ATECtrl, band_idx, wdev_idx);
pWdev = pAd->wdev_list[wdev_idx];
if (pWdev) {
WmmIdx = TESTMODE_GET_PARAM(ATECtrl, band_idx, wmm_idx);
if (WmmIdx > 3) {
MTWF_LOG(
DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s: wdev_idx=%d, invalid WmmIdx=%d, reset to 0!\n",
__func__, wdev_idx, WmmIdx));
WmmIdx = 0xFF;
}
} else {
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s: invalid WDEV, reset WmmIdx to 0!\n", __func__));
WmmIdx = 0xFF;
}
#endif
MTWF_LOG(DBG_CAT_TEST, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s: wdev_idx=%d, WmmIdx=%d\n", __func__, wdev_idx, WmmIdx));
value = ((agg_limit & 0x3F) << 24) | ((agg_limit & 0x3F) << 16) |
((agg_limit & 0x3F) << 8) | ((agg_limit & 0x3F) << 0);
if (WmmIdx <= 3)
MAC_IO_WRITE32(pAd, agg_cnt_array[WmmIdx], value);
else {
MAC_IO_WRITE32(pAd, AGG_AALCR0, value);
MAC_IO_WRITE32(pAd, AGG_AALCR1, value);
MAC_IO_WRITE32(pAd, AGG_AALCR2, value);
MAC_IO_WRITE32(pAd, AGG_AALCR3, value);
}
value = 0x0;
MAC_IO_WRITE32(pAd, AGG_AWSCR0, value);
return 0;
}
INT mt_ate_set_sta_pause_cr(RTMP_ADAPTER *pAd, UINT32 band_idx)
{
INT32 ret = 0;
UINT32 value;
/* Set station pause CRs to 0 for TX after reset WTBL */
/* The CR meaning in normal mode is that stop to TX packet when STA disconnect */
value = 0x0;
MAC_IO_WRITE32(pAd, STATION_PAUSE0, value);
MAC_IO_WRITE32(pAd, STATION_PAUSE1, value);
MAC_IO_WRITE32(pAd, STATION_PAUSE2, value);
MAC_IO_WRITE32(pAd, STATION_PAUSE3, value);
return ret;
}

View File

@ -1,55 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
mt_testmode_smac.c
*/
#ifdef COMPOS_TESTMODE_WIN
#include "config.h"
#else
#include "rt_config.h"
#endif
INT mt_ate_mac_cr_restore(RTMP_ADAPTER *pAd)
{
/* Data frame protection CR recover */
MtTestModeRestoreCr(pAd, AGG_PCR);
/* RTS threshold CR recover */
MtTestModeRestoreCr(pAd, AGG_PCR1);
return 0;
}
INT mt_ate_mac_cr_backup_and_set(RTMP_ADAPTER *pAd)
{
struct _ATE_CTRL *ATECtrl = &pAd->ATECtrl;
UINT32 val = 0;
NdisZeroMemory(&ATECtrl->bk_cr,
sizeof(struct _TESTMODE_BK_CR) * MAX_TEST_BKCR_NUM);
/* Enable data frame protection for test mode */
MtTestModeBkCr(pAd, AGG_PCR, TEST_MAC_BKCR);
MAC_IO_READ32(pAd, AGG_PCR, &val);
val = 0x80008;
MAC_IO_WRITE32(pAd, AGG_PCR, val);
/* RTS threshold need to change to 1 for test mode */
MtTestModeBkCr(pAd, AGG_PCR1, TEST_MAC_BKCR);
MAC_IO_READ32(pAd, AGG_PCR1, &val);
/* val &= 0x0FFFFFFF; */
/* val |= 0x10000000; */
/* Setting RTS threshold to max value to aviod send RTS in test mode */
val = 0xFE0FFFFF;
MAC_IO_WRITE32(pAd, AGG_PCR1, val);
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,252 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002-2004, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
rt_chip.c
Abstract:
Ralink Wireless driver CHIP related functions
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#include "rt_config.h"
/*
========================================================================
Routine Description:
write high memory.
if firmware do not support auto high/low memory switching, we should switch to high memory by ourself.
Arguments:
pAd - WLAN control block pointer
Offset - Memory offsets
Value - Written value
Unit - Unit in "Byte"
Return Value:
None
Note:
========================================================================
*/
VOID RtmpChipWriteHighMemory(IN RTMP_ADAPTER *pAd, IN USHORT Offset,
IN UINT32 Value, IN UINT8 Unit)
{
}
/*
========================================================================
Routine Description:
write memory
Arguments:
pAd - WLAN control block pointer
Offset - Memory offsets
Value - Written value
Unit - Unit in "Byte"
Return Value:
None
Note:
========================================================================
*/
VOID RtmpChipWriteMemory(IN RTMP_ADAPTER *pAd, IN USHORT Offset,
IN UINT32 Value, IN UINT8 Unit)
{
switch (Unit) {
case 1:
RTMP_IO_WRITE8(pAd, Offset, Value);
break;
case 2:
RTMP_IO_WRITE16(pAd, Offset, Value);
break;
case 4:
RTMP_IO_WRITE32(pAd, Offset, Value);
default:
break;
}
}
/*
========================================================================
Routine Description:
Initialize normal beacon frame architecture.
Arguments:
pAd - WLAN control block pointer
Return Value:
None
Note:
========================================================================
*/
VOID RtmpChipBcnInit(IN RTMP_ADAPTER *pAd)
{
RTMP_CHIP_CAP *pChipCap = hc_get_chip_cap(pAd->hdev_ctrl);
struct _RTMP_CHIP_OP *ops = hc_get_chip_ops(pAd->hdev_ctrl);
pChipCap->FlgIsSupSpecBcnBuf = FALSE;
pChipCap->BcnMaxHwNum = 8;
pChipCap->BcnMaxNum =
(pChipCap->BcnMaxHwNum - MAX_MESH_NUM - MAX_APCLI_NUM);
pChipCap->BcnMaxHwSize = 0x1000;
pChipCap->BcnBase[0] = 0x7800;
pChipCap->BcnBase[1] = 0x7A00;
pChipCap->BcnBase[2] = 0x7C00;
pChipCap->BcnBase[3] = 0x7E00;
pChipCap->BcnBase[4] = 0x7200;
pChipCap->BcnBase[5] = 0x7400;
pChipCap->BcnBase[6] = 0x5DC0;
pChipCap->BcnBase[7] = 0x5BC0;
/*
If the MAX_MBSSID_NUM is larger than 6,
it shall reserve some WCID space(wcid 222~253) for beacon frames.
- these wcid 238~253 are reserved for beacon#6(ra6).
- these wcid 222~237 are reserved for beacon#7(ra7).
*/
if (pChipCap->BcnMaxNum == 8)
pChipCap->WcidHwRsvNum = 222;
else if (pChipCap->BcnMaxNum == 7)
pChipCap->WcidHwRsvNum = 238;
else
pChipCap->WcidHwRsvNum = 255;
ops->BeaconUpdate = RtmpChipWriteMemory;
}
UINT8 NICGetBandSupported(RTMP_ADAPTER *pAd)
{
if (BOARD_IS_5G_ONLY(pAd))
return RFIC_5GHZ;
else if (BOARD_IS_2G_ONLY(pAd))
return RFIC_24GHZ;
else if (RFIC_IS_5G_BAND(pAd))
return RFIC_DUAL_BAND;
else
return RFIC_24GHZ;
}
INT WaitForAsicReady(RTMP_ADAPTER *pAd)
{
return TRUE;
}
INT AsicGetMacVersion(RTMP_ADAPTER *pAd)
{
UINT32 reg = 0;
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
/* TODO: shiang-7603 */
if (cap->hif_type == HIF_MT) {
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%s(%d): Not support for HIF_MT yet!\n", __func__,
__LINE__));
return FALSE;
}
if (WaitForAsicReady(pAd) == TRUE) {
RTMP_IO_READ32(pAd, reg, &pAd->MACVersion);
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("MACVersion[Ver:Rev]=0x%08x : 0x%08x\n",
pAd->MACVersion, pAd->ChipID));
return TRUE;
} else {
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s() failed!\n", __func__));
return FALSE;
}
}
/*
========================================================================
Routine Description:
Initialize chip related information.
Arguments:
pCB - WLAN control block pointer
Return Value:
None
Note:
========================================================================
*/
int RtmpChipOpsHook(VOID *pCB)
{
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)pCB;
RTMP_CHIP_CAP *pChipCap = hc_get_chip_cap(pAd->hdev_ctrl);
int ret = 0;
#ifdef MT_DFS_SUPPORT
/* Initial new DFS channel list */
DfsSetNewChInit(pAd);
#endif
/* sanity check */
if (WaitForAsicReady(pAd) == FALSE)
return -1;
/* TODO: shiang-7603 */
if (IS_MT7603(pAd) || IS_MT7628(pAd) || IS_MT76x6(pAd) ||
IS_MT7637(pAd) || IS_MT7615(pAd)) {
MTWF_LOG(
DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%s(%d): Not support for HIF_MT yet! MACVersion=0x%x\n",
__func__, __LINE__, pAd->MACVersion));
}
if (pAd->MACVersion == 0xffffffff)
return -1;
/* default init */
RTMP_DRS_ALG_INIT(pAd, RATE_ALG_LEGACY);
#ifdef RTMP_RBUS_SUPPORT
if (pAd->infType == RTMP_DEV_INF_RBUS) {
/* wilsonl, need DE provide info */
#ifndef MT7622
RTMP_SYS_IO_READ32(0xb000000c, &pAd->CommonCfg.CID);
RTMP_SYS_IO_READ32(0xb0000000, &pAd->CommonCfg.CN);
#endif
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("CN: %lx\tCID = %lx\n", pAd->CommonCfg.CN,
pAd->CommonCfg.CID));
}
#endif /* RTMP_RBUS_SUPPORT */
/*initial chip hook function*/
WfSysPreInit(pAd);
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Chip specific bbpRegTbSize=%d!\n", pChipCap->bbpRegTbSize));
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Chip VCO calibration mode = %d!\n",
pChipCap->FlgIsVcoReCalMode));
#ifdef DOT11W_PMF_SUPPORT
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("[PMF] Encryption mode = %d\n", pChipCap->FlgPMFEncrtptMode));
#endif /* DOT11W_PMF_SUPPORT */
return ret;
}

View File

@ -1,543 +0,0 @@
config MT_WIFI
tristate "MT WIFI Driver"
select WIFI_BASIC_FUNC if MT_WIFI
config MT_WIFI_PATH
string
depends on MT_WIFI
default "mt_wifi"
if MT_WIFI
menu "WiFi Generic Feature Options"
choice
prompt "EEPROM Type of 1st Card"
depends on ! FIRST_IF_NONE
config FIRST_IF_EEPROM_FLASH
bool "FLASH"
config FIRST_IF_EEPROM_EFUSE
bool "EFUSE"
endchoice
config RT_FIRST_CARD_EEPROM
string
depends on ! FIRST_IF_NONE
default "flash" if FIRST_IF_EEPROM_FLASH
choice
prompt "EEPROM Type of 2nd Card"
depends on ! SECOND_IF_NONE
config SECOND_IF_EEPROM_FLASH
bool "FLASH"
config SECOND_IF_EEPROM_PROM
bool "EEPROM"
config SECOND_IF_EEPROM_EFUSE
bool "EFUSE"
endchoice
config RT_SECOND_CARD_EEPROM
string
depends on ! SECOND_IF_NONE
default "prom" if SECOND_IF_EEPROM_PROM
default "efuse" if SECOND_IF_EEPROM_EFUSE
default "flash" if SECOND_IF_EEPROM_FLASH
choice
prompt "EEPROM Type of 3th Card"
depends on ! THIRD_IF_NONE
config THIRD_IF_EEPROM_FLASH
bool "FLASH"
config THIRD_IF_EEPROM_PROM
bool "EEPROM"
config THIRD_IF_EEPROM_EFUSE
bool "EFUSE"
endchoice
config RT_THIRD_CARD_EEPROM
string
depends on ! THIRD_IF_NONE
default "prom" if THIRD_IF_EEPROM_PROM
default "efuse" if THIRD_IF_EEPROM_EFUSE
default "flash" if THIRD_IF_EEPROM_FLASH
config MULTI_INF_SUPPORT
bool
default y if !FIRST_IF_NONE && !SECOND_IF_NONE
config WIFI_BASIC_FUNC
bool "Basic Functions"
select WIRELESS_EXT
select WEXT_SPY
select WEXT_PRIV
config DOT11_N_SUPPORT
bool "802.11n support"
default y
config DOT11_VHT_AC
bool "802.11AC support"
depends on WIFI_DRIVER
depends on DOT11_N_SUPPORT
default y
config G_BAND_256QAM_SUPPORT
bool "2.4G 256QAM support"
depends on WIFI_DRIVER
depends on DOT11_VHT_AC
default y
config TPC_SUPPORT
bool "802.11h TPC Support"
depends on WIFI_DRIVER
default y
config ICAP_SUPPORT
bool "ICAP Support"
depends on WIFI_DRIVER
depends on MT_AP_SUPPORT
default y
config SPECTRUM_SUPPORT
bool "Wifi Spectrum Support"
depends on WIFI_DRIVER
depends on MT_AP_SUPPORT
default y
config BACKGROUND_SCAN_SUPPORT
bool "Background Scan Support"
depends on WIFI_DRIVER
default y
config SMART_CARRIER_SENSE_SUPPORT
bool "Smart Carrier Sense Support"
depends on WIFI_DRIVER
default y
config MT_DFS_SUPPORT
bool "Dynamic Frequency Selection Support"
depends on WIFI_DRIVER
default y
config MTK_OFFCHANNEL_SCAN_FEATURE
bool "Channel Quality Monitor"
depends on MTK_WIFI_DRIVER
depends on MTK_MT_AP_SUPPORT
default n
config MTK_DPP_SUPPORT
bool "DPP Support"
depends on MTK_WIFI_DRIVER
depends on MTK_MT_AP_SUPPORT
select DOT11W_PMF_SUPPORT
default n
#config WFA_VHT_R2_PF
# bool "WFA VHT R2 Plugfest"
# depends on DOT11_VHT_AC
# default n
config HDR_TRANS_TX_SUPPORT
bool "Tx Header Translation"
depends on CHIP_MT7615E || CHIP_MT7622 || CHIP_MT7663E
default y
config HDR_TRANS_RX_SUPPORT
bool "Rx Header Translation"
depends on CHIP_MT7615E || CHIP_MT7622 || CHIP_MT7663E
default y
config DBDC_MODE
bool "dbdc mode support"
depends on CHIP_MT7615E
select MULTI_PROFILE_SUPPORT
# select DEFAULT_5G_PROFILE
default y
config MULTI_PROFILE_SUPPORT
bool "Multi Profile Support"
depends on DBDC_MODE
default y
config DEFAULT_5G_PROFILE
bool "5G default profile for DBDC"
depends on DBDC_MODE
default n
config WSC_INCLUDED
bool "WSC (WiFi Simple Config)"
depends on WIFI_DRIVER
depends on MT_AP_SUPPORT || MT_STA_SUPPORT
default y
config WSC_V2_SUPPORT
bool "WSC V2(WiFi Simple Config Version 2.0)"
depends on WIFI_DRIVER
depends on MT_AP_SUPPORT || MT_STA_SUPPORT
default y
config DOT11W_PMF_SUPPORT
bool "PMF"
depends on WIFI_DRIVER
depends on MT_AP_SUPPORT || MT_STA_SUPPORT
default y
config TXBF_SUPPORT
bool "Tx Bean Forming Support"
depends on WIFI_DRIVER
default y
config FAST_NAT_SUPPORT
bool "Fast-NAT support"
depends on RA_HW_NAT_WIFI
default n
config WHNAT_SUPPORT
tristate "Wifi Hardware NAT support"
depends on CHIP_MT7615E
depends on WLAN_HOOK
depends on FAST_NAT_SUPPORT
default n
#config LLTD_SUPPORT
# bool "LLTD (Link Layer Topology Discovery Protocol)"
# depends on WIFI_DRIVER
# depends on MT_AP_SUPPORT
# default n
#config QOS_DLS_SUPPORT
# bool "802.11e DLS ((Direct-Link Setup) Support"
# depends on WIFI_DRIVER
# depends on MT_AP_SUPPORT
# default n
#config WAPI_SUPPORT
# bool "WAPI Support"
# depends on WIFI_DRIVER
# default n
config FTM_SUPPORT
bool "FTM Support"
depends on WIFI_DRIVER
select PASSPOINT_R2
default n
config MBO_SUPPORT
bool "MBO Support"
depends on WIFI_DRIVER
select INTERWORKING
select WNM_SUPPORT
select DOT11K_RRM_SUPPORT
select DOT11R_FT_SUPPORT
select DOT11W_PMF_SUPPORT
default n
#config CARRIER_DETECTION_SUPPORT
# bool "Carrier Detect"
# depends on WIFI_DRIVER
# default n
config IGMP_SNOOP_SUPPORT
bool "IGMP snooping"
depends on WIFI_DRIVER
depends on MT_AP_SUPPORT
default y
#config BLOCK_NET_IF
# bool "NETIF Block"
# depends on WIFI_DRIVER
# depends on MT_AP_SUPPORT
# default n
# help
# Support Net interface block while Tx-Sw queue full
#config RATE_ADAPTION
# bool "New Rate Adaptation support"
# depends on WIFI_DRIVER
# default y
#config NEW_RATE_ADAPT_SUPPORT
# bool "Intelligent Rate Adaption"
# depends on WIFI_DRIVER && RATE_ADAPTION
# default y
#config AGS_SUPPORT
# bool "Adaptive Group Switching"
# depends on WIFI_DRIVER && RATE_ADAPTION
# depends on MT_AP_SUPPORT || MT_STA_SUPPORT
# default n
#config RATE_ADAPT_AGBS_SUPPORT
# bool "Adaptive AGBS Mode"
# depends on WIFI_DRIVER && RATE_ADAPTION
# depends on MT_AP_SUPPORT || MT_STA_SUPPORT
# default y
#config IDS_SUPPORT
# bool "IDS (Intrusion Detection System) Support"
# depends on WIFI_DRIVER
# depends on MT_AP_SUPPORT
# default n
#config WIFI_WORK_QUEUE
# bool "Work Queue"
# depends on WIFI_DRIVER
# default n
#config WIFI_SKB_RECYCLE
# bool "SKB Recycle(Linux)"
# depends on WIFI_DRIVER
# depends on MT_AP_SUPPORT
# default n
config RTMP_FLASH_SUPPORT
bool "Flash Support"
depends on WIFI_DRIVER
default y
config PRE_CAL_TRX_SET1_SUPPORT
bool "Calibration To Flash/BinFile Support"
depends on WIFI_DRIVER
default y
config RLM_CAL_CACHE_SUPPORT
bool "RlmCalibrationCache Support"
depends on WIFI_DRIVER
default y
config PRE_CAL_TRX_SET2_SUPPORT
bool "Pre-calibration to Flash Support"
depends on WIFI_DRIVER
default y
config CAL_BIN_FILE_SUPPORT
bool "Calibration to BinFile Support"
depends on WIFI_DRIVER
default y
config RF_LOCKDOWN_SUPPORT
bool "RF Lockdown Support"
depends on WIFI_DRIVER
default n
config LINK_TEST_SUPPORT
bool "Link Test Support"
depends on WIFI_DRIVER
default y
#config LED_CONTROL_SUPPORT
# bool "LED Support"
# depends on WIFI_DRIVER
# depends on MT_AP_SUPPORT
# default n
config ATE_SUPPORT
bool "ATE/QA Support"
depends on WIFI_DRIVER
default y
#config MEMORY_OPTIMIZATION
# bool "Memory Optimization"
# depends on WIFI_DRIVER
# default n
config PASSPOINT_R2
bool "Passpoint Release-2 Support"
depends on WIFI_DRIVER
select DOT11W_PMF_SUPPORT
depends on MT_AP_SUPPORT
default n
#config TRACE_TCP_PKT
# bool "TCP DATA/ACK packets trace log"
# depends on WIFI_DRIVER
# default n
config UAPSD
bool "UAPSD support"
depends on WIFI_DRIVER
depends on MT_AP_SUPPORT || MT_STA_SUPPORT
default y
config TCP_RACK_SUPPORT
bool "TCP Reduced ACK support"
depends on WIFI_DRIVER
default n
#### PA_LNA_Type choice
config RED_SUPPORT
bool "RED(Random Early Drop) support"
depends on WIFI_DRIVER
depends on MT_AP_SUPPORT || MT_STA_SUPPORT
default y
config FDB_SUPPORT
bool "FW Debug Port"
depends on WIFI_DRIVER
default n
choice
prompt "PA LNA Type of 1st Card"
depends on ! FIRST_IF_NONE
config FIRST_IF_EPAELNA
bool "ePAeLNA"
config FIRST_IF_IPAILNA
bool "iPAiLNA"
config FIRST_IF_IPAELNA
bool "iPAeLNA"
# config FIRST_IF_EPAILNA
# bool "ePAiLNA"
endchoice
choice
prompt "PA LNA Type of 2nd Card"
depends on ! SECOND_IF_NONE
config SECOND_IF_EPAELNA
bool "ePAeLNA"
config SECOND_IF_IPAILNA
bool "iPAiLNA"
config SECOND_IF_IPAELNA
bool "iPAeLNA"
# config SECOND_IF_EPAILNA
# bool "ePAiLNA"
endchoice
choice
prompt "PA LNA Type of 3rd Card"
depends on ! THIRD_IF_NONE
config THIRD_IF_EPAELNA
bool "ePAeLNA"
config THIRD_IF_IPAILNA
bool "iPAiLNA"
config THIRD_IF_IPAELNA
bool "iPAeLNA"
# config THIRD_IF_EPAILNA
# bool "ePAiLNA"
endchoice
#### PA_LNA_Type choice END
#
# Section for chip architectures
#
# "RLT MAC Support"
config RLT_MAC
bool
depends on WIFI_DRIVER
default n
config RLT_BBP
bool
config RLT_RF
bool
# "RTMP MAC Support"
config RTMP_MAC
bool
depends on WIFI_DRIVER
default n
config RTMP_BBP
bool
config RTMP_RF
bool
#
# Section for interfaces
#
config RTMP_PCI_SUPPORT
bool
config RTMP_USB_SUPPORT
bool
config RTMP_RBUS_SUPPORT
bool
endmenu
menu "WiFi Operation Modes"
choice
prompt "Main Mode"
default WIFI_MODE_AP
config WIFI_MODE_AP
tristate "AP"
select MT_AP_SUPPORT
config WIFI_MODE_STA
tristate "STA"
select MT_STA_SUPPORT
config WIFI_MODE_BOTH
tristate "APSTA"
select MT_AP_SUPPORT
select MT_STA_SUPPORT
endchoice
if WIFI_MODE_AP || WIFI_MODE_BOTH
source "drivers/net/wireless/mtk/mt7615e/mt_wifi_ap/Kconfig"
endif
if WIFI_MODE_STA || WIFI_MODE_BOTH
source "drivers/net/wireless/mtk/mt7615e/mt_wifi_sta/Kconfig"
endif
endmenu
endif
if WIFI_RLT_MAC
config RLT_MAC
bool
default y
endif
if WIFI_RTMP_MAC
config RTMP_MAC
bool
default y
endif
if WIFI_MT_MAC
config MT_MAC
bool
default y
config CHIP_MT7603E
bool
default n
config CHIP_MT7615E
bool
default n
config CHIP_MT7622
bool
default n
config CHIP_MT7663E
bool
default n
endif
if CHIP_MT7615E
config MT_MAC
bool
default y
select RATE_ADAPTION
select RATE_ADAPT_AGBS_SUPPORT
select DOT11_N_SUPPORT
select DOT11_VHT_AC
select HDR_TRANS_TX_SUPPORT
select HDR_TRANS_RX_SUPPORT
endif

View File

@ -1,603 +0,0 @@
ifeq ($(WIFI_MODE),)
RT28xx_MODE = AP
else
RT28xx_MODE = $(WIFI_MODE)
endif
ifeq ($(TARGET),)
TARGET = LINUX
endif
# CHIPSET
ifeq ($(CHIPSET),)
CHIPSET = mt7622 mt7615
endif
MODULE = $(word 1, $(CHIPSET))
#OS ABL - YES or NO
OSABL = NO
ifneq ($(TARGET),THREADX)
#RT28xx_DIR = home directory of RT28xx source code
RT28xx_EMBEDDED_DIR = $(shell pwd)
RT28xx_DIR = $(shell cd ..;pwd)
#RT28xx_BIN_DIR = parent directory of bin folder, used by bin2h
RT28xx_BIN_DIR = $(shell cd ../..;pwd)
RT28xx_OS_DIR = $(RT28xx_DIR)/os
endif
include $(RT28xx_OS_DIR)/linux/config.mk
RTMP_SRC_DIR = $(RT28xx_DIR)/RT$(MODULE)
ifeq ($(PLATFORM),)
#PLATFORM: Target platform
PLATFORM = PC
#PLATFORM = BB_SOC
#PLATFORM = IKANOS_V160
#PLATFORM = IKANOS_V180
#PLATFORM = SIGMA
#PLATFORM = SIGMA_8622
#PLATFORM = INIC
#PLATFORM = STAR
#PLATFORM = IXP
#PLATFORM = INF_TWINPASS
#PLATFORM = INF_DANUBE
#PLATFORM = INF_AR9
#PLATFORM = INF_VR9
#PLATFORM = BRCM_6358
#PLATFORM = INF_AMAZON_SE
#PLATFORM = CAVM_OCTEON
#PLATFORM = CMPC
#PLATFORM = SMDK
#PLATFORM = RMI
#PLATFORM = RMI_64
#PLATFORM = KODAK_DC
#PLATFORM = DM6446
#PLATFORM = FREESCALE8377
#PLATFORM = BL2348
#PLATFORM = BL23570
#PLATFORM = BLUBB
#PLATFORM = BLPMP
#PLATFORM = MT85XX
#PLATFORM = MT53XX
#PLATFORM = NXP_TV550
#PLATFORM = MVL5
#PLATFORM = UBICOM_IPX8
#PLATFORM = INTELP6
#PLATFORM = MT7620
#PLATFORM = MT7621
#PLATFORM = MT7622
endif
ifeq ($(PLATFORM),INTELP6)
ifndef TARG_ARCH
export TARG_ARCH=intel_gen3-linux
endif
ifndef BUILD_ROOT
export BUILD_ROOT=$(PWD)/../../..
endif
ifndef BUILD_DEST
export BUILD_DEST=$(BUILD_ROOT)/$(BUILD_DIR)/
endif
ifndef HOST_CC
export HOST_CC=gcc
endif
ifeq ($(TARG_ARCH),intel_gen3-linux)
BUILD_DIR=build_i686/staging_dir
HOST=LINUX
TARGET=LINUX
BUILD=LINUX
CROSS_COMPILE=$(BUILD_DEST)/bin/i686-cm-linux-
endif
export HOST
export TARGET
export BUILD
export CROSS_COMPILE
ifdef TARGETCC
export CC=$(TARGETCC)
export LD=$(TARGETLD)
export AR=$(TARGETAR)
export AR_RC=$(TARGETAR) rc
export STRIP=$(TARGETSTRIP)
export CXX=$(TARGETCXX)
export RANLIB=$(TARGETRANLIB)
export STRINGS=$(TARGETSTRINGS)
export M4=$(TARGETM4)
export BISON=$(TARGETBISON)
export YACC=$(TARGETYACC)
else
export CC=$(CROSS_COMPILE)gcc
export LD=$(CROSS_COMPILE)ld
export AR=$(CROSS_COMPILE)ar
export AR_RC=$(CROSS_COMPILE)ar rc
export STRIP=$(CROSS_COMPILE)strip
export CXX=$(CROSS_COMPILE)g++
export RANLIB=$(CROSS_COMPILE)ranlib
export STRINGS=$(CROSS_COMPILE)strings
export M4=$(CROSS_COMPILE)m4
export BISON=$(CROSS_COMPILE)bison
export YACC=$(CROSS_COMPILE)yacc
endif
ifndef TARGETDEST
export TARGETDEST = $(BUILD_ROOT)/project_build_i686/IntelCE/
endif
ifndef FSROOT
export FSROOT = $(TARGETDEST)/root/
endif
ifndef KERNEL_VER
export KERNEL_VER=linux-2.6.28
endif
ifndef KERNEL_DIR
export KERNEL_DIR=$(BUILD_DEST)/kernel/$(KERNEL_VER)
endif
endif
#APSOC
ifeq ($(CHIPSET),mt7628)
PLATFORM = MT7628
endif
#RELEASE Package
RELEASE = FormalRelease
ifeq ($(TARGET),LINUX)
MAKE = make
endif
ifeq ($(TARGET), UCOS)
MAKE = make
endif
ifeq ($(TARGET),THREADX)
MAKE = gmake
endif
ifeq ($(TARGET), ECOS)
MAKE = make
MODULE = $(shell pwd | sed "s/.*\///" ).o
export MODULE
endif
ifeq ($(PLATFORM),BB_SOC)
LINUX_SRC = $(KERNEL_DIR)
#CROSS_COMPILE = /opt/trendchip/mips-linux-uclibc/usr/bin/mips-linux-uclibc-
endif
ifeq ($(PLATFORM),UBICOM_IPX8)
LINUX_SRC = /home/sample/Customers/UBICOM/ubicom-linux-dist-2.1.1/linux-2.6.x
CROSS_COMPILE = ubicom32-elf-
endif
ifeq ($(PLATFORM),IKANOS_V160)
LINUX_SRC = /home/sample/projects/LX_2618_RG_5_3_00r4_SRC/linux-2.6.18
CROSS_COMPILE = mips-linux-
endif
ifeq ($(PLATFORM),IKANOS_V180)
LINUX_SRC = /home/sample/projects/LX_BSP_VX180_5_4_0r1_ALPHA_26DEC07/linux-2.6.18
CROSS_COMPILE = mips-linux-
endif
ifeq ($(PLATFORM),SIGMA)
LINUX_SRC = /root/sigma/smp86xx_kernel_source_2.7.172.0/linux-2.6.15
CROSS_COMPILE = /root/sigma/smp86xx_toolchain_2.7.172.0/build_mipsel_nofpu/staging_dir/bin/mipsel-linux-
endif
ifeq ($(PLATFORM),SIGMA_8622)
LINUX_SRC = /home/snowpin/armutils_2.5.120.1/build_arm/linux-2.4.22-em86xx
CROSS_COMPILE = /home/snowpin/armutils_2.5.120.1/toolchain/bin/arm-elf-
CROSS_COMPILE_INCLUDE = /home/snowpin/armutils_2.5.120.1/toolchain/lib/gcc-lib/arm-elf/2.95.3
endif
ifeq ($(PLATFORM),INIC)
UCOS_SRC = /opt/uCOS/iNIC_rt2880
CROSS_COMPILE = /usr/bin/mipsel-linux-
endif
ifeq ($(PLATFORM),STAR)
LINUX_SRC = /opt/star/kernel/linux-2.4.27-star
CROSS_COMPILE = /opt/star/tools/arm-linux/bin/arm-linux-
endif
ifeq ($(PLATFORM),RMI)
LINUX_SRC = /opt/rmi/1.7.0/linux/src/
CROSS_COMPILE = /opt/rmi/1.7.0/mipscross/nptl/bin/mips64-unknown-linux-gnu-
endif
ifeq ($(PLATFORM),RMI_64)
LINUX_SRC = /opt/rmi/1.7.0/linux_64/src/
CROSS_COMPILE = /opt/rmi/1.7.0/mipscross/nptl/bin/mips64-unknown-linux-gnu-
endif
ifeq ($(PLATFORM),FREESCALE8377)
LINUX_SRC = /opt/ltib-mpc8377_rds-20090309/rpm/BUILD/linux-2.6.25
CROSS_COMPILE = /opt/freescale/usr/local/gcc-4.2.187-eglibc-2.5.187/powerpc-linux-gnu/bin/powerpc-linux-gnu-
endif
ifeq ($(PLATFORM),BL2348)
LINUX_SRC = /home/sample/Customers/BroadLight/bl234x-linux-2.6.21-small-v29
CROSS_COMPILE = mips-wrs-linux-gnu-
endif
ifeq ($(PLATFORM),BL23570)
LINUX_SRC = /home/FIBERHOME/linux-2.6.34.8
CROSS_COMPILE = mips-wrs-linux-gnu-mips_74k_softfp-glibc_small-
ARCH:=mips
export $ARCH
endif
ifeq ($(PLATFORM),BLUBB)
LINUX_SRC = /home/sample/Customers/BroadLight/UBB/gmp20/linux-2.6.21-small
CROSS_COMPILE = mips-wrs-linux-gnu-
endif
ifeq ($(PLATFORM),BLPMP)
LINUX_SRC = /home/sample/Customers/BroadLight/UBB/pmp16/bl234x-linux-2.6.21-small-v30.2
CROSS_COMPILE = mips-wrs-linux-gnu-
endif
ifeq ($(PLATFORM),PC)
# Linux 2.6
#LINUX_SRC = /lib/modules/$(shell uname -r)/build
# Linux 2.4 Change to your local setting
#LINUX_SRC = /usr/src/linux-2.4
#LINUX_SRC_MODULE = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless/
LINUX_SRC = /lib/modules/3.16.0-30-generic/build
LINUX_SRC_MODULE = /lib/modules/3.16.0-30-generic/kernel/drivers/net/wireless/
CROSS_COMPILE =
endif
ifeq ($(PLATFORM),INTELP6)
LINUX_SRC = $(KERNEL_DIR)
CROSS_COMPILE =
endif
ifeq ($(PLATFORM),IXP)
LINUX_SRC = /project/stable/Gmtek/snapgear-uclibc/linux-2.6.x
CROSS_COMPILE = arm-linux-
endif
ifeq ($(PLATFORM),INF_TWINPASS)
# Linux 2.6
#LINUX_SRC = /lib/modules/$(shell uname -r)/build
# Linux 2.4 Change to your local setting
LINUX_SRC = /project/stable/twinpass/release/2.0.1/source/kernel/opensource/linux-2.4.31/
CROSS_COMPILE = mips-linux-
endif
ifeq ($(PLATFORM),INF_DANUBE)
LINUX_SRC = /opt/danube/sdk/linux-2.6.16.x
CROSS_COMPILE = mips-linux-
ROOTDIR = /opt/danube/sdk
export ROOTDIR
endif
ifeq ($(PLATFORM),INF_AR9)
LINUX_SRC = /root/ar9/xR9_BSP1.2.2.0/source/kernel/opensource/linux-2.6.20/
CROSS_COMPILE = /root/ar9/ifx-lxdb26-1.0.2/gcc-3.4.4/toolchain-mips/bin/
endif
ifeq ($(PLATFORM),INF_VR9)
LINUX_SRC = /home/public/lantiq/VR9/UGW-4.2/build_dir/linux-ifxcpe_platform_vr9/linux-2.6.20.19
CROSS_COMPILE = /home/public/lantiq/VR9/UGW-4.2/staging_dir/toolchain-mips_gcc-3.4.6_uClibc-0.9.29/bin/mips-linux-
endif
ifeq ($(PLATFORM),BRCM_6358)
LINUX_SRC =
CROSS_COMPILE =
endif
ifeq ($(PLATFORM),INF_AMAZON_SE)
# Linux 2.6
#LINUX_SRC = /lib/modules/$(shell uname -r)/build
# Linux 2.4 Change to your local setting
LINUX_SRC = /backup/ifx/3.6.2.2/source/kernel/opensource/linux-2.4.31
#CROSS_COMPILE = mips-linux-
#LINUX_SRC = /project/Infineon/3.6.2.2/source/kernel/opensource/linux-2.4.31
CROSS_COMPILE = /opt/uclibc-toolchain/ifx-lxdb-1-2-3-external/gcc-3.3.6/toolchain-mips/R0208V35/mips-linux-uclibc/bin/
endif
ifeq ($(PLATFORM),ST)
LINUX_SRC = /opt/STM/STLinux-2.2/devkit/sources/kernel/linux0039
CROSS_COMPILE = /opt/STM/STLinux-2.2/devkit/sh4/bin/sh4-linux-
ARCH := sh
export ARCH
endif
ifeq ($(PLATFORM),CAVM_OCTEON)
OCTEON_ROOT = /usr/local/Cavium_Networks/OCTEON-SDK
LINUX_SRC = $(OCTEON_ROOT)/linux/kernel_2.6/linux
CROSS_COMPILE = mips64-octeon-linux-gnu-
endif
ifeq ($(PLATFORM),CMPC)
LINUX_SRC = /opt/fvt_11N_SDK_0807/fvt131x_SDK_11n/linux-2.6.17
CROSS_COMPILE =
endif
ifeq ($(PLATFORM),SMDK)
LINUX_SRC = /home/bhushan/itcenter/may28/linux-2.6-samsung
CROSS_COMPILE = /usr/local/arm/4.2.2-eabi/usr/bin/arm-linux-
endif
ifeq ($(PLATFORM),KODAK_DC)
SKD_SRC = C:/SigmaTel/DC1250_SDK_v1-9/sdk
CROSS_COMPILE = $(cc)
endif
ifeq ($(PLATFORM),DM6446)
LINUX_SRC = /home/fonchi/work/soc/ti-davinci
endif
ifeq ($(PLATFORM),MT85XX)
LINUX_SRC = /home/john/MTK/BDP_Linux/linux-2.6.27
CROSS_COMPILE = armv6z-mediatek-linux-gnueabi-
endif
ifeq ($(PLATFORM),MT53XX)
TARGET = LINUX
#****** For system auto build ******
#LINUX_SRC=$(KERNEL_OBJ_ROOT)/$(KERNEL_VER)/$(KERNEL_CONFIG)_modules
#****** For local build ******
# uncomment the following lines
VM_LINUX_ROOT ?= $(word 1, $(subst /vm_linux/,/vm_linux /, $(shell pwd)))
LINUX_ROOT ?= $(VM_LINUX_ROOT)
LINUX_SRC=$(VM_LINUX_ROOT)/output/Sony_android/Fiji_EU_JB/rel/obj/kernel/chiling/kernel/linux-3.4/_android_smp_mod_defconfig_modules
OBJ_ROOT ?= $(VM_LINUX_ROOT)/output/Sony_android/Fiji_EU_JB/rel/obj
export KERNEL_OBJ_ROOT=$(LINUX_SRC)/../..
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE=/mtkoss/gnuarm/vfp_4.5.1_2.6.27_cortex-a9-rhel4/i686/bin/armv7a-mediatek451_001_vfp-linux-gnueabi-
endif
ifeq "$(CC)" "gcc"
CC ?= $(CROSS_COMPILE)gcc
endif
$(warning =============================================)
$(warning CC=$(CC) for wifi driver LINUX_SRC=$(LINUX_SRC))
$(warning TARGET=$(TARGET))
$(warning =============================================)
endif
ifeq ($(PLATFORM),NXP_TV550)
LINUX_SRC = /data/tv550/kernel/linux-2.6.28.9
LINUX_SRC_MODULE = /data/tv550/kernel/linux-2.6.28.9/drivers/net/wireless
CROSS_COMPILE = /opt/embeddedalley/nxp_tv550/bin/mipsel-linux-
endif
ifeq ($(PLATFORM),MVL5)
LINUX_SRC = /home2/charlestu/AP-VT3426/linux-2.6.18
CROSS_COMPILE = /opt/montavista/pro/devkit/arm/v5t_le_mvl5/bin/arm_v5t_le-
endif
ifeq ($(PLATFORM),MT7620)
LINUX_SRC = /home/share/src/MT7601/AP/RT288x_SDK/source/linux-2.6.36.x
CROSS_COMPILE = /opt/buildroot-gcc342/bin/mipsel-linux-
endif
ifeq ($(PLATFORM),MT7621)
LINUX_SRC = /mtkoss/linux_headers/linux-headers-3.10.14-mips
CROSS_COMPILE = /opt/buildroot-gcc463/usr/bin/mipsel-linux-
ARCH = mips
export $ARCH
endif
ifeq ($(PLATFORM),MT7628)
LINUX_SRC = /root/Working/MT7628_SDK_2013_0912/RT288x_SDK/source/linux-2.6.36.x
CROSS_COMPILE = /opt/buildroot-gcc342/bin/mipsel-linux-
endif
ifeq ($(PLATFORM),MT7622)
LINUX_SRC = /mtkoss/linux_headers/linux-headers-4.4.24-arm64/
CROSS_COMPILE = /opt/buildroot-gcc492_arm64/usr/bin/aarch64-linux-
ARCH = arm64
export $ARCH
endif
export OSABL RT28xx_DIR RT28xx_BIN_DIR RT28xx_OS_DIR RT28xx_EMBEDDED_DIR RT28xx_MODE LINUX_SRC CROSS_COMPILE CROSS_COMPILE_INCLUDE PLATFORM RELEASE CHIPSET MODULE RTMP_SRC_DIR LINUX_SRC_MODULE TARGET HAS_WOW_SUPPORT HAS_FPGA_MODE HAS_RX_CUT_THROUGH
# The targets that may be used.
PHONY += all build_tools test UCOS THREADX LINUX release prerelease clean uninstall install libwapi osabl sdk_build_tools
ifeq ($(TARGET),LINUX)
all: build_tools $(TARGET) plug_in
else
all: $(TARGET)
endif
build_sku_tables:
$(MAKE) -C $(RT28xx_DIR)/txpwr
$(RT28xx_DIR)/txpwr/data2h
build_power_limit_tables:
$(MAKE) -C $(RT28xx_DIR)/txpwr
$(RT28xx_DIR)/txpwr/data2h
build_tools:
$(MAKE) -C tools
$(RT28xx_EMBEDDED_DIR)/tools/bin2h
sdk_build_tools:
if [ -f $(RT28xx_DIR)/eeprom_log ]; then \
rm -f $(RT28xx_DIR)/eeprom_log
fi
echo $(EE_TYPE) >> eeprom_log
echo $(CHIPSET) >> eeprom_log
if [ -f $(RT28xx_DIR)/eeprom/SA/MT7603E_EEPROM.bin ]; then \
echo 'find SA/MT7603E_EEPROM.bin' >> eeprom_log ; \
cp -f $(RT28xx_DIR)/eeprom/SA/MT7603E_EEPROM.bin $(RT28xx_DIR)/eeprom/MT7603E_EEPROM.bin ; \
else \
cp -f $(RT28xx_DIR)/eeprom/$(EE_TYPE)/MT7603E_EEPROM.bin $(RT28xx_DIR)/eeprom/MT7603E_EEPROM.bin ; \
fi
$(MAKE) -C tools
$(RT28xx_EMBEDDED_DIR)/tools/bin2h
# rm -f $(RT28xx_DIR)/eeprom/SA/MT7603E_EEPROM.bin
test:
$(MAKE) -C tools test
UCOS:
$(MAKE) -C os/ucos/ MODE=$(RT28xx_MODE)
echo $(RT28xx_MODE)
ECOS:
$(MAKE) -C os/ecos/ MODE=$(RT28xx_MODE)
cp -f os/ecos/$(MODULE) $(MODULE)
THREADX:
$(MAKE) -C $(RT28xx_OS_DIR)/Threadx -f $(RT28xx_OS_DIR)/ThreadX/Makefile
LINUX:
ifneq (,$(findstring 2.4,$(LINUX_SRC)))
ifeq ($(OSABL),YES)
cp -f $(RT28xx_OS_DIR)/linux/Makefile.4.util $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(RT28xx_OS_DIR)/linux/
endif
cp -f $(RT28xx_OS_DIR)/linux/Makefile.4 $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(RT28xx_OS_DIR)/linux/
ifeq ($(OSABL),YES)
cp -f $(RT28xx_OS_DIR)/linux/Makefile.4.netif $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(RT28xx_OS_DIR)/linux/
endif
else
ifeq ($(OSABL),YES)
cp -f $(RT28xx_OS_DIR)/linux/Makefile.6.util $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_OS_DIR)/linux modules
endif
cp -f $(RT28xx_OS_DIR)/linux/Makefile.6 $(RT28xx_OS_DIR)/linux/Makefile
ifeq ($(PLATFORM),DM6446)
$(MAKE) ARCH=arm CROSS_COMPILE=arm_v5t_le- -C $(LINUX_SRC) SUBDIRS=$(RT28xx_OS_DIR)/linux modules
else ifeq ($(PLATFORM),FREESCALE8377)
$(MAKE) ARCH=powerpc CROSS_COMPILE=$(CROSS_COMPILE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_OS_DIR)/linux modules
else ifeq ($(PLATFORM), $(filter $(PLATFORM), MT7622 MT7621))
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_OS_DIR)/linux modules
else
$(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_OS_DIR)/linux modules
endif
ifeq ($(OSABL),YES)
cp -f $(RT28xx_OS_DIR)/linux/Makefile.6.netif $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_OS_DIR)/linux modules
endif
endif
check_build:
$(RT28xx_EMBEDDED_DIR)/tools/check_build_script.sh
plug_in:
$(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_EMBEDDED_DIR)/tools/plug_in MODULE_FLAGS="$(WFLAGS)"
release: build_tools
$(MAKE) -C $(RT28xx_EMBEDDED_DIR)/striptool -f Makefile.release clean
$(MAKE) -C $(RT28xx_EMBEDDED_DIR)/striptool -f Makefile.release
striptool/striptool.out
ifeq ($(RELEASE), DPO)
gcc -o embedded/striptool/banner striptool/banner.c
./embedded/striptool/banner -b embedded/striptool/copyright.gpl -s DPO/ -d DPO_GPL -R
./embedded/striptool/banner -b embedded/striptool/copyright.frm -s DPO_GPL/include/firmware.h
endif
prerelease:
ifeq ($(MODULE), 2880)
$(MAKE) -C $(RT28xx_OS_DIR)/linux -f Makefile.release.2880 prerelease
else
$(MAKE) -C $(RT28xx_OS_DIR)/linux -f Makefile.release prerelease
endif
cp $(RT28xx_OS_DIR)/linux/Makefile.DPB $(RTMP_SRC_DIR)/os/linux/.
cp $(RT28xx_OS_DIR)/linux/Makefile.DPA $(RTMP_SRC_DIR)/os/linux/.
cp $(RT28xx_OS_DIR)/linux/Makefile.DPC $(RTMP_SRC_DIR)/os/linux/.
ifeq ($(RT28xx_MODE),STA)
cp $(RT28xx_OS_DIR)/linux/Makefile.DPD $(RTMP_SRC_DIR)/os/linux/.
cp $(RT28xx_OS_DIR)/linux/Makefile.DPO $(RTMP_SRC_DIR)/os/linux/.
endif
clean:
ifeq ($(TARGET), LINUX)
cp -f $(RT28xx_OS_DIR)/linux/Makefile.clean $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(RT28xx_OS_DIR)/linux clean
rm -rf $(RT28xx_OS_DIR)/linux/Makefile
ifeq ($(PLATFORM),INTELP6)
rm -rf $(BUILD_DEST)/etc/Wireless/7615AP/
rm -rf $(FSROOT)/etc/Wireless/7615AP/
rm -rf $(BUILD_DEST)/lib/modules/wifi/mt7615e_ap.ko
rm -rf $(FSROOT)/lib/modules/wifi/mt7615e_ap.ko
endif
endif
ifeq ($(TARGET), UCOS)
$(MAKE) -C $(RT28xx_OS_DIR)/ucos clean MODE=$(RT28xx_MODE)
endif
ifeq ($(TARGET), ECOS)
$(MAKE) -C $(RT28xx_OS_DIR)/ecos clean MODE=$(RT28xx_MODE)
endif
uninstall:
ifeq ($(TARGET), LINUX)
ifneq (,$(findstring 2.4,$(LINUX_SRC)))
$(MAKE) -C $(RT28xx_OS_DIR)/linux -f Makefile.4 uninstall
else
$(MAKE) -C $(RT28xx_OS_DIR)/linux -f Makefile.6 uninstall
endif
endif
install:
ifeq ($(TARGET), LINUX)
ifneq (,$(findstring 2.4,$(LINUX_SRC)))
$(MAKE) -C $(RT28xx_OS_DIR)/linux -f Makefile.4 install
else
$(MAKE) -C $(RT28xx_OS_DIR)/linux -f Makefile.6 install
endif
endif
libwapi:
ifneq (,$(findstring 2.4,$(LINUX_SRC)))
cp -f embedded/os/linux/Makefile.libwapi.4 $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(RT28xx_OS_DIR)/linux/
else
cp -f embedded/os/linux/Makefile.libwapi.6 $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_OS_DIR)/linux modules
endif
osutil:
ifeq ($(OSABL),YES)
ifneq (,$(findstring 2.4,$(LINUX_SRC)))
cp -f os/linux/Makefile.4.util $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(RT28xx_DIR)/os/linux/
else
cp -f os/linux/Makefile.6.util $(RT28xx_OS_DIR)/linux/Makefile
$(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
endif
endif
osnet:
ifeq ($(OSABL),YES)
ifneq (,$(findstring 2.4,$(LINUX_SRC)))
cp -f os/linux/Makefile.4.netif $(RT28xx_DIR)/os/linux/Makefile
$(MAKE) -C $(RT28xx_DIR)/os/linux/
else
cp -f os/linux/Makefile.6.netif $(RT28xx_DIR)/os/linux/Makefile
$(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
endif
endif
osdrv:
ifneq (,$(findstring 2.4,$(LINUX_SRC)))
cp -f os/linux/Makefile.4 $(RT28xx_DIR)/os/linux/Makefile
$(MAKE) -C $(RT28xx_DIR)/os/linux/
else
cp -f os/linux/Makefile.6 $(RT28xx_DIR)/os/linux/Makefile
$(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
endif
# Declare the contents of the .PHONY variable as phony. We keep that information in a variable
.PHONY: $(PHONY)

View File

@ -1,92 +0,0 @@
EmbeddedDir=`pwd`
BaseCodeDir=`dirname $EmbeddedDir`
HomeDir=`dirname $BaseCodeDir`
dir_main=mt_wifi
dir_ap=mt_wifi_ap
dir_sta=mt_wifi_sta
release_profile=$BaseCodeDir/Release.log
#module_name=`basename $BaseCodeDir`
module_name=`cat $release_profile | line`
release_version=`sed -e '1d' $release_profile | line`
release_date=`sed -e '1,2d' $release_profile | line`
package_name=$module_name\_$release_version\_$release_date
############################
cd $HomeDir
### Creat dir_main ###
if [ -d $dir_main ]; then
rm -rf $dir_main
fi
if [ -d $dir_ap ]; then
rm -rf $dir_ap
fi
#if [ -d $dir_sta ]; then
# rm -rf $dir_sta
#fi
if [ -d $HomeDir/../temp_release ]; then
rm -rf $HomeDir/../temp_release
fi
mv $BaseCodeDir $HomeDir/../temp_release
rm -rf *
mv $HomeDir/../temp_release $dir_main
#cp Kconfig $dir_main/
rm $dir_main/embedded/Pack_Release.sh $dir_main/Release.log
mkdir $dir_ap
cp $dir_main/os/linux/Kconfig.mt_wifi_ap $dir_ap/Kconfig
cp $dir_main/os/linux/Makefile.mt_wifi_ap $dir_ap/Makefile
cp $dir_main/os/linux/Kconfig.mt_wifi $dir_main/embedded/Kconfig
#mv $dir_main/embedded/$dir_sta ./
### Creat dir_ap ###
#if [ -d $dir_ap ]; then
# rm -rf $dir_ap
#fi
#mkdir $dir_ap
#if [ ! -d $dir_ap ]; then
# echo "Error! Cannot creat folder [$dir_ap]"
# exit 1
#fi
#
#
#cp $BaseCodeDir/os/linux/Makefile.rlt_wifi_ap $dir_ap/Makefile
#cp $BaseCodeDir/os/linux/Kconfig.rlt_wifi_ap $dir_ap/Kconfig
if [ ! -d $dir_ap ]; then
echo "Error! [$dir_ap] doesn't exist."
exit 1
fi
#if [ ! -d $dir_sta ]; then
# echo "Error! [$dir_sta] doesn't exist."
# exit 1
#fi
if [ "$1" == "auto_build" ]; then
if [ -d ../$dir_main\_auto_build ]; then
rm -rf ../$dir_main\_auto_build
fi
if [ -d ../$dir_ap\_auto_build ]; then
rm -rf ../$dir_ap\_auto_build
fi
#if [ -d ../$dir_sta\_auto_build ]; then
# rm -rf ../$dir_sta\_auto_build
#fi
mv $dir_main ../$dir_main\_auto_build
mv $dir_ap ../$dir_ap\_auto_build
#mv $dir_sta ../$dir_sta\_auto_build
cd ../../
#rm -rf release
else
rm $dir_main/embedded/*auto_build*
tar -jcvf $package_name\.tar.bz2 $dir_main $dir_ap
#tar -jcvf $package_name\.tar.bz2 $dir_main $dir_ap $dir_sta
#rm -rf $dir_main $dir_ap $dir_sta
fi
############################

View File

@ -1,134 +0,0 @@
OSABL=NO
EmbeddedDir=`pwd`
BaseCodeDir=`dirname $EmbeddedDir`
ChipName="mt7615"
WiFiMode=AP
DriverVersion="V4.4.0.2"
Release="DPA"
Note=$1
Description="Formal release."
release_profile=Release.log
###### Fixed Settings ######
Day=`date +%d`
Month=`date +%m`
Year=`date +%Y`
Date=$Year$Month$Day
Hour=`date +%H`
Minute=`date +%M`
HomeDir=`dirname $BaseCodeDir`
#ModuleName=mt$ChipName\_wifi_$DriverVersion
ModulePrefix=MT7615_LinuxAP
ModuleName=$ModulePrefix\_$DriverVersion
WorkDir=$HomeDir/release
TargetDir=$WorkDir/$ModuleName\_$Date\_$Hour$Minute
############################
if [ ! -d $WorkDir ]; then
mkdir $WorkDir
fi
BaseCodeDir=`readlink -f $BaseCodeDir` #get full path
if [ ! -d $BaseCodeDir ] ; then
echo "Error: BaseCodeDir ($BaseCodeDir) does not exist."
exit 1;
fi
cp -a $BaseCodeDir $TargetDir
if [ ! -d $TargetDir ] ; then
echo "Error: TargetDir ($TargetDir) does not exist."
exit 1;
fi
cd $TargetDir
if [ -f /home/haipin/script/chmod_644.sh ]; then
/home/haipin/script/chmod_644.sh
fi
if [ -f /home/haipin/script/clean.sh ]; then
/home/haipin/script/clean.sh
fi
for i in $Release; do
cd $TargetDir/embedded
####### Remove unwanted files that do not processed by strip tool ####### // TODO
rm os/linux/Makefile.libautoprovision.6 common/rt2860.bin common/rt2870_sw_ch_offload.bin common/RT85592.bin
rm tools/mt7662e_ap.sh tools/mt7662e_sta.sh tools/i.sh tools/trace.sh
rm ../eeprom/MT7601*.bin ../eeprom/MT7603*.bin ../eeprom/MT7628*.bin ../eeprom/MT7637*.bin ../eeprom/MT7662*.bin
rm ../eeprom/MT7636*.bin
rm ../mcu/bin/*_FPGA*.bin ../mcu/bin/*_plain*.bin ../mcu/bin/*_test*.bin
rm ../mcu/bin/*7601* ../mcu/bin/*7603* ../mcu/bin/*7612* ../mcu/bin/*7636* ../mcu/bin/*7637*
rm ../mcu/bin/*7610* ../mcu/bin/*7650* ../mcu/bin/*7662* ../mcu/bin/*7628*
rm ../os/linux/Kconfig.ap* ../os/linux/Kconfig.sta* ../os/linux/Kconfig.rlt* ../os/linux/Kconfig.wifi
rm ../os/linux/Makefile.ap* ../os/linux/Makefile.sta* ../os/linux/Makefile.2880* ../os/linux/Makefile.rlt*
#########################################################################
## Regenerate Firmware ##
#rm -rf include/mcu/mt7628_firmware.h
#rm -rf include/mcu/mt7628_e2_firmware.h
make build_tools CHIPSET=$ChipName
## Regenerate SKU tables ##
make build_sku_tables CHIPSET=$ChipName
if [ "$1" != "auto_build" ]; then
make release WIFI_MODE=$WiFiMode CHIPSET=$ChipName RELEASE=$i
else
make release WIFI_MODE=$WiFiMode CHIPSET=$ChipName RELEASE=$i AUTO_BUILD=y
fi
if [ -d $i ]; then
lower=`echo $i | tr A-Z a-z` #transfer "DPA DPB DPC DPD" to lower case
#ReleaseDir=$ModuleName\_$lower\_$Date
ReleaseDir=$ModuleName\_$i\_$Date
#ReleaseDir=$ModuleName\_$Date
#ReleaseDir=$ModulePrefix
mv $i $TargetDir/$ReleaseDir
ReleaseDir=$TargetDir/$ReleaseDir
#if [ "$i" == "DPA" ]; then
cd $ReleaseDir/embedded
find . -name "*Card.dat" -exec rm -rf {} \; #// TODO
find . -name "*2870*.dat" -exec rm -rf {} \;
rm -rf doc/*History*.txt doc/*README* doc/RT_WIFI_Revision_History_2010_April.xls doc/RT2860card.readme
rm -rf Makefile.OSABL threadX.MakeFile vxworks.makefile History.txt RT2860AP.dat
rm -rf os/linux/Makefile.2880.*
rm -rf Release.sh load.4 load.6 load unload
#rm -rf Makefile
cd $TargetDir/embedded
#fi
### Generate profile for release ###
echo $ModulePrefix > $ReleaseDir/$release_profile
echo $DriverVersion >> $ReleaseDir/$release_profile
echo $Date >> $ReleaseDir/$release_profile
cp Pack_Release.sh $ReleaseDir/embedded
##Copy sku_tables .dat to release package##
cp -R $TargetDir/txpwr/sku_tables $ReleaseDir/txpwr/
cd $ReleaseDir/embedded
sh Pack_Release.sh $1
#tar -jcvf $ReleaseDir.tar.bz2 $ReleaseDir
else
echo "Error: ReleaseDir ($i) does not exist"
exit 1
fi
done
#####Log File#####
#if [ "$1" != "auto_build" ]; then
# cd $TargetDir/embedded
# echo "OSABL = $OSABL" > Release.log
# echo "BaseCodeDir = $BaseCodeDir" >> Release.log
# echo "ChipName = $ChipName" >> Release.log
# echo "DriverVersion = $DriverVersion" >> Release.log
#echo "BuildDir = $BuildDir" >> Release.log
# echo "Release = $Release" >> Release.log
# if [ "$Description" != "" ]; then
# echo "Description = $Description" >> Release.log
# fi
# echo "Note: $Note" >> Release.log
#fi
##################

View File

@ -1,97 +0,0 @@
[ V4.4.0.2 ]
Support function:
1. MU-MIMO support.
2. BW160 for IEEE 802.11 new standard modification.
3. Multiple default bin file support.
4. Single SKU for TxBF.
5. Repeater - WiFi Forwarding Module support
Issue Fixed:
1. Endurance and robustness enhancement.
2. DFS - Fix "channel closing time too long" issue.
3. 802.11R - Fixed AP would delete STA if STA send disassoc
frame which BSSID is AP's BSSID but DA is another AP.
4. Fix Auto Channel Selection trigger by iwpriv command.
5. Fix BA session overflow issue.
[ V4.4.0.1 ]
Support function:
1. 802.11R/802.11K I-phone compliant.
2. Single SKU table now can also take TxBF for reference.
Issue Fixed:
1. Fix throughput degrade after radio off/on.
2. Fix CCK TX Power unstable issue.
3. Reduce bootup calibration time.
4. Fix firmware download failed after s/w reboot.
5. Fix RX AMSDU reordering issue.
6. Fix Counter Measure failed to recover connection access.
7. Fix DFS NOP and CAC issue.
[ V4.4.0.0 ]
Formal Release:
Support function:
1. Tx Beamforming Support
2. Calibration Data Save in Flash Support
Issue Fixed:
1. Fixed a kernel panic issues in repeater mode under heavy traffic loading
2. Improve stability when playing video streaming and under heavy traffic loading
[ V4.4.0.0 ]
Beta release 2:
Support function:
1. DFS master mode and client mode
2. IGMP snooping
3. Single SKU
4. Tx Power Percentage
5. ApCli Connection Trial
6. LED
Issue Fixed:
1. Site survey cannot find APs in other channels
2. Correct data rate displayed in iwconfig
3. Support DFS master/slave mode
4. Support LED
5. Fix kernel panic issue during interface down/up
6. Fix scan list cannot correctly show AP with 11ac capability issue.
7. 2.4G repeater performance improvement
8. Support DFS master/slave mode
[ V4.4.0.0 ]
Beta release 1:
Support function:
1. 802.11n certification of (AP mode)
2. Band Steering
3. Thermal Protection
4. Concurrent WPS
Issue Fixed:
1. Reduce the total time of Wifi interface up
2. IOT: Fix Iphone-6/S6 set to only BW20 when connected.
3. Reduce total number of tx/rx packet token to avoid run out of system memory under heavy loading.
4. Performance improvement of multi-client/repeater/RvR(Waterfall) .
5. Fix system crash issue during interface down/up
6. Fix connection stability issue and looping issue of repeater mode.
7. Fix jitter and packet loss issues in Verivave tests.
8. Fix potential memory leackage issues.
Known issues:
1. 5G Peek Tx/Rx performance on MT7621. (around 850~940Mbps)
2. Peek throughput drop about 20~30Mbps (happens ramdonly with about 15% chances)
3. CPU loading increased about 3~5% while running peek throughput.
[ V4.4.0.0 ]
Alpha release 1:
support function:
1. 80211.ac
2. WPS
3. Apcli / MAC Repeater
4. PMF
Known issues:
1. VHT MCS8/9 not stable.
2. Repeater connection stability
3. DBDC performance
4. When peer is Ralink device, RDG+Security shows ICV Error
5. Occasionally Tx/Rx Stop (E3 fix)

File diff suppressed because it is too large Load Diff

View File

@ -1,181 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002-2006, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
ap_apcli.c
Abstract:
Support AP-Client function.
Note:
1. Call RT28xx_ApCli_Init() in init function and
call RT28xx_ApCli_Remove() in close function
2. MAC of ApCli-interface is initialized in RT28xx_ApCli_Init()
3. ApCli index (0) of different rx packet is got in
4. ApCli index (0) of different tx packet is assigned in
5. ApCli index (0) of different interface is got in tx_pkt_handle() by using
6. ApCli index (0) of IOCTL command is put in pAd->OS_Cookie->ioctl_if
8. The number of ApCli only can be 1
9. apcli convert engine subroutines, we should just take care data packet.
Revision History:
Who When What
-------------- ---------- ----------------------------------------------
Shiang, Fonchi 02-13-2007 created
*/
#define RTMP_MODULE_OS
#ifdef APCLI_SUPPORT
/*#include "rt_config.h" */
#include "rtmp_comm.h"
#include "rt_os_util.h"
#include "rt_os_net.h"
/* --------------------------------- Public -------------------------------- */
NET_DEV_STATS *RT28xx_get_ether_stats(PNET_DEV net_dev);
/*
========================================================================
Routine Description:
Init AP-Client function.
Arguments:
pAd points to our adapter
main_dev_p points to the main BSS network interface
Return Value:
None
Note:
1. Only create and initialize virtual network interfaces.
2. No main network interface here.
========================================================================
*/
VOID RT28xx_ApCli_Init(VOID *pAd, PNET_DEV main_dev_p)
{
RTMP_OS_NETDEV_OP_HOOK netDevOpHook;
/* init operation functions */
NdisZeroMemory(&netDevOpHook, sizeof(RTMP_OS_NETDEV_OP_HOOK));
netDevOpHook.open = apcli_virtual_if_open;
netDevOpHook.stop = apcli_virtual_if_close;
netDevOpHook.xmit = rt28xx_send_packets;
netDevOpHook.ioctl = rt28xx_ioctl;
netDevOpHook.get_stats = RT28xx_get_ether_stats;
RTMP_AP_IoctlHandle(pAd, NULL, CMD_RTPRIV_IOCTL_APC_INIT, 0,
&netDevOpHook, 0);
}
/*
========================================================================
Routine Description:
Open a virtual network interface.
Arguments:
dev_p which WLAN network interface
Return Value:
0: open successfully
otherwise: open fail
Note:
========================================================================
*/
INT apcli_virtual_if_open(PNET_DEV pDev)
{
VOID *pAd;
pAd = RTMP_OS_NETDEV_GET_PRIV(pDev);
ASSERT(pAd);
MTWF_LOG(DBG_CAT_CLIENT, CATCLIENT_APCLI, DBG_LVL_OFF,
("%s: ===> %s\n", RTMP_OS_NETDEV_GET_DEVNAME(pDev), __func__));
if (VIRTUAL_IF_INIT(pAd, pDev) != 0)
return -1;
if (VIRTUAL_IF_UP(pAd, pDev) != 0)
return -1;
/* increase MODULE use count */
RT_MOD_INC_USE_COUNT();
RT_MOD_HNAT_REG(pDev);
RTMP_OS_NETDEV_START_QUEUE(pDev);
#ifdef MTFWD
RTMP_OS_NETDEV_CARRIER_OFF(pDev);
#endif
return 0;
}
/*
========================================================================
Routine Description:
Close a virtual network interface.
Arguments:
dev_p which WLAN network interface
Return Value:
0: close successfully
otherwise: close fail
Note:
========================================================================
*/
INT apcli_virtual_if_close(PNET_DEV pDev)
{
VOID *pAd;
pAd = RTMP_OS_NETDEV_GET_PRIV(pDev);
ASSERT(pAd);
MTWF_LOG(DBG_CAT_CLIENT, CATCLIENT_APCLI, DBG_LVL_OFF,
("%s: ===> %s\n", RTMP_OS_NETDEV_GET_DEVNAME(pDev), __func__));
VIRTUAL_IF_DOWN(pAd, pDev);
VIRTUAL_IF_DEINIT(pAd, pDev);
RT_MOD_HNAT_DEREG(pDev);
RT_MOD_DEC_USE_COUNT();
return 0;
}
/*
========================================================================
Routine Description:
Remove ApCli-BSS network interface.
Arguments:
pAd points to our adapter
Return Value:
None
Note:
========================================================================
*/
VOID RT28xx_ApCli_Remove(VOID *pAd)
{
RTMP_AP_IoctlHandle(pAd, NULL, CMD_RTPRIV_IOCTL_APC_REMOVE, 0, NULL, 0);
}
#endif /* APCLI_SUPPORT */

View File

@ -1,512 +0,0 @@
/****************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
****************************************************************************
Module Name:
ap_ids.c
Abstract:
monitor intrusion detection condition
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#ifdef IDS_SUPPORT
#include "rt_config.h"
#define IDS_EXEC_INTV 1000 /* 1 sec */
VOID RTMPIdsStart(IN PRTMP_ADAPTER pAd)
{
if (pAd->ApCfg.IDSTimerRunning == FALSE) {
RTMPSetTimer(&pAd->ApCfg.IDSTimer, IDS_EXEC_INTV);
pAd->ApCfg.IDSTimerRunning = TRUE;
}
}
VOID RTMPIdsStop(IN PRTMP_ADAPTER pAd)
{
BOOLEAN Cancelled;
if (pAd->ApCfg.IDSTimerRunning == TRUE) {
RTMPCancelTimer(&pAd->ApCfg.IDSTimer, &Cancelled);
pAd->ApCfg.IDSTimerRunning = FALSE;
}
}
#ifdef SYSTEM_LOG_SUPPORT
VOID RTMPHandleIdsEvent(IN PRTMP_ADAPTER pAd)
{
INT i, j;
UINT32 FloodFrameCount[IW_FLOOD_EVENT_TYPE_NUM];
UINT32 FloodFrameThreshold[IW_FLOOD_EVENT_TYPE_NUM];
FloodFrameCount[0] = pAd->ApCfg.RcvdAuthCount;
FloodFrameCount[1] = pAd->ApCfg.RcvdAssocReqCount;
FloodFrameCount[2] = pAd->ApCfg.RcvdReassocReqCount;
FloodFrameCount[3] = pAd->ApCfg.RcvdProbeReqCount;
FloodFrameCount[4] = pAd->ApCfg.RcvdDisassocCount;
FloodFrameCount[5] = pAd->ApCfg.RcvdDeauthCount;
FloodFrameCount[6] = pAd->ApCfg.RcvdEapReqCount;
FloodFrameThreshold[0] = pAd->ApCfg.AuthFloodThreshold;
FloodFrameThreshold[1] = pAd->ApCfg.AssocReqFloodThreshold;
FloodFrameThreshold[2] = pAd->ApCfg.ReassocReqFloodThreshold;
FloodFrameThreshold[3] = pAd->ApCfg.ProbeReqFloodThreshold;
FloodFrameThreshold[4] = pAd->ApCfg.DisassocFloodThreshold;
FloodFrameThreshold[5] = pAd->ApCfg.DeauthFloodThreshold;
FloodFrameThreshold[6] = pAd->ApCfg.EapReqFloodThreshold;
/* trigger flooding traffic event */
for (j = 0; j < IW_FLOOD_EVENT_TYPE_NUM; j++) {
if ((FloodFrameThreshold[j] > 0) &&
(FloodFrameCount[j] > FloodFrameThreshold[j])) {
RTMPSendWirelessEvent(pAd, IW_FLOOD_AUTH_EVENT_FLAG + j,
NULL, MAIN_MBSSID, 0);
/*MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("flooding traffic event(%d) - %d\n", IW_FLOOD_AUTH_EVENT_FLAG + j, FloodFrameCount[j])); */
}
}
for (i = 0; i < pAd->ApCfg.BssidNum; i++) {
UINT32 SpoofedFrameCount[IW_SPOOF_EVENT_TYPE_NUM];
CHAR RssiOfSpoofedFrame[IW_SPOOF_EVENT_TYPE_NUM];
INT k;
SpoofedFrameCount[0] =
pAd->ApCfg.MBSSID[i].RcvdConflictSsidCount;
SpoofedFrameCount[1] =
pAd->ApCfg.MBSSID[i].RcvdSpoofedAssocRespCount;
SpoofedFrameCount[2] =
pAd->ApCfg.MBSSID[i].RcvdSpoofedReassocRespCount;
SpoofedFrameCount[3] =
pAd->ApCfg.MBSSID[i].RcvdSpoofedProbeRespCount;
SpoofedFrameCount[4] =
pAd->ApCfg.MBSSID[i].RcvdSpoofedBeaconCount;
SpoofedFrameCount[5] =
pAd->ApCfg.MBSSID[i].RcvdSpoofedDisassocCount;
SpoofedFrameCount[6] =
pAd->ApCfg.MBSSID[i].RcvdSpoofedAuthCount;
SpoofedFrameCount[7] =
pAd->ApCfg.MBSSID[i].RcvdSpoofedDeauthCount;
SpoofedFrameCount[8] =
pAd->ApCfg.MBSSID[i].RcvdSpoofedUnknownMgmtCount;
SpoofedFrameCount[9] =
pAd->ApCfg.MBSSID[i].RcvdReplayAttackCount;
RssiOfSpoofedFrame[0] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdConflictSsid;
RssiOfSpoofedFrame[1] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedAssocResp;
RssiOfSpoofedFrame[2] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedReassocResp;
RssiOfSpoofedFrame[3] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedProbeResp;
RssiOfSpoofedFrame[4] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedBeacon;
RssiOfSpoofedFrame[5] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedDisassoc;
RssiOfSpoofedFrame[6] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedAuth;
RssiOfSpoofedFrame[7] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedDeauth;
RssiOfSpoofedFrame[8] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedUnknownMgmt;
RssiOfSpoofedFrame[9] =
pAd->ApCfg.MBSSID[i].RssiOfRcvdReplayAttack;
/* trigger spoofed attack event */
for (k = 0; k < IW_SPOOF_EVENT_TYPE_NUM; k++) {
if (SpoofedFrameCount[k] > 0) {
RTMPSendWirelessEvent(
pAd, IW_CONFLICT_SSID_EVENT_FLAG + k,
NULL, i, RssiOfSpoofedFrame[k]);
/*MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("spoofed attack event(%d) - %d\n", IW_CONFLICT_SSID_EVENT_FLAG + k, SpoofedFrameCount[k])); */
}
}
}
}
#endif /* SYSTEM_LOG_SUPPORT */
VOID RTMPClearAllIdsCounter(IN PRTMP_ADAPTER pAd)
{
INT i;
pAd->ApCfg.RcvdAuthCount = 0;
pAd->ApCfg.RcvdAssocReqCount = 0;
pAd->ApCfg.RcvdReassocReqCount = 0;
pAd->ApCfg.RcvdProbeReqCount = 0;
pAd->ApCfg.RcvdDisassocCount = 0;
pAd->ApCfg.RcvdDeauthCount = 0;
pAd->ApCfg.RcvdEapReqCount = 0;
pAd->ApCfg.RcvdMaliciousDataCount = 0;
for (i = 0; i < pAd->ApCfg.BssidNum; i++) {
pAd->ApCfg.MBSSID[i].RcvdConflictSsidCount = 0;
pAd->ApCfg.MBSSID[i].RcvdSpoofedAssocRespCount = 0;
pAd->ApCfg.MBSSID[i].RcvdSpoofedReassocRespCount = 0;
pAd->ApCfg.MBSSID[i].RcvdSpoofedProbeRespCount = 0;
pAd->ApCfg.MBSSID[i].RcvdSpoofedBeaconCount = 0;
pAd->ApCfg.MBSSID[i].RcvdSpoofedDisassocCount = 0;
pAd->ApCfg.MBSSID[i].RcvdSpoofedAuthCount = 0;
pAd->ApCfg.MBSSID[i].RcvdSpoofedDeauthCount = 0;
pAd->ApCfg.MBSSID[i].RcvdSpoofedUnknownMgmtCount = 0;
pAd->ApCfg.MBSSID[i].RcvdReplayAttackCount = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdConflictSsid = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedAssocResp = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedReassocResp = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedProbeResp = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedBeacon = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedDisassoc = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedAuth = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedDeauth = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedUnknownMgmt = 0;
pAd->ApCfg.MBSSID[i].RssiOfRcvdReplayAttack = 0;
}
}
VOID RTMPIdsPeriodicExec(IN PVOID SystemSpecific1, IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
PRTMP_ADAPTER pAd = (RTMP_ADAPTER *)FunctionContext;
pAd->ApCfg.IDSTimerRunning = FALSE;
#ifdef SYSTEM_LOG_SUPPORT
/* when IDS occured, send out wireless event */
if (pAd->CommonCfg.bWirelessEvent)
RTMPHandleIdsEvent(pAd);
#endif /* SYSTEM_LOG_SUPPORT */
/* clear all IDS counter */
RTMPClearAllIdsCounter(pAd);
/* set timer */
if (pAd->ApCfg.IdsEnable) {
RTMPSetTimer(&pAd->ApCfg.IDSTimer, IDS_EXEC_INTV);
pAd->ApCfg.IDSTimerRunning = TRUE;
}
}
/*
========================================================================
Routine Description:
This routine is used to check if a rogue AP sent an 802.11 management
frame to a client using our BSSID.
Arguments:
pAd - Pointer to our adapter
pHeader - Pointer to 802.11 header
Return Value:
TRUE - This is a spoofed frame
FALSE - This isn't a spoofed frame
========================================================================
*/
BOOLEAN RTMPSpoofedMgmtDetection(IN RTMP_ADAPTER *pAd, IN RX_BLK *rxblk)
{
INT i;
FRAME_CONTROL *FC = (FRAME_CONTROL *)rxblk->FC;
for (i = 0; i < pAd->ApCfg.BssidNum; i++) {
/* Spoofed BSSID detection */
if (NdisEqualMemory(rxblk->Addr2,
pAd->ApCfg.MBSSID[i].wdev.bssid,
MAC_ADDR_LEN)) {
CHAR RcvdRssi;
struct raw_rssi_info rssi_info;
rssi_info.raw_rssi[0] = rxblk->rx_signal.raw_rssi[0];
rssi_info.raw_rssi[1] = rxblk->rx_signal.raw_rssi[1];
rssi_info.raw_rssi[2] = rxblk->rx_signal.raw_rssi[2];
#if defined(CUSTOMER_DCC_FEATURE) || defined(CONFIG_MAP_SUPPORT)
rssi_info.raw_rssi[3] = rxblk->rx_signal.raw_rssi[3];
#endif
RcvdRssi = RTMPMaxRssi(
pAd, ConvertToRssi(pAd, &rssi_info, RSSI_IDX_0),
ConvertToRssi(pAd, &rssi_info, RSSI_IDX_1),
ConvertToRssi(pAd, &rssi_info, RSSI_IDX_2)
#if defined(CUSTOMER_DCC_FEATURE) || defined(CONFIG_MAP_SUPPORT)
,
ConvertToRssi(pAd, &rssi_info, RSSI_IDX_3)
#endif
);
switch (FC->SubType) {
case SUBTYPE_ASSOC_RSP:
pAd->ApCfg.MBSSID[i].RcvdSpoofedAssocRespCount++;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedAssocResp =
RcvdRssi;
break;
case SUBTYPE_REASSOC_RSP:
pAd->ApCfg.MBSSID[i]
.RcvdSpoofedReassocRespCount++;
pAd->ApCfg.MBSSID[i]
.RssiOfRcvdSpoofedReassocResp =
RcvdRssi;
break;
case SUBTYPE_PROBE_RSP:
pAd->ApCfg.MBSSID[i].RcvdSpoofedProbeRespCount++;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedProbeResp =
RcvdRssi;
break;
case SUBTYPE_BEACON:
pAd->ApCfg.MBSSID[i].RcvdSpoofedBeaconCount++;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedBeacon =
RcvdRssi;
break;
case SUBTYPE_DISASSOC:
pAd->ApCfg.MBSSID[i].RcvdSpoofedDisassocCount++;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedDisassoc =
RcvdRssi;
break;
case SUBTYPE_AUTH:
pAd->ApCfg.MBSSID[i].RcvdSpoofedAuthCount++;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedAuth =
RcvdRssi;
break;
case SUBTYPE_DEAUTH:
pAd->ApCfg.MBSSID[i].RcvdSpoofedDeauthCount++;
pAd->ApCfg.MBSSID[i].RssiOfRcvdSpoofedDeauth =
RcvdRssi;
break;
default:
pAd->ApCfg.MBSSID[i]
.RcvdSpoofedUnknownMgmtCount++;
pAd->ApCfg.MBSSID[i]
.RssiOfRcvdSpoofedUnknownMgmt =
RcvdRssi;
break;
}
return TRUE;
}
}
return FALSE;
}
VOID RTMPConflictSsidDetection(IN PRTMP_ADAPTER pAd, IN PUCHAR pSsid,
IN UCHAR SsidLen, IN CHAR Rssi0, IN CHAR Rssi1,
IN CHAR Rssi2
#if defined(CUSTOMER_DCC_FEATURE) || defined(CONFIG_MAP_SUPPORT)
,
IN CHAR Rssi3
#endif
)
{
INT i;
for (i = 0; i < pAd->ApCfg.BssidNum; i++) {
/* Conflict SSID detection */
if (SSID_EQUAL(pSsid, SsidLen, pAd->ApCfg.MBSSID[i].Ssid,
pAd->ApCfg.MBSSID[i].SsidLen)) {
CHAR RcvdRssi;
struct raw_rssi_info rssi_info;
rssi_info.raw_rssi[0] = Rssi0;
rssi_info.raw_rssi[1] = Rssi1;
rssi_info.raw_rssi[2] = Rssi2;
#if defined(CUSTOMER_DCC_FEATURE) || defined(CONFIG_MAP_SUPPORT)
rssi_info.raw_rssi[3] = Rssi3;
#endif
RcvdRssi = RTMPMaxRssi(
pAd, ConvertToRssi(pAd, &rssi_info, RSSI_IDX_0),
ConvertToRssi(pAd, &rssi_info, RSSI_IDX_1),
ConvertToRssi(pAd, &rssi_info, RSSI_IDX_2)
#if defined(CUSTOMER_DCC_FEATURE) || defined(CONFIG_MAP_SUPPORT)
,
ConvertToRssi(pAd, &rssi_info, RSSI_IDX_3)
#endif
);
pAd->ApCfg.MBSSID[i].RcvdConflictSsidCount++;
pAd->ApCfg.MBSSID[i].RssiOfRcvdConflictSsid = RcvdRssi;
return;
}
}
}
BOOLEAN RTMPReplayAttackDetection(IN RTMP_ADAPTER *pAd, IN UCHAR *pAddr2,
IN RX_BLK *rxblk)
{
INT i;
for (i = 0; i < pAd->ApCfg.BssidNum; i++) {
/* Conflict SSID detection */
if (NdisEqualMemory(pAddr2, pAd->ApCfg.MBSSID[i].wdev.bssid,
MAC_ADDR_LEN)) {
CHAR RcvdRssi;
struct raw_rssi_info rssi_info;
rssi_info.raw_rssi[0] = rxblk->rx_signal.raw_rssi[0];
rssi_info.raw_rssi[1] = rxblk->rx_signal.raw_rssi[1];
rssi_info.raw_rssi[2] = rxblk->rx_signal.raw_rssi[2];
#if defined(CUSTOMER_DCC_FEATURE) || defined(CONFIG_MAP_SUPPORT)
rssi_info.raw_rssi[3] = rxblk->rx_signal.raw_rssi[3];
#endif
RcvdRssi = RTMPMaxRssi(
pAd, ConvertToRssi(pAd, &rssi_info, RSSI_IDX_0),
ConvertToRssi(pAd, &rssi_info, RSSI_IDX_1),
ConvertToRssi(pAd, &rssi_info, RSSI_IDX_2)
#if defined(CUSTOMER_DCC_FEATURE) || defined(CONFIG_MAP_SUPPORT)
,
ConvertToRssi(pAd, &rssi_info, RSSI_IDX_3)
#endif
);
pAd->ApCfg.MBSSID[i].RcvdReplayAttackCount++;
pAd->ApCfg.MBSSID[i].RssiOfRcvdReplayAttack = RcvdRssi;
return TRUE;
}
}
return FALSE;
}
VOID RTMPUpdateStaMgmtCounter(RTMP_ADAPTER *pAd, USHORT type)
{
switch (type) {
case SUBTYPE_ASSOC_REQ:
pAd->ApCfg.RcvdAssocReqCount++;
break;
case SUBTYPE_REASSOC_REQ:
pAd->ApCfg.RcvdReassocReqCount++;
break;
case SUBTYPE_PROBE_REQ:
pAd->ApCfg.RcvdProbeReqCount++;
break;
case SUBTYPE_DISASSOC:
pAd->ApCfg.RcvdDisassocCount++;
break;
case SUBTYPE_DEAUTH:
pAd->ApCfg.RcvdDeauthCount++;
break;
case SUBTYPE_AUTH:
pAd->ApCfg.RcvdAuthCount++;
break;
}
/*
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("RcvdAssocReqCount=%d\n", pAd->ApCfg.RcvdAssocReqCount));
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("RcvdReassocReqCount=%d\n", pAd->ApCfg.RcvdReassocReqCount));
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("RcvdProbeReqCount=%d\n", pAd->ApCfg.RcvdProbeReqCount));
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("RcvdDisassocCount=%d\n", pAd->ApCfg.RcvdDisassocCount));
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("RcvdDeauthCount=%d\n", pAd->ApCfg.RcvdDeauthCount));
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("RcvdAuthCount=%d\n", pAd->ApCfg.RcvdAuthCount));
*/
}
VOID rtmp_read_ids_from_file(IN PRTMP_ADAPTER pAd, RTMP_STRING *tmpbuf,
RTMP_STRING *buffer)
{
/*IdsEnable */
if (RTMPGetKeyParameter("IdsEnable", tmpbuf, 10, buffer, TRUE)) {
if (os_str_tol(tmpbuf, 0, 10) == 1)
pAd->ApCfg.IdsEnable = TRUE;
else
pAd->ApCfg.IdsEnable = FALSE;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("IDS is %s\n",
pAd->ApCfg.IdsEnable ? "enabled" : "disabled"));
}
/*AuthFloodThreshold */
if (RTMPGetKeyParameter("AuthFloodThreshold", tmpbuf, 10, buffer,
TRUE)) {
pAd->ApCfg.AuthFloodThreshold = os_str_tol(tmpbuf, 0, 10);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("AuthFloodThreshold = %d\n",
pAd->ApCfg.AuthFloodThreshold));
}
/*AssocReqFloodThreshold */
if (RTMPGetKeyParameter("AssocReqFloodThreshold", tmpbuf, 10, buffer,
TRUE)) {
pAd->ApCfg.AssocReqFloodThreshold = os_str_tol(tmpbuf, 0, 10);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("AssocReqFloodThreshold = %d\n",
pAd->ApCfg.AssocReqFloodThreshold));
}
/*ReassocReqFloodThreshold */
if (RTMPGetKeyParameter("ReassocReqFloodThreshold", tmpbuf, 10, buffer,
TRUE)) {
pAd->ApCfg.ReassocReqFloodThreshold = os_str_tol(tmpbuf, 0, 10);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("ReassocReqFloodThreshold = %d\n",
pAd->ApCfg.ReassocReqFloodThreshold));
}
/*ProbeReqFloodThreshold */
if (RTMPGetKeyParameter("ProbeReqFloodThreshold", tmpbuf, 10, buffer,
TRUE)) {
pAd->ApCfg.ProbeReqFloodThreshold = os_str_tol(tmpbuf, 0, 10);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("ProbeReqFloodThreshold = %d\n",
pAd->ApCfg.ProbeReqFloodThreshold));
}
/*DisassocFloodThreshold */
if (RTMPGetKeyParameter("DisassocFloodThreshold", tmpbuf, 10, buffer,
TRUE)) {
pAd->ApCfg.DisassocFloodThreshold = os_str_tol(tmpbuf, 0, 10);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("DisassocFloodThreshold = %d\n",
pAd->ApCfg.DisassocFloodThreshold));
}
/*DeauthFloodThreshold */
if (RTMPGetKeyParameter("DeauthFloodThreshold", tmpbuf, 10, buffer,
TRUE)) {
pAd->ApCfg.DeauthFloodThreshold = os_str_tol(tmpbuf, 0, 10);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("DeauthFloodThreshold = %d\n",
pAd->ApCfg.DeauthFloodThreshold));
}
/*EapReqFloodThreshold */
if (RTMPGetKeyParameter("EapReqFloodThreshold", tmpbuf, 10, buffer,
TRUE)) {
pAd->ApCfg.EapReqFloodThreshold = os_str_tol(tmpbuf, 0, 10);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("EapReqFloodThreshold = %d\n",
pAd->ApCfg.EapReqFloodThreshold));
}
/* DataFloodThreshold */
if (RTMPGetKeyParameter("DataFloodThreshold", tmpbuf, 10, buffer,
TRUE)) {
pAd->ApCfg.DataFloodThreshold = os_str_tol(tmpbuf, 0, 10);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("DataFloodThreshold = %d\n",
pAd->ApCfg.DataFloodThreshold));
}
}
#endif /* IDS_SUPPORT */

View File

@ -1,381 +0,0 @@
/****************************************************************************
* Ralink Tech Inc.
* Taiwan, R.O.C.
*
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************/
/****************************************************************************
Abstract:
Support multi-BSS function.
Note:
1. Call RT28xx_MBSS_Init() in init function and
call RT28xx_MBSS_Remove() in close function
2. MAC of different BSS is initialized in APStartUp()
3. BSS Index (0 ~ 15) of different rx packet is got in
4. BSS Index (0 ~ 15) of different tx packet is assigned in
5. BSS Index (0 ~ 15) of different BSS is got in tx_pkt_handle() by using
6. BSS Index (0 ~ 15) of IOCTL command is put in pAd->OS_Cookie->ioctl_if
7. Beacon of different BSS is enabled in APMakeAllBssBeacon() by writing 1
to the register MAC_BSSID_DW1
8. The number of MBSS can be 1, 2, 4, or 8
***************************************************************************/
#ifdef MBSS_SUPPORT
#include "rt_config.h"
#ifdef VENDOR_FEATURE7_SUPPORT
#ifndef ARRIS_MODULE_PRESENT
void (*f)(int, int, int, char *, int) = arris_event_send_hook_fn;
#endif /* !ARRIS_MODULE_PRESENT */
#endif
#ifdef MULTI_PROFILE
INT multi_profile_devname_req(struct _RTMP_ADAPTER *ad, UCHAR *final_name,
UCHAR *ifidx);
#endif /*MULTI_PROFILE*/
extern struct wifi_dev_ops ap_wdev_ops;
/* --------------------------------- Public -------------------------------- */
/*
========================================================================
Routine Description:
Initialize Multi-BSS function.
Arguments:
pAd points to our adapter
pDevMain points to the main BSS network interface
Return Value:
None
Note:
1. Only create and initialize virtual network interfaces.
2. No main network interface here.
3. If you down ra0 and modify the BssNum of RT2860AP.dat/RT2870AP.dat,
it will not work! You must rmmod rt2860ap.ko and lsmod rt2860ap.ko again.
========================================================================
*/
VOID MBSS_Init(RTMP_ADAPTER *pAd, RTMP_OS_NETDEV_OP_HOOK *pNetDevOps)
{
#define MBSS_MAX_DEV_NUM 32
PNET_DEV pDevNew;
INT32 IdBss, MaxNumBss;
INT status;
RTMP_OS_NETDEV_OP_HOOK netDevHook;
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
/* sanity check to avoid redundant virtual interfaces are created */
if (pAd->FlgMbssInit != FALSE)
return;
#ifdef CREATE_ALL_INTERFACE_AT_INIT
/* Create and initialize all 8 MBSS interfaces duirng
* driver insmod as part of customer requirement
*/
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF, ("Set 8 Max BSS\n"));
pAd->ApCfg.BssidNum = MAX_MBSS_NUM;
#endif
MaxNumBss = pAd->ApCfg.BssidNum;
if (MaxNumBss > HW_BEACON_MAX_NUM)
MaxNumBss = HW_BEACON_MAX_NUM;
/* first IdBss must not be 0 (BSS0), must be 1 (BSS1) */
for (IdBss = FIRST_MBSSID; IdBss < HW_BEACON_MAX_NUM; IdBss++) {
pAd->ApCfg.MBSSID[IdBss].wdev.if_dev = NULL;
pAd->ApCfg.MBSSID[IdBss].wdev.bcn_buf.BeaconPkt = NULL;
}
/* create virtual network interface */
for (IdBss = FIRST_MBSSID; IdBss < MaxNumBss; IdBss++) {
struct wifi_dev *wdev;
UINT32 MC_RowID = 0, IoctlIF = 0;
char *dev_name = NULL;
INT32 Ret;
BSS_STRUCT *pMbss = NULL;
UCHAR ifidx = IdBss;
UCHAR final_name[32] = "";
BOOLEAN autoSuffix = TRUE;
#ifdef MULTIPLE_CARD_SUPPORT
MC_RowID = pAd->MC_RowID;
#endif /* MULTIPLE_CARD_SUPPORT */
#ifdef HOSTAPD_SUPPORT
IoctlIF = pAd->IoctlIF;
#endif /* HOSTAPD_SUPPORT */
dev_name = get_dev_name_prefix(pAd, INT_MBSSID);
if (dev_name == NULL) {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("get_dev_name_prefix error!\n"));
break;
}
snprintf(final_name, sizeof(final_name), "%s", dev_name);
#ifdef MULTI_PROFILE
multi_profile_devname_req(pAd, final_name, &ifidx);
if (ifidx == 0)
autoSuffix = FALSE;
#endif /*MULTI_PROFILE*/
#ifdef INTELP6_SUPPORT
#ifdef CONFIG_RT_SECOND_CARD
if (pAd->dev_idx == 1)
pDevNew = RtmpOSNetDevCreate(MC_RowID, &IoctlIF,
INT_MBSSID,
IdBss + MAX_MBSS_NUM,
sizeof(struct mt_dev_priv),
dev_name, autoSuffix);
else
#endif
#endif
pDevNew = RtmpOSNetDevCreate(MC_RowID, &IoctlIF,
INT_MBSSID, ifidx,
sizeof(struct mt_dev_priv),
final_name, autoSuffix);
#ifdef HOSTAPD_SUPPORT
pAd->IoctlIF = IoctlIF;
#endif /* HOSTAPD_SUPPORT */
if (pDevNew == NULL) {
pAd->ApCfg.BssidNum =
IdBss; /* re-assign new MBSS number */
break;
}
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Register MBSSID IF (%s)\n",
RTMP_OS_NETDEV_GET_DEVNAME(pDevNew)));
pMbss = &pAd->ApCfg.MBSSID[IdBss];
wdev = &pAd->ApCfg.MBSSID[IdBss].wdev;
Ret = wdev_init(pAd, wdev, WDEV_TYPE_AP, pDevNew, IdBss,
(VOID *)&pAd->ApCfg.MBSSID[IdBss], (void *)pAd);
if (!Ret) {
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("Assign wdev idx for %s failed, free net device!\n",
RTMP_OS_NETDEV_GET_DEVNAME(pDevNew)));
RtmpOSNetDevFree(pDevNew);
break;
}
Ret = wdev_ops_register(wdev, WDEV_TYPE_AP, &ap_wdev_ops,
cap->wmm_detect_method);
if (!Ret) {
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("register wdev_ops %s failed, free net device!\n",
RTMP_OS_NETDEV_GET_DEVNAME(pDevNew)));
RtmpOSNetDevFree(pDevNew);
break;
}
RTMP_OS_NETDEV_SET_PRIV(pDevNew, pAd);
RTMP_OS_NETDEV_SET_WDEV(pDevNew, wdev);
/* init operation functions and flags */
NdisCopyMemory(&netDevHook, pNetDevOps, sizeof(netDevHook));
netDevHook.priv_flags = INT_MBSSID;
#ifdef CREATE_ALL_INTERFACE_AT_INIT
netDevHook.needProtcted = FALSE;
#else
netDevHook.needProtcted = TRUE;
#endif
netDevHook.wdev = wdev;
/* Init MAC address of virtual network interface */
NdisMoveMemory(&netDevHook.devAddr[0], &wdev->bssid[0],
MAC_ADDR_LEN);
#ifdef RT_CFG80211_SUPPORT
{
struct wireless_dev *pWdev;
CFG80211_CB *p80211CB = pAd->pCfg80211_CB;
UINT32 DevType = RT_CMD_80211_IFTYPE_AP;
os_alloc_mem_suspend(NULL, (UCHAR **)&pWdev,
sizeof(*pWdev));
if (!pWdev) {
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL,
DBG_LVL_ERROR,
("mem alloc failed for %s, free net device!\n",
RTMP_OS_NETDEV_GET_DEVNAME(pDevNew)));
RtmpOSNetDevFree(pDevNew);
break;
}
os_zero_mem((PUCHAR)pWdev, sizeof(*pWdev));
pDevNew->ieee80211_ptr = pWdev;
pWdev->wiphy = p80211CB->pCfg80211_Wdev->wiphy;
SET_NETDEV_DEV(pDevNew, wiphy_dev(pWdev->wiphy));
pWdev->netdev = pDevNew;
pWdev->iftype = DevType;
}
#endif /* RT_CFG80211_SUPPORT */
/* register this device to OS */
status = RtmpOSNetDevAttach(pAd->OpMode, pDevNew, &netDevHook);
#ifdef CONFIG_MAP_SUPPORT
if (IS_MAP_TURNKEY_ENABLE(pAd)) {
if (wdev && wdev->wdev_type == WDEV_TYPE_AP)
map_make_vend_ie(pAd, IdBss);
}
#endif /* CONFIG_MAP_SUPPORT */
}
pAd->FlgMbssInit = TRUE;
#ifdef MAP_R2
if (IS_MAP_ENABLE(pAd))
MtCmdSetRxTxAirtimeEn(
pAd, ENUM_RX_AT_FEATURE_SUB_TYPE_AIRTIME_EN, TRUE);
#endif
}
/*
========================================================================
Routine Description:
Remove Multi-BSS network interface.
Arguments:
pAd points to our adapter
Return Value:
None
Note:
FIRST_MBSSID = 1
Main BSS is not removed here.
========================================================================
*/
VOID MBSS_Remove(RTMP_ADAPTER *pAd)
{
struct wifi_dev *wdev;
UINT IdBss;
BSS_STRUCT *pMbss;
INT32 MaxNumBss;
if (!pAd)
return;
MaxNumBss = pAd->ApCfg.BssidNum;
if (MaxNumBss > HW_BEACON_MAX_NUM)
MaxNumBss = HW_BEACON_MAX_NUM;
for (IdBss = FIRST_MBSSID; IdBss < MaxNumBss; IdBss++) {
wdev = &pAd->ApCfg.MBSSID[IdBss].wdev;
pMbss = &pAd->ApCfg.MBSSID[IdBss];
if (pMbss)
bcn_buf_deinit(pAd, &wdev->bcn_buf);
if (wdev->if_dev) {
RtmpOSNetDevProtect(1);
RtmpOSNetDevDetach(wdev->if_dev);
RtmpOSNetDevProtect(0);
wdev_deinit(pAd, wdev);
#ifdef RT_CFG80211_SUPPORT
os_free_mem(wdev->if_dev->ieee80211_ptr);
wdev->if_dev->ieee80211_ptr = NULL;
#endif /* RT_CFG80211_SUPPORT */
RtmpOSNetDevFree(wdev->if_dev);
wdev->if_dev = NULL;
}
}
}
/*
========================================================================
Routine Description:
Get multiple bss idx.
Arguments:
pAd points to our adapter
pDev which WLAN network interface
Return Value:
0: close successfully
otherwise: close fail
Note:
========================================================================
*/
INT32 RT28xx_MBSS_IdxGet(RTMP_ADAPTER *pAd, PNET_DEV pDev)
{
INT32 BssId = -1;
INT32 IdBss;
if (!pAd || !pDev)
return -1;
for (IdBss = 0; IdBss < pAd->ApCfg.BssidNum; IdBss++) {
if (pAd->ApCfg.MBSSID[IdBss].wdev.if_dev == pDev) {
BssId = IdBss;
break;
}
}
return BssId;
}
#ifdef MT_MAC
INT32 ext_mbss_hw_cr_enable(PNET_DEV pDev)
{
PRTMP_ADAPTER pAd;
INT BssId;
pAd = RTMP_OS_NETDEV_GET_PRIV(pDev);
BssId = RT28xx_MBSS_IdxGet(pAd, pDev);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("##### %s, BssId = %d\n", __func__, BssId));
if (BssId < 0)
return -1;
if (!IS_HIF_TYPE(pAd, HIF_MT))
return 0;
AsicSetExtMbssEnableCR(pAd, BssId, TRUE); /* enable rmac 0_1~0_15 bit */
AsicSetMbssHwCRSetting(
pAd, BssId, TRUE); /* enable lp timing setting for 0_1~0_15 */
return 0;
}
INT ext_mbss_hw_cr_disable(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;
if (!IS_HIF_TYPE(pAd, HIF_MT))
return 0;
AsicSetMbssHwCRSetting(pAd, BssId, FALSE);
AsicSetExtMbssEnableCR(pAd, BssId, FALSE);
return 0;
}
#endif /* MT_MAC */
#endif /* MBSS_SUPPORT */

View File

@ -1,181 +0,0 @@
/****************************************************************************
* Ralink Tech Inc.
* Taiwan, R.O.C.
*
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************/
/****************************************************************************
Abstract:
Support multi-BSS function.
Note:
1. Call RT28xx_MBSS_Init() in init function and
call RT28xx_MBSS_Remove() in close function
2. MAC of different BSS is initialized in APStartUp()
3. BSS Index (0 ~ 15) of different rx packet is got in
4. BSS Index (0 ~ 15) of different tx packet is assigned in
5. BSS Index (0 ~ 15) of different BSS is got in ap_tx_pkt_handle() by using
6. BSS Index (0 ~ 15) of IOCTL command is put in pAd->OS_Cookie->ioctl_if
7. Beacon of different BSS is enabled in APMakeAllBssBeacon() by writing 1
to the register MAC_BSSID_DW1
8. The number of MBSS can be 1, 2, 4, or 8
***************************************************************************/
#define RTMP_MODULE_OS
#ifdef MBSS_SUPPORT
/*#include "rt_config.h" */
#include "rtmp_comm.h"
#include "rt_os_util.h"
#include "rt_os_net.h"
/* --------------------------------- Public -------------------------------- */
NET_DEV_STATS *RT28xx_get_ether_stats(PNET_DEV net_dev);
/*
========================================================================
Routine Description:
Initialize Multi-BSS function.
Arguments:
pAd points to our adapter
pDevMain points to the main BSS network interface
Return Value:
None
Note:
1. Only create and initialize virtual network interfaces.
2. No main network interface here.
3. If you down ra0 and modify the BssNum of RT2860AP.dat/RT2870AP.dat,
it will not work! You must rmmod rt2860ap.ko and lsmod rt2860ap.ko again.
========================================================================
*/
VOID RT28xx_MBSS_Init(VOID *pAd, PNET_DEV pDevMain)
{
RTMP_OS_NETDEV_OP_HOOK netDevHook;
NdisZeroMemory(&netDevHook, sizeof(netDevHook));
netDevHook.open = mbss_virtual_if_open; /* device opem hook point */
netDevHook.stop = mbss_virtual_if_close; /* device close hook point */
netDevHook.xmit = rt28xx_send_packets; /* hard transmit hook point */
netDevHook.ioctl = rt28xx_ioctl; /* ioctl hook point */
netDevHook.get_stats = RT28xx_get_ether_stats;
RTMP_AP_IoctlHandle(pAd, NULL, CMD_RTPRIV_IOCTL_MBSS_INIT, 0,
&netDevHook, 0);
}
/*
========================================================================
Routine Description:
Remove Multi-BSS network interface.
Arguments:
pAd points to our adapter
Return Value:
None
Note:
FIRST_MBSSID = 1
Main BSS is not removed here.
========================================================================
*/
VOID RT28xx_MBSS_Remove(VOID *pAd)
{
RTMP_AP_IoctlHandle(pAd, NULL, CMD_RTPRIV_IOCTL_MBSS_REMOVE, 0, NULL,
0);
}
/* --------------------------------- Private -------------------------------- */
/*
========================================================================
Routine Description:
Open a virtual network interface.
Arguments:
pDev which WLAN network interface
Return Value:
0: open successfully
otherwise: open fail
Note:
========================================================================
*/
INT mbss_virtual_if_open(PNET_DEV pDev)
{
VOID *pAd;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%s: ===> %s\n", RTMP_OS_NETDEV_GET_DEVNAME(pDev), __func__));
pAd = RTMP_OS_NETDEV_GET_PRIV(pDev);
if (VIRTUAL_IF_INIT(pAd, pDev) != 0)
return -1;
if (VIRTUAL_IF_UP(pAd, pDev) != 0)
return -1;
/* increase MODULE use count */
RT_MOD_INC_USE_COUNT();
RT_MOD_HNAT_REG(pDev);
RTMP_OS_NETDEV_START_QUEUE(pDev);
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_virtual_if_close(PNET_DEV pDev)
{
VOID *pAd;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%s: ===> %s\n", RTMP_OS_NETDEV_GET_DEVNAME(pDev), __func__));
pAd = RTMP_OS_NETDEV_GET_PRIV(pDev);
RTMP_OS_NETDEV_STOP_QUEUE(pDev);
VIRTUAL_IF_DOWN(pAd, pDev);
VIRTUAL_IF_DEINIT(pAd, pDev);
RT_MOD_HNAT_DEREG(pDev);
RT_MOD_DEC_USE_COUNT();
return 0;
}
#endif /* MBSS_SUPPORT */

View File

@ -1,861 +0,0 @@
/****************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
****************************************************************************
Module Name:
mlme.c
Abstract:
Major MLME state machiones here
Revision History:
Who When What
-------- ---------- ----------------------------------------------
John Chang 08-04-2003 created for 11g soft-AP
*/
#include "rt_config.h"
#include <stdarg.h>
#define MCAST_WCID_TO_REMOVE 0 /* Pat: TODO */
#ifdef APCLI_SUPPORT
#ifdef APCLI_CERT_SUPPORT
extern UCHAR ZeroSsid[32];
#endif /* APCLI_CERT_SUPPORT */
#endif /* APCLI_SUPPORT */
#ifdef DOT11_N_SUPPORT
int DetectOverlappingPeriodicRound;
#ifdef DOT11N_DRAFT3
VOID Bss2040CoexistTimeOut(IN PVOID SystemSpecific1, IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
int apidx;
PRTMP_ADAPTER pAd = (RTMP_ADAPTER *)FunctionContext;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Bss2040CoexistTimeOut(): Recovery to original setting!\n"));
/* Recovery to original setting when next DTIM Interval. */
pAd->CommonCfg.Bss2040CoexistFlag &= (~BSS_2040_COEXIST_TIMER_FIRED);
NdisZeroMemory(&pAd->CommonCfg.LastBSSCoexist2040,
sizeof(BSS_2040_COEXIST_IE));
pAd->CommonCfg.Bss2040CoexistFlag |= BSS_2040_COEXIST_INFO_SYNC;
if (pAd->CommonCfg.bBssCoexEnable == FALSE) {
/* TODO: Find a better way to handle this when the timer is fired and we disable the bBssCoexEable support!! */
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Bss2040CoexistTimeOut(): bBssCoexEnable is FALSE, return directly!\n"));
return;
}
for (apidx = 0; apidx < pAd->ApCfg.BssidNum; apidx++)
SendBSS2040CoexistMgmtAction(pAd, MCAST_WCID_TO_REMOVE, apidx,
0);
}
#endif /* DOT11N_DRAFT3 */
#endif /* DOT11_N_SUPPORT */
VOID APDetectOverlappingExec(IN PVOID SystemSpecific1, IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
#ifdef DOT11_N_SUPPORT
PRTMP_ADAPTER pAd = (RTMP_ADAPTER *)FunctionContext;
struct freq_oper oper;
BOOLEAN bSupport2G = HcIsRfSupport(pAd, RFIC_24GHZ);
int i;
struct wifi_dev *wdev;
UCHAR cfg_ht_bw;
UCHAR cfg_ext_cha;
if (DetectOverlappingPeriodicRound == 0) {
/* switch back 20/40 */
if (bSupport2G) {
for (i = 0; i < pAd->ApCfg.BssidNum; i++) {
wdev = &pAd->ApCfg.MBSSID[i].wdev;
cfg_ht_bw = wlan_config_get_ht_bw(wdev);
if (wmode_2_rfic(wdev->PhyMode) == RFIC_24GHZ &&
(cfg_ht_bw == HT_BW_40)) {
cfg_ext_cha =
wlan_config_get_ext_cha(wdev);
wlan_operate_set_ht_bw(wdev, HT_BW_40,
cfg_ext_cha);
}
}
}
} else {
if ((DetectOverlappingPeriodicRound == 25) ||
(DetectOverlappingPeriodicRound == 1)) {
if (hc_radio_query_by_rf(pAd, RFIC_24GHZ, &oper) !=
HC_STATUS_OK) {
return;
}
if (oper.ht_bw == HT_BW_40) {
SendBeaconRequest(pAd, 1);
SendBeaconRequest(pAd, 2);
SendBeaconRequest(pAd, 3);
}
}
DetectOverlappingPeriodicRound--;
}
#endif /* DOT11_N_SUPPORT */
}
/*
==========================================================================
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)
{
#ifdef A_BAND_SUPPORT
BOOLEAN bSupport5G = HcIsRfSupport(pAd, RFIC_5GHZ);
#ifdef MT_DFS_SUPPORT
USHORT ChannelMovingTime;
#endif
#endif /*A_BAND_SUPPORT*/
#ifdef A4_CONN
UCHAR mbss_idx;
#endif
#ifdef CUSTOMER_DCC_FEATURE
if (pAd->AllowedStaList.StaCount > 0)
RemoveOldStaList(pAd);
APResetStreamingStatus(pAd);
#endif
#ifdef CUSTOMER_DCC_FEATURE
if (pAd->ApEnableBeaconTable == TRUE)
RemoveOldBssEntry(pAd);
#endif
/*
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 != DBG_LVL_TRACE) {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL,
DBG_LVL_TRACE, ("Carrier gone\n"));
/* start all TX actions. */
UpdateBeaconHandler(pAd, NULL,
BCN_UPDATE_AP_RENEW);
AsicSetSyncModeAndEnable(
pAd, pAd->CommonCfg.BeaconPeriod,
HW_BSSID_0, OPMODE_AP);
} else
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL,
DBG_LVL_TRACE, ("Carrier gone\n"));
}
pCarrierDetect->OneSecIntCount = 0;
}
#endif /* CARRIER_DETECTION_SUPPORT */
#ifdef VOW_SUPPORT
vow_display_info_periodic(pAd);
#endif /* VOW_SUPPORT */
#ifdef RED_SUPPORT
if (pAd->red_debug_en && (pAd->red_have_cr4 == FALSE))
appShowRedDebugMessage(pAd);
#endif /* RED_SUPPORT */
#ifdef FQ_SCH_SUPPORT
if (pAd->fq_ctrl.dbg_en)
app_show_fq_dbgmsg(pAd);
#endif /* RRSCH_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);
RTMPMaintainPMKIDCache(pAd);
#ifdef WDS_SUPPORT
WdsTableMaintenance(pAd);
#endif /* WDS_SUPPORT */
#ifdef CLIENT_WDS
CliWds_ProxyTabMaintain(pAd);
#endif /* CLIENT_WDS */
#ifdef A4_CONN
for (mbss_idx = 0; mbss_idx < pAd->ApCfg.BssidNum; mbss_idx++)
a4_proxy_maintain(pAd, mbss_idx);
pAd->a4_need_refresh = FALSE;
#endif /* A4_CONN */
#ifdef WIFI_DIAG
DiagApMlmeOneSecProc(pAd);
#endif
}
#ifdef AP_SCAN_SUPPORT
AutoChannelSelCheck(pAd);
#endif /* AP_SCAN_SUPPORT */
#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 */
) ||
(pAd->Mlme.OneSecPeriodicRound % 2 == 1
#ifdef CONFIG_MAP_SUPPORT
&& (IS_MAP_TURNKEY_ENABLE(pAd))
#endif /* APCLI_AUTO_CONNECT_SUPPORT */
)) {
ApCliIfUp(pAd);
}
{
INT loop;
ULONG Now32;
MAC_TABLE_ENTRY *pEntry;
#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];
#ifdef APCLI_CERT_SUPPORT
if ((pApCliEntry->bBlockAssoc == TRUE) &&
RTMP_TIME_AFTER(Now32,
pApCliEntry->LastMicErrorTime +
(60 * OS_HZ)))
pAd->ApCfg.ApCliTab[loop].bBlockAssoc = FALSE;
#endif /* APCLI_CERT_SUPPORT */
if ((pApCliEntry->Valid == TRUE) &&
(VALID_UCAST_ENTRY_WCID(pAd,
pApCliEntry->MacTabWCID))) {
/* update channel quality for Roaming and UI LinkQuality display */
pEntry = &pAd->MacTab.Content
[pApCliEntry->MacTabWCID];
/* update channel quality for Roaming and UI LinkQuality display */
if (pEntry && (pApCliEntry->MacTabWCID > 0) &&
IS_ENTRY_AP(pEntry))
MlmeCalculateChannelQuality(pAd, pEntry,
Now32);
}
}
}
#endif /* APCLI_SUPPORT */
#ifdef DOT11_N_SUPPORT
{
INT IdBss = 0;
UCHAR ht_protect_en = 1;
BSS_STRUCT *pMbss = NULL;
for (IdBss = 0; IdBss < pAd->ApCfg.BssidNum; IdBss++) {
pMbss = &pAd->ApCfg.MBSSID[IdBss];
if ((pMbss) && (&pMbss->wdev) &&
(pMbss->wdev.DevInfo.Active)) {
ht_protect_en = wlan_config_get_ht_protect_en(
&pMbss->wdev);
if (ht_protect_en) {
ApUpdateCapabilityAndErpIe(pAd, pMbss);
APUpdateOperationMode(pAd,
&pMbss->wdev);
}
}
}
}
#endif /* DOT11_N_SUPPORT */
#ifdef A_BAND_SUPPORT
if (bSupport5G && (pAd->CommonCfg.bIEEE80211H == 1)) {
INT IdBss = 0;
BOOLEAN BandInCac[DBDC_BAND_NUM];
UCHAR i;
BSS_STRUCT *pMbss = NULL;
struct DOT11_H *pDot11hTest = NULL;
struct wifi_dev *wdev;
UCHAR BandIdx;
for (i = 0; i < DBDC_BAND_NUM; i++)
BandInCac[i] = FALSE;
for (IdBss = 0; IdBss < pAd->ApCfg.BssidNum; IdBss++) {
pMbss = &pAd->ApCfg.MBSSID[IdBss];
wdev = &pMbss->wdev;
if ((pMbss == NULL) || (wdev == NULL))
continue;
if (wdev->pHObj == NULL)
continue;
BandIdx = HcGetBandByWdev(wdev);
pDot11hTest = &pAd->Dot11_H[BandIdx];
if (pDot11hTest == NULL)
continue;
#ifdef MT_DFS_SUPPORT
#ifdef CONFIG_MAP_SUPPORT
if (IS_MAP_TURNKEY_ENABLE(pAd)) {
if (wdev->map_indicate_channel_change &&
(wdev->map_radar_detect == 0)) {
wdev->map_indicate_channel_change = 0;
wapp_send_ch_change_rsp(pAd, wdev,
wdev->channel);
}
}
#endif
if (pDot11hTest->RDMode == RD_SILENCE_MODE) {
if (BandInCac[BandIdx] == TRUE)
continue;
else
BandInCac[BandIdx] = TRUE;
#ifdef BACKGROUND_SCAN_SUPPORT
if (IS_SUPPORT_MT_ZEROWAIT_DFS(pAd) == TRUE)
ChannelMovingTime =
pDot11hTest
->DfsZeroWaitChMovingTime;
else
#endif
{
ChannelMovingTime =
pDot11hTest->ChMovingTime;
}
if (pDot11hTest->RDCount++ >
ChannelMovingTime) {
pDot11hTest->RDCount = 0;
#ifdef CONFIG_MAP_SUPPORT
if (IS_MAP_ENABLE(pAd)) {
wapp_send_cac_stop(
pAd,
RtmpOsGetNetIfIndex(
wdev->if_dev),
wdev->channel, TRUE);
}
#endif
MlmeEnqueue(pAd, DFS_STATE_MACHINE,
DFS_CAC_END, 0, NULL,
HcGetBandByWdev(wdev));
AsicSetSyncModeAndEnable(
pAd,
pAd->CommonCfg.BeaconPeriod,
HW_BSSID_0, OPMODE_AP);
pDot11hTest->RDMode = RD_NORMAL_MODE;
}
} else
#endif
{
pDot11hTest->InServiceMonitorCount++;
}
}
}
#endif /* A_BAND_SUPPORT */
#ifdef MT_DFS_SUPPORT
DfsNonOccupancyCountDown(pAd);
DfsOutBandCacCountUpdate(pAd);
#ifdef DFS_VENDOR10_CUSTOM_FEATURE
DfsV10W56APDownTimeCountDown(pAd);
#endif
#endif
#ifdef MBO_SUPPORT
MboCheckBssTermination(pAd);
#endif /* MBO_SUPPORT */
#ifdef DOT11R_FT_SUPPORT
FT_R1KHInfoMaintenance(pAd);
#endif /* DOT11R_FT_SUPPORT */
#ifdef APCLI_SUPPORT
#ifdef DOT11_N_SUPPORT
#ifdef DOT11N_DRAFT3
#ifdef APCLI_CERT_SUPPORT
/* Perform 20/40 BSS COEX scan every Dot11BssWidthTriggerScanInt */
{
UCHAR apcli2Gidx = 0;
#ifdef DBDC_MODE
if (pAd->CommonCfg.dbdc_mode)
apcli2Gidx = 1;
#endif
if (APCLI_IF_UP_CHECK(pAd, apcli2Gidx) &&
(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))) {
#ifdef MT7615
if (IS_MT7615(pAd) || IS_MT7622(pAd)) {
PAPCLI_STRUCT pApCliEntry =
&pAd->ApCfg.ApCliTab[BSS0];
MAC_TABLE_ENTRY *pEntry = NULL;
STA_TR_ENTRY *tr_entry = NULL;
UINT tx_tp = 0;
UINT rx_tp = 0;
if (pApCliEntry->Valid == TRUE) {
pEntry =
&pAd->MacTab.Content
[pApCliEntry
->MacTabWCID];
tr_entry =
&pAd->MacTab.tr_entry
[pApCliEntry
->MacTabWCID];
}
if ((pEntry) &&
IS_ENTRY_APCLI(pEntry) &&
(tr_entry->PortSecured ==
WPA_802_1X_PORT_SECURED)) {
tx_tp = ((pApCliEntry
->OneSecTxBytes) >>
BYTES_PER_SEC_TO_MBPS);
rx_tp = ((pApCliEntry
->OneSecRxBytes) >>
BYTES_PER_SEC_TO_MBPS);
}
/* 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 ((tx_tp < 1) && (rx_tp < 1)) {
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,
(ULONG)(&pApCliEntry
->wdev));
/* Set InfoReq = 1, So after scan , alwats sebd 20/40 Coexistence frame to AP*/
pAd->CommonCfg.BSSCoexist2040
.field.InfoReq = 1;
RTMP_MLME_HANDLER(pAd);
}
} else
#endif /* MT7615 */
{
MTWF_LOG(
DBG_CAT_MLME, DBG_SUBCAT_ALL,
DBG_LVL_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)) {
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);
}
MTWF_LOG(
DBG_CAT_MLME, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("MMCHK - 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 */
#ifdef BAND_STEERING
BndStrgHeartBeatMonitor(pAd);
#endif
}
/*! \brief To substitute the message type if the message is coming from external
* \param *Fr The frame received
* \param *Machine The state machine
* \param *MsgType the message type for the state machine
* \return TRUE if the substitution is successful, FALSE otherwise
* \pre
* \post
*/
BOOLEAN APMsgTypeSubst(IN PRTMP_ADAPTER pAd, IN PFRAME_802_11 pFrame,
OUT INT *Machine, OUT INT *MsgType)
{
USHORT Seq;
#ifdef DOT11_SAE_SUPPORT
USHORT Alg;
#endif /* DOT11_SAE_SUPPORT */
UCHAR EAPType;
BOOLEAN Return = FALSE;
#ifdef WSC_AP_SUPPORT
UCHAR EAPCode;
PMAC_TABLE_ENTRY pEntry;
#endif /* WSC_AP_SUPPORT */
unsigned char hdr_len = LENGTH_802_11;
#ifdef A4_CONN
if ((pFrame->Hdr.FC.FrDs == 1) && (pFrame->Hdr.FC.ToDs == 1))
hdr_len = LENGTH_802_11_WITH_ADDR4;
#endif
/*
TODO:
only PROBE_REQ can be broadcast, all others must be unicast-to-me && is_mybssid;
otherwise, ignore this frame
*/
/* wpa EAPOL PACKET */
if (pFrame->Hdr.FC.Type == FC_TYPE_DATA) {
#ifdef WSC_AP_SUPPORT
WSC_CTRL *wsc_ctrl;
struct wifi_dev *wdev;
/*WSC EAPOL PACKET */
pEntry = MacTableLookup(pAd, pFrame->Hdr.Addr2);
if (pEntry) {
wdev = &pAd->ApCfg.MBSSID[pEntry->func_tb_idx].wdev;
if (pEntry->bWscCapable ||
IS_AKM_OPEN(wdev->SecConfig.AKMMap) ||
IS_AKM_SHARED(wdev->SecConfig.AKMMap) ||
IS_AKM_AUTOSWITCH(wdev->SecConfig.AKMMap)) {
/*
WSC AP only can service one WSC STA in one WPS session.
Forward this EAP packet to WSC SM if this EAP packets is from
WSC STA that WSC AP services or WSC AP doesn't service any
WSC STA now.
*/
wsc_ctrl = &wdev->WscControl;
if ((MAC_ADDR_EQUAL(wsc_ctrl->EntryAddr,
pEntry->Addr) ||
MAC_ADDR_EQUAL(wsc_ctrl->EntryAddr,
ZERO_MAC_ADDR)) &&
IS_ENTRY_CLIENT(pEntry) &&
(wsc_ctrl->WscConfMode != WSC_DISABLE)) {
*Machine = WSC_STATE_MACHINE;
EAPType = *((UCHAR *)pFrame + hdr_len +
LENGTH_802_1_H + 1);
EAPCode = *((UCHAR *)pFrame + hdr_len +
LENGTH_802_1_H + 4);
Return = WscMsgTypeSubst(
EAPType, EAPCode, MsgType);
}
}
}
#endif /* WSC_AP_SUPPORT */
if (!Return) {
*Machine = WPA_STATE_MACHINE;
EAPType = *((UCHAR *)pFrame + hdr_len + LENGTH_802_1_H +
1);
Return = WpaMsgTypeSubst(EAPType, (INT *)MsgType);
}
return Return;
}
if (pFrame->Hdr.FC.Type != FC_TYPE_MGMT)
return FALSE;
switch (pFrame->Hdr.FC.SubType) {
case SUBTYPE_ASSOC_REQ:
*Machine = AP_ASSOC_STATE_MACHINE;
*MsgType = APMT2_PEER_ASSOC_REQ;
break;
/*
case SUBTYPE_ASSOC_RSP:
*Machine = AP_ASSOC_STATE_MACHINE;
*MsgType = APMT2_PEER_ASSOC_RSP;
break;
*/
case SUBTYPE_REASSOC_REQ:
*Machine = AP_ASSOC_STATE_MACHINE;
*MsgType = APMT2_PEER_REASSOC_REQ;
break;
/*
case SUBTYPE_REASSOC_RSP:
*Machine = AP_ASSOC_STATE_MACHINE;
*MsgType = APMT2_PEER_REASSOC_RSP;
break;
*/
case SUBTYPE_PROBE_REQ:
*Machine = AP_SYNC_STATE_MACHINE;
*MsgType = APMT2_PEER_PROBE_REQ;
break;
/* For Active Scan */
case SUBTYPE_PROBE_RSP:
*Machine = AP_SYNC_STATE_MACHINE;
*MsgType = APMT2_PEER_PROBE_RSP;
break;
case SUBTYPE_BEACON:
*Machine = AP_SYNC_STATE_MACHINE;
*MsgType = APMT2_PEER_BEACON;
break;
/*
case SUBTYPE_ATIM:
*Machine = AP_SYNC_STATE_MACHINE;
*MsgType = APMT2_PEER_ATIM;
break;
*/
case SUBTYPE_DISASSOC:
*Machine = AP_ASSOC_STATE_MACHINE;
*MsgType = APMT2_PEER_DISASSOC_REQ;
break;
case SUBTYPE_AUTH:
/* get the sequence number from payload 24 Mac Header + 2 bytes algorithm */
#ifdef DOT11_SAE_SUPPORT
NdisMoveMemory(&Alg, &pFrame->Octet[0], sizeof(USHORT));
#endif /* DOT11_SAE_SUPPORT */
NdisMoveMemory(&Seq, &pFrame->Octet[2], sizeof(USHORT));
*Machine = AP_AUTH_STATE_MACHINE;
if (Seq == 1
#ifdef DOT11_SAE_SUPPORT
|| (Alg == AUTH_MODE_SAE && Seq == 2)
#endif /* DOT11_SAE_SUPPORT */
)
*MsgType = APMT2_PEER_AUTH_REQ;
else if (Seq == 3)
*MsgType = APMT2_PEER_AUTH_CONFIRM;
else {
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("wrong AUTH seq=%d Octet=%02x %02x %02x %02x %02x %02x %02x %02x\n",
Seq, pFrame->Octet[0], pFrame->Octet[1],
pFrame->Octet[2], pFrame->Octet[3],
pFrame->Octet[4], pFrame->Octet[5],
pFrame->Octet[6], pFrame->Octet[7]));
return FALSE;
}
break;
case SUBTYPE_DEAUTH:
*Machine = AP_AUTH_STATE_MACHINE; /*AP_AUTH_RSP_STATE_MACHINE;*/
*MsgType = APMT2_PEER_DEAUTH;
break;
case SUBTYPE_ACTION:
case SUBTYPE_ACTION_NO_ACK:
*Machine = ACTION_STATE_MACHINE;
/* Sometimes Sta will return with category bytes with MSB = 1, if they receive catogory out of their support */
if ((pFrame->Octet[0] & 0x7F) > MAX_PEER_CATE_MSG)
*MsgType = MT2_ACT_INVALID;
else
*MsgType = (pFrame->Octet[0] & 0x7F);
break;
default:
return FALSE;
}
return TRUE;
}
/*
========================================================================
Routine Description:
Periodic evaluate antenna link status
Arguments:
pAd - Adapter pointer
Return Value:
None
========================================================================
*/
VOID APAsicEvaluateRxAnt(IN PRTMP_ADAPTER pAd)
{
ULONG TxTotalCnt;
#ifdef CONFIG_ATE
if (ATE_ON(pAd))
return;
#endif /* CONFIG_ATE */
#ifdef CARRIER_DETECTION_SUPPORT
if (pAd->CommonCfg.CarrierDetect.CD_State == CD_SILENCE)
return;
#endif /* CARRIER_DETECTION_SUPPORT */
bbp_set_rxpath(pAd, pAd->Antenna.field.RxPath);
TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
pAd->RalinkCounters.OneSecTxRetryOkCount +
pAd->RalinkCounters.OneSecTxFailCount;
if (TxTotalCnt > 50) {
RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 20);
pAd->Mlme.bLowThroughput = FALSE;
} else {
RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 300);
pAd->Mlme.bLowThroughput = TRUE;
}
}
/*
========================================================================
Routine Description:
After evaluation, check antenna link status
Arguments:
pAd - Adapter pointer
Return Value:
None
========================================================================
*/
VOID APAsicRxAntEvalTimeout(RTMP_ADAPTER *pAd)
{
CHAR rssi[3], *target_rssi;
#ifdef CONFIG_ATE
if (ATE_ON(pAd))
return;
#endif /* CONFIG_ATE */
/* if the traffic is low, use average rssi as the criteria */
if (pAd->Mlme.bLowThroughput == TRUE)
target_rssi = &pAd->ApCfg.RssiSample.LastRssi[0];
else
target_rssi = &pAd->ApCfg.RssiSample.AvgRssi[0];
NdisMoveMemory(&rssi[0], target_rssi, 3);
/* Disable the below to fix 1T/2R issue. It's suggested by Rory at 2007/7/11. */
bbp_set_rxpath(pAd, pAd->Mlme.RealRxPath);
}
/*
========================================================================
Routine Description:
After evaluation, check antenna link status
Arguments:
pAd - Adapter pointer
Return Value:
None
========================================================================
*/
VOID APAsicAntennaAvg(IN PRTMP_ADAPTER pAd, IN UCHAR AntSelect,
IN SHORT *RssiAvg)
{
SHORT realavgrssi;
LONG realavgrssi1;
ULONG recvPktNum = pAd->RxAnt.RcvPktNum[AntSelect];
realavgrssi1 = pAd->RxAnt.Pair1AvgRssiGroup1[AntSelect];
if (realavgrssi1 == 0) {
*RssiAvg = 0;
return;
}
realavgrssi = (SHORT)(realavgrssi1 / recvPktNum);
pAd->RxAnt.Pair1AvgRssiGroup1[0] = 0;
pAd->RxAnt.Pair1AvgRssiGroup1[1] = 0;
pAd->RxAnt.Pair1AvgRssiGroup2[0] = 0;
pAd->RxAnt.Pair1AvgRssiGroup2[1] = 0;
pAd->RxAnt.RcvPktNum[0] = 0;
pAd->RxAnt.RcvPktNum[1] = 0;
*RssiAvg = realavgrssi - 256;
}

View File

@ -1,277 +0,0 @@
/****************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
****************************************************************************
Module Name:
ap_nps.c
Abstract:
IEEE 802.11v NPS SoftAP related function
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Carter Chen 08-23-2013 created for 7603 AP
*/
#ifdef MT_MAC
#include "rt_config.h"
extern VOID write_tmac_info_tim(RTMP_ADAPTER *pAd, INT apidx, UCHAR *tmac_buf,
HTTRANSMIT_SETTING *BeaconTransmit,
ULONG frmLen);
BOOLEAN TimTransmitRequired(RTMP_ADAPTER *pAd, INT apidx, BSS_STRUCT *pMbss)
{
BOOLEAN result = FALSE;
TIM_BUF_STRUC *tim_info;
tim_info = &pMbss->wdev.bcn_buf.tim_buf;
if (tim_info->TimBufIdx >= HW_BEACON_MAX_NUM)
return result;
if (tim_info->bTimSntReq == TRUE)
result = TRUE;
return result;
}
#ifdef MT_MAC
VOID MtUpdateTimToAsic(IN RTMP_ADAPTER *pAd, IN INT apidx, IN ULONG FrameLen)
{
TIM_BUF_STRUC *tim_buf = NULL;
UCHAR *buf;
INT len;
PNDIS_PACKET *pkt = NULL;
UINT32 WdevIdx;
struct wifi_dev *wdev = &pAd->ApCfg.MBSSID[apidx].wdev;
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
{
tim_buf = &wdev->bcn_buf.tim_buf;
}
if (!tim_buf) {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s(): bcn_buf is NULL!\n", __func__));
return;
}
WdevIdx = wdev->wdev_idx;
pkt = tim_buf->TimPkt;
if (pkt) {
UCHAR qIdx;
buf = (UCHAR *)GET_OS_PKT_DATAPTR(pkt);
len = FrameLen + cap->tx_hw_hdr_len;
SET_OS_PKT_LEN(pkt, len);
RTMP_SET_PACKET_WDEV(pkt, WdevIdx);
qIdx = HcGetBcnQueueIdx(pAd, wdev);
RTMP_SET_PACKET_TYPE(pkt, TX_MGMT);
send_mlme_pkt(pAd, pkt, wdev, qIdx, FALSE);
return;
} else
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s(): TimPkt is NULL!\n", __func__));
}
#endif /* MT_MAC */
VOID write_tmac_info_tim(RTMP_ADAPTER *pAd, INT apidx, UCHAR *tmac_buf,
HTTRANSMIT_SETTING *BeaconTransmit, ULONG frmLen)
{
MAC_TX_INFO mac_info;
struct wifi_dev *wdev;
NdisZeroMemory((UCHAR *)&mac_info, sizeof(mac_info));
#ifdef MT_MAC
mac_info.Type = FC_TYPE_MGMT;
mac_info.SubType = SUBTYPE_ACTION;
#endif
mac_info.FRAG = FALSE;
mac_info.CFACK = FALSE;
mac_info.InsTimestamp = FALSE;
mac_info.AMPDU = FALSE;
mac_info.BM = 1;
mac_info.Ack = FALSE;
mac_info.NSeq = TRUE;
mac_info.BASize = 0;
mac_info.WCID = 0;
mac_info.Length = frmLen;
mac_info.PID = PID_MGMT;
mac_info.TID = 0;
mac_info.TxRate = 0;
mac_info.Txopmode = IFS_HTTXOP;
mac_info.hdr_len = 24;
mac_info.bss_idx = apidx;
mac_info.SpeEn = 1;
mac_info.Preamble = LONG_PREAMBLE;
mac_info.IsAutoRate = FALSE;
wdev = wdev_search_by_address(pAd, tmac_buf + sizeof(TMAC_TXD_L) + 10);
if (!wdev)
return;
mac_info.q_idx = HcGetBcnQueueIdx(pAd, wdev);
#ifdef MT_MAC
mac_info.TxSPriv = wdev->func_idx;
mac_info.OmacIdx = wdev->OmacIdx;
if (wdev->bcn_buf.BcnUpdateMethod == BCN_GEN_BY_FW)
mac_info.IsOffloadPkt = TRUE;
else
mac_info.IsOffloadPkt = FALSE;
mac_info.Preamble = LONG_PREAMBLE;
NdisZeroMemory(tmac_buf, sizeof(TMAC_TXD_L));
#endif
pAd->archOps.write_tmac_info_fixed_rate(pAd, tmac_buf, &mac_info,
BeaconTransmit);
}
VOID APMakeBssTimFrame(RTMP_ADAPTER *pAd, INT apidx)
{
BSS_STRUCT *pMbss = &pAd->ApCfg.MBSSID[apidx];
HEADER_802_11 TimHdr;
LARGE_INTEGER FakeTimestamp;
ULONG FrameLen = 0;
UCHAR *pTimFrame, *ptr, *tmac_info;
HTTRANSMIT_SETTING TimTransmit = {
.word = 0
}; /* MGMT frame PHY rate setting when operatin at HT rate. */
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
UINT8 tx_hw_hdr_len = cap->tx_hw_hdr_len;
UCHAR Cat = 11; /* Tim Category field */
UCHAR Act = 0; /* Tim Action field */
UCHAR ChkBcn = 0; /* Check Beacon field init from 0. */
ULONG UpdatePos = 0;
struct wifi_dev *wdev = &pAd->ApCfg.MBSSID[apidx].wdev;
if (!TimTransmitRequired(pAd, apidx, pMbss))
return;
if (wdev->bcn_buf.tim_buf.TimPkt == NULL) {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s():Invalid TimPkt for MBSS[%d]\n", __func__,
apidx));
return;
}
tmac_info = (UCHAR *)GET_OS_PKT_DATAPTR(wdev->bcn_buf.tim_buf.TimPkt);
pTimFrame = (UCHAR *)(tmac_info + tx_hw_hdr_len);
ActHeaderInit(pAd, &TimHdr, BROADCAST_ADDR, wdev->if_addr, wdev->bssid);
MakeOutgoingFrame(pTimFrame, &FrameLen, sizeof(HEADER_802_11), &TimHdr,
1, &Cat, 1, &Act, 1, &ChkBcn, TIMESTAMP_LEN,
&FakeTimestamp, END_OF_ARGS);
TimTransmit.word = 0;
wdev->bcn_buf.TimIELocationInTim = (UCHAR)FrameLen;
UpdatePos = wdev->bcn_buf.TimIELocationInTim;
/*
step 2 - update TIM IE
TODO: enlarge TIM bitmap to support up to 64 STAs
TODO: re-measure if RT2600 TBTT interrupt happens faster than BEACON sent out time
*/
ptr = pTimFrame + (UCHAR)FrameLen;
*ptr = IE_TIM;
*(ptr + 1) = 0x0e;
*(ptr + 2) = pAd->ApCfg.DtimCount;
*(ptr + 3) = pAd->ApCfg.DtimPeriod;
*(ptr + 4) = 0xa0;
*(ptr + 5) = 0xa0;
*(ptr + 6) = 0xa0;
*(ptr + 7) = 0xa0;
*(ptr + 8) = 0xa0;
*(ptr + 9) = 0xa0;
*(ptr + 10) = 0xa0;
*(ptr + 11) = 0xa0;
*(ptr + 12) = 0xa0;
*(ptr + 13) = 0xa0;
*(ptr + 14) = 0xa0;
*(ptr + 15) = 0xa0;
/* adjust TIM length according to the new TIM */
FrameLen += 16; /* (2 + *(ptr+1)); */
/* When Beacon is use CCK to send, high rate TIM shall use OFDM to send. and it's mandatory. */
if (wdev->channel <= 14) {
TimTransmit.field.MODE = MODE_OFDM;
TimTransmit.field.MCS = MCS_RATE_6;
} else {
TimTransmit.field.MODE = MODE_OFDM;
TimTransmit.field.MCS = MCS_RATE_9;
}
write_tmac_info_tim(pAd, apidx, tmac_info, &TimTransmit, FrameLen);
#ifdef BCN_V2_SUPPORT /* add bcn v2 support , 1.5k beacon support */
AsicUpdateBeacon(pAd, wdev, FrameLen, PKT_V2_TIM);
#else
AsicUpdateBeacon(pAd, wdev, FrameLen, PKT_TIM);
#endif
if (0) {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%s(): Dump the TimFrame of BSS%d!\n", __func__,
apidx));
hex_dump("Initial TimFrameBuf", tmac_info,
FrameLen + tx_hw_hdr_len);
}
}
UCHAR GetTimNum(RTMP_ADAPTER *pAd)
{
int i;
int NumTim;
TIM_BUF_STRUC *tim_info;
NumTim = 0;
for (i = 0; i < pAd->ApCfg.BssidNum; i++) {
tim_info = &pAd->ApCfg.MBSSID[i].wdev.bcn_buf.tim_buf;
if (tim_info->bTimSntReq) {
tim_info->TimBufIdx = NumTim;
NumTim++;
}
}
return NumTim;
}
VOID APMakeAllTimFrame(RTMP_ADAPTER *pAd)
{
INT i;
for (i = 0; i < pAd->ApCfg.BssidNum; i++)
APMakeBssTimFrame(pAd, i);
}
INT wdev_tim_buf_init(RTMP_ADAPTER *pAd, TIM_BUF_STRUC *tim_info)
{
INT ret;
/* tim_info->TimBufIdx = HW_BEACON_MAX_NUM; */
if (!tim_info->TimPkt) {
ret = RTMPAllocateNdisPacket(pAd, &tim_info->TimPkt, NULL, 0,
NULL, MAX_TIM_SIZE);
if (ret != NDIS_STATUS_SUCCESS)
return FALSE;
} else {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%s():TimPkt is allocated!\n", __func__));
}
tim_info->bTimSntReq = TRUE;
return TRUE;
}
#endif /* MT_MAC */

View File

@ -1,997 +0,0 @@
/****************************************************************************
* Ralink Tech Inc.
* Taiwan, R.O.C.
*
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************/
/****************************************************************************
Abstract:
Provide information on the current STA population and traffic levels
in the QBSS.
This attribute is available only at a QAP. This attribute, when TRUE,
indicates that the QAP implementation is capable of generating and
transmitting the QBSS load element in the Beacon and Probe Response frames.
***************************************************************************/
#include "rt_config.h"
#ifdef AP_QLOAD_SUPPORT
struct GNU_PACKED _ELM_QBSS_LOAD {
UINT8 ElementId;
UINT8 Length;
/* the total number of STAs currently associated with this QBSS */
UINT16 StationCount;
/* defined as the percentage of time, nomalized to 255, the QAP sensed the
medium busy, as indicated by either the physical or virtual carrier
sense mechanism.
This percentage is computed using the formula:
((channel busy time / (dot11ChannelUtilizationBeaconIntervals *
dot11BeaconPeriod * 1024)) * 255) */
UINT8 ChanUtil;
/* specifies the remaining amount of medium time available via explicit
admission control, in units of 32 microsecond periods per 1 second.
The field is helpful for roaming non-AP QSTAs to select a QAP that is
likely to accept future admission control requests, but it does not
represent a guarantee that the HC will admit these requests. */
UINT16 AvalAdmCap;
};
#define ELM_QBSS_LOAD_ID 11
#define ELM_QBSS_LOAD_LEN 5
/*
We will send a alarm when channel busy time (primary or secondary) >=
Time Threshold and Num Threshold.
QBSS_LOAD_ALRAM_BUSY_TIME_THRESHOLD = 0 means alarm function is disabled.
If you want to enable it, use command
"iwpriv ra0 set qloadalarmtimethres=90"
*/
#define QBSS_LOAD_ALRAM_BUSY_TIME_THRESHOLD 0 /* unit: % */
#define QBSS_LOAD_ALRAM_BUSY_NUM_THRESHOLD 10 /* unit: 1 */
/* a alarm will not re-issued until QBSS_LOAD_ALARM_DURATION * TBTT */
#define QBSS_LOAD_ALARM_DURATION 100 /* unit: TBTT */
static VOID QBSS_LoadAlarmSuspend(IN RTMP_ADAPTER *pAd);
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
/* handle a alarm */
static VOID QBSS_LoadAlarm(IN RTMP_ADAPTER *pAd);
static VOID QBSS_LoadAlarmBusyTimeThresholdReset(IN RTMP_ADAPTER *pAd,
IN UINT32 TimePeriod);
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
/* --------------------------------- Private -------------------------------- */
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
/*
========================================================================
Routine Description:
Handle a alarm.
Arguments:
pAd - WLAN control block pointer
Return Value:
None
Note:
You can use different methods to handle QBSS Load alarm here.
Current methods are:
1. Change 20/40 to 20-only.
2. Change channel to the clear channel.
========================================================================
*/
static VOID QBSS_LoadAlarm(IN RTMP_ADAPTER *pAd)
{
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
#ifdef DOT11_N_SUPPORT
#ifdef DOT11N_DRAFT3
struct wifi_dev *wdev;
UCHAR i;
UCHAR op_ht_bw;
UCHAR op_ext_cha;
#endif /*DOT11N_DRAFT3*/
#endif /*DOT11_N_SUPPORT*/
/* suspend alarm until channel switch */
QBSS_LoadAlarmSuspend(pAd);
pQloadCtrl->QloadAlarmNumber++;
/* check if we have already been 20M bandwidth */
#ifdef DOT11_N_SUPPORT
#ifdef DOT11N_DRAFT3
for (i = 0; i < pAd->ApCfg.BssidNum; i++) {
wdev = &pAd->ApCfg.MBSSID[i].wdev;
op_ext_cha = wlan_operate_get_ext_cha(wdev);
op_ht_bw = wlan_operate_get_ht_bw(wdev);
if ((op_ext_cha != 0) && (op_ht_bw != HT_BW_20)) {
MAC_TABLE *pMacTable;
UINT32 StaId;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("qbss> Alarm! Change to 20 bw...\n"));
/* disassociate stations without D3 2040Coexistence function */
pMacTable = &pAd->MacTab;
/*TODO: Carter, check StaId why start from 1.*/
for (StaId = 1; VALID_UCAST_ENTRY_WCID(pAd, StaId);
StaId++) {
MAC_TABLE_ENTRY *pEntry =
&pMacTable->Content[StaId];
BOOLEAN bDisconnectSta = FALSE;
if (!IS_ENTRY_CLIENT(pEntry))
continue;
if (pEntry->Sst != SST_ASSOC)
continue;
if (pEntry->BSS2040CoexistenceMgmtSupport)
bDisconnectSta = TRUE;
if (bDisconnectSta) {
/* send wireless event - for ageout */
RTMPSendWirelessEvent(
pAd, IW_AGEOUT_EVENT_FLAG,
pEntry->Addr, 0, 0);
{
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
HEADER_802_11 DeAuthHdr;
USHORT Reason;
/* send out a DISASSOC request frame */
NStatus = MlmeAllocateMemory(
pAd, &pOutBuffer);
if (NStatus !=
NDIS_STATUS_SUCCESS) {
MTWF_LOG(
DBG_CAT_AP,
DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
(" MlmeAllocateMemory fail ..\n"));
/*NdisReleaseSpinLock(&pAd->MacTabLock); */
continue;
}
Reason =
REASON_DEAUTH_STA_LEAVING;
MgtMacHeaderInit(
pAd, &DeAuthHdr,
SUBTYPE_DEAUTH, 0,
pEntry->Addr,
pAd->ApCfg
.MBSSID[pEntry->func_tb_idx]
.wdev.if_addr,
pAd->ApCfg
.MBSSID[pEntry->func_tb_idx]
.wdev.bssid);
MakeOutgoingFrame(
pOutBuffer, &FrameLen,
sizeof(HEADER_802_11),
&DeAuthHdr, 2, &Reason,
END_OF_ARGS);
MiniportMMRequest(pAd, 0,
pOutBuffer,
FrameLen);
MlmeFreeMemory(pOutBuffer);
}
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("qbss> Alarm! Deauth the station %02x:%02x:%02x:%02x:%02x:%02x\n",
PRINT_MAC(pEntry->Addr)));
#ifdef MAP_R2
if (IS_MAP_ENABLE(pAd) &&
IS_MAP_R2_ENABLE(pAd))
wapp_handle_sta_disassoc(
pAd, pEntry->wcid,
REASON_DEAUTH_STA_LEAVING);
#endif
mac_entry_delete(pAd, pEntry);
continue;
}
}
/* for 11n */
wlan_operate_set_ht_bw(wdev, HT_BW_20, EXTCHA_NONE);
/* mark alarm flag */
pQloadCtrl->FlgQloadAlarm = TRUE;
QBSS_LoadAlarmResume(pAd);
} else
#endif /* DOT11N_DRAFT3 */
#endif /* DOT11_N_SUPPORT */
{
/* we are in 20MHz bandwidth so try to switch channel */
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("qbss> Alarm! Switch channel...\n"));
/* send command to switch channel */
RTEnqueueInternalCmd(pAd, CMDTHREAD_CHAN_RESCAN,
(VOID *)&i, sizeof(UCHAR));
}
}
}
/*
========================================================================
Routine Description:
Re-calculate busy time threshold.
Arguments:
pAd - WLAN control block pointer
TimePeriod - TBTT
Return Value:
None
Note:
EX: TBTT=100ms, 90%, pAd->QloadBusyTimeThreshold = 90ms
========================================================================
*/
static VOID QBSS_LoadAlarmBusyTimeThresholdReset(IN RTMP_ADAPTER *pAd,
IN UINT32 TimePeriod)
{
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
pQloadCtrl->QloadBusyTimeThreshold = TimePeriod;
pQloadCtrl->QloadBusyTimeThreshold *=
pQloadCtrl->QloadAlarmBusyTimeThreshold;
pQloadCtrl->QloadBusyTimeThreshold /= 100;
pQloadCtrl->QloadBusyTimeThreshold <<=
10; /* translate mini-sec to micro-sec */
}
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
/*
========================================================================
Routine Description:
Initialize ASIC Channel Busy Calculation mechanism.
Arguments:
pAd - WLAN control block pointer
Return Value:
None
Note:
Init Condition: WMM must be enabled.
========================================================================
*/
VOID QBSS_LoadInit(RTMP_ADAPTER *pAd)
{
UINT32 IdBss;
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
/* check whether any BSS enables WMM feature */
for (IdBss = 0; IdBss < pAd->ApCfg.BssidNum; IdBss++) {
if ((pAd->ApCfg.MBSSID[IdBss].wdev.bWmmCapable)
#ifdef DOT11K_RRM_SUPPORT
|| (IS_RRM_ENABLE(&pAd->ApCfg.MBSSID[IdBss].wdev))
#endif /* DOT11K_RRM_SUPPORT */
) {
if (pAd->ApCfg.MBSSID[IdBss].wdev.channel > 14)
pQloadCtrl = HcGetQloadCtrlByRf(pAd, RFIC_5GHZ);
else
pQloadCtrl =
HcGetQloadCtrlByRf(pAd, RFIC_24GHZ);
if (!pQloadCtrl)
continue;
if (pQloadCtrl->FlgQloadEnable)
continue;
pQloadCtrl->FlgQloadEnable = TRUE;
/* default value is 50, please reference to IEEE802.11e 2005 Annex D */
/* pQloadCtrl->QloadChanUtilBeaconInt = 50; */
pQloadCtrl->QloadChanUtilBeaconInt = 5;
AsicSetChBusyStat(pAd, pQloadCtrl->FlgQloadEnable);
pQloadCtrl->QloadChanUtilTotal = 0;
pQloadCtrl->QloadChanUtilTotalCcaNavTx = 0;
pQloadCtrl->QloadUpTimeLast = 0;
#ifdef QLOAD_FUNC_BUSY_TIME_STATS
/* clear busy time statistics */
NdisZeroMemory(pQloadCtrl->QloadBusyCountPri,
sizeof(pQloadCtrl->QloadBusyCountPri));
NdisZeroMemory(pQloadCtrl->QloadBusyCountSec,
sizeof(pQloadCtrl->QloadBusyCountSec));
#endif /* QLOAD_FUNC_BUSY_TIME_STATS */
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
/* init threshold before QBSS_LoadAlarmReset */
pQloadCtrl->QloadAlarmBusyTimeThreshold =
QBSS_LOAD_ALRAM_BUSY_TIME_THRESHOLD;
pQloadCtrl->QloadAlarmBusyNumThreshold =
QBSS_LOAD_ALRAM_BUSY_NUM_THRESHOLD;
QBSS_LoadAlarmReset(pAd);
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
}
}
}
/*
========================================================================
Routine Description:
Reset alarm function.
Arguments:
pAd - WLAN control block pointer
Return Value:
None
Note:
========================================================================
*/
VOID QBSS_LoadAlarmReset(IN RTMP_ADAPTER *pAd)
{
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
pQloadCtrl->FlgQloadAlarm = FALSE;
pQloadCtrl->QloadAlarmDuration = 0;
pQloadCtrl->QloadAlarmNumber = 0;
pQloadCtrl->FlgQloadAlarmIsSuspended = FALSE;
QBSS_LoadAlarmBusyTimeThresholdReset(pAd, pAd->CommonCfg.BeaconPeriod);
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
}
/*
========================================================================
Routine Description:
Resume alarm function.
Arguments:
pAd - WLAN control block pointer
Return Value:
None
Note:
========================================================================
*/
VOID QBSS_LoadAlarmResume(IN RTMP_ADAPTER *pAd)
{
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
pQloadCtrl->FlgQloadAlarmIsSuspended = FALSE;
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
}
/*
========================================================================
Routine Description:
Suspend alarm function.
Arguments:
pAd - WLAN control block pointer
Return Value:
None
Note:
========================================================================
*/
static VOID QBSS_LoadAlarmSuspend(IN RTMP_ADAPTER *pAd)
{
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
pQloadCtrl->FlgQloadAlarmIsSuspended = TRUE;
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
}
/*
========================================================================
Routine Description:
Get average busy time in current channel.
Arguments:
pAd - WLAN control block pointer
Return Value:
average busy time
Note:
========================================================================
*/
UINT32 QBSS_LoadBusyTimeGet(IN RTMP_ADAPTER *pAd)
{
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
if (pQloadCtrl->QloadChanUtilBeaconCnt == 0)
return pQloadCtrl->QloadChanUtilTotal;
return (pQloadCtrl->QloadChanUtilTotal /
pQloadCtrl->QloadChanUtilBeaconCnt);
}
/*
========================================================================
Routine Description:
Check if a alarm is occurred and clear the alarm.
Arguments:
pAd - WLAN control block pointer
Return Value:
TRUE - alarm occurs
FALSE - no alarm
Note:
We will clear the alarm in the function.
========================================================================
*/
BOOLEAN QBSS_LoadIsAlarmIssued(IN RTMP_ADAPTER *pAd)
{
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
BOOLEAN FlgQloadAlarm = pQloadCtrl->FlgQloadAlarm;
pQloadCtrl->FlgQloadAlarm = FALSE;
return FlgQloadAlarm;
#else
return FALSE;
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
}
/*
========================================================================
Routine Description:
Check if the busy time is accepted.
Arguments:
pAd - WLAN control block pointer
Return Value:
TURE - ok
FALSE - fail
Note:
========================================================================
*/
BOOLEAN QBSS_LoadIsBusyTimeAccepted(IN RTMP_ADAPTER *pAd, IN UINT32 BusyTime)
{
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
if (pQloadCtrl->QloadAlarmBusyTimeThreshold == 0)
return TRUE; /* always ok */
if (BusyTime >= pQloadCtrl->QloadBusyTimeThreshold)
return FALSE;
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
return TRUE;
}
#ifdef CONFIG_HOTSPOT_R2
UINT32 QBSS_LoadElementAppend_HSTEST(IN RTMP_ADAPTER *pAd,
OUT UINT8 *pBeaconBuf, IN UCHAR apidx)
{
struct _ELM_QBSS_LOAD load, *pLoad = &load;
ULONG ElmLen;
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
/* check whether channel busy time calculation is enabled */
if (pQloadCtrl->FlgQloadEnable == 0)
return 0;
/* End of if */
/* init */
pLoad->ElementId = ELM_QBSS_LOAD_ID;
pLoad->Length = ELM_QBSS_LOAD_LEN;
pLoad->StationCount =
le2cpu16(pAd->ApCfg.MBSSID[apidx].HotSpotCtrl.QLoadStaCnt);
pLoad->ChanUtil = pAd->ApCfg.MBSSID[apidx].HotSpotCtrl.QLoadCU;
/* because no ACM is supported, the available bandwidth is 1 sec */
pLoad->AvalAdmCap = le2cpu16(0xffff); /* 0x7a12 * 32us = 1 second */
/* copy the element to the frame */
MakeOutgoingFrame(pBeaconBuf, &ElmLen, sizeof(struct _ELM_QBSS_LOAD),
pLoad, END_OF_ARGS);
return ElmLen;
} /* End of QBSS_LoadElementAppend */
#endif
/*
========================================================================
Routine Description:
Append the QBSS Load element to the beacon frame.
Arguments:
pAd - WLAN control block pointer
*pBeaconBuf - the beacon or probe response frame
Return Value:
the element total Length
Note:
Append Condition: You must check whether WMM is enabled before the
function is using.
========================================================================
*/
UINT32 QBSS_LoadElementAppend(RTMP_ADAPTER *pAd, UINT8 *pBeaconBuf,
QLOAD_CTRL *pQloadCtrl, UCHAR apidx)
{
struct _ELM_QBSS_LOAD load, *pLoad = &load;
ULONG ElmLen;
/* check whether channel busy time calculation is enabled */
if (pQloadCtrl->FlgQloadEnable == 0)
return 0;
/* init */
pLoad->ElementId = ELM_QBSS_LOAD_ID;
pLoad->Length = ELM_QBSS_LOAD_LEN;
pLoad->StationCount = le2cpu16(pAd->ApCfg.MBSSID[apidx].StaCount);
pLoad->ChanUtil = pQloadCtrl->QloadChanUtilCcaNavTx;
/* because no ACM is supported, the available bandwidth is 1 sec */
pLoad->AvalAdmCap = le2cpu16(0x7a12); /* 0x7a12 * 32us = 1 second */
/* copy the element to the frame */
MakeOutgoingFrame(pBeaconBuf, &ElmLen, sizeof(struct _ELM_QBSS_LOAD),
pLoad, END_OF_ARGS);
return ElmLen;
}
/*
========================================================================
Routine Description:
Update Channel Utilization.
Arguments:
pAd - WLAN control block pointer
UpTime - current up time
Return Value:
None
Note:
UpTime is used in QLOAD_FUNC_BUSY_TIME_STATS & QLOAD_FUNC_BUSY_TIME_ALARM
If UpTime != 0, it means that the time period calling the function
maybe not TBTT so we need to re-calculate the time period.
If you call the function in kernel thread, the time period sometimes
will not accurate due to kernel thread is not real-time, so we need to
recalculate the time period.
========================================================================
*/
VOID QBSS_LoadUpdate(IN RTMP_ADAPTER *pAd, IN ULONG UpTime)
{
UINT32 ChanUtilNu, ChanUtilNuCcaNavTx, ChanUtilDe;
UINT32 BusyTime = 0;
UINT32 BusyTimeCcaNavTx = 0;
UINT32 BusyTimeId;
UINT32 TimePeriod = pAd->CommonCfg.BeaconPeriod;
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
BOOLEAN FlgIsBusyOverThreshold = FALSE;
BOOLEAN FlgIsAlarmNeeded = FALSE;
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
#ifdef OCE_SUPPORT
BOOLEAN SameChanUtil = TRUE;
#endif /* OCE_SUPPORT */
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
UINT8 UpdateBands = 1, i = 0;
#if defined(ACS_CTCC_SUPPORT) || defined(OCE_SUPPORT)
struct wifi_dev *wdev = NULL;
UCHAR band_idx = 0;
AUTO_CH_CTRL *auto_ch_ctrl = NULL;
wdev = &pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev;
band_idx = HcGetBandByWdev(wdev);
auto_ch_ctrl = HcGetAutoChCtrlbyBandIdx(pAd, band_idx);
#endif /* ACS_CTCC_SUPPORT OCE_SUPPORT*/
UpdateBands = (pAd->CommonCfg.dbdc_mode == 0) ? 1 : 2;
for (i = 0; i < UpdateBands; i++) {
if (pAd->CommonCfg.dbdc_mode != 0) {
UCHAR PhyMode = HcGetRadioPhyModeByBandIdx(pAd, i);
UINT32 RfIC = (WMODE_CAP_5G(PhyMode)) ? RFIC_5GHZ :
RFIC_24GHZ;
pQloadCtrl = HcGetQloadCtrlByRf(pAd, RfIC);
if (!pQloadCtrl)
continue;
}
/* check whether channel busy time calculation is enabled */
if ((pQloadCtrl->FlgQloadEnable == 0) ||
(pQloadCtrl->FlgQloadAlarmIsSuspended == TRUE))
continue;
/* calculate new time period if needed */
if ((UpTime > 0) && (pQloadCtrl->QloadUpTimeLast > 0) &&
(UpTime > pQloadCtrl->QloadUpTimeLast)) {
/* re-calculate time period */
TimePeriod =
(UINT32)(UpTime - pQloadCtrl->QloadUpTimeLast);
/* translate to mini-second */
TimePeriod = (TimePeriod * 1000) / OS_HZ;
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
/* re-calculate QloadBusyTimeThreshold */
if (TimePeriod != pQloadCtrl->QloadTimePeriodLast)
QBSS_LoadAlarmBusyTimeThresholdReset(
pAd, TimePeriod);
pQloadCtrl->QloadTimePeriodLast = TimePeriod;
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
}
/* update up time */
pQloadCtrl->QloadUpTimeLast = UpTime;
/* do busy time statistics */
#ifdef DOT11_N_SUPPORT
{
struct freq_oper oper;
if (hc_radio_query_by_index(pAd, i, &oper) !=
HC_STATUS_OK)
continue;
if ((oper.ext_cha != 0) && (oper.ht_bw != 0)
#ifdef OFFCHANNEL_SCAN_FEATURE
&& (!ApScanRunning(pAd, NULL)) &&
(pAd->ScanCtrl.state == OFFCHANNEL_SCAN_INVALID)
#endif
) {
/* in 20MHz, no need to check busy time of secondary channel */
#ifdef ACS_CTCC_SUPPORT
if (auto_ch_ctrl->AutoChSelCtrl
.AutoChScanStatMachine.CurrState ==
AUTO_CH_SEL_SCAN_IDLE)
#endif
BusyTimeCcaNavTx =
AsicGetChBusyCnt(pAd, 1);
pQloadCtrl->QloadLatestChannelBusyTimeSec =
BusyTime;
#ifdef QLOAD_FUNC_BUSY_TIME_STATS
BusyTimeId = BusyTimeCcaNavTx >>
10; /* translate us to ms */
/* ex:95ms, 95*20/100 = 19 */
BusyTimeId =
(BusyTimeId * QLOAD_BUSY_INTERVALS) /
TimePeriod;
if (BusyTimeId >= QLOAD_BUSY_INTERVALS)
BusyTimeId = QLOAD_BUSY_INTERVALS - 1;
pQloadCtrl->QloadBusyCountSec[BusyTimeId]++;
#endif /* QLOAD_FUNC_BUSY_TIME_STATS */
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
if ((pQloadCtrl->FlgQloadAlarmIsSuspended ==
FALSE) &&
(pQloadCtrl->QloadAlarmBusyTimeThreshold >
0)) {
/* Alarm is not suspended and is enabled */
if ((pQloadCtrl->QloadBusyTimeThreshold !=
0) &&
(BusyTimeCcaNavTx >=
pQloadCtrl->QloadBusyTimeThreshold))
FlgIsBusyOverThreshold = TRUE;
}
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
}
}
#endif /* DOT11_N_SUPPORT */
/* do busy time statistics for primary channel */
/* BusyTime = AsicGetChBusyCnt(pAd, 0); */
/* update BusyTime from OneSecMibBucket[i] */
BusyTime = pAd->OneSecMibBucket.ChannelBusyTime[i];
if (i < DBDC_BAND_NUM)
BusyTimeCcaNavTx =
pAd->OneSecMibBucket.ChannelBusyTimeCcaNavTx[i];
pQloadCtrl->QloadLatestChannelBusyTimePri = BusyTime;
#ifdef QLOAD_FUNC_BUSY_TIME_STATS
BusyTimeId = BusyTimeCcaNavTx >> 10; /* translate us to ms */
/* ex:95ms, 95*20/100 = 19 */
BusyTimeId = (BusyTimeId * QLOAD_BUSY_INTERVALS) / TimePeriod;
if (BusyTimeId >= QLOAD_BUSY_INTERVALS)
BusyTimeId = QLOAD_BUSY_INTERVALS - 1;
pQloadCtrl->QloadBusyCountPri[BusyTimeId]++;
#endif /* QLOAD_FUNC_BUSY_TIME_STATS */
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
if ((pQloadCtrl->FlgQloadAlarmIsSuspended == FALSE) &&
(pQloadCtrl->QloadAlarmBusyTimeThreshold > 0)) {
/* Alarm is not suspended and is enabled */
if ((pQloadCtrl->QloadBusyTimeThreshold != 0) &&
(BusyTimeCcaNavTx >=
pQloadCtrl->QloadBusyTimeThreshold))
FlgIsBusyOverThreshold = TRUE;
}
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
/* accumulate channel busy time for primary channel */
pQloadCtrl->QloadChanUtilTotal += BusyTime;
pQloadCtrl->QloadChanUtilTotalCcaNavTx += BusyTimeCcaNavTx;
/* update new channel utilization for primary channel */
if (++pQloadCtrl->QloadChanUtilBeaconCnt >=
pQloadCtrl->QloadChanUtilBeaconInt) {
ChanUtilNu = pQloadCtrl->QloadChanUtilTotal;
ChanUtilNu *= 255;
ChanUtilNuCcaNavTx =
pQloadCtrl->QloadChanUtilTotalCcaNavTx;
ChanUtilNuCcaNavTx *= 255;
ChanUtilDe = pQloadCtrl->QloadChanUtilBeaconInt;
ChanUtilDe *= 1000000; /* sec to us */
#ifdef OCE_SUPPORT
if (pQloadCtrl->QloadChanUtilCcaNavTx ==
(UINT8)(ChanUtilNuCcaNavTx / ChanUtilDe))
SameChanUtil = TRUE;
else
SameChanUtil = FALSE;
#endif /* OCE_SUPPORT */
pQloadCtrl->QloadChanUtil =
(UINT8)(ChanUtilNu / ChanUtilDe);
pQloadCtrl->QloadChanUtilCcaNavTx =
(UINT8)(ChanUtilNuCcaNavTx / ChanUtilDe);
if ((ChanUtilNu / ChanUtilDe) >= 255)
pQloadCtrl->QloadChanUtil = 255;
if ((ChanUtilNuCcaNavTx / ChanUtilDe) >= 255)
pQloadCtrl->QloadChanUtilCcaNavTx = 255;
/* re-accumulate channel busy time */
pQloadCtrl->QloadChanUtilBeaconCnt = 0;
pQloadCtrl->QloadChanUtilTotal = 0;
pQloadCtrl->QloadChanUtilTotalCcaNavTx = 0;
#ifdef OCE_SUPPORT
if (!SameChanUtil)
UpdateBeaconHandler(pAd, wdev,
BCN_UPDATE_IE_CHG);
#endif /* OCE_SUPPORT */
}
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
/* check if alarm function is enabled */
if ((pQloadCtrl->FlgQloadAlarmIsSuspended == FALSE) &&
(pQloadCtrl->QloadAlarmBusyTimeThreshold > 0)) {
/* Alarm is not suspended and is enabled */
/* check if we need to issue a alarm */
if (FlgIsBusyOverThreshold == TRUE) {
if (pQloadCtrl->QloadAlarmDuration == 0) {
/* last alarm ended so we can check new alarm */
pQloadCtrl->QloadAlarmBusyNum++;
if (pQloadCtrl->QloadAlarmBusyNum >=
pQloadCtrl
->QloadAlarmBusyNumThreshold) {
/*
The continued number of busy time >= threshold is larger
than number threshold so issuing a alarm.
*/
FlgIsAlarmNeeded = TRUE;
pQloadCtrl->QloadAlarmDuration++;
}
}
} else
pQloadCtrl->QloadAlarmBusyNum = 0;
if (pQloadCtrl->QloadAlarmDuration > 0) {
/*
New alarm occurs so we can not re-issue new alarm during
QBSS_LOAD_ALARM_DURATION * TBTT.
*/
if (++pQloadCtrl->QloadAlarmDuration >=
QBSS_LOAD_ALARM_DURATION) {
/* can re-issue next alarm */
pQloadCtrl->QloadAlarmDuration = 0;
pQloadCtrl->QloadAlarmBusyNum = 0;
}
}
if (FlgIsAlarmNeeded == TRUE)
QBSS_LoadAlarm(pAd);
} else {
/* clear statistics counts */
pQloadCtrl->QloadAlarmBusyNum = 0;
pQloadCtrl->QloadAlarmDuration = 0;
pQloadCtrl->FlgQloadAlarm = FALSE;
}
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
}
}
/*
========================================================================
Routine Description:
Clear QoS Load information.
Arguments:
pAd - WLAN control block pointer
Return Value:
None
Note:
========================================================================
*/
VOID QBSS_LoadStatusClear(IN RTMP_ADAPTER *pAd, IN UCHAR Channel)
{
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
if (pAd->CommonCfg.dbdc_mode == 0)
pQloadCtrl = HcGetQloadCtrl(pAd);
else
pQloadCtrl = (Channel > 14) ?
HcGetQloadCtrlByRf(pAd, RFIC_5GHZ) :
HcGetQloadCtrlByRf(pAd, RFIC_24GHZ);
if (pQloadCtrl) {
#ifdef QLOAD_FUNC_BUSY_TIME_STATS
/* clear busy time statistics */
NdisZeroMemory(pQloadCtrl->QloadBusyCountPri,
sizeof(pQloadCtrl->QloadBusyCountPri));
NdisZeroMemory(pQloadCtrl->QloadBusyCountSec,
sizeof(pQloadCtrl->QloadBusyCountSec));
#endif /* QLOAD_FUNC_BUSY_TIME_STATS */
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
/* clear alarm function variables */
pQloadCtrl->QloadChanUtilTotal = 0;
pQloadCtrl->QloadChanUtilTotalCcaNavTx = 0;
pQloadCtrl->FlgQloadAlarm = FALSE;
pQloadCtrl->QloadAlarmBusyNum = 0;
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
}
}
/*
========================================================================
Routine Description:
Show QoS Load information.
Arguments:
pAd - WLAN control block pointer
Arg - Input arguments
Return Value:
None
Note:
========================================================================
*/
INT Show_QoSLoad_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
#ifdef QLOAD_FUNC_BUSY_TIME_STATS
UINT32 BusyTimeId;
UINT32 Time;
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
Time = pAd->CommonCfg.BeaconPeriod / QLOAD_BUSY_INTERVALS;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("\n\tPrimary Busy Time\tTimes\n"));
for (BusyTimeId = 0; BusyTimeId < QLOAD_BUSY_INTERVALS; BusyTimeId++) {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("\t%dms ~ %dms\t\t%d\n", BusyTimeId * Time,
(BusyTimeId + 1) * Time,
pQloadCtrl->QloadBusyCountPri[BusyTimeId]));
}
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("\n\tSecondary Busy Time\tTimes\n"));
for (BusyTimeId = 0; BusyTimeId < QLOAD_BUSY_INTERVALS; BusyTimeId++) {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("\t%dms ~ %dms\t\t%d\n", BusyTimeId * Time,
(BusyTimeId + 1) * Time,
pQloadCtrl->QloadBusyCountSec[BusyTimeId]));
}
#else
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("\tBusy time statistics is not included into the driver!\n"));
#endif /* QLOAD_FUNC_BUSY_TIME_STATS */
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF, ("\n"));
return TRUE;
}
/*
========================================================================
Routine Description:
Command for QoS Load information clear.
Arguments:
pAd - WLAN control block pointer
Arg - Input arguments
Return Value:
None
Note:
========================================================================
*/
INT Set_QloadClr_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
QBSS_LoadStatusClear(pAd, 1);
QBSS_LoadStatusClear(pAd, 36);
return TRUE;
}
/*
========================================================================
Routine Description:
Command for QoS Alarm Time Threshold set.
Arguments:
pAd - WLAN control block pointer
Arg - Input arguments
Return Value:
None
Note:
========================================================================
*/
INT Set_QloadAlarmTimeThreshold_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *Arg)
{
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
pQloadCtrl->QloadAlarmBusyTimeThreshold = (UCHAR)os_str_tol(Arg, 0, 10);
QBSS_LoadAlarmReset(pAd);
pQloadCtrl->QloadTimePeriodLast = pAd->CommonCfg.BeaconPeriod;
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
return TRUE;
}
/*
========================================================================
Routine Description:
Command for QoS Alarm Number Threshold set.
Arguments:
pAd - WLAN control block pointer
Arg - Input arguments
Return Value:
None
Note:
========================================================================
*/
INT Set_QloadAlarmNumThreshold_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *Arg)
{
#ifdef QLOAD_FUNC_BUSY_TIME_ALARM
QLOAD_CTRL *pQloadCtrl = HcGetQloadCtrl(pAd);
pQloadCtrl->QloadAlarmBusyNumThreshold = (UCHAR)os_str_tol(Arg, 0, 10);
#endif /* QLOAD_FUNC_BUSY_TIME_ALARM */
return TRUE;
}
#endif /* AP_QLOAD_SUPPORT */

View File

@ -1,29 +0,0 @@
/****************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
****************************************************************************
Module Name:
ap_sanity.c
Abstract:
Handle association related requests either from WSTA or from local MLME
Revision History:
Who When What
-------- ---------- ----------------------------------------------
John Chang 08-14-2003 created for 11g soft-AP
John Chang 12-30-2004 merge with STA driver for RT2600
*/
#include "rt_config.h"

View File

@ -1,953 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
ap_sec.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
*/
#include "rt_config.h"
BUILD_TIMER_FUNCTION(GroupRekeyExec);
#ifdef DOT11W_PMF_SUPPORT
VOID APPMFInit(IN RTMP_ADAPTER *pAd, IN struct wifi_dev *wdev)
{
struct _SECURITY_CONFIG *pSecConfig = &wdev->SecConfig;
/*
IEEE 802.11W/P.10 -
A STA that has associated with Management Frame Protection enabled
shall not use pairwise cipher suite selectors WEP-40, WEP-104,
TKIP, or "Use Group cipher suite".
IEEE 802.11W/P.3 -
IEEE Std 802.11 provides one security protocol, CCMP, for protection
of unicast Robust Management frames.
*/
pSecConfig->PmfCfg.MFPC = FALSE;
pSecConfig->PmfCfg.MFPR = FALSE;
pSecConfig->PmfCfg.PMFSHA256 = FALSE;
if (IS_AKM_WPA3PSK(pSecConfig->AKMMap)) {
/* In WPA3 spec, When a WPA3-Personal only BSS is configured,
* Protected Management Frame (PMF) shall be set to required (MFPR=1)
* When WPA2-Personal and WPA3-Personal are configured on the same BSS (mixed mode),
* Protected Management Frame (PMF) shall be set to capable (MFPC = 1, MFPR = 0)
*/
pSecConfig->PmfCfg.MFPC = TRUE;
pSecConfig->PmfCfg.MFPR =
(IS_AKM_WPA2PSK(pSecConfig->AKMMap)) ? FALSE : TRUE;
} else if (IS_AKM_WPA3_192BIT(pSecConfig->AKMMap) ||
IS_AKM_OWE(pSecConfig->AKMMap)
#ifdef DPP_SUPPORT
|| IS_AKM_DPP(pSecConfig->AKMMap)
#endif /* DPP_SUPPORT */
|| IS_AKM_WPA3(pSecConfig->AKMMap)) {
/* In WPA3 spec, When WPA3-Enterprise Suite B is used,
* Protected Management Frame (PMF) shall be set to required (MFPR=1).
*/
pSecConfig->PmfCfg.MFPC = TRUE;
pSecConfig->PmfCfg.MFPR = TRUE;
} else if ((IS_AKM_WPA2(pSecConfig->AKMMap) ||
IS_AKM_WPA2PSK(pSecConfig->AKMMap)) &&
IS_CIPHER_CCMP128(pSecConfig->PairwiseCipher) &&
IS_CIPHER_CCMP128(pSecConfig->GroupCipher) &&
(pSecConfig->PmfCfg.Desired_MFPC
#ifdef OCE_SUPPORT
|| IS_OCE_ENABLE(wdev)
#endif /* OCE_SUPPORT */
)) {
pSecConfig->PmfCfg.MFPC = TRUE;
pSecConfig->PmfCfg.MFPR = pSecConfig->PmfCfg.Desired_MFPR;
if ((pSecConfig->PmfCfg.Desired_PMFSHA256) ||
(pSecConfig->PmfCfg.MFPR))
pSecConfig->PmfCfg.PMFSHA256 = TRUE;
#ifdef OCE_SUPPORT
if (IS_OCE_ENABLE(wdev) &&
pSecConfig->PmfCfg.Desired_MFPC == FALSE)
MTWF_LOG(DBG_CAT_SEC, CATSEC_PMF, DBG_LVL_OFF,
("%s:: Force MFPC on when OCE enable\n",
__func__));
#endif /* OCE_SUPPORT */
} else if (pSecConfig->PmfCfg.Desired_MFPC)
MTWF_LOG(DBG_CAT_SEC, CATSEC_PMF, DBG_LVL_ERROR,
("[PMF]%s:: Security is not WPA2/WPA2PSK AES\n",
__func__));
if (pSecConfig->PmfCfg.MFPC) {
if (IS_AKM_WPA3_192BIT(pSecConfig->AKMMap))
SET_CIPHER_BIP_GMAC256(pSecConfig->PmfCfg.igtk_cipher);
else
SET_CIPHER_BIP_CMAC128(pSecConfig->PmfCfg.igtk_cipher);
}
MTWF_LOG(DBG_CAT_SEC, CATSEC_PMF, DBG_LVL_ERROR,
("[PMF]%s:: apidx=%d, MFPC=%d, MFPR=%d, SHA256=%d\n", __func__,
wdev->func_idx, pSecConfig->PmfCfg.MFPC,
pSecConfig->PmfCfg.MFPR, pSecConfig->PmfCfg.PMFSHA256));
}
#endif /* DOT11W_PMF_SUPPORT */
INT APSecInit(IN RTMP_ADAPTER *pAd, IN struct wifi_dev *wdev)
{
struct _SECURITY_CONFIG *pSecConfig = &wdev->SecConfig;
if (pSecConfig->AKMMap == 0x0)
SET_AKM_OPEN(pSecConfig->AKMMap);
if (pSecConfig->PairwiseCipher == 0x0)
SET_CIPHER_NONE(pSecConfig->PairwiseCipher);
/* Decide Group cipher */
if ((IS_AKM_OPEN(pSecConfig->AKMMap) ||
IS_AKM_SHARED(pSecConfig->AKMMap)) &&
(IS_CIPHER_WEP(pSecConfig->PairwiseCipher))) {
/* WEP */
pSecConfig->GroupCipher = pSecConfig->PairwiseCipher;
pSecConfig->GroupKeyId = pSecConfig->PairwiseKeyId;
} else if (IS_AKM_WPA_CAPABILITY(pSecConfig->AKMMap) &&
IS_CIPHER_TKIP(pSecConfig->PairwiseCipher)) {
/* Mix mode */
SET_CIPHER_TKIP(pSecConfig->GroupCipher);
} else
pSecConfig->GroupCipher = pSecConfig->PairwiseCipher;
/* Default key index is always 2 in WPA mode */
if (IS_AKM_WPA_CAPABILITY(pSecConfig->AKMMap))
pSecConfig->GroupKeyId = 1;
#ifdef DOT11R_FT_SUPPORT
if (wdev->FtCfg.FtCapFlag.Dot11rFtEnable) {
if (IS_AKM_WPA2(pSecConfig->AKMMap))
SET_AKM_FT_WPA2(pSecConfig->AKMMap);
if (IS_AKM_WPA2PSK(pSecConfig->AKMMap))
SET_AKM_FT_WPA2PSK(pSecConfig->AKMMap);
if (IS_AKM_WPA3PSK(pSecConfig->AKMMap))
SET_AKM_FT_SAE_SHA256(pSecConfig->AKMMap);
if (IS_AKM_SUITEB_SHA384(pSecConfig->AKMMap))
SET_AKM_FT_WPA2_SHA384(pSecConfig->AKMMap);
}
#endif /* DOT11R_FT_SUPPORT */
#ifdef DOT11W_PMF_SUPPORT
APPMFInit(pAd, wdev);
#endif /* DOT11W_PMF_SUPPORT */
#ifdef DOT11_SAE_SUPPORT
#ifdef DOT11_SAE_PWD_ID_SUPPORT
if (pSecConfig->pwd_id_cnt == 0) {
pSecConfig->pwd_id_only = FALSE;
DlListInit(&pSecConfig->pwd_id_list_head.list);
}
#endif /* DOT11_SAE_PWD_ID_SUPPORT */
if (IS_AKM_SAE(pSecConfig->AKMMap)) {
BSS_STRUCT *pMbss = &pAd->ApCfg.MBSSID[wdev->func_idx];
sae_derive_pt(&pAd->SaeCfg, pSecConfig->PSK, pMbss->Ssid,
pMbss->SsidLen, &pSecConfig->pt_list);
}
#endif /* DOT11_SAE_SUPPORT */
/* Generate the corresponding RSNIE */
#ifdef HOSTAPD_SUPPORT
if (pAd->ApCfg.MBSSID[wdev->func_id].Hostapd)
return TRUE;
#endif /* HOSTAPD_SUPPORT */
WPAMakeRSNIE(wdev->wdev_type, &wdev->SecConfig, NULL);
return TRUE;
}
INT ap_sec_deinit(IN struct wifi_dev *wdev)
{
#ifdef DOT11_SAE_SUPPORT
struct _SECURITY_CONFIG *pSecConfig = &wdev->SecConfig;
if (IS_AKM_SAE(pSecConfig->AKMMap))
sae_pt_list_deinit(&pSecConfig->pt_list);
#endif
return TRUE;
}
INT APKeyTableInit(IN RTMP_ADAPTER *pAd, IN struct wifi_dev *wdev,
IN STA_REC_CTRL_T *sta_rec)
{
BSS_STRUCT *pMbss = NULL;
struct _SECURITY_CONFIG *pSecConfig = NULL;
ASIC_SEC_INFO *asic_sec_info = &sta_rec->asic_sec_info;
USHORT Wcid = 0;
STA_TR_ENTRY *tr_entry = NULL;
if (wdev == NULL)
return 0;
/*
Initialize security variable per entry,
1. pairwise key table, re-set all WCID entry as NO-security mode.
2. access control port status
*/
/* Init Security variables */
pMbss = &pAd->ApCfg.MBSSID[wdev->func_idx];
pSecConfig = &wdev->SecConfig;
RTMPInitTimer(pAd, &pSecConfig->GroupRekeyTimer,
GET_TIMER_FUNCTION(GroupRekeyExec), pAd, TRUE);
if (IS_AKM_WPA_CAPABILITY(pSecConfig->AKMMap))
pSecConfig->GroupKeyId = 1;
/* Get a specific WCID to record this MBSS key attribute */
Wcid = sta_rec->WlanIdx;
tr_entry = &pAd->MacTab.tr_entry[Wcid];
wdev->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
tr_entry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
/* Set key material to Asic */
os_zero_mem(asic_sec_info, sizeof(ASIC_SEC_INFO));
asic_sec_info->Operation = SEC_ASIC_ADD_GROUP_KEY;
asic_sec_info->Direction = SEC_ASIC_KEY_TX;
asic_sec_info->Wcid = Wcid;
asic_sec_info->BssIndex = wdev->func_idx;
asic_sec_info->Cipher = pSecConfig->GroupCipher;
asic_sec_info->KeyIdx = pSecConfig->GroupKeyId;
os_move_mem(&asic_sec_info->PeerAddr[0], wdev->bssid, MAC_ADDR_LEN);
/* When WEP, TKIP or AES is enabled, set group key info to Asic */
if (IS_CIPHER_WEP(pSecConfig->GroupCipher)) {
INT i;
/* Generate 3-bytes IV randomly for software encryption using */
for (i = 0; i < LEN_WEP_TSC; i++)
pSecConfig->WepKey[asic_sec_info->KeyIdx].TxTsc[i] =
RandomByte(pAd);
os_move_mem(&asic_sec_info->Key,
&pSecConfig->WepKey[asic_sec_info->KeyIdx],
sizeof(SEC_KEY_INFO));
sta_rec->EnableFeature |= STA_REC_INSTALL_KEY_FEATURE;
} else if (IS_CIPHER_TKIP(pSecConfig->GroupCipher) ||
IS_CIPHER_CCMP128(pSecConfig->GroupCipher) ||
IS_CIPHER_CCMP256(pSecConfig->GroupCipher) ||
IS_CIPHER_GCMP128(pSecConfig->GroupCipher) ||
IS_CIPHER_GCMP256(pSecConfig->GroupCipher)) {
struct _SEC_KEY_INFO *pGroupKey = &asic_sec_info->Key;
/* Calculate PMK */
SetWPAPSKKey(pAd, pSecConfig->PSK, strlen(pSecConfig->PSK),
(PUCHAR)pMbss->Ssid, pMbss->SsidLen,
pSecConfig->PMK);
/* Generate GMK and GNonce randomly per MBSS */
GenRandom(pAd, wdev->bssid, pSecConfig->GMK);
GenRandom(pAd, wdev->bssid, pSecConfig->Handshake.GNonce);
/* Derive GTK per BSSID */
WpaDeriveGTK(pSecConfig->GMK,
(UCHAR *)pSecConfig->Handshake.GNonce, wdev->bssid,
(UCHAR *)pSecConfig->GTK, LEN_MAX_GTK);
/* Install Shared key */
os_move_mem(pGroupKey->Key, pSecConfig->GTK, LEN_MAX_GTK);
#ifdef DOT11W_PMF_SUPPORT
if (pSecConfig->PmfCfg.MFPC == TRUE) {
/* IGTK default key index as 4 */
pSecConfig->PmfCfg.IGTK_KeyIdx = 4;
/* Clear IPN */
NdisZeroMemory(&pSecConfig->PmfCfg.IPN[0][0],
LEN_WPA_TSC);
/* Derive IGTK */
PMF_DeriveIGTK(pAd, &pSecConfig->PmfCfg.IGTK[0][0]);
os_move_mem(asic_sec_info->IGTK,
&pSecConfig->PmfCfg.IGTK[0][0],
LEN_MAX_IGTK);
if (IS_CIPHER_BIP_CMAC128(
pSecConfig->PmfCfg.igtk_cipher) ||
IS_CIPHER_BIP_GMAC128(
pSecConfig->PmfCfg.igtk_cipher))
asic_sec_info->IGTKKeyLen = LEN_BIP128_IGTK;
else if (IS_CIPHER_BIP_CMAC256(
pSecConfig->PmfCfg.igtk_cipher) ||
IS_CIPHER_BIP_GMAC256(
pSecConfig->PmfCfg.igtk_cipher))
asic_sec_info->IGTKKeyLen = LEN_BIP256_IGTK;
if (asic_sec_info->IGTKKeyLen != 0)
asic_sec_info->Cipher |=
pSecConfig->PmfCfg.igtk_cipher;
}
#endif /* DOT11W_PMF_SUPPORT */
WPAInstallKey(pAd, asic_sec_info, TRUE, FALSE);
sta_rec->EnableFeature |= STA_REC_INSTALL_KEY_FEATURE;
pSecConfig->Handshake.GTKState = REKEY_ESTABLISHED;
}
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("### BSS(%d) AKM=0x%x, PairwiseCipher=0x%x, GroupCipher=0x%x\n",
wdev->func_idx, pSecConfig->AKMMap, pSecConfig->PairwiseCipher,
pSecConfig->GroupCipher));
return TRUE;
}
VOID GroupRekeyExec(IN PVOID SystemSpecific1, IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
UINT i, apidx;
ULONG temp_counter = 0;
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
PRALINK_TIMER_STRUCT pTimer = (PRALINK_TIMER_STRUCT)SystemSpecific3;
struct wifi_dev *wdev = NULL;
struct _SECURITY_CONFIG *pSecConfig = NULL;
for (apidx = 0; apidx < pAd->ApCfg.BssidNum; apidx++) {
if (&pAd->ApCfg.MBSSID[apidx].wdev.SecConfig.GroupRekeyTimer ==
pTimer)
break;
}
if (apidx == pAd->ApCfg.BssidNum)
return;
wdev = &pAd->ApCfg.MBSSID[apidx].wdev;
pSecConfig = &wdev->SecConfig;
if (pSecConfig->GroupReKeyInterval == 0)
return;
if (pSecConfig->Handshake.GTKState == REKEY_NEGOTIATING) {
pSecConfig->GroupReKeyInstallCountDown--;
if (pSecConfig->GroupReKeyInstallCountDown == 0)
goto INSTALL_KEY;
}
if (pSecConfig->GroupReKeyMethod == SEC_GROUP_REKEY_TIME)
temp_counter = (++pSecConfig->GroupPacketCounter);
else if (pSecConfig->GroupReKeyMethod == SEC_GROUP_REKEY_PACKET)
temp_counter = pSecConfig->GroupPacketCounter /
1000; /* Packet-based: kilo-packets */
else
return;
if (temp_counter > pSecConfig->GroupReKeyInterval) {
UINT entry_count = 0;
pSecConfig->GroupPacketCounter = 0;
pSecConfig->Handshake.GTKState = REKEY_NEGOTIATING;
/* change key index */
pSecConfig->GroupKeyId = (pSecConfig->GroupKeyId == 1) ? 2 : 1;
/* Generate GNonce randomly per MBSS */
GenRandom(pAd, wdev->bssid, pSecConfig->Handshake.GNonce);
/* Derive GTK per BSSID */
WpaDeriveGTK(pSecConfig->GMK,
(UCHAR *)pSecConfig->Handshake.GNonce, wdev->bssid,
(UCHAR *)pSecConfig->GTK, LEN_MAX_GTK);
/* Process 2-way handshaking */
for (i = 0; VALID_UCAST_ENTRY_WCID(pAd, i); i++) {
MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[i];
if (IS_ENTRY_CLIENT(pEntry) &&
(pEntry->SecConfig.Handshake.WpaState ==
AS_PTKINITDONE) &&
(pEntry->func_tb_idx == apidx)) {
#ifdef A4_CONN
if (IS_ENTRY_A4(pEntry))
continue;
#endif /* A4_CONN */
entry_count++;
RTMPSetTimer(
&pEntry->SecConfig.StartFor2WayTimer,
ENQUEUE_EAPOL_2WAY_START_TIMER);
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("Rekey interval excess, Update Group Key for %02X:%02X:%02X:%02X:%02X:%02X , DefaultKeyId= %x\n",
PRINT_MAC(pEntry->Addr),
pSecConfig->GroupKeyId));
}
}
if (entry_count == 0)
goto INSTALL_KEY;
else
pSecConfig->GroupReKeyInstallCountDown =
1; /* 1 seconds */
}
return;
INSTALL_KEY:
/* If no sta connect, directly install group rekey, else install key after 2 way completed or 1 seconds */
{
ASIC_SEC_INFO Info = { 0 };
USHORT Wcid;
/* Get a specific WCID to record this MBSS key attribute */
GET_GroupKey_WCID(wdev, Wcid);
/* Set key material to Asic */
os_zero_mem(&Info, sizeof(ASIC_SEC_INFO));
Info.Operation = SEC_ASIC_ADD_GROUP_KEY;
Info.Direction = SEC_ASIC_KEY_TX;
Info.Wcid = Wcid;
Info.BssIndex = apidx;
Info.Cipher = pSecConfig->GroupCipher;
Info.KeyIdx = pSecConfig->GroupKeyId;
os_move_mem(&Info.PeerAddr[0], BROADCAST_ADDR, MAC_ADDR_LEN);
/* Install Shared key */
os_move_mem(Info.Key.Key, pSecConfig->GTK, LEN_MAX_GTK);
WPAInstallKey(pAd, &Info, TRUE, TRUE);
pSecConfig->Handshake.GTKState = REKEY_ESTABLISHED;
}
}
VOID WPAGroupRekeyByWdev(IN RTMP_ADAPTER *pAd, IN struct wifi_dev *wdev)
{
struct _SECURITY_CONFIG *pSecConfig = &wdev->SecConfig;
if (IS_CIPHER_TKIP(pSecConfig->GroupCipher) ||
IS_CIPHER_CCMP128(pSecConfig->GroupCipher) ||
IS_CIPHER_CCMP256(pSecConfig->GroupCipher) ||
IS_CIPHER_GCMP128(pSecConfig->GroupCipher) ||
IS_CIPHER_GCMP256(pSecConfig->GroupCipher)) {
/* Group rekey related */
if ((pSecConfig->GroupReKeyInterval != 0) &&
((pSecConfig->GroupReKeyMethod == SEC_GROUP_REKEY_TIME) ||
(pSecConfig->GroupReKeyMethod == SEC_GROUP_REKEY_PACKET))) {
pSecConfig->GroupPacketCounter = 0;
RTMPSetTimer(&pSecConfig->GroupRekeyTimer,
GROUP_KEY_UPDATE_EXEC_INTV);
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
(" %s : Group rekey method= %d , interval = 0x%lx\n",
__func__, pSecConfig->GroupReKeyMethod,
pSecConfig->GroupReKeyInterval));
}
}
}
/*
Set group re-key timer if necessary.
It must be processed after clear flag "fRTMP_ADAPTER_HALT_IN_PROGRESS"
*/
VOID APStartRekeyTimer(IN RTMP_ADAPTER *pAd, IN struct wifi_dev *wdev)
{
if (HcIsRadioAcq(wdev)) {
WPAGroupRekeyByWdev(pAd, wdev);
}
}
VOID APStopRekeyTimer(IN RTMP_ADAPTER *pAd, IN struct wifi_dev *wdev)
{
BOOLEAN Cancelled;
RTMPCancelTimer(&wdev->SecConfig.GroupRekeyTimer, &Cancelled);
}
VOID APReleaseRekeyTimer(IN RTMP_ADAPTER *pAd, IN struct wifi_dev *wdev)
{
BOOLEAN Cancelled;
RTMPReleaseTimer(&wdev->SecConfig.GroupRekeyTimer, &Cancelled);
}
static PCHAR portsecured[] = { "NONE", "PORT_SECURED", "NOT_SECURED" };
INT Show_APSecurityInfo_Proc(IN RTMP_ADAPTER *pAd, IN RTMP_STRING *arg)
{
UCHAR idx;
USHORT Wcid;
struct _SECURITY_CONFIG *pSecConfig = NULL;
struct wifi_dev *wdev = NULL;
STA_TR_ENTRY *tr_entry = NULL;
if (!pAd)
return FALSE;
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("Security Infomation: AP\n"));
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("BSS\tWCID\tAuthMode\tPairwiseCipher\tGroupCipher\tGroupKeyId\tPortSecured\n"));
for (idx = 0; idx < pAd->ApCfg.BssidNum; idx++) {
pSecConfig = &pAd->ApCfg.MBSSID[idx].wdev.SecConfig;
wdev = &pAd->ApCfg.MBSSID[idx].wdev;
GET_GroupKey_WCID(wdev, Wcid);
tr_entry = &pAd->MacTab.tr_entry[Wcid];
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_OFF,
(" %d\t%d\t%s\t\t%s\t\t%s\t\t%d\t\t%s\n", idx, Wcid,
GetAuthModeStr(GET_SEC_AKM(pSecConfig)),
GetEncryModeStr(GET_PAIRWISE_CIPHER(pSecConfig)),
GetEncryModeStr(GET_GROUP_CIPHER(pSecConfig)),
pSecConfig->GroupKeyId,
portsecured[tr_entry->PortSecured]));
}
#ifdef DOT11_SAE_PWD_ID_SUPPORT
if (!DlListEmpty(&pSecConfig->pwd_id_list_head.list)) {
struct pwd_id_list *list = NULL;
UCHAR i = 0;
DlListForEach(list, &pSecConfig->pwd_id_list_head.list,
struct pwd_id_list, list)
{
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%d pwdid = %s, pwd = %s\n", i++,
list->pwd_id, list->pwd));
hex_dump_with_lvl("pwdid", list->pwd_id, 40, 1);
hex_dump_with_lvl("pwd", list->pwd, LEN_PSK, 1);
}
}
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("PWDID Required = %d\n", pSecConfig->sae_cap.pwd_id_only));
#endif
#ifdef APCLI_SUPPORT
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("Security Infomation: AP Client\n"));
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("BSS\tWCID\tAuthMode\tPairwiseCipher\tPortSecured\n"));
for (idx = 0; idx < MAX_APCLI_NUM; idx++) {
PAPCLI_STRUCT pApCliEntry = &pAd->ApCfg.ApCliTab[idx];
pSecConfig = &pApCliEntry->wdev.SecConfig;
wdev = &pApCliEntry->wdev;
tr_entry = &pAd->MacTab.tr_entry[wdev->bss_info_argument
.ucBcMcWlanIdx];
if (pApCliEntry->Enable == TRUE) {
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_OFF,
(" %d\t%d\t%s\t\t%s\t\t%s\n", idx,
wdev->bss_info_argument.ucBcMcWlanIdx,
GetAuthModeStr(GET_SEC_AKM(pSecConfig)),
GetEncryModeStr(
GET_PAIRWISE_CIPHER(pSecConfig)),
portsecured[tr_entry->PortSecured]));
}
}
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_OFF, ("\n"));
#endif
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("Security Infomation: STA\n"));
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("BSS\t\t\tAID\tWCID\tAuthMode\tPairwiseCipher\tPortSecured\n"));
for (idx = 0; idx < MAX_LEN_OF_MAC_TABLE; idx++) {
PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[idx];
tr_entry = &pAd->MacTab.tr_entry[pEntry->tr_tb_idx];
pSecConfig = &pEntry->SecConfig;
if (pEntry && IS_ENTRY_CLIENT(pEntry) &&
pEntry->Sst == SST_ASSOC) {
MTWF_LOG(
DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%02X:%02X:%02X:%02X:%02X:%02X\t%d\t%d\t%s\t\t%s\t\t%s\n",
PRINT_MAC(pEntry->Addr), pEntry->Aid,
pEntry->wcid,
GetAuthModeStr(GET_SEC_AKM(pSecConfig)),
GetEncryModeStr(
GET_PAIRWISE_CIPHER(pSecConfig)),
portsecured[tr_entry->PortSecured]));
}
}
return TRUE;
}
VOID CheckBMCPortSecured(IN RTMP_ADAPTER *pAd, IN MAC_TABLE_ENTRY *pEntry,
IN BOOLEAN isConnect)
{
UINT32 bss_index = pEntry->func_tb_idx;
UINT32 wcid;
UCHAR PortSecured = WPA_802_1X_PORT_NOT_SECURED;
MAC_TABLE_ENTRY *pMacEntry = NULL;
STA_TR_ENTRY *tr_entry = NULL;
struct wifi_dev *wdev = &pAd->ApCfg.MBSSID[bss_index].wdev;
if (wdev->tr_tb_idx == 0xff)
return; /* skip uninit tr_tb_idx. */
if (isConnect)
PortSecured = WPA_802_1X_PORT_SECURED;
else {
for (wcid = 1; VALID_UCAST_ENTRY_WCID(pAd, wcid); wcid++) {
pMacEntry = &pAd->MacTab.Content[wcid];
tr_entry = &pAd->MacTab.tr_entry[wcid];
if (wcid == pEntry->wcid)
continue;
if (((pMacEntry) && (IS_ENTRY_CLIENT(pMacEntry)) &&
(pMacEntry->Sst == SST_ASSOC) &&
(pMacEntry->func_tb_idx == bss_index) &&
(tr_entry->PortSecured ==
WPA_802_1X_PORT_SECURED))) {
PortSecured = WPA_802_1X_PORT_SECURED;
break;
}
}
}
if (wdev->PortSecured != PortSecured) {
tr_entry = &pAd->MacTab.tr_entry[wdev->bss_info_argument
.ucBcMcWlanIdx];
tr_entry->PortSecured = PortSecured;
wdev->PortSecured = PortSecured;
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s: bss_index = %d, wcid = %d, PortSecured = %d\n",
__func__, bss_index,
wdev->bss_info_argument.ucBcMcWlanIdx, PortSecured));
}
}
#ifdef DOT1X_SUPPORT
/*
========================================================================
Routine Description:
Sending EAP Req. frame to station in authenticating state.
These frames come from Authenticator deamon.
Arguments:
pAdapter Pointer to our adapter
pPacket Pointer to outgoing EAP frame body + 8023 Header
Len length of pPacket
Return Value:
None
========================================================================
*/
VOID WpaSend(RTMP_ADAPTER *pAdapter, UCHAR *pPacket, ULONG Len)
{
PEAP_HDR pEapHdr;
UCHAR Addr[MAC_ADDR_LEN];
UCHAR Header802_3[LENGTH_802_3];
MAC_TABLE_ENTRY *pEntry;
STA_TR_ENTRY *tr_entry;
PUCHAR pData;
NdisMoveMemory(Addr, pPacket, 6);
NdisMoveMemory(Header802_3, pPacket, LENGTH_802_3);
pEapHdr = (EAP_HDR *)(pPacket + LENGTH_802_3);
pData = (pPacket + LENGTH_802_3);
pEntry = MacTableLookup(pAdapter, Addr);
if (pEntry == NULL) {
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_INFO,
("WpaSend - No such MAC - %02x:%02x:%02x:%02x:%02x:%02x\n",
PRINT_MAC(Addr)));
return;
}
tr_entry = &pAdapter->MacTab.tr_entry[pEntry->wcid];
/* Send EAP frame to STA */
if ((IS_AKM_WPA_CAPABILITY_Entry(pEntry) &&
(pEapHdr->ProType != EAPOLKey)) ||
(IS_IEEE8021X(&pAdapter->ApCfg.MBSSID[pEntry->func_tb_idx]
.wdev.SecConfig)))
RTMPToWirelessSta(pAdapter, pEntry, Header802_3, LENGTH_802_3,
pData, Len - LENGTH_802_3,
(tr_entry->PortSecured ==
WPA_802_1X_PORT_SECURED) ?
FALSE :
TRUE);
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s(%d), pEapHdr->code=%d, pEntry->SecConfig.Handshake.WpaState=%d\n",
__func__, __LINE__, pEapHdr->code,
pEntry->SecConfig.Handshake.WpaState));
if (RTMPEqualMemory((pPacket + 12), EAPOL, 2)) {
switch (pEapHdr->code) {
case EAP_CODE_REQUEST:
if ((pEntry->SecConfig.Handshake.WpaState >=
AS_PTKINITDONE) &&
(pEapHdr->ProType == EAPPacket)) {
pEntry->SecConfig.Handshake.WpaState =
AS_AUTHENTICATION;
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("Start to re-authentication by 802.1x daemon\n"));
}
break;
/* After receiving EAP_SUCCESS, trigger state machine */
case EAP_CODE_SUCCESS:
if (IS_AKM_WPA_CAPABILITY_Entry(pEntry) &&
(pEapHdr->ProType != EAPOLKey)) {
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("Send EAP_CODE_SUCCESS\n\n"));
if (pEntry->Sst == SST_ASSOC) {
UINT8 pmk_len = LEN_PMK;
pEntry->SecConfig.Handshake.WpaState =
AS_INITPMK;
pEntry->SecConfig.Handshake
.MsgRetryCounter = 0;
os_move_mem(
&pEntry->SecConfig.Handshake
.AAddr,
pAdapter->ApCfg
.MBSSID[pEntry->func_tb_idx]
.wdev.bssid,
MAC_ADDR_LEN);
os_move_mem(&pEntry->SecConfig.Handshake
.SAddr,
pEntry->Addr, MAC_ADDR_LEN);
if (pEntry->SecConfig.key_deri_alg ==
SEC_KEY_DERI_SHA384)
pmk_len = LEN_PMK_SHA384;
os_move_mem(
&pEntry->SecConfig.PMK,
&pAdapter->ApCfg
.MBSSID[pEntry->func_tb_idx]
.wdev.SecConfig.PMK,
pmk_len);
WPABuildPairMsg1(pAdapter,
&pEntry->SecConfig,
pEntry);
}
} else {
pEntry->PrivacyFilter =
Ndis802_11PrivFilterAcceptAll;
pEntry->SecConfig.Handshake.WpaState =
AS_PTKINITDONE;
/* 1x+WEP will update port secured in key install stage, todo: change the below code to WifiSysUpdatePortSecur? */
if (IS_CIPHER_NONE(
pEntry->SecConfig.PairwiseCipher)) {
pAdapter->ApCfg
.MBSSID[pEntry->func_tb_idx]
.wdev.PortSecured =
WPA_802_1X_PORT_SECURED;
tr_entry->PortSecured =
WPA_802_1X_PORT_SECURED;
}
#ifdef WSC_AP_SUPPORT
if (pAdapter->ApCfg.MBSSID[pEntry->func_tb_idx]
.wdev.WscControl.WscConfMode !=
WSC_DISABLE)
WscInformFromWPA(pEntry);
#endif /* WSC_AP_SUPPORT */
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("IEEE8021X-WEP : Send EAP_CODE_SUCCESS\n\n"));
}
break;
case EAP_CODE_FAILURE:
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Send Deauth, Reason : REASON_8021X_AUTH_FAIL\n"));
MlmeDeAuthAction(pAdapter, pEntry,
REASON_8021X_AUTH_FAIL, FALSE);
break;
default:
break;
}
} else {
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Send Deauth, Reason : REASON_NO_LONGER_VALID\n"));
MlmeDeAuthAction(pAdapter, pEntry, REASON_NO_LONGER_VALID,
FALSE);
}
}
INT RTMPAddPMKIDCache(IN NDIS_AP_802_11_PMKID *pPMKIDCache, IN INT apidx,
IN UCHAR *pAddr, IN UCHAR *PMKID, IN UCHAR *PMK,
IN UINT8 pmk_len)
{
INT i, CacheIdx;
/* Update PMKID status */
CacheIdx = RTMPSearchPMKIDCache(pPMKIDCache, apidx, pAddr);
if (CacheIdx != INVALID_PMKID_IDX) {
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s(): cache found and renew it(%d)\n", __func__,
CacheIdx));
} else {
ULONG ts = 0;
INT old_entry = 0;
/* Add a new PMKID */
for (i = 0; i < MAX_PMKID_COUNT; i++) {
if (pPMKIDCache->BSSIDInfo[i].Valid == FALSE) {
CacheIdx = i;
break;
}
if ((ts == 0) ||
(ts > pPMKIDCache->BSSIDInfo[i].RefreshTime)) {
ts = pPMKIDCache->BSSIDInfo[i].RefreshTime;
old_entry = i;
}
}
if (i == MAX_PMKID_COUNT) {
CacheIdx = old_entry;
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("%s():Cache full, replace oldest(%d)\n",
__func__, old_entry));
}
}
pPMKIDCache->BSSIDInfo[CacheIdx].Valid = TRUE;
pPMKIDCache->BSSIDInfo[CacheIdx].Mbssidx = apidx;
NdisGetSystemUpTime(&(pPMKIDCache->BSSIDInfo[CacheIdx].RefreshTime));
COPY_MAC_ADDR(&pPMKIDCache->BSSIDInfo[CacheIdx].MAC, pAddr);
NdisMoveMemory(&pPMKIDCache->BSSIDInfo[CacheIdx].PMKID, PMKID,
LEN_PMKID);
NdisMoveMemory(&pPMKIDCache->BSSIDInfo[CacheIdx].PMK, PMK, pmk_len);
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s(): add %02x:%02x:%02x:%02x:%02x:%02x cache(%d) for ra%d\n",
__func__, PRINT_MAC(pAddr), CacheIdx, apidx));
return CacheIdx;
}
INT RTMPSearchPMKIDCache(IN NDIS_AP_802_11_PMKID *pPMKIDCache, IN INT apidx,
IN UCHAR *pAddr)
{
INT i = 0;
for (i = 0; i < MAX_PMKID_COUNT; i++) {
if ((pPMKIDCache->BSSIDInfo[i].Valid == TRUE) &&
(pPMKIDCache->BSSIDInfo[i].Mbssidx == apidx) &&
MAC_ADDR_EQUAL(&pPMKIDCache->BSSIDInfo[i].MAC, pAddr)) {
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s():%02x:%02x:%02x:%02x:%02x:%02x cache(%d) from IF(ra%d)\n",
__func__, PRINT_MAC(pAddr), i, apidx));
break;
}
}
if (i >= MAX_PMKID_COUNT) {
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s(): - IF(%d) not found\n", __func__, apidx));
return INVALID_PMKID_IDX;
}
return i;
}
INT RTMPSearchPMKIDCacheByPmkId(IN NDIS_AP_802_11_PMKID *pPMKIDCache,
IN INT apidx, IN UCHAR *pAddr, IN UCHAR *pPmkId)
{
INT i = 0;
for (i = 0; i < MAX_PMKID_COUNT; i++) {
if ((pPMKIDCache->BSSIDInfo[i].Valid == TRUE) &&
(pPMKIDCache->BSSIDInfo[i].Mbssidx == apidx) &&
MAC_ADDR_EQUAL(&pPMKIDCache->BSSIDInfo[i].MAC, pAddr) &&
RTMPEqualMemory(pPmkId, &pPMKIDCache->BSSIDInfo[i].PMKID,
LEN_PMKID)) {
MTWF_LOG(
DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s():%02x:%02x:%02x:%02x:%02x:%02x cache(%d) from IF(ra%d)\n",
__func__, PRINT_MAC(pAddr), i, apidx));
break;
}
}
if (i >= MAX_PMKID_COUNT) {
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s(): - IF(%d) not found\n", __func__, apidx));
return INVALID_PMKID_IDX;
}
return i;
}
INT RTMPValidatePMKIDCache(IN NDIS_AP_802_11_PMKID *pPMKIDCache, IN INT apidx,
IN UCHAR *pAddr, IN UCHAR *pPMKID)
{
INT CacheIdx = RTMPSearchPMKIDCache(pPMKIDCache, apidx, pAddr);
if (CacheIdx == INVALID_PMKID_IDX)
return INVALID_PMKID_IDX;
if (RTMPEqualMemory(pPMKID, &pPMKIDCache->BSSIDInfo[CacheIdx].PMKID,
LEN_PMKID))
return CacheIdx;
else
return INVALID_PMKID_IDX;
}
VOID RTMPDeletePMKIDCache(IN NDIS_AP_802_11_PMKID *pPMKIDCache, IN INT apidx,
IN INT idx)
{
PAP_BSSID_INFO pInfo = &pPMKIDCache->BSSIDInfo[idx];
if (pInfo->Valid && (pInfo->Mbssidx == apidx)) {
pInfo->Valid = FALSE;
MTWF_LOG(DBG_CAT_SEC, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s():(IF(%d), del PMKID CacheIdx=%d\n", __func__,
apidx, idx));
}
}
VOID RTMPMaintainPMKIDCache(IN RTMP_ADAPTER *pAd)
{
INT i;
ULONG Now;
for (i = 0; i < MAX_PMKID_COUNT; i++) {
PAP_BSSID_INFO pBssInfo = &pAd->ApCfg.PMKIDCache.BSSIDInfo[i];
NdisGetSystemUpTime(&Now);
if ((pBssInfo->Valid) && /*((Now - pBssInfo->RefreshTime) >= pMbss->PMKCachePeriod)*/
(RTMP_TIME_AFTER(Now, (pBssInfo->RefreshTime +
pAd->ApCfg.MBSSID[pBssInfo->Mbssidx]
.PMKCachePeriod))))
RTMPDeletePMKIDCache(&pAd->ApCfg.PMKIDCache,
pBssInfo->Mbssidx, i);
}
}
UCHAR is_rsne_pmkid_cache_match(IN UINT8 *rsnie, IN UINT rsnie_len,
IN NDIS_AP_802_11_PMKID *pmkid_cache,
IN INT apidx, IN UCHAR *addr, OUT INT *cacheidx)
{
UINT8 *pmkid = NULL;
UINT8 pmkid_count;
pmkid = WPA_ExtractSuiteFromRSNIE(rsnie, rsnie_len, PMKID_LIST,
&pmkid_count);
if (pmkid != NULL) {
*cacheidx =
RTMPValidatePMKIDCache(pmkid_cache, apidx, addr, pmkid);
return TRUE;
}
return FALSE;
}
#endif /* DOT1X_SUPPORT */

View File

@ -1,108 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
ap_wds.c
Abstract:
Support WDS function.
Revision History:
Who When What
------ ---------- ----------------------------------------------
Fonchi 02-13-2007 created
*/
#define RTMP_MODULE_OS
#ifdef WDS_SUPPORT
/*#include "rt_config.h" */
#include "rtmp_comm.h"
#include "rt_os_util.h"
#include "rt_os_net.h"
NET_DEV_STATS *RT28xx_get_wds_ether_stats(PNET_DEV net_dev);
/* Register WDS interface */
VOID RT28xx_WDS_Init(VOID *pAd, PNET_DEV net_dev)
{
RTMP_OS_NETDEV_OP_HOOK netDevOpHook;
NdisZeroMemory((PUCHAR)&netDevOpHook, sizeof(RTMP_OS_NETDEV_OP_HOOK));
netDevOpHook.open = wds_virtual_if_open;
netDevOpHook.stop = wds_virtual_if_close;
netDevOpHook.xmit = rt28xx_send_packets;
netDevOpHook.ioctl = rt28xx_ioctl;
netDevOpHook.get_stats = RT28xx_get_wds_ether_stats;
NdisMoveMemory(&netDevOpHook.devAddr[0],
RTMP_OS_NETDEV_GET_PHYADDR(net_dev), MAC_ADDR_LEN);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("The new WDS interface MAC = %02X:%02X:%02X:%02X:%02X:%02X\n",
PRINT_MAC(netDevOpHook.devAddr)));
RTMP_AP_IoctlHandle(pAd, NULL, CMD_RTPRIV_IOCTL_WDS_INIT, 0,
&netDevOpHook, 0);
}
INT wds_virtual_if_open(PNET_DEV pDev)
{
VOID *pAd;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%s: ===> %s\n", RTMP_OS_NETDEV_GET_DEVNAME(pDev), __func__));
pAd = RTMP_OS_NETDEV_GET_PRIV(pDev);
if (VIRTUAL_IF_INIT(pAd, pDev) != 0)
return -1;
if (VIRTUAL_IF_UP(pAd, pDev) != 0)
return -1;
/* increase MODULE use count */
RT_MOD_INC_USE_COUNT();
RT_MOD_HNAT_REG(pDev);
RTMP_OS_NETDEV_START_QUEUE(pDev);
return 0;
}
INT wds_virtual_if_close(PNET_DEV pDev)
{
VOID *pAd;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%s: ===> %s\n", RTMP_OS_NETDEV_GET_DEVNAME(pDev), __func__));
pAd = RTMP_OS_NETDEV_GET_PRIV(pDev);
/* RTMP_OS_NETDEV_CARRIER_OFF(pDev); */
RTMP_OS_NETDEV_STOP_QUEUE(pDev);
VIRTUAL_IF_DOWN(pAd, pDev);
VIRTUAL_IF_DEINIT(pAd, pDev);
RT_MOD_HNAT_DEREG(pDev);
RT_MOD_DEC_USE_COUNT();
return 0;
}
VOID RT28xx_WDS_Remove(VOID *pAd)
{
RTMP_AP_IoctlHandle(pAd, NULL, CMD_RTPRIV_IOCTL_WDS_REMOVE, 0, NULL, 0);
}
#endif /* WDS_SUPPORT */

View File

@ -1,229 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
wpa.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Jan Lee 03-07-22 Initial
Rory Chen 04-11-29 Add WPA2PSK
*/
#include "rt_config.h"
extern UCHAR EAPOL[];
/*
==========================================================================
Description:
Port Access Control Inquiry function. Return entry's Privacy and Wpastate.
Return:
pEntry
==========================================================================
*/
MAC_TABLE_ENTRY *PACInquiry(RTMP_ADAPTER *pAd, UCHAR Wcid)
{
MAC_TABLE_ENTRY *pEntry = NULL;
if (VALID_UCAST_ENTRY_WCID(pAd, Wcid))
pEntry = &(pAd->MacTab.Content[Wcid]);
return pEntry;
}
/*
==========================================================================
Description:
Function to handle countermeasures active attack. Init 60-sec timer if necessary.
Return:
==========================================================================
*/
VOID HandleCounterMeasure(RTMP_ADAPTER *pAd, MAC_TABLE_ENTRY *pEntry)
{
#ifndef RT_CFG80211_SUPPORT
INT i;
#endif
BOOLEAN Cancelled;
if (!pEntry)
return;
/* Todo by AlbertY - Not support currently in ApClient-link */
if (IS_ENTRY_APCLI(pEntry) || IS_ENTRY_REPEATER(pEntry))
return;
#ifndef RT_CFG80211_SUPPORT
/* if entry not set key done, ignore this RX MIC ERROR */
if ((pEntry->SecConfig.Handshake.WpaState < AS_PTKINITDONE) ||
(pEntry->SecConfig.Handshake.GTKState != REKEY_ESTABLISHED))
return;
#endif
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("HandleCounterMeasure ===>\n"));
/* record which entry causes this MIC error, if this entry sends disauth/disassoc, AP doesn't need to log the CM */
pEntry->CMTimerRunning = TRUE;
pAd->ApCfg.MICFailureCounter++;
/* send wireless event - for MIC error */
RTMPSendWirelessEvent(pAd, IW_MIC_ERROR_EVENT_FLAG, pEntry->Addr, 0, 0);
#ifdef RT_CFG80211_SUPPORT
{
const UCHAR tsc[6] = { 0, 0, 0, 0, 0, 0 };
PNET_DEV pNetDev =
pAd->ApCfg.MBSSID[pEntry->func_tb_idx].wdev.if_dev;
/* NL80211_KEYTYPE_PAIRWISE = 1, tsc = tsc of frame causing mic failure */
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s:calling cfg event to HandleCounterMeasure\n",
__FUNCTION__));
cfg80211_michael_mic_failure(pNetDev, pEntry->Addr, 1, 0, tsc,
GFP_KERNEL);
}
#endif
if (pAd->ApCfg.CMTimerRunning == TRUE) {
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("Receive CM Attack Twice within 60 seconds ====>>>\n"));
/* send wireless event - for counter measures */
RTMPSendWirelessEvent(pAd, IW_COUNTER_MEASURES_EVENT_FLAG,
pEntry->Addr, 0, 0);
ApLogEvent(pAd, pEntry->Addr, EVENT_COUNTER_M);
#ifndef RT_CFG80211_SUPPORT
/* renew GTK */
GenRandom(pAd,
pAd->ApCfg.MBSSID[pEntry->func_tb_idx].wdev.bssid,
pAd->ApCfg.MBSSID[pEntry->func_tb_idx].GNonce);
#endif
/* Cancel CounterMeasure Timer */
RTMPCancelTimer(&pAd->ApCfg.CounterMeasureTimer, &Cancelled);
pAd->ApCfg.CMTimerRunning = FALSE;
#ifndef RT_CFG80211_SUPPORT
for (i = 0; VALID_UCAST_ENTRY_WCID(pAd, i); i++) {
struct wifi_dev *wdev = pAd->MacTab.Content[i].wdev;
/* happened twice within 60 sec, AP SENDS disaccociate all associated STAs. All STA's transition to State 2 */
if ((IS_ENTRY_CLIENT(&pAd->MacTab.Content[i])) &&
wdev != NULL &&
wdev->channel == pEntry->wdev->channel) {
#ifdef MAP_R2
if (IS_MAP_ENABLE(pAd) && IS_MAP_R2_ENABLE(pAd))
wapp_handle_sta_disassoc(
pAd, i, REASON_MIC_FAILURE);
#endif
MlmeDeAuthAction(pAd, &pAd->MacTab.Content[i],
REASON_MIC_FAILURE, FALSE);
}
}
#endif
/*
Further, ban all Class 3 DATA transportation for a period 0f 60 sec
disallow new association , too
*/
pAd->ApCfg.BANClass3Data = TRUE;
/* check how many entry left... should be zero */
/*pAd->ApCfg.MBSSID[pEntry->func_tb_idx].GKeyDoneStations = pAd->MacTab.Size; */
/*MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("GKeyDoneStations=%d\n", pAd->ApCfg.MBSSID[pEntry->func_tb_idx].GKeyDoneStations)); */
}
RTMPSetTimer(&pAd->ApCfg.CounterMeasureTimer,
60 * MLME_TASK_EXEC_INTV * MLME_TASK_EXEC_MULTIPLE);
pAd->ApCfg.CMTimerRunning = TRUE;
pAd->ApCfg.PrevaMICFailTime = pAd->ApCfg.aMICFailTime;
RTMP_GetCurrentSystemTime(&pAd->ApCfg.aMICFailTime);
}
/*
==========================================================================
Description:
countermeasures active attack timer execution
Return:
==========================================================================
*/
VOID CMTimerExec(IN PVOID SystemSpecific1, IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
UINT i, j = 0;
PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)FunctionContext;
pAd->ApCfg.BANClass3Data = FALSE;
for (i = 0; VALID_UCAST_ENTRY_WCID(pAd, i); i++) {
if (IS_ENTRY_CLIENT(&pAd->MacTab.Content[i]) &&
(pAd->MacTab.Content[i].CMTimerRunning == TRUE)) {
pAd->MacTab.Content[i].CMTimerRunning = FALSE;
j++;
}
}
if (j > 1)
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("Find more than one entry which generated MIC Fail ..\n"));
pAd->ApCfg.CMTimerRunning = FALSE;
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("Counter measure timer expired, resume connection access.\n"));
}
#ifdef HOSTAPD_SUPPORT
/*for sending an event to notify hostapd about michael failure. */
VOID ieee80211_notify_michael_failure(IN PRTMP_ADAPTER pAd,
IN PHEADER_802_11 pHeader, IN UINT keyix,
IN INT report)
{
static const char *tag = "MLME-MICHAELMICFAILURE.indication";
/* struct net_device *dev = pAd->net_dev; */
/* union iwreq_data wrqu; */
char buf[128]; /* XXX */
/* TODO: needed parameters: count, keyid, key type, src address, TSC */
if (report) { /*station reports a mic error to this ap. */
snprintf(buf, sizeof(buf), "%s(keyid=%d %scast addr=%s)", tag,
keyix, "uni", ether_sprintf(pHeader->Addr2));
} else { /*ap itself receives a mic error. */
snprintf(buf, sizeof(buf), "%s(keyid=%d %scast addr=%s)", tag,
keyix,
IEEE80211_IS_MULTICAST(pHeader->Addr1) ? "broad" :
"uni",
ether_sprintf(pHeader->Addr2));
}
RtmpOSWrielessEventSend(pAd->net_dev, RT_WLAN_EVENT_CUSTOM, -1, NULL,
NULL, 0);
/* NdisZeroMemory(&wrqu, sizeof(wrqu)); */
/* wrqu.data.length = strlen(buf); */
/* wireless_send_event(dev, RT_WLAN_EVENT_CUSTOM, &wrqu, buf); */
}
const CHAR *ether_sprintf(const UINT8 *mac)
{
static char etherbuf[18];
snprintf(etherbuf, sizeof(etherbuf), "%02x:%02x:%02x:%02x:%02x:%02x",
PRINT_MAC(mac));
return etherbuf;
}
#endif /* HOSTAPD_SUPPORT */
#ifdef APCLI_SUPPORT
#endif /*APCLI_SUPPORT*/

View File

@ -1,136 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002-2006, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
apcli_ctrl.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Fonchi 2006-06-23 modified for rt61-APClinent
*/
#ifdef APCLI_SUPPORT
#ifdef APCLI_LINK_COVER_SUPPORT
#include "rt_config.h"
extern VOID *p5G_pAd;
extern VOID *p2G_pAd;
INT ApcliLinkMonitorThread(IN ULONG Context)
{
RTMP_ADAPTER *pAd;
RTMP_ADAPTER *pAd_other_band;
RTMP_OS_TASK *pTask;
int status = 0;
pTask = (RTMP_OS_TASK *)Context;
pAd = (PRTMP_ADAPTER)RTMP_OS_TASK_DATA_GET(pTask);
RtmpOSTaskCustomize(pTask);
if (p2G_pAd == NULL) {
MTWF_LOG(DBG_CAT_CLIENT, CATCLIENT_APCLI, DBG_LVL_TRACE,
("##### no 2G pAd!!!\n"));
/* RtmpOSTaskNotifyToExit(pTask); */
/* return 0; */
} else if (p5G_pAd == NULL) {
MTWF_LOG(DBG_CAT_CLIENT, CATCLIENT_APCLI, DBG_LVL_TRACE,
("##### no 5G pAd!!!\n"));
/* RtmpOSTaskNotifyToExit(pTask); */
/* return 0; */
}
if (p5G_pAd == pAd) {
MTWF_LOG(DBG_CAT_CLIENT, CATCLIENT_APCLI, DBG_LVL_TRACE,
("we are 5G interface, wait 2G link update\n"));
pAd_other_band = p2G_pAd;
} else {
MTWF_LOG(DBG_CAT_CLIENT, CATCLIENT_APCLI, DBG_LVL_TRACE,
("we are 2G interface, wait 5G link update\n"));
pAd_other_band = p5G_pAd;
}
while (pTask && !RTMP_OS_TASK_IS_KILLED(pTask) &&
(pAd_other_band != NULL)) {
if (RtmpOSTaskWait(pAd, pTask, &status) == FALSE) {
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
break;
}
if (status != 0)
break;
/* TODO: wait_for_completion */
}
/* notify the exit routine that we're actually exiting now
*
* complete()/wait_for_completion() is similar to up()/down(),
* except that complete() is safe in the case where the structure
* is getting deleted in a parallel mode of execution (i.e. just
* after the down() -- that's necessary for the thread-shutdown
* case.
*
* complete_and_exit() goes even further than this -- it is safe in
* the case that the thread of the caller is going away (not just
* the structure) -- this is necessary for the module-remove case.
* This is important in preemption kernels, which transfer the flow
* of execution immediately upon a complete().
*/
MTWF_LOG(DBG_CAT_CLIENT, CATCLIENT_APCLI, DBG_LVL_TRACE,
("<---ApcliLinkMonitorThread\n"));
/* if (pTask) */
/* RtmpOSTaskNotifyToExit(pTask); */
return 0;
}
NDIS_STATUS RtmpApcliLinkTaskInit(IN PRTMP_ADAPTER pAd)
{
RTMP_OS_TASK *pTask;
NDIS_STATUS status;
/* Creat ApCli Link Monitor Thread */
pTask = &pAd->apcliLinkTask;
RTMP_OS_TASK_INIT(pTask, "LinkMonitorTask", pAd);
/* status = RtmpOSTaskAttach(pTask, RTPCICmdThread, (ULONG)pTask); */
status = RtmpOSTaskAttach(pTask, ApcliLinkMonitorThread, (ULONG)pTask);
if (status == NDIS_STATUS_FAILURE) {
MTWF_LOG(DBG_CAT_CLIENT, CATCLIENT_APCLI, DBG_LVL_TRACE,
("%s: Unable to start ApcliLinkMonitorThread!\n",
get_dev_name_prefix(pAd, INT_APCLI)));
return NDIS_STATUS_FAILURE;
}
return NDIS_STATUS_SUCCESS;
}
VOID RtmpApcliLinkTaskExit(IN RTMP_ADAPTER *pAd)
{
INT ret;
/* Terminate cmdQ thread */
if (RTMP_OS_TASK_LEGALITY(&pAd->apcliLinkTask)) {
/*RTUSBCMDUp(&pAd->cmdQTask); */
ret = RtmpOSTaskKill(&pAd->apcliLinkTask);
if (ret == NDIS_STATUS_FAILURE)
MTWF_LOG(DBG_CAT_CLIENT, CATCLIENT_APCLI, DBG_LVL_ERROR,
("Kill command task fail!\n"));
}
}
#endif /* APCLI_LINK_COVER_SUPPORT */
#endif /* APCLI_SUPPORT */

View File

@ -1,768 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2009, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
a4_conn.c
Abstract:
This is A4 connection function used to process those 4-addr of connected APClient or STA.
Used by MWDS and MAP feature
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#ifdef A4_CONN
#include "rt_config.h"
BOOLEAN a4_interface_init(IN PRTMP_ADAPTER adapter, IN UCHAR if_index,
IN BOOLEAN is_ap, IN UCHAR a4_type)
{
BSS_STRUCT *mbss = NULL;
BOOLEAN add_inf = FALSE;
if (is_ap) {
if (if_index >= HW_BEACON_MAX_NUM)
return FALSE;
mbss = &adapter->ApCfg.MBSSID[if_index];
if (mbss->a4_init == 0) {
NdisAllocateSpinLock(adapter, &mbss->a4_entry_lock);
DlListInit(&mbss->a4_entry_list);
RoutingTabInit(adapter, if_index, ROUTING_ENTRY_A4);
add_inf = TRUE;
}
mbss->a4_init |= (1 << a4_type);
}
#ifdef APCLI_SUPPORT
else {
PAPCLI_STRUCT apcli_entry;
if (if_index >= MAX_APCLI_NUM)
return FALSE;
apcli_entry = &adapter->ApCfg.ApCliTab[if_index];
if (apcli_entry->a4_init == 0)
add_inf = TRUE;
apcli_entry->a4_init |= (1 << a4_type);
}
#else
else
return FALSE;
#endif
if (add_inf) {
if (adapter->a4_interface_count == 0)
MtCmdSetA4Enable(adapter, HOST2CR4, TRUE);
adapter->a4_interface_count++;
}
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("a4_interface_init a4_interface_count: %d\n",
adapter->a4_interface_count));
return TRUE;
}
BOOLEAN a4_interface_deinit(IN PRTMP_ADAPTER adapter, IN UCHAR if_index,
IN BOOLEAN is_ap, IN UCHAR a4_type)
{
BSS_STRUCT *mbss = NULL;
PA4_CONNECT_ENTRY a4_entry = NULL, pConnEntryTmp = NULL;
PDL_LIST a4_entry_list = NULL;
PMAC_TABLE_ENTRY entry = NULL;
BOOLEAN delete_inf = FALSE;
if (is_ap) {
if (if_index >= HW_BEACON_MAX_NUM)
return FALSE;
mbss = &adapter->ApCfg.MBSSID[if_index];
if (mbss->a4_init) {
a4_entry_list = &mbss->a4_entry_list;
DlListForEachSafe(a4_entry, pConnEntryTmp,
a4_entry_list, A4_CONNECT_ENTRY, List)
{
if (a4_entry) {
entry = &adapter->MacTab
.Content[a4_entry->wcid];
a4_ap_peer_disable(adapter, entry,
a4_type);
}
}
mbss->a4_init &= ~(1 << a4_type);
if (!mbss->a4_init) {
NdisFreeSpinLock(&mbss->a4_entry_lock);
RoutingTabDestory(adapter, if_index,
ROUTING_ENTRY_A4);
delete_inf = TRUE;
}
}
}
#ifdef APCLI_SUPPORT
else {
PAPCLI_STRUCT apcli_entry;
if (if_index >= MAX_APCLI_NUM)
return FALSE;
apcli_entry = &adapter->ApCfg.ApCliTab[if_index];
if (apcli_entry->a4_init) {
apcli_entry->a4_init &= ~(1 << a4_type);
if (!apcli_entry->a4_init)
delete_inf = TRUE;
}
}
#else
else
return FALSE;
#endif
if (delete_inf) {
adapter->a4_interface_count--;
if (adapter->a4_interface_count == 0)
MtCmdSetA4Enable(adapter, HOST2CR4, FALSE);
}
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("a4_interface_init a4_interface_count: %d\n",
adapter->a4_interface_count));
return TRUE;
}
INT a4_get_entry_count(IN PRTMP_ADAPTER adapter, IN UCHAR if_index)
{
int count = 0;
BSS_STRUCT *mbss = NULL;
if (if_index >= HW_BEACON_MAX_NUM)
return 0;
mbss = &adapter->ApCfg.MBSSID[if_index];
if (!mbss->a4_init)
return 0;
count = DlListLen(&mbss->a4_entry_list);
return count;
}
BOOLEAN a4_lookup_entry_by_wcid(IN PRTMP_ADAPTER adapter, IN UCHAR if_index,
IN UCHAR wcid)
{
BSS_STRUCT *mbss = NULL;
PDL_LIST a4_entry_list = NULL;
PA4_CONNECT_ENTRY a4_entry = NULL;
BOOLEAN found = FALSE;
if (a4_get_entry_count(adapter, if_index) == 0)
return FALSE;
mbss = &adapter->ApCfg.MBSSID[if_index];
a4_entry_list = &mbss->a4_entry_list;
DlListForEach(a4_entry, a4_entry_list, A4_CONNECT_ENTRY, List)
{
if (a4_entry && a4_entry->valid && (a4_entry->wcid == wcid)) {
found = TRUE;
break;
}
}
return found;
}
BOOLEAN a4_lookup_entry_by_addr(IN PRTMP_ADAPTER adapter, IN UCHAR if_index,
IN PUCHAR mac_addr)
{
BSS_STRUCT *mbss = NULL;
PDL_LIST a4_entry_list = NULL;
PA4_CONNECT_ENTRY a4_entry = NULL;
PMAC_TABLE_ENTRY entry = NULL;
BOOLEAN found = FALSE;
if ((a4_get_entry_count(adapter, if_index) == 0) || (mac_addr == NULL))
return FALSE;
mbss = &adapter->ApCfg.MBSSID[if_index];
a4_entry_list = &mbss->a4_entry_list;
DlListForEach(a4_entry, a4_entry_list, A4_CONNECT_ENTRY, List)
{
if (a4_entry && a4_entry->valid && VALID_WCID(a4_entry->wcid)) {
entry = &adapter->MacTab.Content[a4_entry->wcid];
if (MAC_ADDR_EQUAL(mac_addr, entry->Addr)) {
found = TRUE;
break;
}
}
}
return found;
}
VOID a4_add_entry(IN PRTMP_ADAPTER adapter, IN UCHAR if_index, IN UCHAR wcid)
{
BSS_STRUCT *mbss = NULL;
PA4_CONNECT_ENTRY a4_entry = NULL;
if (a4_lookup_entry_by_wcid(adapter, if_index, wcid))
return;
mbss = &adapter->ApCfg.MBSSID[if_index];
os_alloc_mem(adapter, (UCHAR **)&a4_entry, sizeof(A4_CONNECT_ENTRY));
if (a4_entry) {
NdisZeroMemory(a4_entry, sizeof(A4_CONNECT_ENTRY));
a4_entry->valid = 1;
a4_entry->wcid = wcid;
RTMP_SEM_LOCK(&mbss->a4_entry_lock);
DlListAddTail(&mbss->a4_entry_list, &a4_entry->List);
RTMP_SEM_UNLOCK(&mbss->a4_entry_lock);
} else
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s: Fail to alloc memory for pNewConnEntry\n",
__func__));
}
VOID a4_delete_entry(IN PRTMP_ADAPTER adapter, IN UCHAR if_index, IN UCHAR wcid)
{
BSS_STRUCT *mbss = NULL;
PA4_CONNECT_ENTRY a4_entry = NULL;
PDL_LIST a4_entry_list = NULL;
if (a4_get_entry_count(adapter, if_index) == 0)
return;
mbss = &adapter->ApCfg.MBSSID[if_index];
a4_entry_list = &mbss->a4_entry_list;
RTMP_SEM_LOCK(&mbss->a4_entry_lock);
DlListForEach(a4_entry, a4_entry_list, A4_CONNECT_ENTRY, List)
{
if (a4_entry && a4_entry->valid && (a4_entry->wcid == wcid)) {
DlListDel(&a4_entry->List);
os_free_mem(a4_entry);
break;
}
}
RTMP_SEM_UNLOCK(&mbss->a4_entry_lock);
}
VOID a4_proxy_delete(IN PRTMP_ADAPTER adapter, IN UCHAR if_index,
IN PUCHAR mac_addr)
{
if (a4_get_entry_count(adapter, if_index) == 0)
return;
RoutingTabSetOneFree(adapter, if_index, mac_addr, ROUTING_ENTRY_A4);
}
BOOLEAN a4_get_dst_ip(void *pkt, unsigned char *ip)
{
UCHAR *pSrcBuf;
UINT16 TypeLen;
UINT32 type_len_idx = 12;
UCHAR *ip_header = NULL;
pSrcBuf = pkt;
TypeLen = (pSrcBuf[type_len_idx] << 8) | pSrcBuf[type_len_idx + 1];
while (TypeLen == ETH_TYPE_VLAN) {
type_len_idx += 2;
TypeLen = (pSrcBuf[type_len_idx] << 8) |
pSrcBuf[type_len_idx + 1];
}
if (TypeLen == ETH_TYPE_IPv4) {
ip_header = &pSrcBuf[type_len_idx + 2];
NdisCopyMemory(ip, ip_header + 16, 4);
return TRUE;
}
return FALSE;
}
BOOLEAN a4_proxy_lookup(IN PRTMP_ADAPTER adapter, IN UCHAR if_index,
IN PUCHAR mac_addr, IN BOOLEAN update_alive_time,
IN BOOLEAN is_rx, OUT UCHAR *wcid)
{
*wcid = 0;
if (a4_get_entry_count(adapter, if_index) == 0) {
return FALSE;
}
if (RoutingTabLookup(adapter, if_index, mac_addr, update_alive_time,
wcid) != NULL)
return TRUE;
else {
return FALSE;
}
}
VOID a4_proxy_update(IN PRTMP_ADAPTER adapter, IN UCHAR if_index, IN UCHAR wcid,
IN PUCHAR mac_addr, IN UINT32 ip /* ARP Sender IP*/
)
{
UCHAR proxy_wcid = 0;
BOOLEAN found = FALSE;
PROUTING_ENTRY routing_entry = NULL;
if (a4_get_entry_count(adapter, if_index) == 0)
return;
if (!VALID_WCID(wcid) || !mac_addr)
return;
routing_entry = RoutingTabLookup(adapter, if_index, mac_addr, TRUE,
&proxy_wcid);
found = (routing_entry != NULL) ? TRUE : FALSE;
if (found) {
if (ROUTING_ENTRY_TEST_FLAG(routing_entry, ROUTING_ENTRY_A4)) {
/* Mean the target change to other ProxyAP */
if (proxy_wcid != wcid) {
RoutingTabSetOneFree(adapter, if_index,
mac_addr,
ROUTING_ENTRY_A4);
routing_entry = NULL;
found = FALSE;
}
} else {
/* Assign A4 falg to this one if found. */
SET_ROUTING_ENTRY(routing_entry, ROUTING_ENTRY_A4);
}
}
if (!found) {
/* Allocate a new one if not found. */
routing_entry = RoutingTabGetFree(adapter, if_index);
if (routing_entry) {
SET_ROUTING_ENTRY(routing_entry, ROUTING_ENTRY_A4);
RoutingEntrySet(adapter, if_index, wcid, mac_addr,
routing_entry);
}
}
if (routing_entry != NULL && (ip != 0)) /* ARP Sender IP Update*/
RoutingTabARPLookupUpdate(adapter, if_index, routing_entry, ip);
}
VOID a4_proxy_maintain(IN PRTMP_ADAPTER adapter, IN UCHAR if_index)
{
if (a4_get_entry_count(adapter, if_index) == 0)
return;
RoutingTabMaintain(adapter, if_index);
}
INT a4_hard_transmit(IN PRTMP_ADAPTER adapter, IN struct wifi_dev *wdev,
IN PNDIS_PACKET pkt)
{
UINT pkt_len;
INT ret = NDIS_STATUS_SUCCESS;
UCHAR wcid = RESERVED_WCID;
struct wifi_dev_ops *ops = wdev->wdev_ops;
/* Precautionary measure */
if (RTMP_GET_PACKET_WCID(pkt) == 0) {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("invalid wcid=0 in a4_hard_transmit\n"));
RELEASE_NDIS_PACKET(adapter, pkt, NDIS_STATUS_FAILURE);
return ret;
}
if (IS_ASIC_CAP(adapter, fASIC_CAP_MCU_OFFLOAD))
ret = ops->fp_send_data_pkt(adapter, wdev, pkt);
else {
wcid = RTMP_GET_PACKET_WCID(pkt);
pkt_len = GET_OS_PKT_LEN(pkt);
if ((pkt_len <= 14) ||
(!RTMPCheckEtherType(adapter, pkt,
&adapter->MacTab.tr_entry[wcid],
wdev))) {
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("Pkt Len/Ethernet Check Fail\n"));
RELEASE_NDIS_PACKET(adapter, pkt, NDIS_STATUS_FAILURE);
return ret;
}
ret = ops->send_data_pkt(adapter, wdev, pkt);
}
return ret;
}
PNDIS_PACKET a4_clone_packet(IN PRTMP_ADAPTER adapter, IN PNET_DEV if_dev,
IN PNDIS_PACKET pkt)
{
struct sk_buff *skb = NULL;
PNDIS_PACKET pkt_clone = NULL;
skb = skb_copy(RTPKT_TO_OSPKT(pkt), GFP_ATOMIC);
if (skb) {
skb->dev = if_dev;
pkt_clone = OSPKT_TO_RTPKT(skb);
}
return pkt_clone;
}
void a4_send_clone_pkt(IN PRTMP_ADAPTER adapter, IN UCHAR if_index,
IN PNDIS_PACKET pkt, IN PUCHAR exclude_mac_addr)
{
struct wifi_dev *wdev = NULL;
PNDIS_PACKET pkt_clone = NULL;
PDL_LIST a4_entry_list = NULL;
PA4_CONNECT_ENTRY a4_entry = NULL;
PROUTING_ENTRY routing_entry = NULL;
PMAC_TABLE_ENTRY entry = NULL;
#ifdef MAP_TS_TRAFFIC_SUPPORT
PMAC_TABLE_ENTRY peer_entry = NULL;
#endif
BOOLEAN found = FALSE;
UCHAR wcid = 0;
struct wifi_dev *ap_wdev = NULL;
if (!pkt)
return;
if ((a4_get_entry_count(adapter, if_index) > 0)) {
ap_wdev = &adapter->ApCfg.MBSSID[if_index].wdev;
#if (defined(IGMP_SNOOP_SUPPORT) && defined(IGMP_TX_QUERY_HOLD))
if (ap_wdev->IgmpSnoopEnable) { /* If snooping enabled*/
UCHAR *pDestAddr = NULL;
pDestAddr = GET_OS_PKT_DATAPTR(pPacket);
if (IS_MULTICAST_MAC_ADDR(pDestAddr)) {
PUCHAR pData = pDestAddr + 12;
UINT16 protoType =
OS_NTOHS(*((UINT16 *)(pData)));
/* Check whether membership query sent by some other device.*/
/* If detected, set internal query Hold duration to avoid flooding in network*/
if (protoType == ETH_P_IP) {
if (isIGMPquery(adapter, pDestAddr,
pData)) {
adapter->ApCfg.MBSSID[if_index]
.IgmpQueryHoldTick =
QUERY_HOLD_PERIOD;
}
} else if (protoType == ETH_P_IPV6) {
if (isMLDquery(adapter, pDestAddr,
pData)) {
adapter->ApCfg.MBSSID[if_index]
.MldQueryHoldTick =
QUERY_HOLD_PERIOD;
}
}
}
}
#endif
if (exclude_mac_addr) {
routing_entry = RoutingTabLookup(adapter, if_index,
exclude_mac_addr,
FALSE, &wcid);
if (routing_entry &&
ROUTING_ENTRY_TEST_FLAG(routing_entry,
ROUTING_ENTRY_A4))
found = TRUE;
else
found = FALSE;
}
a4_entry_list = &adapter->ApCfg.MBSSID[if_index].a4_entry_list;
DlListForEach(a4_entry, a4_entry_list, A4_CONNECT_ENTRY, List)
{
if (a4_entry && a4_entry->valid &&
VALID_WCID(a4_entry->wcid)) {
if (found && (wcid == a4_entry->wcid))
continue;
entry = &adapter->MacTab.Content[a4_entry->wcid];
wdev = entry->wdev;
pkt_clone = a4_clone_packet(adapter,
wdev->if_dev, pkt);
if (pkt_clone == NULL) {
MTWF_LOG(
DBG_CAT_ALL, DBG_SUBCAT_ALL,
DBG_LVL_ERROR,
("%s: Fail to alloc memory for pPacketClone\n",
__func__));
return;
}
#ifdef MAP_TS_TRAFFIC_SUPPORT
if (adapter->bTSEnable) {
peer_entry =
&adapter->MacTab
.Content[entry->wcid];
if (!map_ts_tx_process(adapter, wdev,
pkt_clone,
peer_entry)) {
RELEASE_NDIS_PACKET(
adapter, pkt_clone,
NDIS_STATUS_FAILURE);
continue;
}
}
#endif
RTMP_SET_PACKET_WCID(pkt_clone, entry->wcid);
RTMP_SET_PACKET_WDEV(pkt_clone, wdev->wdev_idx);
RTMP_SET_PACKET_MOREDATA(pkt_clone, FALSE);
/*RTMP_SET_PACKET_QUEIDX(pPacketClone, QID_AC_BE);*/
a4_hard_transmit(adapter, wdev, pkt_clone);
}
}
}
}
BOOLEAN a4_ap_peer_enable(IN PRTMP_ADAPTER adapter, IN PMAC_TABLE_ENTRY entry,
IN UCHAR type)
{
BSS_STRUCT *mbss = NULL;
UCHAR if_index;
CMD_WTBL_HDR_TRANS_T wtbl_hdr_trans;
if (!entry || !IS_ENTRY_CLIENT(entry))
return FALSE;
if_index = entry->func_tb_idx;
if (if_index >= HW_BEACON_MAX_NUM)
return FALSE;
mbss = &adapter->ApCfg.MBSSID[if_index];
#ifdef WSC_AP_SUPPORT
if (mbss && (mbss->WscControl.WscConfMode != WSC_DISABLE) &&
(mbss->WscControl.bWscTrigger == TRUE))
return FALSE;
#endif /* WSC_AP_SUPPORT */
if (IS_ENTRY_A4(entry) == FALSE) {
/* To check and remove entry which is created from another side. */
a4_proxy_delete(adapter, if_index, entry->Addr);
os_zero_mem(&wtbl_hdr_trans, sizeof(CMD_WTBL_HDR_TRANS_T));
MTWF_LOG(
DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("Enabled A4 for entry:%02x-%02x-%02x-%02x-%02x-%02x\n",
PRINT_MAC(entry->Addr)));
wtbl_hdr_trans.u2Tag = WTBL_HDR_TRANS;
wtbl_hdr_trans.u2Length = sizeof(CMD_WTBL_HDR_TRANS_T);
wtbl_hdr_trans.ucTd = 1;
wtbl_hdr_trans.ucFd = 1;
wtbl_hdr_trans.ucDisRhtr = 0;
if (NDIS_STATUS_SUCCESS !=
CmdExtWtblUpdate(adapter, entry->wcid, SET_WTBL,
&wtbl_hdr_trans,
sizeof(CMD_WTBL_HDR_TRANS_T)))
return FALSE;
a4_add_entry(adapter, if_index, entry->wcid);
}
if (type > GET_ENTRY_A4(entry)) {
SET_ENTRY_A4(entry, type);
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("SET_A4_ENTRY type:%d OK!\n", type));
}
return TRUE;
}
BOOLEAN a4_ap_peer_disable(IN PRTMP_ADAPTER adapter, IN PMAC_TABLE_ENTRY entry,
IN UCHAR type)
{
UCHAR if_index;
if (!entry || !IS_ENTRY_CLIENT(entry))
return FALSE;
if_index = entry->func_tb_idx;
if (if_index >= HW_BEACON_MAX_NUM)
return FALSE;
if (type == GET_ENTRY_A4(entry)) {
SET_ENTRY_A4(entry, A4_TYPE_NONE);
a4_delete_entry(adapter, if_index, entry->wcid);
RoutingTabSetAllFree(adapter, if_index, entry->wcid,
ROUTING_ENTRY_A4);
MTWF_LOG(
DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("a4_ap_peer_disable: Disable A4 for entry : %02x-%02x-%02x-%02x-%02x-%02x\n",
PRINT_MAC(entry->Addr)));
}
return TRUE;
}
#ifdef APCLI_SUPPORT
BOOLEAN a4_apcli_peer_enable(IN PRTMP_ADAPTER adapter,
IN PAPCLI_STRUCT apcli_entry,
IN PMAC_TABLE_ENTRY entry, IN UCHAR type)
{
CMD_WTBL_HDR_TRANS_T wtbl_hdr_trans;
if (!apcli_entry || !entry || !IS_ENTRY_APCLI(entry))
return FALSE;
#ifdef WSC_AP_SUPPORT
if (((apcli_entry->WscControl.WscConfMode != WSC_DISABLE) &&
(apcli_entry->WscControl.bWscTrigger == TRUE)))
return FALSE;
#endif /* WSC_AP_SUPPORT */
if (IS_ENTRY_A4(entry) == FALSE) {
os_zero_mem(&wtbl_hdr_trans, sizeof(CMD_WTBL_HDR_TRANS_T));
MTWF_LOG(
DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("a4_apcli_peer_enable enabled A4 for entry : %02x-%02x-%02x-%02x-%02x-%02x\n",
PRINT_MAC(entry->Addr)));
wtbl_hdr_trans.u2Tag = WTBL_HDR_TRANS;
wtbl_hdr_trans.u2Length = sizeof(CMD_WTBL_HDR_TRANS_T);
wtbl_hdr_trans.ucTd = 1;
wtbl_hdr_trans.ucFd = 1;
wtbl_hdr_trans.ucDisRhtr = 0;
if (CmdExtWtblUpdate(adapter, entry->wcid, SET_WTBL,
&wtbl_hdr_trans,
sizeof(CMD_WTBL_HDR_TRANS_T)) ==
NDIS_STATUS_SUCCESS)
MTWF_LOG(DBG_CAT_CLIENT, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("SET_A4_ENTRY OK!\n"));
else
return FALSE;
}
if (type > GET_ENTRY_A4(entry)) {
SET_APCLI_A4(apcli_entry, type);
SET_ENTRY_A4(entry, type);
}
return TRUE;
}
BOOLEAN a4_apcli_peer_disable(IN PRTMP_ADAPTER adapter,
IN PAPCLI_STRUCT apcli_entry,
IN PMAC_TABLE_ENTRY entry, IN UCHAR type)
{
if (!apcli_entry || !entry)
return FALSE;
if (type == GET_ENTRY_A4(entry)) {
MTWF_LOG(
DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("a4_apcli_peer_disable, Disable A4 for entry:%02x-%02x-%02x-%02x-%02x-%02x\n",
PRINT_MAC(entry->Addr)));
SET_APCLI_A4(apcli_entry, A4_TYPE_NONE);
SET_ENTRY_A4(entry, A4_TYPE_NONE);
}
return TRUE;
}
#endif /* APCLI_SUPPORT */
INT Set_APProxy_Status_Show_Proc(IN PRTMP_ADAPTER adapter, IN RTMP_STRING *arg)
{
POS_COOKIE obj;
UCHAR if_index;
INT32 i, count = 0;
UINT32 ip_addr = 0;
ULONG now = 0, AliveTime = 0;
PDL_LIST a4_entry_list = NULL;
PA4_CONNECT_ENTRY a4_entry = NULL;
PROUTING_ENTRY routing_entry = NULL,
*routing_entry_list[ROUTING_POOL_SIZE];
UCHAR *proxy_mac_addr = NULL, proxy_ip[64];
obj = (POS_COOKIE)adapter->OS_Cookie;
if_index = obj->ioctl_if;
if ((obj->ioctl_if_type != INT_MBSSID) &&
(obj->ioctl_if_type != INT_MAIN))
return FALSE;
if (a4_get_entry_count(adapter, if_index) == 0)
return TRUE;
a4_entry_list = &adapter->ApCfg.MBSSID[if_index].a4_entry_list;
NdisGetSystemUpTime(&now);
DlListForEach(a4_entry, a4_entry_list, A4_CONNECT_ENTRY, List)
{
if (a4_entry && a4_entry->valid && VALID_WCID(a4_entry->wcid)) {
count = 0;
proxy_mac_addr =
adapter->MacTab.Content[a4_entry->wcid].Addr;
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("Proxy Mac: %02X:%02X:%02X:%02X:%02X:%02X\n",
PRINT_MAC(proxy_mac_addr)));
if (GetRoutingEntryAll(
adapter, if_index, a4_entry->wcid,
ROUTING_ENTRY_A4, ROUTING_POOL_SIZE,
(ROUTING_ENTRY **)&routing_entry_list,
&count)) {
for (i = 0; i < count; i++) {
routing_entry = (PROUTING_ENTRY)
routing_entry_list[i];
if (!routing_entry)
continue;
if (routing_entry->KeepAliveTime >= now)
AliveTime =
((routing_entry
->KeepAliveTime -
now) /
OS_HZ);
else
AliveTime = 0;
if (routing_entry->IPAddr != 0) {
ip_addr = routing_entry->IPAddr;
sprintf(proxy_ip, "%d.%d.%d.%d",
(ip_addr & 0xff),
((ip_addr &
(0xff << 8)) >>
8),
((ip_addr &
(0xff << 16)) >>
16),
((ip_addr &
(0xff << 24)) >>
24));
} else
strcpy(proxy_ip, "0.0.0.0");
MTWF_LOG(
DBG_CAT_ALL, DBG_SUBCAT_ALL,
DBG_LVL_OFF,
("MAC:%02X:%02X:%02X:%02X:%02X:%02X, IP:%s, AgeOut:%lus, Retry:(%d,%d)\n",
PRINT_MAC(routing_entry->Mac),
proxy_ip, AliveTime,
routing_entry->Retry,
ROUTING_ENTRY_MAX_RETRY));
}
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL,
DBG_LVL_OFF,
("Total Count = %d\n\n", count));
}
}
}
return TRUE;
}
INT Set_APProxy_Refresh_Proc(IN PRTMP_ADAPTER adapter, IN RTMP_STRING *arg)
{
adapter->a4_need_refresh = TRUE;
return TRUE;
}
#endif /* A4_CONN */

View File

@ -1,322 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
client_wds.c
Abstract:
*/
#ifdef CLIENT_WDS
#include "rt_config.h"
VOID CliWds_ProxyTabInit(IN PRTMP_ADAPTER pAd)
{
INT idx;
ULONG i;
NdisAllocateSpinLock(pAd, &pAd->ApCfg.CliWdsTabLock);
os_alloc_mem(pAd, (UCHAR **)&(pAd->ApCfg.pCliWdsEntryPool),
sizeof(CLIWDS_PROXY_ENTRY) * CLIWDS_POOL_SIZE);
if (pAd->ApCfg.pCliWdsEntryPool) {
NdisZeroMemory(pAd->ApCfg.pCliWdsEntryPool,
sizeof(CLIWDS_PROXY_ENTRY) * CLIWDS_POOL_SIZE);
initList(&pAd->ApCfg.CliWdsEntryFreeList);
for (i = 0; i < CLIWDS_POOL_SIZE; i++)
insertTailList(
&pAd->ApCfg.CliWdsEntryFreeList,
(RT_LIST_ENTRY *)(pAd->ApCfg.pCliWdsEntryPool +
(ULONG)i));
} else
MTWF_LOG(
DBG_CAT_CLIENT, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s Fail to alloc memory for pAd->CommonCfg.pCliWdsEntryPool",
__func__));
for (idx = 0; idx < CLIWDS_HASH_TAB_SIZE; idx++)
initList(&pAd->ApCfg.CliWdsProxyTb[idx]);
return;
}
VOID CliWds_ProxyTabDestory(IN PRTMP_ADAPTER pAd)
{
INT idx;
PCLIWDS_PROXY_ENTRY pCliWdsEntry;
NdisFreeSpinLock(&pAd->ApCfg.CliWdsTabLock);
for (idx = 0; idx < CLIWDS_HASH_TAB_SIZE; idx++) {
pCliWdsEntry =
(PCLIWDS_PROXY_ENTRY)pAd->ApCfg.CliWdsProxyTb[idx].pHead;
while (pCliWdsEntry) {
PCLIWDS_PROXY_ENTRY pCliWdsEntryNext =
pCliWdsEntry->pNext;
CliWdsEntyFree(pAd, pCliWdsEntry);
pCliWdsEntry = pCliWdsEntryNext;
}
}
if (pAd->ApCfg.pCliWdsEntryPool)
os_free_mem(pAd->ApCfg.pCliWdsEntryPool);
pAd->ApCfg.pCliWdsEntryPool = NULL;
return;
}
PCLIWDS_PROXY_ENTRY CliWdsEntyAlloc(IN PRTMP_ADAPTER pAd)
{
PCLIWDS_PROXY_ENTRY pCliWdsEntry;
RTMP_SEM_LOCK(&pAd->ApCfg.CliWdsTabLock);
pCliWdsEntry = (PCLIWDS_PROXY_ENTRY)removeHeadList(
&pAd->ApCfg.CliWdsEntryFreeList);
RTMP_SEM_UNLOCK(&pAd->ApCfg.CliWdsTabLock);
return pCliWdsEntry;
}
VOID CliWdsEntyFree(IN PRTMP_ADAPTER pAd, IN PCLIWDS_PROXY_ENTRY pCliWdsEntry)
{
RTMP_SEM_LOCK(&pAd->ApCfg.CliWdsTabLock);
insertTailList(&pAd->ApCfg.CliWdsEntryFreeList,
(RT_LIST_ENTRY *)pCliWdsEntry);
RTMP_SEM_UNLOCK(&pAd->ApCfg.CliWdsTabLock);
return;
}
VOID CliWdsEnryFreeAid(IN PRTMP_ADAPTER pAd, IN SHORT Aid)
{
INT idx;
PCLIWDS_PROXY_ENTRY pCliWdsEntry;
for (idx = 0; idx < CLIWDS_HASH_TAB_SIZE; idx++) {
pCliWdsEntry =
(PCLIWDS_PROXY_ENTRY)pAd->ApCfg.CliWdsProxyTb[idx].pHead;
while (pCliWdsEntry) {
if (pCliWdsEntry->Aid == Aid) {
delEntryList(&pAd->ApCfg.CliWdsProxyTb[idx],
(RT_LIST_ENTRY *)pCliWdsEntry);
CliWdsEntyFree(pAd, pCliWdsEntry);
}
pCliWdsEntry = pCliWdsEntry->pNext;
}
}
return;
}
UCHAR *CliWds_ProxyLookup(RTMP_ADAPTER *pAd, UCHAR *pMac)
{
UINT8 HashId = (*(pMac + 5) & (CLIWDS_HASH_TAB_SIZE - 1));
PCLIWDS_PROXY_ENTRY pCliWdsEntry;
pCliWdsEntry =
(PCLIWDS_PROXY_ENTRY)pAd->ApCfg.CliWdsProxyTb[HashId].pHead;
while (pCliWdsEntry) {
if (MAC_ADDR_EQUAL(pMac, pCliWdsEntry->Addr)) {
ULONG Now;
NdisGetSystemUpTime(&Now);
pCliWdsEntry->LastRefTime = Now;
/*FIXME: take aid as wcid shall be refined, let aid is aid, wcid is wcid.*/
if (VALID_UCAST_ENTRY_WCID(pAd, pCliWdsEntry->Aid))
return pAd->MacTab.Content[pCliWdsEntry->Aid]
.Addr;
else
return NULL;
}
pCliWdsEntry = pCliWdsEntry->pNext;
}
return NULL;
}
VOID CliWds_ProxyTabUpdate(IN PRTMP_ADAPTER pAd, IN SHORT Aid, IN PUCHAR pMac)
{
UINT8 HashId = (*(pMac + 5) & (CLIWDS_HASH_TAB_SIZE - 1));
PCLIWDS_PROXY_ENTRY pCliWdsEntry;
if (CliWds_ProxyLookup(pAd, pMac) != NULL)
return;
pCliWdsEntry = CliWdsEntyAlloc(pAd);
if (pCliWdsEntry) {
ULONG Now;
NdisGetSystemUpTime(&Now);
pCliWdsEntry->Aid = Aid;
COPY_MAC_ADDR(&pCliWdsEntry->Addr, pMac);
pCliWdsEntry->LastRefTime = Now;
pCliWdsEntry->pNext = NULL;
insertTailList(&pAd->ApCfg.CliWdsProxyTb[HashId],
(RT_LIST_ENTRY *)pCliWdsEntry);
}
return;
}
VOID CliWds_ProxyTabMaintain(IN PRTMP_ADAPTER pAd)
{
ULONG idx;
PCLIWDS_PROXY_ENTRY pCliWdsEntry;
ULONG Now;
NdisGetSystemUpTime(&Now);
for (idx = 0; idx < CLIWDS_HASH_TAB_SIZE; idx++) {
pCliWdsEntry =
(PCLIWDS_PROXY_ENTRY)(pAd->ApCfg.CliWdsProxyTb[idx]
.pHead);
while (pCliWdsEntry) {
PCLIWDS_PROXY_ENTRY pCliWdsEntryNext =
pCliWdsEntry->pNext;
if (RTMP_TIME_AFTER(
Now,
pCliWdsEntry->LastRefTime +
(ULONG)((ULONG)(CLI_WDS_ENTRY_AGEOUT)*OS_HZ /
1000))) {
delEntryList(&pAd->ApCfg.CliWdsProxyTb[idx],
(RT_LIST_ENTRY *)pCliWdsEntry);
CliWdsEntyFree(pAd, pCliWdsEntry);
}
pCliWdsEntry = pCliWdsEntryNext;
}
}
return;
}
#ifndef WDS_SUPPORT
MAC_TABLE_ENTRY *FindWdsEntry(IN PRTMP_ADAPTER pAd, IN RX_BLK *pRxBlk)
{
MAC_TABLE_ENTRY *pEntry;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s(): Wcid = %d, PhyMode = 0x%x\n", __func__, pRxBlk->wcid,
pRxBlk->rx_rate.field.MODE));
/* lookup the match wds entry for the incoming packet. */
pEntry = WdsTableLookupByWcid(pAd, pRxBlk->wcid, pRxBlk->Addr2, TRUE);
if (pEntry == NULL)
pEntry = WdsTableLookup(pAd, pRxBlk->Addr2, TRUE);
/* Report to MLME, add WDS entry */
if ((pEntry == NULL) && (pAd->WdsTab.Mode >= WDS_LAZY_MODE)) {
UCHAR *pTmpBuf = pRxBlk->pData - LENGTH_802_11;
RXD_BASE_STRUCT *rxd_base =
(RXD_BASE_STRUCT *)pRxBlk->rmac_info;
NdisMoveMemory(pTmpBuf, pRxBlk->FC, LENGTH_802_11);
REPORT_MGMT_FRAME_TO_MLME(
pAd, pRxBlk->wcid, pTmpBuf,
pRxBlk->DataSize + LENGTH_802_11,
pRxBlk->rx_signal.raw_rssi[0],
pRxBlk->rx_signal.raw_rssi[1],
pRxBlk->rx_signal.raw_rssi[2],
pRxBlk->rx_signal.raw_rssi[3],
#if defined(CUSTOMER_DCC_FEATURE) || defined(CONFIG_MAP_SUPPORT)
pRxBlk->rx_signal.raw_snr[0],
pRxBlk->rx_signal.raw_snr[1],
pRxBlk->rx_signal.raw_snr[2],
pRxBlk->rx_signal.raw_snr[3],
#endif
(rxd_base != NULL) ? rxd_base->RxD1.ChFreq : 0, 0,
OPMODE_AP, &pAd->ApCfg.MBSSID[pRxBlk->bss_idx].wdev,
pRxBlk->rx_rate.field.MODE);
MTWF_LOG(
DBG_CAT_RX, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("!!! report WDS UC DATA (from %02x-%02x-%02x-%02x-%02x-%02x) to MLME (len=%d) !!!\n",
PRINT_MAC(pRxBlk->Addr2), pRxBlk->DataSize));
}
return pEntry;
}
MAC_TABLE_ENTRY *WdsTableLookupByWcid(IN PRTMP_ADAPTER pAd, IN UCHAR wcid,
IN PUCHAR pAddr,
IN BOOLEAN bResetIdelCount)
{
ULONG WdsIndex;
MAC_TABLE_ENTRY *pCurEntry = NULL, *pEntry = NULL;
RETURN_ZERO_IF_PAD_NULL(pAd);
if (!VALID_UCAST_ENTRY_WCID(pAd, wcid))
return NULL;
NdisAcquireSpinLock(&pAd->WdsTab.WdsTabLock);
NdisAcquireSpinLock(&pAd->MacTabLock);
do {
pCurEntry = &pAd->MacTab.Content[wcid];
WdsIndex = 0xff;
if ((pCurEntry) && IS_ENTRY_WDS(pCurEntry))
WdsIndex = pCurEntry->func_tb_idx;
if (WdsIndex == 0xff)
break;
if (pAd->WdsTab.WdsEntry[WdsIndex].Valid != TRUE)
break;
if (MAC_ADDR_EQUAL(pCurEntry->Addr, pAddr)) {
if (bResetIdelCount) {
pCurEntry->NoDataIdleCount = 0;
/* TODO: shiang-usw, remove upper setting because we need to migrate to tr_entry! */
pAd->MacTab.tr_entry[pCurEntry->tr_tb_idx]
.NoDataIdleCount = 0;
}
pEntry = pCurEntry;
break;
}
} while (FALSE);
NdisReleaseSpinLock(&pAd->MacTabLock);
NdisReleaseSpinLock(&pAd->WdsTab.WdsTabLock);
return pEntry;
}
MAC_TABLE_ENTRY *WdsTableLookup(RTMP_ADAPTER *pAd, UCHAR *addr,
BOOLEAN bResetIdelCount)
{
USHORT HashIdx;
PMAC_TABLE_ENTRY pEntry = NULL;
NdisAcquireSpinLock(&pAd->WdsTab.WdsTabLock);
NdisAcquireSpinLock(&pAd->MacTabLock);
HashIdx = MAC_ADDR_HASH_INDEX(addr);
pEntry = pAd->MacTab.Hash[HashIdx];
while (pEntry) {
if (IS_ENTRY_WDS(pEntry) &&
MAC_ADDR_EQUAL(pEntry->Addr, addr)) {
if (bResetIdelCount) {
pEntry->NoDataIdleCount = 0;
/* TODO: shiang-usw, remove upper setting because we need to migrate to tr_entry! */
pAd->MacTab.tr_entry[pEntry->wcid]
.NoDataIdleCount = 0;
}
break;
}
pEntry = pEntry->pNext;
}
NdisReleaseSpinLock(&pAd->MacTabLock);
NdisReleaseSpinLock(&pAd->WdsTab.WdsTabLock);
return pEntry;
}
#endif
#endif /* CLIENT_WDS */

View File

@ -1,647 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002-2006, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
cmm_cmd.c
Abstract:
All command related API.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Paul Lin 06-25-2004 created
*/
#include "rt_config.h"
#ifdef DBG_STARVATION
static void cmdq_starv_timeout_handle(struct starv_dbg *starv,
struct starv_log_entry *entry)
{
struct _CmdQElmt *cmd = container_of(starv, struct _CmdQElmt, starv);
struct _CmdQ *cmdq = starv->block->priv;
struct starv_log_basic *log = NULL;
os_alloc_mem(NULL, (UCHAR **)&log, sizeof(struct starv_log_basic));
if (!log)
return;
log->qsize = cmdq->size;
log->id = cmd->command;
entry->log = log;
}
static void cmdq_starv_block_init(struct starv_log *ctrl, struct _CmdQ *cmdq)
{
struct starv_dbg_block *block = &cmdq->block;
strncpy(block->name, "cmdq", sizeof(block->name));
block->priv = cmdq;
block->ctrl = ctrl;
block->timeout = 100;
block->timeout_fn = cmdq_starv_timeout_handle;
block->log_fn = starv_timeout_log_basic;
register_starv_block(block);
}
#endif /*DBG_STARVATION*/
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
VOID RTInitializeCmdQ(IN PCmdQ cmdq)
{
cmdq->head = NULL;
cmdq->tail = NULL;
cmdq->size = 0;
cmdq->CmdQState = RTMP_TASK_STAT_INITED;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
VOID RTThreadDequeueCmd(IN PCmdQ cmdq, OUT PCmdQElmt *pcmdqelmt)
{
*pcmdqelmt = cmdq->head;
if (*pcmdqelmt != NULL) {
cmdq->head = cmdq->head->next;
cmdq->size--;
if (cmdq->size == 0)
cmdq->tail = NULL;
}
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NDIS_STATUS RTEnqueueInternalCmd(IN PRTMP_ADAPTER pAd, IN NDIS_OID Oid,
IN PVOID pInformationBuffer,
IN UINT32 InformationBufferLength)
{
NDIS_STATUS status;
ULONG flag = 0;
PCmdQElmt cmdqelmt = NULL;
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) {
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("--->RTEnqueueInternalCmd - NIC is not exist!!\n"));
return NDIS_STATUS_FAILURE;
}
status = os_alloc_mem(pAd, (PUCHAR *)&cmdqelmt, sizeof(CmdQElmt));
if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt == NULL))
return NDIS_STATUS_RESOURCES;
NdisZeroMemory(cmdqelmt, sizeof(CmdQElmt));
if (InformationBufferLength > 0) {
status = os_alloc_mem(pAd, (PUCHAR *)&cmdqelmt->buffer,
InformationBufferLength);
if ((status != NDIS_STATUS_SUCCESS) ||
(cmdqelmt->buffer == NULL)) {
os_free_mem(cmdqelmt);
return NDIS_STATUS_RESOURCES;
} else {
NdisMoveMemory(cmdqelmt->buffer, pInformationBuffer,
InformationBufferLength);
cmdqelmt->bufferlength = InformationBufferLength;
}
} else {
cmdqelmt->buffer = NULL;
cmdqelmt->bufferlength = 0;
}
cmdqelmt->command = Oid;
cmdqelmt->CmdFromNdis = FALSE;
if (cmdqelmt != NULL) {
RTMP_SPIN_LOCK_IRQSAVE(&pAd->CmdQLock, &flag);
if (pAd->CmdQ.CmdQState & RTMP_TASK_CAN_DO_INSERT) {
#ifdef DBG_STARVATION
starv_dbg_init(&pAd->CmdQ.block, &cmdqelmt->starv);
starv_dbg_get(&cmdqelmt->starv);
#endif /*DBG_STARVATION*/
EnqueueCmd((&pAd->CmdQ), cmdqelmt);
status = NDIS_STATUS_SUCCESS;
} else
status = NDIS_STATUS_FAILURE;
RTMP_SPIN_UNLOCK_IRQRESTORE(&pAd->CmdQLock, &flag);
if (status == NDIS_STATUS_FAILURE) {
if (cmdqelmt->buffer)
os_free_mem(cmdqelmt->buffer);
os_free_mem(cmdqelmt);
} else
RTCMDUp(&pAd->cmdQTask);
}
return NDIS_STATUS_SUCCESS;
}
/*Define common Cmd Thread*/
#ifdef CONFIG_AP_SUPPORT
static NTSTATUS _802_11_CounterMeasureHdlr(IN PRTMP_ADAPTER pAd,
IN PCmdQElmt CMDQelmt)
{
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
{
MAC_TABLE_ENTRY *pEntry;
pEntry = (MAC_TABLE_ENTRY *)CMDQelmt->buffer;
HandleCounterMeasure(pAd, pEntry);
}
return NDIS_STATUS_SUCCESS;
}
static NTSTATUS ApSoftReStart(IN PRTMP_ADAPTER pAd, IN PCmdQElmt CMDQelmt)
{
BSS_STRUCT *pMbss;
UCHAR apidx;
NdisMoveMemory(&apidx, CMDQelmt->buffer, sizeof(UCHAR));
pMbss = &pAd->ApCfg.MBSSID[apidx];
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("cmd> ApSoftReStart: apidx = %d\n", apidx));
APStop(pAd, pMbss, AP_BSS_OPER_SINGLE);
APStartUp(pAd, pMbss, AP_BSS_OPER_SINGLE);
return NDIS_STATUS_SUCCESS;
}
#ifdef APCLI_SUPPORT
static NTSTATUS ApCliSetChannel(IN PRTMP_ADAPTER pAd, IN PCmdQElmt CMDQelmt)
{
PAPCLI_STRUCT pApCliTab = (PAPCLI_STRUCT)CMDQelmt->buffer;
UCHAR channel = 0;
channel = pApCliTab->MlmeAux.Channel;
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("cmd> channel=%d CMDTHREAD_APCLI_PBC_TIMEOUT!\n", channel));
rtmp_set_channel(pAd, &pApCliTab->wdev, channel);
return NDIS_STATUS_SUCCESS;
}
static NTSTATUS CmdApCliIfDown(IN PRTMP_ADAPTER pAd, IN PCmdQElmt CMDQelmt)
{
UCHAR apidx = 0;
BOOLEAN apcliEn;
NdisMoveMemory(&apidx, CMDQelmt->buffer, sizeof(UCHAR));
apcliEn = pAd->ApCfg.ApCliTab[apidx].Enable;
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("cmd> CMDTHREAD_APCLI_IF_DOWN! apidx=%u, apcliEn=%d\n",
apidx, apcliEn));
/* bring apcli interface down first */
if (apcliEn == TRUE) {
pAd->ApCfg.ApCliTab[apidx].Enable = FALSE;
ApCliIfDown(pAd);
pAd->ApCfg.ApCliTab[apidx].Enable = apcliEn;
}
#ifdef CONFIG_MAP_SUPPORT
else if ((pAd->ApCfg.ApCliTab[apidx].wdev.WscControl.WscConfMode !=
WSC_DISABLE) &&
(pAd->ApCfg.ApCliTab[apidx].wdev.WscControl.bWscTrigger) &&
IS_MAP_ENABLE(pAd)) {
MTWF_LOG(
DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("MAP WPS CASE FIRST LINKDOWN THEN CONNECTION apidx=%u, apcliEn=%d\n",
apidx, apcliEn));
ApCliIfDown(pAd);
pAd->ApCfg.ApCliTab[apidx].Enable = TRUE;
}
#endif
return NDIS_STATUS_SUCCESS;
}
#ifdef WSC_AP_SUPPORT
static NTSTATUS CmdWscApCliLinkDown(IN PRTMP_ADAPTER pAd, IN PCmdQElmt CMDQelmt)
{
UCHAR apidx = 0;
NdisMoveMemory(&apidx, CMDQelmt->buffer, sizeof(UCHAR));
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("cmd> CMDTHREAD_WSC_APCLI_LINK_DOWN! apidx=%u\n", apidx));
WscApCliLinkDownById(pAd, apidx);
return NDIS_STATUS_SUCCESS;
}
#endif /* WSC_AP_SUPPORT */
#endif /* APCLI_SUPPORT */
#endif /* CONFIG_AP_SUPPORT */
#ifdef CONFIG_AP_SUPPORT
static NTSTATUS ChannelRescanHdlr(IN PRTMP_ADAPTER pAd, IN PCmdQElmt CMDQelmt)
{
/*SUPPORT RTMP_CHIP ONLY, Single Band*/
UCHAR Channel = HcGetRadioChannel(pAd);
struct wifi_dev *wdev = get_default_wdev(pAd);
AUTO_CH_CTRL *pAutoChCtrl = HcGetAutoChCtrl(pAd);
UCHAR apidx;
BSS_STRUCT *pMbss;
NdisMoveMemory(&apidx, CMDQelmt->buffer, sizeof(UCHAR));
pMbss = &pAd->ApCfg.MBSSID[apidx];
Channel = APAutoSelectChannel(pAd, wdev, TRUE,
pAutoChCtrl->pChannelInfo->IsABand);
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("cmd> Re-scan channel!\n"));
#ifdef ACS_CTCC_SUPPORT
if (!pAd->ApCfg.auto_ch_score_flag)
#endif
{
wdev->channel = Channel;
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("cmd> Switch to %d!\n", Channel));
APStop(pAd, pMbss, AP_BSS_OPER_BY_RF);
APStartUp(pAd, pMbss, AP_BSS_OPER_BY_RF);
}
#ifdef AP_QLOAD_SUPPORT
QBSS_LoadAlarmResume(pAd);
#endif /* AP_QLOAD_SUPPORT */
return NDIS_STATUS_SUCCESS;
}
#endif /* CONFIG_AP_SUPPORT*/
#ifdef LINUX
#ifdef RT_CFG80211_SUPPORT
static NTSTATUS RegHintHdlr(RTMP_ADAPTER *pAd, IN PCmdQElmt CMDQelmt)
{
RT_CFG80211_CRDA_REG_HINT(pAd, CMDQelmt->buffer,
CMDQelmt->bufferlength);
return NDIS_STATUS_SUCCESS;
}
static NTSTATUS RegHint11DHdlr(RTMP_ADAPTER *pAd, IN PCmdQElmt CMDQelmt)
{
RT_CFG80211_CRDA_REG_HINT11D(pAd, CMDQelmt->buffer,
CMDQelmt->bufferlength);
return NDIS_STATUS_SUCCESS;
}
static NTSTATUS RT_Mac80211_ScanEnd(RTMP_ADAPTER *pAd, IN PCmdQElmt CMDQelmt)
{
RT_CFG80211_SCAN_END(pAd, FALSE);
return NDIS_STATUS_SUCCESS;
}
static NTSTATUS RT_Mac80211_ConnResultInfom(RTMP_ADAPTER *pAd,
IN PCmdQElmt CMDQelmt)
{
return NDIS_STATUS_SUCCESS;
}
#endif /* RT_CFG80211_SUPPORT */
#endif /* LINUX */
#ifdef STREAM_MODE_SUPPORT
static NTSTATUS UpdateTXChainAddress(RTMP_ADAPTER *pAd, IN PCmdQElmt CMDQelmt)
{
AsicUpdateTxChainAddress(pAd, CMDQelmt->buffer);
return NDIS_STATUS_SUCCESS;
}
#endif /* STREAM_MODE_SUPPORT */
#ifdef CFG_TDLS_SUPPORT
static NTSTATUS CFGTdlsSendCHSWSetupHdlr(IN PRTMP_ADAPTER pAd,
IN PCmdQElmt CMDQelmt)
{
return NDIS_STATUS_SUCCESS;
}
static NTSTATUS CFGTdlsAutoTeardownHdlr(IN PRTMP_ADAPTER pAd,
IN PCmdQElmt CMDQelmt)
{
MAC_TABLE_ENTRY *pEntry = (MAC_TABLE_ENTRY *)(CMDQelmt->buffer);
cfg_tdls_auto_teardown(pAd, pEntry);
return NDIS_STATUS_SUCCESS;
}
#endif /* CFG_TDLS_SUPPORT */
static NTSTATUS mac_table_delete_handle(struct _RTMP_ADAPTER *ad,
struct _CmdQElmt *elem)
{
struct _MAC_TABLE_ENTRY *entry =
(struct _MAC_TABLE_ENTRY *)(elem->buffer);
MacTableDeleteEntry(ad, entry->wcid, entry->Addr);
return NDIS_STATUS_SUCCESS;
}
static NTSTATUS RXVWriteInFile(IN PRTMP_ADAPTER pAd, IN PCmdQElmt CMDQelmt)
{
RTMP_OS_FD_EXT srcf;
UINT i;
INT8 Ret;
RTMP_STRING tmpSrc[256], chipname[100];
PRxVBQElmt prxvbqelmt = (PRxVBQElmt)CMDQelmt->buffer;
srcf = os_file_open(pAd->RxvFilePath, O_WRONLY | O_CREAT | O_APPEND, 0);
if (srcf.Status) {
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("Open file \"%s\" failed!\n", pAd->RxvFilePath));
return NDIS_STATUS_FAILURE;
}
if (IS_MT7615(pAd))
sprintf(chipname, "Chip Name = 7615.\n");
else if (IS_MT7622(pAd))
sprintf(chipname, "Chip Name = 7622.\n");
else if (IS_MT7663(pAd))
sprintf(chipname, "Chip Name = 7663.\n");
else
sprintf(chipname, "Chip Name = Not Support.\n");
if (pAd->ucFirstWrite) {
sprintf(tmpSrc, "======================================\n");
os_file_write(srcf, tmpSrc, strlen(tmpSrc));
os_file_write(srcf, chipname, strlen(chipname));
sprintf(tmpSrc,
"WCID(STA Index) = %d, We will record all WCID if WCID = 0.\n",
pAd->ucRxvWcid);
os_file_write(srcf, tmpSrc, strlen(tmpSrc));
sprintf(tmpSrc, "Band Index = %d\n", pAd->ucRxvBandIdx);
os_file_write(srcf, tmpSrc, strlen(tmpSrc));
sprintf(tmpSrc, "CSD-Debug Group1/Group2 = 0x%x/0x%x\n",
pAd->ucRxvG1, pAd->ucRxvG2);
os_file_write(srcf, tmpSrc, strlen(tmpSrc));
sprintf(tmpSrc, "======================================\n");
os_file_write(srcf, tmpSrc, strlen(tmpSrc));
pAd->ucFirstWrite = FALSE;
}
sprintf(tmpSrc, "[TimeStamp %u][STA %d][Rxv_SN %u][AggCnt %u]\n",
prxvbqelmt->timestamp, prxvbqelmt->wcid, prxvbqelmt->rxv_sn,
prxvbqelmt->aggcnt);
os_file_write(srcf, tmpSrc, strlen(tmpSrc));
sprintf(tmpSrc,
"[FcsErrorBitmap[255-0] 0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x]\n",
prxvbqelmt->arFCScheckBitmap[7],
prxvbqelmt->arFCScheckBitmap[6],
prxvbqelmt->arFCScheckBitmap[5],
prxvbqelmt->arFCScheckBitmap[4],
prxvbqelmt->arFCScheckBitmap[3],
prxvbqelmt->arFCScheckBitmap[2],
prxvbqelmt->arFCScheckBitmap[1],
prxvbqelmt->arFCScheckBitmap[0]);
os_file_write(srcf, tmpSrc, strlen(tmpSrc));
os_file_write(srcf, "[RXV DUMP START]\n", strlen("[RXV DUMP START]\n"));
for (i = 0; i < 9; i++) {
sprintf(tmpSrc, "[RXVD%d] %08x\n", (i + 1),
prxvbqelmt->RXV_CYCLE[i]);
os_file_write(srcf, tmpSrc, strlen(tmpSrc));
}
os_file_write(srcf, "[RXV DUMP END]\n", strlen("[RXV DUMP END]\n"));
Ret = os_file_close(srcf);
if (Ret)
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("File Close Error ! Ret = %d\n", Ret));
return NDIS_STATUS_SUCCESS;
}
typedef NTSTATUS (*CMDHdlr)(RTMP_ADAPTER *pAd, IN PCmdQElmt CMDQelmt);
typedef struct {
UINT32 CmdID;
CMDHdlr CmdHdlr;
} MT_CMD_TABL_T;
static MT_CMD_TABL_T CMDHdlrTable[] = {
/*STA related*/
/*AP related*/
#ifdef CONFIG_AP_SUPPORT
{ CMDTHREAD_CHAN_RESCAN, ChannelRescanHdlr },
{ CMDTHREAD_802_11_COUNTER_MEASURE, _802_11_CounterMeasureHdlr },
{ CMDTHREAD_AP_RESTART, ApSoftReStart },
#ifdef APCLI_SUPPORT
{ CMDTHREAD_APCLI_PBC_TIMEOUT, ApCliSetChannel },
{ CMDTHREAD_APCLI_IF_DOWN, CmdApCliIfDown },
#ifdef WSC_AP_SUPPORT
{ CMDTHREAD_WSC_APCLI_LINK_DOWN, CmdWscApCliLinkDown },
#endif /* WSC_AP_SUPPORT */
#endif /* APCLI_SUPPORT */
#endif
/*CFG 802.11*/
#if defined(LINUX) && defined(RT_CFG80211_SUPPORT)
{ CMDTHREAD_REG_HINT, RegHintHdlr },
{ CMDTHREAD_REG_HINT_11D, RegHint11DHdlr },
{ CMDTHREAD_SCAN_END, RT_Mac80211_ScanEnd },
{ CMDTHREAD_CONNECT_RESULT_INFORM, RT_Mac80211_ConnResultInfom },
#endif
/*P2P*/
/*RT3593*/
#ifdef STREAM_MODE_SUPPORT
{ CMDTHREAD_UPDATE_TX_CHAIN_ADDRESS, UpdateTXChainAddress },
#endif
/*TDLS*/
#ifdef CFG_TDLS_SUPPORT
{ CMDTHREAD_TDLS_SEND_CH_SW_SETUP, CFGTdlsSendCHSWSetupHdlr },
{ CMDTHREAD_TDLS_AUTO_TEARDOWN, CFGTdlsAutoTeardownHdlr },
#endif
#ifdef WIFI_SPECTRUM_SUPPORT
{ CMDTHRED_WIFISPECTRUM_DUMP_RAW_DATA, WifiSpectrumRawDataHandler },
#endif /* WIFI_SPECTRUM_SUPPORT */
#ifdef INTERNAL_CAPTURE_SUPPORT
{ CMDTHRED_ICAP_DUMP_RAW_DATA, ICapRawDataHandler },
#endif /* INTERNAL_CAPTURE_SUPPORT */
#if defined(RLM_CAL_CACHE_SUPPORT) || defined(PRE_CAL_TRX_SET2_SUPPORT)
{ CMDTHRED_PRECAL_TXLPF, PreCalTxLPFStoreProcHandler },
{ CMDTHRED_PRECAL_TXIQ, PreCalTxIQStoreProcHandler },
{ CMDTHRED_PRECAL_TXDC, PreCalTxDCStoreProcHandler },
{ CMDTHRED_PRECAL_RXFI, PreCalRxFIStoreProcHandler },
{ CMDTHRED_PRECAL_RXFD, PreCalRxFDStoreProcHandler },
#endif /* defined(RLM_CAL_CACHE_SUPPORT) || defined(PRE_CAL_TRX_SET2_SUPPORT) */
#ifdef CONFIG_AP_SUPPORT
{ CMDTHRED_DOT11H_SWITCH_CHANNEL, Dot11HCntDownTimeoutAction },
#ifdef CUSTOMER_DCC_FEATURE
{ CMDTREAD_AP_SWITCH_CHANNEL, APChannelSwitch },
#endif
#endif /* CONFIG_AP_SUPPORT */
#ifdef MT_DFS_SUPPORT
{ CMDTHRED_DFS_CAC_TIMEOUT, DfsChannelSwitchTimeoutAction },
{ CMDTHRED_DFS_AP_RESTART, DfsAPRestart },
{ CMDTHRED_DFS_RADAR_DETECTED_SW_CH, DfsSwitchChAfterRadarDetected },
#endif
{ CMDTHRED_MAC_TABLE_DEL, mac_table_delete_handle },
{ CMDTHRED_RXV_WRITE_IN_FILE, RXVWriteInFile },
{ CMDTHREAD_END_CMD_ID, NULL }
};
static inline CMDHdlr ValidCMD(IN PCmdQElmt CMDQelmt)
{
SHORT CMDIndex = CMDQelmt->command;
SHORT CurIndex = 0;
USHORT CMDHdlrTableLength =
sizeof(CMDHdlrTable) / sizeof(MT_CMD_TABL_T);
CMDHdlr Handler = NULL;
if (CMDIndex > CMDTHREAD_END_CMD_ID) {
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("CMD(%x) is out of boundary\n", CMDQelmt->command));
return NULL;
}
for (CurIndex = 0; CurIndex < CMDHdlrTableLength; CurIndex++) {
if (CMDHdlrTable[CurIndex].CmdID == CMDIndex) {
Handler = CMDHdlrTable[CurIndex].CmdHdlr;
break;
}
}
if (Handler == NULL)
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("No corresponding CMDHdlr for this CMD(%x)\n",
CMDQelmt->command));
return Handler;
}
VOID CMDHandler(RTMP_ADAPTER *pAd)
{
PCmdQElmt cmdqelmt;
NDIS_STATUS NdisStatus = NDIS_STATUS_SUCCESS;
NTSTATUS ntStatus;
CMDHdlr Handler = NULL;
UINT32 process_cnt = 0;
while (pAd && pAd->CmdQ.size > 0) {
NdisStatus = NDIS_STATUS_SUCCESS;
/* For worst case, avoid process CmdQ too long which cause RCU_sched stall */
process_cnt++;
/* process_cnt-16 */
if ((!in_interrupt()) &&
(process_cnt >= (MAX_LEN_OF_CMD_QUEUE >> 4))) {
process_cnt = 0;
OS_SCHEDULE();
}
NdisAcquireSpinLock(&pAd->CmdQLock);
RTThreadDequeueCmd(&pAd->CmdQ, &cmdqelmt);
NdisReleaseSpinLock(&pAd->CmdQLock);
if (cmdqelmt == NULL)
break;
if (!(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) ||
RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))) {
Handler = ValidCMD(cmdqelmt);
if (Handler)
ntStatus = Handler(pAd, cmdqelmt);
}
#ifdef DBG_STARVATION
starv_dbg_put(&cmdqelmt->starv);
#endif /*DBG_STARVATION*/
if (cmdqelmt->CmdFromNdis == TRUE) {
if (cmdqelmt->buffer != NULL)
os_free_mem(cmdqelmt->buffer);
os_free_mem(cmdqelmt);
} else {
if ((cmdqelmt->buffer != NULL) &&
(cmdqelmt->bufferlength != 0))
os_free_mem(cmdqelmt->buffer);
os_free_mem(cmdqelmt);
}
} /* end of while */
}
void RtmpCmdQExit(RTMP_ADAPTER *pAd)
{
/* WCNCR00034259: unify CmdQ init and exit. But cleanup is done by
* RTUSBCmdThread() before its exit.
*/
#ifdef DBG_STARVATION
unregister_starv_block(&pAd->CmdQ.block);
#endif /*DBG_STARVATION*/
return;
}
void RtmpCmdQInit(RTMP_ADAPTER *pAd)
{
/* WCNCR00034259: moved from RTMP{Init, Alloc}TxRxRingMemory() */
/* Init the CmdQ and CmdQLock*/
NdisAllocateSpinLock(pAd, &pAd->CmdQLock);
NdisAcquireSpinLock(&pAd->CmdQLock);
RTInitializeCmdQ(&pAd->CmdQ);
NdisReleaseSpinLock(&pAd->CmdQLock);
#ifdef DBG_STARVATION
cmdq_starv_block_init(&pAd->starv_log_ctrl, &pAd->CmdQ);
#endif /*DBG_STARVATION*/
}

View File

@ -1,761 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
cmm_cs.c
Abstract:
Carrier Sensing related functions
Revision History:
Who When What
---------------------------------------------------------------------
*/
#include "rt_config.h"
#ifdef CARRIER_DETECTION_SUPPORT
static ULONG time[20];
static ULONG idle[20];
static ULONG busy[20];
static ULONG cd_idx;
static void ToneRadarProgram(PRTMP_ADAPTER pAd);
#ifdef CONFIG_AP_SUPPORT
static inline VOID CarrierDetectionResetStatus(PRTMP_ADAPTER pAd)
{
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
if (cap->carrier_func == TONE_RADAR_V3)
RTMP_BBP_IO_WRITE32(pAd, TR_R1, 0x3);
else
RTMP_CARRIER_IO_WRITE8(pAd, 1, 1);
}
static inline VOID CarrierDetectionStatusGet(PRTMP_ADAPTER pAd, PUINT8 pStatus)
{
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
*pStatus = 0;
if (cap->carrier_func == TONE_RADAR_V3) {
UINT32 mac_value = 0;
RTMP_BBP_IO_READ32(pAd, TR_R1, &mac_value);
*pStatus = (UINT8)mac_value;
} else
RTMP_CARRIER_IO_READ8(pAd, 1, pStatus);
}
static inline VOID CarrierDetectionEnable(PRTMP_ADAPTER pAd, BOOLEAN bEnable)
{
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
if (cap->carrier_func == TONE_RADAR_V3)
RTMP_BBP_IO_WRITE32(pAd, TR_R0, bEnable);
else
RTMP_CARRIER_IO_WRITE8(pAd, 0, bEnable);
}
/*
==========================================================================
Description:
Check current CS state, indicating Silient state (carrier exist) or not
Arguments:
pAd Pointer to our adapter
Return Value:
TRUE if the current state is SILENT state, FALSE other wise
Note:
==========================================================================
*/
INT isCarrierDetectExist(IN PRTMP_ADAPTER pAd)
{
if (pAd->CommonCfg.CarrierDetect.CD_State == CD_SILENCE)
return TRUE;
else
return FALSE;
}
/*
==========================================================================
Description:
Enable or Disable Carrier Detection feature (AP ioctl).
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
Usage:
1.) iwpriv ra0 set CarrierDetect=[1/0]
==========================================================================
*/
INT Set_CarrierDetect_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
UCHAR apidx = pObj->ioctl_if;
UINT Enable;
if (apidx != MAIN_MBSSID)
return FALSE;
Enable = (UINT)os_str_tol(arg, 0, 10);
pAd->CommonCfg.CarrierDetect.Enable =
(BOOLEAN)(Enable == 0 ? FALSE : TRUE);
RTMP_CHIP_RADAR_GLRT_COMPENSATE(pAd);
RTMP_CHIP_CCK_MRC_STATUS_CTRL(pAd);
if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
CarrierDetectionStart(pAd);
else
CarrierDetectionStop(pAd);
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s:: %s\n", __func__,
pAd->CommonCfg.CarrierDetect.Enable == TRUE ?
"Enable Carrier Detection" :
"Disable Carrier Detection"));
return TRUE;
}
#endif /* CONFIG_AP_SUPPORT */
/*
==========================================================================
Description:
When h/w interrupt is not available for CS, this function monitor necessary parameters that determine the CS
state periodically. (every 100ms)
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
VOID CarrierDetectionPeriodicStateCtrl(IN PRTMP_ADAPTER pAd)
{
PCARRIER_DETECTION_STRUCT pCarrierDetect =
&pAd->CommonCfg.CarrierDetect;
CD_STATE *pCD_State = &pCarrierDetect->CD_State;
ULONG *pOneSecIntCount = &pCarrierDetect->OneSecIntCount;
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
#ifdef CONFIG_ATE
/* Nothing to do in ATE mode */
if (ATE_ON(pAd))
return;
#endif /* CONFIG_ATE */
/* TODO: shiang-7603 */
if (IS_HIF_TYPE(pAd, HIF_MT)) {
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("%s(%d): Not support for HIF_MT yet!\n", __func__,
__LINE__));
return;
}
if (pCarrierDetect->bCsInit == FALSE)
return;
if (cap->carrier_func == TONE_RADAR_V3) {
UINT8 TrStatus = 0;
CarrierDetectionStatusGet(pAd, &TrStatus);
if (TrStatus) {
if (*pCD_State == CD_NORMAL) {
MTWF_LOG(
DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_OFF,
("Carrier Detected ! (TrStatus = 0x%x)\n",
TrStatus));
*pCD_State = CD_SILENCE;
/* stop all TX actions including Beacon sending.*/
AsicDisableSync(pAd, HW_BSSID_0);
}
*pOneSecIntCount = pCarrierDetect->CarrierGoneThreshold;
CarrierDetectionResetStatus(pAd);
} else
*pOneSecIntCount = 0;
/*CarrierDetectionResetStatus(pAd);*/
}
}
/*
==========================================================================
Description:
When there is no f/w taking care of CS operation, this function depends on h/w interrupts for every possible carrier
tone to judge the CS state
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
VOID RTMPHandleRadarInterrupt(PRTMP_ADAPTER pAd)
{
UINT32 value, delta;
UCHAR bbp = 0;
PCARRIER_DETECTION_STRUCT pCarrierDetect =
&pAd->CommonCfg.CarrierDetect;
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
if (cap->carrier_func > TONE_RADAR_V2)
return;
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("RTMPHandleRadarInterrupt()\n"));
RTMP_IO_READ32(pAd, PBF_LIFE_TIMER, &value);
RTMP_IO_READ32(pAd, CH_IDLE_STA, &pCarrierDetect->idle_time);
pCarrierDetect->busy_time = AsicGetChBusyCnt(pAd, 0);
delta = (value >> 4) - pCarrierDetect->TimeStamp;
pCarrierDetect->TimeStamp = value >> 4;
pCarrierDetect->OneSecIntCount++;
if (cap->carrier_func == TONE_RADAR_V2) {
{
UINT32 RadarInt = 0;
/* Disable carrier detection and clear the status bit*/
CarrierDetectionEnable(pAd, 0);
CarrierDetectionResetStatus(pAd);
/* Clear interrupt */
RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, RadarInt);
}
}
if (pCarrierDetect->Debug) {
if (cd_idx < 20) {
time[cd_idx] = delta;
idle[cd_idx] = pCarrierDetect->idle_time;
busy[cd_idx] = pCarrierDetect->busy_time;
cd_idx++;
} else {
int i;
pCarrierDetect->Debug = 0;
for (i = 0; i < 20; i++)
printk("%3d %4ld %ld %ld\n", i, time[i],
idle[i], busy[i]);
cd_idx = 0;
}
}
if (pCarrierDetect->CD_State == CD_NORMAL) {
if ((delta < pCarrierDetect->criteria) &&
(pCarrierDetect->recheck))
pCarrierDetect->recheck--;
else
pCarrierDetect->recheck = pCarrierDetect->recheck1;
if (pCarrierDetect->recheck == 0) {
/* declare carrier sense*/
pCarrierDetect->CD_State = CD_SILENCE;
if (pCarrierDetect->Debug != DBG_LVL_TRACE) {
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL,
DBG_LVL_TRACE, ("Carrier Detected\n"));
/* stop all TX actions including Beacon sending.*/
AsicDisableSync(pAd, HW_BSSID_0);
} else
printk("Carrier Detected\n");
}
}
if (cap->carrier_func == TONE_RADAR_V2) {
CarrierDetectionStatusGet(pAd, &bbp);
if (bbp & 0x1) {
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("CS bit not cleared!!!\n"));
CarrierDetectionResetStatus(pAd);
}
/* re-enable carrier detection */
CarrierDetectionEnable(pAd, 1);
} else if (cap->carrier_func == TONE_RADAR_V1 && pCarrierDetect->Enable)
ToneRadarProgram(pAd);
}
/*
==========================================================================
Description:
Reset CS state to NORMAL state.
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
INT CarrierDetectReset(IN PRTMP_ADAPTER pAd)
{
pAd->CommonCfg.CarrierDetect.CD_State = CD_NORMAL;
return 0;
}
/*
==========================================================================
Description:
Criteria in CS is a timing difference threshold for a pair of carrier tones. This function is a ioctl uesed to adjust the
Criteria. (unit: 16us)
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
INT Set_CarrierCriteria_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
UINT32 Value;
Value = os_str_tol(arg, 0, 10);
pAd->CommonCfg.CarrierDetect.criteria = Value;
return TRUE;
}
/*
==========================================================================
Description:
ReCheck in CS is a value indicating how many continuous incoming carrier tones is enough us to announce that there
is carrier tone (and hence enter SILENT state). This function is a ioctl uesed to adjust the ReCheck value.
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
INT Set_CarrierReCheck_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
pAd->CommonCfg.CarrierDetect.recheck1 = os_str_tol(arg, 0, 10);
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Set Recheck = %u\n", pAd->CommonCfg.CarrierDetect.recheck1));
return TRUE;
}
/*
==========================================================================
Description:
CarrierGoneThreshold is used to determine whether we should leave SILENT state. When the number of carrier
tones in a certain period of time is less than CarrierGoneThreshold, we should return to NORMAL state. This function
is a ioctl uesed to adjust the CarrierGoneThreshold.
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
INT Set_CarrierGoneThreshold_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
pAd->CommonCfg.CarrierDetect.CarrierGoneThreshold =
os_str_tol(arg, 0, 10);
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("Set CarrierGoneThreshold = %u\n",
pAd->CommonCfg.CarrierDetect.CarrierGoneThreshold));
return TRUE;
}
/*
==========================================================================
Description:
Setting up the carrier debug level. set 0 means to turning off the carrier debug
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
INT Set_CarrierDebug_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
pAd->CommonCfg.CarrierDetect.Debug = os_str_tol(arg, 0, 10);
printk("pAd->CommonCfg.CarrierDetect.Debug = %ld\n",
pAd->CommonCfg.CarrierDetect.Debug);
return TRUE;
}
/*
==========================================================================
Description:
Delta control the delay line characteristic of the cross correlation energy calculation.
This function is a ioctl uesed to adjust the Delta value.
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
INT Set_CarrierDelta_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
pAd->CommonCfg.CarrierDetect.delta = os_str_tol(arg, 0, 10);
printk("Delta = %d\n", pAd->CommonCfg.CarrierDetect.delta);
CarrierDetectionStart(pAd);
return TRUE;
}
/*
==========================================================================
Description:
To set ON/OFF of the "Not Divide Flag"
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
INT Set_CarrierDivFlag_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
pAd->CommonCfg.CarrierDetect.div_flag = os_str_tol(arg, 0, 10);
printk("DivFlag = %d\n", pAd->CommonCfg.CarrierDetect.div_flag);
CarrierDetectionStart(pAd);
return TRUE;
}
/*
==========================================================================
Description:
Carrier Threshold is the energy threshold for h/w to determine a carrier tone or not.
This function is a ioctl uesed to adjust the Threshold value.
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
INT Set_CarrierThrd_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
pAd->CommonCfg.CarrierDetect.threshold = os_str_tol(arg, 0, 10);
printk("CarrThrd = %d(0x%x)\n", pAd->CommonCfg.CarrierDetect.threshold,
pAd->CommonCfg.CarrierDetect.threshold);
CarrierDetectionStart(pAd);
return TRUE;
}
/*
==========================================================================
Description:
Carrier SymRund is the number of round bits in Radar Symmetric Round Bits Option.
This function is a ioctl uesed to adjust the SymRund. (unit: bit)
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
INT Set_CarrierSymRund_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
pAd->CommonCfg.CarrierDetect.SymRund = os_str_tol(arg, 0, 10);
printk("SymRund = %d\n", pAd->CommonCfg.CarrierDetect.SymRund);
CarrierDetectionStart(pAd);
return TRUE;
}
/*
==========================================================================
Description:
Carrier Masks are used to prevent false trigger while doing Rx_PE, Packet_End, and AGC tuning.
This function is a ioctl uesed to adjust these three mask. (unit: 100ns)
Arguments:
pAd Pointer to our adapter
arg Pointer to the ioctl argument
Return Value:
None
Note:
==========================================================================
*/
INT Set_CarrierMask_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
pAd->CommonCfg.CarrierDetect.VGA_Mask = os_str_tol(arg, 0, 10);
pAd->CommonCfg.CarrierDetect.Packet_End_Mask = os_str_tol(arg, 0, 10);
pAd->CommonCfg.CarrierDetect.Rx_PE_Mask = os_str_tol(arg, 0, 10);
printk("CarrMask = %u(%x)\n", pAd->CommonCfg.CarrierDetect.VGA_Mask,
pAd->CommonCfg.CarrierDetect.VGA_Mask);
CarrierDetectionStart(pAd);
return TRUE;
}
/*
==========================================================================
Description:
Initialize CS parameters.
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
VOID CSInit(IN PRTMP_ADAPTER pAd)
{
PCARRIER_DETECTION_STRUCT pCarrierDetect =
&pAd->CommonCfg.CarrierDetect;
pCarrierDetect->TimeStamp = 0;
pCarrierDetect->recheck = pCarrierDetect->recheck1;
pCarrierDetect->OneSecIntCount = 0;
pCarrierDetect->bCsInit = FALSE;
}
/*
==========================================================================
Description:
To trigger CS start
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
VOID CarrierDetectionStart(PRTMP_ADAPTER pAd)
{
/*ULONG Value;*/
/* Enable Bandwidth usage monitor*/
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("CarrierDetectionStart\n"));
/*RTMP_IO_READ32(pAd, CH_TIME_CFG, &Value);*/
/*RTMP_IO_WRITE32(pAd, CH_TIME_CFG, Value | 0x1f); */
/* Init Carrier Detect*/
if (pAd->CommonCfg.CarrierDetect.Enable) {
CSInit(pAd);
ToneRadarProgram(pAd);
/* trun on interrupt polling for pcie device */
if (pAd->infType == RTMP_DEV_INF_PCIE)
AsicSendCommandToMcu(pAd, CD_INT_POLLING_CMD, 0xff,
0x01, 0x00, FALSE);
pAd->CommonCfg.CarrierDetect.bCsInit = TRUE;
}
}
/*
==========================================================================
Description:
To stop CS
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
VOID CarrierDetectionStop(IN PRTMP_ADAPTER pAd)
{
CarrierDetectReset(pAd);
CarrierDetectionEnable(pAd, 0);
return;
}
/*
==========================================================================
Description:
To program CS related BBP registers (CS initialization)
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
static VOID ToneRadarProgram(PRTMP_ADAPTER pAd)
{
ULONG threshold;
struct wifi_dev *wdev = get_default_wdev(pAd);
CHAR bw = HcGetBw(pAd, wdev);
/* if wireless mode is 20Mhz mode, then the threshold should div by 2 */
if (bw == BW_20)
threshold = pAd->CommonCfg.CarrierDetect.threshold >> 1;
else
threshold = pAd->CommonCfg.CarrierDetect.threshold;
/* Call ToneRadarProgram_v1/ToneRadarProgram_v2*/
RTMP_CHIP_CARRIER_PROGRAM(pAd, threshold);
}
/*
==========================================================================
Description:
To program CS v1 related BBP registers (CS initialization)
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
VOID ToneRadarProgram_v1(PRTMP_ADAPTER pAd, ULONG threshold)
{
UCHAR bbp;
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("ToneRadarProgram v1\n"));
/* programe delta delay & division bit*/
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R184, 0xf0);
bbp = pAd->CommonCfg.CarrierDetect.delta << 4;
bbp |= (pAd->CommonCfg.CarrierDetect.div_flag & 0x1) << 3;
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R185, bbp);
/* program threshold*/
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R184, 0x34);
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R185, (threshold & 0xff000000) >> 24);
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R184, 0x24);
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R185, (threshold & 0xff0000) >> 16);
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R184, 0x14);
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R185, (threshold & 0xff00) >> 8);
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R184, 0x04);
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R185, threshold & 0xff);
/* ToneRadarEnable v1 */
BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R184, 0x05);
}
/*
==========================================================================
Description:
To program CS v2 related BBP registers (CS initialization)
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
VOID ToneRadarProgram_v2(PRTMP_ADAPTER pAd, ULONG threshold)
{
UCHAR bbp;
/* programe delta delay & division bit*/
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("ToneRadarProgram v2\n"));
bbp = pAd->CommonCfg.CarrierDetect.delta |
((pAd->CommonCfg.CarrierDetect.SymRund & 0x3) << 4) |
((pAd->CommonCfg.CarrierDetect.div_flag & 0x1) << 6) |
0x80; /* Full 40MHz Detection Mode */
RTMP_CARRIER_IO_WRITE8(pAd, 5, bbp);
/* program *_mask*/
RTMP_CARRIER_IO_WRITE8(pAd, 2, pAd->CommonCfg.CarrierDetect.VGA_Mask);
RTMP_CARRIER_IO_WRITE8(pAd, 3,
pAd->CommonCfg.CarrierDetect.Packet_End_Mask);
RTMP_CARRIER_IO_WRITE8(pAd, 4, pAd->CommonCfg.CarrierDetect.Rx_PE_Mask);
/* program threshold*/
RTMP_CARRIER_IO_WRITE8(pAd, 6, threshold & 0xff);
RTMP_CARRIER_IO_WRITE8(pAd, 7, (threshold & 0xff00) >> 8);
RTMP_CARRIER_IO_WRITE8(pAd, 8, (threshold & 0xff0000) >> 16);
RTMP_CARRIER_IO_WRITE8(pAd, 9, (threshold & 0xff000000) >> 24);
/* ToneRadarEnable v2 */
CarrierDetectionEnable(pAd, 1);
}
/*
==========================================================================
Description:
To program CS v3 related BBP registers (CS initialization)
Arguments:
pAd Pointer to our adapter
Return Value:
None
Note:
==========================================================================
*/
VOID ToneRadarProgram_v3(PRTMP_ADAPTER pAd, ULONG threshold)
{
/*
Carrier Sense (Tone Radar) BBP initialization
(MT7650 Carrier sense programming guide_v1_20120824.docx)
*/
MTWF_LOG(DBG_CAT_HW, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("ToneRadarProgram v3\n"));
CarrierDetectionEnable(pAd, 0);
RTMP_BBP_IO_WRITE32(pAd, TR_R2, 0x002d002d);
RTMP_BBP_IO_WRITE32(pAd, TR_R3, 0x0003002d);
RTMP_BBP_IO_WRITE32(pAd, TR_R5, 0x80000000);
RTMP_BBP_IO_WRITE32(pAd, TR_R6, 0x80100000);
CarrierDetectionEnable(pAd, 1);
}
#endif /* CARRIER_DETECTION_SUPPORT */

View File

@ -1,585 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
cmm_info_element.c
Abstract:
Revision History:
Who When What
-------- ---------- --------------------------------------------
2016-08-18 AP/APCLI/STA SYNC FSM Integration
*/
#include "rt_config.h"
static INT build_wsc_probe_req_ie(RTMP_ADAPTER *pAd, struct wifi_dev *wdev,
UCHAR *buf)
{
INT len = 0;
#ifdef WSC_INCLUDED
BOOLEAN bHasWscIe = FALSE;
if (wdev->wdev_type == WDEV_TYPE_APCLI) {
#ifdef APCLI_SUPPORT
/*
Append WSC information in probe request if WSC state is running
*/
if ((wdev->WscControl.WscConfMode != WSC_DISABLE) &&
(wdev->WscControl.bWscTrigger))
bHasWscIe = TRUE;
#if defined(WSC_V2_SUPPORT) && !defined(CONFIG_MAP_SUPPORT) && !defined(CON_WPS)
/* need to check if !defined(CONFIG_MAP_SUPPORT) is necessary */
else if (wdev->WscControl.WscV2Info.bEnableWpsV2)
bHasWscIe = TRUE;
#endif /* WSC_V2_SUPPORT */
#endif /* APCLI_SUPPORT */
#ifdef CON_WPS
if (bHasWscIe) {
PWSC_CTRL pWscControl = NULL;
/* Do not include wsc ie in case concurrent WPS is running */
bHasWscIe = FALSE;
pWscControl = &wdev->WscControl;
if ((pWscControl->conWscStatus ==
CON_WPS_STATUS_DISABLED) ||
(pAd->ApCfg.ConWpsApCliMode !=
CON_WPS_APCLI_BAND_AUTO))
bHasWscIe = TRUE;
MTWF_LOG(
DBG_CAT_PROTO, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("[scan_active: %d] ConWpsApCliMode=%d conWscStatus=%d bHasWscIe=%d\n",
__LINE__, pAd->ApCfg.ConWpsApCliMode,
pWscControl->conWscStatus, bHasWscIe));
}
#endif /*CON_WPS*/
} else if (wdev->wdev_type == WDEV_TYPE_STA) {
}
if (bHasWscIe) {
UCHAR *pWscBuf = NULL, WscIeLen = 0;
os_alloc_mem(NULL, (UCHAR **)&pWscBuf, 512);
if (pWscBuf != NULL) {
NdisZeroMemory(pWscBuf, 512);
WscBuildProbeReqIE(pAd, wdev, pWscBuf, &WscIeLen);
MAKE_IE_TO_BUF(buf, pWscBuf, WscIeLen, len);
os_free_mem(pWscBuf);
} else
MTWF_LOG(DBG_CAT_PROTO, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("%s:: WscBuf Allocate failed!\n", __func__));
}
#endif /* WSC_INCLUDED */
return len;
}
static INT build_wsc_probe_rsp_ie(RTMP_ADAPTER *pAd, struct wifi_dev *wdev,
UCHAR *buf)
{
INT len = 0;
switch (wdev->wdev_type) {
#ifdef WSC_AP_SUPPORT
case WDEV_TYPE_AP: {
/* for windows 7 logo test */
if ((wdev->WscControl.WscConfMode != WSC_DISABLE) &&
#ifdef DOT1X_SUPPORT
(!IS_IEEE8021X_Entry(wdev)) &&
#endif /* DOT1X_SUPPORT */
(IS_CIPHER_WEP(wdev->SecConfig.PairwiseCipher))) {
/*
Non-WPS Windows XP and Vista PCs are unable to determine if a WEP enalbed network is static key based
or 802.1X based. If the legacy station gets an EAP-Rquest/Identity from the AP, it assume the WEP
network is 802.1X enabled & will prompt the user for 802.1X credentials. If the legacy station doesn't
receive anything after sending an EAPOL-Start, it will assume the WEP network is static key based and
prompt user for the WEP key. <<from "WPS and Static Key WEP Networks">>
A WPS enabled AP should include this IE in the beacon when the AP is hosting a static WEP key network.
The IE would be 7 bytes long with the Extended Capability field set to 0 (all bits zero)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/randz/protocol/securing_public_wi-fi_hotspots.asp
*/
const UCHAR PROVISION_SERVICE_IE[7] = {
0xDD, 0x05, 0x00, 0x50, 0xF2, 0x05, 0x00
};
MAKE_IE_TO_BUF(buf, PROVISION_SERVICE_IE, 7, len);
}
/* add Simple Config Information Element */
if ((wdev->WscControl.WscConfMode > WSC_DISABLE) &&
(wdev->WscIEProbeResp.ValueLen))
MAKE_IE_TO_BUF(buf, wdev->WscIEProbeResp.Value,
wdev->WscIEProbeResp.ValueLen, len);
break;
}
#endif /* WSC_AP_SUPPORT */
#ifdef WSC_STA_SUPPORT
case WDEV_TYPE_ADHOC: {
/* PSTA_ADMIN_CONFIG pStaCfg = GetStaCfgByWdev(pAd,wdev); */
/* add Simple Config Information Element */
if (wdev->WscIEProbeResp.ValueLen != 0)
MAKE_IE_TO_BUF(buf, wdev->WscIEProbeResp.Value,
wdev->WscIEProbeResp.ValueLen, len);
break;
}
#endif /* WSC_STA_SUPPORT */
}
return len;
}
static INT build_wsc_assoc_req_ie(RTMP_ADAPTER *pAd, struct wifi_dev *wdev,
UCHAR *buf)
{
INT len = 0;
#ifdef WSC_STA_SUPPORT
/* Add WSC IE if we are connecting to WSC AP */
if ((wdev->WscControl.WscEnAssociateIE) &&
(wdev->WscControl.WscConfMode != WSC_DISABLE) &&
(wdev->WscControl.bWscTrigger)) {
UCHAR *pWscBuf = NULL, WscIeLen = 0;
os_alloc_mem(pAd, (UCHAR **)&pWscBuf, 512);
if (pWscBuf != NULL) {
NdisZeroMemory(pWscBuf, 512);
WscBuildAssocReqIE(&wdev->WscControl, pWscBuf,
&WscIeLen);
MAKE_IE_TO_BUF(buf, pWscBuf, WscIeLen, len);
os_free_mem(pWscBuf);
} else
MTWF_LOG(DBG_CAT_CLIENT, DBG_SUBCAT_ALL, DBG_LVL_WARN,
("%s:: WscBuf Allocate failed!\n", __func__));
}
#endif /* WSC_STA_SUPPORT */
return len;
}
INT build_wsc_ie(RTMP_ADAPTER *pAd, struct _build_ie_info *info)
{
INT len = 0;
if (info->frame_subtype == SUBTYPE_PROBE_REQ)
len += build_wsc_probe_req_ie(pAd, info->wdev,
(UCHAR *)(info->frame_buf + len));
else if (info->frame_subtype == SUBTYPE_PROBE_RSP)
len += build_wsc_probe_rsp_ie(pAd, info->wdev,
(UCHAR *)(info->frame_buf + len));
else if (info->frame_subtype == SUBTYPE_ASSOC_REQ)
len += build_wsc_assoc_req_ie(pAd, info->wdev,
(UCHAR *)(info->frame_buf + len));
return len;
}
INT build_extra_probe_req_ie(RTMP_ADAPTER *pAd, struct wifi_dev *wdev,
UCHAR *buf)
{
INT len = 0;
SCAN_INFO *ScanInfo = &wdev->ScanInfo;
#ifdef RT_CFG80211_SUPPORT
#ifdef APCLI_CFG80211_SUPPORT
if ((pAd->ApCfg.ApCliTab[wdev->func_idx]
.wpa_supplicant_info.WpaSupplicantUP !=
WPA_SUPPLICANT_DISABLE) &&
(pAd->cfg80211_ctrl.ExtraIeLen > 0)) {
MAKE_IE_TO_BUF(buf, pAd->cfg80211_ctrl.pExtraIe,
pAd->cfg80211_ctrl.ExtraIeLen, len);
}
#endif /* APCLI_CFG80211_SUPPORT */
#endif /* RT_CFG80211_SUPPORT */
if (ScanInfo->ExtraIeLen && ScanInfo->ExtraIe) {
MAKE_IE_TO_BUF(buf, ScanInfo->ExtraIe, ScanInfo->ExtraIeLen,
len);
}
return len;
}
INT build_extra_assoc_req_ie(RTMP_ADAPTER *pAd, struct wifi_dev *wdev,
UCHAR *buf)
{
INT len = 0;
return len;
}
INT build_extra_ie(RTMP_ADAPTER *pAd, struct _build_ie_info *info)
{
INT len = 0;
if (info->frame_subtype == SUBTYPE_PROBE_REQ)
len += build_extra_probe_req_ie(
pAd, info->wdev, (UCHAR *)(info->frame_buf + len));
else if (info->frame_subtype == SUBTYPE_ASSOC_REQ)
len += build_extra_assoc_req_ie(
pAd, info->wdev, (UCHAR *)(info->frame_buf + len));
return len;
}
#ifdef CONFIG_AP_SUPPORT
/* Extended Capabilities IE */
INT build_ap_extended_cap_ie(RTMP_ADAPTER *pAd, struct wifi_dev *wdev,
UCHAR *buf)
{
INT len = 0;
ULONG infoPos;
PUCHAR pInfo;
BOOLEAN bNeedAppendExtIE = FALSE;
UCHAR extInfoLen = sizeof(EXT_CAP_INFO_ELEMENT);
BSS_STRUCT *mbss;
EXT_CAP_INFO_ELEMENT extCapInfo = { 0 };
/* NdisZeroMemory(&extCapInfo, extInfoLen); */
mbss = wdev->func_dev;
#ifdef DOT11_N_SUPPORT
#ifdef DOT11N_DRAFT3
/* P802.11n_D1.10, HT Information Exchange Support */
if ((pAd->CommonCfg.bBssCoexEnable == TRUE) &&
WMODE_CAP_N(wdev->PhyMode) && (wdev->channel <= 14) &&
(wdev->DesiredHtPhyInfo.bHtEnable))
extCapInfo.BssCoexistMgmtSupport = 1;
#endif /* DOT11N_DRAFT3 */
#endif /* DOT11_N_SUPPORT */
#ifdef CONFIG_DOT11V_WNM
if (mbss->WNMCtrl.ProxyARPEnable)
extCapInfo.proxy_arp = 1;
if (mbss->WNMCtrl.WNMBTMEnable)
extCapInfo.BssTransitionManmt = 1;
#ifdef CONFIG_HOTSPOT_R2
if (mbss->WNMCtrl.WNMNotifyEnable)
extCapInfo.wnm_notification = 1;
if (mbss->HotSpotCtrl.QosMapEnable)
extCapInfo.qosmap = 1;
#endif /* CONFIG_HOTSPOT_R2 */
#endif /* CONFIG_DOT11V_WNM */
/* interworking ie without hotspot enabled. */
#ifdef DOT11U_INTERWORKING_IE_SUPPORT
if (mbss->bEnableInterworkingIe == TRUE)
extCapInfo.interworking = 1;
#endif
#if defined(CONFIG_HOTSPOT) || defined(FTM_SUPPORT) || \
defined(CONFIG_DOT11U_INTERWORKING)
if (mbss->GASCtrl.b11U_enable)
extCapInfo.interworking = 1;
#endif
#ifdef DOT11_VHT_AC
if (WMODE_CAP_AC(wdev->PhyMode) && (wdev->channel > 14))
extCapInfo.operating_mode_notification = 1;
#endif /* DOT11_VHT_AC */
#ifdef FTM_SUPPORT
/* add IE_EXT_CAPABILITY IE here */
if (pAd->pFtmCtrl->bSetCivicRpt)
extCapInfo.civic_location = 1;
if (pAd->pFtmCtrl->bSetLciRpt)
extCapInfo.geospatial_location = 1;
/* 802.11mc D3.0: 10.24.6.2 (p.1717):
"A STA in which dot11FineTimingMsmtRespActivated is true shall set the Fine Timing Measurement
Responder field of the Extended Capabilities element to 1."
*/
/* 8.4.2.26 Extended Capabilities element (p.817):
Capabilities field= 70: Fine Timing Measurement Responder (p.823)
*/
extCapInfo.ftm_resp = 1;
#endif /* FTM_SUPPORT */
#ifdef OCE_FILS_SUPPORT
if (IS_AKM_FILS(wdev->SecConfig.AKMMap))
extCapInfo.FILSCap = 1;
#endif /* OCE_FILS_SUPPORT */
#ifdef DOT11_SAE_PWD_ID_SUPPORT
{
struct _SECURITY_CONFIG *sec_cfg = &wdev->SecConfig;
if (IS_AKM_SAE(sec_cfg->AKMMap) && sec_cfg->pwd_id_cnt != 0)
extCapInfo.sae_pwd_id_in_use = 1;
else
extCapInfo.sae_pwd_id_in_use = 0;
if (IS_AKM_SAE(sec_cfg->AKMMap) && sec_cfg->sae_cap.pwd_id_only)
extCapInfo.sae_pwd_id_used_exclusively = 1;
else
extCapInfo.sae_pwd_id_used_exclusively = 0;
}
#endif
pInfo = (PUCHAR)(&extCapInfo);
for (infoPos = 0; infoPos < extInfoLen; infoPos++) {
if (pInfo[infoPos] != 0) {
bNeedAppendExtIE = TRUE;
break;
}
}
if (bNeedAppendExtIE == TRUE) {
for (infoPos = (extInfoLen - 1);
infoPos >= EXT_CAP_MIN_SAFE_LENGTH; infoPos--) {
if (pInfo[infoPos] == 0)
extInfoLen--;
else
break;
}
#ifdef RT_BIG_ENDIAN
RTMPEndianChange((UCHAR *)&extCapInfo, 8);
#endif
MAKE_IE_TO_BUF(buf, &ExtCapIe, 1, len);
MAKE_IE_TO_BUF(buf, &extInfoLen, 1, len);
MAKE_IE_TO_BUF(buf, &extCapInfo, extInfoLen, len);
}
return len;
}
#endif /* CONFIG_AP_SUPPORT */
INT build_extended_cap_ie(RTMP_ADAPTER *pAd, struct _build_ie_info *info)
{
INT len = 0;
struct wifi_dev *wdev = info->wdev;
switch (wdev->wdev_type) {
default:
#ifdef CONFIG_AP_SUPPORT
len += build_ap_extended_cap_ie(
pAd, info->wdev, (UCHAR *)(info->frame_buf + len));
#endif /* CONFIG_AP_SUPPORT */
break;
}
return len;
}
#ifdef CONFIG_AP_SUPPORT
static INT build_ap_wmm_cap_ie(RTMP_ADAPTER *pAd, struct wifi_dev *wdev,
UCHAR *buf)
{
INT len = 0;
UCHAR i;
UCHAR WmeParmIe[26] = {
IE_VENDOR_SPECIFIC, 24, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x01, 0, 0
};
UINT8 AIFSN[4];
#ifdef UAPSD_SUPPORT
BSS_STRUCT *pMbss = wdev->func_dev;
#endif
struct _EDCA_PARM *pBssEdca = wlan_config_get_ht_edca(wdev);
if (pBssEdca) {
WmeParmIe[8] = pBssEdca->EdcaUpdateCount & 0x0f;
#ifdef UAPSD_SUPPORT
UAPSD_MR_IE_FILL(WmeParmIe[8], &pMbss->wdev.UapsdInfo);
#endif /* UAPSD_SUPPORT */
NdisMoveMemory(AIFSN, pBssEdca->Aifsn, sizeof(AIFSN));
for (i = QID_AC_BK; i <= QID_AC_VO; i++) {
WmeParmIe[10 + (i * 4)] =
(i << 5) + /* b5-6 is ACI */
((UCHAR)pBssEdca->bACM[i]
<< 4) + /* b4 is ACM */
(AIFSN[i] & 0x0f); /* b0-3 is AIFSN */
WmeParmIe[11 + (i * 4)] =
(pBssEdca->Cwmax[i] << 4) + /* b5-8 is CWMAX */
(pBssEdca->Cwmin[i] & 0x0f); /* b0-3 is CWMIN */
WmeParmIe[12 + (i * 4)] =
(UCHAR)(pBssEdca->Txop[i] &
0xff); /* low byte of TXOP */
WmeParmIe[13 + (i * 4)] =
(UCHAR)(pBssEdca->Txop[i] >>
8); /* high byte of TXOP */
}
MAKE_IE_TO_BUF(buf, WmeParmIe, 26, len);
}
return len;
}
#endif /* CONFIG_AP_SUPPORT */
INT build_wmm_cap_ie(RTMP_ADAPTER *pAd, struct _build_ie_info *info)
{
INT len = 0;
struct wifi_dev *wdev = info->wdev;
if (!wdev->bWmmCapable)
return len;
switch (wdev->wdev_type) {
default:
#ifdef CONFIG_AP_SUPPORT
len += build_ap_wmm_cap_ie(pAd, info->wdev,
(UCHAR *)(info->frame_buf + len));
#endif /* CONFIG_AP_SUPPORT */
break;
}
return len;
}
ULONG build_support_rate_ie(struct wifi_dev *wdev, UCHAR *sup_rate,
UCHAR sup_rate_len, UCHAR *buf)
{
ULONG frame_len;
ULONG bss_mem_selector_len = 0;
UCHAR bss_mem_selector_code = BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_SAE_H2E_ONLY;
USHORT PhyMode = wdev->PhyMode;
UCHAR real_sup_rate_len = sup_rate_len;
UCHAR total_len;
if (PhyMode == WMODE_B)
real_sup_rate_len = 4;
#ifdef DOT11_SAE_SUPPORT
if (wdev->SecConfig.sae_cap.gen_pwe_method == PWE_HASH_ONLY &&
real_sup_rate_len < 8)
bss_mem_selector_len++;
#endif
total_len = real_sup_rate_len + bss_mem_selector_len;
MakeOutgoingFrame(buf, &frame_len, 1, &SupRateIe, 1, &total_len,
real_sup_rate_len, sup_rate, bss_mem_selector_len,
&bss_mem_selector_code, END_OF_ARGS);
return frame_len;
}
ULONG build_support_ext_rate_ie(struct wifi_dev *wdev, UCHAR sup_rate_len,
UCHAR *ext_sup_rate, UCHAR ext_sup_rate_len,
UCHAR *buf)
{
ULONG frame_len = 0;
ULONG bss_mem_selector_len = 0;
UCHAR bss_mem_selector_code = BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_SAE_H2E_ONLY;
USHORT PhyMode = wdev->PhyMode;
UCHAR total_len;
if (PhyMode == WMODE_B)
return frame_len;
#ifdef DOT11_SAE_SUPPORT
if (sup_rate_len >= 8 &&
wdev->SecConfig.sae_cap.gen_pwe_method == PWE_HASH_ONLY)
bss_mem_selector_len++;
#endif
if (ext_sup_rate_len == 0 && bss_mem_selector_len == 0)
return frame_len;
total_len = ext_sup_rate_len + bss_mem_selector_len;
MakeOutgoingFrame(buf, &frame_len, 1, &ExtRateIe, 1, &total_len,
ext_sup_rate_len, ext_sup_rate, bss_mem_selector_len,
&bss_mem_selector_code, END_OF_ARGS);
return frame_len;
}
VOID parse_support_rate_ie(struct dev_rate_info *rate, EID_STRUCT *eid_ptr)
{
UCHAR i = 0;
if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) &&
(eid_ptr->Len > 0)) {
rate->SupRateLen = 0;
for (i = 0; i < eid_ptr->Len; i++)
if (eid_ptr->Octet[i] !=
(BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_HT_PHY) &&
eid_ptr->Octet[i] !=
(BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_VHT_PHY) &&
eid_ptr->Octet[i] !=
(BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_SAE_H2E_ONLY) &&
eid_ptr->Octet[i] !=
(BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_HE_PHY))
rate->SupRate[rate->SupRateLen++] =
eid_ptr->Octet[i];
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_INFO,
("%s - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",
__func__, eid_ptr->Len, rate->SupRate[0]));
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_INFO,
("Rates[1]=%x %x %x %x %x %x %x\n", rate->SupRate[1],
rate->SupRate[2], rate->SupRate[3], rate->SupRate[4],
rate->SupRate[5], rate->SupRate[6],
rate->SupRate[7]));
} else {
UCHAR RateDefault[8] = { 0x82, 0x84, 0x8b, 0x96,
0x12, 0x24, 0x48, 0x6c };
/* HT rate not ready yet. return true temporarily. rt2860c */
/*MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("PeerAssocReqSanity - wrong IE_SUPP_RATES\n")); */
NdisMoveMemory(rate->SupRate, RateDefault, 8);
rate->SupRateLen = 8;
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s - wrong IE_SUPP_RATES., Len=%d\n", __func__,
eid_ptr->Len));
}
}
VOID parse_support_ext_rate_ie(struct dev_rate_info *rate, EID_STRUCT *eid_ptr)
{
UINT16 i = 0;
if (eid_ptr->Len > MAX_LEN_OF_SUPPORTED_RATES) {
MTWF_LOG(
DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s:ext support rate ie size(%d) is large than MAX_LEN_OF_SUPPORTED_RATE(%d))\n",
__func__, eid_ptr->Len, MAX_LEN_OF_SUPPORTED_RATES));
return;
}
rate->ExtRateLen = 0;
for (i = 0; i < eid_ptr->Len; i++)
if (eid_ptr->Octet[i] != (BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_HT_PHY) &&
eid_ptr->Octet[i] != (BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_VHT_PHY) &&
eid_ptr->Octet[i] !=
(BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_SAE_H2E_ONLY) &&
eid_ptr->Octet[i] != (BSS_MEMBERSHIP_SELECTOR_VALID |
BSS_MEMBERSHIP_SELECTOR_HE_PHY))
rate->ExtRate[rate->ExtRateLen++] = eid_ptr->Octet[i];
}

View File

@ -1,452 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
cmm_mat.c
Abstract:
Support Mac Address Translation function.
Note:
MAC Address Translation(MAT) engine subroutines, we should just take care
packet to bridge.
Revision History:
Who When What
-------------- ---------- ----------------------------------------------
Shiang 02-26-2007 Init version
*/
#ifdef MAT_SUPPORT
#include "rt_config.h"
extern MATProtoOps MATProtoIPHandle;
extern MATProtoOps MATProtoARPHandle;
extern MATProtoOps MATProtoPPPoEDisHandle;
extern MATProtoOps MATProtoPPPoESesHandle;
extern MATProtoOps MATProtoIPv6Handle;
extern UCHAR SNAP_802_1H[];
extern UCHAR SNAP_BRIDGE_TUNNEL[];
#define MAX_MAT_NODE_ENTRY_NUM \
128 /* We support maximum 128 node entry for our system */
#define MAT_NODE_ENTRY_SIZE \
40 /*28 // bytes //change to 40 for IPv6Mac Table */
typedef struct _MATNodeEntry {
UCHAR data[MAT_NODE_ENTRY_SIZE];
struct _MATNodeEntry *next;
} MATNodeEntry, *PMATNodeEntry;
#ifdef KMALLOC_BATCH
/*static MATNodeEntry *MATNodeEntryPoll = NULL; */
#endif
static MATProtoTable MATProtoTb[] = {
{ ETH_P_IP, &MATProtoIPHandle }, /* IP handler */
{ ETH_P_ARP, &MATProtoARPHandle }, /* ARP handler */
{ ETH_P_PPP_DISC,
&MATProtoPPPoEDisHandle }, /* PPPoE discovery stage handler */
{ ETH_P_PPP_SES,
&MATProtoPPPoESesHandle }, /* PPPoE session stage handler */
{ ETH_P_IPV6, &MATProtoIPv6Handle }, /* IPv6 handler */
};
#define MAX_MAT_SUPPORT_PROTO_NUM (sizeof(MATProtoTb) / sizeof(MATProtoTable))
/* --------------------------------- Public Function-------------------------------- */
NDIS_STATUS MATDBEntryFree(IN MAT_STRUCT *pMatStruct, IN PUCHAR NodeEntry)
{
#ifdef KMALLOC_BATCH
MATNodeEntry *pPtr, *pMATNodeEntryPoll;
pMATNodeEntryPoll = (MATNodeEntry *)pAd->MatCfg.MATNodeEntryPoll;
pPtr = (MATNodeEntry *)NodeEntry;
NdisZeroMemory(pPtr, sizeof(MATNodeEntry));
if (pMATNodeEntryPoll->next) {
pPtr->next = pMATNodeEntryPoll->next;
pMATNodeEntryPoll->next = pPtr;
} else
pMATNodeEntryPoll->next = pPtr;
#else
os_free_mem(NodeEntry);
#endif
return TRUE;
}
PUCHAR MATDBEntryAlloc(IN MAT_STRUCT *pMatStruct, IN UINT32 size)
{
#ifdef KMALLOC_BATCH
MATNodeEntry *pPtr = NULL, *pMATNodeEntryPoll;
pMATNodeEntryPoll = (MATNodeEntry *)pMatStruct->pMATNodeEntryPoll;
if (pMATNodeEntryPoll->next) {
pPtr = pMATNodeEntryPoll->next;
pMATNodeEntryPoll->next = pPtr->next;
}
#else
UCHAR *pPtr = NULL;
os_alloc_mem(NULL, (PUCHAR *)&pPtr, size);
#endif
return (PUCHAR)pPtr;
}
VOID dumpPkt(PUCHAR pHeader, int len)
{
int i;
RTMP_STRING *tmp;
tmp = (RTMP_STRING *)pHeader;
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF, ("--StartDump\n"));
for (i = 0; i < len; i++) {
if ((i % 16 == 0) && (i != 0))
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("\n"));
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("%02x ", tmp[i] & 0xff));
}
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF, ("\n--EndDump\n"));
return;
}
/*
========================================================================
Routine Description:
For each out-going packet, check the upper layer protocol type if need
to handled by our APCLI convert engine. If yes, call corresponding handler
to handle it.
Arguments:
pAd =>Pointer to our adapter
pPkt =>pointer to the 802.11 header of outgoing packet
ifIdx =>Interface Index want to dispatch to.
Return Value:
Success =>
TRUE
Mapped mac address if found, else return specific default mac address
depends on the upper layer protocol type.
Error =>
FALSE.
Note:
1.the pPktHdr must be a 802.3 packet.
2.Maybe we need a TxD arguments?
3.We check every packet here including group mac address becasue we need to
handle DHCP packet.
========================================================================
*/
PUCHAR MATEngineTxHandle(IN PRTMP_ADAPTER pAd, IN PNDIS_PACKET pPkt,
IN UINT ifIdx, IN UCHAR OpMode)
{
PUCHAR pLayerHdr = NULL, pPktHdr = NULL, pMacAddr = NULL;
UINT16 protoType, protoType_ori;
INT i;
struct _MATProtoOps *pHandle = NULL;
PUCHAR retSkb = NULL;
BOOLEAN bVLANPkt = FALSE;
if (pAd->MatCfg.status != MAT_ENGINE_STAT_INITED)
return NULL;
pPktHdr = GET_OS_PKT_DATAPTR(pPkt);
if (!pPktHdr)
return NULL;
protoType_ori = get_unaligned((PUINT16)(pPktHdr + 12));
/* Get the upper layer protocol type of this 802.3 pkt. */
protoType = OS_NTOHS(protoType_ori);
/* handle 802.1q enabled packet. Skip the VLAN tag field to get the protocol type. */
if (protoType == 0x8100) {
protoType_ori = get_unaligned((PUINT16)(pPktHdr + 12 + 4));
protoType = OS_NTOHS(protoType_ori);
bVLANPkt = TRUE;
}
/* For differnet protocol, dispatch to specific handler */
for (i = 0; i < MAX_MAT_SUPPORT_PROTO_NUM; i++) {
if (protoType == MATProtoTb[i].protocol) {
pHandle =
MATProtoTb[i]
.pHandle; /* the pHandle must not be null! */
pLayerHdr = bVLANPkt ?
(pPktHdr + MAT_VLAN_ETH_HDR_LEN) :
(pPktHdr + MAT_ETHER_HDR_LEN);
#ifdef CONFIG_AP_SUPPORT
#ifdef APCLI_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
{
#ifdef MAC_REPEATER_SUPPORT
UCHAR tempIdx = ifIdx;
UCHAR CliIdx = 0xFF;
if (tempIdx >= REPT_MLME_START_IDX) {
CliIdx = tempIdx - REPT_MLME_START_IDX;
pMacAddr =
&pAd->ApCfg
.pRepeaterCliPool[CliIdx]
.CurrentAddress[0];
} else
#endif /* MAC_REPEATER_SUPPORT */
pMacAddr = &pAd->ApCfg.ApCliTab[ifIdx]
.wdev.if_addr[0];
}
#endif /* APCLI_SUPPORT */
#endif /* CONFIG_AP_SUPPORT */
if (pHandle->tx != NULL)
retSkb = pHandle->tx((PVOID)&pAd->MatCfg,
RTPKT_TO_OSPKT(pPkt),
pLayerHdr, pMacAddr);
return retSkb;
}
}
return retSkb;
}
/*
========================================================================
Routine Description:
Depends on the Received packet, check the upper layer protocol type
and search for specific mapping table to find out the real destination
MAC address.
Arguments:
pAd =>Pointer to our adapter
pPkt =>pointer to the 802.11 header of receviced packet
infIdx =>Interface Index want to dispatch to.
Return Value:
Success =>
Mapped mac address if found, else return specific default mac address
depends on the upper layer protocol type.
Error =>
NULL
Note:
========================================================================
*/
PUCHAR MATEngineRxHandle(IN PRTMP_ADAPTER pAd, IN PNDIS_PACKET pPkt,
IN UINT infIdx)
{
PUCHAR pMacAddr = NULL;
PUCHAR pLayerHdr = NULL, pPktHdr = NULL;
UINT16 protoType;
INT i = 0;
struct _MATProtoOps *pHandle = NULL;
if (pAd->MatCfg.status != MAT_ENGINE_STAT_INITED)
return NULL;
pPktHdr = GET_OS_PKT_DATAPTR(pPkt);
if (!pPktHdr)
return NULL;
/* If it's a multicast/broadcast packet, we do nothing. */
if (IS_GROUP_MAC(pPktHdr))
return NULL;
/* Get the upper layer protocol type of this 802.3 pkt and dispatch to specific handler */
protoType = OS_NTOHS(get_unaligned((PUINT16)(pPktHdr + 12)));
pLayerHdr = (pPktHdr + MAT_ETHER_HDR_LEN);
if (protoType == ETH_P_VLAN) {
protoType = OS_NTOHS(get_unaligned((
PUINT16)(pPktHdr + 12 +
LENGTH_802_1Q))); /* Shift VLAN Tag Length (4 byte) */
pLayerHdr = (pPktHdr + MAT_VLAN_ETH_HDR_LEN);
}
for (i = 0; i < MAX_MAT_SUPPORT_PROTO_NUM; i++) {
if (protoType == MATProtoTb[i].protocol) {
pHandle =
MATProtoTb[i]
.pHandle; /* the pHandle must not be null! */
/* RTMP_SEM_LOCK(&MATDBLock); */
if (pHandle->rx != NULL)
pMacAddr = pHandle->rx((PVOID)&pAd->MatCfg,
RTPKT_TO_OSPKT(pPkt),
pLayerHdr, NULL);
/* RTMP_SEM_UNLOCK(&MATDBLock); */
break;
}
}
if (pMacAddr)
NdisMoveMemory(pPktHdr, pMacAddr, MAC_ADDR_LEN);
return NULL;
}
BOOLEAN MATPktRxNeedConvert(IN PRTMP_ADAPTER pAd, IN PNET_DEV net_dev)
{
#ifdef CONFIG_AP_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
{
#ifdef APCLI_SUPPORT
int i = 0;
/* Check if the packet will be send to apcli interface. */
while (i < MAX_APCLI_NUM) {
/*BSSID match the ApCliBssid ?(from a valid AP) */
if ((pAd->ApCfg.ApCliTab[i].Valid == TRUE) &&
(net_dev == pAd->ApCfg.ApCliTab[i].wdev.if_dev)
#ifdef A4_CONN
&& (IS_APCLI_A4(&pAd->ApCfg.ApCliTab[i]) == FALSE)
#endif /* A4_CONN */
) {
//MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_WARN,("MATPktRxNeedConvert TRUE for ApCliTab[%d]\n",i));
return TRUE;
}
i++;
}
#endif /* APCLI_SUPPORT */
}
#endif /* CONFIG_AP_SUPPORT */
return FALSE;
}
NDIS_STATUS MATEngineExit(IN RTMP_ADAPTER *pAd)
{
struct _MATProtoOps *pHandle = NULL;
int i;
if (pAd->MatCfg.status == MAT_ENGINE_STAT_EXITED)
return TRUE;
/* For each registered protocol, we call it's exit handler. */
for (i = 0; i < MAX_MAT_SUPPORT_PROTO_NUM; i++) {
pHandle = MATProtoTb[i].pHandle;
if (pHandle->exit != NULL)
pHandle->exit(&pAd->MatCfg);
}
#ifdef KMALLOC_BATCH
/* Free the memory used to store node entries. */
if (pAd->MatCfg.pMATNodeEntryPoll) {
os_free_mem(pAd->MatCfg.pMATNodeEntryPoll);
pAd->MatCfg.pMATNodeEntryPoll = NULL;
}
#endif
pAd->MatCfg.status = MAT_ENGINE_STAT_EXITED;
return TRUE;
}
NDIS_STATUS MATEngineInit(IN RTMP_ADAPTER *pAd)
{
MATProtoOps *pHandle = NULL;
int i, status;
if (pAd->MatCfg.status == MAT_ENGINE_STAT_INITED)
return TRUE;
#ifdef KMALLOC_BATCH
/* Allocate memory for node entry, we totally allocate 128 entries and link them together. */
os_alloc_mem_suspend(NULL, (UCHAR **)&(pAd->MatCfg.pMATNodeEntryPoll),
sizeof(MATNodeEntry) * MAX_MAT_NODE_ENTRY_NUM);
if (pAd->MatCfg.pMATNodeEntryPoll != NULL) {
MATNodeEntry *pPtr = NULL;
NdisZeroMemory(pAd->MatCfg.pMATNodeEntryPoll,
sizeof(MATNodeEntry) * MAX_MAT_NODE_ENTRY_NUM);
pPtr = pAd->MatCfg.pMATNodeEntryPoll;
for (i = 0; i < (MAX_MAT_NODE_ENTRY_NUM - 1); i++) {
pPtr->next = (MATNodeEntry *)(pPtr + 1);
pPtr = pPtr->next;
}
pPtr->next = NULL;
} else
return FALSE;
#endif
/* For each specific protocol, call it's init function. */
for (i = 0; i < MAX_MAT_SUPPORT_PROTO_NUM; i++) {
pHandle = MATProtoTb[i].pHandle;
ASSERT(pHandle);
if (pHandle->init != NULL) {
status = pHandle->init(&pAd->MatCfg);
if (status == FALSE) {
MTWF_LOG(
DBG_CAT_PROTO, CATPROTO_MAT,
DBG_LVL_ERROR,
("MATEngine Init Protocol (0x%x) failed, Stop the MAT Funciton initialization failed!\n",
MATProtoTb[i].protocol));
goto init_failed;
}
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE,
("MATEngine Init Protocol (0x%04x) success!\n",
MATProtoTb[i].protocol));
}
}
NdisAllocateSpinLock(pAd, &pAd->MatCfg.MATDBLock);
#ifdef MAC_REPEATER_SUPPORT
pAd->MatCfg.bMACRepeaterEn = FALSE;
#endif /* MAC_REPEATER_SUPPORT */
pAd->MatCfg.pPriv = (VOID *)pAd;
pAd->MatCfg.status = MAT_ENGINE_STAT_INITED;
return TRUE;
init_failed:
/* For each specific protocol, call it's exit function. */
for (i = 0; i < MAX_MAT_SUPPORT_PROTO_NUM; i++) {
pHandle = MATProtoTb[i].pHandle;
if (pHandle != NULL) {
if (pHandle->exit != NULL) {
status = pHandle->exit(&pAd->MatCfg);
if (status == FALSE)
goto init_failed;
}
}
}
#ifdef KMALLOC_BATCH
if (pAd->MatCfg.pMATNodeEntryPoll)
os_free_mem(pAd->MatCfg.pMATNodeEntryPoll);
pAd->MatCfg.status = MAT_ENGINE_STAT_EXITED;
#endif /* KMALLOC_BATCH */
return FALSE;
}
#endif /* MAT_SUPPORT */

View File

@ -1,836 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
cmm_mat_iparp.c
Abstract:
MAT convert engine subroutine for ip base protocols, currently now we
just handle IP/ARP protocols.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Shiang 02/26/07 Init version
*/
#ifdef MAT_SUPPORT
#include "rt_config.h"
static NDIS_STATUS MATProto_IP_Init(MAT_STRUCT *pMatCfg);
static NDIS_STATUS MATProto_IP_Exit(MAT_STRUCT *pMatCfg);
static PUCHAR MATProto_IP_Rx(MAT_STRUCT *pMatCfg, PNDIS_PACKET pSkb,
PUCHAR pLayerHdr, PUCHAR pMacAddr);
static PUCHAR MATProto_IP_Tx(MAT_STRUCT *pMatCfg, PNDIS_PACKET pSkb,
PUCHAR pLayerHdr, PUCHAR pMacAddr);
static NDIS_STATUS MATProto_ARP_Init(MAT_STRUCT *pMatCfg);
static NDIS_STATUS MATProto_ARP_Exit(MAT_STRUCT *pMatCfg);
static PUCHAR MATProto_ARP_Rx(MAT_STRUCT *pMatCfg, PNDIS_PACKET pSkb,
PUCHAR pLayerHdr, PUCHAR pMacAddr);
static PUCHAR MATProto_ARP_Tx(MAT_STRUCT *pMatCfg, PNDIS_PACKET pSkb,
PUCHAR pLayerHdr, PUCHAR pMacAddr);
#define IPV4_ADDR_LEN 4
#define NEED_UPDATE_IPMAC_TB(Mac, IP) (IS_UCAST_MAC(Mac) && IS_GOOD_IP(IP))
typedef struct _IPMacMappingEntry {
UINT ipAddr; /* In network order */
UCHAR macAddr[MAC_ADDR_LEN];
ULONG lastTime;
struct _IPMacMappingEntry *pNext;
} IPMacMappingEntry, *PIPMacMappingEntry;
typedef struct _IPMacMappingTable {
BOOLEAN valid;
IPMacMappingEntry *hash
[MAT_MAX_HASH_ENTRY_SUPPORT +
1]; /*0~63 for specific station, 64 for broadcast MacAddress */
UCHAR curMcastAddr
[MAC_ADDR_LEN]; /* The multicast mac addr for currecnt received packet destined to ipv4 multicast addr */
} IPMacMappingTable;
struct _MATProtoOps MATProtoIPHandle = {
.init = MATProto_IP_Init,
.tx = MATProto_IP_Tx,
.rx = MATProto_IP_Rx,
.exit = MATProto_IP_Exit,
};
struct _MATProtoOps MATProtoARPHandle = {
.init = MATProto_ARP_Init,
.tx = MATProto_ARP_Tx,
.rx = MATProto_ARP_Rx,
.exit = MATProto_ARP_Exit,
};
VOID dumpIPMacTb(IN MAT_STRUCT *pMatCfg, IN int index)
{
IPMacMappingTable *pIPMacTable;
IPMacMappingEntry *pHead;
int startIdx, endIdx;
pIPMacTable = (IPMacMappingTable *)pMatCfg->MatTableSet.IPMacTable;
if (!pIPMacTable)
return;
if (!pIPMacTable->valid) {
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("%s():IPMacTable not init yet, so cannot do dump!\n",
__func__));
return;
}
if (index < 0) {
/* dump all. */
startIdx = 0;
endIdx = MAT_MAX_HASH_ENTRY_SUPPORT;
} else {
/* dump specific hash index. */
startIdx = endIdx = index;
}
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("%s():\n", __func__));
for (; startIdx <= endIdx; startIdx++) {
pHead = pIPMacTable->hash[startIdx];
while (pHead) {
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("IPMac[%d]:\n", startIdx));
MTWF_LOG(
DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("\t:IP=0x%x,Mac=%02x:%02x:%02x:%02x:%02x:%02x, lastTime=0x%lx, next=%p\n",
pHead->ipAddr, pHead->macAddr[0],
pHead->macAddr[1], pHead->macAddr[2],
pHead->macAddr[3], pHead->macAddr[4],
pHead->macAddr[5], pHead->lastTime,
pHead->pNext));
pHead = pHead->pNext;
}
}
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("\t----EndOfDump!\n"));
}
static inline NDIS_STATUS getDstIPFromIpPkt(IN PUCHAR pIpHdr, IN UINT *dstIP)
{
if (!pIpHdr)
return FALSE;
NdisMoveMemory(dstIP, (pIpHdr + 16),
4); /*shift 16 for IP header len before DstIP. */
/* MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE, ("%s(): Get the dstIP=0x%x\n", __func__, *dstIP)); */
return TRUE;
}
static inline NDIS_STATUS getSrcIPFromIpPkt(IN PUCHAR pIpHdr, IN UINT *pSrcIP)
{
if (!pIpHdr)
return FALSE;
NdisMoveMemory(pSrcIP, (pIpHdr + 12),
4); /*shift 12 for IP header len before DstIP. */
/* MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE, ("%s(): Get the srcIP=0x%x\n", __func__, *pSrcIP)); */
return TRUE;
}
static NDIS_STATUS IPMacTableUpdate(IN MAT_STRUCT *pMatCfg, IN PUCHAR pMacAddr,
IN UINT ipAddr)
{
UINT hashIdx;
IPMacMappingTable *pIPMacTable;
IPMacMappingEntry *pEntry = NULL, *pPrev = NULL, *pNewEntry = NULL,
*pTempEntry = NULL;
ULONG now;
pIPMacTable = (IPMacMappingTable *)pMatCfg->MatTableSet.IPMacTable;
if (!pIPMacTable)
return FALSE;
if (!pIPMacTable->valid)
return FALSE;
hashIdx = MAT_IP_ADDR_HASH_INDEX(ipAddr);
pEntry = pPrev = pIPMacTable->hash[hashIdx];
while (pEntry) {
NdisGetSystemUpTime(&now);
/* Find a existed IP-MAC Mapping entry */
if (ipAddr == pEntry->ipAddr) {
/* MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE, ("%s(): Got the Mac(%02x:%02x:%02x:%02x:%02x:%02x) of mapped IP(%d.%d.%d.%d)\n",
__func__, pEntry->macAddr[0],pEntry->macAddr[1],pEntry->macAddr[2], pEntry->macAddr[3],pEntry->macAddr[4],
pEntry->macAddr[5], (ipAddr>>24) & 0xff, (ipAddr>>16) & 0xff, (ipAddr>>8) & 0xff, ipAddr & 0xff));
*/
/* compare is useless. So we directly copy it into the entry. */
NdisMoveMemory(pEntry->macAddr, pMacAddr, 6);
pEntry->lastTime = now;
return TRUE;
} else {
/* handle the age-out situation */
/*if ((Now - pEntry->lastTime) > MAT_TB_ENTRY_AGEOUT_TIME) */
if (RTMP_TIME_AFTER(now,
pEntry->lastTime +
MAT_TB_ENTRY_AGEOUT_TIME)) {
/* Remove the aged entry */
if (pEntry == pIPMacTable->hash[hashIdx]) {
pIPMacTable->hash[hashIdx] =
pEntry->pNext;
pPrev = pIPMacTable->hash[hashIdx];
} else
pPrev->pNext = pEntry->pNext;
pTempEntry = pEntry;
pEntry = (pPrev == NULL ? NULL : pPrev->pNext);
MATDBEntryFree(pMatCfg, (PUCHAR)pTempEntry);
pMatCfg->nodeCount--;
} else {
pPrev = pEntry;
pEntry = pEntry->pNext;
}
}
}
/* Allocate a new IPMacMapping entry and insert into the hash */
pNewEntry = (IPMacMappingEntry *)MATDBEntryAlloc(
pMatCfg, sizeof(IPMacMappingEntry));
if (pNewEntry != NULL) {
pNewEntry->ipAddr = ipAddr;
NdisMoveMemory(pNewEntry->macAddr, pMacAddr, 6);
pNewEntry->pNext = NULL;
NdisGetSystemUpTime(&pNewEntry->lastTime);
if (pIPMacTable->hash[hashIdx] == NULL) {
/* Hash list is empty, directly assign it. */
pIPMacTable->hash[hashIdx] = pNewEntry;
} else {
/* Ok, we insert the new entry into the root of hash[hashIdx] */
pNewEntry->pNext = pIPMacTable->hash[hashIdx];
pIPMacTable->hash[hashIdx] = pNewEntry;
}
/*dumpIPMacTb(pMatCfg, hashIdx); //for debug */
pMatCfg->nodeCount++;
return TRUE;
}
return FALSE;
}
static PUCHAR IPMacTableLookUp(IN MAT_STRUCT *pMatCfg, IN UINT ipAddr)
{
IPMacMappingTable *pIPMacTable;
UINT hashIdx, ip;
IPMacMappingEntry *pEntry = NULL;
PUCHAR pGroupMacAddr;
pIPMacTable = (IPMacMappingTable *)pMatCfg->MatTableSet.IPMacTable;
if (!pIPMacTable)
return NULL;
if (!pIPMacTable->valid)
return NULL;
/*if multicast ip, need converting multicast group address to ethernet address. */
ip = ntohl(ipAddr);
if (IS_MULTICAST_IP(ip)) {
pGroupMacAddr = (PUCHAR)(&pIPMacTable->curMcastAddr);
ConvertMulticastIP2MAC((PUCHAR)&ipAddr,
(UCHAR **)(&pGroupMacAddr), ETH_P_IP);
return pIPMacTable->curMcastAddr;
}
/* Use hash to find out the location of that entry and get the Mac address. */
hashIdx = MAT_IP_ADDR_HASH_INDEX(ipAddr);
/* spin_lock_irqsave(&IPMacTabLock, irqFlag); */
pEntry = pIPMacTable->hash[hashIdx];
while (pEntry) {
if (pEntry->ipAddr == ipAddr) {
/* MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE, ("%s(): dstMac=%02x:%02x:%02x:%02x:%02x:%02x for mapped dstIP(%d.%d.%d.%d)\n",
__func__, pEntry->macAddr[0],pEntry->macAddr[1],pEntry->macAddr[2],
pEntry->macAddr[3],pEntry->macAddr[4],pEntry->macAddr[5],
(ipAddr>>24) & 0xff, (ipAddr>>16) & 0xff, (ipAddr>>8) & 0xff, ipAddr & 0xff));
*/
/*Update the lastTime to prevent the aging before pDA processed! */
NdisGetSystemUpTime(&pEntry->lastTime);
return pEntry->macAddr;
} else
pEntry = pEntry->pNext;
}
/*
We didn't find any matched Mac address, our policy is treat it as
broadcast packet and send to all.
*/
return pIPMacTable->hash[IPMAC_TB_HASH_INDEX_OF_BCAST]->macAddr;
}
static NDIS_STATUS IPMacTable_RemoveAll(IN MAT_STRUCT *pMatCfg)
{
IPMacMappingEntry *pEntry;
IPMacMappingTable *pIPMacTable;
INT i;
pIPMacTable = (IPMacMappingTable *)pMatCfg->MatTableSet.IPMacTable;
if (!pIPMacTable)
return TRUE;
if (pIPMacTable->valid) {
pIPMacTable->valid = FALSE;
for (i = 0; i < IPMAC_TB_HASH_ENTRY_NUM; i++) {
while ((pEntry = pIPMacTable->hash[i]) != NULL) {
pIPMacTable->hash[i] = pEntry->pNext;
MATDBEntryFree(pMatCfg, (PUCHAR)pEntry);
}
}
}
os_free_mem(pIPMacTable);
pMatCfg->MatTableSet.IPMacTable = NULL;
return TRUE;
}
static NDIS_STATUS IPMacTable_init(IN MAT_STRUCT *pMatCfg)
{
IPMacMappingTable *pIPMacTable;
IPMacMappingEntry *pEntry = NULL;
if (pMatCfg->MatTableSet.IPMacTable != NULL)
pIPMacTable =
(IPMacMappingTable *)pMatCfg->MatTableSet.IPMacTable;
else {
os_alloc_mem_suspend(
NULL, (UCHAR **)&(pMatCfg->MatTableSet.IPMacTable),
sizeof(IPMacMappingTable));
if (pMatCfg->MatTableSet.IPMacTable) {
pIPMacTable = (IPMacMappingTable *)
pMatCfg->MatTableSet.IPMacTable;
NdisZeroMemory(pIPMacTable, sizeof(IPMacMappingTable));
} else {
MTWF_LOG(
DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_ERROR,
("IPMacTable_init(): Allocate memory for IPMacTable failed!\n"));
return FALSE;
}
}
if (pIPMacTable->valid == FALSE) {
/*Set the last hash entry (hash[64]) as our default broadcast Mac address */
pEntry = (IPMacMappingEntry *)MATDBEntryAlloc(
pMatCfg, sizeof(IPMacMappingEntry));
if (!pEntry) {
MTWF_LOG(
DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_ERROR,
("IPMacTable_init(): Allocate memory for IPMacTable broadcast entry failed!\n"));
return FALSE;
}
NdisZeroMemory(pEntry, sizeof(IPMacMappingEntry));
NdisMoveMemory(&pEntry->macAddr[0], &BROADCAST_ADDR[0], 6);
pEntry->pNext = NULL;
pIPMacTable->hash[IPMAC_TB_HASH_INDEX_OF_BCAST] = pEntry;
pIPMacTable->valid = TRUE;
} else
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE,
("%s(): IPMacTable already inited!\n", __func__));
return TRUE;
}
static NDIS_STATUS MATProto_ARP_Exit(IN MAT_STRUCT *pMatCfg)
{
INT status;
status = IPMacTable_RemoveAll(pMatCfg);
return status;
}
static PUCHAR MATProto_ARP_Rx(IN MAT_STRUCT *pMatCfg, IN PNDIS_PACKET pSkb,
IN PUCHAR pLayerHdr, IN PUCHAR pMacAddr)
{
PUCHAR pArpHdr = NULL, pRealMac = NULL;
PUCHAR tgtMac, tgtIP;
BOOLEAN isUcastMac, isGoodIP;
pArpHdr = pLayerHdr;
/*dumpPkt(RTPKT_TO_OSPKT(pSkb)->data, RTPKT_TO_OSPKT(pSkb)->len); */
/* We just take care about the target(Mac/IP address) fields. */
tgtMac = pArpHdr + 18;
tgtIP = tgtMac + 6;
/* isUcastMac = !(00:00:00:00:00:00|| mcastMac); */
isUcastMac = ((tgtMac[0] | tgtMac[1] | tgtMac[2] | tgtMac[3] |
tgtMac[4] | tgtMac[5]) != 0);
isUcastMac &= ((tgtMac[0] & 0x1) == 0);
/* isGoodIP = ip address is not 0.0.0.0 */
isGoodIP = (*(UINT *)tgtIP != 0);
if (isUcastMac && isGoodIP)
pRealMac = IPMacTableLookUp(pMatCfg, *(UINT *)tgtIP);
/*
For need replaced mac, we need to replace the targetMAC as correct one to make
the real receiver can receive that.
*/
if (isUcastMac && pRealMac)
NdisMoveMemory(tgtMac, pRealMac, MAC_ADDR_LEN);
if (pRealMac == NULL)
pRealMac = &BROADCAST_ADDR[0];
/* pRealMac = pIPMacTable->hash[IPMAC_TB_HASH_INDEX_OF_BCAST]->macAddr; */
return pRealMac;
}
static PUCHAR MATProto_ARP_Tx(IN MAT_STRUCT *pMatCfg, IN PNDIS_PACKET pSkb,
IN PUCHAR pLayerHdr, IN PUCHAR pMacAddr)
{
PUCHAR pSMac, pSIP;
BOOLEAN isUcastMac, isGoodIP;
NET_PRO_ARP_HDR *arpHdr;
PUCHAR pPktHdr;
PNDIS_PACKET newSkb = NULL;
pPktHdr = GET_OS_PKT_DATAPTR(pSkb);
arpHdr = (NET_PRO_ARP_HDR *)pLayerHdr;
/*
Check the arp header.
We just handle ether type hardware address and IPv4 internet
address type and opcode is ARP reuqest/response.
*/
if ((arpHdr->ar_hrd != OS_HTONS(ARPHRD_ETHER)) ||
(arpHdr->ar_pro != OS_HTONS(ETH_P_IP)) ||
(arpHdr->ar_op != OS_HTONS(ARPOP_REPLY) &&
arpHdr->ar_op != OS_HTONS(ARPOP_REQUEST)))
return NULL;
/* We just take care about the sender(Mac/IP address) fields. */
pSMac = (PUCHAR)(pLayerHdr + 8);
pSIP = (PUCHAR)(pSMac + MAC_ADDR_LEN);
isUcastMac = IS_UCAST_MAC(pSMac);
isGoodIP = IS_GOOD_IP(get_unaligned32((PUINT)pSIP));
/*
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE,("%s(): ARP Pkt=>senderIP=%d.%d.%d.%d, senderMac=%02x:%02x:%02x:%02x:%02x:%02x\n",
__func__, pSIP[0], pSIP[1], pSIP[2], pSIP[3],
pSMac[0],pSMac[1],pSMac[2],pSMac[3],pSMac[4],pSMac[5]));
*/
if (isUcastMac && isGoodIP)
IPMacTableUpdate(pMatCfg, pSMac, get_unaligned32((PUINT)pSIP));
/*
For outgoing unicast mac, we need to replace the senderMAC as ourself to make
the receiver can send to us.
*/
if (isUcastMac) {
if (OS_PKT_CLONED(pSkb)) {
OS_PKT_COPY(pSkb, newSkb);
if (newSkb) {
if (IS_VLAN_PACKET(GET_OS_PKT_DATAPTR(newSkb)))
pSMac = (PUCHAR)(GET_OS_PKT_DATAPTR(
newSkb) +
MAT_VLAN_ETH_HDR_LEN +
8);
else
pSMac = (PUCHAR)(GET_OS_PKT_DATAPTR(
newSkb) +
MAT_ETHER_HDR_LEN + 8);
}
}
ASSERT(pMacAddr);
NdisMoveMemory(pSMac, pMacAddr, MAC_ADDR_LEN);
}
return (PUCHAR)newSkb;
}
static NDIS_STATUS MATProto_ARP_Init(IN MAT_STRUCT *pMatCfg)
{
BOOLEAN status = FALSE;
status = IPMacTable_init(pMatCfg);
return status;
}
static NDIS_STATUS MATProto_IP_Exit(IN MAT_STRUCT *pMatCfg)
{
INT status;
status = IPMacTable_RemoveAll(pMatCfg);
return status;
}
static PUCHAR MATProto_IP_Rx(IN MAT_STRUCT *pMatCfg, IN PNDIS_PACKET pSkb,
IN PUCHAR pLayerHdr, IN PUCHAR pDevMacAdr)
{
#ifdef MAC_REPEATER_SUPPORT
PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pMatCfg->pPriv;
USHORT wcid = 0xFF;
PMAC_TABLE_ENTRY pEntry = NULL;
PREPEATER_CLIENT_ENTRY pReptEntry = NULL;
#endif /* MAC_REPEATER_SUPPORT */
PUCHAR pMacAddr;
UINT dstIP = 0;
/* Fetch the IP addres from the packet header. */
getDstIPFromIpPkt(pLayerHdr, &dstIP);
pMacAddr = IPMacTableLookUp(pMatCfg, dstIP);
#ifdef MAC_REPEATER_SUPPORT
if (pAd == NULL) {
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_ERROR,
("%s():ERROR! pAd is null!\n", __func__));
return pMacAddr;
}
wcid = RTMP_GET_PACKET_WCID(pSkb);
pEntry = &pAd->MacTab.Content[wcid];
pReptEntry = &pAd->ApCfg.pRepeaterCliPool[pEntry->MatchReptCliIdx];
if (pAd->ApCfg.bMACRepeaterEn) {
if (pEntry->bReptCli) {
UINT ip;
struct wifi_dev *wdev;
ip = ntohl(dstIP);
wdev = pEntry->wdev;
/* avoid duplicate packet in IGMP case */
if (IS_MULTICAST_IP(ip))
return pReptEntry->OriginalAddress;
}
if (pAd->ApCfg.MACRepeaterOuiMode != CASUALLY_DEFINE_MAC_ADDR) {
if (pEntry->bReptCli) {
/*For UDP packet, we need to check about the DHCP packet. */
if (*(pLayerHdr + 9) == 0x11) {
PUCHAR pUdpHdr;
UINT16 srcPort, dstPort;
BOOLEAN bHdrChanged;
bHdrChanged = FALSE;
pUdpHdr = pLayerHdr + 20;
srcPort = OS_NTOHS(get_unaligned(
(PUINT16)(pUdpHdr)));
dstPort = OS_NTOHS(get_unaligned(
(PUINT16)(pUdpHdr + 2)));
if (srcPort == 67 &&
dstPort ==
68) { /*It's a DHCP packet */
PUCHAR bootpHdr, dhcpHdr,
pCliHwAddr;
bootpHdr = pUdpHdr + 8;
dhcpHdr = bootpHdr + 236;
pCliHwAddr = (bootpHdr + 28);
if (pReptEntry)
NdisMoveMemory(
pCliHwAddr,
pReptEntry
->OriginalAddress,
MAC_ADDR_LEN);
else
MTWF_LOG(
DBG_CAT_PROTO,
CATPROTO_MAT,
DBG_LVL_OFF,
("%s() MatchAPCLITabIdx = %u\n",
__func__,
pEntry->func_tb_idx));
bHdrChanged = TRUE;
}
if (bHdrChanged == TRUE) {
NdisZeroMemory(
(pUdpHdr + 6),
2); /*modify the UDP chksum as zero */
#ifdef DHCP_UC_SUPPORT
*(UINT16 *)(pUdpHdr + 6) =
RTMP_UDP_Checksum(pSkb);
#endif /* DHCP_UC_SUPPORT */
}
}
}
}
}
#endif /* MAC_REPEATER_SUPPORT */
return pMacAddr;
}
static UCHAR DHCP_MAGIC[] = { 0x63, 0x82, 0x53, 0x63 };
static PUCHAR MATProto_IP_Tx(IN MAT_STRUCT *pMatCfg, IN PNDIS_PACKET pSkb,
IN PUCHAR pLayerHdr, IN PUCHAR pDevMacAdr)
{
#if defined(DHCP_UC_SUPPORT) && defined(MAC_REPEATER_SUPPORT)
PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pMatCfg->pPriv;
BOOLEAN use_dhcpbroadcast = TRUE;
#endif /* DHCP_UC_SUPPORT && MAC_REPEATER_SUPPORT */
PUCHAR pSrcMac;
PUCHAR pSrcIP;
BOOLEAN needUpdate;
PUCHAR pPktHdr;
PNDIS_PACKET newSkb = NULL;
pPktHdr = GET_OS_PKT_DATAPTR(pSkb);
pSrcMac = pPktHdr + 6;
pSrcIP = pLayerHdr + 12;
needUpdate =
NEED_UPDATE_IPMAC_TB(pSrcMac, get_unaligned32((PUINT)(pSrcIP)));
if (needUpdate)
IPMacTableUpdate(pMatCfg, pSrcMac,
get_unaligned32((PUINT)(pSrcIP)));
/*For UDP packet, we need to check about the DHCP packet, to modify the flag of DHCP discovey/request as broadcast. */
if (*(pLayerHdr + 9) == 0x11) {
PUCHAR udpHdr;
UINT16 srcPort, dstPort;
BOOLEAN bHdrChanged = FALSE;
udpHdr = pLayerHdr + 20;
srcPort = OS_NTOHS(get_unaligned((PUINT16)(udpHdr)));
dstPort = OS_NTOHS(get_unaligned((PUINT16)(udpHdr + 2)));
if (srcPort == 68 && dstPort == 67) { /*It's a DHCP packet */
PUCHAR bootpHdr;
UINT16 bootpFlag;
PUCHAR dhcpHdr;
if (OS_PKT_CLONED(pSkb)) {
OS_PKT_COPY(pSkb, newSkb);
if (newSkb) {
/* reassign packet header pointer for new skb*/
if (IS_VLAN_PACKET(GET_OS_PKT_DATAPTR(
newSkb))) {
pPktHdr = GET_OS_PKT_DATAPTR(
newSkb);
pLayerHdr =
(pPktHdr +
MAT_VLAN_ETH_HDR_LEN);
udpHdr = pLayerHdr + 20;
} else {
pPktHdr = GET_OS_PKT_DATAPTR(
newSkb);
pLayerHdr = (pPktHdr +
MAT_ETHER_HDR_LEN);
udpHdr = pLayerHdr + 20;
}
}
}
bootpHdr = udpHdr + 8;
bootpFlag = OS_NTOHS(
get_unaligned((PUINT16)(bootpHdr + 10)));
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE,
("is bootp packet! bootpFlag=0x%x\n",
bootpFlag));
dhcpHdr = bootpHdr + 236;
#if defined(DHCP_UC_SUPPORT) && defined(MAC_REPEATER_SUPPORT)
if (pAd->DhcpUcEnable == TRUE) {
if (pMatCfg->bMACRepeaterEn) { /* check repeater case*/
REPEATER_CLIENT_ENTRY *pReptEntry =
NULL;
pReptEntry = RTMPLookupRepeaterCliEntry(
pMatCfg->pPriv, FALSE,
pDevMacAdr, TRUE);
if (pReptEntry != NULL)
use_dhcpbroadcast = FALSE;
}
}
#endif /* DHCP_UC_SUPPORT && MAC_REPEATER_SUPPORT */
#if defined(DHCP_UC_SUPPORT) && defined(MAC_REPEATER_SUPPORT)
if ((bootpFlag != 0x8000) &&
(use_dhcpbroadcast ==
TRUE)) /*check if it's a broadcast request. */
#else
if (bootpFlag !=
0x8000) /*check if it's a broadcast request. */
#endif
{
MTWF_LOG(
DBG_CAT_PROTO, CATPROTO_MAT,
DBG_LVL_TRACE,
("the DHCP flag is a unicast, dhcp_magic=%02x:%02x:%02x:%02x\n",
dhcpHdr[0], dhcpHdr[1], dhcpHdr[2],
dhcpHdr[3]));
if (NdisEqualMemory(dhcpHdr, DHCP_MAGIC, 4)) {
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT,
DBG_LVL_TRACE,
("dhcp magic macthed!\n"));
bootpFlag = OS_HTONS(0x8000);
NdisMoveMemory(
(bootpHdr + 10), &bootpFlag,
2); /*Set the bootp flag as broadcast */
bHdrChanged = TRUE;
}
}
#ifdef MAC_REPEATER_SUPPORT
if (pMatCfg->bMACRepeaterEn) {
REPEATER_CLIENT_ENTRY *pReptEntry = NULL;
pReptEntry = RTMPLookupRepeaterCliEntry(
pMatCfg->pPriv, FALSE, pDevMacAdr,
TRUE);
if (pReptEntry != NULL) {
ASSERT(pReptEntry->CliValid == TRUE);
NdisMoveMemory((bootpHdr + 28),
pDevMacAdr,
MAC_ADDR_LEN);
if (NdisEqualMemory(dhcpHdr, DHCP_MAGIC,
4)) {
PUCHAR pOptCode, pOptLen;
UINT16 udpLen;
udpLen = OS_NTOHS(get_unaligned(
(PUINT16)(udpHdr + 4)));
pOptCode = (dhcpHdr + 4);
do {
pOptLen = pOptCode + 1;
if (*pOptCode ==
61) { /* Client Identifier */
MTWF_LOG(
DBG_CAT_PROTO,
CATPROTO_MAT,
DBG_LVL_TRACE,
("Client Identifier found, change Hardware Address to "
"%02x:%02x:%02x:%02x:%02x:%02x\n",
pDevMacAdr
[0],
pDevMacAdr
[1],
pDevMacAdr
[2],
pDevMacAdr
[3],
pDevMacAdr
[4],
pDevMacAdr
[5]));
/* Change Hardware Address */
NdisMoveMemory(
(pOptCode +
3),
pDevMacAdr,
MAC_ADDR_LEN);
break;
}
pOptCode +=
(2 + *pOptLen);
} while ((*pOptCode != 0xFF) &&
((pOptCode - udpHdr) <=
udpLen));
}
bHdrChanged = TRUE;
}
}
#endif /* MAC_REPEATER_SUPPORT */
}
if (bHdrChanged == TRUE) {
NdisZeroMemory((udpHdr + 6),
2); /* Modify the UDP chksum as zero */
#ifdef DHCP_UC_SUPPORT
*(UINT16 *)(udpHdr + 6) = RTMP_UDP_Checksum(
(newSkb == NULL) ? pSkb : newSkb);
#endif /* DHCP_UC_SUPPORT */
}
}
return (PUCHAR)newSkb;
}
static NDIS_STATUS MATProto_IP_Init(IN MAT_STRUCT *pMatCfg)
{
BOOLEAN status;
status = IPMacTable_init(pMatCfg);
return status;
}
static inline void IPintToIPstr(int ipint, char Ipstr[20], ULONG BufLen)
{
int temp = 0;
temp = ipint & 0x000FF;
snprintf(Ipstr, BufLen, "%d.", temp);
temp = (ipint >> 8) & 0x000FF;
snprintf(Ipstr, BufLen, "%s%d.", Ipstr, temp);
temp = (ipint >> 16) & 0x000FF;
snprintf(Ipstr, BufLen, "%s%d.", Ipstr, temp);
temp = (ipint >> 24) & 0x000FF;
snprintf(Ipstr, BufLen, "%s%d", Ipstr, temp);
}
VOID getIPMacTbInfo(IN MAT_STRUCT *pMatCfg, IN char *pOutBuf, IN ULONG BufLen)
{
IPMacMappingTable *pIPMacTable;
IPMacMappingEntry *pHead;
int startIdx, endIdx;
char Ipstr[20] = { 0 };
pIPMacTable = (IPMacMappingTable *)pMatCfg->MatTableSet.IPMacTable;
if ((!pIPMacTable) || (!pIPMacTable->valid)) {
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE,
("%s():IPMacTable not init yet!\n", __func__));
return;
}
/* dump all. */
startIdx = 0;
endIdx = MAT_MAX_HASH_ENTRY_SUPPORT;
sprintf(pOutBuf, "\n");
sprintf(pOutBuf + strlen(pOutBuf), "%-18s%-20s\n", "IP", "MAC");
for (; startIdx < endIdx; startIdx++) {
pHead = pIPMacTable->hash[startIdx];
while (pHead) {
/* if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30)) */
if (RtmpOsCmdDisplayLenCheck(strlen(pOutBuf), 30) ==
FALSE)
break;
NdisZeroMemory(Ipstr, 20);
IPintToIPstr(pHead->ipAddr, Ipstr, sizeof(Ipstr));
sprintf(pOutBuf + strlen(pOutBuf),
"%-18s%02x:%02x:%02x:%02x:%02x:%02x\n", Ipstr,
pHead->macAddr[0], pHead->macAddr[1],
pHead->macAddr[2], pHead->macAddr[3],
pHead->macAddr[4], pHead->macAddr[5]);
pHead = pHead->pNext;
}
}
}
#endif /* MAT_SUPPORT */

View File

@ -1,833 +0,0 @@
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002-2007, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
***************************************************************************
Module Name:
cmm_mat_ipv6.c
Abstract:
MAT convert engine subroutine for ipv6 base protocols, currently now we
just handle IPv6/ICMPv6 packets without Authentication/Encryption headers.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Shiang 06/03/07 Init version
*/
#ifdef MAT_SUPPORT
#include "rt_config.h"
#include "ipv6.h"
/*#include <asm/checksum.h> */
/*#include <net/ip6_checksum.h> */
const UCHAR IPV6_LOOPBACKADDR[] = { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1 };
static NDIS_STATUS MATProto_IPv6_Init(MAT_STRUCT *pMatCfg);
static NDIS_STATUS MATProto_IPv6_Exit(MAT_STRUCT *pMatCfg);
static PUCHAR MATProto_IPv6_Rx(MAT_STRUCT *pMatCfg, PNDIS_PACKET pSkb,
PUCHAR pLayerHdr, PUCHAR pDevMacAdr);
static PUCHAR MATProto_IPv6_Tx(MAT_STRUCT *pMatCfg, PNDIS_PACKET pSkb,
PUCHAR pLayerHdr, PUCHAR pDevMacAdr);
#define RT_UDP_HDR_LEN 8
typedef struct _IPv6MacMappingEntry {
UCHAR ipv6Addr[16]; /* In network order */
UCHAR macAddr[MAC_ADDR_LEN];
ULONG lastTime;
struct _IPv6MacMappingEntry *pNext;
} IPv6MacMappingEntry, *PIPv6MacMappingEntry;
typedef struct _IPv6MacMappingTable {
BOOLEAN valid;
IPv6MacMappingEntry *hash
[MAT_MAX_HASH_ENTRY_SUPPORT +
1]; /*0~63 for specific station, 64 for broadcast MacAddress */
UCHAR curMcastAddr
[MAC_ADDR_LEN]; /* The multicast mac addr for currecnt received packet destined to ipv6 multicast addr */
} IPv6MacMappingTable;
struct _MATProtoOps MATProtoIPv6Handle = {
.init = MATProto_IPv6_Init,
.tx = MATProto_IPv6_Tx,
.rx = MATProto_IPv6_Rx,
.exit = MATProto_IPv6_Exit,
};
static inline BOOLEAN needUpdateIPv6MacTB(UCHAR *pMac, RT_IPV6_ADDR *pIPv6Addr)
{
ASSERT(pIPv6Addr);
if (isMcastEtherAddr(pMac) || isZeroEtherAddr(pMac))
return FALSE;
/* IPv6 multicast address */
if (IS_MULTICAST_IPV6_ADDR(*pIPv6Addr))
return FALSE;
/* unspecified address */
if (IS_UNSPECIFIED_IPV6_ADDR(*pIPv6Addr))
return FALSE;
/* loopback address */
if (IS_LOOPBACK_IPV6_ADDR(*pIPv6Addr))
return FALSE;
return TRUE;
}
/*
IPv6 Header Format
0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Traffic Class | Flow Label |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Payload Length | Next Header | Hop Limit |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| Source Address |
+ +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| Destination Address |
+ +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
ICMPv6 Format:
|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Code | Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message Body |
+ +
| |
......
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
NDIS_STATUS dumpIPv6MacTb(IN MAT_STRUCT *pMatCfg, IN int index)
{
IPv6MacMappingTable *pIPv6MacTable;
IPv6MacMappingEntry *pHead;
int startIdx, endIdx;
pIPv6MacTable =
(IPv6MacMappingTable *)pMatCfg->MatTableSet.IPv6MacTable;
if ((!pIPv6MacTable) || (!pIPv6MacTable->valid)) {
MTWF_LOG(
DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("%s():IPv6MacTable not init yet, so cannot do dump!\n",
__func__));
return FALSE;
}
if (index < 0) {
/* dump all. */
startIdx = 0;
endIdx = MAT_MAX_HASH_ENTRY_SUPPORT;
} else {
/* dump specific hash index. */
startIdx = endIdx = index;
}
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("%s():\n", __func__));
for (; startIdx <= endIdx; startIdx++) {
pHead = pIPv6MacTable->hash[startIdx];
while (pHead) {
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("IPv6Mac[%d]:\n", startIdx));
MTWF_LOG(
DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("\t:IPv6=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x,Mac=%02x:%02x:%02x:%02x:%02x:%02x, lastTime=0x%lx, next=%p\n",
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[0]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[1]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[2]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[3]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[4]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[5]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[6]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[7]),
pHead->macAddr[0], pHead->macAddr[1],
pHead->macAddr[2], pHead->macAddr[3],
pHead->macAddr[4], pHead->macAddr[5],
pHead->lastTime, pHead->pNext));
pHead = pHead->pNext;
}
}
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_OFF,
("\t----EndOfDump!\n"));
return TRUE;
}
static NDIS_STATUS IPv6MacTableUpdate(IN MAT_STRUCT *pMatCfg,
IN PUCHAR pMacAddr, IN PCHAR pIPv6Addr)
{
UINT hashIdx;
IPv6MacMappingTable *pIPv6MacTable;
IPv6MacMappingEntry *pEntry = NULL, *pPrev = NULL, *pNewEntry = NULL,
*pTempEntry = NULL;
ULONG now;
pIPv6MacTable =
(IPv6MacMappingTable *)pMatCfg->MatTableSet.IPv6MacTable;
if ((!pIPv6MacTable) || (!pIPv6MacTable->valid))
return FALSE;
hashIdx = MAT_IPV6_ADDR_HASH_INDEX(pIPv6Addr);
pEntry = pPrev = pIPv6MacTable->hash[hashIdx];
while (pEntry) {
NdisGetSystemUpTime(&now);
/* Find a existed IP-MAC Mapping entry */
if (NdisEqualMemory(pIPv6Addr, pEntry->ipv6Addr,
IPV6_ADDR_LEN)) {
/* comparison is useless. So we directly copy it into the entry. */
NdisMoveMemory(pEntry->macAddr, pMacAddr, 6);
NdisGetSystemUpTime(&pEntry->lastTime);
return TRUE;
} else {
/* handle the aging-out situation */
if (RTMP_TIME_AFTER(now, (pEntry->lastTime +
MAT_TB_ENTRY_AGEOUT_TIME))) {
/* Remove the aged entry */
if (pEntry == pIPv6MacTable->hash[hashIdx]) {
pIPv6MacTable->hash[hashIdx] =
pEntry->pNext;
pPrev = pIPv6MacTable->hash[hashIdx];
} else
pPrev->pNext = pEntry->pNext;
pTempEntry = pEntry;
pEntry = (pPrev == NULL ? NULL : pPrev->pNext);
MATDBEntryFree(pMatCfg, (PUCHAR)pTempEntry);
pMatCfg->nodeCount--;
} else {
pPrev = pEntry;
pEntry = pEntry->pNext;
}
}
}
/* Allocate a new IPv6MacMapping entry and insert into the hash */
pNewEntry = (IPv6MacMappingEntry *)MATDBEntryAlloc(
pMatCfg, sizeof(IPv6MacMappingEntry));
if (pNewEntry != NULL) {
NdisMoveMemory(pNewEntry->ipv6Addr, pIPv6Addr, IPV6_ADDR_LEN);
NdisMoveMemory(pNewEntry->macAddr, pMacAddr, 6);
pNewEntry->pNext = NULL;
NdisGetSystemUpTime(&pNewEntry->lastTime);
if (pIPv6MacTable->hash[hashIdx] == NULL) {
/* Hash list is empty, directly assign it. */
pIPv6MacTable->hash[hashIdx] = pNewEntry;
} else {
/* Ok, we insert the new entry into the root of hash[hashIdx] */
pNewEntry->pNext = pIPv6MacTable->hash[hashIdx];
pIPv6MacTable->hash[hashIdx] = pNewEntry;
}
/*dumpIPv6MacTb(pMatCfg, hashIdx); //for debug */
pMatCfg->nodeCount++;
return TRUE;
}
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_ERROR,
("IPv6MacTableUpdate():Insertion failed!\n"));
return FALSE;
}
static PUCHAR IPv6MacTableLookUp(IN MAT_STRUCT *pMatCfg, IN PUCHAR pIPv6Addr)
{
UINT hashIdx;
IPv6MacMappingTable *pIPv6MacTable;
IPv6MacMappingEntry *pEntry = NULL;
PUCHAR pGroupMacAddr;
pIPv6MacTable =
(IPv6MacMappingTable *)pMatCfg->MatTableSet.IPv6MacTable;
if ((!pIPv6MacTable) || (!pIPv6MacTable->valid))
return NULL;
/*if IPV6 multicast address, need converting multicast group address to ethernet address. */
if (IS_MULTICAST_IPV6_ADDR(*(RT_IPV6_ADDR *)pIPv6Addr)) {
pGroupMacAddr = (PUCHAR)&pIPv6MacTable->curMcastAddr;
ConvertMulticastIP2MAC(pIPv6Addr, (UCHAR **)(&pGroupMacAddr),
ETH_P_IPV6);
return pIPv6MacTable->curMcastAddr;
}
/* Use hash to find out the location of that entry and get the Mac address. */
hashIdx = MAT_IPV6_ADDR_HASH_INDEX(pIPv6Addr);
/* spin_lock_irqsave(&IPMacTabLock, irqFlag); */
pEntry = pIPv6MacTable->hash[hashIdx];
while (pEntry) {
if (NdisEqualMemory(pEntry->ipv6Addr, pIPv6Addr,
IPV6_ADDR_LEN)) {
/*Update the lastTime to prevent the aging before pDA processed! */
NdisGetSystemUpTime(&pEntry->lastTime);
return pEntry->macAddr;
} else
pEntry = pEntry->pNext;
}
/*
We didn't find any matched Mac address, our policy is treat it as
broadcast packet and send to all.
*/
return pIPv6MacTable->hash[IPV6MAC_TB_HASH_INDEX_OF_BCAST]->macAddr;
}
static inline unsigned short int icmpv6_csum(RT_IPV6_ADDR *saddr,
RT_IPV6_ADDR *daddr, USHORT len,
UCHAR proto, UCHAR *pICMPMsg)
{
int carry;
UINT32 ulen;
UINT32 uproto;
int i;
unsigned int csum = 0;
unsigned short int chksum;
if (len % 4)
return 0;
for (i = 0; i < 4; i++) {
csum += saddr->ipv6_addr32[i];
carry = (csum < saddr->ipv6_addr32[i]);
csum += carry;
}
for (i = 0; i < 4; i++) {
csum += daddr->ipv6_addr32[i];
carry = (csum < daddr->ipv6_addr32[i]);
csum += carry;
}
ulen = OS_HTONL((UINT32)len);
csum += ulen;
carry = (csum < ulen);
csum += carry;
uproto = OS_HTONL((UINT32)proto);
csum += uproto;
carry = (csum < uproto);
csum += carry;
for (i = 0; i < len; i += 4) {
csum += get_unaligned32(((UINT32 *)&pICMPMsg[i]));
carry = (csum < get_unaligned32(((UINT32 *)&pICMPMsg[i])));
csum += carry;
}
while (csum >> 16)
csum = (csum & 0xffff) + (csum >> 16);
chksum = ~csum;
return chksum;
}
static PUCHAR MATProto_IPv6_Rx(IN MAT_STRUCT *pMatCfg, IN PNDIS_PACKET pSkb,
IN PUCHAR pLayerHdr, IN PUCHAR pDevMacAdr)
{
PUCHAR pMacAddr;
PUCHAR pDstIPv6Addr;
/* Fetch the IPv6 addres from the packet header. */
pDstIPv6Addr = (UCHAR *)(&((RT_IPV6_HDR *)pLayerHdr)->dstAddr);
pMacAddr = IPv6MacTableLookUp(pMatCfg, pDstIPv6Addr);
return pMacAddr;
}
static PNDIS_PACKET ICMPv6_Handle_Tx(IN MAT_STRUCT *pMatSrtuct,
IN PNDIS_PACKET pSkb, IN PUCHAR pLayerHdr,
IN PUCHAR pDevMacAdr, IN UINT32 offset)
{
RT_IPV6_HDR *pIPv6Hdr;
RT_ICMPV6_HDR *pICMPv6Hdr;
RT_ICMPV6_OPTION_HDR *pOptHdr;
USHORT payloadLen;
UINT32 ICMPOffset = 0, ICMPMsgLen = 0;
INT32 leftLen;
PNDIS_PACKET newSkb = NULL;
BOOLEAN needModify = FALSE;
PUCHAR pSrcMac;
pIPv6Hdr = (RT_IPV6_HDR *)pLayerHdr;
payloadLen = OS_NTOHS(pIPv6Hdr->payload_len);
pICMPv6Hdr = (RT_ICMPV6_HDR *)(pLayerHdr + offset);
ICMPOffset = offset;
ICMPMsgLen = payloadLen + IPV6_HDR_LEN - ICMPOffset;
leftLen = ICMPMsgLen;
switch (pICMPv6Hdr->type) {
case ICMPV6_MSG_TYPE_ROUTER_SOLICITATION:
offset += ROUTER_SOLICITATION_FIXED_LEN;
leftLen -= ROUTER_SOLICITATION_FIXED_LEN;
/* for unspecified source address, it should not include the option about link-layer address. */
if (!(IS_UNSPECIFIED_IPV6_ADDR(pIPv6Hdr->srcAddr)) &&
(ICMPMsgLen > ROUTER_SOLICITATION_FIXED_LEN)) {
while (leftLen > sizeof(RT_ICMPV6_OPTION_HDR)) {
pOptHdr = (RT_ICMPV6_OPTION_HDR *)(pLayerHdr +
offset);
if (pOptHdr->len == 0)
break; /* discard it, because it's invalid. */
if (pOptHdr->type == TYPE_SRC_LL_ADDR) {
/*replace the src link-layer address as ours. */
needModify = TRUE;
offset +=
2; /* 2 = "type, len" fields. Here indicate to the place of src mac. */
break;
} else {
offset +=
(pOptHdr->len *
8); /* in unit of 8 octets. */
leftLen -= (pOptHdr->len * 8);
}
}
}
break;
case ICMPV6_MSG_TYPE_ROUTER_ADVERTISEMENT:
offset += ROUTER_ADVERTISEMENT_FIXED_LEN;
leftLen -= ROUTER_ADVERTISEMENT_FIXED_LEN;
/* for unspecified source address, it should not include the option about link-layer address. */
if (!(IS_UNSPECIFIED_IPV6_ADDR(pIPv6Hdr->srcAddr)) &&
(ICMPMsgLen > ROUTER_ADVERTISEMENT_FIXED_LEN)) {
while (leftLen > sizeof(RT_ICMPV6_OPTION_HDR)) {
pOptHdr = (RT_ICMPV6_OPTION_HDR *)(pLayerHdr +
offset);
if (pOptHdr->len == 0)
break; /* discard it, because it's invalid. */
if (pOptHdr->type == TYPE_SRC_LL_ADDR) {
/*replace the src link-layer address as ours. */
needModify = TRUE;
offset +=
2; /* 2 = "type, len" fields. Here indicate to the place of src mac. */
break;
} else {
offset +=
(pOptHdr->len *
8); /* in unit of 8 octets. */
leftLen -= (pOptHdr->len * 8);
}
}
}
break;
case ICMPV6_MSG_TYPE_NEIGHBOR_SOLICITATION:
offset += NEIGHBOR_SOLICITATION_FIXED_LEN;
leftLen -= NEIGHBOR_SOLICITATION_FIXED_LEN;
/* for unspecified source address, it should not include the option about link-layer address. */
if (!(IS_UNSPECIFIED_IPV6_ADDR(pIPv6Hdr->srcAddr)) &&
(ICMPMsgLen > NEIGHBOR_SOLICITATION_FIXED_LEN)) {
while (leftLen > sizeof(RT_ICMPV6_OPTION_HDR)) {
pOptHdr = (RT_ICMPV6_OPTION_HDR *)(pLayerHdr +
offset);
if (pOptHdr->len == 0)
break; /* discard it, because it's invalid. */
if (pOptHdr->type == TYPE_SRC_LL_ADDR) {
/*replace the src link-layer address as ours. */
needModify = TRUE;
offset +=
2; /* 2 = "type, len" fields. Here indicate to the place of src mac. */
break;
} else {
offset +=
(pOptHdr->len *
8); /* in unit of 8 octets. */
leftLen -= (pOptHdr->len * 8);
}
}
}
break;
case ICMPV6_MSG_TYPE_NEIGHBOR_ADVERTISEMENT:
offset += NEIGHBOR_ADVERTISEMENT_FIXED_LEN;
leftLen -= NEIGHBOR_ADVERTISEMENT_FIXED_LEN;
/* for unspecified source address, it should not include the option about link-layer address. */
if (!(IS_UNSPECIFIED_IPV6_ADDR(pIPv6Hdr->srcAddr)) &&
(ICMPMsgLen > NEIGHBOR_ADVERTISEMENT_FIXED_LEN)) {
while (leftLen > sizeof(RT_ICMPV6_OPTION_HDR)) {
pOptHdr = (RT_ICMPV6_OPTION_HDR *)(pLayerHdr +
offset);
if (pOptHdr->len == 0)
break; /* discard it, because it's invalid. */
if (pOptHdr->type == TYPE_TGT_LL_ADDR) {
/*replace the src link-layer address as ours. */
needModify = TRUE;
offset +=
2; /* 2 = "type, len" fields. */
break;
} else {
offset +=
(pOptHdr->len *
8); /* in unit of 8 octets. */
leftLen -= (pOptHdr->len * 8);
}
}
}
break;
case ICMPV6_MSG_TYPE_REDIRECT:
offset += REDIRECT_FIXED_LEN;
leftLen -= REDIRECT_FIXED_LEN;
/* for unspecified source address, it should not include the options about link-layer address. */
if (!(IS_UNSPECIFIED_IPV6_ADDR(pIPv6Hdr->srcAddr)) &&
(ICMPMsgLen > REDIRECT_FIXED_LEN)) {
while (leftLen > sizeof(RT_ICMPV6_OPTION_HDR)) {
pOptHdr = (RT_ICMPV6_OPTION_HDR *)(pLayerHdr +
offset);
if (pOptHdr->len == 0)
break; /* discard it, because it's invalid. */
if (pOptHdr->type == TYPE_TGT_LL_ADDR) {
/* TODO: Need to check if the TGT_LL_ADDR is the inner MAC. */
/*replace the src link-layer address as ours. */
needModify = TRUE;
offset +=
2; /* 2 = "type, len" fields. */
break;
} else {
offset +=
(pOptHdr->len *
8); /* in unit of 8 octets. */
leftLen -= (pOptHdr->len * 8);
}
}
}
break;
default:
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE,
("Un-supported ICMPv6 msg type(0x%x)! Ignore it\n",
pICMPv6Hdr->type));
break;
}
/* We need to handle about the solicitation/Advertisement packets. */
if (needModify) {
if (OS_PKT_CLONED(pSkb)) {
OS_PKT_COPY(RTPKT_TO_OSPKT(pSkb), newSkb);
if (newSkb) {
if (IS_VLAN_PACKET(GET_OS_PKT_DATAPTR(newSkb)))
pIPv6Hdr =
(RT_IPV6_HDR
*)(GET_OS_PKT_DATAPTR(
newSkb) +
MAT_VLAN_ETH_HDR_LEN);
else
pIPv6Hdr =
(RT_IPV6_HDR
*)(GET_OS_PKT_DATAPTR(
newSkb) +
MAT_ETHER_HDR_LEN);
}
}
pICMPv6Hdr = (RT_ICMPV6_HDR *)((PUCHAR)pIPv6Hdr + ICMPOffset);
pSrcMac = (PUCHAR)((PUCHAR)pIPv6Hdr + offset);
NdisMoveMemory(pSrcMac, pDevMacAdr, MAC_ADDR_LEN);
/* Now re-calculate the Checksum. */
pICMPv6Hdr->chksum = 0;
pICMPv6Hdr->chksum =
icmpv6_csum(&pIPv6Hdr->srcAddr, &pIPv6Hdr->dstAddr,
ICMPMsgLen, IPV6_NEXT_HEADER_ICMPV6,
(PUCHAR)pICMPv6Hdr);
}
return newSkb;
}
static PUCHAR MATProto_IPv6_Tx(IN MAT_STRUCT *pMatCfg, IN PNDIS_PACKET pSkb,
IN PUCHAR pLayerHdr, IN PUCHAR pDevMacAdr)
{
PUCHAR pSrcMac, pSrcIP;
BOOLEAN needUpdate;
UCHAR nextProtocol;
UINT32 offset;
HEADER_802_3 *pEthHdr;
RT_IPV6_HDR *pIPv6Hdr;
PNDIS_PACKET newSkb = NULL;
pIPv6Hdr = (RT_IPV6_HDR *)pLayerHdr;
pEthHdr = (HEADER_802_3 *)(GET_OS_PKT_DATAPTR(pSkb));
pSrcMac = (UCHAR *)&pEthHdr->SAAddr2;
pSrcIP = (UCHAR *)&pIPv6Hdr->srcAddr;
needUpdate = needUpdateIPv6MacTB(pSrcMac,
(RT_IPV6_ADDR *)(&pIPv6Hdr->srcAddr));
if (needUpdate)
IPv6MacTableUpdate(pMatCfg, pSrcMac,
(CHAR *)(&pIPv6Hdr->srcAddr));
/* We need to traverse the whole IPv6 Header and extend headers to check about the ICMPv6 pacekt. */
nextProtocol = pIPv6Hdr->nextHdr;
offset = IPV6_HDR_LEN;
/*MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_INFO, ("NextProtocol=0x%x! payloadLen=%d! offset=%d!\n", nextProtocol, payloadLen, offset)); */
while (nextProtocol != IPV6_NEXT_HEADER_ICMPV6 &&
nextProtocol != IPV6_NEXT_HEADER_UDP &&
nextProtocol != IPV6_NEXT_HEADER_TCP &&
nextProtocol != IPV6_NEXT_HEADER_NONE) {
if (IPv6ExtHdrHandle((RT_IPV6_EXT_HDR *)(pLayerHdr + offset),
&nextProtocol, &offset) == FALSE) {
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE,
("IPv6ExtHdrHandle failed!\n"));
break;
}
}
switch (nextProtocol) {
case IPV6_NEXT_HEADER_ICMPV6:
newSkb = ICMPv6_Handle_Tx(pMatCfg, pSkb, pLayerHdr, pDevMacAdr,
offset);
break;
case IPV6_NEXT_HEADER_UDP:
/*newSkb = DHCPv6_Handle_Tx(pMatStrcut, pSkb, pLayerHdr, pMacAddr, offset); */
break;
case IPV6_NEXT_HEADER_TCP:
case IPV6_NEXT_HEADER_NONE:
default:
break;
}
return (PUCHAR)newSkb;
}
static NDIS_STATUS IPv6MacTable_RemoveAll(IN MAT_STRUCT *pMatCfg)
{
IPv6MacMappingTable *pIPv6MacTable;
IPv6MacMappingEntry *pEntry;
UINT32 i;
pIPv6MacTable =
(IPv6MacMappingTable *)pMatCfg->MatTableSet.IPv6MacTable;
if (!pIPv6MacTable)
return TRUE;
if (pIPv6MacTable->valid) {
pIPv6MacTable->valid = FALSE;
for (i = 0; i < IPV6MAC_TB_HASH_ENTRY_NUM; i++) {
while ((pEntry = pIPv6MacTable->hash[i]) != NULL) {
pIPv6MacTable->hash[i] = pEntry->pNext;
MATDBEntryFree(pMatCfg, (PUCHAR)pEntry);
}
}
}
os_free_mem(pIPv6MacTable);
pMatCfg->MatTableSet.IPv6MacTable = NULL;
return TRUE;
}
static NDIS_STATUS IPv6MacTable_init(IN MAT_STRUCT *pMatCfg)
{
IPv6MacMappingEntry *pEntry = NULL;
IPv6MacMappingTable *pIPv6MacTable;
if (pMatCfg->MatTableSet.IPv6MacTable != NULL)
pIPv6MacTable = (IPv6MacMappingTable *)
pMatCfg->MatTableSet.IPv6MacTable;
else {
os_alloc_mem_suspend(
NULL, (UCHAR **)&(pMatCfg->MatTableSet.IPv6MacTable),
sizeof(IPv6MacMappingTable));
if (pMatCfg->MatTableSet.IPv6MacTable) {
pIPv6MacTable =
(IPv6MacMappingTable *)
pMatCfg->MatTableSet.IPv6MacTable;
NdisZeroMemory(pIPv6MacTable,
sizeof(IPv6MacMappingTable));
} else {
MTWF_LOG(
DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_ERROR,
("IPMacTable_init(): Allocate memory for IPv6MacTable failed!\n"));
return FALSE;
}
}
if (pIPv6MacTable->valid == FALSE) {
/*Set the last hash entry (hash[64]) as our default broadcast Mac address */
pEntry = (IPv6MacMappingEntry *)MATDBEntryAlloc(
pMatCfg, sizeof(IPv6MacMappingEntry));
if (!pEntry) {
MTWF_LOG(
DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_ERROR,
("IPMacTable_init(): Allocate memory for IPMacTable broadcast entry failed!\n"));
return FALSE;
}
NdisZeroMemory(pEntry, sizeof(IPv6MacMappingEntry));
NdisMoveMemory(pEntry->macAddr, BROADCAST_ADDR, MAC_ADDR_LEN);
pEntry->pNext = NULL;
pIPv6MacTable->hash[IPV6MAC_TB_HASH_INDEX_OF_BCAST] = pEntry;
pIPv6MacTable->valid = TRUE;
} else
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE,
("%s(): IPv6MacTable already inited!\n", __func__));
return TRUE;
}
static NDIS_STATUS MATProto_IPv6_Exit(IN MAT_STRUCT *pMatCfg)
{
INT status;
status = IPv6MacTable_RemoveAll(pMatCfg);
return status;
}
static NDIS_STATUS MATProto_IPv6_Init(IN MAT_STRUCT *pMatCfg)
{
BOOLEAN status = FALSE;
status = IPv6MacTable_init(pMatCfg);
return status;
}
VOID getIPv6MacTbInfo(IN MAT_STRUCT *pMatCfg, IN char *pOutBuf, IN ULONG BufLen)
{
IPv6MacMappingTable *pIPv6MacTable;
IPv6MacMappingEntry *pHead;
int startIdx, endIdx;
char Ipv6str[40] = { 0 };
pIPv6MacTable =
(IPv6MacMappingTable *)pMatCfg->MatTableSet.IPv6MacTable;
if ((!pIPv6MacTable) || (!pIPv6MacTable->valid)) {
MTWF_LOG(DBG_CAT_PROTO, CATPROTO_MAT, DBG_LVL_TRACE,
("%s():IPv6MacTable not init yet!\n", __func__));
return;
}
/* dump all. */
startIdx = 0;
endIdx = MAT_MAX_HASH_ENTRY_SUPPORT;
sprintf(pOutBuf, "\n");
sprintf(pOutBuf + strlen(pOutBuf), "%-40s%-20s\n", "IP", "MAC");
for (; startIdx < endIdx; startIdx++) {
pHead = pIPv6MacTable->hash[startIdx];
while (pHead) {
/* if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30)) */
if (RtmpOsCmdDisplayLenCheck(strlen(pOutBuf), 30) ==
FALSE)
break;
NdisZeroMemory(Ipv6str, 40);
sprintf(Ipv6str,
"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[0]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[1]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[2]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[3]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[4]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[5]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[6]),
OS_NTOHS((*((RT_IPV6_ADDR
*)(&pHead->ipv6Addr[0])))
.ipv6_addr16[7]));
sprintf(pOutBuf + strlen(pOutBuf),
"%-40s%02x:%02x:%02x:%02x:%02x:%02x\n", Ipv6str,
pHead->macAddr[0], pHead->macAddr[1],
pHead->macAddr[2], pHead->macAddr[3],
pHead->macAddr[4], pHead->macAddr[5]);
pHead = pHead->pNext;
}
}
}
#endif /* MAT_SUPPORT */

View File

@ -1,232 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 MediaTek Inc.
*
* All rights reserved. Copying, compilation, modification, distribution
* or any other use whatsoever of this material is strictly prohibited
* except in accordance with a Software License Agreement with
* MediaTek Inc.
* ******************************************************************************
*/
/******************************************************************************
* LEGAL DISCLAIMER
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
* AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
* SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
* PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
* DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
* ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
* WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
* SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
* WARRANTY CLAIM RELATING THERetO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
* FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
* CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
* BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
* ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
* BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
* OF LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
* THEREOF AND RELATED THERetO SHALL BE SETTLED BY ARBITRATION IN SAN
* FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
* (ICC).
* ******************************************************************************
*/
#include "rt_config.h"
#ifdef CFG_SUPPORT_MU_MIMO
enum {
/* debug commands */
MU_SET_STA_PARAM = 50,
MU_GET_STA_PARAM,
/* HQA STA commands */
MU_HQA_SET_STA_PARAM = 60,
MU_HQA_GET_STA_PARAM,
};
enum {
MU_EVENT_MU_STA_PARAM = 50,
MU_EVENT_HQA_GET_MU_STA_PARAM = 60,
};
typedef struct _CMD_MU_SET_STA_PARAM {
UINT32 gid[2];
UINT32 up[4];
} CMD_MU_SET_STA_PARAM, *P_CMD_MU_SET_STA_PARAM;
typedef struct _CMD_HQA_SET_MU_STA_PARAM {
MU_STRUCT_MU_STA_PARAM param;
} CMD_HQA_SET_MU_STA_PARAM, *P_CMD_HQA_SET_MU_STA_PARAM;
INT SetMuStaParamProc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
INT32 Ret = TRUE;
/* prepare command message */
struct cmd_msg *msg = NULL;
PCHAR pLowGidUserMemberStatus = NULL;
PCHAR pHighGidUserMemberStatus = NULL;
PCHAR pLowGidUserPosition0 = NULL;
PCHAR pLowGidUserPosition1 = NULL;
PCHAR pHighGidUserPosition0 = NULL;
PCHAR pHighGidUserPosition1 = NULL;
PUINT8 pch = NULL;
struct _CMD_ATTRIBUTE attr = { 0 };
CMD_MU_SET_STA_PARAM param = { { 0 }, { 0 } };
UINT32 cmd = MU_SET_STA_PARAM;
pch = strsep(&arg, "_");
if (pch != NULL)
pLowGidUserMemberStatus = pch;
else {
Ret = 0;
goto error;
}
pch = strsep(&arg, "_");
if (pch != NULL)
pHighGidUserMemberStatus = pch;
else {
Ret = 0;
goto error;
}
pch = strsep(&arg, "_");
if (pch != NULL)
pLowGidUserPosition0 = pch;
else {
Ret = 0;
goto error;
}
pch = strsep(&arg, "_");
if (pch != NULL)
pLowGidUserPosition1 = pch;
else {
Ret = 0;
goto error;
}
pch = strsep(&arg, "_");
if (pch != NULL)
pHighGidUserPosition0 = pch;
else {
Ret = 0;
goto error;
}
pch = strsep(&arg, "");
if (pch != NULL)
pHighGidUserPosition1 = pch;
else {
Ret = 0;
goto error;
}
/* To we need change edian? */
param.gid[0] = os_str_tol(pLowGidUserMemberStatus, 0, 16);
param.gid[1] = os_str_tol(pHighGidUserMemberStatus, 0, 16);
param.up[0] = os_str_tol(pLowGidUserPosition0, 0, 16);
param.up[1] = os_str_tol(pLowGidUserPosition1, 0, 16);
param.up[2] = os_str_tol(pHighGidUserPosition0, 0, 16);
param.up[3] = os_str_tol(pHighGidUserPosition1, 0, 16);
param.gid[0] = cpu2le32(param.gid[0]);
param.gid[1] = cpu2le32(param.gid[1]);
param.up[0] = cpu2le32(param.up[0]);
param.up[1] = cpu2le32(param.up[1]);
param.up[2] = cpu2le32(param.up[2]);
param.up[3] = cpu2le32(param.up[3]);
/* Allocate memory for msg */
msg = AndesAllocCmdMsg(pAd, sizeof(cmd) + sizeof(CMD_MU_SET_STA_PARAM));
if (!msg) {
Ret = 0;
goto error;
}
SET_CMD_ATTR_MCU_DEST(attr, HOST2N9);
SET_CMD_ATTR_TYPE(attr, EXT_CID);
SET_CMD_ATTR_EXT_TYPE(attr, EXT_CMD_ID_MU_MIMO);
SET_CMD_ATTR_CTRL_FLAGS(attr, INIT_CMD_SET_AND_RETRY);
SET_CMD_ATTR_RSP_WAIT_MS_TIME(attr, 0);
SET_CMD_ATTR_RSP_EXPECT_SIZE(attr, 0);
SET_CMD_ATTR_RSP_WB_BUF_IN_CALBK(attr, NULL);
SET_CMD_ATTR_RSP_HANDLER(attr, NULL);
AndesInitCmdMsg(msg, attr);
#ifdef RT_BIG_ENDIAN
cmd = cpu2le32(cmd);
#endif
AndesAppendCmdMsg(msg, (char *)&cmd, sizeof(cmd));
AndesAppendCmdMsg(msg, (char *)&param, sizeof(CMD_MU_SET_STA_PARAM));
AndesSendCmdMsg(pAd, msg);
error:
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s:(Ret = %d_\n", __func__, Ret));
return Ret;
}
bool hqa_wifi_test_mu_set_sta_gid_and_up(PRTMP_ADAPTER pAd,
P_MU_STRUCT_MU_STA_PARAM ptr)
{
INT Ret = 0;
struct cmd_msg *msg = NULL;
UINT32 cmd = MU_HQA_SET_STA_PARAM;
CMD_HQA_SET_MU_STA_PARAM param;
struct _CMD_ATTRIBUTE attr = { 0 };
msg = AndesAllocCmdMsg(pAd, sizeof(cmd) + sizeof(param));
if (!msg) {
Ret = -1;
goto error;
}
NdisCopyMemory(&param.param, ptr, sizeof(MU_STRUCT_MU_STA_PARAM));
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s: MU_STRUCT_MU_STA_PARAM\n", __func__));
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("gid[0] = %u\n", param.param.gid[0]));
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("gid[1] = %u\n", param.param.gid[1]));
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("up[0] = %u\n", param.param.up[0]));
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("up[1] = %u\n", param.param.up[1]));
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("up[2] = %u\n", param.param.up[2]));
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("up[3] = %u\n", param.param.up[3]));
SET_CMD_ATTR_MCU_DEST(attr, HOST2N9);
SET_CMD_ATTR_TYPE(attr, EXT_CID);
SET_CMD_ATTR_EXT_TYPE(attr, EXT_CMD_ID_MU_MIMO);
SET_CMD_ATTR_CTRL_FLAGS(attr, INIT_CMD_SET_AND_RETRY);
SET_CMD_ATTR_RSP_WAIT_MS_TIME(attr, 0);
SET_CMD_ATTR_RSP_EXPECT_SIZE(attr, 0);
SET_CMD_ATTR_RSP_WB_BUF_IN_CALBK(attr, NULL);
SET_CMD_ATTR_RSP_HANDLER(attr, NULL);
AndesInitCmdMsg(msg, attr);
#ifdef RT_BIG_ENDIAN
cmd = cpu2le32(cmd);
RTMPEndianChange((UCHAR *)&param.param, sizeof(MU_STRUCT_MU_STA_PARAM));
#endif
AndesAppendCmdMsg(msg, (char *)&cmd, sizeof(cmd));
AndesAppendCmdMsg(msg, (char *)&param, sizeof(param));
AndesSendCmdMsg(pAd, msg);
error:
MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("%s:(Ret = %d_\n", __func__, Ret));
return Ret;
}
#endif

View File

@ -1,862 +0,0 @@
/*
***************************************************************************
* MediaTek Inc.
*
* All rights reserved. source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of MediaTek. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of MediaTek, Inc. is obtained.
***************************************************************************
Module Name:
cmm_rvr_dbg.c
*/
#include "rt_config.h"
#define MSG_LEN 2048
static const RTMP_STRING *hex_RTMP_STRING = "0123456789abcdefABCDEF";
static const RTMP_STRING *dec_RTMP_STRING = "0123456789";
static struct {
RTMP_STRING *name;
INT(*rd_proc)
(RTMP_ADAPTER *pAd, RTMP_STRING *arg, RTMP_IOCTL_INPUT_STRUCT *wrq);
} * PRTMP_PRIVATE_RD_PROC,
RTMP_PRIVATE_RD_SUPPORT_PROC[] = { { "view", rd_view },
{ "view+", rd_view_plus },
{ "view-", rd_view_minus },
/*Alias */
{ "wcid", rd_wcid },
{ "sta", rd_wcid },
{ "apcli", rd_wcid },
{ "ap", rd_wcid },
{ "reset", rd_reset },
{ "help", rd_help },
{
NULL,
} };
static struct {
RTMP_STRING *key;
RTMP_STRING *str;
INT val;
} * PView_Key_Node,
View_Key_Node_List[] = { { "basic", "VIEW_BASICINFO", VIEW_BASICINFO },
{ "wcid", "VIEW_WCID", VIEW_WCID },
{ "mac", "VIEW_MACCOUNTER", VIEW_MACCOUNTER },
{ "phy", "VIEW_PHYCOUNTER", VIEW_PHYCOUNTER },
{ "noise", "VIEW_NOISE", VIEW_NOISE },
{ "cn", "VIEW_CNNUMBER", VIEW_CNNUMBER },
{ "others", "VIEW_OTHERS", VIEW_OTHERS },
{
NULL,
NULL,
} };
VOID RTMPIoctlRvRDebug_Init(RTMP_ADAPTER *pAd)
{
pAd->RVRDBGCtrl.ucViewLevel = VIEW_BASICINFO | VIEW_MACCOUNTER |
VIEW_PHYCOUNTER |
VIEW_WCID; /*Default View Info */
pAd->RVRDBGCtrl.ucWcid = 0;
pAd->RVRDBGCtrl.ucCNcnt = 0xFF;
}
INT RTMPIoctlRvRDebug(RTMP_ADAPTER *pAd, RTMP_IOCTL_INPUT_STRUCT *wrq)
{
RTMP_STRING *this_char, *value = NULL;
INT Status = NDIS_STATUS_SUCCESS;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s----------------->\n", __func__));
this_char = wrq->u.data.pointer;
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s(): Before check, this_char = %s\n", __func__, this_char));
value = strchr(this_char, '=');
if (value) {
if (strlen(value) > 1) {
*value++ = 0;
} else {
*value = 0;
value = NULL;
}
}
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s(): After check, this_char = %s, value = %s\n", __func__,
this_char, (value == NULL ? "" : value)));
for (PRTMP_PRIVATE_RD_PROC = RTMP_PRIVATE_RD_SUPPORT_PROC;
PRTMP_PRIVATE_RD_PROC->name; PRTMP_PRIVATE_RD_PROC++) {
if (!strcmp(this_char, PRTMP_PRIVATE_RD_PROC->name)) {
if (!PRTMP_PRIVATE_RD_PROC->rd_proc(pAd, value, wrq)) {
/*FALSE:Set private failed then return Invalid argument */
Status = -EINVAL;
}
break; /*Exit for loop. */
}
}
if (PRTMP_PRIVATE_RD_PROC->name == NULL) {
/*Not found argument */
MTWF_LOG(DBG_CAT_AP, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("PRTMP_PRIVATE_RD_PROC->name == NULL"));
rd_dashboard(pAd, wrq);
return Status;
}
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s<-----------------\n", __func__));
return Status;
}
INT rd_dashboard(RTMP_ADAPTER *pAd, IN RTMP_IOCTL_INPUT_STRUCT *wrq)
{
INT Status = NDIS_STATUS_SUCCESS;
RTMP_STRING *msg;
PRvR_Debug_CTRL pRVRDBGCtrl;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
os_alloc_mem(pAd, (UCHAR **)&msg, sizeof(CHAR) * MSG_LEN);
if (msg == NULL)
return 0;
memset(msg, 0x00, MSG_LEN);
sprintf(msg, "\n");
snprintf(msg + strlen(msg), 100, "%s%-16s%s\n",
"====================", " RvR Debug Info ",
"====================");
if ((pRVRDBGCtrl->ucViewLevel & VIEW_BASICINFO) == VIEW_BASICINFO)
printBasicinfo(pAd, msg);
if ((pRVRDBGCtrl->ucViewLevel & VIEW_WCID) == VIEW_WCID)
printWcid(pAd, msg);
if ((pRVRDBGCtrl->ucViewLevel & VIEW_MACCOUNTER) == VIEW_MACCOUNTER) {
updateBFTxCnt(pAd);
printMacCounter(pAd, msg);
}
if ((pRVRDBGCtrl->ucViewLevel & VIEW_PHYCOUNTER) == VIEW_PHYCOUNTER)
printPhyCounter(pAd, msg);
if ((pRVRDBGCtrl->ucViewLevel & VIEW_NOISE) == VIEW_NOISE)
printNoise(pAd, msg);
if ((pRVRDBGCtrl->ucViewLevel & VIEW_OTHERS) == VIEW_OTHERS)
printOthers(pAd, msg);
snprintf(msg + strlen(msg), 100, "%s\n",
"========================================================");
if ((pRVRDBGCtrl->ucViewLevel & VIEW_CNNUMBER) == VIEW_CNNUMBER)
updateCNNum(pAd, TRUE);
else
updateCNNum(pAd, FALSE);
wrq->u.data.length = strlen(msg);
Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
os_free_mem(msg);
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s<-----------------\n", __func__));
return TRUE;
}
INT rd_view(RTMP_ADAPTER *pAd, RTMP_STRING *arg, RTMP_IOCTL_INPUT_STRUCT *wrq)
{
INT Status = NDIS_STATUS_SUCCESS;
PRvR_Debug_CTRL pRVRDBGCtrl;
RTMP_STRING *msg;
INT button = Case_SHOW;
UINT8 ucViewLevel_val = 0;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
os_alloc_mem(pAd, (UCHAR **)&msg, sizeof(CHAR) * MSG_LEN);
memset(msg, 0x00, MSG_LEN);
sprintf(msg, "\n");
if (arg != NULL) {
if (strlen(arg) > 2) {
button = Case_ERROR;
} else {
if (strspn(arg, hex_RTMP_STRING) == strlen(arg)) {
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("Vaild strspn=%d,strlen=%d,",
(INT)strspn(arg, hex_RTMP_STRING),
(INT)strlen(arg)));
button = Case_SET;
ucViewLevel_val = (UINT8)os_str_tol(arg, 0, 16);
} else {
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("Vaild strspn=%d,strlen=%d,",
(INT)strspn(arg, hex_RTMP_STRING),
(INT)strlen(arg)));
button = Case_ERROR;
}
}
}
switch (button) {
case Case_ERROR:
sprintf(msg + strlen(msg), "No corresponding parameter !!!\n");
sprintf(msg + strlen(msg), "ex: iwpriv ra0 rd view=FF(bit8)\n");
break;
case Case_SHOW:
printView(pAd, msg);
break;
case Case_SET:
pRVRDBGCtrl->ucViewLevel = ucViewLevel_val;
sprintf(msg + strlen(msg), "pRVRDBGCtrl->ucViewLevel = %x",
pRVRDBGCtrl->ucViewLevel);
break;
}
wrq->u.data.length = strlen(msg);
Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
os_free_mem(msg);
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s<-----------------\n", __func__));
return TRUE;
}
INT rd_view_plus(RTMP_ADAPTER *pAd, RTMP_STRING *arg,
RTMP_IOCTL_INPUT_STRUCT *wrq)
{
INT Status = NDIS_STATUS_SUCCESS;
PRvR_Debug_CTRL pRVRDBGCtrl;
RTMP_STRING *msg;
INT view_val = VIEW_ERROR;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
os_alloc_mem(pAd, (UCHAR **)&msg, sizeof(CHAR) * MSG_LEN);
memset(msg, 0x00, MSG_LEN);
sprintf(msg, "\n");
if (arg)
view_val = getViewLevelValue(arg);
switch (view_val) {
case VIEW_BASICINFO:
pRVRDBGCtrl->ucViewLevel |= VIEW_BASICINFO;
sprintf(msg + strlen(msg), "VIEW_BASICINFO Enable");
break;
case VIEW_WCID:
pRVRDBGCtrl->ucViewLevel |= VIEW_WCID;
sprintf(msg + strlen(msg), "VIEW_WCID Enable");
break;
case VIEW_MACCOUNTER:
pRVRDBGCtrl->ucViewLevel |= VIEW_MACCOUNTER;
sprintf(msg + strlen(msg), "VIEW_MACCOUNTER Enable");
break;
case VIEW_PHYCOUNTER:
pRVRDBGCtrl->ucViewLevel |= VIEW_PHYCOUNTER;
sprintf(msg + strlen(msg), "VIEW_PHYCOUNTER Enable");
break;
case VIEW_CNNUMBER:
pRVRDBGCtrl->ucViewLevel |= VIEW_CNNUMBER;
sprintf(msg + strlen(msg), "VIEW_CNNUMBER Enable");
break;
case VIEW_NOISE:
pRVRDBGCtrl->ucViewLevel |= VIEW_NOISE;
sprintf(msg + strlen(msg), "VIEW_NOISE Enable");
break;
case VIEW_6:
break;
case VIEW_OTHERS:
pRVRDBGCtrl->ucViewLevel |= VIEW_OTHERS;
sprintf(msg + strlen(msg), "VIEW_OTHERS Enable");
break;
case VIEW_ERROR:
sprintf(msg + strlen(msg), "No corresponding parameter !!!\n");
sprintf(msg + strlen(msg), "ex: iwpriv ra0 rd view+=rate\n");
printView(pAd, msg);
break;
}
wrq->u.data.length = strlen(msg);
Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
os_free_mem(msg);
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s<-----------------\n", __func__));
return TRUE;
}
INT rd_view_minus(RTMP_ADAPTER *pAd, RTMP_STRING *arg,
RTMP_IOCTL_INPUT_STRUCT *wrq)
{
INT Status = NDIS_STATUS_SUCCESS;
PRvR_Debug_CTRL pRVRDBGCtrl;
RTMP_STRING *msg;
INT view_val = VIEW_ERROR;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
os_alloc_mem(pAd, (UCHAR **)&msg, sizeof(CHAR) * MSG_LEN);
memset(msg, 0x00, MSG_LEN);
sprintf(msg, "\n");
if (arg)
view_val = getViewLevelValue(arg);
switch (view_val) {
case VIEW_BASICINFO:
pRVRDBGCtrl->ucViewLevel &= ~VIEW_BASICINFO;
sprintf(msg + strlen(msg), "VIEW_BASICINFO Disable");
break;
case VIEW_WCID:
pRVRDBGCtrl->ucViewLevel &= ~VIEW_WCID;
sprintf(msg + strlen(msg), "VIEW_WCID Disable");
break;
case VIEW_MACCOUNTER:
pRVRDBGCtrl->ucViewLevel &= ~VIEW_MACCOUNTER;
sprintf(msg + strlen(msg), "VIEW_MACCOUNTER Disable");
break;
case VIEW_PHYCOUNTER:
pRVRDBGCtrl->ucViewLevel &= ~VIEW_PHYCOUNTER;
sprintf(msg + strlen(msg), "VIEW_PHYCOUNTER Disable");
break;
case VIEW_CNNUMBER:
pRVRDBGCtrl->ucViewLevel &= ~VIEW_CNNUMBER;
sprintf(msg + strlen(msg), "VIEW_CNNUMBER Disable");
break;
case VIEW_NOISE:
pRVRDBGCtrl->ucViewLevel &= ~VIEW_NOISE;
sprintf(msg + strlen(msg), "VIEW_NOISE Disable");
break;
case VIEW_6:
break;
case VIEW_OTHERS:
pRVRDBGCtrl->ucViewLevel &= ~VIEW_OTHERS;
sprintf(msg + strlen(msg), "VIEW_OTHERS Disable");
break;
case VIEW_ERROR:
sprintf(msg + strlen(msg), "No corresponding parameter !!!\n");
sprintf(msg + strlen(msg), "ex: iwpriv ra0 rd view-=rate\n");
printView(pAd, msg);
break;
}
wrq->u.data.length = strlen(msg);
Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
os_free_mem(msg);
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s<-----------------\n", __func__));
return TRUE;
}
INT rd_wcid(RTMP_ADAPTER *pAd, RTMP_STRING *arg, RTMP_IOCTL_INPUT_STRUCT *wrq)
{
INT Status = NDIS_STATUS_SUCCESS;
PRvR_Debug_CTRL pRVRDBGCtrl;
RTMP_STRING *msg;
INT button = Case_SHOW;
LONG input;
UINT8 ucWcid = 0;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
os_alloc_mem(pAd, (UCHAR **)&msg, sizeof(CHAR) * MSG_LEN);
memset(msg, 0x00, MSG_LEN);
sprintf(msg, "\n");
if (arg != NULL) {
if (strlen(arg) > 3) {
button = Case_ERROR;
} else {
if (strspn(arg, dec_RTMP_STRING) == strlen(arg)) {
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("Vaild strspn=%d,strlen=%d,",
(INT)strspn(arg, dec_RTMP_STRING),
(INT)strlen(arg)));
input = os_str_tol(arg, 0, 10);
if (input < 0 || input > MAX_LEN_OF_MAC_TABLE) {
button = Case_ERROR;
} else {
ucWcid = input;
button = Case_SET;
}
} else {
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL,
DBG_LVL_TRACE,
("Invaild strspn=%d,strlen=%d,",
(INT)strspn(arg, dec_RTMP_STRING),
(INT)strlen(arg)));
button = Case_ERROR;
}
}
}
switch (button) {
case Case_ERROR:
sprintf(msg + strlen(msg), "No corresponding parameter !!!\n");
sprintf(msg + strlen(msg), "ex: iwpriv ra0 rd sta=1~%d\n",
MAX_LEN_OF_MAC_TABLE);
sprintf(msg + strlen(msg),
"or iwpriv ra0 rd sta=0 for auto search first sta\n");
break;
case Case_SHOW:
Show_MacTable_Proc(pAd, ENTRY_NONE);
break;
case Case_SET:
pRVRDBGCtrl->ucWcid = ucWcid;
sprintf(msg + strlen(msg), "pRVRDBGCtrl->ucWcid = %d",
pRVRDBGCtrl->ucWcid);
break;
}
wrq->u.data.length = strlen(msg);
Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
os_free_mem(msg);
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s<-----------------\n", __func__));
return TRUE;
}
INT rd_reset(RTMP_ADAPTER *pAd, RTMP_STRING *arg, RTMP_IOCTL_INPUT_STRUCT *wrq)
{
INT Status = NDIS_STATUS_SUCCESS;
RTMP_STRING *msg;
INT button = Case_SHOW;
os_alloc_mem(pAd, (UCHAR **)&msg, sizeof(CHAR) * MSG_LEN);
memset(msg, 0x00, MSG_LEN);
sprintf(msg, "\n");
switch (button) {
case Case_SHOW:
sprintf(msg + strlen(msg), "Reset all counter!\n");
Set_ResetStatCounter_Proc(pAd, NULL);
break;
}
wrq->u.data.length = strlen(msg);
Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
os_free_mem(msg);
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s<-----------------\n", __func__));
return TRUE;
}
INT rd_help(RTMP_ADAPTER *pAd, RTMP_STRING *arg, RTMP_IOCTL_INPUT_STRUCT *wrq)
{
INT Status = NDIS_STATUS_SUCCESS;
RTMP_STRING *msg;
INT button = Case_SHOW;
os_alloc_mem(pAd, (UCHAR **)&msg, sizeof(CHAR) * MSG_LEN);
memset(msg, 0x00, MSG_LEN);
sprintf(msg, "\n");
switch (button) {
case Case_SHOW:
snprintf(msg + strlen(msg), 100, "%s",
"iwpriv [Interface] rd [Sub-command]\n");
snprintf(msg + strlen(msg), 100, "%s", "Sub-command List\n");
snprintf(msg + strlen(msg), 100, "%-25s %s", "view",
"Show view level status\n");
snprintf(msg + strlen(msg), 100, "%-25s %s",
"view=", "Set view level by hex value(8bits 00~FF)\n");
snprintf(msg + strlen(msg), 100, "%-25s %s",
"view+=", "Enable view level by string\n");
snprintf(msg + strlen(msg), 100, "%-25s %s",
"view-=", "Disable view level by string\n");
snprintf(msg + strlen(msg), 100, "%-25s %s",
"wcid,sta,ap,apcli", "Show mac table\n");
snprintf(msg + strlen(msg), 100, "%-25s %s",
"wcid=,sta=,ap=,apcli=", "Set WCID\n");
snprintf(msg + strlen(msg), 100, "%-25s %s", "reset",
"Reset all counter\n");
snprintf(msg + strlen(msg), 100, "%-25s %s", "help",
"Show support command info\n");
break;
}
wrq->u.data.length = strlen(msg);
Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
os_free_mem(msg);
MTWF_LOG(DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_TRACE,
("%s<-----------------\n", __func__));
return TRUE;
}
INT printBasicinfo(RTMP_ADAPTER *pAd, RTMP_STRING *msg)
{
POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
struct wifi_dev *wdev = get_wdev_by_ioctl_idx_and_iftype(
pAd, pObj->ioctl_if, pObj->ioctl_if_type);
UINT8 ucBand = BAND0;
UINT32 temperature = 0;
if (wdev != NULL)
ucBand = HcGetBandByWdev(wdev);
else
return FALSE;
snprintf(msg + strlen(msg), 100, "%s%-16s%s\n",
"====================", " BASIC ", "====================");
snprintf(msg + strlen(msg), 100, "%-32s= %d\n", "Current Band ",
ucBand);
RTMP_GET_TEMPERATURE(pAd, &temperature);
snprintf(msg + strlen(msg), 100, "%-32s= %d\n", "Current Temperature ",
temperature);
return TRUE;
}
VOID printView(RTMP_ADAPTER *pAd, IN RTMP_STRING *msg)
{
PRvR_Debug_CTRL pRVRDBGCtrl;
INT view_bits = 0;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
snprintf(msg + strlen(msg), 100, "%-4s | %-6s | %-15s | %s\n", "bit",
"arg", "info", "Status");
for (PView_Key_Node = View_Key_Node_List; PView_Key_Node->key;
PView_Key_Node++) {
snprintf(msg + strlen(msg), 100, "%-4d | %-6s | %-15s | %s\n",
view_bits++, PView_Key_Node->key, PView_Key_Node->str,
(pRVRDBGCtrl->ucViewLevel & PView_Key_Node->val ?
"Enable" :
"Disable"));
}
}
INT printWcid(RTMP_ADAPTER *pAd, RTMP_STRING *msg)
{
UCHAR tmp_str[30];
INT temp_str_len = sizeof(tmp_str);
INT first_sta = 0;
UINT32 lastRxRate;
UINT32 lastTxRate;
PRvR_Debug_CTRL pRVRDBGCtrl;
PMAC_TABLE_ENTRY pEntry = NULL;
struct _RTMP_CHIP_CAP *cap = hc_get_chip_cap(pAd->hdev_ctrl);
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
snprintf(msg + strlen(msg), 100, "%s%-16s%s\n",
"====================", " WCID ", "====================");
/* User assign aid, default = 0 will auto search first sta */
if (pRVRDBGCtrl->ucWcid == 0)
for (first_sta = 1; VALID_UCAST_ENTRY_WCID(pAd, first_sta);
first_sta++) {
pEntry = &pAd->MacTab.Content[first_sta];
if (IS_ENTRY_CLIENT(pEntry) && pEntry->Sst == SST_ASSOC)
break;
}
else if (VALID_UCAST_ENTRY_WCID(pAd, pRVRDBGCtrl->ucWcid))
pEntry = &pAd->MacTab.Content[pRVRDBGCtrl->ucWcid];
if (pEntry && IS_ENTRY_CLIENT(pEntry) && pEntry->Sst == SST_ASSOC) {
sprintf(msg + strlen(msg), "%-32s= %d\n", "AID ",
(int)pEntry->Aid);
sprintf(msg + strlen(msg),
"%-32s= %02X:%02X:%02X:%02X:%02X:%02X\n", "MAC Addr ",
PRINT_MAC(pEntry->Addr));
snprintf(tmp_str, temp_str_len, "%d %d %d %d",
pEntry->RssiSample.AvgRssi[0],
pEntry->RssiSample.AvgRssi[1],
pEntry->RssiSample.AvgRssi[2],
pEntry->RssiSample.AvgRssi[3]);
snprintf(msg + strlen(msg), 100, "%-32s= %s\n", "RSSI0/1/2/3 ",
tmp_str);
lastRxRate = pEntry->LastRxRate;
lastTxRate = pEntry->LastTxRate;
if (cap->fgRateAdaptFWOffload == TRUE) {
if (pEntry->bAutoTxRateSwitch == TRUE) {
EXT_EVENT_TX_STATISTIC_RESULT_T rTxStatResult;
HTTRANSMIT_SETTING LastTxRate;
MtCmdGetTxStatistic(pAd,
GET_TX_STAT_ENTRY_TX_RATE,
0 /*Don't Care*/,
pEntry->wcid,
&rTxStatResult);
LastTxRate.field.MODE =
rTxStatResult.rEntryTxRate.MODE;
LastTxRate.field.BW =
rTxStatResult.rEntryTxRate.BW;
LastTxRate.field.ldpc =
rTxStatResult.rEntryTxRate.ldpc ? 1 : 0;
LastTxRate.field.ShortGI =
rTxStatResult.rEntryTxRate.ShortGI ? 1 :
0;
LastTxRate.field.STBC =
rTxStatResult.rEntryTxRate.STBC;
if (LastTxRate.field.MODE == MODE_VHT)
LastTxRate.field.MCS =
(((rTxStatResult.rEntryTxRate
.VhtNss -
1) &
0x3)
<< 4) +
rTxStatResult.rEntryTxRate.MCS;
else
LastTxRate.field.MCS =
rTxStatResult.rEntryTxRate.MCS;
lastTxRate = (UINT32)(LastTxRate.word);
}
}
if (IS_HIF_TYPE(pAd, HIF_MT)) {
StatRateToString(pAd, msg, 0, lastTxRate);
StatRateToString(pAd, msg, 1, lastRxRate);
}
}
return TRUE;
}
INT printMacCounter(RTMP_ADAPTER *pAd, RTMP_STRING *msg)
{
POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
struct wifi_dev *wdev = get_wdev_by_ioctl_idx_and_iftype(
pAd, pObj->ioctl_if, pObj->ioctl_if_type);
UINT8 ucBand = BAND0;
UINT32 txCount = 0;
UINT32 rxCount = 0;
ULONG txper, rxper;
COUNTER_802_11 *WlanCounter = &pAd->WlanCounters[ucBand];
ULONG mpduper = 0;
ULONG mpduTXCount = 0;
PRvR_Debug_CTRL pRVRDBGCtrl;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
if (wdev != NULL)
ucBand = HcGetBandByWdev(wdev);
else
return FALSE;
snprintf(msg + strlen(msg), 100, "%s%-16s%s\n",
"====================", " MAC COUNTER ",
"====================");
/* Tx Count */
txCount = pAd->WlanCounters[ucBand].TransmittedFragmentCount.u.LowPart;
sprintf(msg + strlen(msg), "%-32s= %d\n", "Tx success count ", txCount);
if (IS_HIF_TYPE(pAd, HIF_MT)) {
txper = txCount == 0 ?
0 :
1000 *
(pAd->WlanCounters[ucBand]
.FailedCount.u.LowPart) /
(pAd->WlanCounters[ucBand]
.FailedCount.u.LowPart +
txCount);
sprintf(msg + strlen(msg), "%-32s= %ld PER=%ld.%1ld%%\n",
"Tx fail count ",
(ULONG)pAd->WlanCounters[ucBand].FailedCount.u.LowPart,
txper / 10, txper % 10);
} else {
txper = txCount == 0 ?
0 :
1000 *
(pAd->WlanCounters[ucBand]
.RetryCount.u.LowPart +
pAd->WlanCounters[ucBand]
.FailedCount.u.LowPart) /
(pAd->WlanCounters[ucBand]
.RetryCount.u.LowPart +
pAd->WlanCounters[ucBand]
.FailedCount.u.LowPart +
txCount);
sprintf(msg + strlen(msg), "%-32s= %ld, PER=%ld.%1ld%%\n",
"Tx retry count ",
(ULONG)pAd->WlanCounters[ucBand].RetryCount.u.LowPart,
txper / 10, txper % 10);
}
/*BF */
sprintf(msg + strlen(msg), "%-32s= %x %x\n", "Tx BF count(iBF/eBF) ",
pRVRDBGCtrl->uiiBFTxcnt, pRVRDBGCtrl->uieBFTxcnt);
/*AMPDU */
sprintf(msg + strlen(msg), "%-32s= %ld\n", "Tx AGG Range 1 (1)",
(LONG)(WlanCounter->TxAggRange1Count.u.LowPart));
sprintf(msg + strlen(msg), "%-32s= %ld\n", "Tx AGG Range 2 (2~5)",
(LONG)(WlanCounter->TxAggRange2Count.u.LowPart));
sprintf(msg + strlen(msg), "%-32s= %ld\n", "Tx AGG Range 3 (6~15)",
(LONG)(WlanCounter->TxAggRange3Count.u.LowPart));
sprintf(msg + strlen(msg), "%-32s= %ld\n", "Tx AGG Range 4 (>15)",
(LONG)(WlanCounter->TxAggRange4Count.u.LowPart));
mpduTXCount = WlanCounter->AmpduSuccessCount.u.LowPart;
sprintf(msg + strlen(msg), "%-32s= %ld\n", "Tx AMPDU success",
mpduTXCount);
mpduper = mpduTXCount == 0 ?
0 :
1000 * (WlanCounter->AmpduFailCount.u.LowPart) /
(WlanCounter->AmpduFailCount.u.LowPart +
mpduTXCount);
sprintf(msg + strlen(msg), "%-32s= %ld PER=%ld.%1ld%%\n",
"Tx AMPDU fail count",
(ULONG)WlanCounter->AmpduFailCount.u.LowPart, mpduper / 10,
mpduper % 10);
/* Rx Count */
rxCount = pAd->WlanCounters[ucBand].ReceivedFragmentCount.QuadPart;
sprintf(msg + strlen(msg), "%-32s= %d\n", "Rx success ", rxCount);
rxper = pAd->WlanCounters[ucBand].ReceivedFragmentCount.u.LowPart == 0 ?
0 :
1000 *
(pAd->WlanCounters[ucBand]
.FCSErrorCount.u.LowPart) /
(pAd->WlanCounters[ucBand]
.FCSErrorCount.u.LowPart +
pAd->WlanCounters[ucBand]
.ReceivedFragmentCount.u.LowPart);
sprintf(msg + strlen(msg), "%-32s= %ld, PER=%ld.%1ld%%\n",
"Rx with CRC ",
(ULONG)pAd->WlanCounters[ucBand].FCSErrorCount.u.LowPart,
rxper / 10, rxper % 10);
sprintf(msg + strlen(msg), "%-32s= %ld\n", "Rx drop(out of resource)",
(ULONG)pAd->Counters8023.RxNoBuffer);
sprintf(msg + strlen(msg), "%-32s= %ld\n", "Rx duplicate frame",
(ULONG)pAd->WlanCounters[ucBand].FrameDuplicateCount.u.LowPart);
return TRUE;
}
INT printPhyCounter(RTMP_ADAPTER *pAd, RTMP_STRING *msg)
{
POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
struct wifi_dev *wdev = get_wdev_by_ioctl_idx_and_iftype(
pAd, pObj->ioctl_if, pObj->ioctl_if_type);
UINT8 ucBand = BAND0;
PRvR_Debug_CTRL pRVRDBGCtrl;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
if (wdev != NULL)
ucBand = HcGetBandByWdev(wdev);
else
return FALSE;
snprintf(msg + strlen(msg), 100, "%s%-16s%s\n",
"====================", " PHY COUNTER ",
"====================");
if ((pRVRDBGCtrl->ucViewLevel & VIEW_CNNUMBER) == VIEW_CNNUMBER)
printCNNum(pAd, msg);
return TRUE;
}
INT printNoise(RTMP_ADAPTER *pAd, RTMP_STRING *msg)
{
POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
struct wifi_dev *wdev = get_wdev_by_ioctl_idx_and_iftype(
pAd, pObj->ioctl_if, pObj->ioctl_if_type);
UINT8 ucBand = BAND0;
PRvR_Debug_CTRL pRVRDBGCtrl;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
if (wdev != NULL)
ucBand = HcGetBandByWdev(wdev);
else
return FALSE;
snprintf(msg + strlen(msg), 100, "%s%-16s%s\n",
"====================", " NOISE ", "====================");
snprintf(msg + strlen(msg), 100, "%-32s= %s\n", "MibBucket ",
pAd->OneSecMibBucket.Enabled[ucBand] ? "Enable" : "Disable");
sprintf(msg + strlen(msg), "%-32s= %d\n", "Channel Busy Time ",
pAd->OneSecMibBucket.ChannelBusyTime[ucBand]);
sprintf(msg + strlen(msg), "%-32s= %d\n", "OBSS Air Time ",
pAd->OneSecMibBucket.OBSSAirtime[ucBand]);
sprintf(msg + strlen(msg), "%-32s= %d\n", "Tx Air Time ",
pAd->OneSecMibBucket.MyTxAirtime[ucBand]);
sprintf(msg + strlen(msg), "%-32s= %d\n", "Rx Air Time ",
pAd->OneSecMibBucket.MyRxAirtime[ucBand]);
sprintf(msg + strlen(msg), "%-32s= %d\n", "EDCCA Time ",
pAd->OneSecMibBucket.EDCCAtime[ucBand]);
sprintf(msg + strlen(msg), "%-32s= %x\n", "PD count ",
pAd->OneSecMibBucket.PdCount[ucBand]);
sprintf(msg + strlen(msg), "%-32s= %x\n", "MDRDY Count ",
pAd->OneSecMibBucket.MdrdyCount[ucBand]);
return TRUE;
}
INT printOthers(RTMP_ADAPTER *pAd, RTMP_STRING *msg)
{
/*
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
struct wifi_dev *wdev = get_wdev_by_ioctl_idx_and_iftype(pAd,pObj->ioctl_if,pObj->ioctl_if_type);
UINT8 ucBand = BAND0;
PRvR_Debug_CTRL pRVRDBGCtrl;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
if (wdev != NULL)
ucBand = HcGetBandByWdev(wdev);
else
return FALSE;
*/
snprintf(msg + strlen(msg), 100, "%s%-16s%s\n",
"====================", " OTHERS ", "====================");
return TRUE;
}
INT printCNNum(RTMP_ADAPTER *pAd, RTMP_STRING *msg)
{
if (IS_MT7615(pAd) || IS_MT7622(pAd)) {
PRvR_Debug_CTRL pRVRDBGCtrl;
UINT8 idx;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
if (pRVRDBGCtrl->ucCNcnt != 10) {
setCNNum(pAd, FALSE);
setRXV2(pAd, FALSE);
}
sprintf(msg + strlen(msg), "%-32s= ", "Condition Number ");
for (idx = 0; idx < 10; idx++)
sprintf(msg + strlen(msg), "%-2d ",
pAd->rxv2_cyc3[idx]);
sprintf(msg + strlen(msg), "\n");
}
return TRUE;
}
INT updateBFTxCnt(RTMP_ADAPTER *pAd)
{
#ifdef MT7615
if (IS_MT7615(pAd) || IS_MT7622(pAd)) {
UINT32 CrValue;
PRvR_Debug_CTRL pRVRDBGCtrl;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
RTMP_IO_READ32(pAd, WF_ETBF_BASE + 0xa09c, &CrValue);
pRVRDBGCtrl->uieBFTxcnt = CrValue & BF_MASK;
pRVRDBGCtrl->uiiBFTxcnt = ((CrValue & ~BF_MASK) >> BF_OFSET);
}
#endif /* MT7615 */
return TRUE;
}
INT updateCNNum(RTMP_ADAPTER *pAd, BOOLEAN Is_Enable)
{
#ifdef MT7615
if (IS_MT7615(pAd) || IS_MT7622(pAd)) {
setCNNum(pAd, Is_Enable);
setRXV2(pAd, Is_Enable);
}
#endif /* MT7615 */
return TRUE;
}
INT setRXV2(RTMP_ADAPTER *pAd, BOOLEAN Is_Enable)
{
#ifdef MT7615
if (IS_MT7615(pAd) || IS_MT7622(pAd)) {
UINT32 value;
if (Is_Enable) {
RTMP_IO_READ32(pAd, ARB_RQCR, &value);
value |= ARB_RQCR_RXV_R_EN;
if (pAd->CommonCfg.dbdc_mode) {
value |= ARB_RQCR_RXV1_R_EN;
}
RTMP_IO_WRITE32(pAd, ARB_RQCR, value);
} else {
RTMP_IO_READ32(pAd, ARB_RQCR, &value);
value &= ~ARB_RQCR_RXV_R_EN;
if (pAd->CommonCfg.dbdc_mode)
value &= ~ARB_RQCR_RXV1_R_EN;
RTMP_IO_WRITE32(pAd, ARB_RQCR, value);
}
}
#endif /* MT7615 */
return TRUE;
}
INT setCNNum(RTMP_ADAPTER *pAd, BOOLEAN Is_Enable)
{
if (IS_MT7615(pAd) || IS_MT7622(pAd)) {
UINT8 idx;
UINT32 value;
PRvR_Debug_CTRL pRVRDBGCtrl;
pRVRDBGCtrl = &pAd->RVRDBGCtrl;
if (Is_Enable) {
pRVRDBGCtrl->ucCNcnt = 0;
for (idx = 0; idx < 10; idx++)
pAd->rxv2_cyc3[idx] = 0xFFFFFFFF;
RTMP_IO_READ32(pAd, WF_PHY_BASE + 0x66c, &value);
value |= 0xD << 4;
RTMP_IO_WRITE32(pAd, WF_PHY_BASE + 0x66c, value);
} else {
RTMP_IO_READ32(pAd, WF_PHY_BASE + 0x66c, &value);
value &= ~0xF0;
RTMP_IO_WRITE32(pAd, WF_PHY_BASE + 0x66c, value);
}
}
return TRUE;
}
INT getViewLevelValue(RTMP_STRING *arg)
{
if (arg == NULL)
return VIEW_ERROR;
for (PView_Key_Node = View_Key_Node_List; PView_Key_Node->key;
PView_Key_Node++)
if (!strcasecmp(arg, PView_Key_Node->key))
return PView_Key_Node->val;
return VIEW_ERROR;
}

Some files were not shown because too many files have changed in this diff Show More