RinCat / RTL88x2BU-Linux-Driver

Realtek RTL88x2BU WiFi USB Driver for Linux
GNU General Public License v2.0
1.26k stars 198 forks source link

[Rocky Linux 8.8]: netif_napi_add error #207

Closed vitduck closed 1 year ago

vitduck commented 1 year ago

Hi,

I am trying to compile the driver on Rocky Linux with 4.18 kernel.

Based on suggestion at #66, I changed to macro to

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)

Compilation then proceeds with the following error instead:

/opt/RTL88x2BU-Linux-Driver/os_dep/linux/os_intfs.c:2153:74: error: 
macro "netif_napi_add" passed 4 arguments, but takes just 3 
netif_napi_add(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT); 

/opt/RTL88x2BU-Linux-Driver/os_dep/linux/os_intfs.c:2153:2: error: 
"netif_napi_add" undeclared (first use in this situation); did you men 'netif_napi_del' ?  
netif_napi_add(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT); 

I understand that upgrading to 5.16 will likely fix the issue, but I am constrained with a clone of RHEL 8.

Thanks.

RinCat commented 1 year ago

You will need to manually check what you kernel ported back patches, change all related error KERNEL_VERSION to you current kernel.

And it looks like also included this:

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/os_intfs.c#L2150-L2154

vitduck commented 1 year ago

Hi @RinCat

Thanks for commenting.

After trial and error, I was able to successfully compiler the kernel module. For future reference, below are the the macros need changing for RHEL 8 due to kernel back port.

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/os_intfs.c#L1722-L1726

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/os_intfs.c#L2150-L2154

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L459-L460

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L484-L485

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L1152-L1154

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L2081-L2083

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L2272-L2274

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L2295-L2297

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L2346-L2348

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L5407-L5409

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L6788-L6790

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L8328-L8329

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L10510-L10511

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/ioctl_cfg80211.c#L10729-L10731

https://github.com/RinCat/RTL88x2BU-Linux-Driver/blob/12cfcd8cd8ec7115158df3d223510435541ddc32/os_dep/linux/rtw_android.c#L666-L668

The module is loaded with modprobe

cfg80211              905216  1 88x2bu

However, the wireless interface does not show up in ifconfig

enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.9  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::aaa1:59ff:fe85:d835  prefixlen 64  scopeid 0x20<link>
        ether a8:a1:59:85:d8:35  txqueuelen 1000  (Ethernet)
        RX packets 749  bytes 58336 (56.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1633  bytes 1781915 (1.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 12  bytes 1020 (1020.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 1020 (1020.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Is there some trivial thing that I miss ? Thanks.

RinCat commented 1 year ago

You can run dmesg and see if there is any error.

vitduck commented 1 year ago

I attached output of dmesg dmesg.txt

Please see the call trace at the end of the file.

RinCat commented 1 year ago

Let me install Rocky Linux 8.8 and check, that one crashed outside of this driver.

RinCat commented 1 year ago
diff --git a/core/monitor/rtw_radiotap.c b/core/monitor/rtw_radiotap.c
index e9ebc7d..e3b2e0b 100644
--- a/core/monitor/rtw_radiotap.c
+++ b/core/monitor/rtw_radiotap.c
@@ -21,7 +21,7 @@

 #define CHAN2FREQ(a) ((a < 14) ? (2407+5*a) : (5000+5*a))

-#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
 #define IEEE80211_RADIOTAP_ZERO_LEN_PSDU 26
 #define IEEE80211_RADIOTAP_LSIG 27
 #endif
diff --git a/include/osdep_service_linux.h b/include/osdep_service_linux.h
index fca4cf6..2bcf707 100644
--- a/include/osdep_service_linux.h
+++ b/include/osdep_service_linux.h
@@ -56,7 +56,7 @@
 #include <linux/list.h>
 #include <linux/vmalloc.h>

-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
    #include <uapi/linux/sched/types.h>
 #endif

diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c
index f7b59a8..b44d319 100644
--- a/os_dep/linux/ioctl_cfg80211.c
+++ b/os_dep/linux/ioctl_cfg80211.c
@@ -456,9 +456,9 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset,
    if (started) {
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0))
        cfg80211_ch_switch_started_notify(adapter->pnetdev, &chdef, 0, 0, false, 0);
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        cfg80211_ch_switch_started_notify(adapter->pnetdev, &chdef, 0, 0, false);
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0))
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))

        /* --- cfg80211_ch_switch_started_notfiy() ---
         *  A new parameter, bool quiet, is added from Linux kernel v5.11,
@@ -481,7 +481,7 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset,

 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0))
    cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0, 0);
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2))
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
    cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0);
 #else
    cfg80211_ch_switch_notify(adapter->pnetdev, &chdef);
@@ -749,7 +749,7 @@ static int rtw_cfg80211_sync_iftype(_adapter *adapter)

 static u64 rtw_get_systime_us(void)
 {
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
    return ktime_to_us(ktime_get_boottime());
 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
    struct timespec ts;
@@ -1149,7 +1149,7 @@ 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(4, 18, 0)
        roam_info.links[0].bssid = cur_network->network.MacAddress;
        #else
        roam_info.bssid = cur_network->network.MacAddress;
@@ -1913,7 +1913,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(4, 18, 0))
    , int link_id
 #endif
    , u8 key_index
@@ -2078,7 +2078,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(4, 18, 0))
    , int link_id
 #endif
    , u8 keyid
@@ -2269,7 +2269,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(4, 18, 0))
                int link_id,
 #endif
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
@@ -2292,7 +2292,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(4, 18, 0))
    int link_id,
 #endif
    u8 key_index
@@ -2343,7 +2343,7 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, struct net_device *

 #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(4, 18, 0))
    int link_id,
 #endif
    u8 key_index)
@@ -5404,7 +5404,7 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd
    return ret;
 }

-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 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)
@@ -6785,7 +6785,7 @@ exit:
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
 static int cfg80211_rtw_get_channel(struct wiphy *wiphy,
    struct wireless_dev *wdev,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
    unsigned int link_id,
 #endif
    struct cfg80211_chan_def *chandef)
@@ -8325,7 +8325,7 @@ exit:
    return ret;
 }

-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
 static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
    struct wireless_dev *wdev,
@@ -10507,7 +10507,7 @@ 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,
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
    .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register,
 #else
    .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_register,
@@ -10726,7 +10726,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(4, 18, 0))
    if (wdev->links[0].client.current_bss) {
    #else
    if (wdev->current_bss) {
diff --git a/os_dep/linux/ioctl_cfg80211.h b/os_dep/linux/ioctl_cfg80211.h
index 7c50e32..51eb064 100644
--- a/os_dep/linux/ioctl_cfg80211.h
+++ b/os_dep/linux/ioctl_cfg80211.h
@@ -414,7 +414,7 @@ void rtw_cfg80211_deinit_rfkill(struct wiphy *wiphy);
 #endif
 #endif

-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
 #define rtw_cfg80211_notify_new_peer_candidate(wdev, addr, ie, ie_len, sig_dbm, gfp) cfg80211_notify_new_peer_candidate(wdev_to_ndev(wdev), addr, ie, ie_len, sig_dbm, gfp)
 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
 #define rtw_cfg80211_notify_new_peer_candidate(wdev, addr, ie, ie_len, sig_dbm, gfp) cfg80211_notify_new_peer_candidate(wdev_to_ndev(wdev), addr, ie, ie_len, gfp)
diff --git a/os_dep/linux/nlrtw.c b/os_dep/linux/nlrtw.c
index 14d164b..385bd54 100644
--- a/os_dep/linux/nlrtw.c
+++ b/os_dep/linux/nlrtw.c
@@ -108,7 +108,7 @@ static struct genl_ops nlrtw_genl_ops[] = {
    {
        .cmd = NLRTW_CMD_CHANNEL_UTILIZATION,
        .flags = 0,
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
        .policy = nlrtw_genl_policy,
 #endif
        .doit = nlrtw_ch_util_set,
@@ -129,7 +129,7 @@ static struct genl_family nlrtw_genl_family = {
    .name = "nlrtw_"DRV_NAME,
    .version = 1,
    .maxattr = NLRTW_ATTR_MAX,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
    .policy = nlrtw_genl_policy,
 #endif
    .netnsok = true,
diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c
index 1d50aa5..e8cf1ff 100644
--- a/os_dep/linux/os_intfs.c
+++ b/os_dep/linux/os_intfs.c
@@ -1719,7 +1719,7 @@ unsigned int rtw_classify8021d(struct sk_buff *skb)

 static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
-   #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
+   #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
    , struct net_device *sb_dev
    #else
    , void *accel_priv
@@ -2147,7 +2147,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(4, 18, 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/recv_linux.c b/os_dep/linux/recv_linux.c
index 14fc295..04abcda 100644
--- a/os_dep/linux/recv_linux.c
+++ b/os_dep/linux/recv_linux.c
@@ -405,7 +405,7 @@ static int napi_recv(_adapter *padapter, int budget)
            So, we should prevent cloned SKB go into napi_gro_receive.
        */
        if (pregistrypriv->en_gro && !skb_cloned(pskb)) {
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
            if (rtw_napi_gro_receive(&padapter->napi, pskb) != GRO_MERGED_FREE)
 #else
            if (rtw_napi_gro_receive(&padapter->napi, pskb) != GRO_DROP)
diff --git a/os_dep/linux/rtw_android.c b/os_dep/linux/rtw_android.c
index 10f8f23..8a19635 100644
--- a/os_dep/linux/rtw_android.c
+++ b/os_dep/linux/rtw_android.c
@@ -663,7 +663,7 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
        ret = -ENOMEM;
        goto exit;
    }
-   #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
+   #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
    if (!access_ok(priv_cmd.buf, priv_cmd.total_len)) {
    #else
    if (!access_ok(VERIFY_READ, priv_cmd.buf, priv_cmd.total_len)) {
diff --git a/os_dep/linux/rtw_cfgvendor.c b/os_dep/linux/rtw_cfgvendor.c
index 53153ba..570f99c 100644
--- a/os_dep/linux/rtw_cfgvendor.c
+++ b/os_dep/linux/rtw_cfgvendor.c
@@ -1883,7 +1883,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LSTATS_SUBCMD_GET_INFO
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_lstats_get_info
@@ -1894,7 +1894,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LSTATS_SUBCMD_SET_INFO
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_lstats_set_info
@@ -1905,7 +1905,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LSTATS_SUBCMD_CLEAR_INFO
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_lstats_clear_info
@@ -1918,7 +1918,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
                         .subcmd = WIFI_SUBCMD_SET_RSSI_MONITOR
                 },
                 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
                 .doit = rtw_cfgvendor_set_rssi_monitor
@@ -1931,7 +1931,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LOGGER_START_LOGGING
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_logger_start_logging
@@ -1942,7 +1942,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LOGGER_GET_FEATURE
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_logger_get_feature
@@ -1953,7 +1953,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LOGGER_GET_VER
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_logger_get_version
@@ -1964,7 +1964,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LOGGER_GET_RING_STATUS
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_logger_get_ring_status
@@ -1975,7 +1975,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LOGGER_GET_RING_DATA
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_logger_get_ring_data
@@ -1986,7 +1986,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LOGGER_TRIGGER_MEM_DUMP
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_logger_get_firmware_memory_dump
@@ -1997,7 +1997,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LOGGER_START_PKT_FATE_MONITORING
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_logger_start_pkt_fate_monitoring
@@ -2008,7 +2008,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LOGGER_GET_TX_PKT_FATES
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_logger_get_tx_pkt_fates
@@ -2019,7 +2019,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = LOGGER_GET_RX_PKT_FATES
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_logger_get_rx_pkt_fates
@@ -2033,7 +2033,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = WIFI_SUBCMD_SET_PNO_RANDOM_MAC_OUI
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_set_rand_mac_oui
@@ -2046,7 +2046,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = WIFI_OFFLOAD_SUBCMD_START_MKEEP_ALIVE
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_start_mkeep_alive
@@ -2057,7 +2057,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = WIFI_OFFLOAD_SUBCMD_STOP_MKEEP_ALIVE
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_stop_mkeep_alive
@@ -2069,7 +2069,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = WIFI_SUBCMD_NODFS_SET
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_set_nodfs_flag
@@ -2081,7 +2081,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = WIFI_SUBCMD_SET_COUNTRY_CODE
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_set_country
@@ -2092,7 +2092,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = WIFI_SUBCMD_CONFIG_ND_OFFLOAD
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_set_nd_offload
@@ -2104,7 +2104,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = WIFI_SUBCMD_GET_FEATURE_SET
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_get_feature_set
@@ -2115,7 +2115,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = {
            .subcmd = WIFI_SUBCMD_GET_FEATURE_SET_MATRIX
        },
        .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        .policy = VENDOR_CMD_RAW_DATA,
 #endif
        .doit = rtw_cfgvendor_get_feature_set_matrix
diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c
index a490028..5a612fa 100644
--- a/os_dep/osdep_service.c
+++ b/os_dep/osdep_service.c
@@ -19,7 +19,7 @@
 #include <drv_types.h>
 #include <linux/kthread.h>

-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
 #define kthread_complete_and_exit(comp, code) complete_and_exit(comp, code)
 #endif

@@ -32,10 +32,6 @@ atomic_t _malloc_size = ATOMIC_INIT(0);
 #endif
 #endif /* DBG_MEMORY_LEAK */

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
-MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
-#endif
-
 #if defined(PLATFORM_LINUX)
 /*
 * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE
@@ -1317,7 +1313,7 @@ u32 _rtw_down_sema(_sema *sema)
 inline void thread_exit(_completion *comp)
 {
 #ifdef PLATFORM_LINUX
-   kthread_complete_and_exit(comp, 0);
+   complete_and_exit(comp, 0);
 #endif

 #ifdef PLATFORM_FREEBSD
@@ -2504,7 +2500,7 @@ static int isFileReadable(const char *path, u32 *sz)
 {
    struct file *fp;
    int ret = 0;
-   #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
+   #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
    mm_segment_t oldfs;
    #endif
    char buf;
@@ -2513,9 +2509,9 @@ static int isFileReadable(const char *path, u32 *sz)
    if (IS_ERR(fp))
        ret = PTR_ERR(fp);
    else {
-       #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
+       #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
        oldfs = get_fs();
-       #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
+       #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
        set_fs(KERNEL_DS);
        #else
        set_fs(get_ds());
@@ -2533,7 +2529,7 @@ static int isFileReadable(const char *path, u32 *sz)
            #endif
        }

-       #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
+       #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
        set_fs(oldfs);
        #endif
        filp_close(fp, NULL);
@@ -2551,7 +2547,7 @@ static int isFileReadable(const char *path, u32 *sz)
 static int retriveFromFile(const char *path, u8 *buf, u32 sz)
 {
    int ret = -1;
-   #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
+   #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
    mm_segment_t oldfs;
    #endif
    struct file *fp;
@@ -2561,9 +2557,9 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
        if (0 == ret) {
            RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);

-           #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
+           #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
            oldfs = get_fs();
-           #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
+           #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
            set_fs(KERNEL_DS);
            #else
            set_fs(get_ds());
@@ -2572,7 +2568,7 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)

            ret = readFile(fp, buf, sz);

-           #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
+           #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
            set_fs(oldfs);
            #endif
            closeFile(fp);
@@ -2598,7 +2594,7 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
 static int storeToFile(const char *path, u8 *buf, u32 sz)
 {
    int ret = 0;
-   #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
+   #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
    mm_segment_t oldfs;
    #endif
    struct file *fp;
@@ -2608,9 +2604,9 @@ static int storeToFile(const char *path, u8 *buf, u32 sz)
        if (0 == ret) {
            RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);

-           #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
+           #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
            oldfs = get_fs();
-           #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
+           #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
            set_fs(KERNEL_DS);
            #else
            set_fs(get_ds());
@@ -2619,7 +2615,7 @@ static int storeToFile(const char *path, u8 *buf, u32 sz)

            ret = writeFile(fp, buf, sz);

-           #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
+           #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
            set_fs(oldfs);
            #endif
            closeFile(fp);
@@ -2918,7 +2914,7 @@ u64 rtw_division64(u64 x, u64 y)
 inline u32 rtw_random32(void)
 {
 #ifdef PLATFORM_LINUX
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
    return get_random_u32();
 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
    return prandom_u32();

I guess you need more than that. This patch works for Rocky 8.8 with kernel 4.18.0-477.10.1.el8_8.x86_64

vitduck commented 1 year ago

Thanks for working the magic.

After applying your patch, I am now able to connect to wifi network .

$ nmcli dev status 
DEVICE                TYPE      STATE         CONNECTION 
wlp9s0f3u2u3          wifi      connected     sazabi     
p2p-dev-wlp9s0f3u2u3  wifi-p2p  disconnected  --         
enp4s0                ethernet  unavailable   --         
lo                    loopback  unmanaged     --       

Please close the issue as you see fit. Once again, thanks very much for your time.