From 0313f65a49a88fe337ea9b2ca52186232fa1b9f3 Mon Sep 17 00:00:00 2001 From: Sebastien Caps <493313+virer@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:04:14 +0200 Subject: [PATCH] Added lastest drv modif from upstream and fix for rhel9.4 --- os_dep/linux/ioctl_cfg80211.c | 33 ++++++++++++++++++-------------- os_dep/linux/os_intfs.c | 2 +- os_dep/linux/rtw_proc.c | 36 +++++++++++++++++------------------ os_dep/linux/wifi_regd.c | 3 ++- os_dep/osdep_service.c | 6 +++--- 5 files changed, 43 insertions(+), 37 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 340724f..1b4551d 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -460,7 +460,8 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) if (started) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 9, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 9, 0)) \ + || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) cfg80211_ch_switch_started_notify(adapter->pnetdev, &chdef, 0, 0, false, 0); #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) cfg80211_ch_switch_started_notify(adapter->pnetdev, &chdef, 0, 0, false); @@ -476,7 +477,8 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset, if (!rtw_cfg80211_allow_ch_switch_notify(adapter)) goto exit; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 9, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 9, 0)) \ + || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0, 0); #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0); @@ -1155,10 +1157,13 @@ check_bss: #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) - #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0) + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0) + #if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0) + #else roam_info.channel = notify_channel; roam_info.bssid = cur_network->network.MacAddress; #endif + #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; @@ -1738,7 +1743,7 @@ exit: } static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) , int link_id #endif , u8 key_index @@ -1885,7 +1890,7 @@ addkey_end: } static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) , int link_id #endif , u8 keyid @@ -2053,7 +2058,7 @@ exit: } static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) int link_id, #endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) @@ -2077,7 +2082,7 @@ 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, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) int link_id, #endif u8 key_index @@ -2129,7 +2134,7 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) int cfg80211_rtw_set_default_mgmt_key(struct wiphy *wiphy, struct net_device *ndev, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) int link_id, #endif u8 key_index) @@ -5286,7 +5291,7 @@ exit: return ret; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 7, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 7, 0)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_ap_update *params) { @@ -5318,10 +5323,10 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd return ret; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 2)) -static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) -#else +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 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 { _adapter *adapter = (_adapter *)rtw_netdev_priv(ndev); @@ -6194,7 +6199,7 @@ static int cfg80211_rtw_set_channel(struct wiphy *wiphy return 0; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, unsigned int link_id, struct cfg80211_chan_def *chandef){ #else static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, struct cfg80211_chan_def *chandef){ @@ -10487,7 +10492,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 (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) if (wdev->links[0].client.current_bss) { #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) if (wdev->connected) { diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 7dd35d8..9c5ba2f 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1703,7 +1703,7 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name) u8 rtnl_lock_needed = rtw_rtnl_lock_needed(dvobj); #ifdef CONFIG_RTW_NAPI -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) netif_napi_add_weight(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT); #else netif_napi_add(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT); diff --git a/os_dep/linux/rtw_proc.c b/os_dep/linux/rtw_proc.c index 840a675..3737f16 100644 --- a/os_dep/linux/rtw_proc.c +++ b/os_dep/linux/rtw_proc.c @@ -213,10 +213,10 @@ const int drv_proc_hdls_num = sizeof(drv_proc_hdls) / sizeof(struct rtw_proc_hdl static int rtw_drv_proc_open(struct inode *inode, struct file *file) { /* struct net_device *dev = proc_get_parent_data(inode); */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) - ssize_t index = (ssize_t)PDE_DATA(inode); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) + ssize_t index = (ssize_t)inode->i_private; #else - ssize_t index = (ssize_t)inode->i_private; + ssize_t index = (ssize_t)PDE_DATA(inode); #endif const struct rtw_proc_hdl *hdl = drv_proc_hdls + index; void *private = NULL; @@ -239,10 +239,10 @@ static int rtw_drv_proc_open(struct inode *inode, struct file *file) static ssize_t rtw_drv_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) - ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) + ssize_t index = (ssize_t)file_inode(file)->i_private; #else - ssize_t index = (ssize_t)file_inode(file)->i_private; + ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); #endif const struct rtw_proc_hdl *hdl = drv_proc_hdls + index; ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; @@ -4163,10 +4163,10 @@ const int adapter_proc_hdls_num = sizeof(adapter_proc_hdls) / sizeof(struct rtw_ static int rtw_adapter_proc_open(struct inode *inode, struct file *file) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) - ssize_t index = (ssize_t)PDE_DATA(inode); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) + ssize_t index = (ssize_t)inode->i_private; #else - ssize_t index = (ssize_t)inode->i_private; + ssize_t index = (ssize_t)PDE_DATA(inode); #endif const struct rtw_proc_hdl *hdl = adapter_proc_hdls + index; void *private = proc_get_parent_data(inode); @@ -4189,10 +4189,10 @@ static int rtw_adapter_proc_open(struct inode *inode, struct file *file) static ssize_t rtw_adapter_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) - ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) + ssize_t index = (ssize_t)file_inode(file)->i_private; #else - ssize_t index = (ssize_t)file_inode(file)->i_private; + ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); #endif const struct rtw_proc_hdl *hdl = adapter_proc_hdls + index; ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; @@ -4358,10 +4358,10 @@ const int odm_proc_hdls_num = sizeof(odm_proc_hdls) / sizeof(struct rtw_proc_hdl static int rtw_odm_proc_open(struct inode *inode, struct file *file) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) - ssize_t index = (ssize_t)PDE_DATA(inode); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) + ssize_t index = (ssize_t)inode->i_private; #else - ssize_t index = (ssize_t)inode->i_private; + ssize_t index = (ssize_t)PDE_DATA(inode); #endif const struct rtw_proc_hdl *hdl = odm_proc_hdls + index; void *private = proc_get_parent_data(inode); @@ -4384,10 +4384,10 @@ static int rtw_odm_proc_open(struct inode *inode, struct file *file) static ssize_t rtw_odm_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) - ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) + ssize_t index = (ssize_t)file_inode(file)->i_private; #else - ssize_t index = (ssize_t)file_inode(file)->i_private; + ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); #endif const struct rtw_proc_hdl *hdl = odm_proc_hdls + index; ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; diff --git a/os_dep/linux/wifi_regd.c b/os_dep/linux/wifi_regd.c index 45c5bd1..8b77a1f 100644 --- a/os_dep/linux/wifi_regd.c +++ b/os_dep/linux/wifi_regd.c @@ -401,11 +401,12 @@ static void _rtw_regd_init_wiphy(struct rtw_regulatory *reg, struct wiphy *wiphy * If build fails on kernel 6.2.x and you're not using Ubuntu, * try changing the version "(6, 3, 0)" below to "(6, 2, 0)". */ - +#if (! RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 39)) \ || (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 13)) \ || (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 4)) wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; +#endif #endif regd = _rtw_regdomain_select(reg); diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index d24b3e1..92c294e 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -1201,10 +1201,10 @@ inline void kthread_thread_exit(_completion *comp) #endif { #ifdef PLATFORM_LINUX -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) - complete_and_exit(comp, 0); -#else +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) || (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0)) kthread_complete_and_exit(comp, 0); +#else + complete_and_exit(comp, 0); #endif #endif