From 5aec58e64fb0ba4e582150d0506e9dddea6efbe3 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Sat, 9 Nov 2013 12:17:56 +0000 Subject: [PATCH 097/196] wifi: Update to newer rtl8192cu driver release --- drivers/net/wireless/rtl8192cu/Kconfig | 4 +- drivers/net/wireless/rtl8192cu/Makefile | 343 +- drivers/net/wireless/rtl8192cu/clean | 4 - .../net/wireless/rtl8192cu/core/efuse/rtw_efuse.c | 68 +- drivers/net/wireless/rtl8192cu/core/rtw_ap.c | 2940 ++ drivers/net/wireless/rtl8192cu/core/rtw_br_ext.c | 25 +- drivers/net/wireless/rtl8192cu/core/rtw_cmd.c | 723 +- drivers/net/wireless/rtl8192cu/core/rtw_debug.c | 672 +- drivers/net/wireless/rtl8192cu/core/rtw_eeprom.c | 3 +- .../net/wireless/rtl8192cu/core/rtw_ieee80211.c | 485 +- drivers/net/wireless/rtl8192cu/core/rtw_io.c | 276 +- .../net/wireless/rtl8192cu/core/rtw_ioctl_query.c | 3 +- .../net/wireless/rtl8192cu/core/rtw_ioctl_rtl.c | 3 +- .../net/wireless/rtl8192cu/core/rtw_ioctl_set.c | 374 +- drivers/net/wireless/rtl8192cu/core/rtw_iol.c | 15 +- drivers/net/wireless/rtl8192cu/core/rtw_mlme.c | 966 +- drivers/net/wireless/rtl8192cu/core/rtw_mlme_ext.c | 11414 ++++--- drivers/net/wireless/rtl8192cu/core/rtw_mp.c | 111 +- drivers/net/wireless/rtl8192cu/core/rtw_mp_ioctl.c | 313 +- drivers/net/wireless/rtl8192cu/core/rtw_p2p.c | 3044 +- drivers/net/wireless/rtl8192cu/core/rtw_pwrctrl.c | 1319 +- drivers/net/wireless/rtl8192cu/core/rtw_recv.c | 2328 +- drivers/net/wireless/rtl8192cu/core/rtw_rf.c | 3 +- drivers/net/wireless/rtl8192cu/core/rtw_security.c | 420 +- drivers/net/wireless/rtl8192cu/core/rtw_sreset.c | 352 + drivers/net/wireless/rtl8192cu/core/rtw_sta_mgt.c | 232 +- drivers/net/wireless/rtl8192cu/core/rtw_tdls.c | 2941 ++ .../net/wireless/rtl8192cu/core/rtw_wlan_util.c | 663 +- drivers/net/wireless/rtl8192cu/core/rtw_xmit.c | 2161 +- drivers/net/wireless/rtl8192cu/hal/HalPwrSeqCmd.c | 177 + drivers/net/wireless/rtl8192cu/hal/dm.c | 314 + drivers/net/wireless/rtl8192cu/hal/dm.h | 30 + drivers/net/wireless/rtl8192cu/hal/hal_com.c | 371 + drivers/net/wireless/rtl8192cu/hal/hal_init.c | 120 - drivers/net/wireless/rtl8192cu/hal/hal_intf.c | 546 + .../wireless/rtl8192cu/hal/rtl8192c/rtl8192c_cmd.c | 504 +- .../wireless/rtl8192cu/hal/rtl8192c/rtl8192c_dm.c | 608 +- .../rtl8192cu/hal/rtl8192c/rtl8192c_hal_init.c | 410 +- .../wireless/rtl8192cu/hal/rtl8192c/rtl8192c_mp.c | 31 +- .../rtl8192cu/hal/rtl8192c/rtl8192c_phycfg.c | 1726 +- .../rtl8192cu/hal/rtl8192c/rtl8192c_rf6052.c | 154 +- .../rtl8192cu/hal/rtl8192c/rtl8192c_rxdesc.c | 121 +- .../rtl8192cu/hal/rtl8192c/rtl8192c_sreset.c | 257 +- .../rtl8192cu/hal/rtl8192c/rtl8192c_xmit.c | 63 + .../rtl8192cu/hal/rtl8192c/usb/Hal8192CUHWImg.c | 11548 ++++--- .../rtl8192cu/hal/rtl8192c/usb/rtl8192cu_led.c | 403 +- .../rtl8192cu/hal/rtl8192c/usb/rtl8192cu_recv.c | 159 +- .../rtl8192cu/hal/rtl8192c/usb/rtl8192cu_xmit.c | 470 +- .../rtl8192cu/hal/rtl8192c/usb/usb_halinit.c | 1758 +- .../rtl8192cu/hal/rtl8192c/usb/usb_ops_ce.c | 5 +- .../rtl8192cu/hal/rtl8192c/usb/usb_ops_linux.c | 1291 +- .../rtl8192cu/hal/rtl8192c/usb/usb_ops_xp.c | 7 +- drivers/net/wireless/rtl8192cu/ifcfg-wlan0 | 0 .../wireless/rtl8192cu/include/Hal8192CEHWImg.h | 16 +- .../wireless/rtl8192cu/include/Hal8192CPhyCfg.h | 35 +- .../wireless/rtl8192cu/include/Hal8192CPhyReg.h | 21 + .../wireless/rtl8192cu/include/Hal8192CUHWImg.h | 26 +- .../wireless/rtl8192cu/include/Hal8192DEHWImg.h | 82 +- .../rtl8192cu/include/Hal8192DETestHWImg.h | 54 - .../wireless/rtl8192cu/include/Hal8192DPhyCfg.h | 26 +- .../wireless/rtl8192cu/include/Hal8192DUHWImg.h | 4 +- .../rtl8192cu/include/Hal8192DUHWImg_wowlan.h | 2 +- .../rtl8192cu/include/Hal8192DUTestHWImg.h | 54 - .../net/wireless/rtl8192cu/include/HalPwrSeqCmd.h | 137 + drivers/net/wireless/rtl8192cu/include/autoconf.h | 114 +- .../net/wireless/rtl8192cu/include/basic_types.h | 45 + .../wireless/rtl8192cu/include/byteorder/generic.h | 9 +- .../wireless/rtl8192cu/include/byteorder/swab.h | 15 +- .../wireless/rtl8192cu/include/byteorder/swabb.h | 3 +- drivers/net/wireless/rtl8192cu/include/drv_conf.h | 2 +- drivers/net/wireless/rtl8192cu/include/drv_types.h | 305 +- .../wireless/rtl8192cu/include/drv_types_sdio.h | 70 + drivers/net/wireless/rtl8192cu/include/farray.h | 31480 ------------------- drivers/net/wireless/rtl8192cu/include/hal_com.h | 146 + drivers/net/wireless/rtl8192cu/include/hal_init.h | 305 - drivers/net/wireless/rtl8192cu/include/hal_intf.h | 432 + drivers/net/wireless/rtl8192cu/include/ieee80211.h | 389 +- drivers/net/wireless/rtl8192cu/include/if_ether.h | 30 +- .../wireless/rtl8192cu/include/ioctl_cfg80211.h | 105 +- drivers/net/wireless/rtl8192cu/include/ip.h | 27 +- .../wireless/rtl8192cu/include/linux/wireless.h | 90 + .../net/wireless/rtl8192cu/include/mlme_osdep.h | 4 - .../net/wireless/rtl8192cu/include/osdep_intf.h | 61 +- .../net/wireless/rtl8192cu/include/osdep_service.h | 1096 +- drivers/net/wireless/rtl8192cu/include/pci_ops.h | 2 + .../net/wireless/rtl8192cu/include/rtl8192c_cmd.h | 50 +- .../net/wireless/rtl8192cu/include/rtl8192c_dm.h | 140 +- .../wireless/rtl8192cu/include/rtl8192c_event.h | 3 +- .../net/wireless/rtl8192cu/include/rtl8192c_hal.h | 110 +- .../net/wireless/rtl8192cu/include/rtl8192c_led.h | 3 +- .../net/wireless/rtl8192cu/include/rtl8192c_recv.h | 23 +- .../net/wireless/rtl8192cu/include/rtl8192c_rf.h | 3 +- .../net/wireless/rtl8192cu/include/rtl8192c_spec.h | 66 +- .../wireless/rtl8192cu/include/rtl8192c_sreset.h | 26 +- .../net/wireless/rtl8192cu/include/rtl8192c_xmit.h | 68 +- .../net/wireless/rtl8192cu/include/rtl8192d_cmd.h | 17 +- .../net/wireless/rtl8192cu/include/rtl8192d_dm.h | 52 +- .../net/wireless/rtl8192cu/include/rtl8192d_hal.h | 171 +- .../net/wireless/rtl8192cu/include/rtl8192d_led.h | 3 +- .../net/wireless/rtl8192cu/include/rtl8192d_recv.h | 6 +- .../net/wireless/rtl8192cu/include/rtl8192d_rf.h | 3 +- .../net/wireless/rtl8192cu/include/rtl8192d_spec.h | 60 +- .../net/wireless/rtl8192cu/include/rtl8192d_xmit.h | 69 +- .../net/wireless/rtl8192cu/include/rtw_android.h | 18 +- drivers/net/wireless/rtl8192cu/include/rtw_ap.h | 64 + .../net/wireless/rtl8192cu/include/rtw_byteorder.h | 3 +- drivers/net/wireless/rtl8192cu/include/rtw_cmd.h | 63 +- drivers/net/wireless/rtl8192cu/include/rtw_debug.h | 287 +- .../net/wireless/rtl8192cu/include/rtw_eeprom.h | 3 +- drivers/net/wireless/rtl8192cu/include/rtw_efuse.h | 5 +- drivers/net/wireless/rtl8192cu/include/rtw_event.h | 6 +- drivers/net/wireless/rtl8192cu/include/rtw_ht.h | 3 +- drivers/net/wireless/rtl8192cu/include/rtw_io.h | 83 +- drivers/net/wireless/rtl8192cu/include/rtw_ioctl.h | 22 +- .../wireless/rtl8192cu/include/rtw_ioctl_query.h | 3 +- .../net/wireless/rtl8192cu/include/rtw_ioctl_rtl.h | 3 +- .../net/wireless/rtl8192cu/include/rtw_ioctl_set.h | 11 +- drivers/net/wireless/rtl8192cu/include/rtw_led.h | 23 +- drivers/net/wireless/rtl8192cu/include/rtw_mlme.h | 295 +- .../net/wireless/rtl8192cu/include/rtw_mlme_ext.h | 275 +- drivers/net/wireless/rtl8192cu/include/rtw_mp.h | 10 +- .../net/wireless/rtl8192cu/include/rtw_mp_ioctl.h | 2 +- .../wireless/rtl8192cu/include/rtw_mp_phy_regdef.h | 3 +- drivers/net/wireless/rtl8192cu/include/rtw_p2p.h | 18 +- .../net/wireless/rtl8192cu/include/rtw_pwrctrl.h | 125 +- drivers/net/wireless/rtl8192cu/include/rtw_qos.h | 3 +- drivers/net/wireless/rtl8192cu/include/rtw_recv.h | 237 +- drivers/net/wireless/rtl8192cu/include/rtw_rf.h | 2 +- .../net/wireless/rtl8192cu/include/rtw_security.h | 38 +- .../net/wireless/rtl8192cu/include/rtw_sreset.h | 74 + drivers/net/wireless/rtl8192cu/include/rtw_tdls.h | 143 + .../net/wireless/rtl8192cu/include/rtw_version.h | 2 +- drivers/net/wireless/rtl8192cu/include/rtw_xmit.h | 254 +- drivers/net/wireless/rtl8192cu/include/sdio_hal.h | 34 - drivers/net/wireless/rtl8192cu/include/sdio_ops.h | 80 - .../net/wireless/rtl8192cu/include/sdio_ops_ce.h | 56 - .../wireless/rtl8192cu/include/sdio_ops_linux.h | 55 - .../net/wireless/rtl8192cu/include/sdio_ops_xp.h | 56 - .../net/wireless/rtl8192cu/include/sdio_osintf.h | 48 - drivers/net/wireless/rtl8192cu/include/sta_info.h | 117 +- drivers/net/wireless/rtl8192cu/include/usb_hal.h | 9 +- drivers/net/wireless/rtl8192cu/include/usb_ops.h | 26 +- .../net/wireless/rtl8192cu/include/usb_ops_linux.h | 63 + .../net/wireless/rtl8192cu/include/usb_osintf.h | 3 +- .../wireless/rtl8192cu/include/usb_vendor_req.h | 3 +- drivers/net/wireless/rtl8192cu/include/wifi.h | 134 +- .../net/wireless/rtl8192cu/include/wlan_bssdef.h | 292 +- .../net/wireless/rtl8192cu/include/xmit_osdep.h | 11 +- .../rtl8192cu/os_dep/linux/ioctl_cfg80211.c | 3771 ++- .../wireless/rtl8192cu/os_dep/linux/ioctl_linux.c | 5232 ++- .../wireless/rtl8192cu/os_dep/linux/mlme_linux.c | 236 +- .../net/wireless/rtl8192cu/os_dep/linux/os_intfs.c | 2049 +- .../net/wireless/rtl8192cu/os_dep/linux/pci_intf.c | 1002 +- .../rtl8192cu/os_dep/linux/pci_ops_linux.c | 24 + .../wireless/rtl8192cu/os_dep/linux/recv_linux.c | 142 +- .../wireless/rtl8192cu/os_dep/linux/rtw_android.c | 220 +- .../wireless/rtl8192cu/os_dep/linux/sdio_intf.c | 922 - .../net/wireless/rtl8192cu/os_dep/linux/usb_intf.c | 1726 +- .../rtl8192cu/os_dep/linux/usb_ops_linux.c | 649 + .../wireless/rtl8192cu/os_dep/linux/xmit_linux.c | 136 +- .../net/wireless/rtl8192cu/os_dep/osdep_service.c | 1143 +- drivers/net/wireless/rtl8192cu/runwpa | 20 + drivers/net/wireless/rtl8192cu/wlan0dhcp | 0 163 files changed, 48963 insertions(+), 60712 deletions(-) mode change 100644 => 100755 drivers/net/wireless/rtl8192cu/clean create mode 100644 drivers/net/wireless/rtl8192cu/core/rtw_ap.c create mode 100644 drivers/net/wireless/rtl8192cu/core/rtw_sreset.c create mode 100644 drivers/net/wireless/rtl8192cu/core/rtw_tdls.c create mode 100644 drivers/net/wireless/rtl8192cu/hal/HalPwrSeqCmd.c create mode 100644 drivers/net/wireless/rtl8192cu/hal/dm.c create mode 100644 drivers/net/wireless/rtl8192cu/hal/dm.h create mode 100644 drivers/net/wireless/rtl8192cu/hal/hal_com.c delete mode 100644 drivers/net/wireless/rtl8192cu/hal/hal_init.c create mode 100644 drivers/net/wireless/rtl8192cu/hal/hal_intf.c create mode 100644 drivers/net/wireless/rtl8192cu/hal/rtl8192c/rtl8192c_xmit.c mode change 100644 => 100755 drivers/net/wireless/rtl8192cu/ifcfg-wlan0 delete mode 100644 drivers/net/wireless/rtl8192cu/include/Hal8192DETestHWImg.h delete mode 100644 drivers/net/wireless/rtl8192cu/include/Hal8192DUTestHWImg.h create mode 100644 drivers/net/wireless/rtl8192cu/include/HalPwrSeqCmd.h create mode 100644 drivers/net/wireless/rtl8192cu/include/drv_types_sdio.h delete mode 100644 drivers/net/wireless/rtl8192cu/include/farray.h create mode 100644 drivers/net/wireless/rtl8192cu/include/hal_com.h delete mode 100644 drivers/net/wireless/rtl8192cu/include/hal_init.h create mode 100644 drivers/net/wireless/rtl8192cu/include/hal_intf.h create mode 100644 drivers/net/wireless/rtl8192cu/include/linux/wireless.h create mode 100644 drivers/net/wireless/rtl8192cu/include/rtw_ap.h create mode 100644 drivers/net/wireless/rtl8192cu/include/rtw_sreset.h create mode 100644 drivers/net/wireless/rtl8192cu/include/rtw_tdls.h delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_hal.h delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_ops.h delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_ops_ce.h delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_ops_linux.h delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_ops_xp.h delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_osintf.h create mode 100644 drivers/net/wireless/rtl8192cu/include/usb_ops_linux.h create mode 100644 drivers/net/wireless/rtl8192cu/os_dep/linux/pci_ops_linux.c delete mode 100644 drivers/net/wireless/rtl8192cu/os_dep/linux/sdio_intf.c create mode 100644 drivers/net/wireless/rtl8192cu/os_dep/linux/usb_ops_linux.c create mode 100755 drivers/net/wireless/rtl8192cu/runwpa mode change 100644 => 100755 drivers/net/wireless/rtl8192cu/wlan0dhcp diff --git a/drivers/net/wireless/rtl8192cu/Kconfig b/drivers/net/wireless/rtl8192cu/Kconfig index ef46361..bee5ed6 100644 --- a/drivers/net/wireless/rtl8192cu/Kconfig +++ b/drivers/net/wireless/rtl8192cu/Kconfig @@ -1,8 +1,6 @@ config RTL8192CU tristate "Realtek 8192C USB WiFi" depends on USB - select WIRELESS_EXT - select WEXT_PRIV ---help--- - Enable wireless network adapters based on Realtek RTL8192C chipset family, such as EDUP nano series + Help message of RTL8192CU diff --git a/drivers/net/wireless/rtl8192cu/Makefile b/drivers/net/wireless/rtl8192cu/Makefile index b52cace..c399011 100644 --- a/drivers/net/wireless/rtl8192cu/Makefile +++ b/drivers/net/wireless/rtl8192cu/Makefile @@ -1,15 +1,15 @@ EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS) EXTRA_CFLAGS += -O1 #EXTRA_CFLAGS += -O3 -#EXTRA_CFLAGS += -Wall -#EXTRA_CFLAGS += -Wextra +#EXTRA_CFLAGS += -Wall +#EXTRA_CFLAGS += -Wextra #EXTRA_CFLAGS += -Werror #EXTRA_CFLAGS += -pedantic -#EXTRA_CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes +#EXTRA_CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -EXTRA_CFLAGS += -Wno-unused-variable -EXTRA_CFLAGS += -Wno-unused-value -EXTRA_CFLAGS += -Wno-unused-label +EXTRA_CFLAGS += -Wno-unused-variable +EXTRA_CFLAGS += -Wno-unused-value +EXTRA_CFLAGS += -Wno-unused-label EXTRA_CFLAGS += -Wno-unused-parameter EXTRA_CFLAGS += -Wno-unused-function EXTRA_CFLAGS += -Wno-unused @@ -22,23 +22,26 @@ CONFIG_AUTOCFG_CP = n CONFIG_RTL8192C = y CONFIG_RTL8192D = n +CONFIG_RTL8723A = n CONFIG_USB_HCI = y CONFIG_PCI_HCI = n CONFIG_SDIO_HCI = n CONFIG_MP_INCLUDED = n -CONFIG_POWER_SAVING = y -CONFIG_USB_AUTOSUSPEND = n -CONFIG_HW_PWRP_DETECTION = n -CONFIG_WIFI_TEST = n -CONFIG_BT_COEXISTENCE = n -CONFIG_RTL8192CU_REDEFINE_1X1 =n -CONFIG_WAKE_ON_WLAN = n - -CONFIG_PLATFORM_I386_PC = n +CONFIG_POWER_SAVING = y +CONFIG_USB_AUTOSUSPEND = n +CONFIG_HW_PWRP_DETECTION = n +CONFIG_WIFI_TEST = n +CONFIG_BT_COEXISTENCE = n +CONFIG_RTL8192CU_REDEFINE_1X1 = n +CONFIG_INTEL_WIDI = n +CONFIG_WAKE_ON_WLAN = n + +CONFIG_PLATFORM_I386_PC = y CONFIG_PLATFORM_TI_AM3517 = n CONFIG_PLATFORM_ANDROID_X86 = n +CONFIG_PLATFORM_JB_X86 = n CONFIG_PLATFORM_ARM_S3C2K4 = n CONFIG_PLATFORM_ARM_PXA2XX = n CONFIG_PLATFORM_ARM_S3C6K4 = n @@ -50,44 +53,33 @@ CONFIG_PLATFORM_MIPS_PLM = n CONFIG_PLATFORM_MSTAR389 = n CONFIG_PLATFORM_MT53XX = n CONFIG_PLATFORM_ARM_MX51_241H = n +CONFIG_PLATFORM_FS_MX61 = n CONFIG_PLATFORM_ACTIONS_ATJ227X = n -CONFIG_PLATFORM_ARM_TEGRA3 = n +CONFIG_PLATFORM_TEGRA3_CARDHU = n +CONFIG_PLATFORM_TEGRA4_DALMORE = n CONFIG_PLATFORM_ARM_TCC8900 = n CONFIG_PLATFORM_ARM_TCC8920 = n +CONFIG_PLATFORM_ARM_TCC8920_JB42 = n CONFIG_PLATFORM_ARM_RK2818 = n CONFIG_PLATFORM_ARM_TI_PANDA = n CONFIG_PLATFORM_MIPS_JZ4760 = n CONFIG_PLATFORM_DMP_PHILIPS = n -CONFIG_PLATFORM_TI_DM365 = n +CONFIG_PLATFORM_TI_DM365 = n CONFIG_PLATFORM_MN10300 = n CONFIG_PLATFORM_MSTAR_TITANIA12 = n -CONFIG_PLATFORM_ARM_BCM2708 = y +CONFIG_PLATFORM_MSTAR_A3 = n +CONFIG_PLATFORM_ARM_SUNxI = n +CONFIG_PLATFORM_ARM_SUN6I = n CONFIG_DRVEXT_MODULE = n export TopDIR ?= $(shell pwd) -ifeq ($(CONFIG_RTL8712), y) - -RTL871X = rtl8712 - -ifeq ($(CONFIG_SDIO_HCI), y) -MODULE_NAME = 8712s -endif -ifeq ($(CONFIG_USB_HCI), y) -MODULE_NAME = 8712u -endif - -endif - ifeq ($(CONFIG_RTL8192C), y) RTL871X = rtl8192c -ifeq ($(CONFIG_SDIO_HCI), y) -MODULE_NAME = 8192cs -endif ifeq ($(CONFIG_USB_HCI), y) MODULE_NAME = 8192cu FW_FILES := hal/$(RTL871X)/usb/Hal8192CUHWImg.o @@ -100,7 +92,9 @@ MODULE_NAME = 8192ce FW_FILES := hal/$(RTL871X)/pci/Hal8192CEHWImg.o endif -CHIP_FILES := hal/$(RTL871X)/$(RTL871X)_sreset.o +CHIP_FILES := \ + hal/$(RTL871X)/$(RTL871X)_sreset.o \ + hal/$(RTL871X)/$(RTL871X)_xmit.o CHIP_FILES += $(FW_FILES) endif @@ -108,111 +102,101 @@ ifeq ($(CONFIG_RTL8192D), y) RTL871X = rtl8192d -ifeq ($(CONFIG_SDIO_HCI), y) -MODULE_NAME = 8192ds -endif ifeq ($(CONFIG_USB_HCI), y) MODULE_NAME = 8192du -FW_FILES := hal/$(RTL871X)/usb/Hal8192DUHWImg.o \ - hal/$(RTL871X)/usb/Hal8192DUTestHWImg.o +FW_FILES := hal/$(RTL871X)/usb/Hal8192DUHWImg.o ifneq ($(CONFIG_WAKE_ON_WLAN), n) FW_FILES += hal/$(RTL871X)/usb/Hal8192DUHWImg_wowlan.o endif endif ifeq ($(CONFIG_PCI_HCI), y) MODULE_NAME = 8192de -FW_FILES := hal/$(RTL871X)/pci/Hal8192DEHWImg.o \ - hal/$(RTL871X)/pci/Hal8192DETestHWImg.o +FW_FILES := hal/$(RTL871X)/pci/Hal8192DEHWImg.o endif +CHIP_FILES := \ + hal/$(RTL871X)/$(RTL871X)_xmit.o CHIP_FILES += $(FW_FILES) endif -ifeq ($(CONFIG_SDIO_HCI), y) +ifeq ($(CONFIG_RTL8723A), y) -HCI_NAME = sdio - -_OS_INTFS_FILES := os_dep/osdep_service.o \ - os_dep/linux/os_intfs.o \ - os_dep/linux/sdio_intf.o \ - os_dep/linux/ioctl_linux.o \ - os_dep/linux/xmit_linux.o \ - os_dep/linux/mlme_linux.o \ - os_dep/linux/recv_linux.o \ - os_dep/linux/rtw_android.o - -_HAL_INTFS_FILES := hal/$(RTL871X)/hal_init.o \ - hal/$(RTL871X)/sdio_halinit.o \ - hal/$(RTL871X)/sdio_ops.o \ - hal/$(RTL871X)/sdio_ops_linux.o +RTL871X = rtl8723a +ifeq ($(CONFIG_SDIO_HCI), y) +MODULE_NAME = 8723as +FW_FILES := hal/$(RTL871X)/sdio/Hal8723SHWImg.o endif - ifeq ($(CONFIG_USB_HCI), y) +MODULE_NAME = 8723au +FW_FILES := hal/$(RTL871X)/usb/Hal8723UHWImg.o +endif -HCI_NAME = usb +ifeq ($(CONFIG_PCI_HCI), y) +MODULE_NAME = 8723ae +FW_FILES := hal/$(RTL871X)/pci/Hal8723EHWImg.o +endif -_OS_INTFS_FILES := os_dep/osdep_service.o \ - os_dep/linux/os_intfs.o \ - os_dep/linux/$(HCI_NAME)_intf.o \ - os_dep/linux/ioctl_linux.o \ - os_dep/linux/xmit_linux.o \ - os_dep/linux/mlme_linux.o \ - os_dep/linux/recv_linux.o \ - os_dep/linux/ioctl_cfg80211.o \ - os_dep/linux/rtw_android.o +PWRSEQ_FILES := hal/HalPwrSeqCmd.o \ + hal/$(RTL871X)/Hal8723PwrSeq.o -_HAL_INTFS_FILES := hal/hal_init.o \ - hal/$(RTL871X)/$(RTL871X)_hal_init.o \ - hal/$(RTL871X)/$(RTL871X)_phycfg.o \ - hal/$(RTL871X)/$(RTL871X)_rf6052.o \ - hal/$(RTL871X)/$(RTL871X)_dm.o \ - hal/$(RTL871X)/$(RTL871X)_rxdesc.o \ - hal/$(RTL871X)/$(RTL871X)_cmd.o \ - hal/$(RTL871X)/$(RTL871X)_mp.o \ - hal/$(RTL871X)/usb/usb_ops_linux.o \ - hal/$(RTL871X)/usb/usb_halinit.o \ - hal/$(RTL871X)/usb/rtl$(MODULE_NAME)_led.o \ - hal/$(RTL871X)/usb/rtl$(MODULE_NAME)_xmit.o \ - hal/$(RTL871X)/usb/rtl$(MODULE_NAME)_recv.o - -_HAL_INTFS_FILES += $(CHIP_FILES) +CHIP_FILES += $(FW_FILES) $(PWRSEQ_FILES) + +endif +ifeq ($(CONFIG_SDIO_HCI), y) +HCI_NAME = sdio endif +ifeq ($(CONFIG_USB_HCI), y) +HCI_NAME = usb +endif ifeq ($(CONFIG_PCI_HCI), y) - HCI_NAME = pci +endif + _OS_INTFS_FILES := os_dep/osdep_service.o \ os_dep/linux/os_intfs.o \ os_dep/linux/$(HCI_NAME)_intf.o \ + os_dep/linux/$(HCI_NAME)_ops_linux.o \ os_dep/linux/ioctl_linux.o \ os_dep/linux/xmit_linux.o \ os_dep/linux/mlme_linux.o \ os_dep/linux/recv_linux.o \ + os_dep/linux/ioctl_cfg80211.o \ os_dep/linux/rtw_android.o -_HAL_INTFS_FILES := hal/hal_init.o \ - hal/$(RTL871X)/$(RTL871X)_hal_init.o \ + +_HAL_INTFS_FILES := hal/hal_intf.o \ + hal/hal_com.o \ + hal/dm.o \ + hal/$(RTL871X)/$(RTL871X)_hal_init.o \ hal/$(RTL871X)/$(RTL871X)_phycfg.o \ hal/$(RTL871X)/$(RTL871X)_rf6052.o \ hal/$(RTL871X)/$(RTL871X)_dm.o \ hal/$(RTL871X)/$(RTL871X)_rxdesc.o \ hal/$(RTL871X)/$(RTL871X)_cmd.o \ - hal/$(RTL871X)/$(RTL871X)_mp.o \ - hal/$(RTL871X)/pci/pci_ops_linux.o \ - hal/$(RTL871X)/pci/pci_halinit.o \ - hal/$(RTL871X)/pci/rtl$(MODULE_NAME)_led.o \ - hal/$(RTL871X)/pci/rtl$(MODULE_NAME)_xmit.o \ - hal/$(RTL871X)/pci/rtl$(MODULE_NAME)_recv.o + hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_halinit.o \ + hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_led.o \ + hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_xmit.o \ + hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_recv.o -_HAL_INTFS_FILES += $(CHIP_FILES) +ifeq ($(CONFIG_SDIO_HCI), y) +_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o +else +_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops_linux.o +endif +ifeq ($(CONFIG_MP_INCLUDED), y) +_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_mp.o endif +_HAL_INTFS_FILES += $(CHIP_FILES) + + ifeq ($(CONFIG_AUTOCFG_CP), y) $(shell cp $(TopDIR)/autoconf_$(RTL871X)_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h) endif @@ -238,22 +222,18 @@ endif ifeq ($(CONFIG_BT_COEXISTENCE), y) EXTRA_CFLAGS += -DCONFIG_BT_COEXISTENCE -endif +endif ifeq ($(CONFIG_RTL8192CU_REDEFINE_1X1), y) EXTRA_CFLAGS += -DRTL8192C_RECONFIG_TO_1T1R -endif +endif ifeq ($(CONFIG_WAKE_ON_WLAN), y) EXTRA_CFLAGS += -DCONFIG_WAKE_ON_WLAN endif -ifeq ($(CONFIG_PLATFORM_ARM_BCM2708), y) -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -ARCH := arm -CROSS_COMPILE ?= -KVER := 3.6.11+ -KSRC := /lib/modules/$(KVER)/build +ifeq ($(CONFIG_INTEL_WIDI), y) +EXTRA_CFLAGS += -DCONFIG_INTEL_WIDI endif ifeq ($(CONFIG_PLATFORM_I386_PC), y) @@ -275,11 +255,20 @@ ARCH := arm endif ifeq ($(CONFIG_PLATFORM_MSTAR_TITANIA12), y) -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_MSTAR_TITANIA12 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_MSTAR -DCONFIG_PLATFORM_MSTAR_TITANIA12 ARCH:=mips -CROSS_COMPILE:= /work/mstar/mips-4.3/bin/mips-linux-gnu- +CROSS_COMPILE:= /usr/src/Mstar_kernel/mips-4.3/bin/mips-linux-gnu- KVER:= 2.6.28.9 -KSRC:= /work/mstar/2.6.28.9/ +KSRC:= /usr/src/Mstar_kernel/2.6.28.9/ +endif + +ifeq ($(CONFIG_PLATFORM_MSTAR_A3), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_MSTAR -DCONFIG_PLATFORM_MSTAR_A3 +ARCH:=arm +CROSS_COMPILE:= arm-none-linux-gnueabi- +KVER:= 2.6.35.11 +KSRC:= /home/gary/PERFORCE/THEALE/RedLion/2.6.35.11/ +MODULE_NAME = wlan endif ifeq ($(CONFIG_PLATFORM_ANDROID_X86), y) @@ -291,6 +280,18 @@ KSRC := /media/DATA-2/android-x86/ics-x86_20120130/out/target/product/generic_x8 MODULE_NAME :=wlan endif +ifeq ($(CONFIG_PLATFORM_JB_X86), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT +EXTRA_CFLAGS += -DCONFIG_P2P_IPS +SUBARCH := $(shell uname -m | sed -e s/i.86/i386/) +ARCH := $(SUBARCH) +CROSS_COMPILE := /home/android_sdk/android-x86_JB/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7/bin/i686-linux-android- +KSRC := /home/android_sdk/android-x86_JB/out/target/product/x86/obj/kernel/ +MODULE_NAME :=wlan +endif + ifeq ($(CONFIG_PLATFORM_ARM_PXA2XX), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN ARCH := arm @@ -327,7 +328,7 @@ ifeq ($(CONFIG_PLATFORM_MIPS_RMI), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN ARCH:=mips CROSS_COMPILE:=mipsisa32r2-uclibc- -KVER:= +KVER:= KSRC:= /root/work/kernel_realtek endif @@ -335,7 +336,7 @@ ifeq ($(CONFIG_PLATFORM_MIPS_PLM), y) EXTRA_CFLAGS += -DCONFIG_BIG_ENDIAN ARCH:=mips CROSS_COMPILE:=mipsisa32r2-uclibc- -KVER:= +KVER:= KSRC:= /root/work/kernel_realtek endif @@ -366,8 +367,8 @@ ifeq ($(CONFIG_PLATFORM_RTK_DMP), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DRTK_DMP_PLATFORM ARCH:=mips CROSS_COMPILE:=mipsel-linux- -KVER:= -KSRC ?= /usr/src/work/DMP_Kernel/jupiter/linux-2.6.12 +KVER:= +KSRC ?= /usr/src/DMP_Kernel/jupiter/linux-2.6.12 endif ifeq ($(CONFIG_PLATFORM_MT53XX), y) @@ -385,7 +386,16 @@ CROSS_COMPILE := /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-li KVER := 2.6.31 KSRC ?= /lib/modules/2.6.31-770-g0e46b52/source endif - + +ifeq ($(CONFIG_PLATFORM_FS_MX61), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN +ARCH := arm +CROSS_COMPILE := /home/share/CusEnv/FreeScale/arm-eabi-4.4.3/bin/arm-eabi- +KSRC ?= /home/share/CusEnv/FreeScale/FS_kernel_env +endif + + + ifeq ($(CONFIG_PLATFORM_ACTIONS_ATJ227X), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_ACTIONS_ATJ227X ARCH := mips @@ -402,27 +412,57 @@ KVER := 2.6.18 KSRC := /home/cnsd4/Appro/mv_pro_5.0/montavista/pro/devkit/lsp/ti-davinci/linux-dm365 endif -ifeq ($(CONFIG_PLATFORM_ARM_TEGRA3), y) -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN #-DCONFIG_MINIMAL_MEMORY_USAGE -ARCH ?= arm -CROSS_COMPILE ?= /media/DATA-1/nvidia/gingerbread/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -KSRC ?= /media/DATA-1/nvidia/gingerbread/out/debug/target/product/cardhu/obj/KERNEL +ifeq ($(CONFIG_PLATFORM_TEGRA3_CARDHU), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN +# default setting for Android 4.1, 4.2 +EXTRA_CFLAGS += -DRTW_ENABLE_WIFI_CONTROL_FUNC +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT +EXTRA_CFLAGS += -DCONFIG_P2P_IPS +ARCH := arm +CROSS_COMPILE := /home/android_sdk/nvidia/tegra-16r3-partner-android-4.1_20120723/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- +KSRC := /home/android_sdk/nvidia/tegra-16r3-partner-android-4.1_20120723/out/target/product/cardhu/obj/KERNEL +MODULE_NAME := wlan +endif + +ifeq ($(CONFIG_PLATFORM_TEGRA4_DALMORE), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN +# default setting for Android 4.1, 4.2 +EXTRA_CFLAGS += -DRTW_ENABLE_WIFI_CONTROL_FUNC +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT +EXTRA_CFLAGS += -DCONFIG_P2P_IPS +ARCH := arm +CROSS_COMPILE := /home/android_sdk/nvidia/tegra-17r9-partner-android-4.2-dalmore_20130131/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi- +KSRC := /home/android_sdk/nvidia/tegra-17r9-partner-android-4.2-dalmore_20130131/out/target/product/dalmore/obj/KERNEL MODULE_NAME := wlan endif ifeq ($(CONFIG_PLATFORM_ARM_TCC8900), y) -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_MINIMAL_MEMORY_USAGE -ARCH ?= arm -CROSS_COMPILE ?= /media/DATA-1/telechips/SDK_2302_20110425/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -KSRC ?=/media/DATA-1/telechips/SDK_2302_20110425/kernel +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN +ARCH := arm +CROSS_COMPILE := /home/android_sdk/Telechips/SDK_2304_20110613/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- +KSRC := /home/android_sdk/Telechips/SDK_2304_20110613/kernel MODULE_NAME := wlan endif ifeq ($(CONFIG_PLATFORM_ARM_TCC8920), y) -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN #-DCONFIG_MINIMAL_MEMORY_USAGE +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN ARCH := arm -CROSS_COMPILE := /media/DATA-2/telechips/ics_sdk/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -KSRC := /media/DATA-2/telechips/ics_sdk/kernel +CROSS_COMPILE := /home/android_sdk/Telechips/v12.06_r1-tcc-android-4.0.4/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- +KSRC := /home/android_sdk/Telechips/v12.06_r1-tcc-android-4.0.4/kernel +MODULE_NAME := wlan +endif + +ifeq ($(CONFIG_PLATFORM_ARM_TCC8920_JB42), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN +# default setting for Android 4.1, 4.2 +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT +EXTRA_CFLAGS += -DCONFIG_P2P_IPS +ARCH := arm +CROSS_COMPILE := /home/android_sdk/Telechips/v13.03_r1-tcc-android-4.2.2_ds_patched/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi- +KSRC := /home/android_sdk/Telechips/v13.03_r1-tcc-android-4.2.2_ds_patched/kernel MODULE_NAME := wlan endif @@ -461,11 +501,39 @@ KSRC := /home/winuser/work/Plat_sLD2T_V3010/usr/src/linux-2.6.32.2 INSTALL_PREFIX := endif +ifeq ($(CONFIG_PLATFORM_ARM_SUNxI), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_ARM_SUNxI +ARCH := arm +CROSS_COMPILE := arm-none-linux-gnueabi- +KVER := 3.0.8 +#KSRC:= ../lichee/linux-3.0/ +endif + +ifeq ($(CONFIG_PLATFORM_ARM_SUN6I), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN +EXTRA_CFLAGS += -DCONFIG_PLATFORM_ARM_SUN6I +EXTRA_CFLAGS += -DCONFIG_USE_USB_BUFFER_ALLOC_TX +EXTRA_CFLAGS += -DCONFIG_TRAFFIC_PROTECT +# default setting for Android 4.1, 4.2 +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT +EXTRA_CFLAGS += -DCONFIG_P2P_IPS +ARCH := arm +CROSS_COMPILE := arm-none-linux-gnueabi- +KVER := 3.3.0 +#KSRC:= ../lichee/linux-3.3/ +endif + +ifneq ($(USER_MODULE_NAME),) +MODULE_NAME := $(USER_MODULE_NAME) +endif + ifeq ($(CONFIG_MP_INCLUDED), y) MODULE_NAME := $(MODULE_NAME)_mp EXTRA_CFLAGS += -DCONFIG_MP_INCLUDED endif + ifneq ($(KERNELRELEASE),) @@ -483,23 +551,26 @@ rtk_core := core/rtw_cmd.o \ core/rtw_rf.o \ core/rtw_recv.o \ core/rtw_sta_mgt.o \ + core/rtw_ap.o \ core/rtw_xmit.o \ core/rtw_p2p.o \ + core/rtw_tdls.o \ core/rtw_br_ext.o \ - core/rtw_iol.o + core/rtw_iol.o \ + core/rtw_sreset.o $(MODULE_NAME)-y += $(rtk_core) - + +$(MODULE_NAME)-$(CONFIG_INTEL_WIDI) += core/rtw_intel_widi.o + $(MODULE_NAME)-y += core/efuse/rtw_efuse.o $(MODULE_NAME)-y += $(_HAL_INTFS_FILES) $(MODULE_NAME)-y += $(_OS_INTFS_FILES) - $(MODULE_NAME)-$(CONFIG_MP_INCLUDED) += core/rtw_mp.o \ - core/rtw_mp_ioctl.o \ - core/rtw_ioctl_rtl.o + core/rtw_mp_ioctl.o obj-$(CONFIG_RTL8192CU) := $(MODULE_NAME).o @@ -522,12 +593,12 @@ install: uninstall: rm -f $(MODDESTDIR)/$(MODULE_NAME).ko /sbin/depmod -a ${KVER} - - + + config_r: @echo "make config" /bin/bash script/Configure script/config.in - + .PHONY: modules clean clean: @@ -535,11 +606,11 @@ clean: rm .tmp_versions -fr ; rm Module.symvers -fr rm -fr Module.markers ; rm -fr modules.order cd core/efuse ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd core ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd hal/$(RTL871X)/$(HCI_NAME) ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd hal/$(RTL871X) ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd hal ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd os_dep/linux ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd os_dep ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko + cd core ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko + cd hal/$(RTL871X)/$(HCI_NAME) ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko + cd hal/$(RTL871X) ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko + cd hal ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko + cd os_dep/linux ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko + cd os_dep ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko endif diff --git a/drivers/net/wireless/rtl8192cu/clean b/drivers/net/wireless/rtl8192cu/clean old mode 100644 new mode 100755 index 34686a0..8766421 --- a/drivers/net/wireless/rtl8192cu/clean +++ b/drivers/net/wireless/rtl8192cu/clean @@ -3,7 +3,3 @@ rmmod 8192cu rmmod 8192ce rmmod 8192du rmmod 8192de - -rmmod rtl8192cu -rmmod rtl8192c_common -rmmod rtlwifi \ No newline at end of file diff --git a/drivers/net/wireless/rtl8192cu/core/efuse/rtw_efuse.c b/drivers/net/wireless/rtl8192cu/core/efuse/rtw_efuse.c index 4908d6e..3d341ac 100644 --- a/drivers/net/wireless/rtl8192cu/core/efuse/rtw_efuse.c +++ b/drivers/net/wireless/rtl8192cu/core/efuse/rtw_efuse.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * + * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. @@ -54,6 +54,11 @@ BOOLEAN Efuse_Read1ByteFromFakeContent( IN PADAPTER pAdapter, IN u16 Offset, + IN OUT u8 *Value ); +BOOLEAN +Efuse_Read1ByteFromFakeContent( + IN PADAPTER pAdapter, + IN u16 Offset, IN OUT u8 *Value ) { if(Offset >= EFUSE_MAX_HW_SIZE) @@ -67,6 +72,12 @@ Efuse_Read1ByteFromFakeContent( *Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset]; return _TRUE; } + +BOOLEAN +Efuse_Write1ByteToFakeContent( + IN PADAPTER pAdapter, + IN u16 Offset, + IN u8 Value ); BOOLEAN Efuse_Write1ByteToFakeContent( IN PADAPTER pAdapter, @@ -210,7 +221,7 @@ ReadEFuseByte( value32 = rtw_read32(Adapter, EFUSE_CTRL); *pbuf = (u8)(value32 & 0xff); - //MSG_8192C("ReadEFuseByte _offset:%08u, in %d ms\n",_offset ,rtw_get_passing_time_ms(start)); + //DBG_871X("ReadEFuseByte _offset:%08u, in %d ms\n",_offset ,rtw_get_passing_time_ms(start)); } @@ -232,6 +243,16 @@ ReadEFuseByte( // 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1 // write addr must be after sec5. // + +VOID +efuse_ReadEFuse( + PADAPTER Adapter, + u8 efuseType, + u16 _offset, + u16 _size_byte, + u8 *pbuf, + IN BOOLEAN bPseudoTest + ); VOID efuse_ReadEFuse( PADAPTER Adapter, @@ -250,7 +271,7 @@ EFUSE_GetEfuseDefinition( IN PADAPTER pAdapter, IN u8 efuseType, IN u8 type, - OUT PVOID *pOut, + OUT void *pOut, IN BOOLEAN bPseudoTest ) { @@ -337,6 +358,12 @@ EFUSE_Read1Byte( * 09/23/2008 MHC Copy from WMAC. * *---------------------------------------------------------------------------*/ + +void +EFUSE_Write1Byte( + IN PADAPTER Adapter, + IN u16 Address, + IN u8 Value); void EFUSE_Write1Byte( IN PADAPTER Adapter, @@ -709,12 +736,12 @@ u8 rtw_efuse_map_write(PADAPTER padapter, u16 addr, u16 cnts, u8 *data) if (word_en != 0xF) { ret = Efuse_PgPacketWrite(padapter, offset, word_en, newdata, _FALSE); - DBG_8192C("offset=%x \n",offset); - DBG_8192C("word_en=%x \n",word_en); + DBG_871X("offset=%x \n",offset); + DBG_871X("word_en=%x \n",word_en); for(i=0;i +#include +#include +#include + + +#ifdef CONFIG_AP_MODE + +extern unsigned char RTW_WPA_OUI[]; +extern unsigned char WMM_OUI[]; +extern unsigned char WPS_OUI[]; +extern unsigned char P2P_OUI[]; +extern unsigned char WFD_OUI[]; + +void init_mlme_ap_info(_adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + + + _rtw_spinlock_init(&pmlmepriv->bcn_update_lock); + + //for ACL + _rtw_init_queue(&pacl_list->acl_node_q); + + //pmlmeext->bstart_bss = _FALSE; + + start_ap_mode(padapter); +} + +void free_mlme_ap_info(_adapter *padapter) +{ + _irqL irqL; + struct sta_info *psta=NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + //stop_ap_mode(padapter); + + pmlmepriv->update_bcn = _FALSE; + pmlmeext->bstart_bss = _FALSE; + + rtw_sta_flush(padapter); + + pmlmeinfo->state = _HW_STATE_NOLINK_; + + //free_assoc_sta_resources + rtw_free_all_stainfo(padapter); + + //free bc/mc sta_info + psta = rtw_get_bcmc_stainfo(padapter); + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + rtw_free_stainfo(padapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + + + _rtw_spinlock_free(&pmlmepriv->bcn_update_lock); + +} + +static void update_BCNTIM(_adapter *padapter) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + WLAN_BSSID_EX *pnetwork_mlmeext = &(pmlmeinfo->network); + unsigned char *pie = pnetwork_mlmeext->IEs; + + //DBG_871X("%s\n", __FUNCTION__); + + //update TIM IE + //if(pstapriv->tim_bitmap) + if(_TRUE) + { + u8 *p, *dst_ie, *premainder_ie=NULL, *pbackup_remainder_ie=NULL; + u16 tim_bitmap_le; + uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; + + tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap); + + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); + if (p != NULL && tim_ielen>0) + { + tim_ielen += 2; + + premainder_ie = p+tim_ielen; + + tim_ie_offset = (sint)(p -pie); + + remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen; + + //append TIM IE from dst_ie offset + dst_ie = p; + } + else + { + tim_ielen = 0; + + //calucate head_len + offset = _FIXED_IE_LENGTH_; + + /* get ssid_ie len */ + p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SSID_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); + if (p != NULL) + offset += tmp_len+2; + + // get supported rates len + p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); + if (p != NULL) + { + offset += tmp_len+2; + } + + //DS Parameter Set IE, len=3 + offset += 3; + + premainder_ie = pie + offset; + + remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen; + + //append TIM IE from offset + dst_ie = pie + offset; + + } + + + if(remainder_ielen>0) + { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if(pbackup_remainder_ie && premainder_ie) + _rtw_memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + *dst_ie++=_TIM_IE_; + + if((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc)) + tim_ielen = 5; + else + tim_ielen = 4; + + *dst_ie++= tim_ielen; + + *dst_ie++=0;//DTIM count + *dst_ie++=1;//DTIM peroid + + if(pstapriv->tim_bitmap&BIT(0))//for bc/mc frames + *dst_ie++ = BIT(0);//bitmap ctrl + else + *dst_ie++ = 0; + + if(tim_ielen==4) + { + *dst_ie++ = *(u8*)&tim_bitmap_le; + } + else if(tim_ielen==5) + { + _rtw_memcpy(dst_ie, &tim_bitmap_le, 2); + dst_ie+=2; + } + + //copy remainder IE + if(pbackup_remainder_ie) + { + _rtw_memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + rtw_mfree(pbackup_remainder_ie, remainder_ielen); + } + + offset = (uint)(dst_ie - pie); + pnetwork_mlmeext->IELength = offset + remainder_ielen; + + } + +#ifndef CONFIG_INTERRUPT_BASED_TXBCN +#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI) + set_tx_beacon_cmd(padapter); +#endif +#endif //!CONFIG_INTERRUPT_BASED_TXBCN + + +} + +void rtw_add_bcn_ie(_adapter *padapter, WLAN_BSSID_EX *pnetwork, u8 index, u8 *data, u8 len) +{ + PNDIS_802_11_VARIABLE_IEs pIE; + u8 bmatch = _FALSE; + u8 *pie = pnetwork->IEs; + u8 *p, *dst_ie, *premainder_ie=NULL, *pbackup_remainder_ie=NULL; + u32 i, offset, ielen, ie_offset, remainder_ielen = 0; + + for (i = sizeof(NDIS_802_11_FIXED_IEs); i < pnetwork->IELength;) + { + pIE = (PNDIS_802_11_VARIABLE_IEs)(pnetwork->IEs + i); + + if (pIE->ElementID > index) + { + break; + } + else if(pIE->ElementID == index) // already exist the same IE + { + p = (u8 *)pIE; + ielen = pIE->Length; + bmatch = _TRUE; + break; + } + + p = (u8 *)pIE; + ielen = pIE->Length; + i += (pIE->Length + 2); + } + + if (p != NULL && ielen>0) + { + ielen += 2; + + premainder_ie = p+ielen; + + ie_offset = (sint)(p -pie); + + remainder_ielen = pnetwork->IELength - ie_offset - ielen; + + if(bmatch) + dst_ie = p; + else + dst_ie = (p+ielen); + } + + if(remainder_ielen>0) + { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if(pbackup_remainder_ie && premainder_ie) + _rtw_memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + *dst_ie++=index; + *dst_ie++=len; + + _rtw_memcpy(dst_ie, data, len); + dst_ie+=len; + + //copy remainder IE + if(pbackup_remainder_ie) + { + _rtw_memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + rtw_mfree(pbackup_remainder_ie, remainder_ielen); + } + + offset = (uint)(dst_ie - pie); + pnetwork->IELength = offset + remainder_ielen; +} + +void rtw_remove_bcn_ie(_adapter *padapter, WLAN_BSSID_EX *pnetwork, u8 index) +{ + u8 *p, *dst_ie, *premainder_ie=NULL, *pbackup_remainder_ie=NULL; + uint offset, ielen, ie_offset, remainder_ielen = 0; + u8 *pie = pnetwork->IEs; + + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, index, &ielen, pnetwork->IELength - _FIXED_IE_LENGTH_); + if (p != NULL && ielen>0) + { + ielen += 2; + + premainder_ie = p+ielen; + + ie_offset = (sint)(p -pie); + + remainder_ielen = pnetwork->IELength - ie_offset - ielen; + + dst_ie = p; + } + else { + return; + } + + if(remainder_ielen>0) + { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if(pbackup_remainder_ie && premainder_ie) + _rtw_memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + //copy remainder IE + if(pbackup_remainder_ie) + { + _rtw_memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + rtw_mfree(pbackup_remainder_ie, remainder_ielen); + } + + offset = (uint)(dst_ie - pie); + pnetwork->IELength = offset + remainder_ielen; +} + + +u8 chk_sta_is_alive(struct sta_info *psta); +u8 chk_sta_is_alive(struct sta_info *psta) +{ + u8 ret = _FALSE; + #ifdef DBG_EXPIRATION_CHK + DBG_871X("sta:"MAC_FMT", rssi:%d, rx:"STA_PKTS_FMT", expire_to:%u, %s%ssq_len:%u\n" + , MAC_ARG(psta->hwaddr) + , psta->rssi_stat.UndecoratedSmoothedPWDB + //, STA_RX_PKTS_ARG(psta) + , STA_RX_PKTS_DIFF_ARG(psta) + , psta->expire_to + , psta->state&WIFI_SLEEP_STATE?"PS, ":"" + , psta->state&WIFI_STA_ALIVE_CHK_STATE?"SAC, ":"" + , psta->sleepq_len + ); + #endif + + //if(sta_last_rx_pkts(psta) == sta_rx_pkts(psta)) + if((psta->sta_stats.last_rx_data_pkts + psta->sta_stats.last_rx_ctrl_pkts) == (psta->sta_stats.rx_data_pkts + psta->sta_stats.rx_ctrl_pkts)) + { + #if 0 + if(psta->state&WIFI_SLEEP_STATE) + ret = _TRUE; + #endif + } + else + { + ret = _TRUE; + } + + sta_update_last_rx_pkts(psta); + + return ret; +} + +void expire_timeout_chk(_adapter *padapter) +{ + _irqL irqL; + _list *phead, *plist; + u8 updated; + struct sta_info *psta=NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 chk_alive_num = 0; + char chk_alive_list[NUM_STA]; + int i; + + _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); + + phead = &pstapriv->auth_list; + plist = get_next(phead); + + //check auth_queue + #ifdef DBG_EXPIRATION_CHK + if (rtw_end_of_queue_search(phead, plist) == _FALSE) { + DBG_871X(FUNC_NDEV_FMT" auth_list, cnt:%u\n" + , FUNC_NDEV_ARG(padapter->pnetdev), pstapriv->auth_list_cnt); + } + #endif + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) + { + psta = LIST_CONTAINOR(plist, struct sta_info, auth_list); + plist = get_next(plist); + + if(psta->expire_to>0) + { + psta->expire_to--; + if (psta->expire_to == 0) + { + rtw_list_delete(&psta->auth_list); + pstapriv->auth_list_cnt--; + + DBG_871X("auth expire %02X%02X%02X%02X%02X%02X\n", + psta->hwaddr[0],psta->hwaddr[1],psta->hwaddr[2],psta->hwaddr[3],psta->hwaddr[4],psta->hwaddr[5]); + + _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + rtw_free_stainfo(padapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + + _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); + } + } + + } + + _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + + psta = NULL; + + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + //check asoc_queue + #ifdef DBG_EXPIRATION_CHK + if (rtw_end_of_queue_search(phead, plist) == _FALSE) { + DBG_871X(FUNC_NDEV_FMT" asoc_list, cnt:%u\n" + , FUNC_NDEV_ARG(padapter->pnetdev), pstapriv->asoc_list_cnt); + } + #endif + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) + { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + plist = get_next(plist); + + if (chk_sta_is_alive(psta) || !psta->expire_to) { + psta->expire_to = pstapriv->expire_to; + psta->keep_alive_trycnt = 0; + #ifdef CONFIG_TX_MCAST2UNI + psta->under_exist_checking = 0; + #endif // CONFIG_TX_MCAST2UNI + } else { + psta->expire_to--; + } + +#ifndef CONFIG_ACTIVE_KEEP_ALIVE_CHECK +#ifdef CONFIG_TX_MCAST2UNI + if ( (psta->flags & WLAN_STA_HT) && (psta->htpriv.agg_enable_bitmap || psta->under_exist_checking) ) { + // check sta by delba(addba) for 11n STA + // ToDo: use CCX report to check for all STAs + //DBG_871X("asoc check by DELBA/ADDBA! (pstapriv->expire_to=%d s)(psta->expire_to=%d s), [%02x, %d]\n", pstapriv->expire_to*2, psta->expire_to*2, psta->htpriv.agg_enable_bitmap, psta->under_exist_checking); + + if ( psta->expire_to <= (pstapriv->expire_to - 50 ) ) { + DBG_871X("asoc expire by DELBA/ADDBA! (%d s)\n", (pstapriv->expire_to-psta->expire_to)*2); + psta->under_exist_checking = 0; + psta->expire_to = 0; + } else if ( psta->expire_to <= (pstapriv->expire_to - 3) && (psta->under_exist_checking==0)) { + DBG_871X("asoc check by DELBA/ADDBA! (%d s)\n", (pstapriv->expire_to-psta->expire_to)*2); + psta->under_exist_checking = 1; + //tear down TX AMPDU + send_delba(padapter, 1, psta->hwaddr);// // originator + psta->htpriv.agg_enable_bitmap = 0x0;//reset + psta->htpriv.candidate_tid_bitmap = 0x0;//reset + } + } +#endif // CONFIG_TX_MCAST2UNI +#endif //CONFIG_ACTIVE_KEEP_ALIVE_CHECK + + if (psta->expire_to <= 0) + { + #ifdef CONFIG_ACTIVE_KEEP_ALIVE_CHECK + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + if (padapter->registrypriv.wifi_spec == 1) + { + psta->expire_to = pstapriv->expire_to; + continue; + } + + if (psta->state & WIFI_SLEEP_STATE) { + if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) { + //to check if alive by another methods if staion is at ps mode. + psta->expire_to = pstapriv->expire_to; + psta->state |= WIFI_STA_ALIVE_CHK_STATE; + + //DBG_871X("alive chk, sta:" MAC_FMT " is at ps mode!\n", MAC_ARG(psta->hwaddr)); + + //to update bcn with tim_bitmap for this station + pstapriv->tim_bitmap |= BIT(psta->aid); + update_beacon(padapter, _TIM_IE_, NULL, _FALSE); + + if(!pmlmeext->active_keep_alive_check) + continue; + } + } + + if (pmlmeext->active_keep_alive_check) { + int stainfo_offset; + + stainfo_offset = rtw_stainfo_offset(pstapriv, psta); + if (stainfo_offset_valid(stainfo_offset)) { + chk_alive_list[chk_alive_num++] = stainfo_offset; + } + + continue; + } + #endif /* CONFIG_ACTIVE_KEEP_ALIVE_CHECK */ + + rtw_list_delete(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + + DBG_871X("asoc expire "MAC_FMT", state=0x%x\n", MAC_ARG(psta->hwaddr), psta->state); + updated = ap_free_sta(padapter, psta, _FALSE, WLAN_REASON_DEAUTH_LEAVING); + } + else + { + /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */ + if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt) + && padapter->xmitpriv.free_xmitframe_cnt < (NR_XMITFRAME/pstapriv->asoc_list_cnt/2) + ){ + DBG_871X("%s sta:"MAC_FMT", sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__ + , MAC_ARG(psta->hwaddr) + , psta->sleepq_len, padapter->xmitpriv.free_xmitframe_cnt, pstapriv->asoc_list_cnt); + wakeup_sta_to_xmit(padapter, psta); + } + } + } + + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + +#ifdef CONFIG_ACTIVE_KEEP_ALIVE_CHECK +if (chk_alive_num) { + + u8 backup_oper_channel=0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + /* switch to correct channel of current network before issue keep-alive frames */ + if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) { + backup_oper_channel = rtw_get_oper_ch(padapter); + SelectChannel(padapter, pmlmeext->cur_channel); + } + + /* issue null data to check sta alive*/ + for (i = 0; i < chk_alive_num; i++) { + + int ret = _FAIL; + + psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]); + if(!(psta->state &_FW_LINKED)) + continue; + + if (psta->state & WIFI_SLEEP_STATE) + ret = issue_nulldata(padapter, psta->hwaddr, 0, 1, 50); + else + ret = issue_nulldata(padapter, psta->hwaddr, 0, 3, 50); + + psta->keep_alive_trycnt++; + if (ret == _SUCCESS) + { + DBG_871X("asoc check, sta(" MAC_FMT ") is alive\n", MAC_ARG(psta->hwaddr)); + psta->expire_to = pstapriv->expire_to; + psta->keep_alive_trycnt = 0; + continue; + } + else if (psta->keep_alive_trycnt <= 3) + { + DBG_871X("ack check for asoc expire, keep_alive_trycnt=%d\n", psta->keep_alive_trycnt); + psta->expire_to = 1; + continue; + } + + psta->keep_alive_trycnt = 0; + + DBG_871X("asoc expire "MAC_FMT", state=0x%x\n", MAC_ARG(psta->hwaddr), psta->state); + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + if (rtw_is_list_empty(&psta->asoc_list)==_FALSE) { + rtw_list_delete(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, _FALSE, WLAN_REASON_DEAUTH_LEAVING); + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + } + + if (backup_oper_channel>0) /* back to the original operation channel */ + SelectChannel(padapter, backup_oper_channel); +} +#endif /* CONFIG_ACTIVE_KEEP_ALIVE_CHECK */ + + associated_clients_update(padapter, updated); +} + + +static void add_RATid(_adapter *padapter, struct sta_info *psta) +{ + int i; + u8 rf_type; + u32 init_rate=0; + unsigned char sta_band = 0, raid, shortGIrate = _FALSE; + unsigned char limit; + unsigned int tx_ra_bitmap=0; + struct ht_priv *psta_ht = NULL; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + WLAN_BSSID_EX *pcur_network = (WLAN_BSSID_EX *)&pmlmepriv->cur_network.network; + + + if(psta) + psta_ht = &psta->htpriv; + else + return; + + //b/g mode ra_bitmap + for (i=0; ibssrateset); i++) + { + if (psta->bssrateset[i]) + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f); + } + + //n mode ra_bitmap + if(psta_ht->ht_option) + { + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if(rf_type == RF_2T2R) + limit=16;// 2R + else + limit=8;// 1R + + for (i=0; iht_cap.supp_mcs_set[i/8] & BIT(i%8)) + tx_ra_bitmap |= BIT(i+12); + } + + //max short GI rate + shortGIrate = psta_ht->sgi; + } + + +#if 0//gtest + if(get_rf_mimo_mode(padapter) == RTL8712_RF_2T2R) + { + //is this a 2r STA? + if((pstat->tx_ra_bitmap & 0x0ff00000) != 0 && !(priv->pshare->has_2r_sta & BIT(pstat->aid))) + { + priv->pshare->has_2r_sta |= BIT(pstat->aid); + if(rtw_read16(padapter, 0x102501f6) != 0xffff) + { + rtw_write16(padapter, 0x102501f6, 0xffff); + reset_1r_sta_RA(priv, 0xffff); + Switch_1SS_Antenna(priv, 3); + } + } + else// bg or 1R STA? + { + if((priv->pmib->dot11BssType.net_work_type & WIRELESS_11N) && pstat->ht_cap_len && priv->pshare->has_2r_sta == 0) + { + if(rtw_read16(padapter, 0x102501f6) != 0x7777) + { // MCS7 SGI + rtw_write16(padapter, 0x102501f6,0x7777); + reset_1r_sta_RA(priv, 0x7777); + Switch_1SS_Antenna(priv, 2); + } + } + } + + } + + if ((pstat->rssi_level < 1) || (pstat->rssi_level > 3)) + { + if (pstat->rssi >= priv->pshare->rf_ft_var.raGoDownUpper) + pstat->rssi_level = 1; + else if ((pstat->rssi >= priv->pshare->rf_ft_var.raGoDown20MLower) || + ((priv->pshare->is_40m_bw) && (pstat->ht_cap_len) && + (pstat->rssi >= priv->pshare->rf_ft_var.raGoDown40MLower) && + (pstat->ht_cap_buf.ht_cap_info & cpu_to_le16(_HTCAP_SUPPORT_CH_WDTH_)))) + pstat->rssi_level = 2; + else + pstat->rssi_level = 3; + } + + // rate adaptive by rssi + if ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11N) && pstat->ht_cap_len) + { + if ((get_rf_mimo_mode(priv) == MIMO_1T2R) || (get_rf_mimo_mode(priv) == MIMO_1T1R)) + { + switch (pstat->rssi_level) { + case 1: + pstat->tx_ra_bitmap &= 0x100f0000; + break; + case 2: + pstat->tx_ra_bitmap &= 0x100ff000; + break; + case 3: + if (priv->pshare->is_40m_bw) + pstat->tx_ra_bitmap &= 0x100ff005; + else + pstat->tx_ra_bitmap &= 0x100ff001; + + break; + } + } + else + { + switch (pstat->rssi_level) { + case 1: + pstat->tx_ra_bitmap &= 0x1f0f0000; + break; + case 2: + pstat->tx_ra_bitmap &= 0x1f0ff000; + break; + case 3: + if (priv->pshare->is_40m_bw) + pstat->tx_ra_bitmap &= 0x000ff005; + else + pstat->tx_ra_bitmap &= 0x000ff001; + + break; + } + + // Don't need to mask high rates due to new rate adaptive parameters + //if (pstat->is_broadcom_sta) // use MCS12 as the highest rate vs. Broadcom sta + // pstat->tx_ra_bitmap &= 0x81ffffff; + + // NIC driver will report not supporting MCS15 and MCS14 in asoc req + //if (pstat->is_rtl8190_sta && !pstat->is_2t_mimo_sta) + // pstat->tx_ra_bitmap &= 0x83ffffff; // if Realtek 1x2 sta, don't use MCS15 and MCS14 + } + } + else if ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11G) && isErpSta(pstat)) + { + switch (pstat->rssi_level) { + case 1: + pstat->tx_ra_bitmap &= 0x00000f00; + break; + case 2: + pstat->tx_ra_bitmap &= 0x00000ff0; + break; + case 3: + pstat->tx_ra_bitmap &= 0x00000ff5; + break; + } + } + else + { + pstat->tx_ra_bitmap &= 0x0000000d; + } + + // disable tx short GI when station cannot rx MCS15(AP is 2T2R) + // disable tx short GI when station cannot rx MCS7 (AP is 1T2R or 1T1R) + // if there is only 1r STA and we are 2T2R, DO NOT mask SGI rate + if ((!(pstat->tx_ra_bitmap & 0x8000000) && (priv->pshare->has_2r_sta > 0) && (get_rf_mimo_mode(padapter) == RTL8712_RF_2T2R)) || + (!(pstat->tx_ra_bitmap & 0x80000) && (get_rf_mimo_mode(padapter) != RTL8712_RF_2T2R))) + { + pstat->tx_ra_bitmap &= ~BIT(28); + } +#endif + + if ( pcur_network->Configuration.DSConfig > 14 ) { + // 5G band + if (tx_ra_bitmap & 0xffff000) + sta_band |= WIRELESS_11_5N | WIRELESS_11A; + else + sta_band |= WIRELESS_11A; + } else { + if (tx_ra_bitmap & 0xffff000) + sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B; + else if (tx_ra_bitmap & 0xff0) + sta_band |= WIRELESS_11G |WIRELESS_11B; + else + sta_band |= WIRELESS_11B; + } + + raid = networktype_to_raid(sta_band); + init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f; + + if (psta->aid < NUM_STA) + { + u8 arg = 0; + + arg = psta->mac_id&0x1f; + + arg |= BIT(7);//support entry 2~31 + + if (shortGIrate==_TRUE) + arg |= BIT(5); + + tx_ra_bitmap |= ((raid<<28)&0xf0000000); + + DBG_871X("%s=> mac_id:%d , raid:%d , bitmap=0x%x, arg=0x%x\n", + __FUNCTION__ , psta->mac_id, raid ,tx_ra_bitmap, arg); + + //bitmap[0:27] = tx_rate_bitmap + //bitmap[28:31]= Rate Adaptive id + //arg[0:4] = macid + //arg[5] = Short GI + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg); + + if (shortGIrate==_TRUE) + init_rate |= BIT(6); + + //set ra_id, init_rate + psta->raid = raid; + psta->init_rate = init_rate; + + } + else + { + DBG_871X("station aid %d exceed the max number\n", psta->aid); + } + +} + +static void update_bmc_sta(_adapter *padapter) +{ + _irqL irqL; + u32 init_rate=0; + unsigned char network_type, raid; + int i, supportRateNum = 0; + unsigned int tx_ra_bitmap=0; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + WLAN_BSSID_EX *pcur_network = (WLAN_BSSID_EX *)&pmlmepriv->cur_network.network; + struct sta_info *psta = rtw_get_bcmc_stainfo(padapter); + + if(psta) + { + psta->aid = 0;//default set to 0 + //psta->mac_id = psta->aid+4; + psta->mac_id = psta->aid + 1; + + psta->qos_option = 0; + psta->htpriv.ht_option = _FALSE; + + psta->ieee8021x_blocked = 0; + + _rtw_memset((void*)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + + //psta->dot118021XPrivacy = _NO_PRIVACY_;//!!! remove it, because it has been set before this. + + + + //prepare for add_RATid + supportRateNum = rtw_get_rateset_len((u8*)&pcur_network->SupportedRates); + network_type = rtw_check_network_type((u8*)&pcur_network->SupportedRates, supportRateNum, 1); + + _rtw_memcpy(psta->bssrateset, &pcur_network->SupportedRates, supportRateNum); + psta->bssratelen = supportRateNum; + + //b/g mode ra_bitmap + for (i=0; ibssrateset[i]) + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f); + } + + if ( pcur_network->Configuration.DSConfig > 14 ) { + //force to A mode. 5G doesn't support CCK rates + network_type = WIRELESS_11A; + tx_ra_bitmap = 0x150; // 6, 12, 24 Mbps + } else { + //force to b mode + network_type = WIRELESS_11B; + tx_ra_bitmap = 0xf; + } + + //tx_ra_bitmap = update_basic_rate(pcur_network->SupportedRates, supportRateNum); + + raid = networktype_to_raid(network_type); + init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f; + + //DBG_871X("Add id %d val %08x to ratr for bmc sta\n", psta->aid, tx_ra_bitmap); + + //if(pHalData->fw_ractrl == _TRUE) + { + u8 arg = 0; + + arg = psta->mac_id&0x1f; + + arg |= BIT(7); + + //if (shortGIrate==_TRUE) + // arg |= BIT(5); + + tx_ra_bitmap |= ((raid<<28)&0xf0000000); + + DBG_871X("update_bmc_sta, mask=0x%x, arg=0x%x\n", tx_ra_bitmap, arg); + + //bitmap[0:27] = tx_rate_bitmap + //bitmap[28:31]= Rate Adaptive id + //arg[0:4] = macid + //arg[5] = Short GI + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg); + + } + + //set ra_id, init_rate + psta->raid = raid; + psta->init_rate = init_rate; + + _enter_critical_bh(&psta->lock, &irqL); + psta->state = _FW_LINKED; + _exit_critical_bh(&psta->lock, &irqL); + + } + else + { + DBG_871X("add_RATid_bmc_sta error!\n"); + } + +} + +//notes: +//AID: 1~MAX for sta and 0 for bc/mc in ap/adhoc mode +//MAC_ID = AID+1 for sta in ap/adhoc mode +//MAC_ID = 1 for bc/mc for sta/ap/adhoc +//MAC_ID = 0 for bssid for sta/ap/adhoc +//CAM_ID = //0~3 for default key, cmd_id=macid + 3, macid=aid+1; + +void update_sta_info_apmode(_adapter *padapter, struct sta_info *psta) +{ + _irqL irqL; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; + struct ht_priv *phtpriv_sta = &psta->htpriv; + + //set intf_tag to if1 + //psta->intf_tag = 0; + + //psta->mac_id = psta->aid+4; + psta->mac_id = psta->aid+1; + + if(psecuritypriv->dot11AuthAlgrthm==dot11AuthAlgrthm_8021X) + psta->ieee8021x_blocked = _TRUE; + else + psta->ieee8021x_blocked = _FALSE; + + + //update sta's cap + + //ERP + VCS_update(padapter, psta); + + //HT related cap + if(phtpriv_sta->ht_option) + { + //check if sta supports rx ampdu + phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable; + + //check if sta support s Short GI + if((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) + { + phtpriv_sta->sgi = _TRUE; + } + + // bwmode + if((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH)) + { + //phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_40; + phtpriv_sta->bwmode = pmlmeext->cur_bwmode; + phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; + + } + + psta->qos_option = _TRUE; + + } + else + { + phtpriv_sta->ampdu_enable = _FALSE; + + phtpriv_sta->sgi = _FALSE; + phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; + phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + } + + //Rx AMPDU + send_delba(padapter, 0, psta->hwaddr);// recipient + + //TX AMPDU + send_delba(padapter, 1, psta->hwaddr);// // originator + phtpriv_sta->agg_enable_bitmap = 0x0;//reset + phtpriv_sta->candidate_tid_bitmap = 0x0;//reset + + + //todo: init other variables + + _rtw_memset((void*)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + + + //add ratid + //add_RATid(padapter, psta);//move to ap_sta_info_defer_update() + + + _enter_critical_bh(&psta->lock, &irqL); + psta->state |= _FW_LINKED; + _exit_critical_bh(&psta->lock, &irqL); + + +} + +static void update_hw_ht_param(_adapter *padapter) +{ + unsigned char max_AMPDU_len; + unsigned char min_MPDU_spacing; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + DBG_871X("%s\n", __FUNCTION__); + + + //handle A-MPDU parameter field + /* + AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k + AMPDU_para [4:2]:Min MPDU Start Spacing + */ + max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03; + + min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + + // + // Config SM Power Save setting + // + pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & 0x0C) >> 2; + if(pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) + { + /*u8 i; + //update the MCS rates + for (i = 0; i < 16; i++) + { + pmlmeinfo->HT_caps.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i]; + }*/ + DBG_871X("%s(): WLAN_HT_CAP_SM_PS_STATIC\n",__FUNCTION__); + } + + // + // Config current HT Protection mode. + // + //pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3; + +} + +static void start_bss_network(_adapter *padapter, u8 *pbuf) +{ + u8 *p; + u8 val8, cur_channel, cur_bwmode, cur_ch_offset; + u16 bcn_interval; + u32 acparm; + int ie_len; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct security_priv* psecuritypriv=&(padapter->securitypriv); + WLAN_BSSID_EX *pnetwork = (WLAN_BSSID_EX *)&pmlmepriv->cur_network.network; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + WLAN_BSSID_EX *pnetwork_mlmeext = &(pmlmeinfo->network); + struct HT_info_element *pht_info=NULL; +#ifdef CONFIG_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif //CONFIG_P2P + u8 cbw40_enable=0; + u8 change_band = _FALSE; + //DBG_871X("%s\n", __FUNCTION__); + + bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; + cur_channel = pnetwork->Configuration.DSConfig; + cur_bwmode = HT_CHANNEL_WIDTH_20;; + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + + //check if there is wps ie, + //if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, + //and at first time the security ie ( RSN/WPA IE) will not include in beacon. + if(NULL == rtw_get_wps_ie(pnetwork->IEs+_FIXED_IE_LENGTH_, pnetwork->IELength-_FIXED_IE_LENGTH_, NULL, NULL)) + { + pmlmeext->bstart_bss = _TRUE; + } + + //todo: update wmm, ht cap + //pmlmeinfo->WMM_enable; + //pmlmeinfo->HT_enable; + if(pmlmepriv->qospriv.qos_option) + pmlmeinfo->WMM_enable = _TRUE; + + if(pmlmepriv->htpriv.ht_option) + { + pmlmeinfo->WMM_enable = _TRUE; + pmlmeinfo->HT_enable = _TRUE; + //pmlmeinfo->HT_info_enable = _TRUE; + //pmlmeinfo->HT_caps_enable = _TRUE; + + update_hw_ht_param(padapter); + } + + + if(pmlmepriv->cur_network.join_res != _TRUE) //setting only at first time + { + //WEP Key will be set before this function, do not clear CAM. + if ((psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) && (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)) + flush_all_cam_entry(padapter); //clear CAM + } + + //set MSR to AP_Mode + Set_MSR(padapter, _HW_STATE_AP_); + + //Set BSSID REG + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pnetwork->MacAddress); + + //Set EDCA param reg +#ifdef CONFIG_CONCURRENT_MODE + acparm = 0x005ea42b; +#else + acparm = 0x002F3217; // VO +#endif + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acparm)); + acparm = 0x005E4317; // VI + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acparm)); + //acparm = 0x00105320; // BE + acparm = 0x005ea42b; + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acparm)); + acparm = 0x0000A444; // BK + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); + + //Set Security + val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf; + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + //Beacon Control related register + rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval)); + + if(pmlmepriv->cur_network.join_res != _TRUE) //setting only at first time + { + u32 initialgain; + + initialgain = 0x1e; + + + //disable dynamic functions, such as high power, DIG + //Save_DM_Func_Flag(padapter); + //Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, _FALSE); + +#ifdef CONFIG_CONCURRENT_MODE + if(padapter->adapter_type > PRIMARY_ADAPTER) + { + if(rtw_buddy_adapter_up(padapter)) + { + _adapter *pbuddy_adapter = padapter->pbuddy_adapter; + + //turn on dynamic functions on PRIMARY_ADAPTER, dynamic functions only runs at PRIMARY_ADAPTER + Switch_DM_Func(pbuddy_adapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, _TRUE); + + rtw_hal_set_hwreg(pbuddy_adapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + } + } + else +#endif + { + //turn on dynamic functions + Switch_DM_Func(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, _TRUE); + + rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + } + + } + + //set channel, bwmode + p = rtw_get_ie((pnetwork->IEs + sizeof(NDIS_802_11_FIXED_IEs)), _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - sizeof(NDIS_802_11_FIXED_IEs))); + if( p && ie_len) + { + pht_info = (struct HT_info_element *)(p+2); + + if( pmlmeext->cur_channel > 14 ) + { + if( pregpriv->cbw40_enable & BIT(1) ) + cbw40_enable = 1; + } + else + if( pregpriv->cbw40_enable & BIT(0) ) + cbw40_enable = 1; + + if ((cbw40_enable) && (pht_info->infos[0] & BIT(2))) + { + //switch to the 40M Hz mode + //pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; + cur_bwmode = HT_CHANNEL_WIDTH_40; + switch (pht_info->infos[0] & 0x3) + { + case 1: + //pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; + + case 3: + //pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; + + default: + //pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; + } + + } + + } + +#ifdef CONFIG_DUALMAC_CONCURRENT + dc_set_ap_channel_bandwidth(padapter, cur_channel, cur_ch_offset, cur_bwmode); +#else + //TODO: need to judge the phy parameters on concurrent mode for single phy + //set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); +#ifdef CONFIG_CONCURRENT_MODE + if(!check_buddy_fwstate(padapter, _FW_LINKED|_FW_UNDER_LINKING|_FW_UNDER_SURVEY)) + { + set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode); + } + else if(check_buddy_fwstate(padapter, _FW_LINKED)==_TRUE)//only second adapter can enter AP Mode + { + _adapter *pbuddy_adapter = padapter->pbuddy_adapter; + struct mlme_ext_priv *pbuddy_mlmeext = &pbuddy_adapter->mlmeextpriv; + + //To sync cur_channel/cur_bwmode/cur_ch_offset with primary adapter + DBG_871X("primary iface is at linked state, sync cur_channel/cur_bwmode/cur_ch_offset\n"); + DBG_871X("primary adapter, CH=%d, BW=%d, offset=%d\n", pbuddy_mlmeext->cur_channel, pbuddy_mlmeext->cur_bwmode, pbuddy_mlmeext->cur_ch_offset); + DBG_871X("second adapter, CH=%d, BW=%d, offset=%d\n", cur_channel, cur_bwmode, cur_ch_offset); + + if((cur_channel <= 14 && pbuddy_mlmeext->cur_channel >= 36) || + (cur_channel >= 36 && pbuddy_mlmeext->cur_channel <= 14)) + change_band = _TRUE; + + cur_channel = pbuddy_mlmeext->cur_channel; + if(cur_bwmode == HT_CHANNEL_WIDTH_40) + { + if(pht_info) + pht_info->infos[0] &= ~(BIT(0)|BIT(1)); + + if(pbuddy_mlmeext->cur_bwmode == HT_CHANNEL_WIDTH_40) + { + cur_ch_offset = pbuddy_mlmeext->cur_ch_offset; + + //to update cur_ch_offset value in beacon + if(pht_info) + { + switch(cur_ch_offset) + { + case HAL_PRIME_CHNL_OFFSET_LOWER: + pht_info->infos[0] |= 0x1; + break; + case HAL_PRIME_CHNL_OFFSET_UPPER: + pht_info->infos[0] |= 0x3; + break; + case HAL_PRIME_CHNL_OFFSET_DONT_CARE: + default: + break; + } + } + + } + else if(pbuddy_mlmeext->cur_bwmode == HT_CHANNEL_WIDTH_20) + { + cur_bwmode = HT_CHANNEL_WIDTH_20; + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + if(cur_channel>0 && cur_channel<5) + { + if(pht_info) + pht_info->infos[0] |= 0x1; + + cur_bwmode = HT_CHANNEL_WIDTH_40; + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + } + + if(cur_channel>7 && cur_channel<(14+1)) + { + if(pht_info) + pht_info->infos[0] |= 0x3; + + cur_bwmode = HT_CHANNEL_WIDTH_40; + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + } + + set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode); + } + + } + + // to update channel value in beacon + pnetwork->Configuration.DSConfig = cur_channel; + p = rtw_get_ie((pnetwork->IEs + sizeof(NDIS_802_11_FIXED_IEs)), _DSSET_IE_, &ie_len, (pnetwork->IELength - sizeof(NDIS_802_11_FIXED_IEs))); + if(p && ie_len>0) + *(p + 2) = cur_channel; + + if(pht_info) + pht_info->primary_channel = cur_channel; + + //set buddy adapter channel, bandwidth, offeset to current adapter + pmlmeext->cur_channel = cur_channel; + pmlmeext->cur_bwmode = cur_bwmode; + pmlmeext->cur_ch_offset = cur_ch_offset; + + //buddy interface band is different from current interface, update ERP, support rate, ext support rate IE + if(change_band == _TRUE) + change_band_update_ie(padapter, pnetwork); + } +#else + set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode); +#endif //CONFIG_CONCURRENT_MODE + + DBG_871X("CH=%d, BW=%d, offset=%d\n", cur_channel, cur_bwmode, cur_ch_offset); + + // + pmlmeext->cur_channel = cur_channel; + pmlmeext->cur_bwmode = cur_bwmode; + pmlmeext->cur_ch_offset = cur_ch_offset; +#endif //CONFIG_DUALMAC_CONCURRENT + pmlmeext->cur_wireless_mode = pmlmepriv->cur_network.network_type; + + //update cur_wireless_mode + update_wireless_mode(padapter); + + //update RRSR after set channel and bandwidth + UpdateBrateTbl(padapter, pnetwork->SupportedRates); + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates); + + //udpate capability after cur_wireless_mode updated + update_capinfo(padapter, rtw_get_capability((WLAN_BSSID_EX *)pnetwork)); + + //let pnetwork_mlmeext == pnetwork_mlme. + _rtw_memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); + +#ifdef CONFIG_P2P + _rtw_memcpy(pwdinfo->p2p_group_ssid, pnetwork->Ssid.Ssid, pnetwork->Ssid.SsidLength); + pwdinfo->p2p_group_ssid_len = pnetwork->Ssid.SsidLength; +#endif //CONFIG_P2P + + if(_TRUE == pmlmeext->bstart_bss) + { + update_beacon(padapter, _TIM_IE_, NULL, _FALSE); + +#ifndef CONFIG_INTERRUPT_BASED_TXBCN //other case will tx beacon when bcn interrupt coming in. +#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI) + //issue beacon frame + if(send_beacon(padapter)==_FAIL) + { + DBG_871X("issue_beacon, fail!\n"); + } +#endif +#endif //!CONFIG_INTERRUPT_BASED_TXBCN + + } + + + //update bc/mc sta_info + update_bmc_sta(padapter); + + //pmlmeext->bstart_bss = _TRUE; + +} + +int rtw_check_beacon_data(_adapter *padapter, u8 *pbuf, int len) +{ + int ret=_SUCCESS; + u8 *p; + u8 *pHT_caps_ie=NULL; + u8 *pHT_info_ie=NULL; + struct sta_info *psta = NULL; + u16 cap, ht_cap=_FALSE; + uint ie_len = 0; + int group_cipher, pairwise_cipher; + u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX]; + int supportRateNum = 0; + u8 OUI1[] = {0x00, 0x50, 0xf2,0x01}; + u8 wps_oui[4]={0x0,0x50,0xf2,0x04}; + u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + WLAN_BSSID_EX *pbss_network = (WLAN_BSSID_EX *)&pmlmepriv->cur_network.network; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *ie = pbss_network->IEs; + + + /* SSID */ + /* Supported rates */ + /* DS Params */ + /* WLAN_EID_COUNTRY */ + /* ERP Information element */ + /* Extended supported rates */ + /* WPA/WPA2 */ + /* Wi-Fi Wireless Multimedia Extensions */ + /* ht_capab, ht_oper */ + /* WPS IE */ + + DBG_871X("%s, len=%d\n", __FUNCTION__, len); + + if(check_fwstate(pmlmepriv, WIFI_AP_STATE) != _TRUE) + return _FAIL; + + + if(len>MAX_IE_SZ) + return _FAIL; + + pbss_network->IELength = len; + + _rtw_memset(ie, 0, MAX_IE_SZ); + + _rtw_memcpy(ie, pbuf, pbss_network->IELength); + + + if(pbss_network->InfrastructureMode!=Ndis802_11APMode) + return _FAIL; + + pbss_network->Rssi = 0; + + _rtw_memcpy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)), ETH_ALEN); + + //beacon interval + p = rtw_get_beacon_interval_from_ie(ie);//ie + 8; // 8: TimeStamp, 2: Beacon Interval 2:Capability + //pbss_network->Configuration.BeaconPeriod = le16_to_cpu(*(unsigned short*)p); + pbss_network->Configuration.BeaconPeriod = RTW_GET_LE16(p); + + //capability + //cap = *(unsigned short *)rtw_get_capability_from_ie(ie); + //cap = le16_to_cpu(cap); + cap = RTW_GET_LE16(ie); + + //SSID + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->IELength -_BEACON_IE_OFFSET_)); + if(p && ie_len>0) + { + _rtw_memset(&pbss_network->Ssid, 0, sizeof(NDIS_802_11_SSID)); + _rtw_memcpy(pbss_network->Ssid.Ssid, (p + 2), ie_len); + pbss_network->Ssid.SsidLength = ie_len; + } + + //chnnel + channel = 0; + pbss_network->Configuration.Length = 0; + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if(p && ie_len>0) + channel = *(p + 2); + + pbss_network->Configuration.DSConfig = channel; + + + _rtw_memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); + // get supported rates + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p != NULL) + { + _rtw_memcpy(supportRate, p+2, ie_len); + supportRateNum = ie_len; + } + + //get ext_supported rates + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_); + if (p != NULL) + { + _rtw_memcpy(supportRate+supportRateNum, p+2, ie_len); + supportRateNum += ie_len; + + } + + network_type = rtw_check_network_type(supportRate, supportRateNum, channel); + + rtw_set_supported_rate(pbss_network->SupportedRates, network_type); + + + //parsing ERP_IE + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if(p && ie_len>0) + { + ERP_IE_handler(padapter, (PNDIS_802_11_VARIABLE_IEs)p); + } + + //update privacy/security + if (cap & BIT(4)) + pbss_network->Privacy = 1; + else + pbss_network->Privacy = 0; + + psecuritypriv->wpa_psk = 0; + + //wpa2 + group_cipher = 0; pairwise_cipher = 0; + psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; + psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if(p && ie_len>0) + { + if(rtw_parse_wpa2_ie(p, ie_len+2, &group_cipher, &pairwise_cipher) == _SUCCESS) + { + psecuritypriv->dot11AuthAlgrthm= dot11AuthAlgrthm_8021X; + + psecuritypriv->dot8021xalg = 1;//psk, todo:802.1x + psecuritypriv->wpa_psk |= BIT(1); + + psecuritypriv->wpa2_group_cipher = group_cipher; + psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher; +#if 0 + switch(group_cipher) + { + case WPA_CIPHER_NONE: + psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; + break; + case WPA_CIPHER_WEP40: + psecuritypriv->wpa2_group_cipher = _WEP40_; + break; + case WPA_CIPHER_TKIP: + psecuritypriv->wpa2_group_cipher = _TKIP_; + break; + case WPA_CIPHER_CCMP: + psecuritypriv->wpa2_group_cipher = _AES_; + break; + case WPA_CIPHER_WEP104: + psecuritypriv->wpa2_group_cipher = _WEP104_; + break; + } + + switch(pairwise_cipher) + { + case WPA_CIPHER_NONE: + psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; + break; + case WPA_CIPHER_WEP40: + psecuritypriv->wpa2_pairwise_cipher = _WEP40_; + break; + case WPA_CIPHER_TKIP: + psecuritypriv->wpa2_pairwise_cipher = _TKIP_; + break; + case WPA_CIPHER_CCMP: + psecuritypriv->wpa2_pairwise_cipher = _AES_; + break; + case WPA_CIPHER_WEP104: + psecuritypriv->wpa2_pairwise_cipher = _WEP104_; + break; + } +#endif + } + + } + + //wpa + ie_len = 0; + group_cipher = 0; pairwise_cipher = 0; + psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; + psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; + for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) + { + p = rtw_get_ie(p, _SSN_IE_1_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + if ((p) && (_rtw_memcmp(p+2, OUI1, 4))) + { + if(rtw_parse_wpa_ie(p, ie_len+2, &group_cipher, &pairwise_cipher) == _SUCCESS) + { + psecuritypriv->dot11AuthAlgrthm= dot11AuthAlgrthm_8021X; + + psecuritypriv->dot8021xalg = 1;//psk, todo:802.1x + + psecuritypriv->wpa_psk |= BIT(0); + + psecuritypriv->wpa_group_cipher = group_cipher; + psecuritypriv->wpa_pairwise_cipher = pairwise_cipher; + +#if 0 + switch(group_cipher) + { + case WPA_CIPHER_NONE: + psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; + break; + case WPA_CIPHER_WEP40: + psecuritypriv->wpa_group_cipher = _WEP40_; + break; + case WPA_CIPHER_TKIP: + psecuritypriv->wpa_group_cipher = _TKIP_; + break; + case WPA_CIPHER_CCMP: + psecuritypriv->wpa_group_cipher = _AES_; + break; + case WPA_CIPHER_WEP104: + psecuritypriv->wpa_group_cipher = _WEP104_; + break; + } + + switch(pairwise_cipher) + { + case WPA_CIPHER_NONE: + psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; + break; + case WPA_CIPHER_WEP40: + psecuritypriv->wpa_pairwise_cipher = _WEP40_; + break; + case WPA_CIPHER_TKIP: + psecuritypriv->wpa_pairwise_cipher = _TKIP_; + break; + case WPA_CIPHER_CCMP: + psecuritypriv->wpa_pairwise_cipher = _AES_; + break; + case WPA_CIPHER_WEP104: + psecuritypriv->wpa_pairwise_cipher = _WEP104_; + break; + } +#endif + } + + break; + + } + + if ((p == NULL) || (ie_len == 0)) + { + break; + } + + } + + //wmm + ie_len = 0; + pmlmepriv->qospriv.qos_option = 0; + if(pregistrypriv->wmm_enable) + { + for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) + { + p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + if((p) && _rtw_memcmp(p+2, WMM_PARA_IE, 6)) + { + pmlmepriv->qospriv.qos_option = 1; + + *(p+8) |= BIT(7);//QoS Info, support U-APSD + + /* disable all ACM bits since the WMM admission control is not supported */ + *(p + 10) &= ~BIT(4); /* BE */ + *(p + 14) &= ~BIT(4); /* BK */ + *(p + 18) &= ~BIT(4); /* VI */ + *(p + 22) &= ~BIT(4); /* VO */ + + break; + } + + if ((p == NULL) || (ie_len == 0)) + { + break; + } + } + } + + //parsing HT_CAP_IE + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if(p && ie_len>0) + { + u8 rf_type; + + struct rtw_ieee80211_ht_cap *pht_cap = (struct rtw_ieee80211_ht_cap *)(p+2); + + pHT_caps_ie=p; + + + ht_cap = _TRUE; + network_type |= WIRELESS_11_24N; + + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + if((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || + (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) + { + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); + } + else + { + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); + } + + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03); //set Max Rx AMPDU size to 64K + + if(rf_type == RF_1T1R) + { + pht_cap->supp_mcs_set[0] = 0xff; + pht_cap->supp_mcs_set[1] = 0x0; + } + + _rtw_memcpy(&pmlmepriv->htpriv.ht_cap, p+2, ie_len); + + } + + //parsing HT_INFO_IE + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if(p && ie_len>0) + { + pHT_info_ie=p; + } + + switch(network_type) + { + case WIRELESS_11B: + pbss_network->NetworkTypeInUse = Ndis802_11DS; + break; + case WIRELESS_11G: + case WIRELESS_11BG: + case WIRELESS_11G_24N: + case WIRELESS_11BG_24N: + pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; + break; + case WIRELESS_11A: + pbss_network->NetworkTypeInUse = Ndis802_11OFDM5; + break; + default : + pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; + break; + } + + pmlmepriv->cur_network.network_type = network_type; + + + pmlmepriv->htpriv.ht_option = _FALSE; +#ifdef CONFIG_80211N_HT + if( (psecuritypriv->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || + (psecuritypriv->wpa_pairwise_cipher&WPA_CIPHER_TKIP)) + { + //todo: + //ht_cap = _FALSE; + } + + //ht_cap + if(pregistrypriv->ht_enable && ht_cap==_TRUE) + { + pmlmepriv->htpriv.ht_option = _TRUE; + pmlmepriv->qospriv.qos_option = 1; + + if(pregistrypriv->ampdu_enable==1) + { + pmlmepriv->htpriv.ampdu_enable = _TRUE; + } + + HT_caps_handler(padapter, (PNDIS_802_11_VARIABLE_IEs)pHT_caps_ie); + + HT_info_handler(padapter, (PNDIS_802_11_VARIABLE_IEs)pHT_info_ie); + } +#endif + + + pbss_network->Length = get_WLAN_BSSID_EX_sz((WLAN_BSSID_EX *)pbss_network); + + //issue beacon to start bss network + start_bss_network(padapter, (u8*)pbss_network); + + + //alloc sta_info for ap itself + psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress); + if(!psta) + { + psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress); + if (psta == NULL) + { + return _FAIL; + } + } + psta->state |= WIFI_AP_STATE; //Aries, add,fix bug of flush_cam_entry at STOP AP mode , 0724 + rtw_indicate_connect( padapter); + + pmlmepriv->cur_network.join_res = _TRUE;//for check if already set beacon + + //update bc/mc sta_info + //update_bmc_sta(padapter); + + return ret; + +} + +void rtw_set_macaddr_acl(_adapter *padapter, int mode) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + + DBG_871X("%s, mode=%d\n", __func__, mode); + + pacl_list->mode = mode; +} + +int rtw_acl_add_sta(_adapter *padapter, u8 *addr) +{ + _irqL irqL; + _list *plist, *phead; + u8 added = _FALSE; + int i, ret=0; + struct rtw_wlan_acl_node *paclnode; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + _queue *pacl_node_q =&pacl_list->acl_node_q; + + DBG_871X("%s(acl_num=%d)=" MAC_FMT "\n", __func__, pacl_list->num, MAC_ARG(addr)); + + if((NUM_ACL-1) < pacl_list->num) + return (-1); + + + _enter_critical_bh(&(pacl_node_q->lock), &irqL); + + phead = get_list_head(pacl_node_q); + plist = get_next(phead); + + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) + { + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + + if(_rtw_memcmp(paclnode->addr, addr, ETH_ALEN)) + { + if(paclnode->valid == _TRUE) + { + added = _TRUE; + DBG_871X("%s, sta has been added\n", __func__); + break; + } + } + } + + _exit_critical_bh(&(pacl_node_q->lock), &irqL); + + + if(added == _TRUE) + return ret; + + + _enter_critical_bh(&(pacl_node_q->lock), &irqL); + + for(i=0; i< NUM_ACL; i++) + { + paclnode = &pacl_list->aclnode[i]; + + if(paclnode->valid == _FALSE) + { + _rtw_init_listhead(&paclnode->list); + + _rtw_memcpy(paclnode->addr, addr, ETH_ALEN); + + paclnode->valid = _TRUE; + + rtw_list_insert_tail(&paclnode->list, get_list_head(pacl_node_q)); + + pacl_list->num++; + + break; + } + } + + DBG_871X("%s, acl_num=%d\n", __func__, pacl_list->num); + + _exit_critical_bh(&(pacl_node_q->lock), &irqL); + + return ret; +} + +int rtw_acl_remove_sta(_adapter *padapter, u8 *addr) +{ + _irqL irqL; + _list *plist, *phead; + int i, ret=0; + struct rtw_wlan_acl_node *paclnode; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + _queue *pacl_node_q =&pacl_list->acl_node_q; + + DBG_871X("%s(acl_num=%d)=" MAC_FMT "\n", __func__, pacl_list->num, MAC_ARG(addr)); + + _enter_critical_bh(&(pacl_node_q->lock), &irqL); + + phead = get_list_head(pacl_node_q); + plist = get_next(phead); + + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) + { + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + + if(_rtw_memcmp(paclnode->addr, addr, ETH_ALEN)) + { + if(paclnode->valid == _TRUE) + { + paclnode->valid = _FALSE; + + rtw_list_delete(&paclnode->list); + + pacl_list->num--; + } + } + } + + _exit_critical_bh(&(pacl_node_q->lock), &irqL); + + DBG_871X("%s, acl_num=%d\n", __func__, pacl_list->num); + + return ret; + +} + +#ifdef CONFIG_NATIVEAP_MLME + +static void update_bcn_fixed_ie(_adapter *padapter) +{ + DBG_871X("%s\n", __FUNCTION__); + +} + +static void update_bcn_erpinfo_ie(_adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + WLAN_BSSID_EX *pnetwork = &(pmlmeinfo->network); + unsigned char *p, *ie = pnetwork->IEs; + u32 len = 0; + + DBG_871X("%s, ERP_enable=%d\n", __FUNCTION__, pmlmeinfo->ERP_enable); + + if(!pmlmeinfo->ERP_enable) + return; + + //parsing ERP_IE + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + if(p && len>0) + { + PNDIS_802_11_VARIABLE_IEs pIE = (PNDIS_802_11_VARIABLE_IEs)p; + + if (pmlmepriv->num_sta_non_erp == 1) + pIE->data[0] |= RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION; + else + pIE->data[0] &= ~(RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION); + + if(pmlmepriv->num_sta_no_short_preamble > 0) + pIE->data[0] |= RTW_ERP_INFO_BARKER_PREAMBLE_MODE; + else + pIE->data[0] &= ~(RTW_ERP_INFO_BARKER_PREAMBLE_MODE); + + ERP_IE_handler(padapter, pIE); + } + +} + +static void update_bcn_htcap_ie(_adapter *padapter) +{ + DBG_871X("%s\n", __FUNCTION__); + +} + +static void update_bcn_htinfo_ie(_adapter *padapter) +{ + DBG_871X("%s\n", __FUNCTION__); + +} + +static void update_bcn_rsn_ie(_adapter *padapter) +{ + DBG_871X("%s\n", __FUNCTION__); + +} + +static void update_bcn_wpa_ie(_adapter *padapter) +{ + DBG_871X("%s\n", __FUNCTION__); + +} + +static void update_bcn_wmm_ie(_adapter *padapter) +{ + DBG_871X("%s\n", __FUNCTION__); + +} + +static void update_bcn_wps_ie(_adapter *padapter) +{ + u8 *pwps_ie=NULL, *pwps_ie_src, *premainder_ie, *pbackup_remainder_ie=NULL; + uint wps_ielen=0, wps_offset, remainder_ielen; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + WLAN_BSSID_EX *pnetwork = &(pmlmeinfo->network); + unsigned char *ie = pnetwork->IEs; + u32 ielen = pnetwork->IELength; + + + DBG_871X("%s\n", __FUNCTION__); + + pwps_ie = rtw_get_wps_ie(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + + if(pwps_ie==NULL || wps_ielen==0) + return; + + wps_offset = (uint)(pwps_ie-ie); + + premainder_ie = pwps_ie + wps_ielen; + + remainder_ielen = ielen - wps_offset - wps_ielen; + + if(remainder_ielen>0) + { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if(pbackup_remainder_ie) + _rtw_memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + + pwps_ie_src = pmlmepriv->wps_beacon_ie; + if(pwps_ie_src == NULL) + return; + + + wps_ielen = (uint)pwps_ie_src[1];//to get ie data len + if((wps_offset+wps_ielen+2+remainder_ielen)<=MAX_IE_SZ) + { + _rtw_memcpy(pwps_ie, pwps_ie_src, wps_ielen+2); + pwps_ie += (wps_ielen+2); + + if(pbackup_remainder_ie) + _rtw_memcpy(pwps_ie, pbackup_remainder_ie, remainder_ielen); + + //update IELength + pnetwork->IELength = wps_offset + (wps_ielen+2) + remainder_ielen; + } + + if(pbackup_remainder_ie) + rtw_mfree(pbackup_remainder_ie, remainder_ielen); + +} + +static void update_bcn_p2p_ie(_adapter *padapter) +{ + +} + +static void update_bcn_vendor_spec_ie(_adapter *padapter, u8*oui) +{ + DBG_871X("%s\n", __FUNCTION__); + + if(_rtw_memcmp(RTW_WPA_OUI, oui, 4)) + { + update_bcn_wpa_ie(padapter); + } + else if(_rtw_memcmp(WMM_OUI, oui, 4)) + { + update_bcn_wmm_ie(padapter); + } + else if(_rtw_memcmp(WPS_OUI, oui, 4)) + { + update_bcn_wps_ie(padapter); + } + else if(_rtw_memcmp(P2P_OUI, oui, 4)) + { + update_bcn_p2p_ie(padapter); + } + else + { + DBG_871X("unknown OUI type!\n"); + } + + +} + +void update_beacon(_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) +{ + _irqL irqL; + struct mlme_priv *pmlmepriv; + struct mlme_ext_priv *pmlmeext; + //struct mlme_ext_info *pmlmeinfo; + + //DBG_871X("%s\n", __FUNCTION__); + + if(!padapter) + return; + + pmlmepriv = &(padapter->mlmepriv); + pmlmeext = &(padapter->mlmeextpriv); + //pmlmeinfo = &(pmlmeext->mlmext_info); + + if(_FALSE == pmlmeext->bstart_bss) + return; + + _enter_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); + + switch(ie_id) + { + case 0xFF: + + update_bcn_fixed_ie(padapter);//8: TimeStamp, 2: Beacon Interval 2:Capability + + break; + + case _TIM_IE_: + + update_BCNTIM(padapter); + + break; + + case _ERPINFO_IE_: + + update_bcn_erpinfo_ie(padapter); + + break; + + case _HT_CAPABILITY_IE_: + + update_bcn_htcap_ie(padapter); + + break; + + case _RSN_IE_2_: + + update_bcn_rsn_ie(padapter); + + break; + + case _HT_ADD_INFO_IE_: + + update_bcn_htinfo_ie(padapter); + + break; + + case _VENDOR_SPECIFIC_IE_: + + update_bcn_vendor_spec_ie(padapter, oui); + + break; + + default: + break; + } + + pmlmepriv->update_bcn = _TRUE; + + _exit_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); + +#ifndef CONFIG_INTERRUPT_BASED_TXBCN +#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI) + if(tx) + { + //send_beacon(padapter);//send_beacon must execute on TSR level + set_tx_beacon_cmd(padapter); + } +#else + { + //PCI will issue beacon when BCN interrupt occurs. + } +#endif +#endif //!CONFIG_INTERRUPT_BASED_TXBCN + +} + +#ifdef CONFIG_80211N_HT + +/* +op_mode +Set to 0 (HT pure) under the followign conditions + - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or + - all STAs in the BSS are 20 MHz HT in 20 MHz BSS +Set to 1 (HT non-member protection) if there may be non-HT STAs + in both the primary and the secondary channel +Set to 2 if only HT STAs are associated in BSS, + however and at least one 20 MHz HT STA is associated +Set to 3 (HT mixed mode) when one or more non-HT STAs are associated + (currently non-GF HT station is considered as non-HT STA also) +*/ +static int rtw_ht_operation_update(_adapter *padapter) +{ + u16 cur_op_mode, new_op_mode; + int op_mode_changes = 0; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; + + if(pmlmepriv->htpriv.ht_option == _TRUE) + return 0; + + //if (!iface->conf->ieee80211n || iface->conf->ht_op_mode_fixed) + // return 0; + + DBG_871X("%s current operation mode=0x%X\n", + __FUNCTION__, pmlmepriv->ht_op_mode); + + if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) + && pmlmepriv->num_sta_ht_no_gf) { + pmlmepriv->ht_op_mode |= + HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + op_mode_changes++; + } else if ((pmlmepriv->ht_op_mode & + HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) && + pmlmepriv->num_sta_ht_no_gf == 0) { + pmlmepriv->ht_op_mode &= + ~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + op_mode_changes++; + } + + if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + (pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) { + pmlmepriv->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + op_mode_changes++; + } else if ((pmlmepriv->ht_op_mode & + HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) { + pmlmepriv->ht_op_mode &= + ~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + op_mode_changes++; + } + + /* Note: currently we switch to the MIXED op mode if HT non-greenfield + * station is associated. Probably it's a theoretical case, since + * it looks like all known HT STAs support greenfield. + */ + new_op_mode = 0; + if (pmlmepriv->num_sta_no_ht || + (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) + new_op_mode = OP_MODE_MIXED; + else if ((phtpriv_ap->ht_cap.cap_info & IEEE80211_HT_CAP_SUP_WIDTH) + && pmlmepriv->num_sta_ht_20mhz) + new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; + else if (pmlmepriv->olbc_ht) + new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS; + else + new_op_mode = OP_MODE_PURE; + + cur_op_mode = pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_OP_MODE_MASK; + if (cur_op_mode != new_op_mode) { + pmlmepriv->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK; + pmlmepriv->ht_op_mode |= new_op_mode; + op_mode_changes++; + } + + DBG_871X("%s new operation mode=0x%X changes=%d\n", + __FUNCTION__, pmlmepriv->ht_op_mode, op_mode_changes); + + return op_mode_changes; + +} + +#endif /* CONFIG_80211N_HT */ + +void associated_clients_update(_adapter *padapter, u8 updated) +{ + //update associcated stations cap. + if(updated == _TRUE) + { + _irqL irqL; + _list *phead, *plist; + struct sta_info *psta=NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + //check asoc_queue + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) + { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + + plist = get_next(plist); + + VCS_update(padapter, psta); + } + + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + } + +} + +/* called > TSR LEVEL for USB or SDIO Interface*/ +void bss_cap_update_on_sta_join(_adapter *padapter, struct sta_info *psta) +{ + u8 beacon_updated = _FALSE; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + +#if 0 + if (!(psta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) && + !psta->no_short_preamble_set) { + psta->no_short_preamble_set = 1; + pmlmepriv->num_sta_no_short_preamble++; + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_preamble == 1)) + ieee802_11_set_beacons(hapd->iface); + } +#endif + + + if(!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) + { + if(!psta->no_short_preamble_set) + { + psta->no_short_preamble_set = 1; + + pmlmepriv->num_sta_no_short_preamble++; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_preamble == 1)) + { + beacon_updated = _TRUE; + update_beacon(padapter, 0xFF, NULL, _TRUE); + } + + } + } + else + { + if(psta->no_short_preamble_set) + { + psta->no_short_preamble_set = 0; + + pmlmepriv->num_sta_no_short_preamble--; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_preamble == 0)) + { + beacon_updated = _TRUE; + update_beacon(padapter, 0xFF, NULL, _TRUE); + } + + } + } + +#if 0 + if (psta->flags & WLAN_STA_NONERP && !psta->nonerp_set) { + psta->nonerp_set = 1; + pmlmepriv->num_sta_non_erp++; + if (pmlmepriv->num_sta_non_erp == 1) + ieee802_11_set_beacons(hapd->iface); + } +#endif + + if(psta->flags & WLAN_STA_NONERP) + { + if(!psta->nonerp_set) + { + psta->nonerp_set = 1; + + pmlmepriv->num_sta_non_erp++; + + if (pmlmepriv->num_sta_non_erp == 1) + { + beacon_updated = _TRUE; + update_beacon(padapter, _ERPINFO_IE_, NULL, _TRUE); + } + } + + } + else + { + if(psta->nonerp_set) + { + psta->nonerp_set = 0; + + pmlmepriv->num_sta_non_erp--; + + if (pmlmepriv->num_sta_non_erp == 0) + { + beacon_updated = _TRUE; + update_beacon(padapter, _ERPINFO_IE_, NULL, _TRUE); + } + } + + } + + +#if 0 + if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT) && + !psta->no_short_slot_time_set) { + psta->no_short_slot_time_set = 1; + pmlmepriv->num_sta_no_short_slot_time++; + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_slot_time == 1)) + ieee802_11_set_beacons(hapd->iface); + } +#endif + + if(!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) + { + if(!psta->no_short_slot_time_set) + { + psta->no_short_slot_time_set = 1; + + pmlmepriv->num_sta_no_short_slot_time++; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_slot_time == 1)) + { + beacon_updated = _TRUE; + update_beacon(padapter, 0xFF, NULL, _TRUE); + } + + } + } + else + { + if(psta->no_short_slot_time_set) + { + psta->no_short_slot_time_set = 0; + + pmlmepriv->num_sta_no_short_slot_time--; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_slot_time == 0)) + { + beacon_updated = _TRUE; + update_beacon(padapter, 0xFF, NULL, _TRUE); + } + } + } + +#ifdef CONFIG_80211N_HT + + if (psta->flags & WLAN_STA_HT) + { + u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info); + + DBG_871X("HT: STA " MAC_FMT " HT Capabilities " + "Info: 0x%04x\n", MAC_ARG(psta->hwaddr), ht_capab); + + if (psta->no_ht_set) { + psta->no_ht_set = 0; + pmlmepriv->num_sta_no_ht--; + } + + if ((ht_capab & IEEE80211_HT_CAP_GRN_FLD) == 0) { + if (!psta->no_ht_gf_set) { + psta->no_ht_gf_set = 1; + pmlmepriv->num_sta_ht_no_gf++; + } + DBG_871X("%s STA " MAC_FMT " - no " + "greenfield, num of non-gf stations %d\n", + __FUNCTION__, MAC_ARG(psta->hwaddr), + pmlmepriv->num_sta_ht_no_gf); + } + + if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH) == 0) { + if (!psta->ht_20mhz_set) { + psta->ht_20mhz_set = 1; + pmlmepriv->num_sta_ht_20mhz++; + } + DBG_871X("%s STA " MAC_FMT " - 20 MHz HT, " + "num of 20MHz HT STAs %d\n", + __FUNCTION__, MAC_ARG(psta->hwaddr), + pmlmepriv->num_sta_ht_20mhz); + } + + } + else + { + if (!psta->no_ht_set) { + psta->no_ht_set = 1; + pmlmepriv->num_sta_no_ht++; + } + if(pmlmepriv->htpriv.ht_option == _TRUE) { + DBG_871X("%s STA " MAC_FMT + " - no HT, num of non-HT stations %d\n", + __FUNCTION__, MAC_ARG(psta->hwaddr), + pmlmepriv->num_sta_no_ht); + } + } + + if (rtw_ht_operation_update(padapter) > 0) + { + update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, _FALSE); + update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, _TRUE); + } + +#endif /* CONFIG_80211N_HT */ + + //update associcated stations cap. + associated_clients_update(padapter, beacon_updated); + + DBG_871X("%s, updated=%d\n", __func__, beacon_updated); + +} + +u8 bss_cap_update_on_sta_leave(_adapter *padapter, struct sta_info *psta) +{ + u8 beacon_updated = _FALSE; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + if(!psta) + return beacon_updated; + + if (psta->no_short_preamble_set) { + psta->no_short_preamble_set = 0; + pmlmepriv->num_sta_no_short_preamble--; + if (pmlmeext->cur_wireless_mode > WIRELESS_11B + && pmlmepriv->num_sta_no_short_preamble == 0) + { + beacon_updated = _TRUE; + update_beacon(padapter, 0xFF, NULL, _TRUE); + } + } + + if (psta->nonerp_set) { + psta->nonerp_set = 0; + pmlmepriv->num_sta_non_erp--; + if (pmlmepriv->num_sta_non_erp == 0) + { + beacon_updated = _TRUE; + update_beacon(padapter, _ERPINFO_IE_, NULL, _TRUE); + } + } + + if (psta->no_short_slot_time_set) { + psta->no_short_slot_time_set = 0; + pmlmepriv->num_sta_no_short_slot_time--; + if (pmlmeext->cur_wireless_mode > WIRELESS_11B + && pmlmepriv->num_sta_no_short_slot_time == 0) + { + beacon_updated = _TRUE; + update_beacon(padapter, 0xFF, NULL, _TRUE); + } + } + +#ifdef CONFIG_80211N_HT + + if (psta->no_ht_gf_set) { + psta->no_ht_gf_set = 0; + pmlmepriv->num_sta_ht_no_gf--; + } + + if (psta->no_ht_set) { + psta->no_ht_set = 0; + pmlmepriv->num_sta_no_ht--; + } + + if (psta->ht_20mhz_set) { + psta->ht_20mhz_set = 0; + pmlmepriv->num_sta_ht_20mhz--; + } + + if (rtw_ht_operation_update(padapter) > 0) + { + update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, _FALSE); + update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, _TRUE); + } + +#endif /* CONFIG_80211N_HT */ + + //update associcated stations cap. + //associated_clients_update(padapter, beacon_updated); //move it to avoid deadlock + + DBG_871X("%s, updated=%d\n", __func__, beacon_updated); + + return beacon_updated; + +} + +u8 ap_free_sta(_adapter *padapter, struct sta_info *psta, bool active, u16 reason) +{ + _irqL irqL; + u8 beacon_updated = _FALSE; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct sta_priv *pstapriv = &padapter->stapriv; + + if(!psta) + return beacon_updated; + + if (active == _TRUE) + { +#ifdef CONFIG_80211N_HT + //tear down Rx AMPDU + send_delba(padapter, 0, psta->hwaddr);// recipient + + //tear down TX AMPDU + send_delba(padapter, 1, psta->hwaddr);// // originator + +#endif //CONFIG_80211N_HT + + issue_deauth(padapter, psta->hwaddr, reason); + } + + psta->htpriv.agg_enable_bitmap = 0x0;//reset + psta->htpriv.candidate_tid_bitmap = 0x0;//reset + + + //report_del_sta_event(padapter, psta->hwaddr, reason); + + //clear cam entry / key + //clear_cam_entry(padapter, (psta->mac_id + 3)); + rtw_clearstakey_cmd(padapter, (u8*)psta, (u8)(psta->mac_id + 3), _TRUE); + + + _enter_critical_bh(&psta->lock, &irqL); + psta->state &= ~_FW_LINKED; + _exit_critical_bh(&psta->lock, &irqL); + + #ifdef CONFIG_IOCTL_CFG80211 + if (1) { + #ifdef COMPAT_KERNEL_RELEASE + rtw_cfg80211_indicate_sta_disassoc(padapter, psta->hwaddr, reason); + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) && !defined(CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER) + rtw_cfg80211_indicate_sta_disassoc(padapter, psta->hwaddr, reason); + #else //(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) && !defined(CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER) + /* will call rtw_cfg80211_indicate_sta_disassoc() in cmd_thread for old API context */ + #endif //(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) && !defined(CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER) + } else + #endif //CONFIG_IOCTL_CFG80211 + { + rtw_indicate_sta_disassoc_event(padapter, psta); + } + + report_del_sta_event(padapter, psta->hwaddr, reason); + + beacon_updated = bss_cap_update_on_sta_leave(padapter, psta); + + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + rtw_free_stainfo(padapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + + + return beacon_updated; + +} + +int rtw_ap_inform_ch_switch(_adapter *padapter, u8 new_ch, u8 ch_offset) +{ + _irqL irqL; + _list *phead, *plist; + int ret=0; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 bc_addr[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; + + if((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return ret; + + DBG_871X(FUNC_NDEV_FMT" with ch:%u, offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), new_ch, ch_offset); + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + /* for each sta in asoc_queue */ + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) + { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + plist = get_next(plist); + + issue_action_spct_ch_switch(padapter, psta->hwaddr, new_ch, ch_offset); + psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2); + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + issue_action_spct_ch_switch(padapter, bc_addr, new_ch, ch_offset); + + return ret; +} + +int rtw_sta_flush(_adapter *padapter) +{ + _irqL irqL; + _list *phead, *plist; + int ret=0; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 bc_addr[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 chk_alive_num = 0; + char chk_alive_list[NUM_STA]; + int i; + + DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); + + if((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return ret; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) { + int stainfo_offset; + + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + plist = get_next(plist); + + /* Remove sta from asoc_list */ + rtw_list_delete(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + + /* Keep sta for ap_free_sta() beyond this asoc_list loop */ + stainfo_offset = rtw_stainfo_offset(pstapriv, psta); + if (stainfo_offset_valid(stainfo_offset)) { + chk_alive_list[chk_alive_num++] = stainfo_offset; + } + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + + /* For each sta in chk_alive_list, call ap_free_sta */ + for (i = 0; i < chk_alive_num; i++) { + psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]); + ap_free_sta(padapter, psta, _TRUE, WLAN_REASON_DEAUTH_LEAVING); + } + + issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); + + associated_clients_update(padapter, _TRUE); + + return ret; + +} + +/* called > TSR LEVEL for USB or SDIO Interface*/ +void sta_info_update(_adapter *padapter, struct sta_info *psta) +{ + int flags = psta->flags; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + + //update wmm cap. + if(WLAN_STA_WME&flags) + psta->qos_option = 1; + else + psta->qos_option = 0; + + if(pmlmepriv->qospriv.qos_option == 0) + psta->qos_option = 0; + + +#ifdef CONFIG_80211N_HT + //update 802.11n ht cap. + if(WLAN_STA_HT&flags) + { + psta->htpriv.ht_option = _TRUE; + psta->qos_option = 1; + } + else + { + psta->htpriv.ht_option = _FALSE; + } + + if(pmlmepriv->htpriv.ht_option == _FALSE) + psta->htpriv.ht_option = _FALSE; +#endif + + + update_sta_info_apmode(padapter, psta); + + +} + +/* called >= TSR LEVEL for USB or SDIO Interface*/ +void ap_sta_info_defer_update(_adapter *padapter, struct sta_info *psta) +{ + if(psta->state & _FW_LINKED) + { + //add ratid + add_RATid(padapter, psta); + } +} + +/* restore hw setting from sw data structures */ +void rtw_ap_restore_network(_adapter *padapter) +{ + struct mlme_priv *mlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct sta_priv * pstapriv = &padapter->stapriv; + struct sta_info *psta; + struct security_priv* psecuritypriv=&(padapter->securitypriv); + _irqL irqL; + _list *phead, *plist; + u8 chk_alive_num = 0; + char chk_alive_list[NUM_STA]; + int i; + + rtw_setopmode_cmd(padapter, Ndis802_11APMode); + + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + start_bss_network(padapter, (u8*)&mlmepriv->cur_network.network); + + if((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || + (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) + { + /* restore group key, WEP keys is restored in ips_leave() */ + rtw_set_key(padapter, psecuritypriv, psecuritypriv->dot118021XGrpKeyid, 0); + } + + /* per sta pairwise key and settings */ + if((padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_) && + (padapter->securitypriv.dot11PrivacyAlgrthm != _AES_)) { + return; + } + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) { + int stainfo_offset; + + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + plist = get_next(plist); + + stainfo_offset = rtw_stainfo_offset(pstapriv, psta); + if (stainfo_offset_valid(stainfo_offset)) { + chk_alive_list[chk_alive_num++] = stainfo_offset; + } + } + + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + for (i = 0; i < chk_alive_num; i++) { + psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]); + + if (psta == NULL) { + DBG_871X(FUNC_ADPT_FMT" sta_info is null\n", FUNC_ADPT_ARG(padapter)); + } else if (psta->state &_FW_LINKED) { + Update_RA_Entry(padapter, psta->mac_id); + //pairwise key + rtw_setstakey_cmd(padapter, (unsigned char *)psta, _TRUE); + } + } + +} + +void start_ap_mode(_adapter *padapter) +{ + int i; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + + pmlmepriv->update_bcn = _FALSE; + + //init_mlme_ap_info(padapter); + pmlmeext->bstart_bss = _FALSE; + + pmlmepriv->num_sta_non_erp = 0; + + pmlmepriv->num_sta_no_short_slot_time = 0; + + pmlmepriv->num_sta_no_short_preamble = 0; + + pmlmepriv->num_sta_ht_no_gf = 0; + + pmlmepriv->num_sta_no_ht = 0; + + pmlmepriv->num_sta_ht_20mhz = 0; + + pmlmepriv->olbc = _FALSE; + + pmlmepriv->olbc_ht = _FALSE; + +#ifdef CONFIG_80211N_HT + pmlmepriv->ht_op_mode = 0; +#endif + + for(i=0; ista_aid[i] = NULL; + + pmlmepriv->wps_beacon_ie = NULL; + pmlmepriv->wps_probe_resp_ie = NULL; + pmlmepriv->wps_assoc_resp_ie = NULL; + + pmlmepriv->p2p_beacon_ie = NULL; + pmlmepriv->p2p_probe_resp_ie = NULL; + + + //for ACL + _rtw_init_listhead(&(pacl_list->acl_node_q.queue)); + pacl_list->num = 0; + pacl_list->mode = 0; + for(i = 0; i < NUM_ACL; i++) + { + _rtw_init_listhead(&pacl_list->aclnode[i].list); + pacl_list->aclnode[i].valid = _FALSE; + } + +} + +void stop_ap_mode(_adapter *padapter) +{ + _irqL irqL; + _list *phead, *plist; + struct rtw_wlan_acl_node *paclnode; + struct sta_info *psta=NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + _queue *pacl_node_q =&pacl_list->acl_node_q; + + pmlmepriv->update_bcn = _FALSE; + pmlmeext->bstart_bss = _FALSE; + //_rtw_spinlock_free(&pmlmepriv->bcn_update_lock); + + //reset and init security priv , this can refine with rtw_reset_securitypriv + _rtw_memset((unsigned char *)&padapter->securitypriv, 0, sizeof (struct security_priv)); + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; + + //for ACL + _enter_critical_bh(&(pacl_node_q->lock), &irqL); + phead = get_list_head(pacl_node_q); + plist = get_next(phead); + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) + { + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + + if(paclnode->valid == _TRUE) + { + paclnode->valid = _FALSE; + + rtw_list_delete(&paclnode->list); + + pacl_list->num--; + } + } + _exit_critical_bh(&(pacl_node_q->lock), &irqL); + + DBG_871X("%s, free acl_node_queue, num=%d\n", __func__, pacl_list->num); + + rtw_sta_flush(padapter); + + //free_assoc_sta_resources + rtw_free_all_stainfo(padapter); + + psta = rtw_get_bcmc_stainfo(padapter); + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + rtw_free_stainfo(padapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + + rtw_init_bcmc_stainfo(padapter); + + rtw_free_mlme_priv_ie_data(pmlmepriv); + +} + +#endif //CONFIG_NATIVEAP_MLME +#endif //CONFIG_AP_MODE + diff --git a/drivers/net/wireless/rtl8192cu/core/rtw_br_ext.c b/drivers/net/wireless/rtl8192cu/core/rtw_br_ext.c index 1fcdf1e..6bb924e 100644 --- a/drivers/net/wireless/rtl8192cu/core/rtw_br_ext.c +++ b/drivers/net/wireless/rtl8192cu/core/rtw_br_ext.c @@ -126,10 +126,10 @@ static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len) int tail_len; unsigned long end, tail; - if ((src+len) > skb->tail || skb->len < len) + if ((src+len) > skb_tail_pointer(skb) || skb->len < len) return -1; - tail = (unsigned long)skb->tail; + tail = (unsigned long)skb_tail_pointer(skb); end = (unsigned long)src+len; if (tail < end) return -1; @@ -522,7 +522,7 @@ static void __nat25_db_network_insert(_adapter *priv, db = db->next_hash; } - db = (struct nat25_network_db_entry *) _rtw_malloc(sizeof(*db)); + db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db)); if(db == NULL) { _exit_critical_bh(&priv->br_ext_lock, &irqL); return; @@ -633,7 +633,7 @@ void nat25_db_cleanup(_adapter *priv) int i; _irqL irqL; _enter_critical_bh(&priv->br_ext_lock, &irqL); - + for(i=0; iscdb_entry = NULL; } __network_hash_unlink(f); - _rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry)); + rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry)); f = g; } @@ -664,7 +664,7 @@ void nat25_db_expire(_adapter *priv) int i; _irqL irqL; _enter_critical_bh(&priv->br_ext_lock, &irqL); - + //if(!priv->ethBrExtInfo.nat25_disable) { for (i=0; iscdb_entry = NULL; } __network_hash_unlink(f); - _rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry)); + rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry)); } } @@ -848,6 +848,11 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method) else { // forward unknow IP packet to upper TCP/IP DEBUG_INFO("NAT25: Replace DA with BR's MAC\n"); + if ( (*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0 ) { + void netdev_br_init(struct net_device *netdev); + printk("Re-init netdev_br_init() due to br_mac==0!\n"); + netdev_br_init(priv->pnetdev); + } memcpy(skb->data, priv->br_mac, ETH_ALEN); } } @@ -1533,7 +1538,7 @@ int nat25_handle_frame(_adapter *priv, struct sk_buff *skb) _exit_critical_bh(&priv->br_ext_lock, &irqL); retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); - } + } } else { if (((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) && @@ -1633,13 +1638,13 @@ void dhcp_flag_bcast(_adapter *priv, struct sk_buff *skb) if(iph->protocol == IPPROTO_UDP) // UDP { - struct udphdr *udph = (struct udphdr *)((unsigned int)iph + (iph->ihl << 2)); + struct udphdr *udph = (struct udphdr *)((SIZE_PTR)iph + (iph->ihl << 2)); if((udph->source == __constant_htons(CLIENT_PORT)) && (udph->dest == __constant_htons(SERVER_PORT))) // DHCP request { struct dhcpMessage *dhcph = - (struct dhcpMessage *)((unsigned int)udph + sizeof(struct udphdr)); + (struct dhcpMessage *)((SIZE_PTR)udph + sizeof(struct udphdr)); if(dhcph->cookie == __constant_htonl(DHCP_MAGIC)) // match magic word { diff --git a/drivers/net/wireless/rtl8192cu/core/rtw_cmd.c b/drivers/net/wireless/rtl8192cu/core/rtw_cmd.c index bdfec5d..f906eb3 100644 --- a/drivers/net/wireless/rtl8192cu/core/rtw_cmd.c +++ b/drivers/net/wireless/rtl8192cu/core/rtw_cmd.c @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * * -******************************************************************************/ + ******************************************************************************/ #define _RTW_CMD_C_ #include @@ -58,9 +58,8 @@ _func_enter_; goto exit; } - //pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ( (SIZE_PTR)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ-1)); - pcmdpriv->cmd_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pcmdpriv->cmd_allocated_buf ), CMDBUFF_ALIGN_SZ); - + pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ( (SIZE_PTR)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ-1)); + pcmdpriv->rsp_allocated_buf = rtw_zmalloc(MAX_RSPSZ + 4); if (pcmdpriv->rsp_allocated_buf == NULL){ @@ -68,9 +67,8 @@ _func_enter_; goto exit; } - //pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ( (SIZE_PTR)(pcmdpriv->rsp_allocated_buf) & 3); - pcmdpriv->rsp_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pcmdpriv->rsp_allocated_buf ), 4); - + pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ( (SIZE_PTR)(pcmdpriv->rsp_allocated_buf) & 3); + pcmdpriv->cmd_issued_cnt = pcmdpriv->cmd_done_cnt = pcmdpriv->rsp_cnt = 0; exit: @@ -81,7 +79,9 @@ _func_exit_; } - +#ifdef CONFIG_C2H_WK +static void c2h_wk_callback(_workitem *work); +#endif sint _rtw_init_evt_priv(struct evt_priv *pevtpriv) { sint res=_SUCCESS; @@ -109,8 +109,7 @@ _func_enter_; res= _FAIL; goto exit; } - //pevtpriv->evt_buf = pevtpriv->evt_allocated_buf + 4 - ((unsigned int)(pevtpriv->evt_allocated_buf) & 3); - pevtpriv->evt_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pevtpriv->evt_allocated_buf ), 4); + pevtpriv->evt_buf = pevtpriv->evt_allocated_buf + 4 - ((unsigned int)(pevtpriv->evt_allocated_buf) & 3); #ifdef CONFIG_SDIO_HCI @@ -121,10 +120,8 @@ _func_enter_; goto exit; } - //pevtpriv->c2h_mem = pevtpriv->allocated_c2h_mem + 4 - //- ( (u32)(pevtpriv->allocated_c2h_mem) & 3); - pevtpriv->c2h_mem = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pevtpriv->allocated_c2h_mem ), 4); - + pevtpriv->c2h_mem = pevtpriv->allocated_c2h_mem + 4\ + - ( (u32)(pevtpriv->allocated_c2h_mem) & 3); #ifdef PLATFORM_OS_XP pevtpriv->pc2h_mdl= IoAllocateMdl((u8 *)pevtpriv->c2h_mem, C2H_MEM_SZ , FALSE, FALSE, NULL); @@ -142,6 +139,12 @@ exit: #endif //end of CONFIG_EVENT_THREAD_MODE +#ifdef CONFIG_C2H_WK + _init_workitem(&pevtpriv->c2h_wk, c2h_wk_callback, NULL); + pevtpriv->c2h_wk_alive = _FALSE; + pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN+1); +#endif + _func_exit_; return res; @@ -162,6 +165,21 @@ _func_enter_; rtw_mfree(pevtpriv->evt_allocated_buf, MAX_EVTSZ + 4); #endif +#ifdef CONFIG_C2H_WK + _cancel_workitem_sync(&pevtpriv->c2h_wk); + while(pevtpriv->c2h_wk_alive) + rtw_msleep_os(10); + + while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) { + void *c2h; + if ((c2h = rtw_cbuf_pop(pevtpriv->c2h_queue)) != NULL + && c2h != (void *)pevtpriv) { + rtw_mfree(c2h, 16); + } + } + rtw_cbuf_free(pevtpriv->c2h_queue); +#endif + RT_TRACE(_module_rtl871x_cmd_c_,_drv_info_,("-_rtw_free_evt_priv \n")); _func_exit_; @@ -229,8 +247,7 @@ struct cmd_obj *_rtw_dequeue_cmd(_queue *queue) _func_enter_; //_enter_critical_bh(&(queue->lock), &irqL); - _enter_critical(&(queue->lock), &irqL); - + _enter_critical(&queue->lock, &irqL); if (rtw_is_list_empty(&(queue->queue))) obj = NULL; else @@ -240,7 +257,7 @@ _func_enter_; } //_exit_critical_bh(&(queue->lock), &irqL); - _exit_critical(&(queue->lock), &irqL); + _exit_critical(&queue->lock, &irqL); _func_exit_; @@ -281,6 +298,7 @@ _func_enter_; _func_exit_; } +int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj); int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) { u8 bAllow = _FALSE; //set to _TRUE to allow enqueuing cmd when hw_init_completed is _FALSE @@ -292,23 +310,23 @@ int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) ) { if(cmd_obj->cmdcode == GEN_CMD_CODE(_Set_Drv_Extra) ) - { + { struct drvextra_cmd_parm *pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)cmd_obj->parmbuf; if(pdrvextra_cmd_parm->ec_id == POWER_SAVING_CTRL_WK_CID) { - //DBG_8192C("==>enqueue POWER_SAVING_CTRL_WK_CID\n"); + //DBG_871X("==>enqueue POWER_SAVING_CTRL_WK_CID\n"); bAllow = _TRUE; } } } -#endif + #endif if(cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan)) bAllow = _TRUE; if( (pcmdpriv->padapter->hw_init_completed ==_FALSE && bAllow == _FALSE) - || pcmdpriv->cmdthd_running== _FALSE //com_thread not running - ) + || pcmdpriv->cmdthd_running== _FALSE //com_thread not running + ) { //DBG_871X("%s:%s: drop cmdcode:%u, hw_init_completed:%u, cmdthd_running:%u\n", caller_func, __FUNCTION__, // cmd_obj->cmdcode, @@ -326,6 +344,7 @@ int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) { int res = _FAIL; + PADAPTER padapter = pcmdpriv->padapter; _func_enter_; @@ -333,6 +352,14 @@ _func_enter_; goto exit; } + cmd_obj->padapter = padapter; + +#ifdef CONFIG_CONCURRENT_MODE + //change pcmdpriv to primary's pcmdpriv + if (padapter->adapter_type != PRIMARY_ADAPTER && padapter->pbuddy_adapter) + pcmdpriv = &(padapter->pbuddy_adapter->cmdpriv); +#endif + if( _FAIL == (res=rtw_cmd_filter(pcmdpriv, cmd_obj)) ) { rtw_free_cmd_obj(cmd_obj); goto exit; @@ -395,6 +422,16 @@ _func_enter_; _func_exit_; } +void rtw_stop_cmd_thread(_adapter *adapter) +{ + if(adapter->cmdThread && adapter->cmdpriv.cmdthd_running == _TRUE + && adapter->cmdpriv.stop_req == 0) + { + adapter->cmdpriv.stop_req = 1; + _rtw_up_sema(&adapter->cmdpriv.cmd_queue_sema); + _rtw_down_sema(&adapter->cmdpriv.terminate_cmdthread_sema); + } +} thread_return rtw_cmd_thread(thread_context context) { @@ -408,11 +445,12 @@ thread_return rtw_cmd_thread(thread_context context) _func_enter_; - thread_enter(padapter); + thread_enter("RTW_CMD_THREAD"); pcmdbuf = pcmdpriv->cmd_buf; prspbuf = pcmdpriv->rsp_buf; + pcmdpriv->stop_req = 0; pcmdpriv->cmdthd_running=_TRUE; _rtw_up_sema(&pcmdpriv->terminate_cmdthread_sema); @@ -420,24 +458,35 @@ _func_enter_; while(1) { - if ((_rtw_down_sema(&(pcmdpriv->cmd_queue_sema))) == _FAIL) + if ((_rtw_down_sema(&(pcmdpriv->cmd_queue_sema))) == _FAIL) { + LOG_LEVEL(_drv_err_, FUNC_ADPT_FMT" _rtw_down_sema(&pcmdpriv->cmd_queue_sema) return _FAIL, break\n", FUNC_ADPT_ARG(padapter)); break; + } + if (pcmdpriv->stop_req) { + LOG_LEVEL(_drv_err_, FUNC_ADPT_FMT" stop_req:%u, break\n", FUNC_ADPT_ARG(padapter), pcmdpriv->stop_req); + break; + } + +#ifdef CONFIG_LPS_LCLK if (rtw_register_cmd_alive(padapter) != _SUCCESS) { continue; } +#endif _next: - if ((padapter->bDriverStopped == _TRUE)||(padapter->bSurpriseRemoved== _TRUE)) + if ((padapter->bDriverStopped == _TRUE)||(padapter->bSurpriseRemoved == _TRUE)) { - DBG_8192C("###> rtw_cmd_thread break.................\n"); - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_cmd_thread:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); + LOG_LEVEL(_drv_err_, "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n", + __FUNCTION__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__); break; } if(!(pcmd = rtw_dequeue_cmd(pcmdpriv))) { +#ifdef CONFIG_LPS_LCLK rtw_unregister_cmd_alive(padapter); +#endif continue; } @@ -447,6 +496,11 @@ _next: goto post_process; } + if( _FAIL == rtw_cmd_filter(pcmdpriv, pcmd) ) { + rtw_free_cmd_obj(pcmd); + continue; + } + pcmdpriv->cmd_issued_cnt++; pcmd->cmdsz = _RND4((pcmd->cmdsz));//_RND4 @@ -459,11 +513,11 @@ _next: if (cmd_hdl) { - ret = cmd_hdl(padapter, pcmdbuf); + ret = cmd_hdl(pcmd->padapter, pcmdbuf); pcmd->res = ret; } - pcmdpriv->cmd_seq++; + pcmdpriv->cmd_seq++; } else { @@ -473,7 +527,7 @@ _next: cmd_hdl = NULL; post_process: - + //call callback function for post-processed if(pcmd->cmdcode <= (sizeof(rtw_cmd_callback) /sizeof(struct _cmd_callback))) { @@ -486,20 +540,17 @@ post_process: else { //todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!=NULL) - pcmd_callback(padapter, pcmd);//need conider that free cmd_obj in rtw_cmd_callback + pcmd_callback(pcmd->padapter, pcmd);//need conider that free cmd_obj in rtw_cmd_callback } - } - + } flush_signals_thread(); goto _next; } - pcmdpriv->cmdthd_running=_FALSE; - DBG_871X("%s: leaving... check & free all cmd_obj resources\n", __FUNCTION__); // free all cmd_obj resources do{ @@ -507,13 +558,11 @@ post_process: if(pcmd==NULL) break; - DBG_871X("%s: leaving... drop cmdcode:%u\n", __FUNCTION__, pcmd->cmdcode); + //DBG_871X("%s: leaving... drop cmdcode:%u\n", __FUNCTION__, pcmd->cmdcode); rtw_free_cmd_obj(pcmd); }while(1); - DBG_871X("%s: leaving... call up terminate_cmdthread_sema\n", __FUNCTION__); - _rtw_up_sema(&pcmdpriv->terminate_cmdthread_sema); _func_exit_; @@ -644,28 +693,28 @@ rtw_sitesurvey_cmd(~) ### NOTE:#### (!!!!) MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock */ -u8 rtw_sitesurvey_cmd(_adapter *padapter, NDIS_802_11_SSID *pssid, int ssid_max_num) +u8 rtw_sitesurvey_cmd(_adapter *padapter, NDIS_802_11_SSID *ssid, int ssid_num, + struct rtw_ieee80211_channel *ch, int ch_num) { u8 res = _FAIL; struct cmd_obj *ph2c; struct sitesurvey_parm *psurveyPara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#ifdef CONFIG_P2P - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); -#endif //CONFIG_P2P -_func_enter_; - +_func_enter_; + #ifdef CONFIG_LPS if(check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE){ rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); } #endif -#ifdef CONFIG_P2P - p2p_ps_wk_cmd(padapter, P2P_PS_SCAN, 1); -#endif //CONFIG_P2P +#ifdef CONFIG_P2P_PS + if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) { + p2p_ps_wk_cmd(padapter, P2P_PS_SCAN, 1); + } +#endif // CONFIG_P2P_PS ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) @@ -683,18 +732,33 @@ _func_enter_; init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey)); - psurveyPara->bsslimit = 48; + /* psurveyPara->bsslimit = 48; */ psurveyPara->scan_mode = pmlmepriv->scan_mode; - _rtw_memset(psurveyPara->ssid, 0, sizeof(NDIS_802_11_SSID)*RTW_SSID_SCAN_AMOUNT); + /* prepare ssid list */ + if (ssid) { + int i; + for (i=0; issid[i], &ssid[i], sizeof(NDIS_802_11_SSID)); + psurveyPara->ssid_num++; + if (0) + DBG_871X(FUNC_ADPT_FMT" ssid:(%s, %d)\n", FUNC_ADPT_ARG(padapter), + psurveyPara->ssid[i].Ssid, psurveyPara->ssid[i].SsidLength); + } + } + } - if(pssid){ + /* prepare channel list */ + if (ch) { int i; - for(i=0; issid[i], &pssid[i], sizeof(NDIS_802_11_SSID)); - //DBG_871X("%s scan for specific ssid: %s, %d\n", __FUNCTION__ - // , psurveyPara->ssid[i].Ssid, psurveyPara->ssid[i].SsidLength); + for (i=0; ich[i], &ch[i], sizeof(struct rtw_ieee80211_channel)); + psurveyPara->ch_num++; + if (0) + DBG_871X(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), + psurveyPara->ch[i].hw_value); } } } @@ -707,7 +771,16 @@ _func_enter_; pmlmepriv->scan_start_time = rtw_get_current_time(); - _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT); +#ifdef CONFIG_STA_MODE_SCAN_UNDER_AP_MODE + if (padapter->pbuddy_adapter == NULL ) + goto full_scan_timeout; + if((padapter->pbuddy_adapter->mlmeextpriv.mlmext_info.state&0x03) == WIFI_FW_AP_STATE) + _set_timer(&pmlmepriv->scan_to_timer, + SURVEY_TO * ( padapter->mlmeextpriv.max_chan_nums + ( padapter->mlmeextpriv.max_chan_nums / RTW_SCAN_NUM_OF_CH ) * RTW_STAY_AP_CH_MILLISECOND ) + 1000 ); + else +#endif //CONFIG_STA_MODE_SCAN_UNDER_AP_MODE +full_scan_timeout: + _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT); rtw_led_control(padapter, LED_CTL_SITE_SURVEY); @@ -1219,7 +1292,7 @@ _func_enter_; { //rtw_restructure_ht_ie rtw_restructure_ht_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], - pnetwork->network.IELength, &psecnetwork->IELength); + pnetwork->network.IELength, &psecnetwork->IELength, (u8)psecnetwork->Configuration.DSConfig ); } } @@ -1276,38 +1349,42 @@ _func_exit_; return res; } -u8 rtw_disassoc_cmd(_adapter*padapter) // for sta_mode +u8 rtw_disassoc_cmd(_adapter*padapter, u32 deauth_timeout_ms, bool enqueue) /* for sta_mode */ { - struct cmd_obj* pdisconnect_cmd; - struct disconnect_parm* pdisconnect; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res=_SUCCESS; + struct cmd_obj *cmdobj = NULL; + struct disconnect_parm *param = NULL; + struct cmd_priv *cmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; _func_enter_; RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n")); - - //if ((check_fwstate(pmlmepriv, _FW_LINKED)) == _TRUE) { - pdisconnect_cmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); - if(pdisconnect_cmd == NULL){ - res=_FAIL; - goto exit; - } + /* prepare cmd parameter */ + param = (struct disconnect_parm *)rtw_zmalloc(sizeof(*param)); + if (param == NULL) { + res = _FAIL; + goto exit; + } + param->deauth_timeout_ms = deauth_timeout_ms; - pdisconnect = (struct disconnect_parm*)rtw_zmalloc(sizeof(struct disconnect_parm)); - if(pdisconnect == NULL) { - rtw_mfree((u8 *)pdisconnect_cmd, sizeof(struct cmd_obj)); - res= _FAIL; + if (enqueue) { + /* need enqueue, prepare cmd_obj and enqueue */ + cmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(*cmdobj)); + if (cmdobj == NULL) { + res = _FAIL; + rtw_mfree((u8 *)param, sizeof(*param)); goto exit; } - - init_h2fwcmd_w_parm_no_rsp(pdisconnect_cmd, pdisconnect, _DisConnect_CMD_); - res = rtw_enqueue_cmd(pcmdpriv, pdisconnect_cmd); - //} - + init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); + res = rtw_enqueue_cmd(cmdpriv, cmdobj); + } else { + /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ + if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) + res = _FAIL; + rtw_mfree((u8 *)param, sizeof(*param)); + } + exit: _func_exit_; @@ -1396,7 +1473,7 @@ _func_enter_; if(sta->tdls_sta_state&TDLS_LINKED_STATE) psetstakey_para->algorithm=(u8)sta->dot118021XPrivacy; else -#endif +#endif //CONFIG_TDLS psetstakey_para->algorithm =(unsigned char) psecuritypriv->dot11PrivacyAlgrthm; }else{ GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, _FALSE); @@ -1404,10 +1481,10 @@ _func_enter_; if (unicast_key == _TRUE) { #ifdef CONFIG_TDLS - if((sta->tdls_sta_state&TDLS_LINKED_STATE)==TDLS_LINKED_STATE) + if(sta->tdls_sta_state&TDLS_LINKED_STATE) _rtw_memcpy(&psetstakey_para->key, sta->tpk.tk, 16); else -#endif +#endif //CONFIG_TDLS _rtw_memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16); } else { _rtw_memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16); @@ -1425,6 +1502,67 @@ _func_exit_; return res; } +u8 rtw_clearstakey_cmd(_adapter *padapter, u8 *psta, u8 entry, u8 enqueue) +{ + struct cmd_obj* ph2c; + struct set_stakey_parm *psetstakey_para; + struct cmd_priv *pcmdpriv=&padapter->cmdpriv; + struct set_stakey_rsp *psetstakey_rsp = NULL; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct sta_info* sta = (struct sta_info* )psta; + u8 res=_SUCCESS; + +_func_enter_; + + if(!enqueue) + { + clear_cam_entry(padapter, entry); + } + else + { + ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); + if ( ph2c == NULL){ + res= _FAIL; + goto exit; + } + + psetstakey_para = (struct set_stakey_parm*)rtw_zmalloc(sizeof(struct set_stakey_parm)); + if(psetstakey_para==NULL){ + rtw_mfree((u8 *) ph2c, sizeof(struct cmd_obj)); + res=_FAIL; + goto exit; + } + + psetstakey_rsp = (struct set_stakey_rsp*)rtw_zmalloc(sizeof(struct set_stakey_rsp)); + if(psetstakey_rsp == NULL){ + rtw_mfree((u8 *) ph2c, sizeof(struct cmd_obj)); + rtw_mfree((u8 *) psetstakey_para, sizeof(struct set_stakey_parm)); + res=_FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); + ph2c->rsp = (u8 *) psetstakey_rsp; + ph2c->rspsz = sizeof(struct set_stakey_rsp); + + _rtw_memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); + + psetstakey_para->algorithm = _NO_PRIVACY_; + + psetstakey_para->id = entry; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + + } + +exit: + +_func_exit_; + + return res; +} + u8 rtw_setrttbl_cmd(_adapter *padapter, struct setratable_parm *prate_table) { struct cmd_obj* ph2c; @@ -1570,7 +1708,7 @@ _func_enter_; init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, GEN_CMD_CODE(_AddBAReq)); - //DBG_8192C("rtw_addbareq_cmd, tid=%d\n", tid); + //DBG_871X("rtw_addbareq_cmd, tid=%d\n", tid); //rtw_enqueue_cmd(pcmdpriv, ph2c); res = rtw_enqueue_cmd(pcmdpriv, ph2c); @@ -1581,6 +1719,87 @@ _func_exit_; return res; } +//add for CONFIG_IEEE80211W, none 11w can use it +u8 rtw_reset_securitypriv_cmd(_adapter*padapter) +{ + struct cmd_obj* ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv=&padapter->cmdpriv; + u8 res=_SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); + if(ph2c==NULL){ + res= _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if(pdrvextra_cmd_parm==NULL){ + rtw_mfree((unsigned char *)ph2c, sizeof(struct cmd_obj)); + res= _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = RESET_SECURITYPRIV; + pdrvextra_cmd_parm->type_size = 0; + pdrvextra_cmd_parm->pbuf = (u8 *)padapter; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + + //rtw_enqueue_cmd(pcmdpriv, ph2c); + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + +_func_exit_; + + return res; + +} + +u8 rtw_free_assoc_resources_cmd(_adapter*padapter) +{ + struct cmd_obj* ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv=&padapter->cmdpriv; + u8 res=_SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); + if(ph2c==NULL){ + res= _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if(pdrvextra_cmd_parm==NULL){ + rtw_mfree((unsigned char *)ph2c, sizeof(struct cmd_obj)); + res= _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = FREE_ASSOC_RESOURCES; + pdrvextra_cmd_parm->type_size = 0; + pdrvextra_cmd_parm->pbuf = (u8 *)padapter; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + + //rtw_enqueue_cmd(pcmdpriv, ph2c); + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + +_func_exit_; + + return res; + +} + u8 rtw_dynamic_chk_wk_cmd(_adapter*padapter) { @@ -1591,6 +1810,15 @@ u8 rtw_dynamic_chk_wk_cmd(_adapter*padapter) _func_enter_; + if ((padapter->bDriverStopped == _TRUE)||(padapter->bSurpriseRemoved== _TRUE)) + goto exit; + + +#ifdef CONFIG_CONCURRENT_MODE + if (padapter->adapter_type != PRIMARY_ADAPTER && padapter->pbuddy_adapter) + pcmdpriv = &(padapter->pbuddy_adapter->cmdpriv); +#endif + ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); if(ph2c==NULL){ res= _FAIL; @@ -1606,7 +1834,7 @@ _func_enter_; pdrvextra_cmd_parm->ec_id = DYNAMIC_CHK_WK_CID; pdrvextra_cmd_parm->type_size = 0; - pdrvextra_cmd_parm->pbuf = NULL; + pdrvextra_cmd_parm->pbuf = (u8 *)padapter; init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); @@ -1622,11 +1850,65 @@ _func_exit_; } +u8 rtw_set_ch_cmd(_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue) +{ + struct cmd_obj *pcmdobj; + struct set_ch_parm *set_ch_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res=_SUCCESS; + +_func_enter_; + + DBG_871X(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), ch, bw, ch_offset); + + /* check input parameter */ + + /* prepare cmd parameter */ + set_ch_parm = (struct set_ch_parm *)rtw_zmalloc(sizeof(*set_ch_parm)); + if (set_ch_parm == NULL) { + res= _FAIL; + goto exit; + } + set_ch_parm->ch = ch; + set_ch_parm->bw = bw; + set_ch_parm->ch_offset = ch_offset; + + if (enqueue) { + /* need enqueue, prepare cmd_obj and enqueue */ + pcmdobj = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); + if(pcmdobj == NULL){ + rtw_mfree((u8 *)set_ch_parm, sizeof(*set_ch_parm)); + res=_FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, set_ch_parm, GEN_CMD_CODE(_SetChannel)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); + } else { + /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ + if( H2C_SUCCESS !=set_ch_hdl(padapter, (u8 *)set_ch_parm) ) + res = _FAIL; + + rtw_mfree((u8 *)set_ch_parm, sizeof(*set_ch_parm)); + } + + /* do something based on res... */ + +exit: + + DBG_871X(FUNC_NDEV_FMT" res:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), res); + +_func_exit_; + + return res; +} + u8 rtw_set_chplan_cmd(_adapter*padapter, u8 chplan, u8 enqueue) { struct cmd_obj* pcmdobj; struct SetChannelPlan_param *setChannelPlan_param; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res=_SUCCESS; @@ -1738,7 +2020,7 @@ _func_enter_; goto exit; } - setChannelSwitch_param = (struct SetChannelSwitch_param *)rtw_zmalloc(sizeof(struct SetChannelSwitch_param)); + setChannelSwitch_param = (struct SetChannelSwitch_param *)rtw_zmalloc(sizeof(struct SetChannelSwitch_param)); if(setChannelSwitch_param == NULL) { rtw_mfree((u8 *)pcmdobj, sizeof(struct cmd_obj)); res= _FAIL; @@ -1806,9 +2088,8 @@ static void traffic_status_watchdog(_adapter *padapter) { #ifdef CONFIG_LPS u8 bEnterPS; - u32 trx_threshold; - u32 rx_threshold; #endif + u16 BusyThreshold = 100; u8 bBusyTraffic = _FALSE, bTxBusyTraffic = _FALSE, bRxBusyTraffic = _FALSE; u8 bHigherBusyTraffic = _FALSE, bHigherBusyRxTraffic = _FALSE, bHigherBusyTxTraffic = _FALSE; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -1816,6 +2097,8 @@ static void traffic_status_watchdog(_adapter *padapter) struct tdls_info *ptdlsinfo = &(padapter->tdlsinfo); #endif //CONFIG_TDLS + RT_LINK_DETECT_T * link_detect = &pmlmepriv->LinkDetectInfo; + // // Determine if our traffic is busy now // @@ -1823,15 +2106,18 @@ static void traffic_status_watchdog(_adapter *padapter) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) { - if( pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 100 || - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 100 ) + // if we raise bBusyTraffic in last watchdog, using lower threshold. + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) + BusyThreshold = 75; + if( pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > BusyThreshold || + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > BusyThreshold ) { bBusyTraffic = _TRUE; - if(pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 100) + if(pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > BusyThreshold) bRxBusyTraffic = _TRUE; - if(pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 100) + if(pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > BusyThreshold) bTxBusyTraffic = _TRUE; } @@ -1849,29 +2135,39 @@ static void traffic_status_watchdog(_adapter *padapter) if(pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 5000) bHigherBusyTxTraffic = _TRUE; } - + +#ifdef CONFIG_TRAFFIC_PROTECT +#define TX_ACTIVE_TH 2 +#define RX_ACTIVE_TH 1 +#define TRAFFIC_PROTECT_PERIOD_MS 4500 + + if (link_detect->NumTxOkInPeriod > TX_ACTIVE_TH + || link_detect->NumRxUnicastOkInPeriod > RX_ACTIVE_TH) { + + LOG_LEVEL(_drv_info_, FUNC_ADPT_FMT" acqiure wake_lock for %u ms(tx:%d,rx_unicast:%d)\n", + FUNC_ADPT_ARG(padapter), + TRAFFIC_PROTECT_PERIOD_MS, + link_detect->NumTxOkInPeriod, + link_detect->NumRxUnicastOkInPeriod); + + rtw_lock_suspend_timeout(TRAFFIC_PROTECT_PERIOD_MS); + } +#endif + #ifdef CONFIG_TDLS #ifdef CONFIG_TDLS_AUTOSETUP - if( ( ptdlsinfo->watchdog_count % TDLS_WATCHDOG_PERIOD ) == 0 ) //10 * 2sec, periodically sending + if( ( ptdlsinfo->watchdog_count % TDLS_WATCHDOG_PERIOD ) == 0 ) //TDLS_WATCHDOG_PERIOD * 2sec, periodically sending issue_tdls_dis_req( padapter, NULL ); ptdlsinfo->watchdog_count++; #endif //CONFIG_TDLS_AUTOSETUP #endif //CONFIG_TDLS - + #ifdef CONFIG_LPS // check traffic for powersaving. - if(padapter->registrypriv.intel_class_mode==1){ - trx_threshold=1; - rx_threshold=1; - } - else{ - trx_threshold=8; - rx_threshold=2; - } - if( ((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > trx_threshold ) || - (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > rx_threshold) ) + if( ((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || + (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) { - //DBG_8192C("Tx = %d, Rx = %d \n",pmlmepriv->LinkDetectInfo.NumTxOkInPeriod,pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); + //DBG_871X("Tx = %d, Rx = %d \n",pmlmepriv->LinkDetectInfo.NumTxOkInPeriod,pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); bEnterPS= _FALSE; } else @@ -1905,15 +2201,39 @@ static void traffic_status_watchdog(_adapter *padapter) pmlmepriv->LinkDetectInfo.bRxBusyTraffic = bRxBusyTraffic; pmlmepriv->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; pmlmepriv->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + pmlmepriv->LinkDetectInfo.bHigherBusyTxTraffic = bHigherBusyTxTraffic; + } +void dynamic_chk_wk_hdl(_adapter *padapter, u8 *pbuf, int sz); void dynamic_chk_wk_hdl(_adapter *padapter, u8 *pbuf, int sz) { - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - //struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_priv *pmlmepriv; + + if ((padapter->bDriverStopped == _TRUE)||(padapter->bSurpriseRemoved== _TRUE)) + return; + + if((void*)padapter != (void*)pbuf && padapter->pbuddy_adapter == NULL) + return; + + padapter = (_adapter *)pbuf; + + if ((padapter->bDriverStopped == _TRUE)||(padapter->bSurpriseRemoved== _TRUE)) + return; + + pmlmepriv = &(padapter->mlmepriv); + +#ifdef CONFIG_ACTIVE_KEEP_ALIVE_CHECK +#ifdef CONFIG_AP_MODE + if(check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) + { + expire_timeout_chk(padapter); + } +#endif +#endif //CONFIG_ACTIVE_KEEP_ALIVE_CHECK + #ifdef DBG_CONFIG_ERROR_DETECT - if(padapter->HalFunc.sreset_xmit_status_check) - padapter->HalFunc.sreset_xmit_status_check(padapter); + rtw_hal_sreset_xmit_status_check(padapter); #endif //if(check_fwstate(pmlmepriv, _FW_UNDER_LINKING|_FW_UNDER_SURVEY)==_FALSE) @@ -1922,13 +2242,15 @@ void dynamic_chk_wk_hdl(_adapter *padapter, u8 *pbuf, int sz) traffic_status_watchdog(padapter); } - padapter->HalFunc.hal_dm_watchdog(padapter); + rtw_hal_dm_watchdog(padapter); //check_hw_pbc(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type_size); } #ifdef CONFIG_LPS + +void lps_ctrl_wk_hdl(_adapter *padapter, u8 lps_ctrl_type); void lps_ctrl_wk_hdl(_adapter *padapter, u8 lps_ctrl_type) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; @@ -1946,28 +2268,28 @@ _func_enter_; switch(lps_ctrl_type) { case LPS_CTRL_SCAN: - //DBG_8192C("LPS_CTRL_SCAN \n"); + //DBG_871X("LPS_CTRL_SCAN \n"); LeaveAllPowerSaveMode(padapter); break; case LPS_CTRL_JOINBSS: - //DBG_8192C("LPS_CTRL_JOINBSS \n"); + //DBG_871X("LPS_CTRL_JOINBSS \n"); LPS_Leave(padapter); break; case LPS_CTRL_CONNECT: - //DBG_8192C("LPS_CTRL_CONNECT \n"); + //DBG_871X("LPS_CTRL_CONNECT \n"); mstatus = 1; // Reset LPS Setting padapter->pwrctrlpriv.LpsIdleCount = 0; - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); break; case LPS_CTRL_DISCONNECT: - //DBG_8192C("LPS_CTRL_DISCONNECT \n"); + //DBG_871X("LPS_CTRL_DISCONNECT \n"); mstatus = 0; LPS_Leave(padapter); - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); break; case LPS_CTRL_SPECIAL_PACKET: - //DBG_8192C("LPS_CTRL_SPECIAL_PACKET \n"); + //DBG_871X("LPS_CTRL_SPECIAL_PACKET \n"); pwrpriv->DelayLPSLastTimeStamp = rtw_get_current_time(); LPS_Leave(padapter); break; @@ -1984,7 +2306,7 @@ u8 rtw_lps_ctrl_wk_cmd(_adapter*padapter, u8 lps_ctrl_type, u8 enqueue) struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + //struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; u8 res = _SUCCESS; _func_enter_; @@ -1992,6 +2314,11 @@ _func_enter_; //if(!pwrctrlpriv->bLeisurePs) // return res; +#ifdef CONFIG_CONCURRENT_MODE + if (padapter->iface_type != IFACE_PORT0) + return res; +#endif + if(enqueue) { ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); @@ -2033,7 +2360,7 @@ _func_exit_; void antenna_select_wk_hdl(_adapter *padapter, u8 antenna) { - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_ANTENNA_DIVERSITY_SELECT, (u8 *)(&antenna)); + rtw_hal_set_hwreg(padapter, HW_VAR_ANTENNA_DIVERSITY_SELECT, (u8 *)(&antenna)); } u8 rtw_antenna_select_cmd(_adapter*padapter, u8 antenna,u8 enqueue) @@ -2045,7 +2372,7 @@ u8 rtw_antenna_select_cmd(_adapter*padapter, u8 antenna,u8 enqueue) u8 res = _SUCCESS; _func_enter_; - padapter->HalFunc.GetHalDefVarHandler(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &(bSupportAntDiv)); + rtw_hal_get_def_var(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &(bSupportAntDiv)); if(_FALSE == bSupportAntDiv ) return res; if(_TRUE == enqueue) @@ -2082,11 +2409,23 @@ _func_exit_; } #endif +void power_saving_wk_hdl(_adapter *padapter, u8 *pbuf, int sz); void power_saving_wk_hdl(_adapter *padapter, u8 *pbuf, int sz) { rtw_ps_processor(padapter); } +//add for CONFIG_IEEE80211W, none 11w can use it +void reset_securitypriv_hdl(_adapter *padapter) +{ + rtw_reset_securitypriv(padapter); +} + +void free_assoc_resources_hdl(_adapter *padapter) +{ + rtw_free_assoc_resources(padapter, 1); +} + #ifdef CONFIG_P2P u8 p2p_protocol_wk_cmd(_adapter*padapter, int intCmdType ) { @@ -2098,7 +2437,7 @@ u8 p2p_protocol_wk_cmd(_adapter*padapter, int intCmdType ) _func_enter_; - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + if(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { return res; } @@ -2141,6 +2480,11 @@ u8 rtw_ps_cmd(_adapter*padapter) u8 res = _SUCCESS; _func_enter_; + +#ifdef CONFIG_CONCURRENT_MODE + if (padapter->adapter_type != PRIMARY_ADAPTER) + goto exit; +#endif ppscmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); if(ppscmd==NULL){ @@ -2157,7 +2501,6 @@ _func_enter_; pdrvextra_cmd_parm->ec_id = POWER_SAVING_CTRL_WK_CID; pdrvextra_cmd_parm->pbuf = NULL; - DBG_8192C("==> %s , enqueue CMD \n",__FUNCTION__); init_h2fwcmd_w_parm_no_rsp(ppscmd, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); res = rtw_enqueue_cmd(pcmdpriv, ppscmd); @@ -2241,6 +2584,108 @@ exit: } #endif +u8 rtw_c2h_wk_cmd(PADAPTER padapter, u8 *c2h_evt) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + rtw_mfree((u8*)ph2c, sizeof(struct cmd_obj)); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = C2H_WK_CID; + pdrvextra_cmd_parm->type_size = c2h_evt?16:0; + pdrvextra_cmd_parm->pbuf = c2h_evt; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +s32 c2h_evt_hdl(_adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter) +{ + s32 ret = _FAIL; + u8 buf[16]; + + if (!c2h_evt) { + /* No c2h event in cmd_obj, read c2h event before handling*/ + if (c2h_evt_read(adapter, buf) == _SUCCESS) { + c2h_evt = (struct c2h_evt_hdr *)buf; + + if (filter && filter(c2h_evt->id) == _FALSE) + goto exit; + + ret = rtw_hal_c2h_handler(adapter, c2h_evt); + } + } else { + + if (filter && filter(c2h_evt->id) == _FALSE) + goto exit; + + ret = rtw_hal_c2h_handler(adapter, c2h_evt); + } +exit: + return ret; +} + +#ifdef CONFIG_C2H_WK +static void c2h_wk_callback(_workitem *work) +{ + struct evt_priv *evtpriv = container_of(work, struct evt_priv, c2h_wk); + _adapter *adapter = container_of(evtpriv, _adapter, evtpriv); + struct c2h_evt_hdr *c2h_evt; + c2h_id_filter ccx_id_filter = rtw_hal_c2h_id_filter_ccx(adapter); + + evtpriv->c2h_wk_alive = _TRUE; + + while (!rtw_cbuf_empty(evtpriv->c2h_queue)) { + if ((c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) { + /* This C2H event is read, clear it */ + c2h_evt_clear(adapter); + } else if ((c2h_evt = (struct c2h_evt_hdr *)rtw_malloc(16)) != NULL) { + /* This C2H event is not read, read & clear now */ + if (c2h_evt_read(adapter, (u8*)c2h_evt) != _SUCCESS) + continue; + } + + /* Special pointer to trigger c2h_evt_clear only */ + if ((void *)c2h_evt == (void *)evtpriv) + continue; + + if (!c2h_evt_exist(c2h_evt)) { + rtw_mfree((u8*)c2h_evt, 16); + continue; + } + + if (ccx_id_filter(c2h_evt->id) == _TRUE) { + /* Handle CCX report here */ + rtw_hal_c2h_handler(adapter, c2h_evt); + rtw_mfree((u8*)c2h_evt, 16); + } else { + /* Enqueue into cmd_thread for others */ + rtw_c2h_wk_cmd(adapter, (u8 *)c2h_evt); + } + } + + evtpriv->c2h_wk_alive = _FALSE; +} +#endif + u8 rtw_drvextra_cmd_hdl(_adapter *padapter, unsigned char *pbuf) { struct drvextra_cmd_parm *pdrvextra_cmd; @@ -2268,24 +2713,39 @@ u8 rtw_drvextra_cmd_hdl(_adapter *padapter, unsigned char *pbuf) antenna_select_wk_hdl(padapter, pdrvextra_cmd->type_size); break; #endif -#ifdef CONFIG_P2P +#ifdef CONFIG_P2P_PS case P2P_PS_WK_CID: p2p_ps_wk_hdl(padapter, pdrvextra_cmd->type_size); break; +#endif // CONFIG_P2P_PS case P2P_PROTO_WK_CID: // Commented by Albert 2011/07/01 // I used the type_size as the type command p2p_protocol_wk_hdl( padapter, pdrvextra_cmd->type_size ); break; -#endif //CONFIG_P2P #ifdef CONFIG_AP_MODE case CHECK_HIQ_WK_CID: rtw_chk_hi_queue_hdl(padapter); break; -#endif //CONFIG_AP_MODE - default: +#endif //CONFIG_AP_MODE +#ifdef CONFIG_INTEL_WIDI + case INTEl_WIDI_WK_CID: + intel_widi_wk_hdl(padapter, pdrvextra_cmd->type_size, pdrvextra_cmd->pbuf); + break; +#endif //CONFIG_INTEL_WIDI + //add for CONFIG_IEEE80211W, none 11w can use it + case RESET_SECURITYPRIV: + reset_securitypriv_hdl(padapter); + break; + case FREE_ASSOC_RESOURCES: + free_assoc_resources_hdl(padapter); + break; + case C2H_WK_CID: + c2h_evt_hdl(padapter, (struct c2h_evt_hdr *)pdrvextra_cmd->pbuf, NULL); break; + default: + break; } @@ -2552,13 +3012,14 @@ _func_enter_; set_fwstate(pmlmepriv, _FW_LINKED); _exit_critical_bh(&pmlmepriv->lock, &irqL); - -exit: + +exit: rtw_free_cmd_obj(pcmd); - + _func_exit_; } +void rtw_getrttbl_cmd_cmdrsp_callback(_adapter* padapter, struct cmd_obj *pcmd); void rtw_getrttbl_cmd_cmdrsp_callback(_adapter* padapter, struct cmd_obj *pcmd) { _func_enter_; diff --git a/drivers/net/wireless/rtl8192cu/core/rtw_debug.c b/drivers/net/wireless/rtl8192cu/core/rtw_debug.c index 04e472d..f70fcb7 100644 --- a/drivers/net/wireless/rtl8192cu/core/rtw_debug.c +++ b/drivers/net/wireless/rtl8192cu/core/rtw_debug.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * + * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. @@ -21,10 +21,11 @@ #include +#include <../hal/dm.h> -#ifdef CONFIG_DEBUG_RTL871X +//#ifdef CONFIG_DEBUG_RTL871X - u32 GlobalDebugLevel = _drv_info_; + u32 GlobalDebugLevel = _drv_err_; u64 GlobalDebugComponents = \ _module_rtl871x_xmit_c_ | @@ -52,12 +53,12 @@ _module_hci_ops_os_c_| _module_rtl871x_ioctl_os_c| _module_rtl8712_cmd_c_| - _module_rtl8192c_xmit_c_| + _module_hal_xmit_c_| _module_rtl8712_recv_c_ | _module_mp_ | _module_efuse_; -#endif +//#endif #ifdef CONFIG_PROC_DEBUG #include @@ -76,6 +77,65 @@ int proc_get_drv_version(char *page, char **start, return len; } +int proc_get_log_level(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + int len = 0; + + len += snprintf(page + len, count - len, + "log_level:%d\n", + GlobalDebugLevel + ); + + *eof = 1; + return len; +} + +int proc_set_log_level(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + char tmp[32]; + u32 is_signal_dbg; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + + int num = sscanf(tmp, "%d ", &is_signal_dbg); + + if( is_signal_dbg >= 0 && is_signal_dbg < 10 ) + { + GlobalDebugLevel= is_signal_dbg; + printk("%d\n", GlobalDebugLevel); + } + } + + return count; + +} + +#ifdef DBG_MEM_ALLOC +int proc_get_mstat(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + int len = 0; + + len += _rtw_mstat_dump(page+len, count-len); + *eof = 1; + + return len; +} +#endif /* DBG_MEM_ALLOC */ + int proc_get_write_reg(char *page, char **start, off_t offset, int count, int *eof, void *data) @@ -94,7 +154,7 @@ int proc_set_write_reg(struct file *file, const char *buffer, if (count < 3) { - DBG_8192C("argument size is less than 3\n"); + DBG_871X("argument size is less than 3\n"); return -EFAULT; } @@ -103,7 +163,7 @@ int proc_set_write_reg(struct file *file, const char *buffer, int num = sscanf(tmp, "%x %x %x", &addr, &val, &len); if (num != 3) { - DBG_8192C("invalid write_reg parameter!\n"); + DBG_871X("invalid write_reg parameter!\n"); return count; } @@ -119,7 +179,7 @@ int proc_set_write_reg(struct file *file, const char *buffer, rtw_write32(padapter, addr, val); break; default: - DBG_8192C("error write length=%d", len); + DBG_871X("error write length=%d", len); break; } @@ -171,14 +231,12 @@ int proc_get_read_reg(char *page, char **start, int proc_set_read_reg(struct file *file, const char *buffer, unsigned long count, void *data) { - struct net_device *dev = (struct net_device *)data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); char tmp[16]; u32 addr, len; if (count < 2) { - DBG_8192C("argument size is less than 2\n"); + DBG_871X("argument size is less than 2\n"); return -EFAULT; } @@ -187,7 +245,7 @@ int proc_set_read_reg(struct file *file, const char *buffer, int num = sscanf(tmp, "%x %x", &addr, &len); if (num != 2) { - DBG_8192C("invalid read_reg parameter!\n"); + DBG_871X("invalid read_reg parameter!\n"); return count; } @@ -289,17 +347,17 @@ int proc_get_rf_info(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; int len = 0; - len += snprintf(page + len, count - len, "cur_ch=%d, cur_bw=%d, cur_ch_offet=%d\n", - pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); - - + len += snprintf(page + len, count - len, "cur_ch=%d, cur_bw=%d, cur_ch_offet=%d\n" + "oper_ch=%d, oper_bw=%d, oper_ch_offet=%d\n", + pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset, + rtw_get_oper_ch(padapter), rtw_get_oper_bw(padapter), rtw_get_oper_choffset(padapter)); *eof = 1; - return len; + return len; } int proc_get_ap_info(char *page, char **start, @@ -371,23 +429,282 @@ int proc_get_trx_info(char *page, char **start, off_t offset, int count, int *eof, void *data) { + int i; struct net_device *dev = data; _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct recv_priv *precvpriv = &padapter->recvpriv; + struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); + struct hw_xmit *phwxmit; int len = 0; - len += snprintf(page + len, count - len, "free_xmitbuf_cnt=%d, free_xmitframe_cnt=%d, free_ext_xmitbuf_cnt=%d, free_recvframe_cnt=%d\n", - pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt,pxmitpriv->free_xmit_extbuf_cnt, precvpriv->free_recvframe_cnt); + len += snprintf(page + len, count - len, "free_xmitbuf_cnt=%d, free_xmitframe_cnt=%d" + ", free_ext_xmitbuf_cnt=%d, free_xframe_ext_cnt=%d" + ", free_recvframe_cnt=%d\n", + pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, + pxmitpriv->free_xmit_extbuf_cnt, pxmitpriv->free_xframe_ext_cnt, + precvpriv->free_recvframe_cnt); #ifdef CONFIG_USB_HCI - len += snprintf(page + len, count - len, "rx_urb_pending_cn=%d\n", precvpriv->rx_pending_cnt); + len += snprintf(page + len, count - len, "rx_urb_pending_cnt=%d\n", precvpriv->rx_pending_cnt); #endif + len += snprintf(page + len, count - len, "recvbuf_skb_alloc_fail_cnt=%d\n", precvpriv->recvbuf_skb_alloc_fail_cnt); + len += snprintf(page + len, count - len, "recvbuf_null_cnt=%d\n", precvpriv->recvbuf_null_cnt); + len += snprintf(page + len, count - len, "read_port_complete_EINPROGRESS_cnt=%d\n", precvpriv->read_port_complete_EINPROGRESS_cnt); + len += snprintf(page + len, count - len, "read_port_complete_other_urb_err_cnt=%d\n", precvpriv->read_port_complete_other_urb_err_cnt); + len += snprintf(page + len, count - len, "hw_init_completed=%d\n", padapter->hw_init_completed); +#ifdef CONFIG_USB_HCI + len += snprintf(page + len, count - len, "continual_urb_error=%d\n", atomic_read(&pdvobj->continual_urb_error)); +#endif + + for(i = 0; i < 4; i++) + { + phwxmit = pxmitpriv->hwxmits + i; + len += snprintf(page + len, count - len, "%d, hwq.accnt=%d\n", i, phwxmit->accnt); + } + + *eof = 1; + return len; + +} + + + +int proc_get_mac_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1; + + len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); + + for(i=0x0;i<0x300;i+=4) + { + if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i); + len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i)); + if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n"); + } + + *eof = 1; + return len; + +} + +int proc_get_mac_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1; + + len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); + memset(page, 0, count); + for(i=0x300;i<0x600;i+=4) + { + if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i); + len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i)); + if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n"); + } + *eof = 1; return len; } + +int proc_get_mac_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1; + + len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); + + for(i=0x600;i<0x800;i+=4) + { + if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i); + len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i)); + if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n"); + } + + *eof = 1; + return len; + +} + +int proc_get_bb_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1; + + len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); + for(i=0x800;i<0xB00;i+=4) + { + if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i); + len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i)); + if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n"); + } + *eof = 1; + return len; +} + +int proc_get_bb_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1; + + len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); + for(i=0xB00;i<0xE00;i+=4) + { + if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i); + len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i)); + if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n"); + } + *eof = 1; + return len; +} + +int proc_get_bb_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1; + + len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); + for(i=0xE00;i<0x1000;i+=4) + { + if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i); + len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i)); + if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n"); + } + *eof = 1; + return len; +} + +int proc_get_rf_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1,path; + u32 value; + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 1; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n",path); + for(i=0;i<0xC0;i++) + { + //value = PHY_QueryRFReg(padapter, (RF90_RADIO_PATH_E)path,i, bMaskDWord); + value =rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if(j%4==1) len += snprintf(page + len, count - len, "0x%02x ",i); + len += snprintf(page + len, count - len, " 0x%08x ",value); + if((j++)%4==0) len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + + +int proc_get_rf_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1,path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 1; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n",path); + for(i=0xC0;i<0x100;i++) + { + //value = PHY_QueryRFReg(padapter, (RF90_RADIO_PATH_E)path,i, bMaskDWord); + value =rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if(j%4==1) len += snprintf(page + len, count - len, "0x%02x ",i); + len += snprintf(page + len, count - len, " 0x%08x ",value); + if((j++)%4==0) len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + + +int proc_get_rf_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1,path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 2; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n",path); + for(i=0;i<0xC0;i++) + { + //value = PHY_QueryRFReg(padapter, (RF90_RADIO_PATH_E)path,i, bMaskDWord); + value =rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if(j%4==1) len += snprintf(page + len, count - len, "0x%02x ",i); + len += snprintf(page + len, count - len, " 0x%08x ",value); + if((j++)%4==0) len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + + +int proc_get_rf_reg_dump4(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + int i,j=1,path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 2; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n",path); + for(i=0xC0;i<0x100;i++) + { + //value = PHY_QueryRFReg(padapter, (RF90_RADIO_PATH_E)path,i, bMaskDWord); + value =rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if(j%4==1) len += snprintf(page + len, count - len, "0x%02x ",i); + len += snprintf(page + len, count - len, " 0x%08x ",value); + if((j++)%4==0) len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + + int proc_get_rx_signal(char *page, char **start, off_t offset, int count, @@ -453,6 +770,101 @@ int proc_set_rx_signal(struct file *file, const char *buffer, } +int proc_get_ht_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + + int len = 0; + + if(pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->ht_enable + ); + + *eof = 1; + return len; +} + +int proc_set_ht_enable(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + u32 mode; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + + int num = sscanf(tmp, "%d ", &mode); + + if( pregpriv && mode >= 0 && mode < 2 ) + { + pregpriv->ht_enable= mode; + printk("ht_enable=%d\n", pregpriv->ht_enable); + } + } + + return count; + +} + + +int proc_get_cbw40_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + + int len = 0; + + if(pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->cbw40_enable + ); + + *eof = 1; + return len; +} + +int proc_set_cbw40_enable(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + u32 mode; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + + int num = sscanf(tmp, "%d ", &mode); + + if( pregpriv && mode >= 0 && mode < 2 ) + { + pregpriv->cbw40_enable= mode; + printk("cbw40_enable=%d\n", mode); + } + } + + return count; + +} + int proc_get_ampdu_enable(char *page, char **start, off_t offset, int count, int *eof, void *data) @@ -500,6 +912,112 @@ int proc_set_ampdu_enable(struct file *file, const char *buffer, } + +int proc_get_two_path_rssi(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + + int len = 0; + + if(padapter) + len += snprintf(page + len, count - len, + "%d %d\n", + padapter->recvpriv.RxRssi[0], + padapter->recvpriv.RxRssi[1] + ); + + *eof = 1; + return len; +} + +int proc_get_rx_stbc(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + + int len = 0; + + if(pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->rx_stbc + ); + + *eof = 1; + return len; +} + +int proc_set_rx_stbc(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + u32 mode; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + + int num = sscanf(tmp, "%d ", &mode); + + if( pregpriv && (mode == 0 || mode == 1|| mode == 2|| mode == 3)) + { + pregpriv->rx_stbc= mode; + printk("rx_stbc=%d\n", mode); + } + } + + return count; + +} + +int proc_get_vid(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + u16 VID=0; + int len = 0; + + rtw_hal_get_hwreg(padapter, HW_VAR_VID, (u8 *)&VID); + len += snprintf(page + len, count - len, + "%04x\n", + VID + ); + + *eof = 1; + return len; +} + +int proc_get_pid(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + u16 PID=0; + int len = 0; + + rtw_hal_get_hwreg(padapter, HW_VAR_PID, (u8 *)&PID); + len += snprintf(page + len, count - len, + "%04x\n", + PID + ); + + *eof = 1; + return len; +} + int proc_get_rssi_disp(char *page, char **start, off_t offset, int count, int *eof, void *data) @@ -703,7 +1221,117 @@ int proc_get_best_channel(char *page, char **start, return len; } + +int proc_set_best_channel(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + char tmp[32]; + + if(count < 1) + return -EFAULT; + + if(buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) + { + int i; + for(i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) + { + pmlmeext->channel_set[i].rx_count = 0; + } + + DBG_871X("set %s\n", "Clean Best Channel Count"); + } + + return count; +} #endif /* CONFIG_FIND_BEST_CHANNEL */ + +#if defined(DBG_CONFIG_ERROR_DETECT) +#include +int proc_get_sreset(char *page, char **start, off_t offset, int count, int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + int len = 0; + + *eof = 1; + return len; +} + +int proc_set_sreset(struct file *file, const char *buffer, unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + char tmp[32]; + s32 trigger_point; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + + int num = sscanf(tmp, "%d", &trigger_point); + + if (trigger_point == SRESET_TGP_NULL) + rtw_hal_sreset_reset(padapter); + else + sreset_set_trigger_point(padapter, trigger_point); + } + + return count; + +} +#endif /* DBG_CONFIG_ERROR_DETECT */ + +#ifdef CONFIG_DM_ADAPTIVITY +int proc_get_dm_adaptivity(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + int len = 0; + + len += dm_adaptivity_get_parm_str(padapter, page, count); + + *eof = 1; + return len; +} + +int proc_set_dm_adaptivity(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); + char tmp[32]; + u32 TH_L2H_ini; + s8 TH_EDCCA_HL_diff; + u32 IGI_Base; + int ForceEDCCA; + u8 AdapEn_RSSI; + u8 IGI_LowerBound; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + + int num = sscanf(tmp, "%x %hhd %x %d %hhu %hhu", + &TH_L2H_ini, &TH_EDCCA_HL_diff, &IGI_Base, &ForceEDCCA, &AdapEn_RSSI, &IGI_LowerBound); + + if (num != 6) + return count; + + dm_adaptivity_set_parm(padapter, (s8)TH_L2H_ini, TH_EDCCA_HL_diff, (s8)IGI_Base, (bool)ForceEDCCA, AdapEn_RSSI, IGI_LowerBound); + } + + return count; +} +#endif /* CONFIG_DM_ADAPTIVITY */ + #endif diff --git a/drivers/net/wireless/rtl8192cu/core/rtw_eeprom.c b/drivers/net/wireless/rtl8192cu/core/rtw_eeprom.c index 4a0832b..fd07d64 100644 --- a/drivers/net/wireless/rtl8192cu/core/rtw_eeprom.c +++ b/drivers/net/wireless/rtl8192cu/core/rtw_eeprom.c @@ -16,8 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * * - -******************************************************************************/ + ******************************************************************************/ #define _RTW_EEPROM_C_ #include diff --git a/drivers/net/wireless/rtl8192cu/core/rtw_ieee80211.c b/drivers/net/wireless/rtl8192cu/core/rtw_ieee80211.c index 2b85af9..6305ba3 100644 --- a/drivers/net/wireless/rtl8192cu/core/rtw_ieee80211.c +++ b/drivers/net/wireless/rtl8192cu/core/rtw_ieee80211.c @@ -25,7 +25,27 @@ #include #include - +u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 }; +u16 RTW_WPA_VERSION = 1; +u8 WPA_AUTH_KEY_MGMT_NONE[] = { 0x00, 0x50, 0xf2, 0 }; +u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x50, 0xf2, 1 }; +u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x50, 0xf2, 2 }; +u8 WPA_CIPHER_SUITE_NONE[] = { 0x00, 0x50, 0xf2, 0 }; +u8 WPA_CIPHER_SUITE_WEP40[] = { 0x00, 0x50, 0xf2, 1 }; +u8 WPA_CIPHER_SUITE_TKIP[] = { 0x00, 0x50, 0xf2, 2 }; +u8 WPA_CIPHER_SUITE_WRAP[] = { 0x00, 0x50, 0xf2, 3 }; +u8 WPA_CIPHER_SUITE_CCMP[] = { 0x00, 0x50, 0xf2, 4 }; +u8 WPA_CIPHER_SUITE_WEP104[] = { 0x00, 0x50, 0xf2, 5 }; + +u16 RSN_VERSION_BSD = 1; +u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x0f, 0xac, 1 }; +u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x0f, 0xac, 2 }; +u8 RSN_CIPHER_SUITE_NONE[] = { 0x00, 0x0f, 0xac, 0 }; +u8 RSN_CIPHER_SUITE_WEP40[] = { 0x00, 0x0f, 0xac, 1 }; +u8 RSN_CIPHER_SUITE_TKIP[] = { 0x00, 0x0f, 0xac, 2 }; +u8 RSN_CIPHER_SUITE_WRAP[] = { 0x00, 0x0f, 0xac, 3 }; +u8 RSN_CIPHER_SUITE_CCMP[] = { 0x00, 0x0f, 0xac, 4 }; +u8 RSN_CIPHER_SUITE_WEP104[] = { 0x00, 0x0f, 0xac, 5 }; //----------------------------------------------------------- // for adhoc-master to generate ie and provide supported-rate to fw //----------------------------------------------------------- @@ -147,7 +167,58 @@ _func_enter_; _func_exit_; } +inline u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, + u8 new_ch, u8 ch_switch_cnt) +{ + u8 ie_data[3]; + + ie_data[0] = ch_switch_mode; + ie_data[1] = new_ch; + ie_data[2] = ch_switch_cnt; + return rtw_set_ie(buf, WLAN_EID_CHANNEL_SWITCH, 3, ie_data, buf_len); +} + +inline u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset) +{ + if (ch_offset == SCN) + return HAL_PRIME_CHNL_OFFSET_DONT_CARE; + else if(ch_offset == SCA) + return HAL_PRIME_CHNL_OFFSET_UPPER; + else if(ch_offset == SCB) + return HAL_PRIME_CHNL_OFFSET_LOWER; + + return HAL_PRIME_CHNL_OFFSET_DONT_CARE; +} + +inline u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset) +{ + if (ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) + return SCN; + else if(ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) + return SCB; + else if(ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) + return SCA; + + return SCN; +} + +inline u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset) +{ + return rtw_set_ie(buf, WLAN_EID_SECONDARY_CHANNEL_OFFSET, 1, &secondary_ch_offset, buf_len); +} + +inline u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, + u8 flags, u16 reason, u16 precedence) +{ + u8 ie_data[6]; + + ie_data[0] = ttl; + ie_data[1] = flags; + RTW_PUT_LE16((u8*)&ie_data[2], reason); + RTW_PUT_LE16((u8*)&ie_data[4], precedence); + return rtw_set_ie(buf, 0x118, 6, ie_data, buf_len); +} /*---------------------------------------------------------------------------- index: the information element id index, limit is the limit for search @@ -185,6 +256,104 @@ _func_exit_; return NULL; } +/** + * rtw_get_ie_ex - Search specific IE from a series of IEs + * @in_ie: Address of IEs to search + * @in_len: Length limit from in_ie + * @eid: Element ID to match + * @oui: OUI to match + * @oui_len: OUI length + * @ie: If not NULL and the specific IE is found, the IE will be copied to the buf starting from the specific IE + * @ielen: If not NULL and the specific IE is found, will set to the length of the entire IE + * + * Returns: The address of the specific IE found, or NULL + */ +u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen) +{ + uint cnt; + u8 *target_ie = NULL; + + + if(ielen) + *ielen = 0; + + if(!in_ie || in_len<=0) + return target_ie; + + cnt = 0; + + while(cnt='0')&&(ch<='9')) return ch - '0'; @@ -1030,16 +1197,23 @@ u8 key_char2num(u8 ch) return 0xff; } +u8 str_2char2num(u8 hch, u8 lch); u8 str_2char2num(u8 hch, u8 lch) { return ((key_char2num(hch) * 10 ) + key_char2num(lch)); } +u8 key_2char2num(u8 hch, u8 lch); u8 key_2char2num(u8 hch, u8 lch) { return ((key_char2num(hch) << 4) | key_char2num(lch)); } +u8 convert_ip_addr(u8 hch, u8 mch, u8 lch) +{ + return ((key_char2num(hch) * 100) + (key_char2num(mch) * 10 ) + key_char2num(lch)); +} + extern char* rtw_initmac; void rtw_macaddr_cfg(u8 *mac_addr) { @@ -1074,10 +1248,10 @@ void rtw_macaddr_cfg(u8 *mac_addr) mac[5] = 0x00; // use default mac addresss _rtw_memcpy(mac_addr, mac, ETH_ALEN); - DBG_8192C("MAC Address from efuse error, assign default one !!!\n"); + DBG_871X("MAC Address from efuse error, assign default one !!!\n"); } - DBG_8192C("rtw_macaddr_cfg MAC Address = "MAC_FMT"\n", MAC_ARG(mac_addr)); + DBG_871X("rtw_macaddr_cfg MAC Address = "MAC_FMT"\n", MAC_ARG(mac_addr)); } void dump_ies(u8 *buf, u32 buf_len) { @@ -1122,6 +1296,77 @@ void dump_wps_ie(u8 *ie, u32 ie_len) { } #ifdef CONFIG_P2P +/** + * rtw_get_p2p_merged_len - Get merged ie length from muitiple p2p ies. + * @in_ie: Pointer of the first p2p ie + * @in_len: Total len of muiltiple p2p ies + * Returns: Length of merged p2p ie length + */ +u32 rtw_get_p2p_merged_ies_len(u8 *in_ie, u32 in_len) +{ + PNDIS_802_11_VARIABLE_IEs pIE; + u8 OUI[4] = { 0x50, 0x6f, 0x9a, 0x09 }; + int i=0; + int j=0, len=0; + + while( i < in_len) + { + pIE = (PNDIS_802_11_VARIABLE_IEs)(in_ie+ i); + + if( pIE->ElementID == _VENDOR_SPECIFIC_IE_ && _rtw_memcmp(pIE->data, OUI, 4) ) + { + len += pIE->Length-4; // 4 is P2P OUI length, don't count it in this loop + } + + i += (pIE->Length + 2); + } + + return len + 4; // Append P2P OUI length at last. +} + +/** + * rtw_p2p_merge_ies - Merge muitiple p2p ies into one + * @in_ie: Pointer of the first p2p ie + * @in_len: Total len of muiltiple p2p ies + * @merge_ie: Pointer of merged ie + * Returns: Length of merged p2p ie + */ +int rtw_p2p_merge_ies(u8 *in_ie, u32 in_len, u8 *merge_ie) +{ + PNDIS_802_11_VARIABLE_IEs pIE; + u8 len = 0; + u8 OUI[4] = { 0x50, 0x6f, 0x9a, 0x09 }; + u8 ELOUI[6] = { 0xDD, 0x00, 0x50, 0x6f, 0x9a, 0x09 }; //EID;Len;OUI, Len would copy at the end of function + int i=0; + + if( merge_ie != NULL) + { + //Set first P2P OUI + _rtw_memcpy(merge_ie, ELOUI, 6); + merge_ie += 6; + + while( i < in_len) + { + pIE = (PNDIS_802_11_VARIABLE_IEs)(in_ie+ i); + + // Take out the rest of P2P OUIs + if( pIE->ElementID == _VENDOR_SPECIFIC_IE_ && _rtw_memcmp(pIE->data, OUI, 4) ) + { + _rtw_memcpy( merge_ie, pIE->data +4, pIE->Length -4); + len += pIE->Length-4; + merge_ie += pIE->Length-4; + } + + i += (pIE->Length + 2); + } + + return len + 4; // 4 is for P2P OUI + + } + + return 0; +} + void dump_p2p_ie(u8 *ie, u32 ie_len) { u8* pos = (u8*)ie; u8 id; @@ -1154,7 +1399,7 @@ void dump_p2p_ie(u8 *ie, u32 ie_len) { * * Returns: The address of the P2P IE found, or NULL */ -u8 *rtw_get_p2p_ie(u8 *in_ie, uint in_len, u8 *p2p_ie, uint *p2p_ielen) +u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) { uint cnt = 0; u8 *p2p_ie_ptr; @@ -1166,7 +1411,12 @@ u8 *rtw_get_p2p_ie(u8 *in_ie, uint in_len, u8 *p2p_ie, uint *p2p_ielen) while(cnt MAX_IE_SZ)) { +#ifdef PLATFORM_LINUX + dump_stack(); +#endif + return NULL; + } if( ( eid == _VENDOR_SPECIFIC_IE_ ) && ( _rtw_memcmp( &in_ie[cnt+2], p2p_oui, 4) == _TRUE ) ) { p2p_ie_ptr = in_ie + cnt; @@ -1215,7 +1465,7 @@ u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_attr if(len_attr) *len_attr = 0; - if ( ( p2p_ie[0] != _VENDOR_SPECIFIC_IE_ ) || + if ( !p2p_ie || ( p2p_ie[0] != _VENDOR_SPECIFIC_IE_ ) || ( _rtw_memcmp( p2p_ie + 2, p2p_oui , 4 ) != _TRUE ) ) { return attr_ptr; @@ -1381,8 +1631,10 @@ void rtw_WLAN_BSSID_EX_remove_p2p_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id) } } +#endif //CONFIG_P2P + #ifdef CONFIG_WFD -int rtw_get_wfd_ie(u8 *in_ie, uint in_len, u8 *wfd_ie, uint *wfd_ielen) +int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen) { int match; uint cnt = 0; @@ -1390,6 +1642,12 @@ int rtw_get_wfd_ie(u8 *in_ie, uint in_len, u8 *wfd_ie, uint *wfd_ielen) match=_FALSE; + + if ( in_len < 0 ) + { + return match; + } + while(cnt