brcm2708: update against latest rpi-3.10.y branch
[openwrt/svn-archive/archive.git] / target / linux / brcm2708 / patches-3.10 / 0097-wifi-Update-to-newer-rtl8192cu-driver-release.patch
1 From f74f54da3639f0dc1fb203c7d5b987b9b9fb0bb4 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Sat, 9 Nov 2013 12:17:56 +0000
4 Subject: [PATCH 097/174] wifi: Update to newer rtl8192cu driver release
5
6 ---
7 drivers/net/wireless/rtl8192cu/Kconfig | 4 +-
8 drivers/net/wireless/rtl8192cu/Makefile | 343 +-
9 drivers/net/wireless/rtl8192cu/clean | 4 -
10 .../net/wireless/rtl8192cu/core/efuse/rtw_efuse.c | 68 +-
11 drivers/net/wireless/rtl8192cu/core/rtw_ap.c | 2940 ++
12 drivers/net/wireless/rtl8192cu/core/rtw_br_ext.c | 25 +-
13 drivers/net/wireless/rtl8192cu/core/rtw_cmd.c | 723 +-
14 drivers/net/wireless/rtl8192cu/core/rtw_debug.c | 672 +-
15 drivers/net/wireless/rtl8192cu/core/rtw_eeprom.c | 3 +-
16 .../net/wireless/rtl8192cu/core/rtw_ieee80211.c | 485 +-
17 drivers/net/wireless/rtl8192cu/core/rtw_io.c | 276 +-
18 .../net/wireless/rtl8192cu/core/rtw_ioctl_query.c | 3 +-
19 .../net/wireless/rtl8192cu/core/rtw_ioctl_rtl.c | 3 +-
20 .../net/wireless/rtl8192cu/core/rtw_ioctl_set.c | 374 +-
21 drivers/net/wireless/rtl8192cu/core/rtw_iol.c | 15 +-
22 drivers/net/wireless/rtl8192cu/core/rtw_mlme.c | 966 +-
23 drivers/net/wireless/rtl8192cu/core/rtw_mlme_ext.c | 11414 ++++---
24 drivers/net/wireless/rtl8192cu/core/rtw_mp.c | 111 +-
25 drivers/net/wireless/rtl8192cu/core/rtw_mp_ioctl.c | 313 +-
26 drivers/net/wireless/rtl8192cu/core/rtw_p2p.c | 3044 +-
27 drivers/net/wireless/rtl8192cu/core/rtw_pwrctrl.c | 1319 +-
28 drivers/net/wireless/rtl8192cu/core/rtw_recv.c | 2328 +-
29 drivers/net/wireless/rtl8192cu/core/rtw_rf.c | 3 +-
30 drivers/net/wireless/rtl8192cu/core/rtw_security.c | 420 +-
31 drivers/net/wireless/rtl8192cu/core/rtw_sreset.c | 352 +
32 drivers/net/wireless/rtl8192cu/core/rtw_sta_mgt.c | 232 +-
33 drivers/net/wireless/rtl8192cu/core/rtw_tdls.c | 2941 ++
34 .../net/wireless/rtl8192cu/core/rtw_wlan_util.c | 663 +-
35 drivers/net/wireless/rtl8192cu/core/rtw_xmit.c | 2161 +-
36 drivers/net/wireless/rtl8192cu/hal/HalPwrSeqCmd.c | 177 +
37 drivers/net/wireless/rtl8192cu/hal/dm.c | 314 +
38 drivers/net/wireless/rtl8192cu/hal/dm.h | 30 +
39 drivers/net/wireless/rtl8192cu/hal/hal_com.c | 371 +
40 drivers/net/wireless/rtl8192cu/hal/hal_init.c | 120 -
41 drivers/net/wireless/rtl8192cu/hal/hal_intf.c | 546 +
42 .../wireless/rtl8192cu/hal/rtl8192c/rtl8192c_cmd.c | 504 +-
43 .../wireless/rtl8192cu/hal/rtl8192c/rtl8192c_dm.c | 608 +-
44 .../rtl8192cu/hal/rtl8192c/rtl8192c_hal_init.c | 410 +-
45 .../wireless/rtl8192cu/hal/rtl8192c/rtl8192c_mp.c | 31 +-
46 .../rtl8192cu/hal/rtl8192c/rtl8192c_phycfg.c | 1726 +-
47 .../rtl8192cu/hal/rtl8192c/rtl8192c_rf6052.c | 154 +-
48 .../rtl8192cu/hal/rtl8192c/rtl8192c_rxdesc.c | 121 +-
49 .../rtl8192cu/hal/rtl8192c/rtl8192c_sreset.c | 257 +-
50 .../rtl8192cu/hal/rtl8192c/rtl8192c_xmit.c | 63 +
51 .../rtl8192cu/hal/rtl8192c/usb/Hal8192CUHWImg.c | 11548 ++++---
52 .../rtl8192cu/hal/rtl8192c/usb/rtl8192cu_led.c | 403 +-
53 .../rtl8192cu/hal/rtl8192c/usb/rtl8192cu_recv.c | 159 +-
54 .../rtl8192cu/hal/rtl8192c/usb/rtl8192cu_xmit.c | 470 +-
55 .../rtl8192cu/hal/rtl8192c/usb/usb_halinit.c | 1758 +-
56 .../rtl8192cu/hal/rtl8192c/usb/usb_ops_ce.c | 5 +-
57 .../rtl8192cu/hal/rtl8192c/usb/usb_ops_linux.c | 1291 +-
58 .../rtl8192cu/hal/rtl8192c/usb/usb_ops_xp.c | 7 +-
59 drivers/net/wireless/rtl8192cu/ifcfg-wlan0 | 0
60 .../wireless/rtl8192cu/include/Hal8192CEHWImg.h | 16 +-
61 .../wireless/rtl8192cu/include/Hal8192CPhyCfg.h | 35 +-
62 .../wireless/rtl8192cu/include/Hal8192CPhyReg.h | 21 +
63 .../wireless/rtl8192cu/include/Hal8192CUHWImg.h | 26 +-
64 .../wireless/rtl8192cu/include/Hal8192DEHWImg.h | 82 +-
65 .../rtl8192cu/include/Hal8192DETestHWImg.h | 54 -
66 .../wireless/rtl8192cu/include/Hal8192DPhyCfg.h | 26 +-
67 .../wireless/rtl8192cu/include/Hal8192DUHWImg.h | 4 +-
68 .../rtl8192cu/include/Hal8192DUHWImg_wowlan.h | 2 +-
69 .../rtl8192cu/include/Hal8192DUTestHWImg.h | 54 -
70 .../net/wireless/rtl8192cu/include/HalPwrSeqCmd.h | 137 +
71 drivers/net/wireless/rtl8192cu/include/autoconf.h | 114 +-
72 .../net/wireless/rtl8192cu/include/basic_types.h | 45 +
73 .../wireless/rtl8192cu/include/byteorder/generic.h | 9 +-
74 .../wireless/rtl8192cu/include/byteorder/swab.h | 15 +-
75 .../wireless/rtl8192cu/include/byteorder/swabb.h | 3 +-
76 drivers/net/wireless/rtl8192cu/include/drv_conf.h | 2 +-
77 drivers/net/wireless/rtl8192cu/include/drv_types.h | 305 +-
78 .../wireless/rtl8192cu/include/drv_types_sdio.h | 70 +
79 drivers/net/wireless/rtl8192cu/include/farray.h | 31480 -------------------
80 drivers/net/wireless/rtl8192cu/include/hal_com.h | 146 +
81 drivers/net/wireless/rtl8192cu/include/hal_init.h | 305 -
82 drivers/net/wireless/rtl8192cu/include/hal_intf.h | 432 +
83 drivers/net/wireless/rtl8192cu/include/ieee80211.h | 389 +-
84 drivers/net/wireless/rtl8192cu/include/if_ether.h | 30 +-
85 .../wireless/rtl8192cu/include/ioctl_cfg80211.h | 105 +-
86 drivers/net/wireless/rtl8192cu/include/ip.h | 27 +-
87 .../wireless/rtl8192cu/include/linux/wireless.h | 90 +
88 .../net/wireless/rtl8192cu/include/mlme_osdep.h | 4 -
89 .../net/wireless/rtl8192cu/include/osdep_intf.h | 61 +-
90 .../net/wireless/rtl8192cu/include/osdep_service.h | 1096 +-
91 drivers/net/wireless/rtl8192cu/include/pci_ops.h | 2 +
92 .../net/wireless/rtl8192cu/include/rtl8192c_cmd.h | 50 +-
93 .../net/wireless/rtl8192cu/include/rtl8192c_dm.h | 140 +-
94 .../wireless/rtl8192cu/include/rtl8192c_event.h | 3 +-
95 .../net/wireless/rtl8192cu/include/rtl8192c_hal.h | 110 +-
96 .../net/wireless/rtl8192cu/include/rtl8192c_led.h | 3 +-
97 .../net/wireless/rtl8192cu/include/rtl8192c_recv.h | 23 +-
98 .../net/wireless/rtl8192cu/include/rtl8192c_rf.h | 3 +-
99 .../net/wireless/rtl8192cu/include/rtl8192c_spec.h | 66 +-
100 .../wireless/rtl8192cu/include/rtl8192c_sreset.h | 26 +-
101 .../net/wireless/rtl8192cu/include/rtl8192c_xmit.h | 68 +-
102 .../net/wireless/rtl8192cu/include/rtl8192d_cmd.h | 17 +-
103 .../net/wireless/rtl8192cu/include/rtl8192d_dm.h | 52 +-
104 .../net/wireless/rtl8192cu/include/rtl8192d_hal.h | 171 +-
105 .../net/wireless/rtl8192cu/include/rtl8192d_led.h | 3 +-
106 .../net/wireless/rtl8192cu/include/rtl8192d_recv.h | 6 +-
107 .../net/wireless/rtl8192cu/include/rtl8192d_rf.h | 3 +-
108 .../net/wireless/rtl8192cu/include/rtl8192d_spec.h | 60 +-
109 .../net/wireless/rtl8192cu/include/rtl8192d_xmit.h | 69 +-
110 .../net/wireless/rtl8192cu/include/rtw_android.h | 18 +-
111 drivers/net/wireless/rtl8192cu/include/rtw_ap.h | 64 +
112 .../net/wireless/rtl8192cu/include/rtw_byteorder.h | 3 +-
113 drivers/net/wireless/rtl8192cu/include/rtw_cmd.h | 63 +-
114 drivers/net/wireless/rtl8192cu/include/rtw_debug.h | 287 +-
115 .../net/wireless/rtl8192cu/include/rtw_eeprom.h | 3 +-
116 drivers/net/wireless/rtl8192cu/include/rtw_efuse.h | 5 +-
117 drivers/net/wireless/rtl8192cu/include/rtw_event.h | 6 +-
118 drivers/net/wireless/rtl8192cu/include/rtw_ht.h | 3 +-
119 drivers/net/wireless/rtl8192cu/include/rtw_io.h | 83 +-
120 drivers/net/wireless/rtl8192cu/include/rtw_ioctl.h | 22 +-
121 .../wireless/rtl8192cu/include/rtw_ioctl_query.h | 3 +-
122 .../net/wireless/rtl8192cu/include/rtw_ioctl_rtl.h | 3 +-
123 .../net/wireless/rtl8192cu/include/rtw_ioctl_set.h | 11 +-
124 drivers/net/wireless/rtl8192cu/include/rtw_led.h | 23 +-
125 drivers/net/wireless/rtl8192cu/include/rtw_mlme.h | 295 +-
126 .../net/wireless/rtl8192cu/include/rtw_mlme_ext.h | 275 +-
127 drivers/net/wireless/rtl8192cu/include/rtw_mp.h | 10 +-
128 .../net/wireless/rtl8192cu/include/rtw_mp_ioctl.h | 2 +-
129 .../wireless/rtl8192cu/include/rtw_mp_phy_regdef.h | 3 +-
130 drivers/net/wireless/rtl8192cu/include/rtw_p2p.h | 18 +-
131 .../net/wireless/rtl8192cu/include/rtw_pwrctrl.h | 125 +-
132 drivers/net/wireless/rtl8192cu/include/rtw_qos.h | 3 +-
133 drivers/net/wireless/rtl8192cu/include/rtw_recv.h | 237 +-
134 drivers/net/wireless/rtl8192cu/include/rtw_rf.h | 2 +-
135 .../net/wireless/rtl8192cu/include/rtw_security.h | 38 +-
136 .../net/wireless/rtl8192cu/include/rtw_sreset.h | 74 +
137 drivers/net/wireless/rtl8192cu/include/rtw_tdls.h | 143 +
138 .../net/wireless/rtl8192cu/include/rtw_version.h | 2 +-
139 drivers/net/wireless/rtl8192cu/include/rtw_xmit.h | 254 +-
140 drivers/net/wireless/rtl8192cu/include/sdio_hal.h | 34 -
141 drivers/net/wireless/rtl8192cu/include/sdio_ops.h | 80 -
142 .../net/wireless/rtl8192cu/include/sdio_ops_ce.h | 56 -
143 .../wireless/rtl8192cu/include/sdio_ops_linux.h | 55 -
144 .../net/wireless/rtl8192cu/include/sdio_ops_xp.h | 56 -
145 .../net/wireless/rtl8192cu/include/sdio_osintf.h | 48 -
146 drivers/net/wireless/rtl8192cu/include/sta_info.h | 117 +-
147 drivers/net/wireless/rtl8192cu/include/usb_hal.h | 9 +-
148 drivers/net/wireless/rtl8192cu/include/usb_ops.h | 26 +-
149 .../net/wireless/rtl8192cu/include/usb_ops_linux.h | 63 +
150 .../net/wireless/rtl8192cu/include/usb_osintf.h | 3 +-
151 .../wireless/rtl8192cu/include/usb_vendor_req.h | 3 +-
152 drivers/net/wireless/rtl8192cu/include/wifi.h | 134 +-
153 .../net/wireless/rtl8192cu/include/wlan_bssdef.h | 292 +-
154 .../net/wireless/rtl8192cu/include/xmit_osdep.h | 11 +-
155 .../rtl8192cu/os_dep/linux/ioctl_cfg80211.c | 3771 ++-
156 .../wireless/rtl8192cu/os_dep/linux/ioctl_linux.c | 5232 ++-
157 .../wireless/rtl8192cu/os_dep/linux/mlme_linux.c | 236 +-
158 .../net/wireless/rtl8192cu/os_dep/linux/os_intfs.c | 2049 +-
159 .../net/wireless/rtl8192cu/os_dep/linux/pci_intf.c | 1002 +-
160 .../rtl8192cu/os_dep/linux/pci_ops_linux.c | 24 +
161 .../wireless/rtl8192cu/os_dep/linux/recv_linux.c | 142 +-
162 .../wireless/rtl8192cu/os_dep/linux/rtw_android.c | 220 +-
163 .../wireless/rtl8192cu/os_dep/linux/sdio_intf.c | 922 -
164 .../net/wireless/rtl8192cu/os_dep/linux/usb_intf.c | 1726 +-
165 .../rtl8192cu/os_dep/linux/usb_ops_linux.c | 649 +
166 .../wireless/rtl8192cu/os_dep/linux/xmit_linux.c | 136 +-
167 .../net/wireless/rtl8192cu/os_dep/osdep_service.c | 1143 +-
168 drivers/net/wireless/rtl8192cu/runwpa | 20 +
169 drivers/net/wireless/rtl8192cu/wlan0dhcp | 0
170 163 files changed, 48963 insertions(+), 60712 deletions(-)
171 mode change 100644 => 100755 drivers/net/wireless/rtl8192cu/clean
172 create mode 100644 drivers/net/wireless/rtl8192cu/core/rtw_ap.c
173 create mode 100644 drivers/net/wireless/rtl8192cu/core/rtw_sreset.c
174 create mode 100644 drivers/net/wireless/rtl8192cu/core/rtw_tdls.c
175 create mode 100644 drivers/net/wireless/rtl8192cu/hal/HalPwrSeqCmd.c
176 create mode 100644 drivers/net/wireless/rtl8192cu/hal/dm.c
177 create mode 100644 drivers/net/wireless/rtl8192cu/hal/dm.h
178 create mode 100644 drivers/net/wireless/rtl8192cu/hal/hal_com.c
179 delete mode 100644 drivers/net/wireless/rtl8192cu/hal/hal_init.c
180 create mode 100644 drivers/net/wireless/rtl8192cu/hal/hal_intf.c
181 create mode 100644 drivers/net/wireless/rtl8192cu/hal/rtl8192c/rtl8192c_xmit.c
182 mode change 100644 => 100755 drivers/net/wireless/rtl8192cu/ifcfg-wlan0
183 delete mode 100644 drivers/net/wireless/rtl8192cu/include/Hal8192DETestHWImg.h
184 delete mode 100644 drivers/net/wireless/rtl8192cu/include/Hal8192DUTestHWImg.h
185 create mode 100644 drivers/net/wireless/rtl8192cu/include/HalPwrSeqCmd.h
186 create mode 100644 drivers/net/wireless/rtl8192cu/include/drv_types_sdio.h
187 delete mode 100644 drivers/net/wireless/rtl8192cu/include/farray.h
188 create mode 100644 drivers/net/wireless/rtl8192cu/include/hal_com.h
189 delete mode 100644 drivers/net/wireless/rtl8192cu/include/hal_init.h
190 create mode 100644 drivers/net/wireless/rtl8192cu/include/hal_intf.h
191 create mode 100644 drivers/net/wireless/rtl8192cu/include/linux/wireless.h
192 create mode 100644 drivers/net/wireless/rtl8192cu/include/rtw_ap.h
193 create mode 100644 drivers/net/wireless/rtl8192cu/include/rtw_sreset.h
194 create mode 100644 drivers/net/wireless/rtl8192cu/include/rtw_tdls.h
195 delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_hal.h
196 delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_ops.h
197 delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_ops_ce.h
198 delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_ops_linux.h
199 delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_ops_xp.h
200 delete mode 100644 drivers/net/wireless/rtl8192cu/include/sdio_osintf.h
201 create mode 100644 drivers/net/wireless/rtl8192cu/include/usb_ops_linux.h
202 create mode 100644 drivers/net/wireless/rtl8192cu/os_dep/linux/pci_ops_linux.c
203 delete mode 100644 drivers/net/wireless/rtl8192cu/os_dep/linux/sdio_intf.c
204 create mode 100644 drivers/net/wireless/rtl8192cu/os_dep/linux/usb_ops_linux.c
205 create mode 100755 drivers/net/wireless/rtl8192cu/runwpa
206 mode change 100644 => 100755 drivers/net/wireless/rtl8192cu/wlan0dhcp
207
208 --- a/drivers/net/wireless/rtl8192cu/Kconfig
209 +++ b/drivers/net/wireless/rtl8192cu/Kconfig
210 @@ -1,8 +1,6 @@
211 config RTL8192CU
212 tristate "Realtek 8192C USB WiFi"
213 depends on USB
214 - select WIRELESS_EXT
215 - select WEXT_PRIV
216 ---help---
217 - Enable wireless network adapters based on Realtek RTL8192C chipset family, such as EDUP nano series
218 + Help message of RTL8192CU
219
220 --- a/drivers/net/wireless/rtl8192cu/Makefile
221 +++ b/drivers/net/wireless/rtl8192cu/Makefile
222 @@ -1,15 +1,15 @@
223 EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
224 EXTRA_CFLAGS += -O1
225 #EXTRA_CFLAGS += -O3
226 -#EXTRA_CFLAGS += -Wall
227 -#EXTRA_CFLAGS += -Wextra
228 +#EXTRA_CFLAGS += -Wall
229 +#EXTRA_CFLAGS += -Wextra
230 #EXTRA_CFLAGS += -Werror
231 #EXTRA_CFLAGS += -pedantic
232 -#EXTRA_CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
233 +#EXTRA_CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
234
235 -EXTRA_CFLAGS += -Wno-unused-variable
236 -EXTRA_CFLAGS += -Wno-unused-value
237 -EXTRA_CFLAGS += -Wno-unused-label
238 +EXTRA_CFLAGS += -Wno-unused-variable
239 +EXTRA_CFLAGS += -Wno-unused-value
240 +EXTRA_CFLAGS += -Wno-unused-label
241 EXTRA_CFLAGS += -Wno-unused-parameter
242 EXTRA_CFLAGS += -Wno-unused-function
243 EXTRA_CFLAGS += -Wno-unused
244 @@ -22,23 +22,26 @@ CONFIG_AUTOCFG_CP = n
245
246 CONFIG_RTL8192C = y
247 CONFIG_RTL8192D = n
248 +CONFIG_RTL8723A = n
249
250 CONFIG_USB_HCI = y
251 CONFIG_PCI_HCI = n
252 CONFIG_SDIO_HCI = n
253
254 CONFIG_MP_INCLUDED = n
255 -CONFIG_POWER_SAVING = y
256 -CONFIG_USB_AUTOSUSPEND = n
257 -CONFIG_HW_PWRP_DETECTION = n
258 -CONFIG_WIFI_TEST = n
259 -CONFIG_BT_COEXISTENCE = n
260 -CONFIG_RTL8192CU_REDEFINE_1X1 =n
261 -CONFIG_WAKE_ON_WLAN = n
262 +CONFIG_POWER_SAVING = y
263 +CONFIG_USB_AUTOSUSPEND = n
264 +CONFIG_HW_PWRP_DETECTION = n
265 +CONFIG_WIFI_TEST = n
266 +CONFIG_BT_COEXISTENCE = n
267 +CONFIG_RTL8192CU_REDEFINE_1X1 = n
268 +CONFIG_INTEL_WIDI = n
269 +CONFIG_WAKE_ON_WLAN = n
270
271 -CONFIG_PLATFORM_I386_PC = n
272 +CONFIG_PLATFORM_I386_PC = y
273 CONFIG_PLATFORM_TI_AM3517 = n
274 CONFIG_PLATFORM_ANDROID_X86 = n
275 +CONFIG_PLATFORM_JB_X86 = n
276 CONFIG_PLATFORM_ARM_S3C2K4 = n
277 CONFIG_PLATFORM_ARM_PXA2XX = n
278 CONFIG_PLATFORM_ARM_S3C6K4 = n
279 @@ -50,44 +53,33 @@ CONFIG_PLATFORM_MIPS_PLM = n
280 CONFIG_PLATFORM_MSTAR389 = n
281 CONFIG_PLATFORM_MT53XX = n
282 CONFIG_PLATFORM_ARM_MX51_241H = n
283 +CONFIG_PLATFORM_FS_MX61 = n
284 CONFIG_PLATFORM_ACTIONS_ATJ227X = n
285 -CONFIG_PLATFORM_ARM_TEGRA3 = n
286 +CONFIG_PLATFORM_TEGRA3_CARDHU = n
287 +CONFIG_PLATFORM_TEGRA4_DALMORE = n
288 CONFIG_PLATFORM_ARM_TCC8900 = n
289 CONFIG_PLATFORM_ARM_TCC8920 = n
290 +CONFIG_PLATFORM_ARM_TCC8920_JB42 = n
291 CONFIG_PLATFORM_ARM_RK2818 = n
292 CONFIG_PLATFORM_ARM_TI_PANDA = n
293 CONFIG_PLATFORM_MIPS_JZ4760 = n
294 CONFIG_PLATFORM_DMP_PHILIPS = n
295 -CONFIG_PLATFORM_TI_DM365 = n
296 +CONFIG_PLATFORM_TI_DM365 = n
297 CONFIG_PLATFORM_MN10300 = n
298 CONFIG_PLATFORM_MSTAR_TITANIA12 = n
299 -CONFIG_PLATFORM_ARM_BCM2708 = y
300 +CONFIG_PLATFORM_MSTAR_A3 = n
301 +CONFIG_PLATFORM_ARM_SUNxI = n
302 +CONFIG_PLATFORM_ARM_SUN6I = n
303
304 CONFIG_DRVEXT_MODULE = n
305
306 export TopDIR ?= $(shell pwd)
307
308
309 -ifeq ($(CONFIG_RTL8712), y)
310 -
311 -RTL871X = rtl8712
312 -
313 -ifeq ($(CONFIG_SDIO_HCI), y)
314 -MODULE_NAME = 8712s
315 -endif
316 -ifeq ($(CONFIG_USB_HCI), y)
317 -MODULE_NAME = 8712u
318 -endif
319 -
320 -endif
321 -
322 ifeq ($(CONFIG_RTL8192C), y)
323
324 RTL871X = rtl8192c
325
326 -ifeq ($(CONFIG_SDIO_HCI), y)
327 -MODULE_NAME = 8192cs
328 -endif
329 ifeq ($(CONFIG_USB_HCI), y)
330 MODULE_NAME = 8192cu
331 FW_FILES := hal/$(RTL871X)/usb/Hal8192CUHWImg.o
332 @@ -100,7 +92,9 @@ MODULE_NAME = 8192ce
333 FW_FILES := hal/$(RTL871X)/pci/Hal8192CEHWImg.o
334 endif
335
336 -CHIP_FILES := hal/$(RTL871X)/$(RTL871X)_sreset.o
337 +CHIP_FILES := \
338 + hal/$(RTL871X)/$(RTL871X)_sreset.o \
339 + hal/$(RTL871X)/$(RTL871X)_xmit.o
340 CHIP_FILES += $(FW_FILES)
341 endif
342
343 @@ -108,111 +102,101 @@ ifeq ($(CONFIG_RTL8192D), y)
344
345 RTL871X = rtl8192d
346
347 -ifeq ($(CONFIG_SDIO_HCI), y)
348 -MODULE_NAME = 8192ds
349 -endif
350 ifeq ($(CONFIG_USB_HCI), y)
351 MODULE_NAME = 8192du
352 -FW_FILES := hal/$(RTL871X)/usb/Hal8192DUHWImg.o \
353 - hal/$(RTL871X)/usb/Hal8192DUTestHWImg.o
354 +FW_FILES := hal/$(RTL871X)/usb/Hal8192DUHWImg.o
355 ifneq ($(CONFIG_WAKE_ON_WLAN), n)
356 FW_FILES += hal/$(RTL871X)/usb/Hal8192DUHWImg_wowlan.o
357 endif
358 endif
359 ifeq ($(CONFIG_PCI_HCI), y)
360 MODULE_NAME = 8192de
361 -FW_FILES := hal/$(RTL871X)/pci/Hal8192DEHWImg.o \
362 - hal/$(RTL871X)/pci/Hal8192DETestHWImg.o
363 +FW_FILES := hal/$(RTL871X)/pci/Hal8192DEHWImg.o
364 endif
365
366 +CHIP_FILES := \
367 + hal/$(RTL871X)/$(RTL871X)_xmit.o
368 CHIP_FILES += $(FW_FILES)
369 endif
370
371 -ifeq ($(CONFIG_SDIO_HCI), y)
372 +ifeq ($(CONFIG_RTL8723A), y)
373
374 -HCI_NAME = sdio
375 -
376 -_OS_INTFS_FILES := os_dep/osdep_service.o \
377 - os_dep/linux/os_intfs.o \
378 - os_dep/linux/sdio_intf.o \
379 - os_dep/linux/ioctl_linux.o \
380 - os_dep/linux/xmit_linux.o \
381 - os_dep/linux/mlme_linux.o \
382 - os_dep/linux/recv_linux.o \
383 - os_dep/linux/rtw_android.o
384 -
385 -_HAL_INTFS_FILES := hal/$(RTL871X)/hal_init.o \
386 - hal/$(RTL871X)/sdio_halinit.o \
387 - hal/$(RTL871X)/sdio_ops.o \
388 - hal/$(RTL871X)/sdio_ops_linux.o
389 +RTL871X = rtl8723a
390
391 +ifeq ($(CONFIG_SDIO_HCI), y)
392 +MODULE_NAME = 8723as
393 +FW_FILES := hal/$(RTL871X)/sdio/Hal8723SHWImg.o
394 endif
395
396 -
397 ifeq ($(CONFIG_USB_HCI), y)
398 +MODULE_NAME = 8723au
399 +FW_FILES := hal/$(RTL871X)/usb/Hal8723UHWImg.o
400 +endif
401
402 -HCI_NAME = usb
403 +ifeq ($(CONFIG_PCI_HCI), y)
404 +MODULE_NAME = 8723ae
405 +FW_FILES := hal/$(RTL871X)/pci/Hal8723EHWImg.o
406 +endif
407
408 -_OS_INTFS_FILES := os_dep/osdep_service.o \
409 - os_dep/linux/os_intfs.o \
410 - os_dep/linux/$(HCI_NAME)_intf.o \
411 - os_dep/linux/ioctl_linux.o \
412 - os_dep/linux/xmit_linux.o \
413 - os_dep/linux/mlme_linux.o \
414 - os_dep/linux/recv_linux.o \
415 - os_dep/linux/ioctl_cfg80211.o \
416 - os_dep/linux/rtw_android.o
417 +PWRSEQ_FILES := hal/HalPwrSeqCmd.o \
418 + hal/$(RTL871X)/Hal8723PwrSeq.o
419
420 -_HAL_INTFS_FILES := hal/hal_init.o \
421 - hal/$(RTL871X)/$(RTL871X)_hal_init.o \
422 - hal/$(RTL871X)/$(RTL871X)_phycfg.o \
423 - hal/$(RTL871X)/$(RTL871X)_rf6052.o \
424 - hal/$(RTL871X)/$(RTL871X)_dm.o \
425 - hal/$(RTL871X)/$(RTL871X)_rxdesc.o \
426 - hal/$(RTL871X)/$(RTL871X)_cmd.o \
427 - hal/$(RTL871X)/$(RTL871X)_mp.o \
428 - hal/$(RTL871X)/usb/usb_ops_linux.o \
429 - hal/$(RTL871X)/usb/usb_halinit.o \
430 - hal/$(RTL871X)/usb/rtl$(MODULE_NAME)_led.o \
431 - hal/$(RTL871X)/usb/rtl$(MODULE_NAME)_xmit.o \
432 - hal/$(RTL871X)/usb/rtl$(MODULE_NAME)_recv.o
433 -
434 -_HAL_INTFS_FILES += $(CHIP_FILES)
435 +CHIP_FILES += $(FW_FILES) $(PWRSEQ_FILES)
436 +
437 +endif
438
439 +ifeq ($(CONFIG_SDIO_HCI), y)
440 +HCI_NAME = sdio
441 endif
442
443 +ifeq ($(CONFIG_USB_HCI), y)
444 +HCI_NAME = usb
445 +endif
446
447 ifeq ($(CONFIG_PCI_HCI), y)
448 -
449 HCI_NAME = pci
450 +endif
451 +
452
453 _OS_INTFS_FILES := os_dep/osdep_service.o \
454 os_dep/linux/os_intfs.o \
455 os_dep/linux/$(HCI_NAME)_intf.o \
456 + os_dep/linux/$(HCI_NAME)_ops_linux.o \
457 os_dep/linux/ioctl_linux.o \
458 os_dep/linux/xmit_linux.o \
459 os_dep/linux/mlme_linux.o \
460 os_dep/linux/recv_linux.o \
461 + os_dep/linux/ioctl_cfg80211.o \
462 os_dep/linux/rtw_android.o
463
464 -_HAL_INTFS_FILES := hal/hal_init.o \
465 - hal/$(RTL871X)/$(RTL871X)_hal_init.o \
466 +
467 +_HAL_INTFS_FILES := hal/hal_intf.o \
468 + hal/hal_com.o \
469 + hal/dm.o \
470 + hal/$(RTL871X)/$(RTL871X)_hal_init.o \
471 hal/$(RTL871X)/$(RTL871X)_phycfg.o \
472 hal/$(RTL871X)/$(RTL871X)_rf6052.o \
473 hal/$(RTL871X)/$(RTL871X)_dm.o \
474 hal/$(RTL871X)/$(RTL871X)_rxdesc.o \
475 hal/$(RTL871X)/$(RTL871X)_cmd.o \
476 - hal/$(RTL871X)/$(RTL871X)_mp.o \
477 - hal/$(RTL871X)/pci/pci_ops_linux.o \
478 - hal/$(RTL871X)/pci/pci_halinit.o \
479 - hal/$(RTL871X)/pci/rtl$(MODULE_NAME)_led.o \
480 - hal/$(RTL871X)/pci/rtl$(MODULE_NAME)_xmit.o \
481 - hal/$(RTL871X)/pci/rtl$(MODULE_NAME)_recv.o
482 + hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_halinit.o \
483 + hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_led.o \
484 + hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_xmit.o \
485 + hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_recv.o
486
487 -_HAL_INTFS_FILES += $(CHIP_FILES)
488 +ifeq ($(CONFIG_SDIO_HCI), y)
489 +_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
490 +else
491 +_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops_linux.o
492 +endif
493
494 +ifeq ($(CONFIG_MP_INCLUDED), y)
495 +_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_mp.o
496 endif
497
498 +_HAL_INTFS_FILES += $(CHIP_FILES)
499 +
500 +
501 ifeq ($(CONFIG_AUTOCFG_CP), y)
502 $(shell cp $(TopDIR)/autoconf_$(RTL871X)_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h)
503 endif
504 @@ -238,22 +222,18 @@ endif
505
506 ifeq ($(CONFIG_BT_COEXISTENCE), y)
507 EXTRA_CFLAGS += -DCONFIG_BT_COEXISTENCE
508 -endif
509 +endif
510
511 ifeq ($(CONFIG_RTL8192CU_REDEFINE_1X1), y)
512 EXTRA_CFLAGS += -DRTL8192C_RECONFIG_TO_1T1R
513 -endif
514 +endif
515
516 ifeq ($(CONFIG_WAKE_ON_WLAN), y)
517 EXTRA_CFLAGS += -DCONFIG_WAKE_ON_WLAN
518 endif
519
520 -ifeq ($(CONFIG_PLATFORM_ARM_BCM2708), y)
521 -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
522 -ARCH := arm
523 -CROSS_COMPILE ?=
524 -KVER := 3.6.11+
525 -KSRC := /lib/modules/$(KVER)/build
526 +ifeq ($(CONFIG_INTEL_WIDI), y)
527 +EXTRA_CFLAGS += -DCONFIG_INTEL_WIDI
528 endif
529
530 ifeq ($(CONFIG_PLATFORM_I386_PC), y)
531 @@ -275,11 +255,20 @@ ARCH := arm
532 endif
533
534 ifeq ($(CONFIG_PLATFORM_MSTAR_TITANIA12), y)
535 -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_MSTAR_TITANIA12
536 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_MSTAR -DCONFIG_PLATFORM_MSTAR_TITANIA12
537 ARCH:=mips
538 -CROSS_COMPILE:= /work/mstar/mips-4.3/bin/mips-linux-gnu-
539 +CROSS_COMPILE:= /usr/src/Mstar_kernel/mips-4.3/bin/mips-linux-gnu-
540 KVER:= 2.6.28.9
541 -KSRC:= /work/mstar/2.6.28.9/
542 +KSRC:= /usr/src/Mstar_kernel/2.6.28.9/
543 +endif
544 +
545 +ifeq ($(CONFIG_PLATFORM_MSTAR_A3), y)
546 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_MSTAR -DCONFIG_PLATFORM_MSTAR_A3
547 +ARCH:=arm
548 +CROSS_COMPILE:= arm-none-linux-gnueabi-
549 +KVER:= 2.6.35.11
550 +KSRC:= /home/gary/PERFORCE/THEALE/RedLion/2.6.35.11/
551 +MODULE_NAME = wlan
552 endif
553
554 ifeq ($(CONFIG_PLATFORM_ANDROID_X86), y)
555 @@ -291,6 +280,18 @@ KSRC := /media/DATA-2/android-x86/ics-x8
556 MODULE_NAME :=wlan
557 endif
558
559 +ifeq ($(CONFIG_PLATFORM_JB_X86), y)
560 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
561 +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
562 +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
563 +EXTRA_CFLAGS += -DCONFIG_P2P_IPS
564 +SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
565 +ARCH := $(SUBARCH)
566 +CROSS_COMPILE := /home/android_sdk/android-x86_JB/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7/bin/i686-linux-android-
567 +KSRC := /home/android_sdk/android-x86_JB/out/target/product/x86/obj/kernel/
568 +MODULE_NAME :=wlan
569 +endif
570 +
571 ifeq ($(CONFIG_PLATFORM_ARM_PXA2XX), y)
572 EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
573 ARCH := arm
574 @@ -327,7 +328,7 @@ ifeq ($(CONFIG_PLATFORM_MIPS_RMI), y)
575 EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
576 ARCH:=mips
577 CROSS_COMPILE:=mipsisa32r2-uclibc-
578 -KVER:=
579 +KVER:=
580 KSRC:= /root/work/kernel_realtek
581 endif
582
583 @@ -335,7 +336,7 @@ ifeq ($(CONFIG_PLATFORM_MIPS_PLM), y)
584 EXTRA_CFLAGS += -DCONFIG_BIG_ENDIAN
585 ARCH:=mips
586 CROSS_COMPILE:=mipsisa32r2-uclibc-
587 -KVER:=
588 +KVER:=
589 KSRC:= /root/work/kernel_realtek
590 endif
591
592 @@ -366,8 +367,8 @@ ifeq ($(CONFIG_PLATFORM_RTK_DMP), y)
593 EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DRTK_DMP_PLATFORM
594 ARCH:=mips
595 CROSS_COMPILE:=mipsel-linux-
596 -KVER:=
597 -KSRC ?= /usr/src/work/DMP_Kernel/jupiter/linux-2.6.12
598 +KVER:=
599 +KSRC ?= /usr/src/DMP_Kernel/jupiter/linux-2.6.12
600 endif
601
602 ifeq ($(CONFIG_PLATFORM_MT53XX), y)
603 @@ -385,7 +386,16 @@ CROSS_COMPILE := /opt/freescale/usr/loca
604 KVER := 2.6.31
605 KSRC ?= /lib/modules/2.6.31-770-g0e46b52/source
606 endif
607 -
608 +
609 +ifeq ($(CONFIG_PLATFORM_FS_MX61), y)
610 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
611 +ARCH := arm
612 +CROSS_COMPILE := /home/share/CusEnv/FreeScale/arm-eabi-4.4.3/bin/arm-eabi-
613 +KSRC ?= /home/share/CusEnv/FreeScale/FS_kernel_env
614 +endif
615 +
616 +
617 +
618 ifeq ($(CONFIG_PLATFORM_ACTIONS_ATJ227X), y)
619 EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_ACTIONS_ATJ227X
620 ARCH := mips
621 @@ -402,27 +412,57 @@ KVER := 2.6.18
622 KSRC := /home/cnsd4/Appro/mv_pro_5.0/montavista/pro/devkit/lsp/ti-davinci/linux-dm365
623 endif
624
625 -ifeq ($(CONFIG_PLATFORM_ARM_TEGRA3), y)
626 -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN #-DCONFIG_MINIMAL_MEMORY_USAGE
627 -ARCH ?= arm
628 -CROSS_COMPILE ?= /media/DATA-1/nvidia/gingerbread/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
629 -KSRC ?= /media/DATA-1/nvidia/gingerbread/out/debug/target/product/cardhu/obj/KERNEL
630 +ifeq ($(CONFIG_PLATFORM_TEGRA3_CARDHU), y)
631 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
632 +# default setting for Android 4.1, 4.2
633 +EXTRA_CFLAGS += -DRTW_ENABLE_WIFI_CONTROL_FUNC
634 +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
635 +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
636 +EXTRA_CFLAGS += -DCONFIG_P2P_IPS
637 +ARCH := arm
638 +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-
639 +KSRC := /home/android_sdk/nvidia/tegra-16r3-partner-android-4.1_20120723/out/target/product/cardhu/obj/KERNEL
640 +MODULE_NAME := wlan
641 +endif
642 +
643 +ifeq ($(CONFIG_PLATFORM_TEGRA4_DALMORE), y)
644 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
645 +# default setting for Android 4.1, 4.2
646 +EXTRA_CFLAGS += -DRTW_ENABLE_WIFI_CONTROL_FUNC
647 +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
648 +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
649 +EXTRA_CFLAGS += -DCONFIG_P2P_IPS
650 +ARCH := arm
651 +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-
652 +KSRC := /home/android_sdk/nvidia/tegra-17r9-partner-android-4.2-dalmore_20130131/out/target/product/dalmore/obj/KERNEL
653 MODULE_NAME := wlan
654 endif
655
656 ifeq ($(CONFIG_PLATFORM_ARM_TCC8900), y)
657 -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_MINIMAL_MEMORY_USAGE
658 -ARCH ?= arm
659 -CROSS_COMPILE ?= /media/DATA-1/telechips/SDK_2302_20110425/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
660 -KSRC ?=/media/DATA-1/telechips/SDK_2302_20110425/kernel
661 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
662 +ARCH := arm
663 +CROSS_COMPILE := /home/android_sdk/Telechips/SDK_2304_20110613/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
664 +KSRC := /home/android_sdk/Telechips/SDK_2304_20110613/kernel
665 MODULE_NAME := wlan
666 endif
667
668 ifeq ($(CONFIG_PLATFORM_ARM_TCC8920), y)
669 -EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN #-DCONFIG_MINIMAL_MEMORY_USAGE
670 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
671 ARCH := arm
672 -CROSS_COMPILE := /media/DATA-2/telechips/ics_sdk/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
673 -KSRC := /media/DATA-2/telechips/ics_sdk/kernel
674 +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-
675 +KSRC := /home/android_sdk/Telechips/v12.06_r1-tcc-android-4.0.4/kernel
676 +MODULE_NAME := wlan
677 +endif
678 +
679 +ifeq ($(CONFIG_PLATFORM_ARM_TCC8920_JB42), y)
680 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
681 +# default setting for Android 4.1, 4.2
682 +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
683 +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
684 +EXTRA_CFLAGS += -DCONFIG_P2P_IPS
685 +ARCH := arm
686 +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-
687 +KSRC := /home/android_sdk/Telechips/v13.03_r1-tcc-android-4.2.2_ds_patched/kernel
688 MODULE_NAME := wlan
689 endif
690
691 @@ -461,11 +501,39 @@ KSRC := /home/winuser/work/Plat_sLD2T_V3
692 INSTALL_PREFIX :=
693 endif
694
695 +ifeq ($(CONFIG_PLATFORM_ARM_SUNxI), y)
696 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_ARM_SUNxI
697 +ARCH := arm
698 +CROSS_COMPILE := arm-none-linux-gnueabi-
699 +KVER := 3.0.8
700 +#KSRC:= ../lichee/linux-3.0/
701 +endif
702 +
703 +ifeq ($(CONFIG_PLATFORM_ARM_SUN6I), y)
704 +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
705 +EXTRA_CFLAGS += -DCONFIG_PLATFORM_ARM_SUN6I
706 +EXTRA_CFLAGS += -DCONFIG_USE_USB_BUFFER_ALLOC_TX
707 +EXTRA_CFLAGS += -DCONFIG_TRAFFIC_PROTECT
708 +# default setting for Android 4.1, 4.2
709 +EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
710 +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
711 +EXTRA_CFLAGS += -DCONFIG_P2P_IPS
712 +ARCH := arm
713 +CROSS_COMPILE := arm-none-linux-gnueabi-
714 +KVER := 3.3.0
715 +#KSRC:= ../lichee/linux-3.3/
716 +endif
717 +
718 +ifneq ($(USER_MODULE_NAME),)
719 +MODULE_NAME := $(USER_MODULE_NAME)
720 +endif
721 +
722 ifeq ($(CONFIG_MP_INCLUDED), y)
723 MODULE_NAME := $(MODULE_NAME)_mp
724 EXTRA_CFLAGS += -DCONFIG_MP_INCLUDED
725 endif
726
727 +
728 ifneq ($(KERNELRELEASE),)
729
730
731 @@ -483,23 +551,26 @@ rtk_core := core/rtw_cmd.o \
732 core/rtw_rf.o \
733 core/rtw_recv.o \
734 core/rtw_sta_mgt.o \
735 + core/rtw_ap.o \
736 core/rtw_xmit.o \
737 core/rtw_p2p.o \
738 + core/rtw_tdls.o \
739 core/rtw_br_ext.o \
740 - core/rtw_iol.o
741 + core/rtw_iol.o \
742 + core/rtw_sreset.o
743
744 $(MODULE_NAME)-y += $(rtk_core)
745 -
746 +
747 +$(MODULE_NAME)-$(CONFIG_INTEL_WIDI) += core/rtw_intel_widi.o
748 +
749 $(MODULE_NAME)-y += core/efuse/rtw_efuse.o
750
751 $(MODULE_NAME)-y += $(_HAL_INTFS_FILES)
752
753 $(MODULE_NAME)-y += $(_OS_INTFS_FILES)
754
755 -
756 $(MODULE_NAME)-$(CONFIG_MP_INCLUDED) += core/rtw_mp.o \
757 - core/rtw_mp_ioctl.o \
758 - core/rtw_ioctl_rtl.o
759 + core/rtw_mp_ioctl.o
760
761 obj-$(CONFIG_RTL8192CU) := $(MODULE_NAME).o
762
763 @@ -522,12 +593,12 @@ install:
764 uninstall:
765 rm -f $(MODDESTDIR)/$(MODULE_NAME).ko
766 /sbin/depmod -a ${KVER}
767 -
768 -
769 +
770 +
771 config_r:
772 @echo "make config"
773 /bin/bash script/Configure script/config.in
774 -
775 +
776 .PHONY: modules clean
777
778 clean:
779 @@ -535,11 +606,11 @@ clean:
780 rm .tmp_versions -fr ; rm Module.symvers -fr
781 rm -fr Module.markers ; rm -fr modules.order
782 cd core/efuse ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
783 - cd core ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
784 - cd hal/$(RTL871X)/$(HCI_NAME) ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
785 - cd hal/$(RTL871X) ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
786 - cd hal ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
787 - cd os_dep/linux ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
788 - cd os_dep ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
789 + cd core ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
790 + cd hal/$(RTL871X)/$(HCI_NAME) ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
791 + cd hal/$(RTL871X) ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
792 + cd hal ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
793 + cd os_dep/linux ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
794 + cd os_dep ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
795 endif
796
797 --- a/drivers/net/wireless/rtl8192cu/clean
798 +++ b/drivers/net/wireless/rtl8192cu/clean
799 @@ -3,7 +3,3 @@ rmmod 8192cu
800 rmmod 8192ce
801 rmmod 8192du
802 rmmod 8192de
803 -
804 -rmmod rtl8192cu
805 -rmmod rtl8192c_common
806 -rmmod rtlwifi
807 \ No newline at end of file
808 --- a/drivers/net/wireless/rtl8192cu/core/efuse/rtw_efuse.c
809 +++ b/drivers/net/wireless/rtl8192cu/core/efuse/rtw_efuse.c
810 @@ -1,7 +1,7 @@
811 /******************************************************************************
812 *
813 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
814 - *
815 + *
816 * This program is free software; you can redistribute it and/or modify it
817 * under the terms of version 2 of the GNU General Public License as
818 * published by the Free Software Foundation.
819 @@ -54,6 +54,11 @@ BOOLEAN
820 Efuse_Read1ByteFromFakeContent(
821 IN PADAPTER pAdapter,
822 IN u16 Offset,
823 + IN OUT u8 *Value );
824 +BOOLEAN
825 +Efuse_Read1ByteFromFakeContent(
826 + IN PADAPTER pAdapter,
827 + IN u16 Offset,
828 IN OUT u8 *Value )
829 {
830 if(Offset >= EFUSE_MAX_HW_SIZE)
831 @@ -67,6 +72,12 @@ Efuse_Read1ByteFromFakeContent(
832 *Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset];
833 return _TRUE;
834 }
835 +
836 +BOOLEAN
837 +Efuse_Write1ByteToFakeContent(
838 + IN PADAPTER pAdapter,
839 + IN u16 Offset,
840 + IN u8 Value );
841 BOOLEAN
842 Efuse_Write1ByteToFakeContent(
843 IN PADAPTER pAdapter,
844 @@ -210,7 +221,7 @@ ReadEFuseByte(
845 value32 = rtw_read32(Adapter, EFUSE_CTRL);
846
847 *pbuf = (u8)(value32 & 0xff);
848 - //MSG_8192C("ReadEFuseByte _offset:%08u, in %d ms\n",_offset ,rtw_get_passing_time_ms(start));
849 + //DBG_871X("ReadEFuseByte _offset:%08u, in %d ms\n",_offset ,rtw_get_passing_time_ms(start));
850
851 }
852
853 @@ -232,6 +243,16 @@ ReadEFuseByte(
854 // 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1
855 // write addr must be after sec5.
856 //
857 +
858 +VOID
859 +efuse_ReadEFuse(
860 + PADAPTER Adapter,
861 + u8 efuseType,
862 + u16 _offset,
863 + u16 _size_byte,
864 + u8 *pbuf,
865 + IN BOOLEAN bPseudoTest
866 + );
867 VOID
868 efuse_ReadEFuse(
869 PADAPTER Adapter,
870 @@ -250,7 +271,7 @@ EFUSE_GetEfuseDefinition(
871 IN PADAPTER pAdapter,
872 IN u8 efuseType,
873 IN u8 type,
874 - OUT PVOID *pOut,
875 + OUT void *pOut,
876 IN BOOLEAN bPseudoTest
877 )
878 {
879 @@ -337,6 +358,12 @@ EFUSE_Read1Byte(
880 * 09/23/2008 MHC Copy from WMAC.
881 *
882 *---------------------------------------------------------------------------*/
883 +
884 +void
885 +EFUSE_Write1Byte(
886 + IN PADAPTER Adapter,
887 + IN u16 Address,
888 + IN u8 Value);
889 void
890 EFUSE_Write1Byte(
891 IN PADAPTER Adapter,
892 @@ -709,12 +736,12 @@ u8 rtw_efuse_map_write(PADAPTER padapter
893
894 if (word_en != 0xF) {
895 ret = Efuse_PgPacketWrite(padapter, offset, word_en, newdata, _FALSE);
896 - DBG_8192C("offset=%x \n",offset);
897 - DBG_8192C("word_en=%x \n",word_en);
898 + DBG_871X("offset=%x \n",offset);
899 + DBG_871X("word_en=%x \n",word_en);
900
901 for(i=0;i<PGPKT_DATA_SIZE;i++)
902 {
903 - DBG_8192C("data=%x \t",newdata[i]);
904 + DBG_871X("data=%x \t",newdata[i]);
905 }
906 if (ret == _FAIL) break;
907 }
908 @@ -759,6 +786,12 @@ Efuse_ReadAllMap(
909 IN PADAPTER pAdapter,
910 IN u8 efuseType,
911 IN OUT u8 *Efuse,
912 + IN BOOLEAN bPseudoTest);
913 +VOID
914 +Efuse_ReadAllMap(
915 + IN PADAPTER pAdapter,
916 + IN u8 efuseType,
917 + IN OUT u8 *Efuse,
918 IN BOOLEAN bPseudoTest)
919 {
920 u16 mapLen=0;
921 @@ -851,6 +884,13 @@ efuse_ShadowRead4Byte(
922 * 11/12/2008 MHC Create Version 0.
923 *
924 *---------------------------------------------------------------------------*/
925 +#ifdef PLATFORM
926 +static VOID
927 +efuse_ShadowWrite1Byte(
928 + IN PADAPTER pAdapter,
929 + IN u16 Offset,
930 + IN u8 Value);
931 +#endif //PLATFORM
932 static VOID
933 efuse_ShadowWrite1Byte(
934 IN PADAPTER pAdapter,
935 @@ -990,7 +1030,13 @@ EFUSE_ShadowRead(
936 * 11/12/2008 MHC Create Version 0.
937 *
938 *---------------------------------------------------------------------------*/
939 -extern VOID
940 +VOID
941 +EFUSE_ShadowWrite(
942 + IN PADAPTER pAdapter,
943 + IN u8 Type,
944 + IN u16 Offset,
945 + IN OUT u32 Value);
946 +VOID
947 EFUSE_ShadowWrite(
948 IN PADAPTER pAdapter,
949 IN u8 Type,
950 @@ -1013,6 +1059,10 @@ EFUSE_ShadowWrite(
951 VOID
952 Efuse_InitSomeVar(
953 IN PADAPTER pAdapter
954 + );
955 +VOID
956 +Efuse_InitSomeVar(
957 + IN PADAPTER pAdapter
958 )
959 {
960 u8 i;
961 @@ -1056,7 +1106,7 @@ int storeAdaptorInfoFile(char *path, str
962 else
963 ret = _FAIL;
964 } else {
965 - DBG_8192C("%s NULL pointer\n",__FUNCTION__);
966 + DBG_871X("%s NULL pointer\n",__FUNCTION__);
967 ret = _FAIL;
968 }
969 return ret;
970 @@ -1086,7 +1136,7 @@ int retriveAdaptorInfoFile(char *path, s
971 #endif
972
973 } else {
974 - DBG_8192C("%s NULL pointer\n",__FUNCTION__);
975 + DBG_871X("%s NULL pointer\n",__FUNCTION__);
976 ret = _FAIL;
977 }
978 return ret;
979 --- /dev/null
980 +++ b/drivers/net/wireless/rtl8192cu/core/rtw_ap.c
981 @@ -0,0 +1,2940 @@
982 +/******************************************************************************
983 + *
984 + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
985 + *
986 + * This program is free software; you can redistribute it and/or modify it
987 + * under the terms of version 2 of the GNU General Public License as
988 + * published by the Free Software Foundation.
989 + *
990 + * This program is distributed in the hope that it will be useful, but WITHOUT
991 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
992 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
993 + * more details.
994 + *
995 + * You should have received a copy of the GNU General Public License along with
996 + * this program; if not, write to the Free Software Foundation, Inc.,
997 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
998 + *
999 + *
1000 + ******************************************************************************/
1001 +#define _RTW_AP_C_
1002 +
1003 +#include <drv_conf.h>
1004 +#include <osdep_service.h>
1005 +#include <drv_types.h>
1006 +#include <wifi.h>
1007 +
1008 +
1009 +#ifdef CONFIG_AP_MODE
1010 +
1011 +extern unsigned char RTW_WPA_OUI[];
1012 +extern unsigned char WMM_OUI[];
1013 +extern unsigned char WPS_OUI[];
1014 +extern unsigned char P2P_OUI[];
1015 +extern unsigned char WFD_OUI[];
1016 +
1017 +void init_mlme_ap_info(_adapter *padapter)
1018 +{
1019 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1020 + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
1021 + struct sta_priv *pstapriv = &padapter->stapriv;
1022 + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
1023 +
1024 +
1025 + _rtw_spinlock_init(&pmlmepriv->bcn_update_lock);
1026 +
1027 + //for ACL
1028 + _rtw_init_queue(&pacl_list->acl_node_q);
1029 +
1030 + //pmlmeext->bstart_bss = _FALSE;
1031 +
1032 + start_ap_mode(padapter);
1033 +}
1034 +
1035 +void free_mlme_ap_info(_adapter *padapter)
1036 +{
1037 + _irqL irqL;
1038 + struct sta_info *psta=NULL;
1039 + struct sta_priv *pstapriv = &padapter->stapriv;
1040 + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
1041 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1042 + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1043 +
1044 + //stop_ap_mode(padapter);
1045 +
1046 + pmlmepriv->update_bcn = _FALSE;
1047 + pmlmeext->bstart_bss = _FALSE;
1048 +
1049 + rtw_sta_flush(padapter);
1050 +
1051 + pmlmeinfo->state = _HW_STATE_NOLINK_;
1052 +
1053 + //free_assoc_sta_resources
1054 + rtw_free_all_stainfo(padapter);
1055 +
1056 + //free bc/mc sta_info
1057 + psta = rtw_get_bcmc_stainfo(padapter);
1058 + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL);
1059 + rtw_free_stainfo(padapter, psta);
1060 + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL);
1061 +
1062 +
1063 + _rtw_spinlock_free(&pmlmepriv->bcn_update_lock);
1064 +
1065 +}
1066 +
1067 +static void update_BCNTIM(_adapter *padapter)
1068 +{
1069 + struct sta_priv *pstapriv = &padapter->stapriv;
1070 + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
1071 + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1072 + WLAN_BSSID_EX *pnetwork_mlmeext = &(pmlmeinfo->network);
1073 + unsigned char *pie = pnetwork_mlmeext->IEs;
1074 +
1075 + //DBG_871X("%s\n", __FUNCTION__);
1076 +
1077 + //update TIM IE
1078 + //if(pstapriv->tim_bitmap)
1079 + if(_TRUE)
1080 + {
1081 + u8 *p, *dst_ie, *premainder_ie=NULL, *pbackup_remainder_ie=NULL;
1082 + u16 tim_bitmap_le;
1083 + uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
1084 +
1085 + tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap);
1086 +
1087 + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
1088 + if (p != NULL && tim_ielen>0)
1089 + {
1090 + tim_ielen += 2;
1091 +
1092 + premainder_ie = p+tim_ielen;
1093 +
1094 + tim_ie_offset = (sint)(p -pie);
1095 +
1096 + remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen;
1097 +
1098 + //append TIM IE from dst_ie offset
1099 + dst_ie = p;
1100 + }
1101 + else
1102 + {
1103 + tim_ielen = 0;
1104 +
1105 + //calucate head_len
1106 + offset = _FIXED_IE_LENGTH_;
1107 +
1108 + /* get ssid_ie len */
1109 + p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SSID_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_));
1110 + if (p != NULL)
1111 + offset += tmp_len+2;
1112 +
1113 + // get supported rates len
1114 + p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_));
1115 + if (p != NULL)
1116 + {
1117 + offset += tmp_len+2;
1118 + }
1119 +
1120 + //DS Parameter Set IE, len=3
1121 + offset += 3;
1122 +
1123 + premainder_ie = pie + offset;
1124 +
1125 + remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen;
1126 +
1127 + //append TIM IE from offset
1128 + dst_ie = pie + offset;
1129 +
1130 + }
1131 +
1132 +
1133 + if(remainder_ielen>0)
1134 + {
1135 + pbackup_remainder_ie = rtw_malloc(remainder_ielen);
1136 + if(pbackup_remainder_ie && premainder_ie)
1137 + _rtw_memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
1138 + }
1139 +
1140 + *dst_ie++=_TIM_IE_;
1141 +
1142 + if((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc))
1143 + tim_ielen = 5;
1144 + else
1145 + tim_ielen = 4;
1146 +
1147 + *dst_ie++= tim_ielen;
1148 +
1149 + *dst_ie++=0;//DTIM count
1150 + *dst_ie++=1;//DTIM peroid
1151 +
1152 + if(pstapriv->tim_bitmap&BIT(0))//for bc/mc frames
1153 + *dst_ie++ = BIT(0);//bitmap ctrl
1154 + else
1155 + *dst_ie++ = 0;
1156 +
1157 + if(tim_ielen==4)
1158 + {
1159 + *dst_ie++ = *(u8*)&tim_bitmap_le;
1160 + }
1161 + else if(tim_ielen==5)
1162 + {
1163 + _rtw_memcpy(dst_ie, &tim_bitmap_le, 2);
1164 + dst_ie+=2;
1165 + }
1166 +
1167 + //copy remainder IE
1168 + if(pbackup_remainder_ie)
1169 + {
1170 + _rtw_memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen);
1171 +
1172 + rtw_mfree(pbackup_remainder_ie, remainder_ielen);
1173 + }
1174 +
1175 + offset = (uint)(dst_ie - pie);
1176 + pnetwork_mlmeext->IELength = offset + remainder_ielen;
1177 +
1178 + }
1179 +
1180 +#ifndef CONFIG_INTERRUPT_BASED_TXBCN
1181 +#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
1182 + set_tx_beacon_cmd(padapter);
1183 +#endif
1184 +#endif //!CONFIG_INTERRUPT_BASED_TXBCN
1185 +
1186 +
1187 +}
1188 +
1189 +void rtw_add_bcn_ie(_adapter *padapter, WLAN_BSSID_EX *pnetwork, u8 index, u8 *data, u8 len)
1190 +{
1191 + PNDIS_802_11_VARIABLE_IEs pIE;
1192 + u8 bmatch = _FALSE;
1193 + u8 *pie = pnetwork->IEs;
1194 + u8 *p, *dst_ie, *premainder_ie=NULL, *pbackup_remainder_ie=NULL;
1195 + u32 i, offset, ielen, ie_offset, remainder_ielen = 0;
1196 +
1197 + for (i = sizeof(NDIS_802_11_FIXED_IEs); i < pnetwork->IELength;)
1198 + {
1199 + pIE = (PNDIS_802_11_VARIABLE_IEs)(pnetwork->IEs + i);
1200 +
1201 + if (pIE->ElementID > index)
1202 + {
1203 + break;
1204 + }
1205 + else if(pIE->ElementID == index) // already exist the same IE
1206 + {
1207 + p = (u8 *)pIE;
1208 + ielen = pIE->Length;
1209 + bmatch = _TRUE;
1210 + break;
1211 + }
1212 +
1213 + p = (u8 *)pIE;
1214 + ielen = pIE->Length;
1215 + i += (pIE->Length + 2);
1216 + }
1217 +
1218 + if (p != NULL && ielen>0)
1219 + {
1220 + ielen += 2;
1221 +
1222 + premainder_ie = p+ielen;
1223 +
1224 + ie_offset = (sint)(p -pie);
1225 +
1226 + remainder_ielen = pnetwork->IELength - ie_offset - ielen;
1227 +
1228 + if(bmatch)
1229 + dst_ie = p;
1230 + else
1231 + dst_ie = (p+ielen);
1232 + }
1233 +
1234 + if(remainder_ielen>0)
1235 + {
1236 + pbackup_remainder_ie = rtw_malloc(remainder_ielen);
1237 + if(pbackup_remainder_ie && premainder_ie)
1238 + _rtw_memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
1239 + }
1240 +
1241 + *dst_ie++=index;
1242 + *dst_ie++=len;
1243 +
1244 + _rtw_memcpy(dst_ie, data, len);
1245 + dst_ie+=len;
1246 +
1247 + //copy remainder IE
1248 + if(pbackup_remainder_ie)
1249 + {
1250 + _rtw_memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen);
1251 +
1252 + rtw_mfree(pbackup_remainder_ie, remainder_ielen);
1253 + }
1254 +
1255 + offset = (uint)(dst_ie - pie);
1256 + pnetwork->IELength = offset + remainder_ielen;
1257 +}
1258 +
1259 +void rtw_remove_bcn_ie(_adapter *padapter, WLAN_BSSID_EX *pnetwork, u8 index)
1260 +{
1261 + u8 *p, *dst_ie, *premainder_ie=NULL, *pbackup_remainder_ie=NULL;
1262 + uint offset, ielen, ie_offset, remainder_ielen = 0;
1263 + u8 *pie = pnetwork->IEs;
1264 +
1265 + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, index, &ielen, pnetwork->IELength - _FIXED_IE_LENGTH_);
1266 + if (p != NULL && ielen>0)
1267 + {
1268 + ielen += 2;
1269 +
1270 + premainder_ie = p+ielen;
1271 +
1272 + ie_offset = (sint)(p -pie);
1273 +
1274 + remainder_ielen = pnetwork->IELength - ie_offset - ielen;
1275 +
1276 + dst_ie = p;
1277 + }
1278 + else {
1279 + return;
1280 + }
1281 +
1282 + if(remainder_ielen>0)
1283 + {
1284 + pbackup_remainder_ie = rtw_malloc(remainder_ielen);
1285 + if(pbackup_remainder_ie && premainder_ie)
1286 + _rtw_memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
1287 + }
1288 +
1289 + //copy remainder IE
1290 + if(pbackup_remainder_ie)
1291 + {
1292 + _rtw_memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen);
1293 +
1294 + rtw_mfree(pbackup_remainder_ie, remainder_ielen);
1295 + }
1296 +
1297 + offset = (uint)(dst_ie - pie);
1298 + pnetwork->IELength = offset + remainder_ielen;
1299 +}
1300 +
1301 +
1302 +u8 chk_sta_is_alive(struct sta_info *psta);
1303 +u8 chk_sta_is_alive(struct sta_info *psta)
1304 +{
1305 + u8 ret = _FALSE;
1306 + #ifdef DBG_EXPIRATION_CHK
1307 + DBG_871X("sta:"MAC_FMT", rssi:%d, rx:"STA_PKTS_FMT", expire_to:%u, %s%ssq_len:%u\n"
1308 + , MAC_ARG(psta->hwaddr)
1309 + , psta->rssi_stat.UndecoratedSmoothedPWDB
1310 + //, STA_RX_PKTS_ARG(psta)
1311 + , STA_RX_PKTS_DIFF_ARG(psta)
1312 + , psta->expire_to
1313 + , psta->state&WIFI_SLEEP_STATE?"PS, ":""
1314 + , psta->state&WIFI_STA_ALIVE_CHK_STATE?"SAC, ":""
1315 + , psta->sleepq_len
1316 + );
1317 + #endif
1318 +
1319 + //if(sta_last_rx_pkts(psta) == sta_rx_pkts(psta))
1320 + 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))
1321 + {
1322 + #if 0
1323 + if(psta->state&WIFI_SLEEP_STATE)
1324 + ret = _TRUE;
1325 + #endif
1326 + }
1327 + else
1328 + {
1329 + ret = _TRUE;
1330 + }
1331 +
1332 + sta_update_last_rx_pkts(psta);
1333 +
1334 + return ret;
1335 +}
1336 +
1337 +void expire_timeout_chk(_adapter *padapter)
1338 +{
1339 + _irqL irqL;
1340 + _list *phead, *plist;
1341 + u8 updated;
1342 + struct sta_info *psta=NULL;
1343 + struct sta_priv *pstapriv = &padapter->stapriv;
1344 + u8 chk_alive_num = 0;
1345 + char chk_alive_list[NUM_STA];
1346 + int i;
1347 +
1348 + _enter_critical_bh(&pstapriv->auth_list_lock, &irqL);
1349 +
1350 + phead = &pstapriv->auth_list;
1351 + plist = get_next(phead);
1352 +
1353 + //check auth_queue
1354 + #ifdef DBG_EXPIRATION_CHK
1355 + if (rtw_end_of_queue_search(phead, plist) == _FALSE) {
1356 + DBG_871X(FUNC_NDEV_FMT" auth_list, cnt:%u\n"
1357 + , FUNC_NDEV_ARG(padapter->pnetdev), pstapriv->auth_list_cnt);
1358 + }
1359 + #endif
1360 + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
1361 + {
1362 + psta = LIST_CONTAINOR(plist, struct sta_info, auth_list);
1363 + plist = get_next(plist);
1364 +
1365 + if(psta->expire_to>0)
1366 + {
1367 + psta->expire_to--;
1368 + if (psta->expire_to == 0)
1369 + {
1370 + rtw_list_delete(&psta->auth_list);
1371 + pstapriv->auth_list_cnt--;
1372 +
1373 + DBG_871X("auth expire %02X%02X%02X%02X%02X%02X\n",
1374 + psta->hwaddr[0],psta->hwaddr[1],psta->hwaddr[2],psta->hwaddr[3],psta->hwaddr[4],psta->hwaddr[5]);
1375 +
1376 + _exit_critical_bh(&pstapriv->auth_list_lock, &irqL);
1377 +
1378 + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL);
1379 + rtw_free_stainfo(padapter, psta);
1380 + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL);
1381 +
1382 + _enter_critical_bh(&pstapriv->auth_list_lock, &irqL);
1383 + }
1384 + }
1385 +
1386 + }
1387 +
1388 + _exit_critical_bh(&pstapriv->auth_list_lock, &irqL);
1389 +
1390 + psta = NULL;
1391 +
1392 +
1393 + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL);
1394 +
1395 + phead = &pstapriv->asoc_list;
1396 + plist = get_next(phead);
1397 +
1398 + //check asoc_queue
1399 + #ifdef DBG_EXPIRATION_CHK
1400 + if (rtw_end_of_queue_search(phead, plist) == _FALSE) {
1401 + DBG_871X(FUNC_NDEV_FMT" asoc_list, cnt:%u\n"
1402 + , FUNC_NDEV_ARG(padapter->pnetdev), pstapriv->asoc_list_cnt);
1403 + }
1404 + #endif
1405 + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
1406 + {
1407 + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list);
1408 + plist = get_next(plist);
1409 +
1410 + if (chk_sta_is_alive(psta) || !psta->expire_to) {
1411 + psta->expire_to = pstapriv->expire_to;
1412 + psta->keep_alive_trycnt = 0;
1413 + #ifdef CONFIG_TX_MCAST2UNI
1414 + psta->under_exist_checking = 0;
1415 + #endif // CONFIG_TX_MCAST2UNI
1416 + } else {
1417 + psta->expire_to--;
1418 + }
1419 +
1420 +#ifndef CONFIG_ACTIVE_KEEP_ALIVE_CHECK
1421 +#ifdef CONFIG_TX_MCAST2UNI
1422 + if ( (psta->flags & WLAN_STA_HT) && (psta->htpriv.agg_enable_bitmap || psta->under_exist_checking) ) {
1423 + // check sta by delba(addba) for 11n STA
1424 + // ToDo: use CCX report to check for all STAs
1425 + //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);
1426 +
1427 + if ( psta->expire_to <= (pstapriv->expire_to - 50 ) ) {
1428 + DBG_871X("asoc expire by DELBA/ADDBA! (%d s)\n", (pstapriv->expire_to-psta->expire_to)*2);
1429 + psta->under_exist_checking = 0;
1430 + psta->expire_to = 0;
1431 + } else if ( psta->expire_to <= (pstapriv->expire_to - 3) && (psta->under_exist_checking==0)) {
1432 + DBG_871X("asoc check by DELBA/ADDBA! (%d s)\n", (pstapriv->expire_to-psta->expire_to)*2);
1433 + psta->under_exist_checking = 1;
1434 + //tear down TX AMPDU
1435 + send_delba(padapter, 1, psta->hwaddr);// // originator
1436 + psta->htpriv.agg_enable_bitmap = 0x0;//reset
1437 + psta->htpriv.candidate_tid_bitmap = 0x0;//reset
1438 + }
1439 + }
1440 +#endif // CONFIG_TX_MCAST2UNI
1441 +#endif //CONFIG_ACTIVE_KEEP_ALIVE_CHECK
1442 +
1443 + if (psta->expire_to <= 0)
1444 + {
1445 + #ifdef CONFIG_ACTIVE_KEEP_ALIVE_CHECK
1446 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1447 +
1448 + if (padapter->registrypriv.wifi_spec == 1)
1449 + {
1450 + psta->expire_to = pstapriv->expire_to;
1451 + continue;
1452 + }
1453 +
1454 + if (psta->state & WIFI_SLEEP_STATE) {
1455 + if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) {
1456 + //to check if alive by another methods if staion is at ps mode.
1457 + psta->expire_to = pstapriv->expire_to;
1458 + psta->state |= WIFI_STA_ALIVE_CHK_STATE;
1459 +
1460 + //DBG_871X("alive chk, sta:" MAC_FMT " is at ps mode!\n", MAC_ARG(psta->hwaddr));
1461 +
1462 + //to update bcn with tim_bitmap for this station
1463 + pstapriv->tim_bitmap |= BIT(psta->aid);
1464 + update_beacon(padapter, _TIM_IE_, NULL, _FALSE);
1465 +
1466 + if(!pmlmeext->active_keep_alive_check)
1467 + continue;
1468 + }
1469 + }
1470 +
1471 + if (pmlmeext->active_keep_alive_check) {
1472 + int stainfo_offset;
1473 +
1474 + stainfo_offset = rtw_stainfo_offset(pstapriv, psta);
1475 + if (stainfo_offset_valid(stainfo_offset)) {
1476 + chk_alive_list[chk_alive_num++] = stainfo_offset;
1477 + }
1478 +
1479 + continue;
1480 + }
1481 + #endif /* CONFIG_ACTIVE_KEEP_ALIVE_CHECK */
1482 +
1483 + rtw_list_delete(&psta->asoc_list);
1484 + pstapriv->asoc_list_cnt--;
1485 +
1486 + DBG_871X("asoc expire "MAC_FMT", state=0x%x\n", MAC_ARG(psta->hwaddr), psta->state);
1487 + updated = ap_free_sta(padapter, psta, _FALSE, WLAN_REASON_DEAUTH_LEAVING);
1488 + }
1489 + else
1490 + {
1491 + /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */
1492 + if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt)
1493 + && padapter->xmitpriv.free_xmitframe_cnt < (NR_XMITFRAME/pstapriv->asoc_list_cnt/2)
1494 + ){
1495 + DBG_871X("%s sta:"MAC_FMT", sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__
1496 + , MAC_ARG(psta->hwaddr)
1497 + , psta->sleepq_len, padapter->xmitpriv.free_xmitframe_cnt, pstapriv->asoc_list_cnt);
1498 + wakeup_sta_to_xmit(padapter, psta);
1499 + }
1500 + }
1501 + }
1502 +
1503 + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL);
1504 +
1505 +#ifdef CONFIG_ACTIVE_KEEP_ALIVE_CHECK
1506 +if (chk_alive_num) {
1507 +
1508 + u8 backup_oper_channel=0;
1509 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1510 + /* switch to correct channel of current network before issue keep-alive frames */
1511 + if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) {
1512 + backup_oper_channel = rtw_get_oper_ch(padapter);
1513 + SelectChannel(padapter, pmlmeext->cur_channel);
1514 + }
1515 +
1516 + /* issue null data to check sta alive*/
1517 + for (i = 0; i < chk_alive_num; i++) {
1518 +
1519 + int ret = _FAIL;
1520 +
1521 + psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
1522 + if(!(psta->state &_FW_LINKED))
1523 + continue;
1524 +
1525 + if (psta->state & WIFI_SLEEP_STATE)
1526 + ret = issue_nulldata(padapter, psta->hwaddr, 0, 1, 50);
1527 + else
1528 + ret = issue_nulldata(padapter, psta->hwaddr, 0, 3, 50);
1529 +
1530 + psta->keep_alive_trycnt++;
1531 + if (ret == _SUCCESS)
1532 + {
1533 + DBG_871X("asoc check, sta(" MAC_FMT ") is alive\n", MAC_ARG(psta->hwaddr));
1534 + psta->expire_to = pstapriv->expire_to;
1535 + psta->keep_alive_trycnt = 0;
1536 + continue;
1537 + }
1538 + else if (psta->keep_alive_trycnt <= 3)
1539 + {
1540 + DBG_871X("ack check for asoc expire, keep_alive_trycnt=%d\n", psta->keep_alive_trycnt);
1541 + psta->expire_to = 1;
1542 + continue;
1543 + }
1544 +
1545 + psta->keep_alive_trycnt = 0;
1546 +
1547 + DBG_871X("asoc expire "MAC_FMT", state=0x%x\n", MAC_ARG(psta->hwaddr), psta->state);
1548 + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL);
1549 + if (rtw_is_list_empty(&psta->asoc_list)==_FALSE) {
1550 + rtw_list_delete(&psta->asoc_list);
1551 + pstapriv->asoc_list_cnt--;
1552 + updated = ap_free_sta(padapter, psta, _FALSE, WLAN_REASON_DEAUTH_LEAVING);
1553 + }
1554 + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL);
1555 +
1556 + }
1557 +
1558 + if (backup_oper_channel>0) /* back to the original operation channel */
1559 + SelectChannel(padapter, backup_oper_channel);
1560 +}
1561 +#endif /* CONFIG_ACTIVE_KEEP_ALIVE_CHECK */
1562 +
1563 + associated_clients_update(padapter, updated);
1564 +}
1565 +
1566 +
1567 +static void add_RATid(_adapter *padapter, struct sta_info *psta)
1568 +{
1569 + int i;
1570 + u8 rf_type;
1571 + u32 init_rate=0;
1572 + unsigned char sta_band = 0, raid, shortGIrate = _FALSE;
1573 + unsigned char limit;
1574 + unsigned int tx_ra_bitmap=0;
1575 + struct ht_priv *psta_ht = NULL;
1576 + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
1577 + WLAN_BSSID_EX *pcur_network = (WLAN_BSSID_EX *)&pmlmepriv->cur_network.network;
1578 +
1579 +
1580 + if(psta)
1581 + psta_ht = &psta->htpriv;
1582 + else
1583 + return;
1584 +
1585 + //b/g mode ra_bitmap
1586 + for (i=0; i<sizeof(psta->bssrateset); i++)
1587 + {
1588 + if (psta->bssrateset[i])
1589 + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f);
1590 + }
1591 +
1592 + //n mode ra_bitmap
1593 + if(psta_ht->ht_option)
1594 + {
1595 + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
1596 + if(rf_type == RF_2T2R)
1597 + limit=16;// 2R
1598 + else
1599 + limit=8;// 1R
1600 +
1601 + for (i=0; i<limit; i++) {
1602 + if (psta_ht->ht_cap.supp_mcs_set[i/8] & BIT(i%8))
1603 + tx_ra_bitmap |= BIT(i+12);
1604 + }
1605 +
1606 + //max short GI rate
1607 + shortGIrate = psta_ht->sgi;
1608 + }
1609 +
1610 +
1611 +#if 0//gtest
1612 + if(get_rf_mimo_mode(padapter) == RTL8712_RF_2T2R)
1613 + {
1614 + //is this a 2r STA?
1615 + if((pstat->tx_ra_bitmap & 0x0ff00000) != 0 && !(priv->pshare->has_2r_sta & BIT(pstat->aid)))
1616 + {
1617 + priv->pshare->has_2r_sta |= BIT(pstat->aid);
1618 + if(rtw_read16(padapter, 0x102501f6) != 0xffff)
1619 + {
1620 + rtw_write16(padapter, 0x102501f6, 0xffff);
1621 + reset_1r_sta_RA(priv, 0xffff);
1622 + Switch_1SS_Antenna(priv, 3);
1623 + }
1624 + }
1625 + else// bg or 1R STA?
1626 + {
1627 + if((priv->pmib->dot11BssType.net_work_type & WIRELESS_11N) && pstat->ht_cap_len && priv->pshare->has_2r_sta == 0)
1628 + {
1629 + if(rtw_read16(padapter, 0x102501f6) != 0x7777)
1630 + { // MCS7 SGI
1631 + rtw_write16(padapter, 0x102501f6,0x7777);
1632 + reset_1r_sta_RA(priv, 0x7777);
1633 + Switch_1SS_Antenna(priv, 2);
1634 + }
1635 + }
1636 + }
1637 +
1638 + }
1639 +
1640 + if ((pstat->rssi_level < 1) || (pstat->rssi_level > 3))
1641 + {
1642 + if (pstat->rssi >= priv->pshare->rf_ft_var.raGoDownUpper)
1643 + pstat->rssi_level = 1;
1644 + else if ((pstat->rssi >= priv->pshare->rf_ft_var.raGoDown20MLower) ||
1645 + ((priv->pshare->is_40m_bw) && (pstat->ht_cap_len) &&
1646 + (pstat->rssi >= priv->pshare->rf_ft_var.raGoDown40MLower) &&
1647 + (pstat->ht_cap_buf.ht_cap_info & cpu_to_le16(_HTCAP_SUPPORT_CH_WDTH_))))
1648 + pstat->rssi_level = 2;
1649 + else
1650 + pstat->rssi_level = 3;
1651 + }
1652 +
1653 + // rate adaptive by rssi
1654 + if ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11N) && pstat->ht_cap_len)
1655 + {
1656 + if ((get_rf_mimo_mode(priv) == MIMO_1T2R) || (get_rf_mimo_mode(priv) == MIMO_1T1R))
1657 + {
1658 + switch (pstat->rssi_level) {
1659 + case 1:
1660 + pstat->tx_ra_bitmap &= 0x100f0000;
1661 + break;
1662 + case 2:
1663 + pstat->tx_ra_bitmap &= 0x100ff000;
1664 + break;
1665 + case 3:
1666 + if (priv->pshare->is_40m_bw)
1667 + pstat->tx_ra_bitmap &= 0x100ff005;
1668 + else
1669 + pstat->tx_ra_bitmap &= 0x100ff001;
1670 +
1671 + break;
1672 + }
1673 + }
1674 + else
1675 + {
1676 + switch (pstat->rssi_level) {
1677 + case 1:
1678 + pstat->tx_ra_bitmap &= 0x1f0f0000;
1679 + break;
1680 + case 2:
1681 + pstat->tx_ra_bitmap &= 0x1f0ff000;
1682 + break;
1683 + case 3:
1684 + if (priv->pshare->is_40m_bw)
1685 + pstat->tx_ra_bitmap &= 0x000ff005;
1686 + else
1687 + pstat->tx_ra_bitmap &= 0x000ff001;
1688 +
1689 + break;
1690 + }
1691 +
1692 + // Don't need to mask high rates due to new rate adaptive parameters
1693 + //if (pstat->is_broadcom_sta) // use MCS12 as the highest rate vs. Broadcom sta
1694 + // pstat->tx_ra_bitmap &= 0x81ffffff;
1695 +
1696 + // NIC driver will report not supporting MCS15 and MCS14 in asoc req
1697 + //if (pstat->is_rtl8190_sta && !pstat->is_2t_mimo_sta)
1698 + // pstat->tx_ra_bitmap &= 0x83ffffff; // if Realtek 1x2 sta, don't use MCS15 and MCS14
1699 + }
1700 + }
1701 + else if ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11G) && isErpSta(pstat))
1702 + {
1703 + switch (pstat->rssi_level) {
1704 + case 1:
1705 + pstat->tx_ra_bitmap &= 0x00000f00;
1706 + break;
1707 + case 2:
1708 + pstat->tx_ra_bitmap &= 0x00000ff0;
1709 + break;
1710 + case 3:
1711 + pstat->tx_ra_bitmap &= 0x00000ff5;
1712 + break;
1713 + }
1714 + }
1715 + else
1716 + {
1717 + pstat->tx_ra_bitmap &= 0x0000000d;
1718 + }
1719 +
1720 + // disable tx short GI when station cannot rx MCS15(AP is 2T2R)
1721 + // disable tx short GI when station cannot rx MCS7 (AP is 1T2R or 1T1R)
1722 + // if there is only 1r STA and we are 2T2R, DO NOT mask SGI rate
1723 + if ((!(pstat->tx_ra_bitmap & 0x8000000) && (priv->pshare->has_2r_sta > 0) && (get_rf_mimo_mode(padapter) == RTL8712_RF_2T2R)) ||
1724 + (!(pstat->tx_ra_bitmap & 0x80000) && (get_rf_mimo_mode(padapter) != RTL8712_RF_2T2R)))
1725 + {
1726 + pstat->tx_ra_bitmap &= ~BIT(28);
1727 + }
1728 +#endif
1729 +
1730 + if ( pcur_network->Configuration.DSConfig > 14 ) {
1731 + // 5G band
1732 + if (tx_ra_bitmap & 0xffff000)
1733 + sta_band |= WIRELESS_11_5N | WIRELESS_11A;
1734 + else
1735 + sta_band |= WIRELESS_11A;
1736 + } else {
1737 + if (tx_ra_bitmap & 0xffff000)
1738 + sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B;
1739 + else if (tx_ra_bitmap & 0xff0)
1740 + sta_band |= WIRELESS_11G |WIRELESS_11B;
1741 + else
1742 + sta_band |= WIRELESS_11B;
1743 + }
1744 +
1745 + raid = networktype_to_raid(sta_band);
1746 + init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f;
1747 +
1748 + if (psta->aid < NUM_STA)
1749 + {
1750 + u8 arg = 0;
1751 +
1752 + arg = psta->mac_id&0x1f;
1753 +
1754 + arg |= BIT(7);//support entry 2~31
1755 +
1756 + if (shortGIrate==_TRUE)
1757 + arg |= BIT(5);
1758 +
1759 + tx_ra_bitmap |= ((raid<<28)&0xf0000000);
1760 +
1761 + DBG_871X("%s=> mac_id:%d , raid:%d , bitmap=0x%x, arg=0x%x\n",
1762 + __FUNCTION__ , psta->mac_id, raid ,tx_ra_bitmap, arg);
1763 +
1764 + //bitmap[0:27] = tx_rate_bitmap
1765 + //bitmap[28:31]= Rate Adaptive id
1766 + //arg[0:4] = macid
1767 + //arg[5] = Short GI
1768 + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg);
1769 +
1770 + if (shortGIrate==_TRUE)
1771 + init_rate |= BIT(6);
1772 +
1773 + //set ra_id, init_rate
1774 + psta->raid = raid;
1775 + psta->init_rate = init_rate;
1776 +
1777 + }
1778 + else
1779 + {
1780 + DBG_871X("station aid %d exceed the max number\n", psta->aid);
1781 + }
1782 +
1783 +}
1784 +
1785 +static void update_bmc_sta(_adapter *padapter)
1786 +{
1787 + _irqL irqL;
1788 + u32 init_rate=0;
1789 + unsigned char network_type, raid;
1790 + int i, supportRateNum = 0;
1791 + unsigned int tx_ra_bitmap=0;
1792 + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
1793 + WLAN_BSSID_EX *pcur_network = (WLAN_BSSID_EX *)&pmlmepriv->cur_network.network;
1794 + struct sta_info *psta = rtw_get_bcmc_stainfo(padapter);
1795 +
1796 + if(psta)
1797 + {
1798 + psta->aid = 0;//default set to 0
1799 + //psta->mac_id = psta->aid+4;
1800 + psta->mac_id = psta->aid + 1;
1801 +
1802 + psta->qos_option = 0;
1803 + psta->htpriv.ht_option = _FALSE;
1804 +
1805 + psta->ieee8021x_blocked = 0;
1806 +
1807 + _rtw_memset((void*)&psta->sta_stats, 0, sizeof(struct stainfo_stats));
1808 +
1809 + //psta->dot118021XPrivacy = _NO_PRIVACY_;//!!! remove it, because it has been set before this.
1810 +
1811 +
1812 +
1813 + //prepare for add_RATid
1814 + supportRateNum = rtw_get_rateset_len((u8*)&pcur_network->SupportedRates);
1815 + network_type = rtw_check_network_type((u8*)&pcur_network->SupportedRates, supportRateNum, 1);
1816 +
1817 + _rtw_memcpy(psta->bssrateset, &pcur_network->SupportedRates, supportRateNum);
1818 + psta->bssratelen = supportRateNum;
1819 +
1820 + //b/g mode ra_bitmap
1821 + for (i=0; i<supportRateNum; i++)
1822 + {
1823 + if (psta->bssrateset[i])
1824 + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f);
1825 + }
1826 +
1827 + if ( pcur_network->Configuration.DSConfig > 14 ) {
1828 + //force to A mode. 5G doesn't support CCK rates
1829 + network_type = WIRELESS_11A;
1830 + tx_ra_bitmap = 0x150; // 6, 12, 24 Mbps
1831 + } else {
1832 + //force to b mode
1833 + network_type = WIRELESS_11B;
1834 + tx_ra_bitmap = 0xf;
1835 + }
1836 +
1837 + //tx_ra_bitmap = update_basic_rate(pcur_network->SupportedRates, supportRateNum);
1838 +
1839 + raid = networktype_to_raid(network_type);
1840 + init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f;
1841 +
1842 + //DBG_871X("Add id %d val %08x to ratr for bmc sta\n", psta->aid, tx_ra_bitmap);
1843 +
1844 + //if(pHalData->fw_ractrl == _TRUE)
1845 + {
1846 + u8 arg = 0;
1847 +
1848 + arg = psta->mac_id&0x1f;
1849 +
1850 + arg |= BIT(7);
1851 +
1852 + //if (shortGIrate==_TRUE)
1853 + // arg |= BIT(5);
1854 +
1855 + tx_ra_bitmap |= ((raid<<28)&0xf0000000);
1856 +
1857 + DBG_871X("update_bmc_sta, mask=0x%x, arg=0x%x\n", tx_ra_bitmap, arg);
1858 +
1859 + //bitmap[0:27] = tx_rate_bitmap
1860 + //bitmap[28:31]= Rate Adaptive id
1861 + //arg[0:4] = macid
1862 + //arg[5] = Short GI
1863 + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg);
1864 +
1865 + }
1866 +
1867 + //set ra_id, init_rate
1868 + psta->raid = raid;
1869 + psta->init_rate = init_rate;
1870 +
1871 + _enter_critical_bh(&psta->lock, &irqL);
1872 + psta->state = _FW_LINKED;
1873 + _exit_critical_bh(&psta->lock, &irqL);
1874 +
1875 + }
1876 + else
1877 + {
1878 + DBG_871X("add_RATid_bmc_sta error!\n");
1879 + }
1880 +
1881 +}
1882 +
1883 +//notes:
1884 +//AID: 1~MAX for sta and 0 for bc/mc in ap/adhoc mode
1885 +//MAC_ID = AID+1 for sta in ap/adhoc mode
1886 +//MAC_ID = 1 for bc/mc for sta/ap/adhoc
1887 +//MAC_ID = 0 for bssid for sta/ap/adhoc
1888 +//CAM_ID = //0~3 for default key, cmd_id=macid + 3, macid=aid+1;
1889 +
1890 +void update_sta_info_apmode(_adapter *padapter, struct sta_info *psta)
1891 +{
1892 + _irqL irqL;
1893 + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
1894 + struct security_priv *psecuritypriv = &padapter->securitypriv;
1895 + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
1896 + struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv;
1897 + struct ht_priv *phtpriv_sta = &psta->htpriv;
1898 +
1899 + //set intf_tag to if1
1900 + //psta->intf_tag = 0;
1901 +
1902 + //psta->mac_id = psta->aid+4;
1903 + psta->mac_id = psta->aid+1;
1904 +
1905 + if(psecuritypriv->dot11AuthAlgrthm==dot11AuthAlgrthm_8021X)
1906 + psta->ieee8021x_blocked = _TRUE;
1907 + else
1908 + psta->ieee8021x_blocked = _FALSE;
1909 +
1910 +
1911 + //update sta's cap
1912 +
1913 + //ERP
1914 + VCS_update(padapter, psta);
1915 +
1916 + //HT related cap
1917 + if(phtpriv_sta->ht_option)
1918 + {
1919 + //check if sta supports rx ampdu
1920 + phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable;
1921 +
1922 + //check if sta support s Short GI
1923 + 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))
1924 + {
1925 + phtpriv_sta->sgi = _TRUE;
1926 + }
1927 +
1928 + // bwmode
1929 + if((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH))
1930 + {
1931 + //phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_40;
1932 + phtpriv_sta->bwmode = pmlmeext->cur_bwmode;
1933 + phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset;
1934 +
1935 + }
1936 +
1937 + psta->qos_option = _TRUE;
1938 +
1939 + }
1940 + else
1941 + {
1942 + phtpriv_sta->ampdu_enable = _FALSE;
1943 +
1944 + phtpriv_sta->sgi = _FALSE;
1945 + phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20;
1946 + phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
1947 + }
1948 +
1949 + //Rx AMPDU
1950 + send_delba(padapter, 0, psta->hwaddr);// recipient
1951 +
1952 + //TX AMPDU
1953 + send_delba(padapter, 1, psta->hwaddr);// // originator
1954 + phtpriv_sta->agg_enable_bitmap = 0x0;//reset
1955 + phtpriv_sta->candidate_tid_bitmap = 0x0;//reset
1956 +
1957 +
1958 + //todo: init other variables
1959 +
1960 + _rtw_memset((void*)&psta->sta_stats, 0, sizeof(struct stainfo_stats));
1961 +
1962 +
1963 + //add ratid
1964 + //add_RATid(padapter, psta);//move to ap_sta_info_defer_update()
1965 +
1966 +
1967 + _enter_critical_bh(&psta->lock, &irqL);
1968 + psta->state |= _FW_LINKED;
1969 + _exit_critical_bh(&psta->lock, &irqL);
1970 +
1971 +
1972 +}
1973 +
1974 +static void update_hw_ht_param(_adapter *padapter)
1975 +{
1976 + unsigned char max_AMPDU_len;
1977 + unsigned char min_MPDU_spacing;
1978 + struct registry_priv *pregpriv = &padapter->registrypriv;
1979 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1980 + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1981 +
1982 + DBG_871X("%s\n", __FUNCTION__);
1983 +
1984 +
1985 + //handle A-MPDU parameter field
1986 + /*
1987 + AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
1988 + AMPDU_para [4:2]:Min MPDU Start Spacing
1989 + */
1990 + max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03;
1991 +
1992 + min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2;
1993 +
1994 + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing));
1995 +
1996 + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len));
1997 +
1998 + //
1999 + // Config SM Power Save setting
2000 + //
2001 + pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & 0x0C) >> 2;
2002 + if(pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC)
2003 + {
2004 + /*u8 i;
2005 + //update the MCS rates
2006 + for (i = 0; i < 16; i++)
2007 + {
2008 + pmlmeinfo->HT_caps.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i];
2009 + }*/
2010 + DBG_871X("%s(): WLAN_HT_CAP_SM_PS_STATIC\n",__FUNCTION__);
2011 + }
2012 +
2013 + //
2014 + // Config current HT Protection mode.
2015 + //
2016 + //pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3;
2017 +
2018 +}
2019 +
2020 +static void start_bss_network(_adapter *padapter, u8 *pbuf)
2021 +{
2022 + u8 *p;
2023 + u8 val8, cur_channel, cur_bwmode, cur_ch_offset;
2024 + u16 bcn_interval;
2025 + u32 acparm;
2026 + int ie_len;
2027 + struct registry_priv *pregpriv = &padapter->registrypriv;
2028 + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
2029 + struct security_priv* psecuritypriv=&(padapter->securitypriv);
2030 + WLAN_BSSID_EX *pnetwork = (WLAN_BSSID_EX *)&pmlmepriv->cur_network.network;
2031 + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
2032 + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
2033 + WLAN_BSSID_EX *pnetwork_mlmeext = &(pmlmeinfo->network);
2034 + struct HT_info_element *pht_info=NULL;
2035 +#ifdef CONFIG_P2P
2036 + struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
2037 +#endif //CONFIG_P2P
2038 + u8 cbw40_enable=0;
2039 + u8 change_band = _FALSE;
2040 + //DBG_871X("%s\n", __FUNCTION__);
2041 +
2042 + bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod;
2043 + cur_channel = pnetwork->Configuration.DSConfig;
2044 + cur_bwmode = HT_CHANNEL_WIDTH_20;;
2045 + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
2046 +
2047 +
2048 + //check if there is wps ie,
2049 + //if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd,
2050 + //and at first time the security ie ( RSN/WPA IE) will not include in beacon.
2051 + if(NULL == rtw_get_wps_ie(pnetwork->IEs+_FIXED_IE_LENGTH_, pnetwork->IELength-_FIXED_IE_LENGTH_, NULL, NULL))
2052 + {
2053 + pmlmeext->bstart_bss = _TRUE;
2054 + }
2055 +
2056 + //todo: update wmm, ht cap
2057 + //pmlmeinfo->WMM_enable;
2058 + //pmlmeinfo->HT_enable;
2059 + if(pmlmepriv->qospriv.qos_option)
2060 + pmlmeinfo->WMM_enable = _TRUE;
2061 +
2062 + if(pmlmepriv->htpriv.ht_option)
2063 + {
2064 + pmlmeinfo->WMM_enable = _TRUE;
2065 + pmlmeinfo->HT_enable = _TRUE;
2066 + //pmlmeinfo->HT_info_enable = _TRUE;
2067 + //pmlmeinfo->HT_caps_enable = _TRUE;
2068 +
2069 + update_hw_ht_param(padapter);
2070 + }
2071 +
2072 +
2073 + if(pmlmepriv->cur_network.join_res != _TRUE) //setting only at first time
2074 + {
2075 + //WEP Key will be set before this function, do not clear CAM.
2076 + if ((psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) && (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_))
2077 + flush_all_cam_entry(padapter); //clear CAM
2078 + }
2079 +
2080 + //set MSR to AP_Mode
2081 + Set_MSR(padapter, _HW_STATE_AP_);
2082 +
2083 + //Set BSSID REG
2084 + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pnetwork->MacAddress);
2085 +
2086 + //Set EDCA param reg
2087 +#ifdef CONFIG_CONCURRENT_MODE
2088 + acparm = 0x005ea42b;
2089 +#else
2090 + acparm = 0x002F3217; // VO
2091 +#endif
2092 + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acparm));
2093 + acparm = 0x005E4317; // VI
2094 + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acparm));
2095 + //acparm = 0x00105320; // BE
2096 + acparm = 0x005ea42b;
2097 + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acparm));
2098 + acparm = 0x0000A444; // BK
2099 + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm));
2100 +
2101 + //Set Security
2102 + val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf;
2103 + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
2104 +
2105 + //Beacon Control related register
2106 + rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval));
2107 +
2108 + if(pmlmepriv->cur_network.join_res != _TRUE) //setting only at first time
2109 + {
2110 + u32 initialgain;
2111 +
2112 + initialgain = 0x1e;
2113 +
2114 +
2115 + //disable dynamic functions, such as high power, DIG
2116 + //Save_DM_Func_Flag(padapter);
2117 + //Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, _FALSE);
2118 +
2119 +#ifdef CONFIG_CONCURRENT_MODE
2120 + if(padapter->adapter_type > PRIMARY_ADAPTER)
2121 + {
2122 + if(rtw_buddy_adapter_up(padapter))
2123 + {
2124 + _adapter *pbuddy_adapter = padapter->pbuddy_adapter;
2125 +
2126 + //turn on dynamic functions on PRIMARY_ADAPTER, dynamic functions only runs at PRIMARY_ADAPTER
2127 + Switch_DM_Func(pbuddy_adapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, _TRUE);
2128 +
2129 + rtw_hal_set_hwreg(pbuddy_adapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain));
2130 + }
2131 + }
2132 + else
2133 +#endif
2134 + {
2135 + //turn on dynamic functions
2136 + Switch_DM_Func(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, _TRUE);
2137 +
2138 + rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain));
2139 + }
2140 +
2141 + }
2142 +
2143 + //set channel, bwmode
2144 + 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)));
2145 + if( p && ie_len)
2146 + {
2147 + pht_info = (struct HT_info_element *)(p+2);
2148 +
2149 + if( pmlmeext->cur_channel > 14 )
2150 + {
2151 + if( pregpriv->cbw40_enable & BIT(1) )
2152 + cbw40_enable = 1;
2153 + }
2154 + else
2155 + if( pregpriv->cbw40_enable & BIT(0) )
2156 + cbw40_enable = 1;
2157 +
2158 + if ((cbw40_enable) && (pht_info->infos[0] & BIT(2)))
2159 + {
2160 + //switch to the 40M Hz mode
2161 + //pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40;
2162 + cur_bwmode = HT_CHANNEL_WIDTH_40;
2163 + switch (pht_info->infos[0] & 0x3)
2164 + {
2165 + case 1:
2166 + //pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
2167 + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
2168 + break;
2169 +
2170 + case 3:
2171 + //pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
2172 + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
2173 + break;
2174 +
2175 + default:
2176 + //pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
2177 + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
2178 + break;
2179 + }
2180 +
2181 + }
2182 +
2183 + }
2184 +
2185 +#ifdef CONFIG_DUALMAC_CONCURRENT
2186 + dc_set_ap_channel_bandwidth(padapter, cur_channel, cur_ch_offset, cur_bwmode);
2187 +#else
2188 + //TODO: need to judge the phy parameters on concurrent mode for single phy
2189 + //set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
2190 +#ifdef CONFIG_CONCURRENT_MODE
2191 + if(!check_buddy_fwstate(padapter, _FW_LINKED|_FW_UNDER_LINKING|_FW_UNDER_SURVEY))
2192 + {
2193 + set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode);
2194 + }
2195 + else if(check_buddy_fwstate(padapter, _FW_LINKED)==_TRUE)//only second adapter can enter AP Mode
2196 + {
2197 + _adapter *pbuddy_adapter = padapter->pbuddy_adapter;
2198 + struct mlme_ext_priv *pbuddy_mlmeext = &pbuddy_adapter->mlmeextpriv;
2199 +
2200 + //To sync cur_channel/cur_bwmode/cur_ch_offset with primary adapter
2201 + DBG_871X("primary iface is at linked state, sync cur_channel/cur_bwmode/cur_ch_offset\n");
2202 + DBG_871X("primary adapter, CH=%d, BW=%d, offset=%d\n", pbuddy_mlmeext->cur_channel, pbuddy_mlmeext->cur_bwmode, pbuddy_mlmeext->cur_ch_offset);
2203 + DBG_871X("second adapter, CH=%d, BW=%d, offset=%d\n", cur_channel, cur_bwmode, cur_ch_offset);
2204 +
2205 + if((cur_channel <= 14 && pbuddy_mlmeext->cur_channel >= 36) ||
2206 + (cur_channel >= 36 && pbuddy_mlmeext->cur_channel <= 14))
2207 + change_band = _TRUE;
2208 +
2209 + cur_channel = pbuddy_mlmeext->cur_channel;
2210 + if(cur_bwmode == HT_CHANNEL_WIDTH_40)
2211 + {
2212 + if(pht_info)
2213 + pht_info->infos[0] &= ~(BIT(0)|BIT(1));
2214 +
2215 + if(pbuddy_mlmeext->cur_bwmode == HT_CHANNEL_WIDTH_40)
2216 + {
2217 + cur_ch_offset = pbuddy_mlmeext->cur_ch_offset;
2218 +
2219 + //to update cur_ch_offset value in beacon
2220 + if(pht_info)
2221 + {
2222 + switch(cur_ch_offset)
2223 + {
2224 + case HAL_PRIME_CHNL_OFFSET_LOWER:
2225 + pht_info->infos[0] |= 0x1;
2226 + break;
2227 + case HAL_PRIME_CHNL_OFFSET_UPPER:
2228 + pht_info->infos[0] |= 0x3;
2229 + break;
2230 + case HAL_PRIME_CHNL_OFFSET_DONT_CARE:
2231 + default:
2232 + break;
2233 + }
2234 + }
2235 +
2236 + }
2237 + else if(pbuddy_mlmeext->cur_bwmode == HT_CHANNEL_WIDTH_20)
2238 + {
2239 + cur_bwmode = HT_CHANNEL_WIDTH_20;
2240 + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
2241 +
2242 + if(cur_channel>0 && cur_channel<5)
2243 + {
2244 + if(pht_info)
2245 + pht_info->infos[0] |= 0x1;
2246 +
2247 + cur_bwmode = HT_CHANNEL_WIDTH_40;
2248 + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
2249 + }
2250 +
2251 + if(cur_channel>7 && cur_channel<(14+1))
2252 + {
2253 + if(pht_info)
2254 + pht_info->infos[0] |= 0x3;
2255 +
2256 + cur_bwmode = HT_CHANNEL_WIDTH_40;
2257 + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
2258 + }
2259 +
2260 + set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode);
2261 + }
2262 +
2263 + }
2264 +
2265 + // to update channel value in beacon
2266 + pnetwork->Configuration.DSConfig = cur_channel;
2267 + p = rtw_get_ie((pnetwork->IEs + sizeof(NDIS_802_11_FIXED_IEs)), _DSSET_IE_, &ie_len, (pnetwork->IELength - sizeof(NDIS_802_11_FIXED_IEs)));
2268 + if(p && ie_len>0)
2269 + *(p + 2) = cur_channel;
2270 +
2271 + if(pht_info)
2272 + pht_info->primary_channel = cur_channel;
2273 +
2274 + //set buddy adapter channel, bandwidth, offeset to current adapter
2275 + pmlmeext->cur_channel = cur_channel;
2276 + pmlmeext->cur_bwmode = cur_bwmode;
2277 + pmlmeext->cur_ch_offset = cur_ch_offset;
2278 +
2279 + //buddy interface band is different from current interface, update ERP, support rate, ext support rate IE
2280 + if(change_band == _TRUE)
2281 + change_band_update_ie(padapter, pnetwork);
2282 + }
2283 +#else
2284 + set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode);
2285 +#endif //CONFIG_CONCURRENT_MODE
2286 +
2287 + DBG_871X("CH=%d, BW=%d, offset=%d\n", cur_channel, cur_bwmode, cur_ch_offset);
2288 +
2289 + //
2290 + pmlmeext->cur_channel = cur_channel;
2291 + pmlmeext->cur_bwmode = cur_bwmode;
2292 + pmlmeext->cur_ch_offset = cur_ch_offset;
2293 +#endif //CONFIG_DUALMAC_CONCURRENT
2294 + pmlmeext->cur_wireless_mode = pmlmepriv->cur_network.network_type;
2295 +
2296 + //update cur_wireless_mode
2297 + update_wireless_mode(padapter);
2298 +
2299 + //update RRSR after set channel and bandwidth
2300 + UpdateBrateTbl(padapter, pnetwork->SupportedRates);
2301 + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates);
2302 +
2303 + //udpate capability after cur_wireless_mode updated
2304 + update_capinfo(padapter, rtw_get_capability((WLAN_BSSID_EX *)pnetwork));
2305 +
2306 + //let pnetwork_mlmeext == pnetwork_mlme.
2307 + _rtw_memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length);
2308 +
2309 +#ifdef CONFIG_P2P
2310 + _rtw_memcpy(pwdinfo->p2p_group_ssid, pnetwork->Ssid.Ssid, pnetwork->Ssid.SsidLength);
2311 + pwdinfo->p2p_group_ssid_len = pnetwork->Ssid.SsidLength;
2312 +#endif //CONFIG_P2P
2313 +
2314 + if(_TRUE == pmlmeext->bstart_bss)
2315 + {
2316 + update_beacon(padapter, _TIM_IE_, NULL, _FALSE);
2317 +
2318 +#ifndef CONFIG_INTERRUPT_BASED_TXBCN //other case will tx beacon when bcn interrupt coming in.
2319 +#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
2320 + //issue beacon frame
2321 + if(send_beacon(padapter)==_FAIL)
2322 + {
2323 + DBG_871X("issue_beacon, fail!\n");
2324 + }
2325 +#endif
2326 +#endif //!CONFIG_INTERRUPT_BASED_TXBCN
2327 +
2328 + }
2329 +
2330 +
2331 + //update bc/mc sta_info
2332 + update_bmc_sta(padapter);
2333 +
2334 + //pmlmeext->bstart_bss = _TRUE;
2335 +
2336 +}
2337 +
2338 +int rtw_check_beacon_data(_adapter *padapter, u8 *pbuf, int len)
2339 +{
2340 + int ret=_SUCCESS;
2341 + u8 *p;
2342 + u8 *pHT_caps_ie=NULL;
2343 + u8 *pHT_info_ie=NULL;
2344 + struct sta_info *psta = NULL;
2345 + u16 cap, ht_cap=_FALSE;
2346 + uint ie_len = 0;
2347 + int group_cipher, pairwise_cipher;
2348 + u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX];
2349 + int supportRateNum = 0;
2350 + u8 OUI1[] = {0x00, 0x50, 0xf2,0x01};
2351 + u8 wps_oui[4]={0x0,0x50,0xf2,0x04};
2352 + u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};
2353 + struct registry_priv *pregistrypriv = &padapter->registrypriv;
2354 + struct security_priv *psecuritypriv = &padapter->securitypriv;
2355 + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
2356 + WLAN_BSSID_EX *pbss_network = (WLAN_BSSID_EX *)&pmlmepriv->cur_network.network;
2357 + struct sta_priv *pstapriv = &padapter->stapriv;
2358 + u8 *ie = pbss_network->IEs;
2359 +
2360 +
2361 + /* SSID */
2362 + /* Supported rates */
2363 + /* DS Params */
2364 + /* WLAN_EID_COUNTRY */
2365 + /* ERP Information element */
2366 + /* Extended supported rates */
2367 + /* WPA/WPA2 */
2368 + /* Wi-Fi Wireless Multimedia Extensions */
2369 + /* ht_capab, ht_oper */
2370 + /* WPS IE */
2371 +
2372 + DBG_871X("%s, len=%d\n", __FUNCTION__, len);
2373 +
2374 + if(check_fwstate(pmlmepriv, WIFI_AP_STATE) != _TRUE)
2375 + return _FAIL;
2376 +
2377 +
2378 + if(len>MAX_IE_SZ)
2379 + return _FAIL;
2380 +
2381 + pbss_network->IELength = len;
2382 +
2383 + _rtw_memset(ie, 0, MAX_IE_SZ);
2384 +
2385 + _rtw_memcpy(ie, pbuf, pbss_network->IELength);
2386 +
2387 +
2388 + if(pbss_network->InfrastructureMode!=Ndis802_11APMode)
2389 + return _FAIL;
2390 +
2391 + pbss_network->Rssi = 0;
2392 +
2393 + _rtw_memcpy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)), ETH_ALEN);
2394 +
2395 + //beacon interval
2396 + p = rtw_get_beacon_interval_from_ie(ie);//ie + 8; // 8: TimeStamp, 2: Beacon Interval 2:Capability
2397 + //pbss_network->Configuration.BeaconPeriod = le16_to_cpu(*(unsigned short*)p);
2398 + pbss_network->Configuration.BeaconPeriod = RTW_GET_LE16(p);
2399 +
2400 + //capability
2401 + //cap = *(unsigned short *)rtw_get_capability_from_ie(ie);
2402 + //cap = le16_to_cpu(cap);
2403 + cap = RTW_GET_LE16(ie);
2404 +
2405 + //SSID
2406 + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->IELength -_BEACON_IE_OFFSET_));
2407 + if(p && ie_len>0)
2408 + {
2409 + _rtw_memset(&pbss_network->Ssid, 0, sizeof(NDIS_802_11_SSID));
2410 + _rtw_memcpy(pbss_network->Ssid.Ssid, (p + 2), ie_len);
2411 + pbss_network->Ssid.SsidLength = ie_len;
2412 + }
2413 +
2414 + //chnnel
2415 + channel = 0;
2416 + pbss_network->Configuration.Length = 0;
2417 + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_));
2418 + if(p && ie_len>0)
2419 + channel = *(p + 2);
2420 +
2421 + pbss_network->Configuration.DSConfig = channel;
2422 +
2423 +
2424 + _rtw_memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX);
2425 + // get supported rates
2426 + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_));
2427 + if (p != NULL)
2428 + {
2429 + _rtw_memcpy(supportRate, p+2, ie_len);
2430 + supportRateNum = ie_len;
2431 + }
2432 +
2433 + //get ext_supported rates
2434 + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_);
2435 + if (p != NULL)
2436 + {
2437 + _rtw_memcpy(supportRate+supportRateNum, p+2, ie_len);
2438 + supportRateNum += ie_len;
2439 +
2440 + }
2441 +
2442 + network_type = rtw_check_network_type(supportRate, supportRateNum, channel);
2443 +
2444 + rtw_set_supported_rate(pbss_network->SupportedRates, network_type);
2445 +
2446 +
2447 + //parsing ERP_IE
2448 + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_));
2449 + if(p && ie_len>0)
2450 + {
2451 + ERP_IE_handler(padapter, (PNDIS_802_11_VARIABLE_IEs)p);
2452 + }
2453 +
2454 + //update privacy/security
2455 + if (cap & BIT(4))
2456 + pbss_network->Privacy = 1;
2457 + else
2458 + pbss_network->Privacy = 0;
2459 +
2460 + psecuritypriv->wpa_psk = 0;
2461 +
2462 + //wpa2
2463 + group_cipher = 0; pairwise_cipher = 0;
2464 + psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_;
2465 + psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_;
2466 + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_));
2467 + if(p && ie_len>0)
2468 + {
2469 + if(rtw_parse_wpa2_ie(p, ie_len+2, &group_cipher, &pairwise_cipher) == _SUCCESS)
2470 + {
2471 + psecuritypriv->dot11AuthAlgrthm= dot11AuthAlgrthm_8021X;
2472 +
2473 + psecuritypriv->dot8021xalg = 1;//psk, todo:802.1x
2474 + psecuritypriv->wpa_psk |= BIT(1);
2475 +
2476 + psecuritypriv->wpa2_group_cipher = group_cipher;
2477 + psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher;
2478 +#if 0
2479 + switch(group_cipher)
2480 + {
2481 + case WPA_CIPHER_NONE:
2482 + psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_;
2483 + break;
2484 + case WPA_CIPHER_WEP40:
2485 + psecuritypriv->wpa2_group_cipher = _WEP40_;
2486 + break;
2487 + case WPA_CIPHER_TKIP:
2488 + psecuritypriv->wpa2_group_cipher = _TKIP_;
2489 + break;
2490 + case WPA_CIPHER_CCMP:
2491 + psecuritypriv->wpa2_group_cipher = _AES_;
2492 + break;
2493 + case WPA_CIPHER_WEP104:
2494 + psecuritypriv->wpa2_group_cipher = _WEP104_;
2495 + break;
2496 + }
2497 +
2498 + switch(pairwise_cipher)
2499 + {
2500 + case WPA_CIPHER_NONE:
2501 + psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_;
2502 + break;
2503 + case WPA_CIPHER_WEP40:
2504 + psecuritypriv->wpa2_pairwise_cipher = _WEP40_;
2505 + break;
2506 + case WPA_CIPHER_TKIP:
2507 + psecuritypriv->wpa2_pairwise_cipher = _TKIP_;
2508 + break;
2509 + case WPA_CIPHER_CCMP:
2510 + psecuritypriv->wpa2_pairwise_cipher = _AES_;
2511 + break;
2512 + case WPA_CIPHER_WEP104:
2513 + psecuritypriv->wpa2_pairwise_cipher = _WEP104_;
2514 + break;
2515 + }
2516 +#endif
2517 + }
2518 +
2519 + }
2520 +
2521 + //wpa
2522 + ie_len = 0;
2523 + group_cipher = 0; pairwise_cipher = 0;
2524 + psecuritypriv->wpa_group_cipher = _NO_PRIVACY_;
2525 + psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_;
2526 + for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2))
2527 + {
2528 + p = rtw_get_ie(p, _SSN_IE_1_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)));
2529 + if ((p) && (_rtw_memcmp(p+2, OUI1, 4)))
2530 + {
2531 + if(rtw_parse_wpa_ie(p, ie_len+2, &group_cipher, &pairwise_cipher) == _SUCCESS)
2532 + {
2533 + psecuritypriv->dot11AuthAlgrthm= dot11AuthAlgrthm_8021X;
2534 +
2535 + psecuritypriv->dot8021xalg = 1;//psk, todo:802.1x
2536 +
2537 + psecuritypriv->wpa_psk |= BIT(0);
2538 +
2539 + psecuritypriv->wpa_group_cipher = group_cipher;
2540 + psecuritypriv->wpa_pairwise_cipher = pairwise_cipher;
2541 +
2542 +#if 0
2543 + switch(group_cipher)
2544 + {
2545 + case WPA_CIPHER_NONE:
2546 + psecuritypriv->wpa_group_cipher = _NO_PRIVACY_;
2547 + break;
2548 + case WPA_CIPHER_WEP40:
2549 + psecuritypriv->wpa_group_cipher = _WEP40_;
2550 + break;
2551 + case WPA_CIPHER_TKIP:
2552 + psecuritypriv->wpa_group_cipher = _TKIP_;
2553 + break;
2554 + case WPA_CIPHER_CCMP:
2555 + psecuritypriv->wpa_group_cipher = _AES_;
2556 + break;
2557 + case WPA_CIPHER_WEP104:
2558 + psecuritypriv->wpa_group_cipher = _WEP104_;
2559 + break;
2560 + }
2561 +
2562 + switch(pairwise_cipher)
2563 + {
2564 + case WPA_CIPHER_NONE:
2565 + psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_;
2566 + break;
2567 + case WPA_CIPHER_WEP40:
2568 + psecuritypriv->wpa_pairwise_cipher = _WEP40_;
2569 + break;
2570 + case WPA_CIPHER_TKIP:
2571 + psecuritypriv->wpa_pairwise_cipher = _TKIP_;
2572 + break;
2573 + case WPA_CIPHER_CCMP:
2574 + psecuritypriv->wpa_pairwise_cipher = _AES_;
2575 + break;
2576 + case WPA_CIPHER_WEP104:
2577 + psecuritypriv->wpa_pairwise_cipher = _WEP104_;
2578 + break;
2579 + }
2580 +#endif
2581 + }
2582 +
2583 + break;
2584 +
2585 + }
2586 +
2587 + if ((p == NULL) || (ie_len == 0))
2588 + {
2589 + break;
2590 + }
2591 +
2592 + }
2593 +
2594 + //wmm
2595 + ie_len = 0;
2596 + pmlmepriv->qospriv.qos_option = 0;
2597 + if(pregistrypriv->wmm_enable)
2598 + {
2599 + for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2))
2600 + {
2601 + p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)));
2602 + if((p) && _rtw_memcmp(p+2, WMM_PARA_IE, 6))
2603 + {
2604 + pmlmepriv->qospriv.qos_option = 1;
2605 +
2606 + *(p+8) |= BIT(7);//QoS Info, support U-APSD
2607 +
2608 + /* disable all ACM bits since the WMM admission control is not supported */
2609 + *(p + 10) &= ~BIT(4); /* BE */
2610 + *(p + 14) &= ~BIT(4); /* BK */
2611 + *(p + 18) &= ~BIT(4); /* VI */
2612 + *(p + 22) &= ~BIT(4); /* VO */
2613 +
2614 + break;
2615 + }
2616 +
2617 + if ((p == NULL) || (ie_len == 0))
2618 + {
2619 + break;
2620 + }
2621 + }
2622 + }
2623 +
2624 + //parsing HT_CAP_IE
2625 + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_));
2626 + if(p && ie_len>0)
2627 + {
2628 + u8 rf_type;
2629 +
2630 + struct rtw_ieee80211_ht_cap *pht_cap = (struct rtw_ieee80211_ht_cap *)(p+2);
2631 +
2632 + pHT_caps_ie=p;
2633 +
2634 +
2635 + ht_cap = _TRUE;
2636 + network_type |= WIRELESS_11_24N;
2637 +
2638 +
2639 + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
2640 +
2641 + if((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) ||
2642 + (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP))
2643 + {
2644 + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2));
2645 + }
2646 + else
2647 + {
2648 + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00);
2649 + }
2650 +
2651 + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03); //set Max Rx AMPDU size to 64K
2652 +
2653 + if(rf_type == RF_1T1R)
2654 + {
2655 + pht_cap->supp_mcs_set[0] = 0xff;
2656 + pht_cap->supp_mcs_set[1] = 0x0;
2657 + }
2658 +
2659 + _rtw_memcpy(&pmlmepriv->htpriv.ht_cap, p+2, ie_len);
2660 +
2661 + }
2662 +
2663 + //parsing HT_INFO_IE
2664 + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_));
2665 + if(p && ie_len>0)
2666 + {
2667 + pHT_info_ie=p;
2668 + }
2669 +
2670 + switch(network_type)
2671 + {
2672 + case WIRELESS_11B:
2673 + pbss_network->NetworkTypeInUse = Ndis802_11DS;
2674 + break;
2675 + case WIRELESS_11G:
2676 + case WIRELESS_11BG:
2677 + case WIRELESS_11G_24N:
2678 + case WIRELESS_11BG_24N:
2679 + pbss_network->NetworkTypeInUse = Ndis802_11OFDM24;
2680 + break;
2681 + case WIRELESS_11A:
2682 + pbss_network->NetworkTypeInUse = Ndis802_11OFDM5;
2683 + break;
2684 + default :
2685 + pbss_network->NetworkTypeInUse = Ndis802_11OFDM24;
2686 + break;
2687 + }
2688 +
2689 + pmlmepriv->cur_network.network_type = network_type;
2690 +
2691 +
2692 + pmlmepriv->htpriv.ht_option = _FALSE;
2693 +#ifdef CONFIG_80211N_HT
2694 + if( (psecuritypriv->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) ||
2695 + (psecuritypriv->wpa_pairwise_cipher&WPA_CIPHER_TKIP))
2696 + {
2697 + //todo:
2698 + //ht_cap = _FALSE;
2699 + }
2700 +
2701 + //ht_cap
2702 + if(pregistrypriv->ht_enable && ht_cap==_TRUE)
2703 + {
2704 + pmlmepriv->htpriv.ht_option = _TRUE;
2705 + pmlmepriv->qospriv.qos_option = 1;
2706 +
2707 + if(pregistrypriv->ampdu_enable==1)
2708 + {
2709 + pmlmepriv->htpriv.ampdu_enable = _TRUE;
2710 + }
2711 +
2712 + HT_caps_handler(padapter, (PNDIS_802_11_VARIABLE_IEs)pHT_caps_ie);
2713 +
2714 + HT_info_handler(padapter, (PNDIS_802_11_VARIABLE_IEs)pHT_info_ie);
2715 + }
2716 +#endif
2717 +
2718 +
2719 + pbss_network->Length = get_WLAN_BSSID_EX_sz((WLAN_BSSID_EX *)pbss_network);
2720 +
2721 + //issue beacon to start bss network
2722 + start_bss_network(padapter, (u8*)pbss_network);
2723 +
2724 +
2725 + //alloc sta_info for ap itself
2726 + psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress);
2727 + if(!psta)
2728 + {
2729 + psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress);
2730 + if (psta == NULL)
2731 + {
2732 + return _FAIL;
2733 + }
2734 + }
2735 + psta->state |= WIFI_AP_STATE; //Aries, add,fix bug of flush_cam_entry at STOP AP mode , 0724
2736 + rtw_indicate_connect( padapter);
2737 +
2738 + pmlmepriv->cur_network.join_res = _TRUE;//for check if already set beacon
2739 +
2740 + //update bc/mc sta_info
2741 + //update_bmc_sta(padapter);
2742 +
2743 + return ret;
2744 +
2745 +}
2746 +
2747 +void rtw_set_macaddr_acl(_adapter *padapter, int mode)
2748 +{
2749 + struct sta_priv *pstapriv = &padapter->stapriv;
2750 + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
2751 +
2752 + DBG_871X("%s, mode=%d\n", __func__, mode);
2753 +
2754 + pacl_list->mode = mode;
2755 +}
2756 +
2757 +int rtw_acl_add_sta(_adapter *padapter, u8 *addr)
2758 +{
2759 + _irqL irqL;
2760 + _list *plist, *phead;
2761 + u8 added = _FALSE;
2762 + int i, ret=0;
2763 + struct rtw_wlan_acl_node *paclnode;
2764 + struct sta_priv *pstapriv = &padapter->stapriv;
2765 + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
2766 + _queue *pacl_node_q =&pacl_list->acl_node_q;
2767 +
2768 + DBG_871X("%s(acl_num=%d)=" MAC_FMT "\n", __func__, pacl_list->num, MAC_ARG(addr));
2769 +
2770 + if((NUM_ACL-1) < pacl_list->num)
2771 + return (-1);
2772 +
2773 +
2774 + _enter_critical_bh(&(pacl_node_q->lock), &irqL);
2775 +
2776 + phead = get_list_head(pacl_node_q);
2777 + plist = get_next(phead);
2778 +
2779 + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
2780 + {
2781 + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list);
2782 + plist = get_next(plist);
2783 +
2784 + if(_rtw_memcmp(paclnode->addr, addr, ETH_ALEN))
2785 + {
2786 + if(paclnode->valid == _TRUE)
2787 + {
2788 + added = _TRUE;
2789 + DBG_871X("%s, sta has been added\n", __func__);
2790 + break;
2791 + }
2792 + }
2793 + }
2794 +
2795 + _exit_critical_bh(&(pacl_node_q->lock), &irqL);
2796 +
2797 +
2798 + if(added == _TRUE)
2799 + return ret;
2800 +
2801 +
2802 + _enter_critical_bh(&(pacl_node_q->lock), &irqL);
2803 +
2804 + for(i=0; i< NUM_ACL; i++)
2805 + {
2806 + paclnode = &pacl_list->aclnode[i];
2807 +
2808 + if(paclnode->valid == _FALSE)
2809 + {
2810 + _rtw_init_listhead(&paclnode->list);
2811 +
2812 + _rtw_memcpy(paclnode->addr, addr, ETH_ALEN);
2813 +
2814 + paclnode->valid = _TRUE;
2815 +
2816 + rtw_list_insert_tail(&paclnode->list, get_list_head(pacl_node_q));
2817 +
2818 + pacl_list->num++;
2819 +
2820 + break;
2821 + }
2822 + }
2823 +
2824 + DBG_871X("%s, acl_num=%d\n", __func__, pacl_list->num);
2825 +
2826 + _exit_critical_bh(&(pacl_node_q->lock), &irqL);
2827 +
2828 + return ret;
2829 +}
2830 +
2831 +int rtw_acl_remove_sta(_adapter *padapter, u8 *addr)
2832 +{
2833 + _irqL irqL;
2834 + _list *plist, *phead;
2835 + int i, ret=0;
2836 + struct rtw_wlan_acl_node *paclnode;
2837 + struct sta_priv *pstapriv = &padapter->stapriv;
2838 + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
2839 + _queue *pacl_node_q =&pacl_list->acl_node_q;
2840 +
2841 + DBG_871X("%s(acl_num=%d)=" MAC_FMT "\n", __func__, pacl_list->num, MAC_ARG(addr));
2842 +
2843 + _enter_critical_bh(&(pacl_node_q->lock), &irqL);
2844 +
2845 + phead = get_list_head(pacl_node_q);
2846 + plist = get_next(phead);
2847 +
2848 + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
2849 + {
2850 + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list);
2851 + plist = get_next(plist);
2852 +
2853 + if(_rtw_memcmp(paclnode->addr, addr, ETH_ALEN))
2854 + {
2855 + if(paclnode->valid == _TRUE)
2856 + {
2857 + paclnode->valid = _FALSE;
2858 +
2859 + rtw_list_delete(&paclnode->list);
2860 +
2861 + pacl_list->num--;
2862 + }
2863 + }
2864 + }
2865 +
2866 + _exit_critical_bh(&(pacl_node_q->lock), &irqL);
2867 +
2868 + DBG_871X("%s, acl_num=%d\n", __func__, pacl_list->num);
2869 +
2870 + return ret;
2871 +
2872 +}
2873 +
2874 +#ifdef CONFIG_NATIVEAP_MLME
2875 +
2876 +static void update_bcn_fixed_ie(_adapter *padapter)
2877 +{
2878 + DBG_871X("%s\n", __FUNCTION__);
2879 +
2880 +}
2881 +
2882 +static void update_bcn_erpinfo_ie(_adapter *padapter)
2883 +{
2884 + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
2885 + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
2886 + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
2887 + WLAN_BSSID_EX *pnetwork = &(pmlmeinfo->network);
2888 + unsigned char *p, *ie = pnetwork->IEs;
2889 + u32 len = 0;
2890 +
2891 + DBG_871X("%s, ERP_enable=%d\n", __FUNCTION__, pmlmeinfo->ERP_enable);
2892 +
2893 + if(!pmlmeinfo->ERP_enable)
2894 + return;
2895 +
2896 + //parsing ERP_IE
2897 + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_));
2898 + if(p && len>0)
2899 + {
2900 + PNDIS_802_11_VARIABLE_IEs pIE = (PNDIS_802_11_VARIABLE_IEs)p;
2901 +
2902 + if (pmlmepriv->num_sta_non_erp == 1)
2903 + pIE->data[0] |= RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION;
2904 + else
2905 + pIE->data[0] &= ~(RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION);
2906 +
2907 + if(pmlmepriv->num_sta_no_short_preamble > 0)
2908 + pIE->data[0] |= RTW_ERP_INFO_BARKER_PREAMBLE_MODE;
2909 + else
2910 + pIE->data[0] &= ~(RTW_ERP_INFO_BARKER_PREAMBLE_MODE);
2911 +
2912 + ERP_IE_handler(padapter, pIE);
2913 + }
2914 +
2915 +}
2916 +
2917 +static void update_bcn_htcap_ie(_adapter *padapter)
2918 +{
2919 + DBG_871X("%s\n", __FUNCTION__);
2920 +
2921 +}
2922 +
2923 +static void update_bcn_htinfo_ie(_adapter *padapter)
2924 +{
2925 + DBG_871X("%s\n", __FUNCTION__);
2926 +
2927 +}
2928 +
2929 +static void update_bcn_rsn_ie(_adapter *padapter)
2930 +{
2931 + DBG_871X("%s\n", __FUNCTION__);
2932 +
2933 +}
2934 +
2935 +static void update_bcn_wpa_ie(_adapter *padapter)
2936 +{
2937 + DBG_871X("%s\n", __FUNCTION__);
2938 +
2939 +}
2940 +
2941 +static void update_bcn_wmm_ie(_adapter *padapter)
2942 +{
2943 + DBG_871X("%s\n", __FUNCTION__);
2944 +
2945 +}
2946 +
2947 +static void update_bcn_wps_ie(_adapter *padapter)
2948 +{
2949 + u8 *pwps_ie=NULL, *pwps_ie_src, *premainder_ie, *pbackup_remainder_ie=NULL;
2950 + uint wps_ielen=0, wps_offset, remainder_ielen;
2951 + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
2952 + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
2953 + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
2954 + WLAN_BSSID_EX *pnetwork = &(pmlmeinfo->network);
2955 + unsigned char *ie = pnetwork->IEs;
2956 + u32 ielen = pnetwork->IELength;
2957 +
2958 +
2959 + DBG_871X("%s\n", __FUNCTION__);
2960 +
2961 + pwps_ie = rtw_get_wps_ie(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen);
2962 +
2963 + if(pwps_ie==NULL || wps_ielen==0)
2964 + return;
2965 +
2966 + wps_offset = (uint)(pwps_ie-ie);
2967 +
2968 + premainder_ie = pwps_ie + wps_ielen;
2969 +
2970 + remainder_ielen = ielen - wps_offset - wps_ielen;
2971 +
2972 + if(remainder_ielen>0)
2973 + {
2974 + pbackup_remainder_ie = rtw_malloc(remainder_ielen);
2975 + if(pbackup_remainder_ie)
2976 + _rtw_memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
2977 + }
2978 +
2979 +
2980 + pwps_ie_src = pmlmepriv->wps_beacon_ie;
2981 + if(pwps_ie_src == NULL)
2982 + return;
2983 +
2984 +
2985 + wps_ielen = (uint)pwps_ie_src[1];//to get ie data len
2986 + if((wps_offset+wps_ielen+2+remainder_ielen)<=MAX_IE_SZ)
2987 + {
2988 + _rtw_memcpy(pwps_ie, pwps_ie_src, wps_ielen+2);
2989 + pwps_ie += (wps_ielen+2);
2990 +
2991 + if(pbackup_remainder_ie)
2992 + _rtw_memcpy(pwps_ie, pbackup_remainder_ie, remainder_ielen);
2993 +
2994 + //update IELength
2995 + pnetwork->IELength = wps_offset + (wps_ielen+2) + remainder_ielen;
2996 + }
2997 +
2998 + if(pbackup_remainder_ie)
2999 + rtw_mfree(pbackup_remainder_ie, remainder_ielen);
3000 +
3001 +}
3002 +
3003 +static void update_bcn_p2p_ie(_adapter *padapter)
3004 +{
3005 +
3006 +}
3007 +
3008 +static void update_bcn_vendor_spec_ie(_adapter *padapter, u8*oui)
3009 +{
3010 + DBG_871X("%s\n", __FUNCTION__);
3011 +
3012 + if(_rtw_memcmp(RTW_WPA_OUI, oui, 4))
3013 + {
3014 + update_bcn_wpa_ie(padapter);
3015 + }
3016 + else if(_rtw_memcmp(WMM_OUI, oui, 4))
3017 + {
3018 + update_bcn_wmm_ie(padapter);
3019 + }
3020 + else if(_rtw_memcmp(WPS_OUI, oui, 4))
3021 + {
3022 + update_bcn_wps_ie(padapter);
3023 + }
3024 + else if(_rtw_memcmp(P2P_OUI, oui, 4))
3025 + {
3026 + update_bcn_p2p_ie(padapter);
3027 + }
3028 + else
3029 + {
3030 + DBG_871X("unknown OUI type!\n");
3031 + }
3032 +
3033 +
3034 +}
3035 +
3036 +void update_beacon(_adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
3037 +{
3038 + _irqL irqL;
3039 + struct mlme_priv *pmlmepriv;
3040 + struct mlme_ext_priv *pmlmeext;
3041 + //struct mlme_ext_info *pmlmeinfo;
3042 +
3043 + //DBG_871X("%s\n", __FUNCTION__);
3044 +
3045 + if(!padapter)
3046 + return;
3047 +
3048 + pmlmepriv = &(padapter->mlmepriv);
3049 + pmlmeext = &(padapter->mlmeextpriv);
3050 + //pmlmeinfo = &(pmlmeext->mlmext_info);
3051 +
3052 + if(_FALSE == pmlmeext->bstart_bss)
3053 + return;
3054 +
3055 + _enter_critical_bh(&pmlmepriv->bcn_update_lock, &irqL);
3056 +
3057 + switch(ie_id)
3058 + {
3059 + case 0xFF:
3060 +
3061 + update_bcn_fixed_ie(padapter);//8: TimeStamp, 2: Beacon Interval 2:Capability
3062 +
3063 + break;
3064 +
3065 + case _TIM_IE_:
3066 +
3067 + update_BCNTIM(padapter);
3068 +
3069 + break;
3070 +
3071 + case _ERPINFO_IE_:
3072 +
3073 + update_bcn_erpinfo_ie(padapter);
3074 +
3075 + break;
3076 +
3077 + case _HT_CAPABILITY_IE_:
3078 +
3079 + update_bcn_htcap_ie(padapter);
3080 +
3081 + break;
3082 +
3083 + case _RSN_IE_2_:
3084 +
3085 + update_bcn_rsn_ie(padapter);
3086 +
3087 + break;
3088 +
3089 + case _HT_ADD_INFO_IE_:
3090 +
3091 + update_bcn_htinfo_ie(padapter);
3092 +
3093 + break;
3094 +