1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
3
4 #define _OS_INTFS_C_
5
6 #include "../include/osdep_service.h"
7 #include "../include/drv_types.h"
8 #include "../include/xmit_osdep.h"
9 #include "../include/recv_osdep.h"
10 #include "../include/hal_intf.h"
11 #include "../include/rtw_ioctl.h"
12
13 #include "../include/usb_osintf.h"
14 #include "../include/rtw_br_ext.h"
15
16 MODULE_LICENSE("GPL");
17 MODULE_DESCRIPTION("Realtek Wireless Lan Driver");
18 MODULE_AUTHOR("Realtek Semiconductor Corp.");
19 MODULE_VERSION(DRIVERVERSION);
20 MODULE_FIRMWARE("rtlwifi/rtl8188eufw.bin");
21
22 #define CONFIG_BR_EXT_BRNAME "br0"
23 #define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */
24
25 /* module param defaults */
26 static int rtw_chip_version = 0x00;
27 static int rtw_rfintfs = HWPI;
28 static int rtw_lbkmode;/* RTL8712_AIR_TRX; */
29 static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure; infra, ad-hoc, auto */
30 static int rtw_channel = 1;/* ad-hoc support requirement */
31 static int rtw_wireless_mode = WIRELESS_11BG_24N;
32 static int rtw_vrtl_carrier_sense = AUTO_VCS;
33 static int rtw_vcs_type = RTS_CTS;/* */
34 static int rtw_rts_thresh = 2347;/* */
35 static int rtw_frag_thresh = 2346;/* */
36 static int rtw_preamble = PREAMBLE_LONG;/* long, short, auto */
37 static int rtw_scan_mode = 1;/* active, passive */
38 static int rtw_adhoc_tx_pwr = 1;
39 static int rtw_soft_ap;
40 static int rtw_power_mgnt = 1;
41 static int rtw_ips_mode = IPS_NORMAL;
42
43 static int rtw_smart_ps = 2;
44
45 module_param(rtw_ips_mode, int, 0644);
46 MODULE_PARM_DESC(rtw_ips_mode, "The default IPS mode");
47
48 static int rtw_debug = 1;
49 static int rtw_radio_enable = 1;
50 static int rtw_long_retry_lmt = 7;
51 static int rtw_short_retry_lmt = 7;
52 static int rtw_busy_thresh = 40;
53 static int rtw_ack_policy = NORMAL_ACK;
54
55 static int rtw_mp_mode;
56
57 static int rtw_software_encrypt;
58 static int rtw_software_decrypt;
59
60 static int rtw_acm_method;/* 0:By SW 1:By HW. */
61
62 static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */
63 static int rtw_uapsd_enable;
64 static int rtw_uapsd_max_sp = NO_LIMIT;
65 static int rtw_uapsd_acbk_en;
66 static int rtw_uapsd_acbe_en;
67 static int rtw_uapsd_acvi_en;
68 static int rtw_uapsd_acvo_en;
69
70 static int rtw_led_enable = 1;
71
72 int rtw_ht_enable = 1;
73 int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */
74 int rtw_ampdu_enable = 1;/* for enable tx_ampdu */
75 static int rtw_rx_stbc = 1;/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */
76 static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */
77
78 static int rtw_lowrate_two_xmit = 1;/* Use 2 path Tx to transmit MCS0~7 and legacy mode */
79
80 static int rtw_rf_config = RF_819X_MAX_TYPE; /* auto */
81 static int rtw_low_power;
82 static int rtw_wifi_spec;
83 static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX;
84 static int rtw_AcceptAddbaReq = true;/* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */
85
86 static int rtw_antdiv_cfg = 2; /* 0:OFF , 1:ON, 2:decide by Efuse config */
87 static int rtw_antdiv_type; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */
88
89 static int rtw_enusbss;/* 0:disable, 1:enable */
90
91 static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */
92
93 static int rtw_hwpwrp_detect; /* HW power ping detect 0:disable , 1:enable */
94
95 static int rtw_hw_wps_pbc = 1;
96
97 int rtw_mc2u_disable;
98
99 static int rtw_80211d;
100
101 static char *ifname = "wlan%d";
102 module_param(ifname, charp, 0644);
103 MODULE_PARM_DESC(ifname, "The default name to allocate for first interface");
104
105 static char *if2name = "wlan%d";
106 module_param(if2name, charp, 0644);
107 MODULE_PARM_DESC(if2name, "The default name to allocate for second interface");
108
109 char *rtw_initmac; /* temp mac address if users want to use instead of the mac address in Efuse */
110
111 module_param(rtw_initmac, charp, 0644);
112 module_param(rtw_channel_plan, int, 0644);
113 module_param(rtw_chip_version, int, 0644);
114 module_param(rtw_rfintfs, int, 0644);
115 module_param(rtw_lbkmode, int, 0644);
116 module_param(rtw_network_mode, int, 0644);
117 module_param(rtw_channel, int, 0644);
118 module_param(rtw_mp_mode, int, 0644);
119 module_param(rtw_wmm_enable, int, 0644);
120 module_param(rtw_vrtl_carrier_sense, int, 0644);
121 module_param(rtw_vcs_type, int, 0644);
122 module_param(rtw_busy_thresh, int, 0644);
123 module_param(rtw_led_enable, int, 0644);
124 module_param(rtw_ht_enable, int, 0644);
125 module_param(rtw_cbw40_enable, int, 0644);
126 module_param(rtw_ampdu_enable, int, 0644);
127 module_param(rtw_rx_stbc, int, 0644);
128 module_param(rtw_ampdu_amsdu, int, 0644);
129 module_param(rtw_lowrate_two_xmit, int, 0644);
130 module_param(rtw_rf_config, int, 0644);
131 module_param(rtw_power_mgnt, int, 0644);
132 module_param(rtw_smart_ps, int, 0644);
133 module_param(rtw_low_power, int, 0644);
134 module_param(rtw_wifi_spec, int, 0644);
135 module_param(rtw_antdiv_cfg, int, 0644);
136 module_param(rtw_antdiv_type, int, 0644);
137 module_param(rtw_enusbss, int, 0644);
138 module_param(rtw_hwpdn_mode, int, 0644);
139 module_param(rtw_hwpwrp_detect, int, 0644);
140 module_param(rtw_hw_wps_pbc, int, 0644);
141
142 static uint rtw_max_roaming_times = 2;
143 module_param(rtw_max_roaming_times, uint, 0644);
144 MODULE_PARM_DESC(rtw_max_roaming_times, "The max roaming times to try");
145
146 static int rtw_fw_iol = 1;/* 0:Disable, 1:enable, 2:by usb speed */
147 module_param(rtw_fw_iol, int, 0644);
148 MODULE_PARM_DESC(rtw_fw_iol, "FW IOL");
149
150 module_param(rtw_mc2u_disable, int, 0644);
151
152 module_param(rtw_80211d, int, 0644);
153 MODULE_PARM_DESC(rtw_80211d, "Enable 802.11d mechanism");
154
155 static uint rtw_notch_filter = RTW_NOTCH_FILTER;
156 module_param(rtw_notch_filter, uint, 0644);
157 MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P");
158 module_param_named(debug, rtw_debug, int, 0444);
159 MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)");
160
161 /* dummy routines */
rtw_proc_remove_one(struct net_device * dev)162 void rtw_proc_remove_one(struct net_device *dev)
163 {
164 }
165
rtw_proc_init_one(struct net_device * dev)166 void rtw_proc_init_one(struct net_device *dev)
167 {
168 }
169
170 #if 0 /* TODO: Convert these to /sys */
171 void rtw_proc_init_one(struct net_device *dev)
172 {
173 struct proc_dir_entry *dir_dev = NULL;
174 struct proc_dir_entry *entry = NULL;
175 struct adapter *padapter = rtw_netdev_priv(dev);
176 u8 rf_type;
177
178 if (!rtw_proc) {
179 memcpy(rtw_proc_name, DRV_NAME, sizeof(DRV_NAME));
180
181 rtw_proc = create_proc_entry(rtw_proc_name, S_IFDIR, init_net.proc_net);
182 if (!rtw_proc) {
183 DBG_88E(KERN_ERR "Unable to create rtw_proc directory\n");
184 return;
185 }
186
187 entry = create_proc_read_entry("ver_info", S_IFREG | S_IRUGO, rtw_proc, proc_get_drv_version, dev);
188 if (!entry) {
189 pr_info("Unable to create_proc_read_entry!\n");
190 return;
191 }
192 }
193
194 if (!padapter->dir_dev) {
195 padapter->dir_dev = create_proc_entry(dev->name,
196 S_IFDIR | S_IRUGO | S_IXUGO,
197 rtw_proc);
198 dir_dev = padapter->dir_dev;
199 if (!dir_dev) {
200 if (rtw_proc_cnt == 0) {
201 if (rtw_proc) {
202 remove_proc_entry(rtw_proc_name, init_net.proc_net);
203 rtw_proc = NULL;
204 }
205 }
206
207 pr_info("Unable to create dir_dev directory\n");
208 return;
209 }
210 } else {
211 return;
212 }
213
214 rtw_proc_cnt++;
215
216 entry = create_proc_read_entry("write_reg", S_IFREG | S_IRUGO,
217 dir_dev, proc_get_write_reg, dev);
218 if (!entry) {
219 pr_info("Unable to create_proc_read_entry!\n");
220 return;
221 }
222 entry->write_proc = proc_set_write_reg;
223
224 entry = create_proc_read_entry("read_reg", S_IFREG | S_IRUGO,
225 dir_dev, proc_get_read_reg, dev);
226 if (!entry) {
227 pr_info("Unable to create_proc_read_entry!\n");
228 return;
229 }
230 entry->write_proc = proc_set_read_reg;
231
232 entry = create_proc_read_entry("fwstate", S_IFREG | S_IRUGO,
233 dir_dev, proc_get_fwstate, dev);
234 if (!entry) {
235 pr_info("Unable to create_proc_read_entry!\n");
236 return;
237 }
238
239 entry = create_proc_read_entry("sec_info", S_IFREG | S_IRUGO,
240 dir_dev, proc_get_sec_info, dev);
241 if (!entry) {
242 pr_info("Unable to create_proc_read_entry!\n");
243 return;
244 }
245
246 entry = create_proc_read_entry("mlmext_state", S_IFREG | S_IRUGO,
247 dir_dev, proc_get_mlmext_state, dev);
248 if (!entry) {
249 pr_info("Unable to create_proc_read_entry!\n");
250 return;
251 }
252
253 entry = create_proc_read_entry("qos_option", S_IFREG | S_IRUGO,
254 dir_dev, proc_get_qos_option, dev);
255 if (!entry) {
256 pr_info("Unable to create_proc_read_entry!\n");
257 return;
258 }
259
260 entry = create_proc_read_entry("ht_option", S_IFREG | S_IRUGO,
261 dir_dev, proc_get_ht_option, dev);
262 if (!entry) {
263 pr_info("Unable to create_proc_read_entry!\n");
264 return;
265 }
266
267 entry = create_proc_read_entry("rf_info", S_IFREG | S_IRUGO,
268 dir_dev, proc_get_rf_info, dev);
269 if (!entry) {
270 pr_info("Unable to create_proc_read_entry!\n");
271 return;
272 }
273
274 entry = create_proc_read_entry("ap_info", S_IFREG | S_IRUGO,
275 dir_dev, proc_get_ap_info, dev);
276 if (!entry) {
277 pr_info("Unable to create_proc_read_entry!\n");
278 return;
279 }
280
281 entry = create_proc_read_entry("adapter_state", S_IFREG | S_IRUGO,
282 dir_dev, proc_getstruct adapter_state, dev);
283 if (!entry) {
284 pr_info("Unable to create_proc_read_entry!\n");
285 return;
286 }
287
288 entry = create_proc_read_entry("trx_info", S_IFREG | S_IRUGO,
289 dir_dev, proc_get_trx_info, dev);
290 if (!entry) {
291 pr_info("Unable to create_proc_read_entry!\n");
292 return;
293 }
294
295 entry = create_proc_read_entry("mac_reg_dump1", S_IFREG | S_IRUGO,
296 dir_dev, proc_get_mac_reg_dump1, dev);
297 if (!entry) {
298 pr_info("Unable to create_proc_read_entry!\n");
299 return;
300 }
301
302 entry = create_proc_read_entry("mac_reg_dump2", S_IFREG | S_IRUGO,
303 dir_dev, proc_get_mac_reg_dump2, dev);
304 if (!entry) {
305 pr_info("Unable to create_proc_read_entry!\n");
306 return;
307 }
308
309 entry = create_proc_read_entry("mac_reg_dump3", S_IFREG | S_IRUGO,
310 dir_dev, proc_get_mac_reg_dump3, dev);
311 if (!entry) {
312 pr_info("Unable to create_proc_read_entry!\n");
313 return;
314 }
315
316 entry = create_proc_read_entry("bb_reg_dump1", S_IFREG | S_IRUGO,
317 dir_dev, proc_get_bb_reg_dump1, dev);
318 if (!entry) {
319 pr_info("Unable to create_proc_read_entry!\n");
320 return;
321 }
322
323 entry = create_proc_read_entry("bb_reg_dump2", S_IFREG | S_IRUGO,
324 dir_dev, proc_get_bb_reg_dump2, dev);
325 if (!entry) {
326 pr_info("Unable to create_proc_read_entry!\n");
327 return;
328 }
329
330 entry = create_proc_read_entry("bb_reg_dump3", S_IFREG | S_IRUGO,
331 dir_dev, proc_get_bb_reg_dump3, dev);
332 if (!entry) {
333 pr_info("Unable to create_proc_read_entry!\n");
334 return;
335 }
336
337 entry = create_proc_read_entry("rf_reg_dump1", S_IFREG | S_IRUGO,
338 dir_dev, proc_get_rf_reg_dump1, dev);
339 if (!entry) {
340 pr_info("Unable to create_proc_read_entry!\n");
341 return;
342 }
343
344 entry = create_proc_read_entry("rf_reg_dump2", S_IFREG | S_IRUGO,
345 dir_dev, proc_get_rf_reg_dump2, dev);
346 if (!entry) {
347 pr_info("Unable to create_proc_read_entry!\n");
348 return;
349 }
350
351 rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
352 if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) {
353 entry = create_proc_read_entry("rf_reg_dump3", S_IFREG | S_IRUGO,
354 dir_dev, proc_get_rf_reg_dump3, dev);
355 if (!entry) {
356 pr_info("Unable to create_proc_read_entry!\n");
357 return;
358 }
359
360 entry = create_proc_read_entry("rf_reg_dump4", S_IFREG | S_IRUGO,
361 dir_dev, proc_get_rf_reg_dump4, dev);
362 if (!entry) {
363 pr_info("Unable to create_proc_read_entry!\n");
364 return;
365 }
366 }
367
368 #ifdef CONFIG_88EU_AP_MODE
369
370 entry = create_proc_read_entry("all_sta_info", S_IFREG | S_IRUGO,
371 dir_dev, proc_get_all_sta_info, dev);
372 if (!entry) {
373 pr_info("Unable to create_proc_read_entry!\n");
374 return;
375 }
376 #endif
377
378 entry = create_proc_read_entry("best_channel", S_IFREG | S_IRUGO,
379 dir_dev, proc_get_best_channel, dev);
380 if (!entry) {
381 pr_info("Unable to create_proc_read_entry!\n");
382 return;
383 }
384
385 entry = create_proc_read_entry("rx_signal", S_IFREG | S_IRUGO,
386 dir_dev, proc_get_rx_signal, dev);
387 if (!entry) {
388 pr_info("Unable to create_proc_read_entry!\n");
389 return;
390 }
391 entry->write_proc = proc_set_rx_signal;
392 entry = create_proc_read_entry("ht_enable", S_IFREG | S_IRUGO,
393 dir_dev, proc_get_ht_enable, dev);
394 if (!entry) {
395 pr_info("Unable to create_proc_read_entry!\n");
396 return;
397 }
398 entry->write_proc = proc_set_ht_enable;
399
400 entry = create_proc_read_entry("cbw40_enable", S_IFREG | S_IRUGO,
401 dir_dev, proc_get_cbw40_enable, dev);
402 if (!entry) {
403 pr_info("Unable to create_proc_read_entry!\n");
404 return;
405 }
406 entry->write_proc = proc_set_cbw40_enable;
407
408 entry = create_proc_read_entry("ampdu_enable", S_IFREG | S_IRUGO,
409 dir_dev, proc_get_ampdu_enable, dev);
410 if (!entry) {
411 pr_info("Unable to create_proc_read_entry!\n");
412 return;
413 }
414 entry->write_proc = proc_set_ampdu_enable;
415
416 entry = create_proc_read_entry("rx_stbc", S_IFREG | S_IRUGO,
417 dir_dev, proc_get_rx_stbc, dev);
418 if (!entry) {
419 pr_info("Unable to create_proc_read_entry!\n");
420 return;
421 }
422 entry->write_proc = proc_set_rx_stbc;
423
424 entry = create_proc_read_entry("path_rssi", S_IFREG | S_IRUGO,
425 dir_dev, proc_get_two_path_rssi, dev);
426 if (!entry) {
427 pr_info("Unable to create_proc_read_entry!\n");
428 return;
429 }
430 entry = create_proc_read_entry("rssi_disp", S_IFREG | S_IRUGO,
431 dir_dev, proc_get_rssi_disp, dev);
432 if (!entry) {
433 pr_info("Unable to create_proc_read_entry!\n");
434 return;
435 }
436 entry->write_proc = proc_set_rssi_disp;
437 }
438
439 void rtw_proc_remove_one(struct net_device *dev)
440 {
441 struct proc_dir_entry *dir_dev = NULL;
442 struct adapter *padapter = rtw_netdev_priv(dev);
443 u8 rf_type;
444
445 dir_dev = padapter->dir_dev;
446 padapter->dir_dev = NULL;
447
448 if (dir_dev) {
449 remove_proc_entry("write_reg", dir_dev);
450 remove_proc_entry("read_reg", dir_dev);
451 remove_proc_entry("fwstate", dir_dev);
452 remove_proc_entry("sec_info", dir_dev);
453 remove_proc_entry("mlmext_state", dir_dev);
454 remove_proc_entry("qos_option", dir_dev);
455 remove_proc_entry("ht_option", dir_dev);
456 remove_proc_entry("rf_info", dir_dev);
457 remove_proc_entry("ap_info", dir_dev);
458 remove_proc_entry("adapter_state", dir_dev);
459 remove_proc_entry("trx_info", dir_dev);
460 remove_proc_entry("mac_reg_dump1", dir_dev);
461 remove_proc_entry("mac_reg_dump2", dir_dev);
462 remove_proc_entry("mac_reg_dump3", dir_dev);
463 remove_proc_entry("bb_reg_dump1", dir_dev);
464 remove_proc_entry("bb_reg_dump2", dir_dev);
465 remove_proc_entry("bb_reg_dump3", dir_dev);
466 remove_proc_entry("rf_reg_dump1", dir_dev);
467 remove_proc_entry("rf_reg_dump2", dir_dev);
468 rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
469 if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) {
470 remove_proc_entry("rf_reg_dump3", dir_dev);
471 remove_proc_entry("rf_reg_dump4", dir_dev);
472 }
473 #ifdef CONFIG_88EU_AP_MODE
474 remove_proc_entry("all_sta_info", dir_dev);
475 #endif
476
477 remove_proc_entry("best_channel", dir_dev);
478 remove_proc_entry("rx_signal", dir_dev);
479 remove_proc_entry("cbw40_enable", dir_dev);
480 remove_proc_entry("ht_enable", dir_dev);
481 remove_proc_entry("ampdu_enable", dir_dev);
482 remove_proc_entry("rx_stbc", dir_dev);
483 remove_proc_entry("path_rssi", dir_dev);
484 remove_proc_entry("rssi_disp", dir_dev);
485 remove_proc_entry(dev->name, rtw_proc);
486 dir_dev = NULL;
487 } else {
488 return;
489 }
490 rtw_proc_cnt--;
491
492 if (rtw_proc_cnt == 0) {
493 if (rtw_proc) {
494 remove_proc_entry("ver_info", rtw_proc);
495
496 remove_proc_entry(rtw_proc_name, init_net.proc_net);
497 rtw_proc = NULL;
498 }
499 }
500 }
501 #endif
502
loadparam(struct adapter * padapter,struct net_device * pnetdev)503 static uint loadparam(struct adapter *padapter, struct net_device *pnetdev)
504 {
505 struct registry_priv *registry_par = &padapter->registrypriv;
506
507 GlobalDebugLevel = rtw_debug;
508 registry_par->chip_version = (u8)rtw_chip_version;
509 registry_par->rfintfs = (u8)rtw_rfintfs;
510 registry_par->lbkmode = (u8)rtw_lbkmode;
511 registry_par->network_mode = (u8)rtw_network_mode;
512
513 memcpy(registry_par->ssid.Ssid, "ANY", 3);
514 registry_par->ssid.SsidLength = 3;
515
516 registry_par->channel = (u8)rtw_channel;
517 registry_par->wireless_mode = (u8)rtw_wireless_mode;
518 registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense;
519 registry_par->vcs_type = (u8)rtw_vcs_type;
520 registry_par->rts_thresh = (u16)rtw_rts_thresh;
521 registry_par->frag_thresh = (u16)rtw_frag_thresh;
522 registry_par->preamble = (u8)rtw_preamble;
523 registry_par->scan_mode = (u8)rtw_scan_mode;
524 registry_par->adhoc_tx_pwr = (u8)rtw_adhoc_tx_pwr;
525 registry_par->soft_ap = (u8)rtw_soft_ap;
526 registry_par->smart_ps = (u8)rtw_smart_ps;
527 registry_par->power_mgnt = (u8)rtw_power_mgnt;
528 registry_par->ips_mode = (u8)rtw_ips_mode;
529 registry_par->radio_enable = (u8)rtw_radio_enable;
530 registry_par->long_retry_lmt = (u8)rtw_long_retry_lmt;
531 registry_par->short_retry_lmt = (u8)rtw_short_retry_lmt;
532 registry_par->busy_thresh = (u16)rtw_busy_thresh;
533 registry_par->ack_policy = (u8)rtw_ack_policy;
534 registry_par->mp_mode = (u8)rtw_mp_mode;
535 registry_par->software_encrypt = (u8)rtw_software_encrypt;
536 registry_par->software_decrypt = (u8)rtw_software_decrypt;
537 registry_par->acm_method = (u8)rtw_acm_method;
538
539 /* UAPSD */
540 registry_par->wmm_enable = (u8)rtw_wmm_enable;
541 registry_par->uapsd_enable = (u8)rtw_uapsd_enable;
542 registry_par->uapsd_max_sp = (u8)rtw_uapsd_max_sp;
543 registry_par->uapsd_acbk_en = (u8)rtw_uapsd_acbk_en;
544 registry_par->uapsd_acbe_en = (u8)rtw_uapsd_acbe_en;
545 registry_par->uapsd_acvi_en = (u8)rtw_uapsd_acvi_en;
546 registry_par->uapsd_acvo_en = (u8)rtw_uapsd_acvo_en;
547
548 registry_par->led_enable = (u8)rtw_led_enable;
549
550 registry_par->ht_enable = (u8)rtw_ht_enable;
551 registry_par->cbw40_enable = (u8)rtw_cbw40_enable;
552 registry_par->ampdu_enable = (u8)rtw_ampdu_enable;
553 registry_par->rx_stbc = (u8)rtw_rx_stbc;
554 registry_par->ampdu_amsdu = (u8)rtw_ampdu_amsdu;
555 registry_par->lowrate_two_xmit = (u8)rtw_lowrate_two_xmit;
556 registry_par->rf_config = (u8)rtw_rf_config;
557 registry_par->low_power = (u8)rtw_low_power;
558 registry_par->wifi_spec = (u8)rtw_wifi_spec;
559 registry_par->channel_plan = (u8)rtw_channel_plan;
560 registry_par->bAcceptAddbaReq = (u8)rtw_AcceptAddbaReq;
561 registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg;
562 registry_par->antdiv_type = (u8)rtw_antdiv_type;
563 registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode;/* 0:disable, 1:enable, 2:by EFUSE config */
564 registry_par->hwpwrp_detect = (u8)rtw_hwpwrp_detect;/* 0:disable, 1:enable */
565 registry_par->hw_wps_pbc = (u8)rtw_hw_wps_pbc;
566
567 registry_par->max_roaming_times = (u8)rtw_max_roaming_times;
568
569 registry_par->fw_iol = rtw_fw_iol;
570
571 registry_par->enable80211d = (u8)rtw_80211d;
572 snprintf(registry_par->ifname, 16, "%s", ifname);
573 snprintf(registry_par->if2name, 16, "%s", if2name);
574 registry_par->notch_filter = (u8)rtw_notch_filter;
575
576 return _SUCCESS;
577 }
578
rtw_net_set_mac_address(struct net_device * pnetdev,void * p)579 static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
580 {
581 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
582 struct sockaddr *addr = p;
583
584 if (!padapter->bup)
585 memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN);
586
587 return 0;
588 }
589
rtw_net_get_stats(struct net_device * pnetdev)590 static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev)
591 {
592 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
593 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
594 struct recv_priv *precvpriv = &padapter->recvpriv;
595
596 padapter->stats.tx_packets = pxmitpriv->tx_pkts;/* pxmitpriv->tx_pkts++; */
597 padapter->stats.rx_packets = precvpriv->rx_pkts;/* precvpriv->rx_pkts++; */
598 padapter->stats.tx_dropped = pxmitpriv->tx_drop;
599 padapter->stats.rx_dropped = precvpriv->rx_drop;
600 padapter->stats.tx_bytes = pxmitpriv->tx_bytes;
601 padapter->stats.rx_bytes = precvpriv->rx_bytes;
602 return &padapter->stats;
603 }
604
605 /*
606 * AC to queue mapping
607 *
608 * AC_VO -> queue 0
609 * AC_VI -> queue 1
610 * AC_BE -> queue 2
611 * AC_BK -> queue 3
612 */
613 static const u16 rtw_1d_to_queue[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
614
615 /* Given a data frame determine the 802.1p/1d tag to use. */
rtw_classify8021d(struct sk_buff * skb)616 static unsigned int rtw_classify8021d(struct sk_buff *skb)
617 {
618 unsigned int dscp;
619
620 /* skb->priority values from 256->263 are magic values to
621 * directly indicate a specific 802.1d priority. This is used
622 * to allow 802.1d priority to be passed directly in from VLAN
623 * tags, etc.
624 */
625 if (skb->priority >= 256 && skb->priority <= 263)
626 return skb->priority - 256;
627
628 switch (skb->protocol) {
629 case htons(ETH_P_IP):
630 dscp = ip_hdr(skb)->tos & 0xfc;
631 break;
632 default:
633 return 0;
634 }
635
636 return dscp >> 5;
637 }
638
rtw_select_queue(struct net_device * dev,struct sk_buff * skb,struct net_device * sb_dev)639 static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev)
640 {
641 struct adapter *padapter = rtw_netdev_priv(dev);
642 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
643
644 skb->priority = rtw_classify8021d(skb);
645
646 if (pmlmepriv->acm_mask != 0)
647 skb->priority = qos_acm(pmlmepriv->acm_mask, skb->priority);
648
649 return rtw_1d_to_queue[skb->priority];
650 }
651
rtw_recv_select_queue(struct sk_buff * skb)652 u16 rtw_recv_select_queue(struct sk_buff *skb)
653 {
654 struct iphdr *piphdr;
655 unsigned int dscp;
656 __be16 eth_type;
657 u32 priority;
658 u8 *pdata = skb->data;
659
660 memcpy(ð_type, pdata + (ETH_ALEN << 1), 2);
661
662 switch (eth_type) {
663 case htons(ETH_P_IP):
664 piphdr = (struct iphdr *)(pdata + ETH_HLEN);
665 dscp = piphdr->tos & 0xfc;
666 priority = dscp >> 5;
667 break;
668 default:
669 priority = 0;
670 }
671
672 return rtw_1d_to_queue[priority];
673 }
674
675 static const struct net_device_ops rtw_netdev_ops = {
676 .ndo_open = netdev_open,
677 .ndo_stop = netdev_close,
678 .ndo_start_xmit = rtw_xmit_entry,
679 .ndo_select_queue = rtw_select_queue,
680 .ndo_set_mac_address = rtw_net_set_mac_address,
681 .ndo_get_stats = rtw_net_get_stats,
682 };
683
rtw_init_netdev_name(struct net_device * pnetdev,const char * ifname)684 int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname)
685 {
686 int err;
687
688 err = dev_alloc_name(pnetdev, ifname);
689 if (err < 0)
690 return err;
691
692 netif_carrier_off(pnetdev);
693 return 0;
694 }
695
696 static const struct device_type wlan_type = {
697 .name = "wlan",
698 };
699
rtw_init_netdev(struct adapter * old_padapter)700 struct net_device *rtw_init_netdev(struct adapter *old_padapter)
701 {
702 struct adapter *padapter;
703 struct net_device *pnetdev;
704
705 if (old_padapter)
706 pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter);
707 else
708 pnetdev = rtw_alloc_etherdev(sizeof(struct adapter));
709
710 if (!pnetdev)
711 return NULL;
712
713 pnetdev->dev.type = &wlan_type;
714 padapter = rtw_netdev_priv(pnetdev);
715 padapter->pnetdev = pnetdev;
716 DBG_88E("register rtw_netdev_ops to netdev_ops\n");
717 pnetdev->netdev_ops = &rtw_netdev_ops;
718 pnetdev->watchdog_timeo = HZ * 3; /* 3 second timeout */
719 pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def;
720
721 /* step 2. */
722 loadparam(padapter, pnetdev);
723
724 return pnetdev;
725 }
726
rtw_start_drv_threads(struct adapter * padapter)727 u32 rtw_start_drv_threads(struct adapter *padapter)
728 {
729 u32 _status = _SUCCESS;
730
731 padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD");
732 if (IS_ERR(padapter->cmdThread))
733 _status = _FAIL;
734 else
735 _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */
736
737 rtw_hal_start_thread(padapter);
738 return _status;
739 }
740
rtw_stop_drv_threads(struct adapter * padapter)741 void rtw_stop_drv_threads(struct adapter *padapter)
742 {
743 /* Below is to termindate rtw_cmd_thread & event_thread... */
744 up(&padapter->cmdpriv.cmd_queue_sema);
745 if (padapter->cmdThread)
746 _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
747
748 rtw_hal_stop_thread(padapter);
749 }
750
rtw_init_default_value(struct adapter * padapter)751 static u8 rtw_init_default_value(struct adapter *padapter)
752 {
753 struct registry_priv *pregistrypriv = &padapter->registrypriv;
754 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
755 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
756 struct security_priv *psecuritypriv = &padapter->securitypriv;
757
758 /* xmit_priv */
759 pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense;
760 pxmitpriv->vcs = pregistrypriv->vcs_type;
761 pxmitpriv->vcs_type = pregistrypriv->vcs_type;
762 pxmitpriv->frag_len = pregistrypriv->frag_thresh;
763
764 /* mlme_priv */
765 pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */
766 pmlmepriv->scan_mode = SCAN_ACTIVE;
767
768 /* ht_priv */
769 pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */
770
771 /* security_priv */
772 psecuritypriv->binstallGrpkey = _FAIL;
773 psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
774 psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
775 psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
776 psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
777 psecuritypriv->dot11PrivacyKeyIndex = 0;
778 psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
779 psecuritypriv->dot118021XGrpKeyid = 1;
780 psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen;
781 psecuritypriv->ndisencryptstatus = Ndis802_11WEPDisabled;
782
783 /* registry_priv */
784 rtw_init_registrypriv_dev_network(padapter);
785 rtw_update_registrypriv_dev_network(padapter);
786
787 /* hal_priv */
788 rtw_hal_def_value_init(padapter);
789
790 /* misc. */
791 padapter->bReadPortCancel = false;
792 padapter->bWritePortCancel = false;
793 padapter->bRxRSSIDisplay = 0;
794 padapter->bNotifyChannelChange = 0;
795 #ifdef CONFIG_88EU_P2P
796 padapter->bShowGetP2PState = 1;
797 #endif
798 return _SUCCESS;
799 }
800
rtw_reset_drv_sw(struct adapter * padapter)801 u8 rtw_reset_drv_sw(struct adapter *padapter)
802 {
803 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
804 struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
805
806 /* hal_priv */
807 rtw_hal_def_value_init(padapter);
808 padapter->bReadPortCancel = false;
809 padapter->bWritePortCancel = false;
810 padapter->bRxRSSIDisplay = 0;
811 pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */
812
813 padapter->xmitpriv.tx_pkts = 0;
814 padapter->recvpriv.rx_pkts = 0;
815
816 pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
817
818 _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING);
819
820 rtw_hal_sreset_reset_value(padapter);
821 pwrctrlpriv->pwr_state_check_cnts = 0;
822
823 /* mlmeextpriv */
824 padapter->mlmeextpriv.sitesurvey_res.state = SCAN_DISABLE;
825
826 rtw_set_signal_stat_timer(&padapter->recvpriv);
827
828 return _SUCCESS;
829 }
830
rtw_init_drv_sw(struct adapter * padapter)831 u8 rtw_init_drv_sw(struct adapter *padapter)
832 {
833 u8 ret8 = _SUCCESS;
834
835 if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) {
836 ret8 = _FAIL;
837 goto exit;
838 }
839
840 padapter->cmdpriv.padapter = padapter;
841
842 if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) {
843 ret8 = _FAIL;
844 goto exit;
845 }
846
847 if (rtw_init_mlme_priv(padapter) == _FAIL) {
848 ret8 = _FAIL;
849 goto exit;
850 }
851
852 #ifdef CONFIG_88EU_P2P
853 rtw_init_wifidirect_timers(padapter);
854 init_wifidirect_info(padapter, P2P_ROLE_DISABLE);
855 reset_global_wifidirect_info(padapter);
856 #endif /* CONFIG_88EU_P2P */
857
858 if (init_mlme_ext_priv(padapter) == _FAIL) {
859 ret8 = _FAIL;
860 goto exit;
861 }
862
863 if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL) {
864 DBG_88E("Can't _rtw_init_xmit_priv\n");
865 ret8 = _FAIL;
866 goto exit;
867 }
868
869 if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL) {
870 DBG_88E("Can't _rtw_init_recv_priv\n");
871 ret8 = _FAIL;
872 goto exit;
873 }
874
875 if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) {
876 DBG_88E("Can't _rtw_init_sta_priv\n");
877 ret8 = _FAIL;
878 goto exit;
879 }
880
881 padapter->stapriv.padapter = padapter;
882
883 rtw_init_bcmc_stainfo(padapter);
884
885 rtw_init_pwrctrl_priv(padapter);
886
887 if (init_mp_priv(padapter) == _FAIL)
888 DBG_88E("%s: initialize MP private data Fail!\n", __func__);
889
890 ret8 = rtw_init_default_value(padapter);
891
892 rtw_hal_dm_init(padapter);
893 rtw_hal_sw_led_init(padapter);
894
895 rtw_hal_sreset_init(padapter);
896
897 spin_lock_init(&padapter->br_ext_lock);
898
899 exit:
900 return ret8;
901 }
902
rtw_cancel_all_timer(struct adapter * padapter)903 void rtw_cancel_all_timer(struct adapter *padapter)
904 {
905 _cancel_timer_ex(&padapter->mlmepriv.assoc_timer);
906
907 _cancel_timer_ex(&padapter->mlmepriv.scan_to_timer);
908
909 _cancel_timer_ex(&padapter->mlmepriv.dynamic_chk_timer);
910
911 /* cancel sw led timer */
912 rtw_hal_sw_led_deinit(padapter);
913
914 _cancel_timer_ex(&padapter->pwrctrlpriv.pwr_state_check_timer);
915
916 _cancel_timer_ex(&padapter->recvpriv.signal_stat_timer);
917 /* cancel dm timer */
918 rtw_hal_dm_deinit(padapter);
919 }
920
rtw_free_drv_sw(struct adapter * padapter)921 u8 rtw_free_drv_sw(struct adapter *padapter)
922 {
923 /* we can call rtw_p2p_enable here, but: */
924 /* 1. rtw_p2p_enable may have IO operation */
925 /* 2. rtw_p2p_enable is bundled with wext interface */
926 #ifdef CONFIG_88EU_P2P
927 {
928 struct wifidirect_info *pwdinfo = &padapter->wdinfo;
929 if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
930 _cancel_timer_ex(&pwdinfo->find_phase_timer);
931 _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer);
932 _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer);
933 rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE);
934 }
935 }
936 #endif
937
938 free_mlme_ext_priv(&padapter->mlmeextpriv);
939
940 rtw_free_cmd_priv(&padapter->cmdpriv);
941
942 rtw_free_evt_priv(&padapter->evtpriv);
943
944 rtw_free_mlme_priv(&padapter->mlmepriv);
945 _rtw_free_xmit_priv(&padapter->xmitpriv);
946
947 _rtw_free_sta_priv(&padapter->stapriv); /* will free bcmc_stainfo here */
948
949 _rtw_free_recv_priv(&padapter->recvpriv);
950
951 rtw_free_pwrctrl_priv(padapter);
952
953 rtw_hal_free_data(padapter);
954
955 /* free the old_pnetdev */
956 if (padapter->rereg_nd_name_priv.old_pnetdev) {
957 free_netdev(padapter->rereg_nd_name_priv.old_pnetdev);
958 padapter->rereg_nd_name_priv.old_pnetdev = NULL;
959 }
960
961 /* clear pbuddystruct adapter to avoid access wrong pointer. */
962 if (padapter->pbuddy_adapter)
963 padapter->pbuddy_adapter->pbuddy_adapter = NULL;
964
965 return _SUCCESS;
966 }
967
netdev_br_init(struct net_device * netdev)968 void netdev_br_init(struct net_device *netdev)
969 {
970 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev);
971
972 rcu_read_lock();
973
974 if (rcu_dereference(adapter->pnetdev->rx_handler_data)) {
975 struct net_device *br_netdev;
976 struct net *devnet = NULL;
977
978 devnet = dev_net(netdev);
979 br_netdev = dev_get_by_name(devnet, CONFIG_BR_EXT_BRNAME);
980 if (br_netdev) {
981 memcpy(adapter->br_mac, br_netdev->dev_addr, ETH_ALEN);
982 dev_put(br_netdev);
983 } else {
984 pr_info("%s()-%d: dev_get_by_name(%s) failed!",
985 __func__, __LINE__, CONFIG_BR_EXT_BRNAME);
986 }
987 }
988 adapter->ethBrExtInfo.addPPPoETag = 1;
989
990 rcu_read_unlock();
991 }
992
_netdev_open(struct net_device * pnetdev)993 int _netdev_open(struct net_device *pnetdev)
994 {
995 uint status;
996 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
997 struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
998
999 DBG_88E("+88eu_drv - drv_open, bup =%d\n", padapter->bup);
1000
1001 if (pwrctrlpriv->ps_flag) {
1002 padapter->net_closed = false;
1003 goto netdev_open_normal_process;
1004 }
1005
1006 if (!padapter->bup) {
1007 padapter->bDriverStopped = false;
1008 padapter->bSurpriseRemoved = false;
1009 padapter->bCardDisableWOHSM = false;
1010
1011 status = rtw_hal_init(padapter);
1012 if (status == _FAIL)
1013 goto netdev_open_error;
1014
1015 pr_info("MAC Address = %pM\n", pnetdev->dev_addr);
1016
1017 status = rtw_start_drv_threads(padapter);
1018 if (status == _FAIL) {
1019 pr_info("Initialize driver software resource Failed!\n");
1020 goto netdev_open_error;
1021 }
1022
1023 if (init_hw_mlme_ext(padapter) == _FAIL) {
1024 pr_info("can't init mlme_ext_priv\n");
1025 goto netdev_open_error;
1026 }
1027 if (padapter->intf_start)
1028 padapter->intf_start(padapter);
1029 rtw_proc_init_one(pnetdev);
1030
1031 rtw_led_control(padapter, LED_CTL_NO_LINK);
1032
1033 padapter->bup = true;
1034 }
1035 padapter->net_closed = false;
1036
1037 _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000);
1038
1039 padapter->pwrctrlpriv.bips_processing = false;
1040 rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
1041
1042 if (!rtw_netif_queue_stopped(pnetdev))
1043 rtw_netif_start_queue(pnetdev);
1044 else
1045 rtw_netif_wake_queue(pnetdev);
1046
1047 netdev_br_init(pnetdev);
1048
1049 netdev_open_normal_process:
1050 DBG_88E("-88eu_drv - drv_open, bup =%d\n", padapter->bup);
1051 return 0;
1052
1053 netdev_open_error:
1054 padapter->bup = false;
1055 netif_carrier_off(pnetdev);
1056 rtw_netif_stop_queue(pnetdev);
1057 DBG_88E("-88eu_drv - drv_open fail, bup =%d\n", padapter->bup);
1058 return -1;
1059 }
1060
netdev_open(struct net_device * pnetdev)1061 int netdev_open(struct net_device *pnetdev)
1062 {
1063 int ret;
1064 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
1065
1066 _enter_critical_mutex(padapter->hw_init_mutex, NULL);
1067 ret = _netdev_open(pnetdev);
1068 _exit_critical_mutex(padapter->hw_init_mutex, NULL);
1069 return ret;
1070 }
1071
ips_netdrv_open(struct adapter * padapter)1072 static int ips_netdrv_open(struct adapter *padapter)
1073 {
1074 int status = _SUCCESS;
1075 padapter->net_closed = false;
1076 DBG_88E("===> %s.........\n", __func__);
1077
1078 padapter->bDriverStopped = false;
1079 padapter->bSurpriseRemoved = false;
1080 padapter->bCardDisableWOHSM = false;
1081
1082 status = rtw_hal_init(padapter);
1083 if (status == _FAIL)
1084 goto netdev_open_error;
1085
1086 if (padapter->intf_start)
1087 padapter->intf_start(padapter);
1088
1089 rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
1090 _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 5000);
1091
1092 return _SUCCESS;
1093
1094 netdev_open_error:
1095 DBG_88E("-ips_netdrv_open - drv_open failure, bup =%d\n", padapter->bup);
1096
1097 return _FAIL;
1098 }
1099
rtw_ips_pwr_up(struct adapter * padapter)1100 int rtw_ips_pwr_up(struct adapter *padapter)
1101 {
1102 int result;
1103 u32 start_time = jiffies;
1104 DBG_88E("===> rtw_ips_pwr_up..............\n");
1105 rtw_reset_drv_sw(padapter);
1106
1107 result = ips_netdrv_open(padapter);
1108
1109 rtw_led_control(padapter, LED_CTL_NO_LINK);
1110
1111 DBG_88E("<=== rtw_ips_pwr_up.............. in %dms\n", rtw_get_passing_time_ms(start_time));
1112 return result;
1113 }
1114
rtw_ips_pwr_down(struct adapter * padapter)1115 void rtw_ips_pwr_down(struct adapter *padapter)
1116 {
1117 u32 start_time = jiffies;
1118 DBG_88E("===> rtw_ips_pwr_down...................\n");
1119
1120 padapter->bCardDisableWOHSM = true;
1121 padapter->net_closed = true;
1122
1123 rtw_led_control(padapter, LED_CTL_POWER_OFF);
1124
1125 rtw_ips_dev_unload(padapter);
1126 padapter->bCardDisableWOHSM = false;
1127 DBG_88E("<=== rtw_ips_pwr_down..................... in %dms\n", rtw_get_passing_time_ms(start_time));
1128 }
1129
rtw_ips_dev_unload(struct adapter * padapter)1130 void rtw_ips_dev_unload(struct adapter *padapter)
1131 {
1132 DBG_88E("====> %s...\n", __func__);
1133
1134 rtw_hal_set_hwreg(padapter, HW_VAR_FIFO_CLEARN_UP, NULL);
1135
1136 if (padapter->intf_stop)
1137 padapter->intf_stop(padapter);
1138
1139 /* s5. */
1140 if (!padapter->bSurpriseRemoved)
1141 rtw_hal_deinit(padapter);
1142 }
1143
pm_netdev_open(struct net_device * pnetdev,u8 bnormal)1144 int pm_netdev_open(struct net_device *pnetdev, u8 bnormal)
1145 {
1146 int status;
1147
1148 if (bnormal)
1149 status = netdev_open(pnetdev);
1150 else
1151 status = (_SUCCESS == ips_netdrv_open((struct adapter *)rtw_netdev_priv(pnetdev))) ? (0) : (-1);
1152 return status;
1153 }
1154
netdev_close(struct net_device * pnetdev)1155 int netdev_close(struct net_device *pnetdev)
1156 {
1157 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
1158 struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
1159
1160 if (padapter->pwrctrlpriv.bInternalAutoSuspend) {
1161 if (padapter->pwrctrlpriv.rf_pwrstate == rf_off)
1162 padapter->pwrctrlpriv.ps_flag = true;
1163 }
1164 padapter->net_closed = true;
1165
1166 if (padapter->pwrctrlpriv.rf_pwrstate == rf_on) {
1167 DBG_88E("(2)88eu_drv - drv_close, bup =%d, hw_init_completed =%d\n",
1168 padapter->bup, padapter->hw_init_completed);
1169
1170 /* s1. */
1171 if (pnetdev) {
1172 if (!rtw_netif_queue_stopped(pnetdev))
1173 rtw_netif_stop_queue(pnetdev);
1174 }
1175
1176 /* s2. */
1177 LeaveAllPowerSaveMode(padapter);
1178 rtw_disassoc_cmd(padapter, 500, false);
1179 /* s2-2. indicate disconnect to os */
1180 rtw_indicate_disconnect(padapter);
1181 /* s2-3. */
1182 rtw_free_assoc_resources(padapter, 1);
1183 /* s2-4. */
1184 rtw_free_network_queue(padapter, true);
1185 /* Close LED */
1186 rtw_led_control(padapter, LED_CTL_POWER_OFF);
1187 }
1188
1189 nat25_db_cleanup(padapter);
1190
1191 #ifdef CONFIG_88EU_P2P
1192 rtw_p2p_enable(padapter, P2P_ROLE_DISABLE);
1193 #endif /* CONFIG_88EU_P2P */
1194
1195 kfree(dvobj->firmware.szFwBuffer);
1196 dvobj->firmware.szFwBuffer = NULL;
1197
1198 DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup);
1199 return 0;
1200 }
1201