From 5d8efec3f6128c0b925cf8fab0a536231176ffde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Guti=C3=83errez?= Date: Sat, 27 Mar 2021 22:02:36 +0100 Subject: [PATCH 1/8] fix for interface changes --- os_dep/osdep_service.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 0d11234..e4893a7 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -1957,13 +1957,8 @@ static int isFileReadable(char *path) ret = PTR_ERR(fp); } else { - oldfs = get_fs(); set_fs(KERNEL_DS); - - if(1!=readFile(fp, &buf, 1)) - ret = PTR_ERR(fp); - - set_fs(oldfs); - filp_close(fp,NULL); + ret = kernel_read(fp, &buf, 1, NULL); + closeFile(fp); } return ret; } @@ -1984,10 +1979,7 @@ static int retriveFromFile(char *path, u8* buf, u32 sz) 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(KERNEL_DS); - ret=readFile(fp, buf, sz); - set_fs(oldfs); + ret = kernel_read(fp, buf, sz, NULL); closeFile(fp); DBG_871X("%s readFile, ret:%d\n",__FUNCTION__, ret); @@ -2018,10 +2010,7 @@ static int storeToFile(char *path, u8* buf, u32 sz) 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(KERNEL_DS); - ret=writeFile(fp, buf, sz); - set_fs(oldfs); + ret = kernel_write(fp, buf, sz, NULL); closeFile(fp); DBG_871X("%s writeFile, ret:%d\n",__FUNCTION__, ret); From be07a12d4b528977b6029017e8893ce57c2f723b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Guti=C3=83errez?= Date: Sat, 27 Mar 2021 22:03:09 +0100 Subject: [PATCH 2/8] delete unused variables --- os_dep/osdep_service.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index e4893a7..f178f1b 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -1949,7 +1949,6 @@ static int isFileReadable(char *path) { struct file *fp; int ret = 0; - mm_segment_t oldfs; char buf; fp=filp_open(path, O_RDONLY, 0); @@ -1973,7 +1972,6 @@ static int isFileReadable(char *path) static int retriveFromFile(char *path, u8* buf, u32 sz) { int ret =-1; - mm_segment_t oldfs; struct file *fp; if(path && buf) { @@ -2004,7 +2002,6 @@ static int retriveFromFile(char *path, u8* buf, u32 sz) static int storeToFile(char *path, u8* buf, u32 sz) { int ret =0; - mm_segment_t oldfs; struct file *fp; if(path && buf) { From e9319db7e776206cd5d67b1830b91e982f367c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Guti=C3=83errez?= Date: Sat, 27 Mar 2021 22:13:58 +0100 Subject: [PATCH 3/8] apply patch from https://github.com/armbian/build/commit/61ba606f4ac50c56d4e92b5505bbe3c4e9fa317c --- core/rtw_mlme_ext.c | 4 +++- include/rtw_wifi_regd.h | 4 ++-- os_dep/linux/ioctl_cfg80211.c | 5 ++--- os_dep/linux/wifi_regd.c | 27 ++++----------------------- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 4027046..19e91e2 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -15121,7 +15121,9 @@ 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/include/rtw_wifi_regd.h b/include/rtw_wifi_regd.h index aea6365..e6ac7df 100644 --- a/include/rtw_wifi_regd.h +++ b/include/rtw_wifi_regd.h @@ -19,8 +19,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/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index e5e0592..35b107a 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -6444,9 +6444,6 @@ void rtw_cfg80211_init_wiphy(_adapter *padapter) rtw_cfg80211_init_ht_capab(padapter, &bands->ht_cap, NL80211_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); @@ -6679,6 +6676,8 @@ struct wiphy *rtw_wiphy_alloc(_adapter *padapter, struct device *dev) *((_adapter**)wiphy_priv(wiphy)) = padapter; rtw_cfg80211_preinit_wiphy(padapter, wiphy); + /* init regulatory domain */ + rtw_regd_init(wiphy); DBG_871X(FUNC_WIPHY_FMT"\n", FUNC_WIPHY_ARG(wiphy)); diff --git a/os_dep/linux/wifi_regd.c b/os_dep/linux/wifi_regd.c index 838f982..72c1ff1 100644 --- a/os_dep/linux/wifi_regd.c +++ b/os_dep/linux/wifi_regd.c @@ -476,12 +476,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); } } @@ -521,28 +521,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 From bdd61e6735eef3ac4b7c6763060e6e1ca72d01a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Guti=C3=83errez?= Date: Sat, 27 Mar 2021 22:02:36 +0100 Subject: [PATCH 4/8] Fix for interface changes for 5.10 --- core/rtw_mlme_ext.c | 4 +++- include/rtw_wifi_regd.h | 4 ++-- os_dep/linux/ioctl_cfg80211.c | 5 ++--- os_dep/linux/wifi_regd.c | 27 ++++----------------------- os_dep/osdep_service.c | 22 ++++------------------ 5 files changed, 15 insertions(+), 47 deletions(-) diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 4027046..19e91e2 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -15121,7 +15121,9 @@ 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/include/rtw_wifi_regd.h b/include/rtw_wifi_regd.h index aea6365..e6ac7df 100644 --- a/include/rtw_wifi_regd.h +++ b/include/rtw_wifi_regd.h @@ -19,8 +19,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/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index e5e0592..35b107a 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -6444,9 +6444,6 @@ void rtw_cfg80211_init_wiphy(_adapter *padapter) rtw_cfg80211_init_ht_capab(padapter, &bands->ht_cap, NL80211_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); @@ -6679,6 +6676,8 @@ struct wiphy *rtw_wiphy_alloc(_adapter *padapter, struct device *dev) *((_adapter**)wiphy_priv(wiphy)) = padapter; rtw_cfg80211_preinit_wiphy(padapter, wiphy); + /* init regulatory domain */ + rtw_regd_init(wiphy); DBG_871X(FUNC_WIPHY_FMT"\n", FUNC_WIPHY_ARG(wiphy)); diff --git a/os_dep/linux/wifi_regd.c b/os_dep/linux/wifi_regd.c index 838f982..72c1ff1 100644 --- a/os_dep/linux/wifi_regd.c +++ b/os_dep/linux/wifi_regd.c @@ -476,12 +476,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); } } @@ -521,28 +521,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 0d11234..f178f1b 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -1949,7 +1949,6 @@ static int isFileReadable(char *path) { struct file *fp; int ret = 0; - mm_segment_t oldfs; char buf; fp=filp_open(path, O_RDONLY, 0); @@ -1957,13 +1956,8 @@ static int isFileReadable(char *path) ret = PTR_ERR(fp); } else { - oldfs = get_fs(); set_fs(KERNEL_DS); - - if(1!=readFile(fp, &buf, 1)) - ret = PTR_ERR(fp); - - set_fs(oldfs); - filp_close(fp,NULL); + ret = kernel_read(fp, &buf, 1, NULL); + closeFile(fp); } return ret; } @@ -1978,16 +1972,12 @@ static int isFileReadable(char *path) static int retriveFromFile(char *path, u8* buf, u32 sz) { int ret =-1; - mm_segment_t oldfs; 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(KERNEL_DS); - ret=readFile(fp, buf, sz); - set_fs(oldfs); + ret = kernel_read(fp, buf, sz, NULL); closeFile(fp); DBG_871X("%s readFile, ret:%d\n",__FUNCTION__, ret); @@ -2012,16 +2002,12 @@ static int retriveFromFile(char *path, u8* buf, u32 sz) static int storeToFile(char *path, u8* buf, u32 sz) { int ret =0; - mm_segment_t oldfs; 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(KERNEL_DS); - ret=writeFile(fp, buf, sz); - set_fs(oldfs); + ret = kernel_write(fp, buf, sz, NULL); closeFile(fp); DBG_871X("%s writeFile, ret:%d\n",__FUNCTION__, ret); From 2b9ebf386e7212a553426e8c6965babd57422a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Guti=C3=83errez?= Date: Wed, 3 Nov 2021 22:54:09 +0100 Subject: [PATCH 5/8] Remove ipx support to build on 5.15 --- core/rtw_br_ext.c | 172 +--------------------------------------------- 1 file changed, 1 insertion(+), 171 deletions(-) diff --git a/core/rtw_br_ext.c b/core/rtw_br_ext.c index 024049c..ed74982 100644 --- a/core/rtw_br_ext.c +++ b/core/rtw_br_ext.c @@ -22,7 +22,6 @@ #ifdef __KERNEL__ #include #include -#include #include #include #include @@ -174,27 +173,6 @@ static __inline__ void __nat25_generate_ipv4_network_addr(unsigned char *network } -static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); - memcpy(networkAddr+5, ipxNodeAddr, 6); -} - - -static __inline__ void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); - memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2); -} - static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networkAddr, unsigned short *network, unsigned char *node) @@ -938,160 +916,12 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method) (protocol == __constant_htons(ETH_P_ATALK)) || (protocol == __constant_htons(ETH_P_AARP))) { - unsigned char ipx_header[2] = {0xFF, 0xFF}; - struct ipxhdr *ipx = NULL; struct elapaarp *ea = NULL; struct ddpehdr *ddp = NULL; unsigned char *framePtr = skb->data + ETH_HLEN; - if(protocol == __constant_htons(ETH_P_IPX)) - { - DBG_871X("NAT25: Protocol=IPX (Ethernet II)\n"); - ipx = (struct ipxhdr *)framePtr; - } - else //if(protocol <= __constant_htons(ETH_FRAME_LEN)) - { - if(!memcmp(ipx_header, framePtr, 2)) - { - DBG_871X("NAT25: Protocol=IPX (Ethernet 802.3)\n"); - ipx = (struct ipxhdr *)framePtr; - } - else - { - unsigned char ipx_8022_type = 0xE0; - unsigned char snap_8022_type = 0xAA; - - if(*framePtr == snap_8022_type) - { - unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; // IPX SNAP ID - unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; // Apple Talk AARP SNAP ID - unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; // Apple Talk DDP SNAP ID - - framePtr += 3; // eliminate the 802.2 header - - if(!memcmp(ipx_snap_id, framePtr, 5)) - { - framePtr += 5; // eliminate the SNAP header - - DBG_871X("NAT25: Protocol=IPX (Ethernet SNAP)\n"); - ipx = (struct ipxhdr *)framePtr; - } - else if(!memcmp(aarp_snap_id, framePtr, 5)) - { - framePtr += 5; // eliminate the SNAP header - - ea = (struct elapaarp *)framePtr; - } - else if(!memcmp(ddp_snap_id, framePtr, 5)) - { - framePtr += 5; // eliminate the SNAP header - - ddp = (struct ddpehdr *)framePtr; - } - else - { - DEBUG_WARN("NAT25: Protocol=Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0], - framePtr[1], framePtr[2], framePtr[3], framePtr[4]); - return -1; - } - } - else if(*framePtr == ipx_8022_type) - { - framePtr += 3; // eliminate the 802.2 header - - if(!memcmp(ipx_header, framePtr, 2)) - { - DBG_871X("NAT25: Protocol=IPX (Ethernet 802.2)\n"); - ipx = (struct ipxhdr *)framePtr; - } - else - return -1; - } - } - } - - /* IPX */ - if(ipx != NULL) - { - switch(method) - { - case NAT25_CHECK: - if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) - { - DBG_871X("NAT25: Check IPX skb_copy\n"); - return 0; - } - return -1; - - case NAT25_INSERT: - { - DBG_871X("NAT25: Insert IPX, Dest=%08x,%02x%02x%02x%02x%02x%02x,%04x Source=%08x,%02x%02x%02x%02x%02x%02x,%04x\n", - ipx->ipx_dest.net, - ipx->ipx_dest.node[0], - ipx->ipx_dest.node[1], - ipx->ipx_dest.node[2], - ipx->ipx_dest.node[3], - ipx->ipx_dest.node[4], - ipx->ipx_dest.node[5], - ipx->ipx_dest.sock, - ipx->ipx_source.net, - ipx->ipx_source.node[0], - ipx->ipx_source.node[1], - ipx->ipx_source.node[2], - ipx->ipx_source.node[3], - ipx->ipx_source.node[4], - ipx->ipx_source.node[5], - ipx->ipx_source.sock); - - if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) - { - DBG_871X("NAT25: Use IPX Net, and Socket as network addr\n"); - - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock); - - // change IPX source node addr to wlan STA address - memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN); - } - else - { - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node); - } - - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - } - return 0; - - case NAT25_LOOKUP: - { - if(!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN)) - { - DBG_871X("NAT25: Lookup IPX, Modify Destination IPX Node addr\n"); - - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - - // replace IPX destination node addr with Lookup destination MAC addr - memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN); - } - else - { - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - } - } - return 0; - - default: - return -1; - } - } - /* AARP */ - else if(ea != NULL) + if(ea != NULL) { /* Sanity check fields. */ if(ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) From 530f10b9e557502916145d339d296328e903f53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Guti=C3=83errez?= Date: Fri, 27 May 2022 22:19:25 +0200 Subject: [PATCH 6/8] Changes for 5.17 --- include/osdep_service_linux.h | 4 ++++ os_dep/linux/rtw_proc.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/include/osdep_service_linux.h b/include/osdep_service_linux.h index 1814045..19388f2 100644 --- a/include/osdep_service_linux.h +++ b/include/osdep_service_linux.h @@ -167,7 +167,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/os_dep/linux/rtw_proc.c b/os_dep/linux/rtw_proc.c index 0e69ef6..c5aeaff 100644 --- a/os_dep/linux/rtw_proc.c +++ b/os_dep/linux/rtw_proc.c @@ -37,6 +37,9 @@ inline struct proc_dir_entry *get_rtw_drv_proc(void) #define RTW_PROC_NAME DRV_NAME +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)) +#define PDE_DATA(inode) pde_data(inode) +#endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) #define file_inode(file) ((file)->f_dentry->d_inode) #endif From d95287c99d1335daaecbc6b21eed387d9524c6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Guti=C3=83errez?= Date: Sun, 20 Nov 2022 22:29:23 +0100 Subject: [PATCH 7/8] Fix build for newer kernels --- Makefile | 17 +++++++++++++++-- include/ieee80211.h | 12 ++++++++---- os_dep/linux/addr_utils.c | 18 ++++++++++++++++++ os_dep/linux/ioctl_cfg80211.c | 4 ++-- 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 os_dep/linux/addr_utils.c diff --git a/Makefile b/Makefile index c53ae39..79723b3 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,8 @@ CONFIG_AP_WOWLAN = n ######### Notify SDIO Host Keep Power During Syspend ########## CONFIG_RTW_SDIO_PM_KEEP_POWER = n ###################### Platform Related ####################### -CONFIG_PLATFORM_I386_PC = y +CONFIG_PLATFORM_I386_PC = n +CONFIG_PLATFORM_PINEBOOK = y CONFIG_PLATFORM_ANDROID_X86 = n CONFIG_PLATFORM_ANDROID_INTEL_X86 = n CONFIG_PLATFORM_JB_X86 = n @@ -159,7 +160,8 @@ _OS_INTFS_FILES := os_dep/osdep_service.o \ os_dep/linux/rtw_cfgvendor.o \ os_dep/linux/wifi_regd.o \ os_dep/linux/rtw_android.o \ - os_dep/linux/rtw_proc.o + os_dep/linux/rtw_proc.o \ + os_dep/linux/addr_utils.o ifeq ($(CONFIG_MP_INCLUDED), y) _OS_INTFS_FILES += os_dep/linux/ioctl_mp.o @@ -892,6 +894,17 @@ endif EXTRA_CFLAGS += -DDM_ODM_SUPPORT_TYPE=0x04 +ifeq ($(CONFIG_PLATFORM_PINEBOOK), y) +EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN +EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT +ARCH := arm64 +CROSS_COMPILE ?= +KVER := $(shell uname -r) +KSRC := /lib/modules/$(KVER)/build +MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/ +INSTALL_PREFIX := +endif + ifeq ($(CONFIG_PLATFORM_I386_PC), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT diff --git a/include/ieee80211.h b/include/ieee80211.h index 032d5ef..f2f8904 100644 --- a/include/ieee80211.h +++ b/include/ieee80211.h @@ -1390,22 +1390,26 @@ enum ieee80211_state { (((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \ (((Addr[5]) & 0xff) == 0xff)) #else -extern __inline int is_multicast_mac_addr(const u8 *addr) +int is_multicast_mac_addr(const u8 *addr); +int is_broadcast_mac_addr(const u8 *addr); +int is_zero_mac_addr(const u8 *addr); +/* +extern int is_multicast_mac_addr(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } -extern __inline int is_broadcast_mac_addr(const u8 *addr) +extern int is_broadcast_mac_addr(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); } -extern __inline int is_zero_mac_addr(const u8 *addr) +extern int is_zero_mac_addr(const u8 *addr) { return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \ (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00)); -} +}*/ #endif //PLATFORM_FREEBSD #define CFG_IEEE80211_RESERVE_FCS (1<<0) diff --git a/os_dep/linux/addr_utils.c b/os_dep/linux/addr_utils.c new file mode 100644 index 0000000..5007372 --- /dev/null +++ b/os_dep/linux/addr_utils.c @@ -0,0 +1,18 @@ +#include /* tolower() */ + +int is_multicast_mac_addr(const u8 *addr) +{ + return ((addr[0] != 0xff) && (0x01 & addr[0])); +} + +int is_broadcast_mac_addr(const u8 *addr) +{ + return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ + (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); +} + +int is_zero_mac_addr(const u8 *addr) +{ + return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \ + (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00)); +} diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 35b107a..a9b9ebf 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -4302,7 +4302,7 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd return ret; } -static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) +static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev, unsigned int notify) { DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); return 0; @@ -6812,7 +6812,7 @@ void rtw_wdev_unregister(struct wireless_dev *wdev) rtw_cfg80211_indicate_scan_done(adapter, _TRUE); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) || defined(COMPAT_KERNEL_RELEASE) - if (wdev->current_bss) { + if (wdev->u.ibss.current_bss) { DBG_871X(FUNC_ADPT_FMT" clear current_bss by cfg80211_disconnected\n", FUNC_ADPT_ARG(adapter)); #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) cfg80211_disconnected(adapter->pnetdev, 0, NULL, 0, GFP_ATOMIC); From b71593a785bf4ab4c101402b3043f7fee922d4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Guti=C3=83errez?= Date: Tue, 4 Jul 2023 16:42:08 +0200 Subject: [PATCH 8/8] fix for 6.x kernels --- os_dep/linux/ioctl_cfg80211.c | 27 +++++++++++++++++++++------ os_dep/osdep_service.c | 4 +++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index a9b9ebf..f741542 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -808,8 +808,13 @@ check_bss: 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].channel = notify_channel; + roam_info.links[0].bssid = cur_network->network.MacAddress; +#else roam_info.channel = notify_channel; roam_info.bssid = cur_network->network.MacAddress; +#endif roam_info.req_ie = pmlmepriv->assoc_req+sizeof(struct ieee80211_hdr_3addr)+2; roam_info.req_ie_len = @@ -1517,9 +1522,11 @@ exit: } static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,0,0)) + int link_id, u8 key_index, bool pairwise, const u8 *mac_addr, +#elif (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)) +#else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) u8 key_index, const u8 *mac_addr, #endif // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) struct key_params *params) @@ -1668,7 +1675,9 @@ addkey_end: } static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,0,0)) + int link_id, u8 key_index, bool pairwise, const u8 *mac_addr, +#elif (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)) u8 key_index, const u8 *mac_addr, @@ -1701,7 +1710,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(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,0,0)) + int link_id, u8 key_index, bool pairwise, const u8 *mac_addr) +#elif (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)) u8 key_index, const u8 *mac_addr) @@ -1722,9 +1733,13 @@ 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,0,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 + bool unicast, bool multicast #endif ) { diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index f178f1b..3d96afd 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -2312,7 +2312,9 @@ u64 rtw_division64(u64 x, u64 y) 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(); + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) return prandom_u32(); #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)) u32 random_int;