diff --git a/Makefile b/Makefile index 0f4fe12..9d740d8 100644 --- a/Makefile +++ b/Makefile @@ -401,7 +401,7 @@ EXTRA_CFLAGS += -DDM_ODM_SUPPORT_TYPE=0x04 ifeq ($(CONFIG_PLATFORM_I386_PC), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT -SUBARCH := $(shell uname -m | sed -e s/i.86/i386/) +SUBARCH := $(shell uname -m | sed -e "s/i.86/i386/; s/ppc/powerpc/; s/armv.l/arm/; s/aarch64/arm64/;") ARCH ?= $(SUBARCH) CROSS_COMPILE ?= KVER := $(shell uname -r) @@ -506,4 +506,3 @@ clean: rm -fr *.mod.c *.mod *.o .*.cmd *.ko *~ rm -fr .tmp_versions endif - diff --git a/README.md b/README.md index d45b34e..e04f54b 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,105 @@ -rtl8188fu for linux -=================== +RTL8188FU driver for Linux kernel 4.15.x ~ 6.7.x (Linux Mint, Ubuntu or Debian Derivatives) -rtl8188fu linux driver for wireless bgn device +info: rtl8188fu support added to rtl8xxxu module of Linux kernel with version 6.2. -Note: -This is an USB2 only adapter, -Source is ripped out of firefly source tree found at -https://gitlab.com/TeeFirefly/linux-kernel +------------------ -If one USB-ID is missing, please mail me. +## How to install -build/load/function tested with v4.19 +`sudo apt-get install build-essential git dkms linux-headers-$(uname -r)` -Building and install driver ---------------------------- +`git clone https://github.com/kelebek333/rtl8188fu` -for building type -`make` +`sudo dkms install ./rtl8188fu` -for load the driver -`sudo modprobe cfg80211` -`sudo insmod rtl8188fu.ko` +`sudo cp ./rtl8188fu/firmware/rtl8188fufw.bin /lib/firmware/rtlwifi/` -You need to install the needed fw with -`sudo make installfw` +------------------ -If you need to crosscompile use -`ARCH= CROSS_COMPILE= KSRC=` -while calling `make` i.e. +## Configuration -`make ARCH="arm" CROSS_COMPILE=armv5tel-softfloat-linux-gnueabi- KSRC=/home/linux-master modules` +#### Disable Power Management -Please use prefix **rtl8188fu** if you want to mail me -But please please don't, I have enough to do. -TIA +Run following commands for disable power management and plugging/replugging issues. -Hans Ulli Kroll +`sudo mkdir -p /etc/modprobe.d/` + +`sudo touch /etc/modprobe.d/rtl8188fu.conf` + +`echo "options rtl8188fu rtw_power_mgnt=0 rtw_enusbss=0 rtw_ips_mode=0" | sudo tee /etc/modprobe.d/rtl8188fu.conf` + +#### Disable MAC Address Spoofing + +Run following commands for disabling MAC Address Spoofing (Note: This is not needed on Ubuntu based distributions. MAC Address Spoofing is already disable on Ubuntu base). + +`sudo mkdir -p /etc/NetworkManager/conf.d/` + +`sudo touch /etc/NetworkManager/conf.d/disable-random-mac.conf` + +`echo -e "[device]\nwifi.scan-rand-mac-address=no" | sudo tee /etc/NetworkManager/conf.d/disable-random-mac.conf` + +#### Blacklist (alias) for kernel 5.15 and 5.16 (No needed for kernel 5.17 and up) + +If you are using kernel 5.15 and 5.16, you must create a configuration file with following command for preventing to conflict rtl8188fu module with built-in r8188eu module. + +`echo 'alias usb:v0BDApF179d*dc*dsc*dp*icFFiscFFipFFin* rtl8188fu' | sudo tee /etc/modprobe.d/r8188eu-blacklist.conf` + +#### Blacklist (alias) for kernel 6.2 and up + +If you are using kernel 6.2 and up, you must create a configuration file with following command for preventing to conflict rtl8188fu module with built-in rtl8xxxu module. + +`echo 'alias usb:v0BDApF179d*dc*dsc*dp*icFFiscFFipFFin* rtl8188fu' | sudo tee /etc/modprobe.d/rtl8xxxu-blacklist.conf` + +##### Then you must update initramfs + +For initramfs + +`sudo update-initramfs -u` + +For dracut + +`sudo dracut -q --force` + +##### Enable rtl8188fu module + +Run following command for up to kernel 6.1 + +`sudo modprobe rtl8188fu` + +Run following commands for kernel 6.2 and up + +`sudo modprobe -r rtl8188fu` + +`sudo modprobe rtl8188fu` + +------------------ + +## How to uninstall + +`sudo dkms remove rtl8188fu/1.0 --all` + +`sudo rm -f /lib/firmware/rtlwifi/rtl8188fufw.bin` + +`sudo rm -f /etc/modprobe.d/rtl8188fu.conf` + + +------------------ + +## How to install from PPA repository + +You can install rtl8188fu driver with following commands from PPA. + +for xUbuntu 16.04-18.04-20.04-22.04-23.04-23.10 / Linux Mint 20.x-21.x + +`sudo add-apt-repository ppa:kelebek333/kablosuz` + +`sudo apt-get update` + +`sudo apt install rtl8188fu-dkms` + + +You can purge packages with following commands + +`sudo apt purge rtl8188fu-dkms` + +------------------ diff --git a/core/efuse/rtw_efuse.c b/core/efuse/rtw_efuse.c index 48c9202..6e6c034 100644 --- a/core/efuse/rtw_efuse.c +++ b/core/efuse/rtw_efuse.c @@ -1590,7 +1590,9 @@ int storeAdaptorInfoFile(char *path, u8* efuse_data) int retriveAdaptorInfoFile(char *path, u8* efuse_data) { int ret = _SUCCESS; +#ifdef set_fs mm_segment_t oldfs; +#endif struct file *fp; if(path && efuse_data) { @@ -1626,7 +1628,9 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf) u32 ret = _FAIL; struct file *fp; +#ifdef set_fs mm_segment_t fs; +#endif loff_t pos = 0; fp = filp_open(path, O_RDONLY, 0); @@ -1643,8 +1647,10 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf) temp[2] = 0; /* add end of string '\0' */ +#ifdef set_fs fs = get_fs(); set_fs(KERNEL_DS); +#endif for (i = 0 ; i < HWSET_MAX_SIZE ; i++) { vfs_read(fp, temp, 2, &pos); @@ -1690,7 +1696,9 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf) u32 rtw_read_macaddr_from_file(const char *path, u8 *buf) { struct file *fp; +#ifdef set_fs mm_segment_t fs; +#endif loff_t pos = 0; u8 source_addr[18]; @@ -1712,8 +1720,10 @@ u32 rtw_read_macaddr_from_file(const char *path, u8 *buf) goto exit; } +#ifdef set_fs fs = get_fs(); set_fs(KERNEL_DS); +#endif vfs_read(fp, source_addr, 18, &pos); source_addr[17] = ':'; diff --git a/core/rtw_br_ext.c b/core/rtw_br_ext.c index 024049c..f3d27d6 100644 --- a/core/rtw_br_ext.c +++ b/core/rtw_br_ext.c @@ -22,7 +22,10 @@ #ifdef __KERNEL__ #include #include +#include +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 14, 0)) #include +#endif #include #include #include @@ -174,6 +177,7 @@ static __inline__ void __nat25_generate_ipv4_network_addr(unsigned char *network } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 14, 0)) static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) { @@ -205,6 +209,7 @@ static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networ memcpy(networkAddr+1, (unsigned char *)network, 2); networkAddr[3] = *node; } +#endif static __inline__ void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, @@ -931,6 +936,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method) } } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 14, 0)) /*---------------------------------------------------*/ /* Handle IPX and Apple Talk frame */ /*---------------------------------------------------*/ @@ -1191,6 +1197,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method) return -1; } +#endif /*---------------------------------------------------*/ /* Handle PPPoE frame */ diff --git a/core/rtw_btcoex.c b/core/rtw_btcoex.c index 3a5cfff..a3d249f 100644 --- a/core/rtw_btcoex.c +++ b/core/rtw_btcoex.c @@ -1435,7 +1435,9 @@ u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool for { u8 error; struct msghdr udpmsg; - mm_segment_t oldfs; +#ifdef set_fs + mm_segment_t oldfs; +#endif struct iovec iov; struct bt_coex_info *pcoex_info = &padapter->coex_info; @@ -1465,15 +1467,19 @@ u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool for udpmsg.msg_control = NULL; udpmsg.msg_controllen = 0; udpmsg.msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL; - oldfs = get_fs(); +#ifdef set_fs + oldfs = get_fs(); set_fs(KERNEL_DS); +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) error = sock_sendmsg(pcoex_info->udpsock, &udpmsg); #else error = sock_sendmsg(pcoex_info->udpsock, &udpmsg, msg_size); #endif +#ifdef set_fs set_fs(oldfs); +#endif if (error < 0) { DBG_871X("Error when sendimg msg, error:%d\n", error); return _FAIL; diff --git a/core/rtw_ieee80211.c b/core/rtw_ieee80211.c index 893be78..ded4e16 100644 --- a/core/rtw_ieee80211.c +++ b/core/rtw_ieee80211.c @@ -1406,7 +1406,9 @@ int rtw_get_mac_addr_intel(unsigned char *buf) int ret = 0; int i; struct file *fp = NULL; - mm_segment_t oldfs; +#ifdef set_fs + mm_segment_t oldfs; +#endif unsigned char c_mac[MAC_ADDRESS_LEN]; char fname[]="/config/wifi/mac.txt"; int jj,kk; diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 7c185f0..2137eb7 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -1188,7 +1188,9 @@ void mgt_dispatcher(_adapter *padapter, union recv_frame *precv_frame) ptable->func = &OnAuth; else ptable->func = &OnAuthClient; - //pass through +#if defined(fallthrough) + fallthrough; +#endif case WIFI_ASSOCREQ: case WIFI_REASSOCREQ: _mgt_dispatcher(padapter, ptable, precv_frame); @@ -15274,7 +15276,8 @@ u8 set_chplan_hdl(_adapter *padapter, unsigned char *pbuf) rtw_hal_set_odm_var(padapter,HAL_ODM_REGULATION,NULL,_TRUE); #ifdef CONFIG_IOCTL_CFG80211 - rtw_reg_notify_by_driver(padapter); + if (padapter->rtw_wdev != NULL) + rtw_reg_notify_by_driver(padapter->rtw_wdev->wiphy); #endif //CONFIG_IOCTL_CFG80211 return H2C_SUCCESS; diff --git a/core/rtw_security.c b/core/rtw_security.c index ebcecdc..ed5e9af 100644 --- a/core/rtw_security.c +++ b/core/rtw_security.c @@ -2281,7 +2281,7 @@ u32 rtw_BIP_verify(_adapter *padapter, u8 *precvframe) #ifndef PLATFORM_FREEBSD /* compress 512-bits */ -static int sha256_compress(struct sha256_state *md, unsigned char *buf) +static int sha256_compress(struct rtw_sha256_state *md, unsigned char *buf) { u32 S[8], W[64], t0, t1; u32 t; @@ -2323,7 +2323,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf) } /* Initialize the hash state */ -static void sha256_init(struct sha256_state *md) +static void sha256_init(struct rtw_sha256_state *md) { md->curlen = 0; md->length = 0; @@ -2344,7 +2344,7 @@ static void sha256_init(struct sha256_state *md) @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -static int sha256_process(struct sha256_state *md, unsigned char *in, +static int sha256_process(struct rtw_sha256_state *md, unsigned char *in, unsigned long inlen) { unsigned long n; @@ -2385,7 +2385,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in, @param out [out] The destination of the hash (32 bytes) @return CRYPT_OK if successful */ -static int sha256_done(struct sha256_state *md, unsigned char *out) +static int sha256_done(struct rtw_sha256_state *md, unsigned char *out) { int i; @@ -2437,7 +2437,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out) static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len, u8 *mac) { - struct sha256_state ctx; + struct rtw_sha256_state ctx; size_t i; sha256_init(&ctx); diff --git a/core/rtw_wlan_util.c b/core/rtw_wlan_util.c index b73ae4a..7ddbb1a 100644 --- a/core/rtw_wlan_util.c +++ b/core/rtw_wlan_util.c @@ -4169,7 +4169,9 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t* ssid, int i = 0; struct file *fp; +#ifdef set_fs mm_segment_t fs; +#endif loff_t pos = 0; u8 *source = NULL; long len = 0; @@ -4206,8 +4208,10 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t* ssid, return 0; } +#ifdef set_fs fs = get_fs(); set_fs(KERNEL_DS); +#endif source = rtw_zmalloc(2048); @@ -4217,7 +4221,9 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t* ssid, rtw_mfree(source, 2048); } +#ifdef set_fs set_fs(fs); +#endif filp_close(fp, NULL); DBG_871X("-%s-\n", __func__); diff --git a/dkms.conf b/dkms.conf new file mode 100644 index 0000000..2ccbfd4 --- /dev/null +++ b/dkms.conf @@ -0,0 +1,7 @@ +PACKAGE_NAME="rtl8188fu" +PACKAGE_VERSION="1.0" +BUILT_MODULE_NAME="rtl8188fu" +DEST_MODULE_LOCATION="/kernel/drivers/net/wireless/" +AUTOINSTALL="yes" +MAKE="'make' all KVER=${kernelver}" +CLEAN="make clean" diff --git a/hal/rtl8188f/usb/usb_halinit.c b/hal/rtl8188f/usb/usb_halinit.c index 2667655..edb8e5c 100644 --- a/hal/rtl8188f/usb/usb_halinit.c +++ b/hal/rtl8188f/usb/usb_halinit.c @@ -764,6 +764,9 @@ static void usb_AggSettingRxUpdate(PADAPTER padapter) aggctrl &= ~RXDMA_AGG_EN; aggrx &= ~BIT_USB_RXDMA_AGG_EN; rxdmamode &= ~BIT_DMA_MODE; +#if defined(fallthrough) + fallthrough; +#endif default: DBG_8192C("%s: RX Aggregation Disable!\n", __func__); break; diff --git a/hal/rtl8188f/usb/usb_ops.c b/hal/rtl8188f/usb/usb_ops.c index 2814eab..f6c8d79 100644 --- a/hal/rtl8188f/usb/usb_ops.c +++ b/hal/rtl8188f/usb/usb_ops.c @@ -487,7 +487,7 @@ int recvbuf2recvframe(PADAPTER padapter, void *ptr) } -void rtl8188fu_xmit_tasklet(void *priv) +void rtl8188fu_xmit_tasklet(unsigned long priv) { int ret = _FALSE; _adapter *padapter = (_adapter *)priv; diff --git a/include/autoconf.h b/include/autoconf.h index bec56f8..63171de 100644 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -302,7 +302,7 @@ /* * Debug Related Configure */ -#define CONFIG_DEBUG /* DBG_871X, etc... */ +// #define CONFIG_DEBUG /* DBG_871X, etc... */ #ifdef CONFIG_DEBUG #define DBG 1 /* for ODM & BTCOEX debug */ #define DBG_PHYDM_MORE 0 @@ -315,7 +315,7 @@ #define CONFIG_DEBUG_RTL871X /* RT_TRACE, RT_PRINT_DATA, _func_enter_, _func_exit_ */ #endif /* DBG_MORE */ -#define CONFIG_PROC_DEBUG +// #define CONFIG_PROC_DEBUG /* #define DBG_CONFIG_ERROR_DETECT diff --git a/include/ieee80211.h b/include/ieee80211.h index 8ed08a9..a556620 100644 --- a/include/ieee80211.h +++ b/include/ieee80211.h @@ -1390,18 +1390,31 @@ enum ieee80211_state { (((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \ (((Addr[5]) & 0xff) == 0xff)) #else +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)) +static inline int is_multicast_mac_addr(const u8 *addr) +#else extern __inline int is_multicast_mac_addr(const u8 *addr) +#endif { return ((addr[0] != 0xff) && (0x01 & addr[0])); } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)) +static inline int is_broadcast_mac_addr(const u8 *addr) +#else extern __inline int is_broadcast_mac_addr(const u8 *addr) +#endif + { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)) +static inline int is_zero_mac_addr(const u8 *addr) +#else extern __inline int is_zero_mac_addr(const u8 *addr) +#endif { return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \ (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00)); diff --git a/include/osdep_service.h b/include/osdep_service.h index a75e72e..e601e80 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -20,6 +20,10 @@ #ifndef __OSDEP_SERVICE_H_ #define __OSDEP_SERVICE_H_ +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#include +#endif #define _FAIL 0 #define _SUCCESS 1 @@ -631,4 +635,3 @@ char alpha_to_upper(char c); #endif - diff --git a/include/osdep_service_linux.h b/include/osdep_service_linux.h index c6b6ec7..ddd2fb2 100644 --- a/include/osdep_service_linux.h +++ b/include/osdep_service_linux.h @@ -162,7 +162,11 @@ typedef int thread_return; typedef void* thread_context; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) + #define thread_exit() kthread_complete_and_exit(NULL, 0) +#else #define thread_exit() complete_and_exit(NULL, 0) +#endif typedef void timer_hdl_return; typedef void* timer_hdl_context; diff --git a/include/rtl8188f_xmit.h b/include/rtl8188f_xmit.h index 265b887..3888cea 100644 --- a/include/rtl8188f_xmit.h +++ b/include/rtl8188f_xmit.h @@ -313,7 +313,7 @@ s32 rtl8188fu_hal_xmit(PADAPTER padapter, struct xmit_frame *pxmitframe); s32 rtl8188fu_mgnt_xmit(PADAPTER padapter, struct xmit_frame *pmgntframe); s32 rtl8188fu_hal_xmitframe_enqueue(_adapter *padapter, struct xmit_frame *pxmitframe); //s32 rtl8812au_xmit_buf_handler(PADAPTER padapter); -void rtl8188fu_xmit_tasklet(void *priv); +void rtl8188fu_xmit_tasklet(unsigned long priv); s32 rtl8188fu_xmitframe_complete(_adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); void _dbg_dump_tx_info(_adapter *padapter,int frame_tag,struct tx_desc *ptxdesc); #endif diff --git a/include/rtw_security.h b/include/rtw_security.h index 5ff7f7d..72138cb 100644 --- a/include/rtw_security.h +++ b/include/rtw_security.h @@ -238,7 +238,7 @@ struct security_priv #endif /* DBG_SW_SEC_CNT */ }; -struct sha256_state { +struct rtw_sha256_state { u64 length; u32 state[8], curlen; u8 buf[64]; @@ -484,4 +484,3 @@ u8 rtw_handle_tkip_countermeasure(_adapter* adapter, const char *caller); #endif //__RTL871X_SECURITY_H_ - diff --git a/include/rtw_wifi_regd.h b/include/rtw_wifi_regd.h index 13679b8..c23262a 100644 --- a/include/rtw_wifi_regd.h +++ b/include/rtw_wifi_regd.h @@ -20,8 +20,8 @@ enum country_code_type_t { COUNTRY_CODE_MAX }; -int rtw_regd_init(_adapter *padapter); -void rtw_reg_notify_by_driver(_adapter *adapter); +void rtw_regd_init(struct wiphy *wiphy); +void rtw_reg_notify_by_driver(struct wiphy *wiphy); #endif /* __RTW_WIFI_REGD_H__ */ diff --git a/include/usb_ops.h b/include/usb_ops.h index ee23314..d89b974 100644 --- a/include/usb_ops.h +++ b/include/usb_ops.h @@ -89,7 +89,7 @@ void interrupt_handler_8192eu(_adapter *padapter, u16 pkt_len, u8 *pbuf); void rtl8188fu_set_hw_type(struct dvobj_priv *pdvobj); void rtl8188fu_set_intf_ops(struct _io_ops *pops); void rtl8188fu_recv_tasklet(void *priv); -void rtl8188fu_xmit_tasklet(void *priv); +void rtl8188fu_xmit_tasklet(unsigned long priv); #ifdef CONFIG_SUPPORT_USB_INT void interrupt_handler_8188fu(_adapter *padapter, u16 pkt_len, u8 *pbuf); #endif diff --git a/include/usb_ops_linux.h b/include/usb_ops_linux.h index b0d0f43..c124efe 100644 --- a/include/usb_ops_linux.h +++ b/include/usb_ops_linux.h @@ -79,7 +79,7 @@ int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val); int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val); int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem); -void usb_recv_tasklet(void *priv); +void usb_recv_tasklet(unsigned long priv); #ifdef CONFIG_USB_INTERRUPT_IN_PIPE void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs); diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 3dd304a..ebc5376 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -355,8 +355,17 @@ rtw_cfg80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = { static u64 rtw_get_systime_us(void) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0)) + struct timespec64 ts; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)) + ktime_get_coarse_real_ts64(&ts); +#else + ts = current_kernel_time64(); +#endif +#else struct timespec ts; get_monotonic_boottime(&ts); +#endif return ((u64)ts.tv_sec*1000000) + ts.tv_nsec / 1000; #else struct timeval tv; @@ -816,7 +825,11 @@ void rtw_cfg80211_indicate_connect(_adapter *padapter) DBG_871X(FUNC_ADPT_FMT" call cfg80211_roamed\n", FUNC_ADPT_ARG(padapter)); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)) + roam_info.links[0].bssid = cur_network->network.MacAddress; +#else roam_info.bssid = cur_network->network.MacAddress; +#endif roam_info.req_ie = pmlmepriv->assoc_req+sizeof(struct rtw_ieee80211_hdr_3addr)+2; roam_info.req_ie_len = pmlmepriv->assoc_req_len-sizeof(struct rtw_ieee80211_hdr_3addr)-2; roam_info.resp_ie = pmlmepriv->assoc_rsp+sizeof(struct rtw_ieee80211_hdr_3addr)+6, @@ -1532,6 +1545,9 @@ _func_enter_; } static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)) + int link_id, +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) u8 key_index, bool pairwise, const u8 *mac_addr, #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) @@ -1683,6 +1699,9 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, } static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)) + int link_id, +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) u8 key_index, bool pairwise, const u8 *mac_addr, #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) @@ -1716,6 +1735,9 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, } static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)) + int link_id, +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) u8 key_index, bool pairwise, const u8 *mac_addr) #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) @@ -1737,7 +1759,11 @@ static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, } static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, - struct net_device *ndev, u8 key_index + struct net_device *ndev, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)) + int link_id, +#endif + u8 key_index #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) || defined(COMPAT_KERNEL_RELEASE) , bool unicast, bool multicast #endif @@ -4325,10 +4351,17 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, } static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *ndev, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 7, 0) + struct cfg80211_ap_update *params) +#else struct cfg80211_beacon_data *info) +#endif { int ret = 0; _adapter *adapter = (_adapter *)rtw_netdev_priv(ndev); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 7, 0) + struct cfg80211_beacon_data *info = ¶ms->beacon; +#endif DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); @@ -4337,7 +4370,11 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd return ret; } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)) +static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev, unsigned int link_id) +#else static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) +#endif { DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); return 0; @@ -5706,13 +5743,22 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, #else struct net_device *ndev, #endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)) + struct mgmt_frame_regs *upd) +#else u16 frame_type, bool reg) +#endif { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6 ,0)) struct net_device *ndev = wdev_to_ndev(wdev); #endif _adapter *adapter; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)) + u16 frame_type = BIT(upd->global_stypes << 4); + bool reg = false; +#endif + struct rtw_wdev_priv *pwdev_priv; if (ndev == NULL) @@ -6466,8 +6512,6 @@ void rtw_cfg80211_init_wiphy(_adapter *padapter) rtw_cfg80211_init_ht_capab(padapter, &bands->ht_cap, IEEE80211_BAND_5GHZ, rf_type); } #endif - /* init regulary domain */ - rtw_regd_init(padapter); /* copy mac_addr to wiphy */ _rtw_memcpy(wiphy->perm_addr, adapter_mac_addr(padapter), ETH_ALEN); @@ -6666,11 +6710,16 @@ static struct cfg80211_ops rtw_cfg80211_ops = { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) .mgmt_tx = cfg80211_rtw_mgmt_tx, - .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register, #elif (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,34) && LINUX_VERSION_CODE<=KERNEL_VERSION(2,6,35)) .action = cfg80211_rtw_mgmt_tx, #endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)) + .update_mgmt_frame_registrations = cfg80211_rtw_mgmt_frame_register, +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) + .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register, +#endif + #if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) .tdls_mgmt = cfg80211_rtw_tdls_mgmt, .tdls_oper = cfg80211_rtw_tdls_oper, @@ -6698,6 +6747,9 @@ struct wiphy *rtw_wiphy_alloc(_adapter *padapter, struct device *dev) rtw_cfg80211_preinit_wiphy(padapter, wiphy); + /* init regulary domain */ + rtw_regd_init(wiphy); + DBG_871X(FUNC_WIPHY_FMT"\n", FUNC_WIPHY_ARG(wiphy)); exit: @@ -6823,7 +6875,13 @@ void rtw_wdev_unregister(struct wireless_dev *wdev) rtw_cfg80211_indicate_scan_done(adapter, _TRUE); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) - if (wdev->current_bss) { + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)) + if (wdev->links[0].client.current_bss) { + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)) + if (wdev->connected) { + #else + if (wdev->current_bss) { + #endif u8 locally_generated = 1; DBG_871X(FUNC_ADPT_FMT" clear current_bss by cfg80211_disconnected\n", FUNC_ADPT_ARG(adapter)); cfg80211_disconnected(adapter->pnetdev, 0, NULL, 0, locally_generated, GFP_ATOMIC); @@ -6953,4 +7011,3 @@ void rtw_cfg80211_dev_res_unregister(struct dvobj_priv *dvobj) } #endif /* CONFIG_IOCTL_CFG80211 */ - diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index 67400e8..ce3833c 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -10669,7 +10669,11 @@ static int rtw_mp_efuse_set(struct net_device *dev, rtw_hal_read_chip_info(padapter); /* set mac addr*/ rtw_macaddr_cfg(adapter_mac_addr(padapter), get_hal_mac_addr(padapter)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) _rtw_memcpy(padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */ +#else + dev_addr_set(padapter->pnetdev, get_hal_mac_addr(padapter)); /* set mac addr to net_device */ +#endif #ifdef CONFIG_P2P rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter)); diff --git a/os_dep/linux/ioctl_mp.c b/os_dep/linux/ioctl_mp.c index a399795..661d472 100644 --- a/os_dep/linux/ioctl_mp.c +++ b/os_dep/linux/ioctl_mp.c @@ -48,7 +48,7 @@ int rtw_mp_write_reg(struct net_device *dev, u32 addr, data; int ret; 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; @@ -111,6 +111,7 @@ int rtw_mp_write_reg(struct net_device *dev, break; } + kfree(input); return ret; } @@ -130,7 +131,7 @@ 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 = kmalloc(wrqu->length, GFP_KERNEL); char *pch, *pnext, *ptmp; char *width_str; char width; @@ -244,6 +245,7 @@ int rtw_mp_read_reg(struct net_device *dev, break; } + kfree(input); return ret; } @@ -262,7 +264,7 @@ int rtw_mp_write_rf(struct net_device *dev, u32 path, addr, data; int ret; PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->length]; + char* input = kmalloc(wrqu->length, GFP_KERNEL); _rtw_memset(input, 0, wrqu->length); @@ -288,6 +290,7 @@ int rtw_mp_write_rf(struct net_device *dev, sprintf(extra, "write_rf completed\n"); wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -304,7 +307,7 @@ 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 = kmalloc(wrqu->length, GFP_KERNEL); char *pch, *pnext, *ptmp; char data[20], tmp[20], buf[3]; u32 path, addr, strtou; @@ -356,6 +359,7 @@ int rtw_mp_read_rf(struct net_device *dev, } wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -410,7 +414,7 @@ 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); PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); @@ -447,6 +451,7 @@ int rtw_mp_rate(struct net_device *dev, SetDataRate(padapter); wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -458,7 +463,7 @@ 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 cur_ch_offset; @@ -474,6 +479,7 @@ int rtw_mp_channel(struct net_device *dev, pHalData->CurrentChannel = channel; wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -486,7 +492,7 @@ int rtw_mp_bandwidth(struct net_device *dev, int cur_ch_offset; 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); if (copy_from_user(input, wrqu->pointer, wrqu->length)) return -EFAULT; @@ -510,6 +516,7 @@ int rtw_mp_bandwidth(struct net_device *dev, /*set_channel_bwmode(padapter, padapter->mppriv.channel, cur_ch_offset, bandwidth);*/ wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -519,7 +526,7 @@ 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 = kmalloc(wrqu->length, GFP_KERNEL); u32 rfpath; u32 txpower_inx; @@ -534,6 +541,7 @@ int rtw_mp_txpower_index(struct net_device *dev, sprintf(extra, " %d", txpower_inx); wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -544,7 +552,7 @@ int rtw_mp_txpower(struct net_device *dev, { u32 idx_a = 0, idx_b = 0, idx_c = 0, idx_d = 0, status = 0; int MsetPower = 1; - u8 input[wrqu->length]; + u8* input = kmalloc(wrqu->length, GFP_KERNEL); PADAPTER padapter = rtw_netdev_priv(dev); PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); @@ -573,6 +581,7 @@ int rtw_mp_txpower(struct net_device *dev, } wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -582,7 +591,7 @@ 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); HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); @@ -618,6 +627,7 @@ int rtw_mp_ant_tx(struct net_device *dev, SetAntenna(padapter); wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -628,7 +638,7 @@ 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); HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); @@ -664,6 +674,7 @@ int rtw_mp_ant_rx(struct net_device *dev, SetAntenna(padapter); wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -804,7 +815,7 @@ int rtw_mp_disable_bt_coexist(struct net_device *dev, HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); struct hal_ops *pHalFunc = &padapter->HalFunc; - u8 input[wrqu->data.length]; + u8* input = kmalloc(wrqu->data.length, GFP_KERNEL); u32 bt_coexist; if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) @@ -832,6 +843,7 @@ int rtw_mp_disable_bt_coexist(struct net_device *dev, #endif } + kfree(input); return 0; } @@ -842,7 +854,7 @@ int rtw_mp_arx(struct net_device *dev, { int bStartRx = 0, bStopRx = 0, bQueryPhy = 0, bQueryMac = 0, bSetBssid = 0; int bmac_filter = 0, bfilter_init = 0, bmon = 0, bSmpCfg = 0, bloopbk = 0; - u8 input[wrqu->length]; + u8* input = kmalloc(wrqu->length, GFP_KERNEL); char *pch, *ptmp, *token, *tmp[2] = {0x00, 0x00}; u32 i = 0, ii = 0, jj = 0, kk = 0, cnts = 0, ret; PADAPTER padapter = rtw_netdev_priv(dev); @@ -978,6 +990,7 @@ int rtw_mp_arx(struct net_device *dev, wrqu->length = strlen(extra) + 1; + kfree(input); return 0; } @@ -1020,7 +1033,7 @@ int rtw_mp_pwrtrk(struct net_device *dev, s32 ret; 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); if (copy_from_user(input, wrqu->pointer, wrqu->length)) return -EFAULT; @@ -1048,6 +1061,7 @@ int rtw_mp_pwrtrk(struct net_device *dev, wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -1058,7 +1072,7 @@ 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); if (copy_from_user(input, wrqu->pointer, wrqu->length)) return -EFAULT; @@ -1067,6 +1081,7 @@ int rtw_mp_psd(struct net_device *dev, wrqu->length = mp_query_psd(padapter, extra); + kfree(input); return 0; } @@ -1162,7 +1177,7 @@ 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); @@ -1177,6 +1192,7 @@ int rtw_mp_dump(struct net_device *dev, bb_reg_dump(RTW_DBGDUMP, padapter); rf_reg_dump(RTW_DBGDUMP, padapter); } + kfree(input); return 0; } @@ -1188,7 +1204,7 @@ 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, ret; if (copy_from_user(input, wrqu->pointer, wrqu->length)) @@ -1204,6 +1220,7 @@ int rtw_mp_phypara(struct net_device *dev, sprintf(extra, "Set xcap=%d", valxcap); wrqu->length = strlen(extra) + 1; + kfree(input); return 0; } @@ -1214,7 +1231,7 @@ int rtw_mp_SetRFPath(struct net_device *dev, struct iw_point *wrqu, char *extra) { PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->length]; + char* input = kmalloc(wrqu->length, GFP_KERNEL); int bMain = 1, bTurnoff = 1; DBG_871X("%s:iwpriv in=%s\n", __func__, input); @@ -1239,6 +1256,7 @@ int rtw_mp_SetRFPath(struct net_device *dev, wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -1248,7 +1266,7 @@ 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; PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter); @@ -1268,6 +1286,7 @@ int rtw_mp_QueryDrv(struct net_device *dev, sprintf(extra, "ok"); } wrqu->data.length = strlen(extra) + 1; + kfree(input); return 0; } @@ -1277,7 +1296,7 @@ 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; if (copy_from_user(input, wrqu->pointer, wrqu->length)) @@ -1293,6 +1312,7 @@ int rtw_mp_PwrCtlDM(struct net_device *dev, } wrqu->length = strlen(extra); + kfree(input); return 0; } @@ -1900,7 +1920,7 @@ int rtw_mp_hwtx(struct net_device *dev, PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); #if defined(CONFIG_RTL8814A) || defined(CONFIG_RTL8821B) || defined(CONFIG_RTL8822B) - u8 input[wrqu->data.length]; + u8* input = malloc(wrqu->data.length, GFP_KERNEL); if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) return -EFAULT; @@ -1912,6 +1932,7 @@ int rtw_mp_hwtx(struct net_device *dev, sprintf(extra, "Set PMac Tx Mode start\n"); wrqu->data.length = strlen(extra); + kfree(input); #endif return 0; diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index a78e317..7347a7f 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -811,7 +811,11 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *addr) } _rtw_memcpy(adapter_mac_addr(padapter), sa->sa_data, ETH_ALEN); /* set mac addr to adapter */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) + eth_hw_addr_set(pnetdev, sa->sa_data); +#else _rtw_memcpy(pnetdev->dev_addr, sa->sa_data, ETH_ALEN); /* set mac addr to net_device */ +#endif rtw_ps_deny(padapter, PS_DENY_IOCTL); LeaveAllPowerSaveModeDirect(padapter); /* leave PS mode for guaranteeing to access hw register successfully */ @@ -885,7 +889,7 @@ static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb #else , void *accel_priv #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) , select_queue_fallback_t fallback #endif @@ -1197,7 +1201,11 @@ int rtw_os_ndev_register(_adapter *adapter, char *name) /* alloc netdev name */ rtw_init_netdev_name(ndev, name); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) + eth_hw_addr_set(ndev, adapter_mac_addr(adapter)); +#else _rtw_memcpy(ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN); +#endif /* Tell the network stack we exist */ if (register_netdev(ndev) != 0) { @@ -3143,7 +3151,9 @@ static int route_dump(u32 *gw_addr ,int* gw_index) struct msghdr msg; struct iovec iov; struct sockaddr_nl nladdr; +#ifdef set_fs mm_segment_t oldfs; +#endif char *pg; int size = 0; @@ -3183,13 +3193,18 @@ static int route_dump(u32 *gw_addr ,int* gw_index) msg.msg_controllen = 0; msg.msg_flags = MSG_DONTWAIT; - oldfs = get_fs(); set_fs(KERNEL_DS); +#ifdef set_fs + oldfs = get_fs(); + set_fs(KERNEL_DS); +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) err = sock_sendmsg(sock, &msg); #else err = sock_sendmsg(sock, &msg, sizeof(req)); #endif +#ifdef set_fs set_fs(oldfs); +#endif if (err < 0) goto out_sock; @@ -3215,9 +3230,14 @@ static int route_dump(u32 *gw_addr ,int* gw_index) iov_iter_init(&msg.msg_iter, READ, &iov, 1, PAGE_SIZE); #endif - oldfs = get_fs(); set_fs(KERNEL_DS); +#ifdef set_fs + oldfs = get_fs(); + set_fs(KERNEL_DS); +#endif err = sock_recvmsg(sock, &msg, PAGE_SIZE, MSG_DONTWAIT); +#ifdef set_fs set_fs(oldfs); +#endif if (err < 0) goto out_sock_pg; @@ -3293,13 +3313,18 @@ static int route_dump(u32 *gw_addr ,int* gw_index) msg.msg_controllen = 0; msg.msg_flags=MSG_DONTWAIT; - oldfs = get_fs(); set_fs(KERNEL_DS); +#ifdef set_fs + oldfs = get_fs(); + set_fs(KERNEL_DS); +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) err = sock_sendmsg(sock, &msg); #else err = sock_sendmsg(sock, &msg, sizeof(req)); #endif +#ifdef set_fs set_fs(oldfs); +#endif if (err > 0) goto restart; diff --git a/os_dep/linux/rtw_proc.c b/os_dep/linux/rtw_proc.c index beda462..4038a96 100644 --- a/os_dep/linux/rtw_proc.c +++ b/os_dep/linux/rtw_proc.c @@ -44,6 +44,8 @@ inline struct proc_dir_entry *get_rtw_drv_proc(void) #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) #define PDE_DATA(inode) PDE((inode))->data #define proc_get_parent_data(inode) PDE((inode))->parent->data +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) +#define PDE_DATA(inode) pde_data(inode) #endif #if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) @@ -69,7 +71,12 @@ inline struct proc_dir_entry *rtw_proc_create_dir(const char *name, struct proc_ } inline struct proc_dir_entry *rtw_proc_create_entry(const char *name, struct proc_dir_entry *parent, - const struct file_operations *fops, void * data) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) + const struct file_operations *fops, +#else + const struct proc_ops *fops, +#endif + void * data) { struct proc_dir_entry *entry; @@ -202,6 +209,7 @@ static ssize_t rtw_drv_proc_write(struct file *file, const char __user *buffer, return -EROFS; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) static const struct file_operations rtw_drv_proc_fops = { .owner = THIS_MODULE, .open = rtw_drv_proc_open, @@ -210,6 +218,15 @@ static const struct file_operations rtw_drv_proc_fops = { .release = single_release, .write = rtw_drv_proc_write, }; +#else +static const struct proc_ops rtw_drv_proc_fops = { + .proc_open = rtw_drv_proc_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = seq_release, + .proc_write = rtw_drv_proc_write, +}; +#endif int rtw_drv_proc_init(void) { @@ -1720,6 +1737,7 @@ static ssize_t rtw_adapter_proc_write(struct file *file, const char __user *buff return -EROFS; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) static const struct file_operations rtw_adapter_proc_fops = { .owner = THIS_MODULE, .open = rtw_adapter_proc_open, @@ -1728,6 +1746,15 @@ static const struct file_operations rtw_adapter_proc_fops = { .release = single_release, .write = rtw_adapter_proc_write, }; +#else +static const struct proc_ops rtw_adapter_proc_fops = { + .proc_open = rtw_adapter_proc_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = seq_release, + .proc_write = rtw_adapter_proc_write, +}; +#endif int proc_get_odm_dbg_comp(struct seq_file *m, void *v) { @@ -1994,6 +2021,7 @@ static ssize_t rtw_odm_proc_write(struct file *file, const char __user *buffer, return -EROFS; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) static const struct file_operations rtw_odm_proc_fops = { .owner = THIS_MODULE, .open = rtw_odm_proc_open, @@ -2002,7 +2030,15 @@ static const struct file_operations rtw_odm_proc_fops = { .release = single_release, .write = rtw_odm_proc_write, }; - +#else +static const struct proc_ops rtw_odm_proc_fops = { + .proc_open = rtw_odm_proc_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = seq_release, + .proc_write = rtw_odm_proc_write, +}; +#endif struct proc_dir_entry *rtw_odm_proc_init(struct net_device *dev) { struct proc_dir_entry *dir_odm = NULL; @@ -2158,4 +2194,3 @@ void rtw_adapter_proc_replace(struct net_device *dev) } #endif /* CONFIG_PROC_DEBUG */ - diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index c10592b..72d9e16 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -161,7 +161,7 @@ struct rtw_usb_drv usb_drv = { .usbdrv.supports_autosuspend = 1, #endif - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)) .usbdrv.drvwrap.driver.shutdown = rtw_dev_shutdown, #else .usbdrv.driver.shutdown = rtw_dev_shutdown, diff --git a/os_dep/linux/usb_ops_linux.c b/os_dep/linux/usb_ops_linux.c index a3e1ebb..1c1f563 100644 --- a/os_dep/linux/usb_ops_linux.c +++ b/os_dep/linux/usb_ops_linux.c @@ -741,7 +741,7 @@ void usb_init_recvbuf(_adapter *padapter, struct recv_buf *precvbuf) int recvbuf2recvframe(PADAPTER padapter, void *ptr); #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX -void usb_recv_tasklet(void *priv) +void usb_recv_tasklet(unsigned long priv) { struct recv_buf *precvbuf = NULL; _adapter *padapter = (_adapter*)priv; @@ -904,7 +904,7 @@ _func_exit_; } #else // CONFIG_USE_USB_BUFFER_ALLOC_RX -void usb_recv_tasklet(void *priv) +void usb_recv_tasklet(unsigned long priv) { _pkt *pskb; _adapter *padapter = (_adapter*)priv; diff --git a/os_dep/linux/wifi_regd.c b/os_dep/linux/wifi_regd.c index 8f094e1..f4c179c 100644 --- a/os_dep/linux/wifi_regd.c +++ b/os_dep/linux/wifi_regd.c @@ -484,12 +484,12 @@ void rtw_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) #endif } -void rtw_reg_notify_by_driver(_adapter *adapter) +void rtw_reg_notify_by_driver(struct wiphy *wiphy) { - if ((adapter->rtw_wdev != NULL) && (adapter->rtw_wdev->wiphy)) { + if (wiphy) { struct regulatory_request request; request.initiator = NL80211_REGDOM_SET_BY_DRIVER; - rtw_reg_notifier(adapter->rtw_wdev->wiphy, &request); + rtw_reg_notifier(wiphy, &request); } } @@ -529,28 +529,9 @@ static struct country_code_to_enum_rd *_rtw_regd_find_country(u16 countrycode) return NULL; } -int rtw_regd_init(_adapter * padapter) +void rtw_regd_init(struct wiphy *wiphy) { - struct wiphy *wiphy = padapter->rtw_wdev->wiphy; - -#if 0 - if (rtw_regd == NULL) { - rtw_regd = (struct rtw_regulatory *) - rtw_malloc(sizeof(struct rtw_regulatory)); - - rtw_regd->alpha2[0] = '9'; - rtw_regd->alpha2[1] = '9'; - - rtw_regd->country_code = COUNTRY_CODE_USER; - } - - DBG_8192C("%s: Country alpha2 being used: %c%c\n", - __func__, rtw_regd->alpha2[0], rtw_regd->alpha2[1]); -#endif - _rtw_regd_init_wiphy(NULL, wiphy); - - return 0; } #endif //CONFIG_IOCTL_CFG80211 diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index a1b40e9..7036052 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -32,6 +32,10 @@ atomic_t _malloc_size = ATOMIC_INIT(0); #endif #endif /* DBG_MEMORY_LEAK */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) +#define __vfs_read vfs_read +#endif + #if defined(PLATFORM_LINUX) /* @@ -1957,7 +1961,9 @@ static int isFileReadable(char *path) { struct file *fp; int ret = 0; +#ifdef set_fs mm_segment_t oldfs; +#endif char buf; fp=filp_open(path, O_RDONLY, 0); @@ -1965,12 +1971,17 @@ static int isFileReadable(char *path) ret = PTR_ERR(fp); } else { - oldfs = get_fs(); set_fs(get_ds()); +#ifdef set_fs + oldfs = get_fs(); + set_fs(KERNEL_DS); +#endif if(1!=readFile(fp, &buf, 1)) ret = PTR_ERR(fp); +#ifdef set_fs set_fs(oldfs); +#endif filp_close(fp,NULL); } return ret; @@ -1986,16 +1997,23 @@ static int isFileReadable(char *path) static int retriveFromFile(char *path, u8* buf, u32 sz) { int ret =-1; +#ifdef set_fs mm_segment_t oldfs; +#endif struct file *fp; if(path && buf) { if( 0 == (ret=openFile(&fp,path, O_RDONLY, 0)) ){ DBG_871X("%s openFile path:%s fp=%p\n",__FUNCTION__, path ,fp); - oldfs = get_fs(); set_fs(get_ds()); +#ifdef set_fs + oldfs = get_fs(); + set_fs(KERNEL_DS); ret=readFile(fp, buf, sz); set_fs(oldfs); +#else + ret=readFile(fp, buf, sz); +#endif closeFile(fp); DBG_871X("%s readFile, ret:%d\n",__FUNCTION__, ret); @@ -2020,16 +2038,23 @@ static int retriveFromFile(char *path, u8* buf, u32 sz) static int storeToFile(char *path, u8* buf, u32 sz) { int ret =0; +#ifdef set_fs mm_segment_t oldfs; +#endif struct file *fp; if(path && buf) { if( 0 == (ret=openFile(&fp, path, O_CREAT|O_WRONLY, 0666)) ) { DBG_871X("%s openFile path:%s fp=%p\n",__FUNCTION__, path ,fp); - oldfs = get_fs(); set_fs(get_ds()); +#ifdef set_fs + oldfs = get_fs(); + set_fs(KERNEL_DS); ret=writeFile(fp, buf, sz); set_fs(oldfs); +#else + ret=writeFile(fp, buf, sz); +#endif closeFile(fp); DBG_871X("%s writeFile, ret:%d\n",__FUNCTION__, ret); @@ -2191,7 +2216,11 @@ int rtw_change_ifname(_adapter *padapter, const char *ifname) rtw_init_netdev_name(pnetdev, ifname); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); +#else + dev_addr_set(pnetdev, adapter_mac_addr(padapter)); +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) if(!rtnl_is_locked()) @@ -2318,7 +2347,11 @@ inline u32 rtw_random32(void) { #ifdef PLATFORM_LINUX #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) + #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) + return get_random_u32(); + #else return prandom_u32(); + #endif #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)) u32 random_int; get_random_bytes( &random_int , 4 ); @@ -2514,4 +2547,3 @@ inline char alpha_to_upper(char c) c = 'A' + (c - 'a'); return c; } -