1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
17 #include <osdep_service.h>
18 #include <osdep_intf.h>
19 #include <drv_types.h>
20 #include <xmit_osdep.h>
21 #include <recv_osdep.h>
23 #include <rtw_ioctl.h>
24 #include <rtl8188e_hal.h>
26 MODULE_LICENSE("GPL");
27 MODULE_DESCRIPTION("Realtek Wireless Lan Driver");
28 MODULE_AUTHOR("Realtek Semiconductor Corp.");
29 MODULE_VERSION(DRIVERVERSION);
31 #define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */
33 /* module param defaults */
34 /* Ndis802_11Infrastructure; infra, ad-hoc, auto */
35 static int rtw_channel = 1;/* ad-hoc support requirement */
36 static int rtw_wireless_mode = WIRELESS_11BG_24N;
37 static int rtw_vrtl_carrier_sense = AUTO_VCS;
38 static int rtw_vcs_type = RTS_CTS;/* */
39 static int rtw_rts_thresh = 2347;/* */
40 static int rtw_frag_thresh = 2346;/* */
41 static int rtw_preamble = PREAMBLE_LONG;/* long, short, auto */
42 static int rtw_power_mgnt = 1;
43 static int rtw_ips_mode = IPS_NORMAL;
45 static int rtw_smart_ps = 2;
47 module_param(rtw_ips_mode, int, 0644);
48 MODULE_PARM_DESC(rtw_ips_mode, "The default IPS mode");
50 static int rtw_debug = 1;
52 static int rtw_software_encrypt;
53 static int rtw_software_decrypt;
55 static int rtw_acm_method;/* 0:By SW 1:By HW. */
57 static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */
58 static int rtw_uapsd_enable;
60 static int rtw_ht_enable = 1;
61 /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */
62 static int rtw_cbw40_enable = 3;
63 static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */
68 * default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ
70 static int rtw_rx_stbc = 1;
71 static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */
73 static int rtw_wifi_spec;
74 static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX;
76 static int rtw_antdiv_cfg = 2; /* 0:OFF , 1:ON, 2:decide by Efuse config */
79 * 1: for 88EE, 1Tx and 1RxCG are diversity (2 Ant with SPDT)
80 * 2: for 88EE, 1Tx and 2Rx are diversity (2 Ant, Tx and RxCG are both on aux
81 * port, RxCS is on main port)
82 * 3: for 88EE, 1Tx and 1RxCG are fixed (1Ant, Tx and RxCG are both on aux port)
84 static int rtw_antdiv_type;
86 static int rtw_enusbss;/* 0:disable, 1:enable */
88 static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */
92 static int rtw_80211d;
94 static char *ifname = "wlan%d";
95 module_param(ifname, charp, 0644);
96 MODULE_PARM_DESC(ifname, "The default name to allocate for first interface");
98 static char *if2name = "wlan%d";
99 module_param(if2name, charp, 0644);
100 MODULE_PARM_DESC(if2name, "The default name to allocate for second interface");
102 /* temp mac address if users want to use instead of the mac address in Efuse */
105 module_param(rtw_initmac, charp, 0644);
106 module_param(rtw_channel_plan, int, 0644);
107 module_param(rtw_channel, int, 0644);
108 module_param(rtw_wmm_enable, int, 0644);
109 module_param(rtw_vrtl_carrier_sense, int, 0644);
110 module_param(rtw_vcs_type, int, 0644);
111 module_param(rtw_ht_enable, int, 0644);
112 module_param(rtw_cbw40_enable, int, 0644);
113 module_param(rtw_ampdu_enable, int, 0644);
114 module_param(rtw_rx_stbc, int, 0644);
115 module_param(rtw_ampdu_amsdu, int, 0644);
116 module_param(rtw_power_mgnt, int, 0644);
117 module_param(rtw_smart_ps, int, 0644);
118 module_param(rtw_wifi_spec, int, 0644);
119 module_param(rtw_antdiv_cfg, int, 0644);
120 module_param(rtw_antdiv_type, int, 0644);
121 module_param(rtw_enusbss, int, 0644);
122 module_param(rtw_hwpdn_mode, int, 0644);
124 static uint rtw_max_roaming_times = 2;
125 module_param(rtw_max_roaming_times, uint, 0644);
126 MODULE_PARM_DESC(rtw_max_roaming_times, "The max roaming times to try");
128 static int rtw_fw_iol = 1;/* 0:Disable, 1:enable, 2:by usb speed */
129 module_param(rtw_fw_iol, int, 0644);
130 MODULE_PARM_DESC(rtw_fw_iol, "FW IOL");
132 module_param(rtw_mc2u_disable, int, 0644);
134 module_param(rtw_80211d, int, 0644);
135 MODULE_PARM_DESC(rtw_80211d, "Enable 802.11d mechanism");
137 static uint rtw_notch_filter = RTW_NOTCH_FILTER;
138 module_param(rtw_notch_filter, uint, 0644);
139 MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P");
140 module_param_named(debug, rtw_debug, int, 0444);
141 MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)");
143 static bool rtw_monitor_enable;
144 module_param_named(monitor_enable, rtw_monitor_enable, bool, 0444);
145 MODULE_PARM_DESC(monitor_enable, "Enable monitor inferface (default: false)");
147 static int netdev_open(struct net_device *pnetdev);
148 static int netdev_close(struct net_device *pnetdev);
150 static void loadparam(struct adapter *padapter, struct net_device *pnetdev)
152 struct registry_priv *registry_par = &padapter->registrypriv;
154 GlobalDebugLevel = rtw_debug;
156 memcpy(registry_par->ssid.Ssid, "ANY", 3);
157 registry_par->ssid.SsidLength = 3;
159 registry_par->channel = (u8)rtw_channel;
160 registry_par->wireless_mode = (u8)rtw_wireless_mode;
161 registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense;
162 registry_par->vcs_type = (u8)rtw_vcs_type;
163 registry_par->rts_thresh = (u16)rtw_rts_thresh;
164 registry_par->frag_thresh = (u16)rtw_frag_thresh;
165 registry_par->preamble = (u8)rtw_preamble;
166 registry_par->smart_ps = (u8)rtw_smart_ps;
167 registry_par->power_mgnt = (u8)rtw_power_mgnt;
168 registry_par->ips_mode = (u8)rtw_ips_mode;
169 registry_par->mp_mode = 0;
170 registry_par->software_encrypt = (u8)rtw_software_encrypt;
171 registry_par->software_decrypt = (u8)rtw_software_decrypt;
172 registry_par->acm_method = (u8)rtw_acm_method;
175 registry_par->wmm_enable = (u8)rtw_wmm_enable;
176 registry_par->uapsd_enable = (u8)rtw_uapsd_enable;
178 registry_par->ht_enable = (u8)rtw_ht_enable;
179 registry_par->cbw40_enable = (u8)rtw_cbw40_enable;
180 registry_par->ampdu_enable = (u8)rtw_ampdu_enable;
181 registry_par->rx_stbc = (u8)rtw_rx_stbc;
182 registry_par->ampdu_amsdu = (u8)rtw_ampdu_amsdu;
183 registry_par->wifi_spec = (u8)rtw_wifi_spec;
184 registry_par->channel_plan = (u8)rtw_channel_plan;
185 registry_par->accept_addba_req = true;
186 registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg;
187 registry_par->antdiv_type = (u8)rtw_antdiv_type;
188 registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode;
190 registry_par->max_roaming_times = (u8)rtw_max_roaming_times;
192 registry_par->fw_iol = rtw_fw_iol;
194 registry_par->enable80211d = (u8)rtw_80211d;
195 snprintf(registry_par->ifname, 16, "%s", ifname);
196 snprintf(registry_par->if2name, 16, "%s", if2name);
197 registry_par->notch_filter = (u8)rtw_notch_filter;
198 registry_par->monitor_enable = rtw_monitor_enable;
201 static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
203 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
204 struct sockaddr *addr = p;
207 memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN);
212 static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev)
214 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
215 struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
216 struct recv_priv *precvpriv = &(padapter->recvpriv);
218 padapter->stats.tx_packets = pxmitpriv->tx_pkts;
219 padapter->stats.rx_packets = precvpriv->rx_pkts;
220 padapter->stats.tx_dropped = pxmitpriv->tx_drop;
221 padapter->stats.rx_dropped = precvpriv->rx_drop;
222 padapter->stats.tx_bytes = pxmitpriv->tx_bytes;
223 padapter->stats.rx_bytes = precvpriv->rx_bytes;
224 return &padapter->stats;
228 * AC to queue mapping
235 static const u16 rtw_1d_to_queue[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
237 /* Given a data frame determine the 802.1p/1d tag to use. */
238 static unsigned int rtw_classify8021d(struct sk_buff *skb)
242 /* skb->priority values from 256->263 are magic values to
243 * directly indicate a specific 802.1d priority. This is used
244 * to allow 802.1d priority to be passed directly in from VLAN
247 if (skb->priority >= 256 && skb->priority <= 263)
248 return skb->priority - 256;
250 switch (skb->protocol) {
251 case htons(ETH_P_IP):
252 dscp = ip_hdr(skb)->tos & 0xfc;
261 static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb,
262 void *accel_priv, select_queue_fallback_t fallback)
264 struct adapter *padapter = rtw_netdev_priv(dev);
265 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
267 skb->priority = rtw_classify8021d(skb);
269 if (pmlmepriv->acm_mask != 0)
270 skb->priority = qos_acm(pmlmepriv->acm_mask, skb->priority);
272 return rtw_1d_to_queue[skb->priority];
275 u16 rtw_recv_select_queue(struct sk_buff *skb)
277 struct iphdr *piphdr;
281 u8 *pdata = skb->data;
283 memcpy(ð_type, pdata+(ETH_ALEN<<1), 2);
286 case htons(ETH_P_IP):
287 piphdr = (struct iphdr *)(pdata+ETH_HLEN);
288 dscp = piphdr->tos & 0xfc;
289 priority = dscp >> 5;
295 return rtw_1d_to_queue[priority];
298 static const struct net_device_ops rtw_netdev_ops = {
299 .ndo_open = netdev_open,
300 .ndo_stop = netdev_close,
301 .ndo_start_xmit = rtw_xmit_entry,
302 .ndo_select_queue = rtw_select_queue,
303 .ndo_set_mac_address = rtw_net_set_mac_address,
304 .ndo_get_stats = rtw_net_get_stats,
305 .ndo_do_ioctl = rtw_ioctl,
308 int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname)
310 if (dev_alloc_name(pnetdev, ifname) < 0)
311 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("dev_alloc_name, fail!\n"));
313 netif_carrier_off(pnetdev);
317 static const struct device_type wlan_type = {
321 struct net_device *rtw_init_netdev(struct adapter *old_padapter)
323 struct adapter *padapter;
324 struct net_device *pnetdev = NULL;
326 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n"));
328 if (old_padapter != NULL)
329 pnetdev = rtw_alloc_etherdev_with_old_priv((void *)old_padapter);
334 pnetdev->dev.type = &wlan_type;
335 padapter = rtw_netdev_priv(pnetdev);
336 padapter->pnetdev = pnetdev;
337 DBG_88E("register rtw_netdev_ops to netdev_ops\n");
338 pnetdev->netdev_ops = &rtw_netdev_ops;
339 pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */
340 pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def;
342 loadparam(padapter, pnetdev);
347 static int rtw_start_drv_threads(struct adapter *padapter)
351 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads\n"));
353 padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter,
355 if (IS_ERR(padapter->cmdThread))
356 err = PTR_ERR(padapter->cmdThread);
358 /* wait for cmd_thread to run */
359 wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
364 void rtw_stop_drv_threads(struct adapter *padapter)
366 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n"));
368 /* Below is to terminate rtw_cmd_thread & event_thread... */
369 complete(&padapter->cmdpriv.cmd_queue_comp);
370 if (padapter->cmdThread)
371 wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
375 static u8 rtw_init_default_value(struct adapter *padapter)
377 struct registry_priv *pregistrypriv = &padapter->registrypriv;
378 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
379 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
380 struct security_priv *psecuritypriv = &padapter->securitypriv;
383 pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense;
384 pxmitpriv->vcs = pregistrypriv->vcs_type;
385 pxmitpriv->vcs_type = pregistrypriv->vcs_type;
386 pxmitpriv->frag_len = pregistrypriv->frag_thresh;
389 pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */
390 pmlmepriv->scan_mode = SCAN_ACTIVE;
393 pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */
396 psecuritypriv->binstallGrpkey = _FAIL;
397 psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
398 psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
399 psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
400 psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
401 psecuritypriv->dot11PrivacyKeyIndex = 0;
402 psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
403 psecuritypriv->dot118021XGrpKeyid = 1;
404 psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen;
405 psecuritypriv->ndisencryptstatus = Ndis802_11WEPDisabled;
408 rtw_init_registrypriv_dev_network(padapter);
409 rtw_update_registrypriv_dev_network(padapter);
412 rtw_hal_def_value_init(padapter);
415 padapter->bReadPortCancel = false;
416 padapter->bWritePortCancel = false;
417 padapter->bRxRSSIDisplay = 0;
421 u8 rtw_reset_drv_sw(struct adapter *padapter)
423 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
424 struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
427 rtw_hal_def_value_init(padapter);
428 padapter->bReadPortCancel = false;
429 padapter->bWritePortCancel = false;
430 padapter->bRxRSSIDisplay = 0;
431 pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */
433 padapter->xmitpriv.tx_pkts = 0;
434 padapter->recvpriv.rx_pkts = 0;
436 pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
438 _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING);
439 rtw_hal_sreset_init(padapter);
440 pwrctrlpriv->pwr_state_check_cnts = 0;
443 padapter->mlmeextpriv.sitesurvey_res.state = SCAN_DISABLE;
445 rtw_set_signal_stat_timer(&padapter->recvpriv);
450 u8 rtw_init_drv_sw(struct adapter *padapter)
455 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw\n"));
457 if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) {
458 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init cmd_priv\n"));
463 padapter->cmdpriv.padapter = padapter;
465 if (rtw_init_mlme_priv(padapter) == _FAIL) {
466 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_priv\n"));
471 if (init_mlme_ext_priv(padapter) == _FAIL) {
472 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_ext_priv\n"));
477 if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL) {
478 DBG_88E("Can't _rtw_init_xmit_priv\n");
483 if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL) {
484 DBG_88E("Can't _rtw_init_recv_priv\n");
489 if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) {
490 DBG_88E("Can't _rtw_init_sta_priv\n");
495 padapter->stapriv.padapter = padapter;
497 rtw_init_bcmc_stainfo(padapter);
499 rtw_init_pwrctrl_priv(padapter);
501 ret8 = rtw_init_default_value(padapter);
503 rtw_hal_dm_init(padapter);
504 rtw_hal_sw_led_init(padapter);
506 rtw_hal_sreset_init(padapter);
509 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_init_drv_sw\n"));
515 void rtw_cancel_all_timer(struct adapter *padapter)
517 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_cancel_all_timer\n"));
519 del_timer_sync(&padapter->mlmepriv.assoc_timer);
520 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel association timer complete!\n"));
522 del_timer_sync(&padapter->mlmepriv.scan_to_timer);
523 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel scan_to_timer!\n"));
525 del_timer_sync(&padapter->mlmepriv.dynamic_chk_timer);
526 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel dynamic_chk_timer!\n"));
528 /* cancel sw led timer */
529 rtw_hal_sw_led_deinit(padapter);
530 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel DeInitSwLeds!\n"));
532 del_timer_sync(&padapter->pwrctrlpriv.pwr_state_check_timer);
534 del_timer_sync(&padapter->recvpriv.signal_stat_timer);
537 u8 rtw_free_drv_sw(struct adapter *padapter)
539 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw"));
541 free_mlme_ext_priv(&padapter->mlmeextpriv);
543 rtw_free_mlme_priv(&padapter->mlmepriv);
544 _rtw_free_xmit_priv(&padapter->xmitpriv);
546 /* will free bcmc_stainfo here */
547 _rtw_free_sta_priv(&padapter->stapriv);
549 _rtw_free_recv_priv(&padapter->recvpriv);
551 rtw_hal_free_data(padapter);
553 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("<== rtw_free_drv_sw\n"));
555 mutex_destroy(&padapter->hw_init_mutex);
557 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw\n"));
562 static int _netdev_open(struct net_device *pnetdev)
566 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
567 struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
569 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - dev_open\n"));
570 DBG_88E("+88eu_drv - drv_open, bup =%d\n", padapter->bup);
572 if (pwrctrlpriv->ps_flag) {
573 padapter->net_closed = false;
574 goto netdev_open_normal_process;
577 if (!padapter->bup) {
578 padapter->bDriverStopped = false;
579 padapter->bSurpriseRemoved = false;
581 status = rtw_hal_init(padapter);
582 if (status == _FAIL) {
583 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("rtl88eu_hal_init(): Can't init h/w!\n"));
584 goto netdev_open_error;
587 pr_info("MAC Address = %pM\n", pnetdev->dev_addr);
589 err = rtw_start_drv_threads(padapter);
591 pr_info("Initialize driver software resource Failed!\n");
592 goto netdev_open_error;
595 if (init_hw_mlme_ext(padapter) == _FAIL) {
596 pr_info("can't init mlme_ext_priv\n");
597 goto netdev_open_error;
599 if (padapter->intf_start)
600 padapter->intf_start(padapter);
602 rtw_led_control(padapter, LED_CTL_NO_LINK);
604 padapter->bup = true;
606 padapter->net_closed = false;
608 mod_timer(&padapter->mlmepriv.dynamic_chk_timer,
609 jiffies + msecs_to_jiffies(2000));
611 padapter->pwrctrlpriv.bips_processing = false;
612 rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
614 if (!rtw_netif_queue_stopped(pnetdev))
615 netif_tx_start_all_queues(pnetdev);
617 netif_tx_wake_all_queues(pnetdev);
619 netdev_open_normal_process:
620 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - dev_open\n"));
621 DBG_88E("-88eu_drv - drv_open, bup =%d\n", padapter->bup);
625 padapter->bup = false;
626 netif_carrier_off(pnetdev);
627 netif_tx_stop_all_queues(pnetdev);
628 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("-88eu_drv - dev_open, fail!\n"));
629 DBG_88E("-88eu_drv - drv_open fail, bup =%d\n", padapter->bup);
633 static int netdev_open(struct net_device *pnetdev)
636 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
638 if (mutex_lock_interruptible(&padapter->hw_init_mutex))
640 ret = _netdev_open(pnetdev);
641 mutex_unlock(&padapter->hw_init_mutex);
645 static int ips_netdrv_open(struct adapter *padapter)
647 int status = _SUCCESS;
649 padapter->net_closed = false;
650 DBG_88E("===> %s.........\n", __func__);
652 padapter->bDriverStopped = false;
653 padapter->bSurpriseRemoved = false;
655 status = rtw_hal_init(padapter);
656 if (status == _FAIL) {
657 RT_TRACE(_module_os_intfs_c_, _drv_err_, ("ips_netdrv_open(): Can't init h/w!\n"));
658 goto netdev_open_error;
661 if (padapter->intf_start)
662 padapter->intf_start(padapter);
664 rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
665 mod_timer(&padapter->mlmepriv.dynamic_chk_timer,
666 jiffies + msecs_to_jiffies(5000));
671 DBG_88E("-ips_netdrv_open - drv_open failure, bup =%d\n", padapter->bup);
677 int rtw_ips_pwr_up(struct adapter *padapter)
680 unsigned long start_time = jiffies;
682 DBG_88E("===> rtw_ips_pwr_up..............\n");
683 rtw_reset_drv_sw(padapter);
685 result = ips_netdrv_open(padapter);
687 rtw_led_control(padapter, LED_CTL_NO_LINK);
689 DBG_88E("<=== rtw_ips_pwr_up.............. in %dms\n",
690 jiffies_to_msecs(jiffies - start_time));
694 void rtw_ips_pwr_down(struct adapter *padapter)
696 unsigned long start_time = jiffies;
698 DBG_88E("===> rtw_ips_pwr_down...................\n");
700 padapter->net_closed = true;
702 rtw_led_control(padapter, LED_CTL_POWER_OFF);
704 rtw_ips_dev_unload(padapter);
705 DBG_88E("<=== rtw_ips_pwr_down..................... in %dms\n",
706 jiffies_to_msecs(jiffies - start_time));
709 void rtw_ips_dev_unload(struct adapter *padapter)
711 DBG_88E("====> %s...\n", __func__);
713 rtw_hal_set_hwreg(padapter, HW_VAR_FIFO_CLEARN_UP, NULL);
715 if (padapter->intf_stop)
716 padapter->intf_stop(padapter);
719 if (!padapter->bSurpriseRemoved)
720 rtw_hal_deinit(padapter);
723 int pm_netdev_open(struct net_device *pnetdev, u8 bnormal)
728 status = netdev_open(pnetdev);
730 status = (_SUCCESS == ips_netdrv_open((struct adapter *)rtw_netdev_priv(pnetdev))) ? (0) : (-1);
734 static int netdev_close(struct net_device *pnetdev)
736 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
738 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n"));
740 if (padapter->pwrctrlpriv.bInternalAutoSuspend) {
741 if (padapter->pwrctrlpriv.rf_pwrstate == rf_off)
742 padapter->pwrctrlpriv.ps_flag = true;
744 padapter->net_closed = true;
746 if (padapter->pwrctrlpriv.rf_pwrstate == rf_on) {
747 DBG_88E("(2)88eu_drv - drv_close, bup =%d, hw_init_completed =%d\n",
748 padapter->bup, padapter->hw_init_completed);
752 if (!rtw_netif_queue_stopped(pnetdev))
753 netif_tx_stop_all_queues(pnetdev);
757 LeaveAllPowerSaveMode(padapter);
758 rtw_disassoc_cmd(padapter, 500, false);
759 /* s2-2. indicate disconnect to os */
760 rtw_indicate_disconnect(padapter);
762 rtw_free_assoc_resources(padapter);
764 rtw_free_network_queue(padapter, true);
766 rtw_led_control(padapter, LED_CTL_POWER_OFF);
769 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n"));
770 DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup);