From 0c8f2cfb6b2c1eaea468d232e5c7eb661d013fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rin=20Cat=20=28=E9=88=B4=E7=8C=AB=29?= Date: Mon, 14 Nov 2022 22:18:11 -0500 Subject: [PATCH] Support Linux 6.1 --- os_dep/linux/ioctl_cfg80211.c | 27 ++++++++++++++++++++++----- os_dep/linux/os_intfs.c | 4 ++++ os_dep/osdep_service.c | 4 +++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index ce1262e..752e117 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -454,7 +454,9 @@ 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(5, 11, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) + cfg80211_ch_switch_started_notify(adapter->pnetdev, &chdef, 0, 0, false); +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)) /* --- cfg80211_ch_switch_started_notfiy() --- * A new parameter, bool quiet, is added from Linux kernel v5.11, @@ -1907,6 +1909,9 @@ exit: } 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 , u8 key_index #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) , bool pairwise @@ -2069,6 +2074,9 @@ addkey_end: } 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 , u8 keyid #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) , bool pairwise @@ -2257,6 +2265,9 @@ exit: } 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)) */ @@ -2276,8 +2287,11 @@ static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, return 0; } -static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, - struct net_device *ndev, u8 key_index +static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, 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 @@ -2324,8 +2338,11 @@ 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, u8 key_index) +int cfg80211_rtw_set_default_mgmt_key(struct wiphy *wiphy, struct net_device *ndev, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) + int link_id, +#endif + u8 key_index) { #define SET_DEF_KEY_PARAM_FMT " key_index=%d" #define SET_DEF_KEY_PARAM_ARG , key_index diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 3752837..eedaaca 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -2141,7 +2141,11 @@ 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)) + 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); +#endif #endif /* CONFIG_RTW_NAPI */ #if defined(CONFIG_IOCTL_CFG80211) diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 47b0bd9..a490028 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -2918,7 +2918,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;