diff --git a/Makefile b/Makefile index 85585e7..471c061 100644 --- a/Makefile +++ b/Makefile @@ -83,6 +83,7 @@ CONFIG_PLATFORM_ARM_S3C6K4 = n CONFIG_PLATFORM_MIPS_RMI = n CONFIG_PLATFORM_RTD2880B = n CONFIG_PLATFORM_MIPS_AR9132 = n +CONFIG_PLATFORM_OPENWRT_NEO2 = n CONFIG_PLATFORM_RTK_DMP = n CONFIG_PLATFORM_MIPS_PLM = n CONFIG_PLATFORM_MSTAR389 = n @@ -869,18 +870,31 @@ EXTRA_CFLAGS += -DCONFIG_TDLS endif ifeq ($(CONFIG_PLATFORM_I386_PC), y) + +ifdef EXT_EXTRA_CFLAGS +EXTRA_CFLAGS += $(EXT_EXTRA_CFLAGS) +else EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN #EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT #EXTRA_CFLAGS += -DCONFIG_P2P_IPS -SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ | sed -e s/ppc64le/powerpc/) +endif +ifndef ARCH +SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/ppc64le/powerpc/ -e s/aarch64/arm64/) ARCH ?= $(SUBARCH) +endif +ifndef CROSS_COMPILE CROSS_COMPILE ?= +endif ifndef KVER KVER ?= $(shell uname -r) endif +ifndef KSRC KSRC := /lib/modules/$(KVER)/build +endif +ifndef MODDESTDIR MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/ +endif INSTALL_PREFIX := endif @@ -1046,6 +1060,16 @@ CROSS_COMPILE := mips-openwrt-linux- KSRC := /home/alex/test_openwrt/tmp/linux-2.6.30.9 endif +# This is how I built for openwrt Neo2 platform. --Ben +ifeq ($(CONFIG_PLATFORM_OPENWRT_NEO2), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN +ARCH := arm64 +CROSS_COMPILE := aarch64-openwrt-linux- +#export PATH=$PATH:/home/greearb/git/openwrt-neo2-dev/staging_dir/toolchain-aarch64_cortex-a53_gcc-7.3.0_musl/bin/ +#export STAGING_DIR=/home/greearb/git/openwrt-neo2-dev/staging_dir +KSRC := /home/greearb/git/openwrt-neo2-dev/build_dir/target-aarch64_cortex-a53_musl/linux-sunxi_cortexa53/linux-4.14.78 +endif + ifeq ($(CONFIG_PLATFORM_DMP_PHILIPS), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DRTK_DMP_PLATFORM ARCH := mips diff --git a/README.md b/README.md index 55d7c42..7ac32bc 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,13 @@ Load module # sudo modprobe -a rtl8812au ``` +# Cross-compiling. You can now specify variables on the command line w/out editing +# makefile. For instance, this builds against recent OpenWRT neo2 platform. Your +# Cross-compile binaries should be in your PATH. + +KSRC=/home/greearb/git/openwrt-neo2-dev/build_dir/target-aarch64_cortex-a53_musl/linux-sunxi_cortexa53/linux-4.14.78 EXT_EXTRA_CFLAGS=-DCONFIG_LITTLE_ENDIAN ARCH=arm64 CROSS_COMPILE=aarch64-openwrt-linux- MODDESTDIR=/tmp make V=1 + + Setup DKMS ```sh diff --git a/core/rtw_ap.c b/core/rtw_ap.c index 1a12c3d..c223828 100644 --- a/core/rtw_ap.c +++ b/core/rtw_ap.c @@ -194,7 +194,7 @@ void rtw_add_bcn_ie(_adapter *padapter, WLAN_BSSID_EX *pnetwork, u8 index, u8 *d u8 bmatch = _FALSE; u8 *pie = pnetwork->IEs; u8 *p=NULL, *dst_ie=NULL, *premainder_ie=NULL, *pbackup_remainder_ie=NULL; - u32 i, offset, ielen, ie_offset, remainder_ielen = 0; + u32 i, offset, ielen = 0, ie_offset, remainder_ielen = 0; for (i = sizeof(NDIS_802_11_FIXED_IEs); i < pnetwork->IELength;) { pIE = (PNDIS_802_11_VARIABLE_IEs)(pnetwork->IEs + i); diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index c61ce96..24565ea 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -3534,7 +3534,8 @@ void issue_p2p_GO_response(_adapter *padapter, u8* raddr, u8* frame_body,uint le u8 action = P2P_PUB_ACTION_ACTION; u32 p2poui = cpu_to_be32(P2POUI); u8 oui_subtype = P2P_GO_NEGO_RESP; - u8 wpsie[ 255 ] = { 0x00 }, p2pie[ 255 ] = { 0x00 }; + u8 *wpsie; + u8 p2pie[ 255 ] = { 0x00 }; u8 p2pielen = 0; uint wpsielen = 0; u16 wps_devicepassword_id = 0x0000; @@ -3560,6 +3561,8 @@ void issue_p2p_GO_response(_adapter *padapter, u8* raddr, u8* frame_body,uint le return; } + wpsie = rtw_zmalloc(256); + DBG_871X( "[%s] In, result = %d\n", __FUNCTION__, result ); //update attribute pattrib = &pmgntframe->attrib; @@ -3965,6 +3968,8 @@ void issue_p2p_GO_response(_adapter *padapter, u8* raddr, u8* frame_body,uint le dump_mgntframe(padapter, pmgntframe); + kfree(wpsie); + return; } diff --git a/include/drv_conf.h b/include/drv_conf.h index 0d20a7e..f0a9f88 100644 --- a/include/drv_conf.h +++ b/include/drv_conf.h @@ -19,7 +19,9 @@ ******************************************************************************/ #ifndef __DRV_CONF_H__ #define __DRV_CONF_H__ -#include "autoconf.h" + +#include +#include "rtl_autoconf.h" #if defined (PLATFORM_LINUX) && defined (PLATFORM_WINDOWS) diff --git a/include/linux/wireless.h b/include/linux/old_unused_rtl_wireless.h similarity index 100% rename from include/linux/wireless.h rename to include/linux/old_unused_rtl_wireless.h diff --git a/include/autoconf.h b/include/rtl_autoconf.h similarity index 100% rename from include/autoconf.h rename to include/rtl_autoconf.h diff --git a/include/rtw_byteorder.h b/include/rtw_byteorder.h index 478e0ee..f864f87 100644 --- a/include/rtw_byteorder.h +++ b/include/rtw_byteorder.h @@ -25,6 +25,18 @@ #error "Shall be CONFIG_LITTLE_ENDIAN or CONFIG_BIG_ENDIAN, but not both!\n" #endif +#if !((defined CONFIG_LITTLE_ENDIAN) || (defined CONFIG_BIG_ENDIAN)) +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define CONFIG_LITTLE_ENDIAN +//#warning "Auto-detected little-endian system...hope it is correct!" +#else +#if __BYTE_ORDER == __BIG_ENDIAN +//#warning "Auto-detected big-endian system...hope it is correct!" +#define CONFIG_BIG_ENDIAN +#endif +#endif +#endif + #if defined (CONFIG_LITTLE_ENDIAN) #ifndef CONFIG_PLATFORM_MSTAR389 # include diff --git a/include/wifi.h b/include/wifi.h index b2afa0b..e39aa26 100644 --- a/include/wifi.h +++ b/include/wifi.h @@ -977,7 +977,7 @@ typedef enum _HT_CAP_AMPDU_FACTOR { * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) */ #define IEEE80211_MIN_AMPDU_BUF 0x8 -#define IEEE80211_MAX_AMPDU_BUF 0x40 +//#define IEEE80211_MAX_AMPDU_BUF 0x40 /* Spatial Multiplexing Power Save Modes */ diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index b410122..019daf9 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -349,6 +349,9 @@ static int rtw_ieee80211_channel_to_frequency(int chan, int band) static u64 rtw_get_systime_us(void) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0)) + return ktime_to_us(ktime_get_boottime()); +#else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) struct timespec ts; get_monotonic_boottime(&ts); @@ -358,6 +361,7 @@ static u64 rtw_get_systime_us(void) do_gettimeofday(&tv); return ((u64)tv.tv_sec*1000000) + tv.tv_usec; #endif +#endif } #define MAX_BSSINFO_LEN 1000 @@ -5837,10 +5841,6 @@ void rtw_cfg80211_init_wiphy(_adapter *padapter) /* init regulary domain */ rtw_regd_init(padapter); - - /* copy mac_addr to wiphy */ - _rtw_memcpy(wiphy->perm_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); - } /* @@ -5959,6 +5959,10 @@ static void rtw_cfg80211_preinit_wiphy(_adapter *padapter, struct wiphy *wiphy) //wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; #endif + + /* copy mac_addr to wiphy */ + _rtw_memcpy(wiphy->perm_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(RTW_VENDOR_EXT_SUPPORT) rtw_cfgvendor_attach(wiphy); #endif diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index 4eba681..c74a153 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -83,6 +83,8 @@ static const char * const iw_operation_mode[] = { "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Monitor" }; +#ifdef CONFIG_WIRELESS_EXT + static int hex2num_i(char c) { if (c >= '0' && c <= '9') @@ -132,6 +134,7 @@ static int hwaddr_aton_i(const char *txt, u8 *addr) return 0; } +#endif static inline void indicate_wx_custom_event(_adapter *padapter, char *msg) { @@ -304,6 +307,8 @@ uint rtw_is_cckratesonly_included(u8 *rate) } */ +#ifdef CONFIG_WIRELESS_EXT + static int search_p2p_wfd_ie(_adapter *padapter, struct iw_request_info* info, struct wlan_network *pnetwork, char *start, char *stop) @@ -378,6 +383,8 @@ static int search_p2p_wfd_ie(_adapter *padapter, #endif //CONFIG_P2P return _TRUE; } +#endif + static inline char *iwe_stream_mac_addr_proess(_adapter *padapter, struct iw_request_info* info, struct wlan_network *pnetwork, char *start, char *stop,struct iw_event *iwe) @@ -826,6 +833,8 @@ static inline char * iwe_stream_net_rsv_process(_adapter *padapter, return start; } +#ifdef CONFIG_WIRELESS_EXT + #if 1 static char *translate_scan(_adapter *padapter, struct iw_request_info* info, struct wlan_network *pnetwork, @@ -1735,6 +1744,9 @@ exit: return ret; } +#endif + +#ifdef CONFIG_WIRELESS_EXT static int rtw_wx_get_name(struct net_device *dev, struct iw_request_info *info, @@ -10238,31 +10250,48 @@ static int rtw_mp_write_reg(struct net_device *dev, char *width_str; char width; u32 addr, data; - int ret; + int ret = 0; PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->length]; + char* input = kmalloc(wrqu->length, GFP_KERNEL); - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } _rtw_memset(extra, 0, wrqu->length); pch = input; pnext = strpbrk(pch, " ,.-"); - if (pnext == NULL) return -EINVAL; + if (pnext == NULL) { + ret = -EINVAL; + goto out; + } *pnext = 0; width_str = pch; pch = pnext + 1; pnext = strpbrk(pch, " ,.-"); - if (pnext == NULL) return -EINVAL; + if (pnext == NULL) { + ret = -EINVAL; + goto out; + } *pnext = 0; addr = simple_strtoul(pch, &ptmp, 16); - if (addr > 0x3FFF) return -EINVAL; + if (addr > 0x3FFF) { + ret = -EINVAL; + goto out; + } pch = pnext + 1; - if ((pch - extra) >= wrqu->length) return -EINVAL; + if ((pch - extra) >= wrqu->length) { + ret = -EINVAL; + goto out; + } data = simple_strtoul(pch, &ptmp, 16); ret = 0; @@ -10293,6 +10322,8 @@ static int rtw_mp_write_reg(struct net_device *dev, break; } +out: + kfree(input); return ret; } @@ -10311,7 +10342,7 @@ static int rtw_mp_read_reg(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - char input[wrqu->length]; + char input[128]; char *pch, *pnext, *ptmp; char *width_str; char width; @@ -10446,20 +10477,28 @@ static int rtw_mp_write_rf(struct net_device *dev, union iwreq_data *wrqu, char *extra) */ u32 path, addr, data; - int ret; + int ret = 0; PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->length]; + char* input = kmalloc(wrqu->length, GFP_KERNEL); - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } ret = sscanf(input, "%d,%x,%x", &path, &addr, &data); - if (ret < 3) return -EINVAL; + if (ret < 3) { + ret = -EINVAL; + goto out; + } - if (path >= GET_HAL_RFPATH_NUM(padapter)) return -EINVAL; - if (addr > 0xFF) return -EINVAL; - if (data > 0xFFFFF) return -EINVAL; + if ((path >= GET_HAL_RFPATH_NUM(padapter)) || + (addr > 0xFF) || + (data > 0xFFFFF)) { + ret = -EINVAL; + goto out; + } _rtw_memset(extra, 0, wrqu->length); @@ -10468,7 +10507,9 @@ static int rtw_mp_write_rf(struct net_device *dev, sprintf(extra, "write_rf completed \n"); wrqu->length = strlen(extra); - return 0; +out: + kfree(input); + return ret; } /* @@ -10483,7 +10524,7 @@ static int rtw_mp_read_rf(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - char input[wrqu->length]; + char input[128]; char *pch, *pnext, *ptmp; char data[20],tmp[20]; //u32 *data = (u32*)extra; @@ -10624,11 +10665,17 @@ static int rtw_mp_rate(struct net_device *dev, struct iw_point *wrqu, char *extra) { u32 rate = MPT_RATE_1M; - u8 input[wrqu->length]; + u8* input = kmalloc(wrqu->length, GFP_KERNEL); PADAPTER padapter = rtw_netdev_priv(dev); + int ret = 0; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } rate = rtw_mpRateParseFunc(padapter,input); @@ -10650,14 +10697,19 @@ static int rtw_mp_rate(struct net_device *dev, sprintf( extra, "Set data rate to %s index %d" ,input,rate ); DBG_871X("%s: %s rate index=%d \n", __func__,input,rate); - if (rate >= MPT_RATE_LAST ) - return -EINVAL; + if (rate >= MPT_RATE_LAST ) { + ret = -EINVAL; + goto out; + } padapter->mppriv.rateidx = rate; Hal_SetDataRate(padapter); wrqu->length = strlen(extra); - return 0; + +out: + kfree(input); + return ret; } static int rtw_mp_channel(struct net_device *dev, @@ -10667,12 +10719,18 @@ static int rtw_mp_channel(struct net_device *dev, PADAPTER padapter = rtw_netdev_priv(dev); HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - u8 input[wrqu->length]; + u8* input = kmalloc(wrqu->length, GFP_KERNEL); u32 channel = 1; + int ret = 0; //int cur_ch_offset; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } channel = rtw_atoi(input); //DBG_871X("%s: channel=%d\n", __func__, channel); @@ -10683,7 +10741,9 @@ static int rtw_mp_channel(struct net_device *dev, pHalData->CurrentChannel = channel; wrqu->length = strlen(extra); - return 0; +out: + kfree(input); + return ret; } static int rtw_mp_bandwidth(struct net_device *dev, @@ -10725,7 +10785,7 @@ static int rtw_mp_txpower_index(struct net_device *dev, struct iw_point *wrqu, char *extra) { PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->length]; + char input[128]; u32 rfpath; u32 txpower_inx; @@ -10750,12 +10810,17 @@ static int rtw_mp_txpower(struct net_device *dev, { u32 idx_a = 0, idx_b = 0; int MsetPower = 1; - u8 input[wrqu->length]; - + u8* input = kmalloc(wrqu->length, GFP_KERNEL); + int ret = 0; PADAPTER padapter = rtw_netdev_priv(dev); - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } MsetPower = strncmp(input, "off", 3); sscanf(input,"patha=%d,pathb=%d",&idx_a,&idx_b); @@ -10771,6 +10836,9 @@ static int rtw_mp_txpower(struct net_device *dev, Hal_SetAntennaPathPower(padapter); } wrqu->length = strlen(extra); + +out: + kfree(input); return 0; } @@ -10779,12 +10847,18 @@ static int rtw_mp_ant_tx(struct net_device *dev, struct iw_point *wrqu, char *extra) { u8 i; - u8 input[wrqu->length]; + u8 *input = kmalloc(wrqu->length, GFP_KERNEL); u16 antenna = 0; PADAPTER padapter = rtw_netdev_priv(dev); + int ret = 0; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } //DBG_871X("%s: input=%s\n", __func__, input); @@ -10809,7 +10883,9 @@ static int rtw_mp_ant_tx(struct net_device *dev, Hal_SetAntenna(padapter); wrqu->length = strlen(extra); - return 0; +out: + kfree(input); + return ret; } static int rtw_mp_ant_rx(struct net_device *dev, @@ -10818,11 +10894,18 @@ static int rtw_mp_ant_rx(struct net_device *dev, { u8 i; u16 antenna = 0; - u8 input[wrqu->length]; + u8 *input = kmalloc(wrqu->length, GFP_KERNEL); PADAPTER padapter = rtw_netdev_priv(dev); + int ret = 0; + + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; //DBG_871X("%s: input=%s\n", __func__, input); _rtw_memset(extra, 0, wrqu->length); @@ -10849,7 +10932,9 @@ static int rtw_mp_ant_rx(struct net_device *dev, Hal_SetAntenna(padapter); wrqu->length = strlen(extra); - return 0; +out: + kfree(input); + return ret; } static int rtw_set_ctx_destAddr(struct net_device *dev, @@ -11063,11 +11148,17 @@ static int rtw_mp_disable_bt_coexist(struct net_device *dev, //struct hal_ops *pHalFunc = &padapter->HalFunc; #endif - u8 input[wrqu->data.length]; + u8 *input = kmalloc(wrqu->data.length, GFP_KERNEL); u32 bt_coexist; + int ret = 0; - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) { + ret = -EFAULT; + goto out; + } bt_coexist = rtw_atoi(input); @@ -11092,7 +11183,9 @@ static int rtw_mp_disable_bt_coexist(struct net_device *dev, #endif } - return 0; +out: + kfree(input); + return ret; } @@ -11102,15 +11195,21 @@ static int rtw_mp_arx(struct net_device *dev, { int bStartRx = 0, bStopRx = 0, bQueryPhy = 0, bQueryMac = 0, bSetBssid = 0; int bmac_filter = 0, bmon = 0; - u8 input[wrqu->length]; + u8 *input = kmalloc(wrqu->length, GFP_KERNEL); char *pch, *token, *tmp[2]= {0x00,0x00}; u32 i = 0, jj = 0, kk = 0, cnts = 0; PADAPTER padapter = rtw_netdev_priv(dev); struct mp_priv *pmppriv = &padapter->mppriv; struct dbg_rx_counter rx_counter; + int ret = 0; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } DBG_871X("%s: %s\n", __func__, input); @@ -11131,10 +11230,14 @@ static int rtw_mp_arx(struct net_device *dev, i++; } if ((tmp[0]==NULL) && (tmp[1]==NULL)) { - return -EFAULT; + ret = -EFAULT; + goto out; } else { cnts = strlen(tmp[1])/2; - if (cnts<1) return -EFAULT; + if (cnts<1) { + ret = -EFAULT; + goto out; + } DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts); DBG_871X("%s: data=%s\n", __FUNCTION__, tmp[1]); for (jj=0, kk=0; jj < cnts ; jj++, kk+=2) { @@ -11154,10 +11257,14 @@ static int rtw_mp_arx(struct net_device *dev, i++; } if ((tmp[0]==NULL) && (tmp[1]==NULL)) { - return -EFAULT; + ret = -EFAULT; + goto out; } else { cnts = strlen(tmp[1])/2; - if (cnts<1) return -EFAULT; + if (cnts<1) { + ret = -EFAULT; + goto out; + } DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts); DBG_871X("%s: data=%s\n", __FUNCTION__, tmp[1]); for (jj=0, kk=0; jj < cnts ; jj++, kk+=2) { @@ -11205,7 +11312,9 @@ static int rtw_mp_arx(struct net_device *dev, wrqu->length = strlen(extra) + 1; - return 0; +out: + kfree(input); + return ret; } static int rtw_mp_trx_query(struct net_device *dev, @@ -11240,11 +11349,16 @@ static int rtw_mp_pwrtrk(struct net_device *dev, u32 thermal; s32 ret; PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - u8 input[wrqu->length]; + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); + u8 *input = kmalloc(wrqu->length, GFP_KERNEL); - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } _rtw_memset(extra, 0, wrqu->length); @@ -11265,11 +11379,17 @@ static int rtw_mp_pwrtrk(struct net_device *dev, } ret = Hal_SetPowerTracking(padapter, enable); - if (ret == _FAIL) return -EPERM; + if (ret == _FAIL) { + ret = -EPERM; + goto out; + } wrqu->length = strlen(extra); + ret = 0; - return 0; +out: + kfree(input); + return ret; } static int rtw_mp_psd(struct net_device *dev, @@ -11277,16 +11397,24 @@ static int rtw_mp_psd(struct net_device *dev, struct iw_point *wrqu, char *extra) { PADAPTER padapter = rtw_netdev_priv(dev); - u8 input[wrqu->length]; + u8 *input = kmalloc(wrqu->length, GFP_KERNEL); + int ret = 0; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } strcpy(extra,input); wrqu->length = mp_query_psd(padapter, extra); - return 0; +out: + kfree(input); + return ret; } static int rtw_mp_thermal(struct net_device *dev, @@ -11380,22 +11508,31 @@ static int rtw_mp_dump(struct net_device *dev, struct mp_priv *pmp_priv; //struct pkt_attrib *pattrib; //u32 value; - u8 input[wrqu->length]; + u8 *input = kmalloc(wrqu->length, GFP_KERNEL); //u8 rf_type,path_nums = 0; //u32 i,j=1,path; PADAPTER padapter = rtw_netdev_priv(dev); + int ret = 0; + if (!input) + return -ENOMEM; + pmp_priv = &padapter->mppriv; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } if ( strncmp(input, "all", 4)==0 ) { mac_reg_dump(RTW_DBGDUMP, padapter); bb_reg_dump(RTW_DBGDUMP, padapter); rf_reg_dump(RTW_DBGDUMP, padapter); } - return 0; + +out: + kfree(input); + return ret; } static int rtw_mp_phypara(struct net_device *dev, @@ -11405,11 +11542,17 @@ static int rtw_mp_phypara(struct net_device *dev, PADAPTER padapter = rtw_netdev_priv(dev); HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - char input[wrqu->length]; + char *input = kmalloc(wrqu->length, GFP_KERNEL); u32 valxcap; + int ret = 0; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } DBG_871X("%s:iwpriv in=%s\n", __func__, input); @@ -11421,7 +11564,9 @@ static int rtw_mp_phypara(struct net_device *dev, sprintf( extra, "Set xcap=%d",valxcap ); wrqu->length = strlen(extra) + 1; - return 0; +out: + kfree(input); + return ret; } @@ -11430,11 +11575,17 @@ static int rtw_mp_SetRFPath(struct net_device *dev, union iwreq_data *wrqu, char *extra) { PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->data.length]; + char* input = kmalloc(wrqu->data.length, GFP_KERNEL); int bMain = 1, bTurnoff = 1; + int ret = 0; - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) { + ret = -EFAULT; + goto out; + } DBG_871X("%s:iwpriv in=%s\n", __func__, input); bMain = strncmp(input, "1", 2); // strncmp TRUE is 0 @@ -11448,7 +11599,9 @@ static int rtw_mp_SetRFPath(struct net_device *dev, DBG_871X("%s:PHY_SetRFPathSwitch=FALSE\n", __func__); } - return 0; +out: + kfree(input); + return ret; } static int rtw_mp_QueryDrv(struct net_device *dev, @@ -11456,13 +11609,19 @@ static int rtw_mp_QueryDrv(struct net_device *dev, union iwreq_data *wrqu, char *extra) { PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->data.length]; + char* input = kmalloc(wrqu->data.length, GFP_KERNEL); int qAutoLoad = 1; + int ret = 0; EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) { + ret = -EFAULT; + goto out; + } DBG_871X("%s:iwpriv in=%s\n", __func__, input); qAutoLoad = strncmp(input, "autoload", 8); // strncmp TRUE is 0 @@ -11476,7 +11635,10 @@ static int rtw_mp_QueryDrv(struct net_device *dev, sprintf(extra, "ok"); } wrqu->data.length = strlen(extra) + 1; - return 0; + +out: + kfree(input); + return ret; } /* update Tx AGC offset */ @@ -11496,11 +11658,17 @@ static int rtw_mp_PwrCtlDM(struct net_device *dev, struct iw_point *wrqu, char *extra) { PADAPTER padapter = rtw_netdev_priv(dev); - u8 input[wrqu->length]; + u8 *input = kmalloc(wrqu->length, GFP_KERNEL); int bstart=1; + int ret = 0; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + ret = -EFAULT; + goto out; + } bstart = strncmp(input, "start", 5); // strncmp TRUE is 0 if(bstart==0) { @@ -11512,7 +11680,9 @@ static int rtw_mp_PwrCtlDM(struct net_device *dev, } wrqu->length = strlen(extra); - return 0; +out: + kfree(input); + return ret; } static int rtw_mp_getver(struct net_device *dev, @@ -13828,6 +13998,7 @@ static int rtw_test( return 0; } +#ifdef CONFIG_WIRELESS_EXT static iw_handler rtw_handlers[] = { NULL, /* SIOCSIWCOMMIT */ rtw_wx_get_name, /* SIOCGIWNAME */ @@ -14113,8 +14284,9 @@ static iw_handler rtw_private_handler[] = { rtw_widi_set_probe_request, //0x1F #endif // CONFIG_INTEL_WIDI }; +#endif - +#ifdef CONFIG_WIRELESS_EXT #if WIRELESS_EXT >= 17 static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) { @@ -14174,6 +14346,7 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) return &padapter->iwstats; } #endif +#endif #ifdef CONFIG_WIRELESS_EXT struct iw_handler_def rtw_handlers_def = { @@ -14189,7 +14362,6 @@ struct iw_handler_def rtw_handlers_def = { .get_wireless_stats = rtw_get_wireless_stats, #endif }; -#endif // copy from net/wireless/wext.c start /* ---------------------------------------------------------------- */ @@ -14534,6 +14706,7 @@ exit: return err; } +#endif #ifdef CONFIG_COMPAT static int rtw_ioctl_compat_wext_private(struct net_device *dev, struct ifreq *rq) @@ -14561,6 +14734,7 @@ static int rtw_ioctl_compat_wext_private(struct net_device *dev, struct ifreq *r } #endif // CONFIG_COMPAT +#ifdef CONFIG_WIRELESS_EXT static inline int rtw_ioctl_standard_wext_private(struct net_device *dev, struct ifreq *rq) { struct iw_point *iwp; @@ -14623,3 +14797,5 @@ int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) return ret; } +#endif +#endif diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 48cb0c3..f5b9251 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -688,7 +688,11 @@ unsigned int rtw_classify8021d(struct sk_buff *skb) static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) + , struct net_device *sb_dev +#else , void *accel_priv +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) , select_queue_fallback_t fallback #endif @@ -745,12 +749,14 @@ static int rtw_ndev_notifier_call(struct notifier_block * nb, unsigned long stat struct net_device *dev = ptr; #endif +#ifdef CONFIG_WIRELESS_EXT #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29)) if (dev->netdev_ops->ndo_do_ioctl != rtw_ioctl) #else if (dev->do_ioctl != rtw_ioctl) #endif return NOTIFY_DONE; +#endif DBG_871X_LEVEL(_drv_info_, FUNC_NDEV_FMT" state:%lu\n", FUNC_NDEV_ARG(dev), state); @@ -810,7 +816,9 @@ static const struct net_device_ops rtw_netdev_ops = { #endif .ndo_set_mac_address = rtw_net_set_mac_address, .ndo_get_stats = rtw_net_get_stats, +#ifdef CONFIG_WIRELESS_EXT .ndo_do_ioctl = rtw_ioctl, +#endif }; #endif @@ -896,8 +904,10 @@ struct net_device *rtw_init_netdev(_adapter *old_padapter) pnetdev->hard_start_xmit = rtw_xmit_entry; pnetdev->set_mac_address = rtw_net_set_mac_address; pnetdev->get_stats = rtw_net_get_stats; +#ifdef CONFIG_WIRELESS_EXT pnetdev->do_ioctl = rtw_ioctl; #endif +#endif #ifdef CONFIG_TCP_CSUM_OFFLOAD_TX @@ -1598,7 +1608,9 @@ static const struct net_device_ops rtw_netdev_vir_if_ops = { .ndo_start_xmit = rtw_xmit_entry, .ndo_set_mac_address = rtw_net_set_mac_address, .ndo_get_stats = rtw_net_get_stats, +#ifdef CONFIG_WIRELESS_EXT .ndo_do_ioctl = rtw_ioctl, +#endif #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35)) .ndo_select_queue = rtw_select_queue, #endif @@ -1989,7 +2001,9 @@ static const struct net_device_ops rtw_netdev_if2_ops = { .ndo_start_xmit = rtw_xmit_entry, .ndo_set_mac_address = rtw_net_set_mac_address, .ndo_get_stats = rtw_net_get_stats, +#ifdef CONFIG_WIRELESS_EXT .ndo_do_ioctl = rtw_ioctl, +#endif #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35)) .ndo_select_queue = rtw_select_queue, #endif diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index 44166bd..9266004 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -1314,17 +1314,9 @@ _adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, if (rtw_handle_dualmac(padapter, 1) != _SUCCESS) goto free_adapter; - if((pnetdev = rtw_init_netdev(padapter)) == NULL) { - goto handle_dualmac; - } - SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); - padapter = rtw_netdev_priv(pnetdev); - -#ifdef CONFIG_IOCTL_CFG80211 - if(rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj)) != 0) { - goto handle_dualmac; - } -#endif + /* Code used to call rtw_init_netdev here, but MAC has not been probed + * yet, so moving it lower. --Ben + */ //step 2. hook HalFunc, allocate HalData //hal_set_hal_ops(padapter); @@ -1349,6 +1341,19 @@ _adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, //step read efuse/eeprom data and get mac_addr rtw_hal_read_chip_info(padapter); + /* Now that we have MAC, init the wiphy and such. --Ben */ + if((pnetdev = rtw_init_netdev(padapter)) == NULL) { + goto handle_dualmac; + } + SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); + padapter = rtw_netdev_priv(pnetdev); + +#ifdef CONFIG_IOCTL_CFG80211 + if(rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj)) != 0) { + goto handle_dualmac; + } +#endif + //step 5. if(rtw_init_drv_sw(padapter) ==_FAIL) { RT_TRACE(_module_hci_intfs_c_,_drv_err_,("Initialize driver software resource Failed!\n"));