2013-05-08 21:45:39 +00:00
/******************************************************************************
*
* Copyright ( c ) 2007 - 2011 Realtek Corporation . All rights reserved .
2014-12-19 06:59:46 +00:00
*
2013-05-08 21:45:39 +00:00
* This program is free software ; you can redistribute it and / or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation .
*
* This program is distributed in the hope that it will be useful , but WITHOUT
* ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License for
* more details .
*
* You should have received a copy of the GNU General Public License along with
* this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 , USA
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define _OS_INTFS_C_
2014-12-17 01:03:30 +00:00
# include <drv_conf.h>
2013-05-08 21:45:39 +00:00
# include <osdep_service.h>
2014-12-17 06:40:52 +00:00
# include <osdep_intf.h>
2013-05-08 21:45:39 +00:00
# include <drv_types.h>
# include <xmit_osdep.h>
# include <recv_osdep.h>
# include <hal_intf.h>
# include <rtw_ioctl.h>
# include <rtw_version.h>
2014-12-19 04:28:04 +00:00
# include <rtw_br_ext.h>
2014-12-28 17:13:03 +00:00
# include <usb_hal.h>
2013-05-08 21:45:39 +00:00
# include <usb_osintf.h>
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_BR_EXT
2013-05-08 21:45:39 +00:00
# include <rtw_br_ext.h>
2015-02-20 04:11:26 +00:00
# endif /* CONFIG_BR_EXT */
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
MODULE_LICENSE ( " GPL " ) ;
MODULE_DESCRIPTION ( " Realtek Wireless Lan Driver " ) ;
MODULE_AUTHOR ( " Realtek Semiconductor Corp. " ) ;
MODULE_VERSION ( DRIVERVERSION ) ;
2013-10-19 17:45:47 +00:00
2013-05-08 21:45:39 +00:00
/* module param defaults */
2014-12-19 04:28:04 +00:00
static int rtw_rfintfs = HWPI ;
2015-02-20 04:11:26 +00:00
static int rtw_lbkmode = 0 ; /* RTL8712_AIR_TRX; */
2014-12-17 01:03:30 +00:00
2015-02-20 04:11:26 +00:00
static int rtw_network_mode = Ndis802_11IBSS ; /* Ndis802_11Infrastructure;infra, ad-hoc, auto */
/* NDIS_802_11_SSID ssid; */
static int rtw_channel = 1 ; /* ad-hoc support requirement */
2014-12-19 04:28:04 +00:00
static int rtw_wireless_mode = WIRELESS_11BG_24N ;
static int rtw_vrtl_carrier_sense = AUTO_VCS ;
2015-02-20 04:11:26 +00:00
static int rtw_vcs_type = RTS_CTS ; /* */
static int rtw_rts_thresh = 2347 ; /* */
static int rtw_frag_thresh = 2346 ; /* */
static int rtw_preamble = PREAMBLE_LONG ; /* long, short, auto */
static int rtw_scan_mode = 1 ; /* active, passive */
2014-12-19 04:28:04 +00:00
static int rtw_adhoc_tx_pwr = 1 ;
static int rtw_soft_ap = 0 ;
2015-02-20 04:11:26 +00:00
/* int smart_ps = 1; */
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_POWER_SAVING
2014-12-19 04:28:04 +00:00
static int rtw_power_mgnt = 1 ;
static int rtw_ips_mode = IPS_NORMAL ;
2014-12-17 01:03:30 +00:00
# else
2014-12-19 04:28:04 +00:00
static int rtw_power_mgnt = PS_MODE_ACTIVE ;
static int rtw_ips_mode = IPS_NONE ;
2014-12-17 01:03:30 +00:00
# endif
2013-05-08 21:45:39 +00:00
2014-12-19 04:28:04 +00:00
static int rtw_smart_ps = 2 ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
module_param ( rtw_ips_mode , int , 0644 ) ;
2014-12-17 01:03:30 +00:00
MODULE_PARM_DESC ( rtw_ips_mode , " The default IPS mode " ) ;
2014-12-17 06:40:52 +00:00
static int rtw_debug = 1 ;
2014-12-19 04:28:04 +00:00
static int rtw_radio_enable = 1 ;
static int rtw_long_retry_lmt = 7 ;
static int rtw_short_retry_lmt = 7 ;
static int rtw_busy_thresh = 40 ;
static int rtw_ack_policy = NORMAL_ACK ;
2014-12-17 01:03:30 +00:00
2014-12-19 04:28:04 +00:00
static int rtw_mp_mode = 0 ;
2014-12-17 01:03:30 +00:00
2014-12-19 04:28:04 +00:00
static int rtw_software_encrypt = 0 ;
static int rtw_software_decrypt = 0 ;
2014-12-17 01:03:30 +00:00
2015-02-20 04:11:26 +00:00
static int rtw_acm_method = 0 ; /* 0:By SW 1:By HW. */
2014-12-19 06:59:46 +00:00
2015-02-20 04:11:26 +00:00
static int rtw_wmm_enable = 1 ; /* default is set to enable the wmm. */
2014-12-19 04:28:04 +00:00
static int rtw_uapsd_enable = 0 ;
static int rtw_uapsd_max_sp = NO_LIMIT ;
static int rtw_uapsd_acbk_en = 0 ;
static int rtw_uapsd_acbe_en = 0 ;
static int rtw_uapsd_acvi_en = 0 ;
static int rtw_uapsd_acvo_en = 0 ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
int rtw_ht_enable = 1 ;
2015-02-20 04:11:26 +00:00
int rtw_cbw40_enable = 3 ; /* 0 :diable, bit(0): enable 2.4g, bit(1): enable 5g */
int rtw_ampdu_enable = 1 ; /* for enable tx_ampdu */
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 */
static int rtw_ampdu_amsdu = 0 ; /* 0: disabled, 1:enabled, 2:auto */
2014-12-17 01:03:30 +00:00
2015-02-20 04:11:26 +00:00
static int rtw_lowrate_two_xmit = 1 ; /* Use 2 path Tx to transmit MCS0~7 and legacy mode */
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* int rf_config = RF_1T2R; 1T2R */
static int rtw_rf_config = RF_819X_MAX_TYPE ; /* auto */
2014-12-19 04:28:04 +00:00
static int rtw_low_power = 0 ;
static int rtw_wifi_spec = 0 ;
static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX ;
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_BT_COEXIST
2014-12-19 04:28:04 +00:00
static int rtw_btcoex_enable = 1 ;
2015-02-20 04:11:26 +00:00
static int rtw_bt_iso = 2 ; /* 0:Low, 1:High, 2:From Efuse */
static int rtw_bt_sco = 3 ; /* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter, 4.Busy, 5.OtherBusy */
static int rtw_bt_ampdu = 1 ; /* 0:Disable BT control A-MPDU, 1:Enable BT control A-MPDU. */
2014-12-17 01:03:30 +00:00
# endif
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
static int rtw_AcceptAddbaReq = true ; /* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
static int rtw_antdiv_cfg = 2 ; /* 0:OFF , 1:ON, 2:decide by Efuse config */
static int rtw_antdiv_type = 0 ; /* 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) */
2013-05-19 04:28:07 +00:00
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_USB_AUTOSUSPEND
2015-02-20 04:11:26 +00:00
static int rtw_enusbss = 1 ; /* 0:disable,1:enable */
2014-12-17 01:03:30 +00:00
# else
2015-02-20 04:11:26 +00:00
static int rtw_enusbss = 0 ; /* 0:disable,1:enable */
2014-12-17 01:03:30 +00:00
# endif
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
static int rtw_hwpdn_mode = 2 ; /* 0:disable,1:enable,2: by EFUSE config */
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
static int rtw_hwpwrp_detect = 0 ; /* HW power ping detect 0:disable , 1:enable */
2014-12-17 01:03:30 +00:00
2014-12-19 04:28:04 +00:00
static int rtw_hw_wps_pbc = 1 ;
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
int rtw_mc2u_disable = 0 ;
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_80211D
2014-12-19 04:28:04 +00:00
static int rtw_80211d = 0 ;
2014-12-17 01:03:30 +00:00
# endif
2013-05-08 21:45:39 +00:00
2014-12-19 04:28:04 +00:00
static int rtw_regulatory_id = 2 ;
2014-12-17 01:03:30 +00:00
module_param ( rtw_regulatory_id , int , 0644 ) ;
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_QOS_OPTIMIZATION
2015-02-20 04:11:26 +00:00
static int rtw_qos_opt_enable = 1 ; /* 0: disable,1:enable */
2014-12-17 01:03:30 +00:00
# else
2015-02-20 04:11:26 +00:00
static int rtw_qos_opt_enable = 0 ; /* 0: disable,1:enable */
2014-12-17 01:03:30 +00:00
# endif
module_param ( rtw_qos_opt_enable , int , 0644 ) ;
2013-05-08 21:45:39 +00:00
2014-12-19 04:28:04 +00:00
static char * ifname = " wlan%d " ;
2013-05-08 21:45:39 +00:00
module_param ( ifname , charp , 0644 ) ;
MODULE_PARM_DESC ( ifname , " The default name to allocate for first interface " ) ;
2015-02-20 04:11:26 +00:00
char * rtw_initmac = NULL ; /* temp mac address if users want to use instead of the mac address in Efuse */
2013-05-08 21:45:39 +00:00
module_param ( rtw_initmac , charp , 0644 ) ;
module_param ( rtw_channel_plan , int , 0644 ) ;
module_param ( rtw_rfintfs , int , 0644 ) ;
module_param ( rtw_lbkmode , int , 0644 ) ;
module_param ( rtw_network_mode , int , 0644 ) ;
module_param ( rtw_channel , int , 0644 ) ;
module_param ( rtw_mp_mode , int , 0644 ) ;
module_param ( rtw_wmm_enable , int , 0644 ) ;
module_param ( rtw_vrtl_carrier_sense , int , 0644 ) ;
module_param ( rtw_vcs_type , int , 0644 ) ;
module_param ( rtw_busy_thresh , int , 0644 ) ;
module_param ( rtw_ht_enable , int , 0644 ) ;
module_param ( rtw_cbw40_enable , int , 0644 ) ;
module_param ( rtw_ampdu_enable , int , 0644 ) ;
module_param ( rtw_rx_stbc , int , 0644 ) ;
module_param ( rtw_ampdu_amsdu , int , 0644 ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
module_param ( rtw_lowrate_two_xmit , int , 0644 ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
module_param ( rtw_rf_config , int , 0644 ) ;
module_param ( rtw_power_mgnt , int , 0644 ) ;
module_param ( rtw_smart_ps , int , 0644 ) ;
module_param ( rtw_low_power , int , 0644 ) ;
module_param ( rtw_wifi_spec , int , 0644 ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
module_param ( rtw_antdiv_cfg , int , 0644 ) ;
module_param ( rtw_antdiv_type , int , 0644 ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
module_param ( rtw_enusbss , int , 0644 ) ;
module_param ( rtw_hwpdn_mode , int , 0644 ) ;
module_param ( rtw_hwpwrp_detect , int , 0644 ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
module_param ( rtw_hw_wps_pbc , int , 0644 ) ;
2014-12-19 04:28:04 +00:00
static uint rtw_max_roaming_times = 2 ;
2013-05-08 21:45:39 +00:00
module_param ( rtw_max_roaming_times , uint , 0644 ) ;
2014-12-17 01:03:30 +00:00
MODULE_PARM_DESC ( rtw_max_roaming_times , " The max roaming times to try " ) ;
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
static int rtw_fw_iol = 1 ; /* 0:Disable, 1:enable, 2:by usb speed */
2013-05-08 21:45:39 +00:00
module_param ( rtw_fw_iol , int , 0644 ) ;
2014-12-17 01:03:30 +00:00
MODULE_PARM_DESC ( rtw_fw_iol , " FW IOL " ) ;
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_FILE_FWIMG
2014-12-19 04:28:04 +00:00
static char * rtw_fw_file_path = " " ;
2014-12-17 01:03:30 +00:00
module_param ( rtw_fw_file_path , charp , 0644 ) ;
MODULE_PARM_DESC ( rtw_fw_file_path , " The path of fw image " ) ;
2015-02-20 04:11:26 +00:00
# endif /* CONFIG_FILE_FWIMG */
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
module_param ( rtw_mc2u_disable , int , 0644 ) ;
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_80211D
2013-05-08 21:45:39 +00:00
module_param ( rtw_80211d , int , 0644 ) ;
MODULE_PARM_DESC ( rtw_80211d , " Enable 802.11d mechanism " ) ;
2014-12-17 01:03:30 +00:00
# endif
# ifdef CONFIG_BT_COEXIST
module_param ( rtw_btcoex_enable , int , 0644 ) ;
MODULE_PARM_DESC ( rtw_btcoex_enable , " Enable BT co-existence mechanism " ) ;
# endif
2013-05-08 21:45:39 +00:00
2014-12-19 04:28:04 +00:00
static uint rtw_notch_filter = RTW_NOTCH_FILTER ;
2013-05-08 21:45:39 +00:00
module_param ( rtw_notch_filter , uint , 0644 ) ;
MODULE_PARM_DESC ( rtw_notch_filter , " 0:Disable, 1:Enable, 2:Enable only for P2P " ) ;
2014-12-17 06:40:52 +00:00
module_param_named ( debug , rtw_debug , int , 0444 ) ;
MODULE_PARM_DESC ( debug , " Set debug level (1-9) (default 1) " ) ;
2013-05-08 21:45:39 +00:00
2015-03-16 13:54:18 +00:00
static uint loadparam ( struct adapter * padapter , struct net_device * pnetdev ) ;
2014-12-17 01:03:30 +00:00
int _netdev_open ( struct net_device * pnetdev ) ;
int netdev_open ( struct net_device * pnetdev ) ;
static int netdev_close ( struct net_device * pnetdev ) ;
# ifdef CONFIG_PROC_DEBUG
# define RTL8192C_PROC_NAME "rtl819xC"
# define RTL8192D_PROC_NAME "rtl819xD"
static char rtw_proc_name [ IFNAMSIZ ] ;
static struct proc_dir_entry * rtw_proc = NULL ;
static int rtw_proc_cnt = 0 ;
# define RTW_PROC_NAME DRV_NAME
2013-05-08 21:45:39 +00:00
void rtw_proc_init_one ( struct net_device * dev )
{
}
void rtw_proc_remove_one ( struct net_device * dev )
{
}
# endif
2015-03-16 13:54:18 +00:00
static uint loadparam ( struct adapter * padapter , struct net_device * pnetdev )
2013-05-08 21:45:39 +00:00
{
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
uint status = _SUCCESS ;
struct registry_priv * registry_par = & padapter - > registrypriv ;
2014-12-17 06:40:52 +00:00
GlobalDebugLevel = rtw_debug ;
2013-05-08 21:45:39 +00:00
registry_par - > rfintfs = ( u8 ) rtw_rfintfs ;
2014-12-19 06:59:46 +00:00
registry_par - > lbkmode = ( u8 ) rtw_lbkmode ;
2015-02-20 04:11:26 +00:00
/* registry_par->hci = (u8)hci; */
2014-12-19 06:59:46 +00:00
registry_par - > network_mode = ( u8 ) rtw_network_mode ;
2013-05-08 21:45:39 +00:00
2015-02-19 20:50:04 +00:00
memcpy ( registry_par - > ssid . Ssid , " ANY " , 3 ) ;
2013-05-08 21:45:39 +00:00
registry_par - > ssid . SsidLength = 3 ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
registry_par - > channel = ( u8 ) rtw_channel ;
registry_par - > wireless_mode = ( u8 ) rtw_wireless_mode ;
registry_par - > vrtl_carrier_sense = ( u8 ) rtw_vrtl_carrier_sense ;
registry_par - > vcs_type = ( u8 ) rtw_vcs_type ;
2014-12-17 01:03:30 +00:00
registry_par - > rts_thresh = ( u16 ) rtw_rts_thresh ;
registry_par - > frag_thresh = ( u16 ) rtw_frag_thresh ;
2013-05-08 21:45:39 +00:00
registry_par - > preamble = ( u8 ) rtw_preamble ;
registry_par - > scan_mode = ( u8 ) rtw_scan_mode ;
registry_par - > adhoc_tx_pwr = ( u8 ) rtw_adhoc_tx_pwr ;
2014-12-17 01:03:30 +00:00
registry_par - > soft_ap = ( u8 ) rtw_soft_ap ;
2014-12-19 06:59:46 +00:00
registry_par - > smart_ps = ( u8 ) rtw_smart_ps ;
2013-05-08 21:45:39 +00:00
registry_par - > power_mgnt = ( u8 ) rtw_power_mgnt ;
registry_par - > ips_mode = ( u8 ) rtw_ips_mode ;
registry_par - > radio_enable = ( u8 ) rtw_radio_enable ;
2014-12-17 06:40:52 +00:00
registry_par - > radio_enable = ( u8 ) rtw_radio_enable ;
2013-05-08 21:45:39 +00:00
registry_par - > long_retry_lmt = ( u8 ) rtw_long_retry_lmt ;
registry_par - > short_retry_lmt = ( u8 ) rtw_short_retry_lmt ;
2014-12-19 06:59:46 +00:00
registry_par - > busy_thresh = ( u16 ) rtw_busy_thresh ;
2015-02-20 04:11:26 +00:00
/* registry_par->qos_enable = (u8)rtw_qos_enable; */
2013-05-08 21:45:39 +00:00
registry_par - > ack_policy = ( u8 ) rtw_ack_policy ;
2014-12-19 06:59:46 +00:00
registry_par - > mp_mode = ( u8 ) rtw_mp_mode ;
2013-05-08 21:45:39 +00:00
registry_par - > software_encrypt = ( u8 ) rtw_software_encrypt ;
2014-12-19 06:59:46 +00:00
registry_par - > software_decrypt = ( u8 ) rtw_software_decrypt ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
registry_par - > acm_method = ( u8 ) rtw_acm_method ;
2015-02-20 04:11:26 +00:00
/* UAPSD */
2013-05-08 21:45:39 +00:00
registry_par - > wmm_enable = ( u8 ) rtw_wmm_enable ;
2014-12-19 06:59:46 +00:00
registry_par - > uapsd_enable = ( u8 ) rtw_uapsd_enable ;
2013-05-08 21:45:39 +00:00
registry_par - > uapsd_max_sp = ( u8 ) rtw_uapsd_max_sp ;
registry_par - > uapsd_acbk_en = ( u8 ) rtw_uapsd_acbk_en ;
registry_par - > uapsd_acbe_en = ( u8 ) rtw_uapsd_acbe_en ;
registry_par - > uapsd_acvi_en = ( u8 ) rtw_uapsd_acvi_en ;
registry_par - > uapsd_acvo_en = ( u8 ) rtw_uapsd_acvo_en ;
registry_par - > ht_enable = ( u8 ) rtw_ht_enable ;
registry_par - > cbw40_enable = ( u8 ) rtw_cbw40_enable ;
registry_par - > ampdu_enable = ( u8 ) rtw_ampdu_enable ;
2014-12-19 06:59:46 +00:00
registry_par - > rx_stbc = ( u8 ) rtw_rx_stbc ;
2013-05-08 21:45:39 +00:00
registry_par - > ampdu_amsdu = ( u8 ) rtw_ampdu_amsdu ;
registry_par - > lowrate_two_xmit = ( u8 ) rtw_lowrate_two_xmit ;
registry_par - > rf_config = ( u8 ) rtw_rf_config ;
registry_par - > low_power = ( u8 ) rtw_low_power ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
registry_par - > wifi_spec = ( u8 ) rtw_wifi_spec ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
registry_par - > channel_plan = ( u8 ) rtw_channel_plan ;
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_BT_COEXIST
registry_par - > btcoex = ( u8 ) rtw_btcoex_enable ;
registry_par - > bt_iso = ( u8 ) rtw_bt_iso ;
registry_par - > bt_sco = ( u8 ) rtw_bt_sco ;
registry_par - > bt_ampdu = ( u8 ) rtw_bt_ampdu ;
# endif
2013-05-08 21:45:39 +00:00
registry_par - > bAcceptAddbaReq = ( u8 ) rtw_AcceptAddbaReq ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
registry_par - > antdiv_cfg = ( u8 ) rtw_antdiv_cfg ;
registry_par - > antdiv_type = ( u8 ) rtw_antdiv_type ;
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_AUTOSUSPEND
2015-02-20 04:11:26 +00:00
registry_par - > usbss_enable = ( u8 ) rtw_enusbss ; /* 0:disable,1:enable */
2014-12-17 01:03:30 +00:00
# endif
2015-02-20 04:11:26 +00:00
registry_par - > hwpdn_mode = ( u8 ) rtw_hwpdn_mode ; /* 0:disable,1:enable,2:by EFUSE config */
registry_par - > hwpwrp_detect = ( u8 ) rtw_hwpwrp_detect ; /* 0:disable,1:enable */
2014-12-17 01:03:30 +00:00
registry_par - > qos_opt_enable = ( u8 ) rtw_qos_opt_enable ;
2013-05-08 21:45:39 +00:00
registry_par - > hw_wps_pbc = ( u8 ) rtw_hw_wps_pbc ;
registry_par - > max_roaming_times = ( u8 ) rtw_max_roaming_times ;
registry_par - > fw_iol = rtw_fw_iol ;
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_80211D
2013-05-08 21:45:39 +00:00
registry_par - > enable80211d = ( u8 ) rtw_80211d ;
2014-12-17 01:03:30 +00:00
# endif
2013-05-08 21:45:39 +00:00
snprintf ( registry_par - > ifname , 16 , " %s " , ifname ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
registry_par - > notch_filter = ( u8 ) rtw_notch_filter ;
2014-12-01 22:31:15 +00:00
2014-12-17 01:03:30 +00:00
registry_par - > regulatory_tid = ( u8 ) rtw_regulatory_id ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
return status ;
}
static int rtw_net_set_mac_address ( struct net_device * pnetdev , void * p )
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter = ( struct adapter * ) rtw_netdev_priv ( pnetdev ) ;
2013-05-08 21:45:39 +00:00
struct sockaddr * addr = p ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( padapter - > bup = = false )
2014-12-17 01:03:30 +00:00
{
2015-08-15 21:38:30 +00:00
/* DBG_88E("r8711_net_set_mac_address(), MAC=%x:%x:%x:%x:%x:%x\n", addr->sa_data[0], addr->sa_data[1], addr->sa_data[2], addr->sa_data[3], */
2015-02-20 04:11:26 +00:00
/* addr->sa_data[4], addr->sa_data[5]); */
2015-02-19 20:50:04 +00:00
memcpy ( padapter - > eeprompriv . mac_addr , addr - > sa_data , ETH_ALEN ) ;
2015-02-20 04:11:26 +00:00
/* memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN); */
/* padapter->bset_hwaddr = true; */
2014-12-17 01:03:30 +00:00
}
2013-05-08 21:45:39 +00:00
return 0 ;
}
static struct net_device_stats * rtw_net_get_stats ( struct net_device * pnetdev )
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter = ( struct adapter * ) rtw_netdev_priv ( pnetdev ) ;
2018-08-30 18:19:58 +00:00
struct xmit_priv * pxmitpriv = & padapter - > xmitpriv ;
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
padapter - > stats . tx_packets = pxmitpriv - > tx_pkts ; /* pxmitpriv->tx_pkts++; */
padapter - > stats . rx_packets = precvpriv - > rx_pkts ; /* precvpriv->rx_pkts++; */
2013-05-08 21:45:39 +00:00
padapter - > stats . tx_dropped = pxmitpriv - > tx_drop ;
padapter - > stats . rx_dropped = precvpriv - > rx_drop ;
padapter - > stats . tx_bytes = pxmitpriv - > tx_bytes ;
padapter - > stats . rx_bytes = precvpriv - > rx_bytes ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
return & padapter - > stats ;
}
2014-12-17 01:03:30 +00:00
# if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35))
2013-05-08 21:45:39 +00:00
/*
* AC to queue mapping
*
* AC_VO - > queue 0
* AC_VI - > queue 1
* AC_BE - > queue 2
* AC_BK - > queue 3
*/
static const u16 rtw_1d_to_queue [ 8 ] = { 2 , 3 , 3 , 2 , 1 , 1 , 0 , 0 } ;
/* Given a data frame determine the 802.1p/1d tag to use. */
2014-12-19 04:28:04 +00:00
static unsigned int rtw_classify8021d ( struct sk_buff * skb )
2013-05-08 21:45:39 +00:00
{
unsigned int dscp ;
/* skb->priority values from 256->263 are magic values to
* directly indicate a specific 802.1 d priority . This is used
* to allow 802.1 d priority to be passed directly in from VLAN
* tags , etc .
*/
if ( skb - > priority > = 256 & & skb - > priority < = 263 )
return skb - > priority - 256 ;
switch ( skb - > protocol ) {
case htons ( ETH_P_IP ) :
dscp = ip_hdr ( skb ) - > tos & 0xfc ;
break ;
default :
return 0 ;
}
return dscp > > 5 ;
}
2014-12-30 00:42:21 +00:00
static u16 rtw_select_queue ( struct net_device * dev , struct sk_buff * skb
2018-08-28 01:19:20 +00:00
# if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
, struct net_device * sb_dev
, select_queue_fallback_t fallback
# elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
2014-12-30 00:42:21 +00:00
, void * unused
, select_queue_fallback_t fallback
# elif (LINUX_VERSION_CODE == KERNEL_VERSION(3, 13, 0))
, void * accel
2014-12-28 00:06:03 +00:00
# endif
2014-12-30 00:42:21 +00:00
)
2013-05-08 21:45:39 +00:00
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter = rtw_netdev_priv ( dev ) ;
2013-05-08 21:45:39 +00:00
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
skb - > priority = rtw_classify8021d ( skb ) ;
2015-08-15 18:02:34 +00:00
if ( pmlmepriv - > acm_mask ! = 0 )
2014-12-17 01:03:30 +00:00
{
2013-05-08 21:45:39 +00:00
skb - > priority = qos_acm ( pmlmepriv - > acm_mask , skb - > priority ) ;
2014-12-17 01:03:30 +00:00
}
2013-05-08 21:45:39 +00:00
return rtw_1d_to_queue [ skb - > priority ] ;
}
2014-12-28 00:06:03 +00:00
# if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0))
2013-05-08 21:45:39 +00:00
u16 rtw_recv_select_queue ( struct sk_buff * skb )
2014-12-28 00:06:03 +00:00
# else
u16 rtw_recv_select_queue ( struct sk_buff * skb ,
void * accel_priv ,
select_queue_fallback_t fallback )
# endif
2013-05-08 21:45:39 +00:00
{
struct iphdr * piphdr ;
unsigned int dscp ;
2014-12-19 04:28:04 +00:00
__be16 eth_type ;
2013-05-08 21:45:39 +00:00
u32 priority ;
u8 * pdata = skb - > data ;
2015-02-19 20:50:04 +00:00
memcpy ( & eth_type , pdata + ( ETH_ALEN < < 1 ) , 2 ) ;
2013-05-08 21:45:39 +00:00
2014-12-19 04:28:04 +00:00
switch ( be16_to_cpu ( eth_type ) ) {
case ETH_P_IP :
2014-12-17 01:03:30 +00:00
piphdr = ( struct iphdr * ) ( pdata + ETH_HLEN ) ;
dscp = piphdr - > tos & 0xfc ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
priority = dscp > > 5 ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
break ;
default :
priority = 0 ;
2013-05-08 21:45:39 +00:00
}
return rtw_1d_to_queue [ priority ] ;
}
2014-12-17 01:03:30 +00:00
# endif
# if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29))
2013-05-08 21:45:39 +00:00
static const struct net_device_ops rtw_netdev_ops = {
. ndo_open = netdev_open ,
. ndo_stop = netdev_close ,
. ndo_start_xmit = rtw_xmit_entry ,
2014-12-17 01:03:30 +00:00
# if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35))
2013-05-08 21:45:39 +00:00
. ndo_select_queue = rtw_select_queue ,
2014-12-17 01:03:30 +00:00
# endif
2013-05-08 21:45:39 +00:00
. ndo_set_mac_address = rtw_net_set_mac_address ,
. ndo_get_stats = rtw_net_get_stats ,
. ndo_do_ioctl = rtw_ioctl ,
} ;
2014-12-17 01:03:30 +00:00
# endif
2013-05-08 21:45:39 +00:00
int rtw_init_netdev_name ( struct net_device * pnetdev , const char * ifname )
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter = rtw_netdev_priv ( pnetdev ) ;
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_EASY_REPLACEMENT
struct net_device * TargetNetdev = NULL ;
2014-12-17 23:13:53 +00:00
struct adapter * TargetAdapter = NULL ;
2014-12-19 06:59:46 +00:00
struct net * devnet = NULL ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( padapter - > bDongle = = 1 )
2014-12-17 01:03:30 +00:00
{
# if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
TargetNetdev = dev_get_by_name ( " wlan0 " ) ;
2014-04-18 06:21:08 +00:00
# else
2014-12-17 01:03:30 +00:00
# if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
devnet = pnetdev - > nd_net ;
# else
devnet = dev_net ( pnetdev ) ;
# endif
TargetNetdev = dev_get_by_name ( devnet , " wlan0 " ) ;
# endif
2015-08-15 18:02:34 +00:00
if ( TargetNetdev ) {
2015-08-15 21:38:30 +00:00
DBG_88E ( " Force onboard module driver disappear !!! \n " ) ;
2014-12-17 01:03:30 +00:00
TargetAdapter = rtw_netdev_priv ( TargetNetdev ) ;
TargetAdapter - > DriverState = DRIVER_DISAPPEAR ;
padapter - > pid [ 0 ] = TargetAdapter - > pid [ 0 ] ;
padapter - > pid [ 1 ] = TargetAdapter - > pid [ 1 ] ;
padapter - > pid [ 2 ] = TargetAdapter - > pid [ 2 ] ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
dev_put ( TargetNetdev ) ;
unregister_netdev ( TargetNetdev ) ;
2015-08-15 18:02:34 +00:00
if ( TargetAdapter - > chip_type = = padapter - > chip_type )
2014-12-17 01:03:30 +00:00
rtw_proc_remove_one ( TargetNetdev ) ;
padapter - > DriverState = DRIVER_REPLACE_DONGLE ;
}
}
2014-04-18 06:21:08 +00:00
# endif
2013-10-18 03:25:27 +00:00
2015-08-15 18:02:34 +00:00
if ( dev_alloc_name ( pnetdev , ifname ) < 0 )
2014-12-17 01:03:30 +00:00
{
2015-08-15 18:00:19 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_err_ , ( " dev_alloc_name, fail! \n " ) ) ;
2014-12-17 01:03:30 +00:00
}
netif_carrier_off ( pnetdev ) ;
2015-02-20 04:11:26 +00:00
/* rtw_netif_stop_queue(pnetdev); */
2014-12-17 01:03:30 +00:00
return 0 ;
}
2014-12-19 06:59:46 +00:00
struct net_device * rtw_init_netdev ( struct adapter * old_padapter )
2013-05-08 21:45:39 +00:00
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter ;
2013-05-08 21:45:39 +00:00
struct net_device * pnetdev ;
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " +init_net_dev \n " ) ) ;
2013-05-19 04:28:07 +00:00
2015-08-15 18:02:34 +00:00
if ( old_padapter ! = NULL )
2014-12-17 23:13:53 +00:00
pnetdev = rtw_alloc_etherdev_with_old_priv ( sizeof ( struct adapter ) , ( void * ) old_padapter ) ;
2014-12-19 06:59:46 +00:00
else
2014-12-17 23:13:53 +00:00
pnetdev = rtw_alloc_etherdev ( sizeof ( struct adapter ) ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
if ( ! pnetdev )
return NULL ;
padapter = rtw_netdev_priv ( pnetdev ) ;
2014-12-19 06:59:46 +00:00
padapter - > pnetdev = pnetdev ;
2014-12-17 01:03:30 +00:00
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
SET_MODULE_OWNER ( pnetdev ) ;
# endif
2014-12-19 06:59:46 +00:00
2015-02-20 04:11:26 +00:00
/* pnetdev->init = NULL; */
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
# if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29))
2015-08-15 21:38:30 +00:00
DBG_88E ( " register rtw_netdev_ops to netdev_ops \n " ) ;
2013-05-08 21:45:39 +00:00
pnetdev - > netdev_ops = & rtw_netdev_ops ;
2014-12-17 01:03:30 +00:00
# else
pnetdev - > open = netdev_open ;
2014-12-19 06:59:46 +00:00
pnetdev - > stop = netdev_close ;
2014-12-17 01:03:30 +00:00
pnetdev - > hard_start_xmit = rtw_xmit_entry ;
pnetdev - > set_mac_address = rtw_net_set_mac_address ;
pnetdev - > get_stats = rtw_net_get_stats ;
pnetdev - > do_ioctl = rtw_ioctl ;
# endif
2013-05-08 21:45:39 +00:00
pnetdev - > watchdog_timeo = HZ * 3 ; /* 3 second timeout */
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_WIRELESS_EXT
2013-05-08 21:45:39 +00:00
pnetdev - > wireless_handlers = ( struct iw_handler_def * ) & rtw_handlers_def ;
2014-12-17 01:03:30 +00:00
# endif
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* step 2. */
2014-12-19 06:59:46 +00:00
loadparam ( padapter , pnetdev ) ;
2013-05-08 21:45:39 +00:00
return pnetdev ;
}
2014-12-17 23:13:53 +00:00
u32 rtw_start_drv_threads ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
u32 _status = _SUCCESS ;
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " +rtw_start_drv_threads \n " ) ) ;
2013-05-08 21:45:39 +00:00
2015-02-15 20:31:30 +00:00
padapter - > cmdThread = kthread_run ( rtw_cmd_thread , padapter , " RTW_CMD_THREAD " ) ;
2015-08-15 18:02:34 +00:00
if ( IS_ERR ( padapter - > cmdThread ) )
2015-02-15 20:31:30 +00:00
_status = _FAIL ;
else
2015-02-20 04:11:26 +00:00
_rtw_down_sema ( & padapter - > cmdpriv . terminate_cmdthread_sema ) ; /* wait for cmd_thread to run */
2014-12-17 01:03:30 +00:00
rtw_hal_start_thread ( padapter ) ;
return _status ;
}
void rtw_unregister_netdevs ( struct dvobj_priv * dvobj )
{
int i ;
2014-12-17 23:13:53 +00:00
struct adapter * padapter = NULL ;
2018-05-05 19:08:13 +00:00
struct net_device * pnetdev = NULL ;
2014-12-17 01:03:30 +00:00
2018-05-05 19:08:13 +00:00
if ( ! dvobj | | dvobj - > iface_nums = = 0 )
return ;
2014-12-19 06:59:46 +00:00
2018-05-05 19:08:13 +00:00
for ( i = 0 ; i < dvobj - > iface_nums ; i + + ) {
2014-12-17 01:03:30 +00:00
padapter = dvobj - > padapters [ i ] ;
if ( padapter = = NULL )
continue ;
pnetdev = padapter - > pnetdev ;
2018-05-05 19:08:13 +00:00
if ( ! pnetdev )
continue ;
2014-12-17 01:03:30 +00:00
2018-05-05 19:08:13 +00:00
if ( padapter - > DriverState ! = DRIVER_DISAPPEAR ) {
struct wireless_dev * wdev = padapter - > rtw_wdev ;
2014-12-19 06:59:46 +00:00
2018-05-05 19:08:13 +00:00
wdev - > current_bss = NULL ;
pnetdev - > reg_state = NETREG_REGISTERED ;
2015-02-20 04:11:26 +00:00
unregister_netdev ( pnetdev ) ; /* will call netdev_close() */
2014-12-17 01:03:30 +00:00
rtw_proc_remove_one ( pnetdev ) ;
}
2018-05-05 19:08:13 +00:00
if ( padapter - > rtw_wdev )
rtw_wdev_unregister ( padapter - > rtw_wdev ) ;
2014-12-17 01:03:30 +00:00
}
2014-12-19 06:59:46 +00:00
}
2014-12-17 01:03:30 +00:00
2014-12-17 23:13:53 +00:00
void rtw_stop_drv_threads ( struct adapter * padapter )
2014-12-17 01:03:30 +00:00
{
2014-12-19 06:59:46 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " +rtw_stop_drv_threads \n " ) ) ;
2014-12-17 01:03:30 +00:00
2015-02-15 20:31:30 +00:00
rtw_stop_cmd_thread ( padapter ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
rtw_hal_stop_thread ( padapter ) ;
}
2015-08-15 00:40:02 +00:00
static u8 rtw_init_default_value ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
u8 ret = _SUCCESS ;
2014-12-17 01:03:30 +00:00
struct registry_priv * pregistrypriv = & padapter - > registrypriv ;
2013-05-08 21:45:39 +00:00
struct xmit_priv * pxmitpriv = & padapter - > xmitpriv ;
2014-12-17 01:03:30 +00:00
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
2013-05-08 21:45:39 +00:00
struct security_priv * psecuritypriv = & padapter - > securitypriv ;
2015-02-20 04:11:26 +00:00
/* xmit_priv */
2013-05-08 21:45:39 +00:00
pxmitpriv - > vcs_setting = pregistrypriv - > vrtl_carrier_sense ;
pxmitpriv - > vcs = pregistrypriv - > vcs_type ;
pxmitpriv - > vcs_type = pregistrypriv - > vcs_type ;
2015-02-20 04:11:26 +00:00
/* pxmitpriv->rts_thresh = pregistrypriv->rts_thresh; */
2013-05-08 21:45:39 +00:00
pxmitpriv - > frag_len = pregistrypriv - > frag_thresh ;
2014-12-19 06:59:46 +00:00
2013-05-19 04:28:07 +00:00
2015-02-20 04:11:26 +00:00
/* recv_priv */
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
2015-02-20 04:11:26 +00:00
/* mlme_priv */
pmlmepriv - > scan_interval = SCAN_INTERVAL ; /* 30*2 sec = 60sec */
2013-05-08 21:45:39 +00:00
pmlmepriv - > scan_mode = SCAN_ACTIVE ;
2015-02-20 04:11:26 +00:00
/* qos_priv */
/* pmlmepriv->qospriv.qos_option = pregistrypriv->wmm_enable; */
2014-12-19 06:59:46 +00:00
2015-02-20 04:11:26 +00:00
/* ht_priv */
pmlmepriv - > htpriv . ampdu_enable = false ; /* set to disabled */
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* security_priv */
/* rtw_get_encrypt_decrypt_from_registrypriv(padapter); */
2013-05-08 21:45:39 +00:00
psecuritypriv - > binstallGrpkey = _FAIL ;
2014-12-17 01:03:30 +00:00
psecuritypriv - > sw_encrypt = pregistrypriv - > software_encrypt ;
psecuritypriv - > sw_decrypt = pregistrypriv - > software_decrypt ;
2014-12-19 06:59:46 +00:00
2015-02-20 04:11:26 +00:00
psecuritypriv - > dot11AuthAlgrthm = dot11AuthAlgrthm_Open ; /* open system */
2013-05-08 21:45:39 +00:00
psecuritypriv - > dot11PrivacyAlgrthm = _NO_PRIVACY_ ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
psecuritypriv - > dot11PrivacyKeyIndex = 0 ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
psecuritypriv - > dot118021XGrpPrivacy = _NO_PRIVACY_ ;
psecuritypriv - > dot118021XGrpKeyid = 1 ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
psecuritypriv - > ndisauthtype = Ndis802_11AuthModeOpen ;
psecuritypriv - > ndisencryptstatus = Ndis802_11WEPDisabled ;
2014-12-19 06:59:46 +00:00
2013-05-19 04:28:07 +00:00
2015-02-20 04:11:26 +00:00
/* pwrctrl_priv */
2014-12-17 01:03:30 +00:00
2015-02-20 04:11:26 +00:00
/* registry_priv */
2014-12-19 06:59:46 +00:00
rtw_init_registrypriv_dev_network ( padapter ) ;
2013-05-08 21:45:39 +00:00
rtw_update_registrypriv_dev_network ( padapter ) ;
2014-12-17 01:03:30 +00:00
2015-02-20 04:11:26 +00:00
/* hal_priv */
2013-05-08 21:45:39 +00:00
rtw_hal_def_value_init ( padapter ) ;
2015-02-20 04:11:26 +00:00
/* misc. */
2014-12-29 02:13:24 +00:00
padapter - > bReadPortCancel = false ;
padapter - > bWritePortCancel = false ;
2013-05-08 21:45:39 +00:00
padapter - > bRxRSSIDisplay = 0 ;
padapter - > bNotifyChannelChange = 0 ;
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_P2P
2013-05-08 21:45:39 +00:00
padapter - > bShowGetP2PState = 1 ;
# endif
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
}
2014-12-17 23:13:53 +00:00
u8 rtw_reset_drv_sw ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2014-12-19 06:59:46 +00:00
u8 ret8 = _SUCCESS ;
2014-12-17 01:03:30 +00:00
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
struct pwrctrl_priv * pwrctrlpriv = adapter_to_pwrctl ( padapter ) ;
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* hal_priv */
2013-05-08 21:45:39 +00:00
rtw_hal_def_value_init ( padapter ) ;
2014-12-29 02:13:24 +00:00
padapter - > bReadPortCancel = false ;
padapter - > bWritePortCancel = false ;
2013-05-08 21:45:39 +00:00
padapter - > bRxRSSIDisplay = 0 ;
2015-02-20 04:11:26 +00:00
pmlmepriv - > scan_interval = SCAN_INTERVAL ; /* 30*2 sec = 60sec */
2013-05-08 21:45:39 +00:00
padapter - > xmitpriv . tx_pkts = 0 ;
padapter - > recvpriv . rx_pkts = 0 ;
2014-12-29 02:13:24 +00:00
pmlmepriv - > LinkDetectInfo . bBusyTraffic = false ;
2014-12-17 01:03:30 +00:00
_clr_fwstate_ ( pmlmepriv , _FW_UNDER_SURVEY | _FW_UNDER_LINKING ) ;
2013-05-08 21:45:39 +00:00
2014-12-19 06:59:46 +00:00
# ifdef CONFIG_AUTOSUSPEND
2014-12-17 01:03:30 +00:00
# if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,22) && LINUX_VERSION_CODE<=KERNEL_VERSION(2,6,34))
2015-02-20 04:11:26 +00:00
adapter_to_dvobj ( padapter ) - > pusbdev - > autosuspend_disabled = 1 ; /* autosuspend disabled by the user */
2014-12-17 01:03:30 +00:00
# endif
# endif
2013-05-08 21:45:39 +00:00
rtw_hal_sreset_reset_value ( padapter ) ;
pwrctrlpriv - > pwr_state_check_cnts = 0 ;
2015-02-20 04:11:26 +00:00
/* mlmeextpriv */
2014-12-17 01:03:30 +00:00
padapter - > mlmeextpriv . sitesurvey_res . state = SCAN_DISABLE ;
2013-05-08 21:45:39 +00:00
rtw_set_signal_stat_timer ( & padapter - > recvpriv ) ;
return ret8 ;
}
2014-12-17 23:13:53 +00:00
u8 rtw_init_drv_sw ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2014-12-17 01:03:30 +00:00
u8 ret8 = _SUCCESS ;
2013-05-08 21:45:39 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-19 04:28:07 +00:00
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " +rtw_init_drv_sw \n " ) ) ;
2013-05-19 04:28:07 +00:00
2014-12-17 01:03:30 +00:00
if ( ( rtw_init_cmd_priv ( & padapter - > cmdpriv ) ) = = _FAIL )
{
RT_TRACE ( _module_os_intfs_c_ , _drv_err_ , ( " \n Can't init cmd_priv \n " ) ) ;
ret8 = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
padapter - > cmdpriv . padapter = padapter ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
if ( ( rtw_init_evt_priv ( & padapter - > evtpriv ) ) = = _FAIL )
{
RT_TRACE ( _module_os_intfs_c_ , _drv_err_ , ( " \n Can't init evt_priv \n " ) ) ;
ret8 = _FAIL ;
goto exit ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
if ( rtw_init_mlme_priv ( padapter ) = = _FAIL )
{
RT_TRACE ( _module_os_intfs_c_ , _drv_err_ , ( " \n Can't init mlme_priv \n " ) ) ;
ret8 = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_P2P
2013-05-08 21:45:39 +00:00
rtw_init_wifidirect_timers ( padapter ) ;
init_wifidirect_info ( padapter , P2P_ROLE_DISABLE ) ;
reset_global_wifidirect_info ( padapter ) ;
2014-12-17 01:03:30 +00:00
rtw_init_cfg80211_wifidirect_info ( padapter ) ;
2015-03-02 04:48:40 +00:00
# ifdef CONFIG_P2P
2015-08-15 18:02:34 +00:00
if ( rtw_init_wifi_display_info ( padapter ) = = _FAIL )
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_err_ , ( " \n Can't init init_wifi_display_info \n " ) ) ;
# endif
# endif /* CONFIG_P2P */
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( init_mlme_ext_priv ( padapter ) = = _FAIL )
2014-12-17 01:03:30 +00:00
{
RT_TRACE ( _module_os_intfs_c_ , _drv_err_ , ( " \n Can't init mlme_ext_priv \n " ) ) ;
ret8 = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-08-15 18:02:34 +00:00
if ( _rtw_init_xmit_priv ( & padapter - > xmitpriv , padapter ) = = _FAIL )
2014-12-17 01:03:30 +00:00
{
2015-08-15 21:38:30 +00:00
DBG_88E ( " Can't _rtw_init_xmit_priv \n " ) ;
2014-12-17 01:03:30 +00:00
ret8 = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( _rtw_init_recv_priv ( & padapter - > recvpriv , padapter ) = = _FAIL )
2014-12-17 01:03:30 +00:00
{
2015-08-15 21:38:30 +00:00
DBG_88E ( " Can't _rtw_init_recv_priv \n " ) ;
2014-12-17 01:03:30 +00:00
ret8 = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-02-20 04:11:26 +00:00
/* add for CONFIG_IEEE80211W, none 11w also can use */
2015-03-05 20:42:30 +00:00
spin_lock_init ( & padapter - > security_key_mutex ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( _rtw_init_sta_priv ( & padapter - > stapriv ) = = _FAIL )
2014-12-17 01:03:30 +00:00
{
2015-08-15 21:38:30 +00:00
DBG_88E ( " Can't _rtw_init_sta_priv \n " ) ;
2014-12-17 01:03:30 +00:00
ret8 = _FAIL ;
goto exit ;
}
2014-12-19 06:59:46 +00:00
padapter - > stapriv . padapter = padapter ;
padapter - > setband = GHZ24_50 ;
2014-12-17 01:03:30 +00:00
padapter - > fix_rate = 0xFF ;
2013-05-08 21:45:39 +00:00
rtw_init_bcmc_stainfo ( padapter ) ;
2014-12-19 06:59:46 +00:00
rtw_init_pwrctrl_priv ( padapter ) ;
2013-05-08 21:45:39 +00:00
ret8 = rtw_init_default_value ( padapter ) ;
rtw_hal_dm_init ( padapter ) ;
rtw_hal_sw_led_init ( padapter ) ;
rtw_hal_sreset_init ( padapter ) ;
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_BR_EXT
2015-03-05 20:42:30 +00:00
spin_lock_init ( & padapter - > br_ext_lock ) ;
2015-02-20 04:11:26 +00:00
# endif /* CONFIG_BR_EXT */
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
exit :
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " -rtw_init_drv_sw \n " ) ) ;
2013-05-08 21:45:39 +00:00
return ret8 ;
2014-12-17 01:03:30 +00:00
}
2014-12-17 23:13:53 +00:00
void rtw_cancel_all_timer ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2015-09-15 01:41:35 +00:00
struct wifidirect_info * pwdinfo = & padapter - > wdinfo ;
struct mlme_ext_priv * pmlmeext = & padapter - > mlmeextpriv ;
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " +rtw_cancel_all_timer \n " ) ) ;
2013-05-08 21:45:39 +00:00
_cancel_timer_ex ( & padapter - > mlmepriv . assoc_timer ) ;
2015-08-15 18:00:19 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " rtw_cancel_all_timer:cancel association timer complete! \n " ) ) ;
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
_cancel_timer_ex ( & padapter - > mlmepriv . scan_to_timer ) ;
2015-08-15 18:00:19 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " rtw_cancel_all_timer:cancel scan_to_timer! \n " ) ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
_cancel_timer_ex ( & padapter - > mlmepriv . dynamic_chk_timer ) ;
2015-08-15 18:00:19 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " rtw_cancel_all_timer:cancel dynamic_chk_timer! \n " ) ) ;
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* cancel sw led timer */
2013-05-08 21:45:39 +00:00
rtw_hal_sw_led_deinit ( padapter ) ;
2015-08-15 18:00:19 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " rtw_cancel_all_timer:cancel DeInitSwLeds! \n " ) ) ;
2014-12-17 01:03:30 +00:00
2018-08-30 18:19:58 +00:00
_cancel_timer_ex ( & adapter_to_pwrctl ( padapter ) - > pwr_state_check_timer ) ;
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_P2P
_cancel_timer_ex ( & padapter - > cfg80211_wdinfo . remain_on_ch_timer ) ;
2015-02-20 04:11:26 +00:00
# endif /* CONFIG_P2P */
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
_cancel_timer_ex ( & padapter - > mlmepriv . set_scan_deny_timer ) ;
rtw_clear_scan_deny ( padapter ) ;
2015-08-15 18:00:19 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " rtw_cancel_all_timer:cancel set_scan_deny_timer! \n " ) ) ;
2013-05-08 21:45:39 +00:00
_cancel_timer_ex ( & padapter - > recvpriv . signal_stat_timer ) ;
2014-12-17 01:03:30 +00:00
# if defined(CONFIG_CHECK_BT_HANG) && defined(CONFIG_BT_COEXIST)
if ( padapter - > HalFunc . hal_cancel_checkbthang_workqueue )
padapter - > HalFunc . hal_cancel_checkbthang_workqueue ( padapter ) ;
2015-09-15 01:41:35 +00:00
# endif
_cancel_timer_ex ( & pwdinfo - > find_phase_timer ) ;
_cancel_timer_ex ( & pwdinfo - > restore_p2p_state_timer ) ;
_cancel_timer_ex ( & pwdinfo - > pre_tx_scan_timer ) ;
_cancel_timer_ex ( & pwdinfo - > reset_ch_sitesurvey ) ;
_cancel_timer_ex ( & pmlmeext - > survey_timer ) ;
_cancel_timer_ex ( & pmlmeext - > link_timer ) ;
# ifdef CONFIG_IEEE80211W
_cancel_timer_ex ( & pmlmeext - > sa_query_timer ) ;
2014-12-19 06:59:46 +00:00
# endif
2015-02-20 04:11:26 +00:00
/* cancel dm timer */
2014-12-19 06:59:46 +00:00
rtw_hal_dm_deinit ( padapter ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
u8 rtw_free_drv_sw ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2014-12-17 01:03:30 +00:00
struct net_device * pnetdev = ( struct net_device * ) padapter - > pnetdev ;
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " ==>rtw_free_drv_sw " ) ) ;
2015-02-20 04:11:26 +00:00
/* we can call rtw_p2p_enable here, but: */
/* 1. rtw_p2p_enable may have IO operation */
/* 2. rtw_p2p_enable is bundled with wext interface */
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_P2P
2013-05-08 21:45:39 +00:00
{
struct wifidirect_info * pwdinfo = & padapter - > wdinfo ;
2015-08-15 18:02:34 +00:00
if ( ! rtw_p2p_chk_state ( pwdinfo , P2P_STATE_NONE ) )
2014-12-17 01:03:30 +00:00
{
_cancel_timer_ex ( & pwdinfo - > find_phase_timer ) ;
_cancel_timer_ex ( & pwdinfo - > restore_p2p_state_timer ) ;
_cancel_timer_ex ( & pwdinfo - > pre_tx_scan_timer ) ;
2013-05-08 21:45:39 +00:00
rtw_p2p_set_state ( pwdinfo , P2P_STATE_NONE ) ;
}
}
# endif
2015-02-20 04:11:26 +00:00
/* add for CONFIG_IEEE80211W, none 11w also can use */
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
free_mlme_ext_priv ( & padapter - > mlmeextpriv ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
rtw_free_cmd_priv ( & padapter - > cmdpriv ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
rtw_free_evt_priv ( & padapter - > evtpriv ) ;
rtw_free_mlme_priv ( & padapter - > mlmepriv ) ;
2014-12-19 06:59:46 +00:00
# if defined(CONFIG_CHECK_BT_HANG) && defined(CONFIG_BT_COEXIST)
2014-12-17 01:03:30 +00:00
if ( padapter - > HalFunc . hal_free_checkbthang_workqueue )
padapter - > HalFunc . hal_free_checkbthang_workqueue ( padapter ) ;
2014-12-19 06:59:46 +00:00
# endif
2015-02-20 04:11:26 +00:00
/* free_io_queue(padapter); */
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
_rtw_free_xmit_priv ( & padapter - > xmitpriv ) ;
2014-12-19 06:59:46 +00:00
2015-02-20 04:11:26 +00:00
_rtw_free_sta_priv ( & padapter - > stapriv ) ; /* will free bcmc_stainfo here */
2014-12-19 06:59:46 +00:00
_rtw_free_recv_priv ( & padapter - > recvpriv ) ;
2013-05-19 04:28:07 +00:00
2014-12-17 01:03:30 +00:00
rtw_free_pwrctrl_priv ( padapter ) ;
2013-05-19 04:28:07 +00:00
2015-02-20 04:11:26 +00:00
/* rtw_mfree((void *)padapter, sizeof (padapter)); */
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_DRVEXT_MODULE
free_drvext ( & padapter - > drvextpriv ) ;
# endif
2013-05-08 21:45:39 +00:00
rtw_hal_free_data ( padapter ) ;
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " <==rtw_free_drv_sw \n " ) ) ;
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* free the old_pnetdev */
2015-08-15 18:02:34 +00:00
if ( padapter - > rereg_nd_name_priv . old_pnetdev ) {
2013-05-08 21:45:39 +00:00
free_netdev ( padapter - > rereg_nd_name_priv . old_pnetdev ) ;
padapter - > rereg_nd_name_priv . old_pnetdev = NULL ;
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* clear pbuddy_adapter to avoid access wrong pointer. */
2015-08-15 18:02:34 +00:00
if ( padapter - > pbuddy_adapter ! = NULL ) {
2013-05-08 21:45:39 +00:00
padapter - > pbuddy_adapter - > pbuddy_adapter = NULL ;
2014-12-17 01:03:30 +00:00
}
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " -rtw_free_drv_sw \n " ) ) ;
2013-05-08 21:45:39 +00:00
return _SUCCESS ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_BR_EXT
void netdev_br_init ( struct net_device * netdev )
{
2014-12-17 23:13:53 +00:00
struct adapter * adapter = ( struct adapter * ) rtw_netdev_priv ( netdev ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
# if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35))
rcu_read_lock ( ) ;
2015-02-20 04:11:26 +00:00
# endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35)) */
2014-12-17 01:03:30 +00:00
2015-08-15 18:02:34 +00:00
/* if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) == true) */
2014-12-17 01:03:30 +00:00
{
2015-02-20 04:11:26 +00:00
/* struct net_bridge *br = netdev->br_port->br;->dev->dev_addr; */
2014-12-17 01:03:30 +00:00
# if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
2014-12-19 06:59:46 +00:00
if ( netdev - > br_port )
2015-02-20 04:11:26 +00:00
# else /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
2014-12-17 01:03:30 +00:00
if ( rcu_dereference ( adapter - > pnetdev - > rx_handler_data ) )
2015-02-20 04:11:26 +00:00
# endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
2014-12-17 01:03:30 +00:00
{
struct net_device * br_netdev ;
# if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
br_netdev = dev_get_by_name ( CONFIG_BR_EXT_BRNAME ) ;
2015-02-20 04:11:26 +00:00
# else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */
2014-12-17 01:03:30 +00:00
struct net * devnet = NULL ;
# if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
devnet = netdev - > nd_net ;
2015-02-20 04:11:26 +00:00
# else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */
2014-12-17 01:03:30 +00:00
devnet = dev_net ( netdev ) ;
2015-02-20 04:11:26 +00:00
# endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */
2014-12-17 01:03:30 +00:00
br_netdev = dev_get_by_name ( devnet , CONFIG_BR_EXT_BRNAME ) ;
2015-02-20 04:11:26 +00:00
# endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */
2014-12-17 01:03:30 +00:00
if ( br_netdev ) {
memcpy ( adapter - > br_mac , br_netdev - > dev_addr , ETH_ALEN ) ;
dev_put ( br_netdev ) ;
} else
2015-08-15 21:38:30 +00:00
DBG_88E ( " %s()-%d: dev_get_by_name(%s) failed! " , __FUNCTION__ , __LINE__ , CONFIG_BR_EXT_BRNAME ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
adapter - > ethBrExtInfo . addPPPoETag = 1 ;
2013-05-08 21:45:39 +00:00
}
2014-12-17 01:03:30 +00:00
# if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35))
2013-05-08 21:45:39 +00:00
rcu_read_unlock ( ) ;
2015-02-20 04:11:26 +00:00
# endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35)) */
2014-12-17 01:03:30 +00:00
}
2015-02-20 04:11:26 +00:00
# endif /* CONFIG_BR_EXT */
2014-12-17 01:03:30 +00:00
2014-12-17 23:13:53 +00:00
static int _rtw_drv_register_netdev ( struct adapter * padapter , char * name )
2014-12-17 01:03:30 +00:00
{
int ret = _SUCCESS ;
struct net_device * pnetdev = padapter - > pnetdev ;
/* alloc netdev name */
rtw_init_netdev_name ( pnetdev , name ) ;
2015-02-19 20:50:04 +00:00
memcpy ( pnetdev - > dev_addr , padapter - > eeprompriv . mac_addr , ETH_ALEN ) ;
2014-12-17 01:03:30 +00:00
/* Tell the network stack we exist */
if ( register_netdev ( pnetdev ) ! = 0 ) {
2015-08-15 21:38:30 +00:00
DBG_88E ( FUNC_NDEV_FMT " Failed! \n " , FUNC_NDEV_ARG ( pnetdev ) ) ;
2014-12-17 01:03:30 +00:00
ret = _FAIL ;
goto error_register_netdev ;
}
2015-08-15 21:38:30 +00:00
DBG_88E ( " %s, MAC Address (if%d) = " MAC_FMT " \n " , __FUNCTION__ , ( padapter - > iface_id + 1 ) , MAC_ARG ( pnetdev - > dev_addr ) ) ;
2014-12-17 01:03:30 +00:00
return ret ;
error_register_netdev :
2015-08-15 18:02:34 +00:00
if ( padapter - > iface_id > IFACE_ID0 )
2014-12-17 01:03:30 +00:00
{
rtw_free_drv_sw ( padapter ) ;
rtw_free_netdev ( pnetdev ) ;
}
return ret ;
}
2014-12-17 23:13:53 +00:00
int rtw_drv_register_netdev ( struct adapter * if1 )
2014-12-17 01:03:30 +00:00
{
int i , status = _SUCCESS ;
struct dvobj_priv * dvobj = if1 - > dvobj ;
2015-08-15 18:02:34 +00:00
if ( dvobj - > iface_nums < IFACE_ID_MAX )
2014-12-17 01:03:30 +00:00
{
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < dvobj - > iface_nums ; i + + )
2014-12-17 01:03:30 +00:00
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter = dvobj - > padapters [ i ] ;
2014-12-17 01:03:30 +00:00
2015-08-15 18:02:34 +00:00
if ( padapter )
2014-12-17 01:03:30 +00:00
{
char * name ;
2015-08-15 18:02:34 +00:00
if ( padapter - > iface_id = = IFACE_ID0 )
2014-12-17 01:03:30 +00:00
name = if1 - > registrypriv . ifname ;
else
name = " wlan%d " ;
2015-08-15 18:02:34 +00:00
if ( ( status = _rtw_drv_register_netdev ( padapter , name ) ) ! = _SUCCESS ) {
2014-12-17 01:03:30 +00:00
break ;
}
}
}
}
return status ;
2013-05-08 21:45:39 +00:00
}
int _netdev_open ( struct net_device * pnetdev )
{
2014-12-19 06:59:46 +00:00
uint status ;
2014-12-17 23:13:53 +00:00
struct adapter * padapter = ( struct adapter * ) rtw_netdev_priv ( pnetdev ) ;
2014-12-17 01:03:30 +00:00
struct pwrctrl_priv * pwrctrlpriv = adapter_to_pwrctl ( padapter ) ;
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " +871x_drv - dev_open \n " ) ) ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " +871x_drv - drv_open, bup=%d \n " , padapter - > bup ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:24:16 +00:00
if ( pwrctrlpriv - > ps_flag = = true ) {
2014-12-29 02:13:24 +00:00
padapter - > net_closed = false ;
2013-05-08 21:45:39 +00:00
goto netdev_open_normal_process ;
}
2015-08-15 18:02:34 +00:00
if ( padapter - > bup = = false )
2014-12-17 01:03:30 +00:00
{
2014-12-29 02:13:24 +00:00
padapter - > bDriverStopped = false ;
padapter - > bSurpriseRemoved = false ;
padapter - > bCardDisableWOHSM = false ;
2013-05-08 21:45:39 +00:00
status = rtw_hal_init ( padapter ) ;
2014-12-17 01:03:30 +00:00
if ( status = = _FAIL )
2014-12-19 06:59:46 +00:00
{
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_err_ , ( " rtl871x_hal_init(): Can't init h/w! \n " ) ) ;
2013-05-08 21:45:39 +00:00
goto netdev_open_error ;
}
2014-12-19 06:59:46 +00:00
2015-08-15 21:38:30 +00:00
DBG_88E ( " MAC Address = " MAC_FMT " \n " , MAC_ARG ( pnetdev - > dev_addr ) ) ;
2014-12-17 01:03:30 +00:00
status = rtw_start_drv_threads ( padapter ) ;
2015-08-15 18:02:34 +00:00
if ( status = = _FAIL )
2014-12-19 06:59:46 +00:00
{
2015-08-15 21:38:30 +00:00
DBG_88E ( " Initialize driver software resource Failed! \n " ) ;
2014-12-19 06:59:46 +00:00
goto netdev_open_error ;
2014-12-17 01:03:30 +00:00
}
2013-05-19 04:28:07 +00:00
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_DRVEXT_MODULE
init_drvext ( padapter ) ;
# endif
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( padapter - > intf_start )
2014-12-17 01:03:30 +00:00
{
padapter - > intf_start ( padapter ) ;
2013-05-08 21:45:39 +00:00
}
rtw_proc_init_one ( pnetdev ) ;
2014-12-17 01:03:30 +00:00
rtw_cfg80211_init_wiphy ( padapter ) ;
2013-05-08 21:45:39 +00:00
rtw_led_control ( padapter , LED_CTL_NO_LINK ) ;
2014-12-29 02:13:24 +00:00
padapter - > bup = true ;
2014-12-19 06:59:46 +00:00
2014-12-29 02:13:24 +00:00
pwrctrlpriv - > bips_processing = false ;
2013-05-08 21:45:39 +00:00
}
2014-12-29 02:13:24 +00:00
padapter - > net_closed = false ;
2013-05-08 21:45:39 +00:00
_set_timer ( & padapter - > mlmepriv . dynamic_chk_timer , 2000 ) ;
2014-12-17 01:03:30 +00:00
rtw_set_pwr_state_check_timer ( pwrctrlpriv ) ;
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* netif_carrier_on(pnetdev);call this func when rtw_joinbss_event_callback return success */
2015-08-15 18:02:34 +00:00
if ( ! rtw_netif_queue_stopped ( pnetdev ) )
2013-05-08 21:45:39 +00:00
rtw_netif_start_queue ( pnetdev ) ;
else
rtw_netif_wake_queue ( pnetdev ) ;
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_BR_EXT
2013-05-08 21:45:39 +00:00
netdev_br_init ( pnetdev ) ;
2015-02-20 04:11:26 +00:00
# endif /* CONFIG_BR_EXT */
2013-05-08 21:45:39 +00:00
netdev_open_normal_process :
2013-05-19 04:28:07 +00:00
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " -871x_drv - dev_open \n " ) ) ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " -871x_drv - drv_open, bup=%d \n " , padapter - > bup ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
return 0 ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
netdev_open_error :
2014-12-17 01:03:30 +00:00
2014-12-29 02:13:24 +00:00
padapter - > bup = false ;
2014-12-19 06:59:46 +00:00
netif_carrier_off ( pnetdev ) ;
2013-05-08 21:45:39 +00:00
rtw_netif_stop_queue ( pnetdev ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_err_ , ( " -871x_drv - dev_open, fail! \n " ) ) ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " -871x_drv - drv_open fail, bup=%d \n " , padapter - > bup ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
return ( - 1 ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
int netdev_open ( struct net_device * pnetdev )
{
int ret ;
2014-12-17 23:13:53 +00:00
struct adapter * padapter = ( struct adapter * ) rtw_netdev_priv ( pnetdev ) ;
2014-12-19 06:59:46 +00:00
2018-08-30 18:19:58 +00:00
_enter_critical_mutex ( & adapter_to_dvobj ( padapter ) - > hw_init_mutex , NULL ) ;
2013-05-08 21:45:39 +00:00
ret = _netdev_open ( pnetdev ) ;
2018-08-30 18:19:58 +00:00
_exit_critical_mutex ( & adapter_to_dvobj ( padapter ) - > hw_init_mutex , NULL ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
}
2014-12-19 04:28:04 +00:00
static int ips_netdrv_open ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
int status = _SUCCESS ;
2014-12-29 02:13:24 +00:00
padapter - > net_closed = false ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " ===> %s......... \n " , __FUNCTION__ ) ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
padapter - > bDriverStopped = false ;
padapter - > bCardDisableWOHSM = false ;
2015-02-20 04:11:26 +00:00
/* padapter->bup = true; */
2013-05-08 21:45:39 +00:00
status = rtw_hal_init ( padapter ) ;
2015-03-02 17:34:17 +00:00
if ( status = = _FAIL ) {
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_err_ , ( " ips_netdrv_open(): Can't init h/w! \n " ) ) ;
2013-05-08 21:45:39 +00:00
goto netdev_open_error ;
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( padapter - > intf_start )
2013-05-08 21:45:39 +00:00
padapter - > intf_start ( padapter ) ;
2014-12-17 01:03:30 +00:00
rtw_set_pwr_state_check_timer ( adapter_to_pwrctl ( padapter ) ) ;
2014-12-19 06:59:46 +00:00
_set_timer ( & padapter - > mlmepriv . dynamic_chk_timer , 5000 ) ;
2013-05-08 21:45:39 +00:00
2015-03-10 16:18:03 +00:00
return _SUCCESS ;
2013-05-08 21:45:39 +00:00
netdev_open_error :
2015-02-20 04:11:26 +00:00
/* padapter->bup = false; */
2015-08-15 21:38:30 +00:00
DBG_88E ( " -ips_netdrv_open - drv_open failure, bup=%d \n " , padapter - > bup ) ;
2013-05-08 21:45:39 +00:00
return _FAIL ;
}
2014-12-17 01:03:30 +00:00
2014-12-17 23:13:53 +00:00
int rtw_ips_pwr_up ( struct adapter * padapter )
2014-12-19 06:59:46 +00:00
{
2013-05-08 21:45:39 +00:00
int result ;
2015-08-15 21:34:17 +00:00
u32 start_time = jiffies ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " ===> rtw_ips_pwr_up.............. \n " ) ;
2013-05-08 21:45:39 +00:00
rtw_reset_drv_sw ( padapter ) ;
result = ips_netdrv_open ( padapter ) ;
rtw_led_control ( padapter , LED_CTL_NO_LINK ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 21:38:30 +00:00
DBG_88E ( " <=== rtw_ips_pwr_up.............. in %dms \n " , rtw_get_passing_time_ms ( start_time ) ) ;
2013-05-08 21:45:39 +00:00
return result ;
2014-12-17 01:03:30 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
void rtw_ips_pwr_down ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2015-08-15 21:34:17 +00:00
u32 start_time = jiffies ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " ===> rtw_ips_pwr_down................... \n " ) ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
padapter - > bCardDisableWOHSM = true ;
padapter - > net_closed = true ;
2013-05-08 21:45:39 +00:00
rtw_led_control ( padapter , LED_CTL_POWER_OFF ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
rtw_ips_dev_unload ( padapter ) ;
2014-12-29 02:13:24 +00:00
padapter - > bCardDisableWOHSM = false ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " <=== rtw_ips_pwr_down..................... in %dms \n " , rtw_get_passing_time_ms ( start_time ) ) ;
2013-05-08 21:45:39 +00:00
}
2015-02-24 16:18:56 +00:00
2014-12-17 23:13:53 +00:00
void rtw_ips_dev_unload ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2014-12-17 01:03:30 +00:00
struct net_device * pnetdev = ( struct net_device * ) padapter - > pnetdev ;
2018-08-30 18:19:58 +00:00
struct xmit_priv * pxmitpriv = & padapter - > xmitpriv ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " ====> %s... \n " , __FUNCTION__ ) ;
2013-05-08 21:45:39 +00:00
2014-12-19 04:28:04 +00:00
rtw_hal_set_hwreg ( padapter , HW_VAR_FIFO_CLEARN_UP , NULL ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( padapter - > intf_stop )
2014-12-17 01:03:30 +00:00
{
2013-05-08 21:45:39 +00:00
padapter - > intf_stop ( padapter ) ;
2014-12-17 01:03:30 +00:00
}
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* s5. */
2015-08-15 18:02:34 +00:00
if ( padapter - > bSurpriseRemoved = = false )
2014-12-17 01:03:30 +00:00
{
2013-05-08 21:45:39 +00:00
rtw_hal_deinit ( padapter ) ;
2014-12-17 01:03:30 +00:00
}
2013-05-08 21:45:39 +00:00
}
2014-12-17 01:03:30 +00:00
int pm_netdev_open ( struct net_device * pnetdev , u8 bnormal )
2013-05-08 21:45:39 +00:00
{
int status ;
2014-12-17 01:03:30 +00:00
2014-12-29 02:13:24 +00:00
if ( true = = bnormal )
2013-05-08 21:45:39 +00:00
status = netdev_open ( pnetdev ) ;
else
2014-12-17 23:13:53 +00:00
status = ( _SUCCESS = = ips_netdrv_open ( ( struct adapter * ) rtw_netdev_priv ( pnetdev ) ) ) ? ( 0 ) : ( - 1 ) ;
2013-05-08 21:45:39 +00:00
return status ;
}
2014-12-17 01:03:30 +00:00
static int netdev_close ( struct net_device * pnetdev )
2013-05-08 21:45:39 +00:00
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter = ( struct adapter * ) rtw_netdev_priv ( pnetdev ) ;
2015-03-13 02:01:49 +00:00
struct dvobj_priv * dvobj = adapter_to_dvobj ( padapter ) ;
2013-05-08 21:45:39 +00:00
2014-12-19 06:59:46 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " +871x_drv - drv_close \n " ) ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( adapter_to_pwrctl ( padapter ) - > bInternalAutoSuspend = = true )
2014-12-17 01:03:30 +00:00
{
2015-02-20 04:11:26 +00:00
/* rtw_pwr_wakeup(padapter); */
2015-08-15 18:02:34 +00:00
if ( adapter_to_pwrctl ( padapter ) - > rf_pwrstate = = rf_off )
2014-12-29 02:13:24 +00:00
adapter_to_pwrctl ( padapter ) - > ps_flag = true ;
2013-05-08 21:45:39 +00:00
}
2014-12-29 02:13:24 +00:00
padapter - > net_closed = true ;
2014-12-17 01:03:30 +00:00
2015-08-15 18:24:16 +00:00
if ( adapter_to_pwrctl ( padapter ) - > rf_pwrstate = = rf_on ) {
2015-08-15 21:38:30 +00:00
DBG_88E ( " (2)871x_drv - drv_close, bup=%d, hw_init_completed=%d \n " , padapter - > bup , padapter - > hw_init_completed ) ;
2013-05-08 21:45:39 +00:00
2015-02-20 04:11:26 +00:00
/* s1. */
2015-08-15 18:02:34 +00:00
if ( pnetdev )
2014-12-17 01:03:30 +00:00
{
2013-05-08 21:45:39 +00:00
if ( ! rtw_netif_queue_stopped ( pnetdev ) )
rtw_netif_stop_queue ( pnetdev ) ;
}
2014-12-17 01:03:30 +00:00
# ifndef CONFIG_ANDROID
2015-02-20 04:11:26 +00:00
/* s2. */
2013-05-08 21:45:39 +00:00
LeaveAllPowerSaveMode ( padapter ) ;
2014-12-29 02:13:24 +00:00
rtw_disassoc_cmd ( padapter , 500 , false ) ;
2015-02-20 04:11:26 +00:00
/* s2-2. indicate disconnect to os */
2013-05-08 21:45:39 +00:00
rtw_indicate_disconnect ( padapter ) ;
2015-02-20 04:11:26 +00:00
/* s2-3. */
2013-05-08 21:45:39 +00:00
rtw_free_assoc_resources ( padapter , 1 ) ;
2015-02-20 04:11:26 +00:00
/* s2-4. */
2014-12-29 02:13:24 +00:00
rtw_free_network_queue ( padapter , true ) ;
2014-12-17 01:03:30 +00:00
# endif
2015-02-20 04:11:26 +00:00
/* Close LED */
2013-05-08 21:45:39 +00:00
rtw_led_control ( padapter , LED_CTL_POWER_OFF ) ;
}
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_BR_EXT
2015-02-20 04:11:26 +00:00
/* if (OPMODE & (WIFI_STATION_STATE | WIFI_ADHOC_STATE)) */
2014-12-17 01:03:30 +00:00
{
2015-02-20 04:11:26 +00:00
/* void nat25_db_cleanup(struct adapter *priv); */
2014-12-17 01:03:30 +00:00
nat25_db_cleanup ( padapter ) ;
}
2015-02-20 04:11:26 +00:00
# endif /* CONFIG_BR_EXT */
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_P2P
2013-05-08 21:45:39 +00:00
rtw_p2p_enable ( padapter , P2P_ROLE_DISABLE ) ;
2015-02-20 04:11:26 +00:00
# endif /* CONFIG_P2P */
2014-12-17 01:03:30 +00:00
2015-03-13 02:01:49 +00:00
kfree ( dvobj - > firmware . szFwBuffer ) ;
dvobj - > firmware . szFwBuffer = NULL ;
2014-12-17 01:03:30 +00:00
rtw_scan_abort ( padapter ) ;
2014-12-29 02:13:24 +00:00
wdev_to_priv ( padapter - > rtw_wdev ) - > bandroid_scan = false ;
2015-02-20 04:11:26 +00:00
padapter - > rtw_wdev - > iftype = NL80211_IFTYPE_MONITOR ; /* set this at the end */
2014-12-17 01:03:30 +00:00
RT_TRACE ( _module_os_intfs_c_ , _drv_info_ , ( " -871x_drv - drv_close \n " ) ) ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " -871x_drv - drv_close, bup=%d \n " , padapter - > bup ) ;
2014-12-17 01:03:30 +00:00
return 0 ;
}
void rtw_ndev_destructor ( struct net_device * ndev )
{
2015-08-15 21:38:30 +00:00
DBG_88E ( FUNC_NDEV_FMT " \n " , FUNC_NDEV_ARG ( ndev ) ) ;
2014-12-17 01:03:30 +00:00
if ( ndev - > ieee80211_ptr )
rtw_mfree ( ( u8 * ) ndev - > ieee80211_ptr , sizeof ( struct wireless_dev ) ) ;
free_netdev ( ndev ) ;
}
# ifdef CONFIG_ARP_KEEP_ALIVE
struct route_info {
struct in_addr dst_addr ;
struct in_addr src_addr ;
struct in_addr gateway ;
unsigned int dev_index ;
} ;
static void parse_routes ( struct nlmsghdr * nl_hdr , struct route_info * rt_info )
{
struct rtmsg * rt_msg ;
struct rtattr * rt_attr ;
int rt_len ;
rt_msg = ( struct rtmsg * ) NLMSG_DATA ( nl_hdr ) ;
if ( ( rt_msg - > rtm_family ! = AF_INET ) | | ( rt_msg - > rtm_table ! = RT_TABLE_MAIN ) )
return ;
rt_attr = ( struct rtattr * ) RTM_RTA ( rt_msg ) ;
rt_len = RTM_PAYLOAD ( nl_hdr ) ;
2014-12-19 06:59:46 +00:00
for ( ; RTA_OK ( rt_attr , rt_len ) ; rt_attr = RTA_NEXT ( rt_attr , rt_len ) )
2014-12-17 01:03:30 +00:00
{
switch ( rt_attr - > rta_type ) {
case RTA_OIF :
rt_info - > dev_index = * ( int * ) RTA_DATA ( rt_attr ) ;
break ;
case RTA_GATEWAY :
rt_info - > gateway . s_addr = * ( u_int * ) RTA_DATA ( rt_attr ) ;
break ;
case RTA_PREFSRC :
rt_info - > src_addr . s_addr = * ( u_int * ) RTA_DATA ( rt_attr ) ;
break ;
case RTA_DST :
rt_info - > dst_addr . s_addr = * ( u_int * ) RTA_DATA ( rt_attr ) ;
break ;
}
}
}
static int route_dump ( u32 * gw_addr , int * gw_index )
{
int err = 0 ;
struct socket * sock ;
struct {
struct nlmsghdr nlh ;
struct rtgenmsg g ;
} req ;
struct msghdr msg ;
struct iovec iov ;
struct sockaddr_nl nladdr ;
mm_segment_t oldfs ;
char * pg ;
int size = 0 ;
err = sock_create ( AF_NETLINK , SOCK_DGRAM , NETLINK_ROUTE , & sock ) ;
if ( err )
{
printk ( " : Could not create a datagram socket, error = %d \n " , - ENXIO ) ;
return err ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
memset ( & nladdr , 0 , sizeof ( nladdr ) ) ;
nladdr . nl_family = AF_NETLINK ;
req . nlh . nlmsg_len = sizeof ( req ) ;
req . nlh . nlmsg_type = RTM_GETROUTE ;
req . nlh . nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST ;
req . nlh . nlmsg_pid = 0 ;
req . g . rtgen_family = AF_INET ;
iov . iov_base = & req ;
iov . iov_len = sizeof ( req ) ;
msg . msg_name = & nladdr ;
msg . msg_namelen = sizeof ( nladdr ) ;
msg . msg_iov = & iov ;
msg . msg_iovlen = 1 ;
msg . msg_control = NULL ;
msg . msg_controllen = 0 ;
msg . msg_flags = MSG_DONTWAIT ;
oldfs = get_fs ( ) ; set_fs ( KERNEL_DS ) ;
err = sock_sendmsg ( sock , & msg , sizeof ( req ) ) ;
set_fs ( oldfs ) ;
if ( size < 0 )
goto out_sock ;
pg = ( char * ) __get_free_page ( GFP_KERNEL ) ;
if ( pg = = NULL ) {
err = - ENOMEM ;
goto out_sock ;
}
# if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
restart :
# endif
2014-12-19 06:59:46 +00:00
for ( ; ; )
2014-12-17 01:03:30 +00:00
{
struct nlmsghdr * h ;
iov . iov_base = pg ;
iov . iov_len = PAGE_SIZE ;
oldfs = get_fs ( ) ; set_fs ( KERNEL_DS ) ;
err = sock_recvmsg ( sock , & msg , PAGE_SIZE , MSG_DONTWAIT ) ;
set_fs ( oldfs ) ;
if ( err < 0 )
goto out_sock_pg ;
if ( msg . msg_flags & MSG_TRUNC ) {
err = - ENOBUFS ;
goto out_sock_pg ;
}
h = ( struct nlmsghdr * ) pg ;
2014-12-19 06:59:46 +00:00
while ( NLMSG_OK ( h , err ) )
2014-12-17 01:03:30 +00:00
{
struct route_info rt_info ;
if ( h - > nlmsg_type = = NLMSG_DONE ) {
err = 0 ;
goto done ;
}
if ( h - > nlmsg_type = = NLMSG_ERROR ) {
struct nlmsgerr * errm = ( struct nlmsgerr * ) NLMSG_DATA ( h ) ;
err = errm - > error ;
printk ( " NLMSG error: %d \n " , errm - > error ) ;
goto done ;
}
if ( h - > nlmsg_type = = RTM_GETROUTE )
{
printk ( " RTM_GETROUTE: NLMSG: %d \n " , h - > nlmsg_type ) ;
}
if ( h - > nlmsg_type ! = RTM_NEWROUTE ) {
printk ( " NLMSG: %d \n " , h - > nlmsg_type ) ;
err = - EINVAL ;
goto done ;
}
memset ( & rt_info , 0 , sizeof ( struct route_info ) ) ;
parse_routes ( h , & rt_info ) ;
2015-08-15 18:02:34 +00:00
if ( ! rt_info . dst_addr . s_addr & & rt_info . gateway . s_addr & & rt_info . dev_index )
2014-12-17 01:03:30 +00:00
{
* gw_addr = rt_info . gateway . s_addr ;
* gw_index = rt_info . dev_index ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
}
h = NLMSG_NEXT ( h , err ) ;
}
2014-12-19 06:59:46 +00:00
if ( err )
2014-12-17 01:03:30 +00:00
{
printk ( " !!!Remnant of size %d %d %d \n " , err , h - > nlmsg_len , h - > nlmsg_type ) ;
err = - EINVAL ;
break ;
}
}
done :
# if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
if ( ! err & & req . g . rtgen_family = = AF_INET ) {
req . g . rtgen_family = AF_INET6 ;
iov . iov_base = & req ;
iov . iov_len = sizeof ( req ) ;
msg . msg_name = & nladdr ;
msg . msg_namelen = sizeof ( nladdr ) ;
msg . msg_iov = & iov ;
msg . msg_iovlen = 1 ;
msg . msg_control = NULL ;
msg . msg_controllen = 0 ;
msg . msg_flags = MSG_DONTWAIT ;
oldfs = get_fs ( ) ; set_fs ( KERNEL_DS ) ;
err = sock_sendmsg ( sock , & msg , sizeof ( req ) ) ;
set_fs ( oldfs ) ;
if ( err > 0 )
goto restart ;
}
# endif
2013-05-08 21:45:39 +00:00
2014-12-17 01:03:30 +00:00
out_sock_pg :
free_page ( ( unsigned long ) pg ) ;
2014-02-14 16:17:29 +00:00
2014-12-17 01:03:30 +00:00
out_sock :
sock_release ( sock ) ;
return err ;
}
static int arp_query ( unsigned char * haddr , u32 paddr ,
struct net_device * dev )
{
struct neighbour * neighbor_entry ;
int ret = 0 ;
neighbor_entry = neigh_lookup ( & arp_tbl , & paddr , dev ) ;
if ( neighbor_entry ! = NULL ) {
neighbor_entry - > used = jiffies ;
if ( neighbor_entry - > nud_state & NUD_VALID ) {
2015-02-19 20:50:04 +00:00
memcpy ( haddr , neighbor_entry - > ha , dev - > addr_len ) ;
2014-12-17 01:03:30 +00:00
ret = 1 ;
}
neigh_release ( neighbor_entry ) ;
}
return ret ;
}
static int get_defaultgw ( u32 * ip_addr , char mac [ ] )
{
2015-02-20 04:11:26 +00:00
int gw_index = 0 ; /* oif device index */
struct net_device * gw_dev = NULL ; /* oif device */
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
route_dump ( ip_addr , & gw_index ) ;
2015-08-15 18:02:34 +00:00
if ( ! ( * ip_addr ) | | ! gw_index )
2014-12-17 01:03:30 +00:00
{
2015-08-15 21:38:30 +00:00
/* DBG_88E("No default GW\n"); */
2014-12-17 01:03:30 +00:00
return - 1 ;
}
gw_dev = dev_get_by_index ( & init_net , gw_index ) ;
2015-08-15 18:02:34 +00:00
if ( gw_dev = = NULL )
2014-12-17 01:03:30 +00:00
{
2015-08-15 21:38:30 +00:00
/* DBG_88E("get Oif Device Fail\n"); */
2014-12-17 01:03:30 +00:00
return - 1 ;
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( ! arp_query ( mac , * ip_addr , gw_dev ) )
2014-12-17 01:03:30 +00:00
{
2015-08-15 21:38:30 +00:00
/* DBG_88E( "arp query failed\n"); */
2014-12-17 01:03:30 +00:00
dev_put ( gw_dev ) ;
return - 1 ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
}
dev_put ( gw_dev ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
return 0 ;
2013-05-19 04:28:07 +00:00
}
2014-12-17 01:03:30 +00:00
2014-12-17 23:13:53 +00:00
int rtw_gw_addr_query ( struct adapter * padapter )
2014-12-17 01:03:30 +00:00
{
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
2015-02-20 04:11:26 +00:00
u32 gw_addr = 0 ; /* default gw address */
unsigned char gw_mac [ 32 ] = { 0 } ; /* default gw mac */
2014-12-17 01:03:30 +00:00
int i ;
int res ;
res = get_defaultgw ( & gw_addr , gw_mac ) ;
2015-08-15 18:02:34 +00:00
if ( ! res )
2014-12-17 01:03:30 +00:00
{
pmlmepriv - > gw_ip [ 0 ] = gw_addr & 0xff ;
pmlmepriv - > gw_ip [ 1 ] = ( gw_addr & 0xff00 ) > > 8 ;
pmlmepriv - > gw_ip [ 2 ] = ( gw_addr & 0xff0000 ) > > 16 ;
pmlmepriv - > gw_ip [ 3 ] = ( gw_addr & 0xff000000 ) > > 24 ;
2015-02-19 20:50:04 +00:00
memcpy ( pmlmepriv - > gw_mac_addr , gw_mac , 6 ) ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " %s Gateway Mac: \t " MAC_FMT " \n " , __FUNCTION__ , MAC_ARG ( pmlmepriv - > gw_mac_addr ) ) ;
DBG_88E ( " %s Gateway IP: \t " IP_FMT " \n " , __FUNCTION__ , IP_ARG ( pmlmepriv - > gw_ip ) ) ;
2014-12-17 01:03:30 +00:00
}
else
{
2015-08-15 21:38:30 +00:00
/* DBG_88E("Get Gateway IP/MAC fail!\n"); */
2014-12-17 01:03:30 +00:00
}
return res ;
2014-12-19 06:59:46 +00:00
}
2014-12-17 01:03:30 +00:00
# endif
2014-12-19 04:28:04 +00:00
static int rtw_suspend_free_assoc_resource ( struct adapter * padapter )
2014-12-17 01:03:30 +00:00
{
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
struct net_device * pnetdev = padapter - > pnetdev ;
struct wifidirect_info * pwdinfo = & padapter - > wdinfo ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " ==> " FUNC_ADPT_FMT " entry.... \n " , FUNC_ADPT_ARG ( padapter ) ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
rtw_cancel_all_timer ( padapter ) ;
2015-08-15 18:24:16 +00:00
if ( pnetdev ) {
2014-12-17 01:03:30 +00:00
netif_carrier_off ( pnetdev ) ;
rtw_netif_stop_queue ( pnetdev ) ;
2014-12-19 06:59:46 +00:00
}
2014-12-17 01:03:30 +00:00
2015-08-15 18:02:34 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) & & check_fwstate ( pmlmepriv , _FW_LINKED ) & & rtw_p2p_chk_state ( pwdinfo , P2P_STATE_NONE ) )
2014-12-17 01:03:30 +00:00
{
2015-08-15 21:38:30 +00:00
DBG_88E ( " %s %s( " MAC_FMT " ), length:%d assoc_ssid.length:%d \n " , __FUNCTION__ ,
2014-12-17 01:03:30 +00:00
pmlmepriv - > cur_network . network . Ssid . Ssid ,
MAC_ARG ( pmlmepriv - > cur_network . network . MacAddress ) ,
pmlmepriv - > cur_network . network . Ssid . SsidLength ,
pmlmepriv - > assoc_ssid . SsidLength ) ;
rtw_set_roaming ( padapter , 1 ) ;
}
2015-08-15 18:02:34 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) & & check_fwstate ( pmlmepriv , _FW_LINKED ) )
2014-12-19 06:59:46 +00:00
{
2014-12-29 02:13:24 +00:00
rtw_disassoc_cmd ( padapter , 0 , false ) ;
2014-12-17 01:03:30 +00:00
}
# ifdef CONFIG_AP_MODE
2015-08-15 18:02:34 +00:00
else if ( check_fwstate ( pmlmepriv , WIFI_AP_STATE ) )
2014-12-17 01:03:30 +00:00
{
rtw_sta_flush ( padapter ) ;
}
# endif
2015-08-15 18:24:16 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) ) {
2015-02-20 04:11:26 +00:00
/* s2-2. indicate disconnect to os */
2014-12-17 01:03:30 +00:00
rtw_indicate_disconnect ( padapter ) ;
}
2014-12-19 06:59:46 +00:00
2015-02-20 04:11:26 +00:00
/* s2-3. */
2014-12-17 01:03:30 +00:00
rtw_free_assoc_resources ( padapter , 1 ) ;
2015-02-20 04:11:26 +00:00
/* s2-4. */
2014-12-17 01:03:30 +00:00
# ifdef CONFIG_AUTOSUSPEND
2015-08-15 18:02:34 +00:00
if ( is_primary_adapter ( padapter ) & & ( ! adapter_to_pwrctl ( padapter ) - > bInternalAutoSuspend ) )
2014-12-17 01:03:30 +00:00
# endif
2014-12-29 02:13:24 +00:00
rtw_free_network_queue ( padapter , true ) ;
2014-12-17 01:03:30 +00:00
2015-08-15 18:02:34 +00:00
if ( check_fwstate ( pmlmepriv , _FW_UNDER_SURVEY ) )
2014-12-17 01:03:30 +00:00
rtw_indicate_scan_done ( padapter , 1 ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 21:38:30 +00:00
DBG_88E ( " ==> " FUNC_ADPT_FMT " exit.... \n " , FUNC_ADPT_ARG ( padapter ) ) ;
2014-12-17 01:03:30 +00:00
return 0 ;
}
2014-12-19 04:28:04 +00:00
2014-12-17 23:13:53 +00:00
int rtw_suspend_common ( struct adapter * padapter )
2014-12-17 01:03:30 +00:00
{
struct pwrctrl_priv * pwrpriv = adapter_to_pwrctl ( padapter ) ;
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
int ret = 0 ;
2015-01-26 22:20:25 +00:00
;
2014-12-17 01:03:30 +00:00
LeaveAllPowerSaveMode ( padapter ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
rtw_suspend_free_assoc_resource ( padapter ) ;
rtw_led_control ( padapter , LED_CTL_POWER_OFF ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 01:03:30 +00:00
rtw_dev_unload ( padapter ) ;
exit :
2015-01-26 22:20:25 +00:00
;
2014-12-17 01:03:30 +00:00
return ret ;
}
2014-12-17 23:13:53 +00:00
int rtw_resume_common ( struct adapter * padapter )
2014-12-17 01:03:30 +00:00
{
int ret = 0 ;
struct net_device * pnetdev = padapter - > pnetdev ;
struct pwrctrl_priv * pwrpriv = adapter_to_pwrctl ( padapter ) ;
struct mlme_priv * mlmepriv = & padapter - > mlmepriv ;
rtw_reset_drv_sw ( padapter ) ;
2014-12-29 02:13:24 +00:00
pwrpriv - > bkeepfwalive = false ;
2014-12-17 01:03:30 +00:00
2015-08-15 21:38:30 +00:00
DBG_88E ( " bkeepfwalive(%x) \n " , pwrpriv - > bkeepfwalive ) ;
2015-08-15 18:02:34 +00:00
if ( pm_netdev_open ( pnetdev , true ) ! = 0 ) {
2015-08-15 21:38:30 +00:00
DBG_88E ( " %s ==> pm_netdev_open failed \n " , __FUNCTION__ ) ;
2014-12-17 01:03:30 +00:00
ret = - 1 ;
return ret ;
}
netif_device_attach ( pnetdev ) ;
netif_carrier_on ( pnetdev ) ;
if ( check_fwstate ( mlmepriv , WIFI_STATION_STATE ) ) {
2015-08-15 21:38:30 +00:00
DBG_88E ( FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_STATION_STATE \n " , FUNC_ADPT_ARG ( padapter ) , get_fwstate ( mlmepriv ) ) ;
2014-12-17 01:03:30 +00:00
rtw_roaming ( padapter , NULL ) ;
} else if ( check_fwstate ( mlmepriv , WIFI_AP_STATE ) ) {
2015-08-15 21:38:30 +00:00
DBG_88E ( FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_AP_STATE \n " , FUNC_ADPT_ARG ( padapter ) , get_fwstate ( mlmepriv ) ) ;
2014-12-17 01:03:30 +00:00
rtw_ap_restore_network ( padapter ) ;
} else if ( check_fwstate ( mlmepriv , WIFI_ADHOC_STATE ) ) {
2015-08-15 21:38:30 +00:00
DBG_88E ( FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_ADHOC_STATE \n " , FUNC_ADPT_ARG ( padapter ) , get_fwstate ( mlmepriv ) ) ;
2014-12-17 01:03:30 +00:00
} else {
2015-08-15 21:38:30 +00:00
DBG_88E ( FUNC_ADPT_FMT " fwstate:0x%08x - ??? \n " , FUNC_ADPT_ARG ( padapter ) , get_fwstate ( mlmepriv ) ) ;
2014-12-17 01:03:30 +00:00
}
return ret ;
}