From 6115e6f3426e5da7bad52b4ec8d331a79b7ed50d Mon Sep 17 00:00:00 2001 From: Sebastien Caps <493313+virer@users.noreply.github.com> Date: Tue, 5 Dec 2023 09:06:43 +0100 Subject: [PATCH] Added fix/support for RHEL9 --- os_dep/linux/ioctl_cfg80211.c | 29 ++++++++++++++++------------- os_dep/linux/os_intfs.c | 2 +- os_dep/linux/rtw_proc.c | 32 ++++++++++++++++---------------- os_dep/osdep_service.c | 6 +++--- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 510fa45..1170335 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -460,7 +460,7 @@ 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)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 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 +476,7 @@ 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)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 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 +1155,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 +1741,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 +1888,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 +2056,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 +2080,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 +2132,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) @@ -5308,10 +5311,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); @@ -6184,7 +6187,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){ @@ -10477,7 +10480,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 2dadae0..0a92b3b 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1734,7 +1734,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..e8aa973 100644 --- a/os_dep/linux/rtw_proc.c +++ b/os_dep/linux/rtw_proc.c @@ -213,7 +213,7 @@ 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) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) && (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9, 0))) ssize_t index = (ssize_t)PDE_DATA(inode); #else ssize_t index = (ssize_t)inode->i_private; @@ -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)) + size_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); -#else +#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)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)); -#else +#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)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); -#else +#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)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)); -#else +#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)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/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