From 8bf93919e70240c4b4b1f6fe0272c6fd0714b187 Mon Sep 17 00:00:00 2001 From: Shen Mintao Date: Thu, 25 Jun 2026 19:26:34 +0800 Subject: [PATCH] fix: support newer kernel cfg80211 APIs --- drivers/aic8800/Makefile | 14 ++- drivers/aic8800/aic8800_fdrv/rwnx_main.c | 146 ++++++++++++++++++++--- drivers/aic8800/aic8800_fdrv/rwnx_tdls.c | 9 ++ install.sh | 2 +- 4 files changed, 154 insertions(+), 17 deletions(-) diff --git a/drivers/aic8800/Makefile b/drivers/aic8800/Makefile index 5b2fb80..54e658f 100644 --- a/drivers/aic8800/Makefile +++ b/drivers/aic8800/Makefile @@ -60,9 +60,21 @@ endif MAKEFLAGS +=-j$(shell nproc) +KERNEL_AUTOCONF := $(KDIR)/include/config/auto.conf +KERNEL_CONFIG := $(KDIR)/.config +KERNEL_CC_IS_CLANG := $(shell if [ -r "$(KERNEL_AUTOCONF)" ] && grep -q '^CONFIG_CC_IS_CLANG=y' "$(KERNEL_AUTOCONF)"; then echo y; elif [ -r "$(KERNEL_CONFIG)" ] && grep -q '^CONFIG_CC_IS_CLANG=y' "$(KERNEL_CONFIG)"; then echo y; fi) + +ifeq ($(KERNEL_CC_IS_CLANG),y) +LLVM ?= 1 +endif + +ifneq ($(LLVM),) +KBUILD_EXTRA_ARGS += LLVM=$(LLVM) +endif + all: modules modules: - make -C $(KDIR) M=$(PWD) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) modules + make -C $(KDIR) M=$(PWD) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) $(KBUILD_EXTRA_ARGS) modules install: mkdir -p $(MODDESTDIR) diff --git a/drivers/aic8800/aic8800_fdrv/rwnx_main.c b/drivers/aic8800/aic8800_fdrv/rwnx_main.c index 8d0cf58..aeb5daa 100644 --- a/drivers/aic8800/aic8800_fdrv/rwnx_main.c +++ b/drivers/aic8800/aic8800_fdrv/rwnx_main.c @@ -2941,7 +2941,12 @@ bool key_flag = false; * @add_key: add a key with the given parameters. @mac_addr will be %NULL * when adding a group key. */ -static int rwnx_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev, +static int rwnx_cfg80211_add_key(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct wireless_dev *wdev, +#else + struct net_device *netdev, +#endif #if (LINUX_VERSION_CODE >= HIGH_KERNEL_VERSION2) int link_id, #endif @@ -2949,7 +2954,11 @@ static int rwnx_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev, struct key_params *params) { struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct rwnx_vif *vif = netdev_priv(wdev->netdev); +#else struct rwnx_vif *vif = netdev_priv(netdev); +#endif int i, error = 0; struct mm_key_add_cfm key_add_cfm; u8_l cipher = 0; @@ -3056,7 +3065,12 @@ static int rwnx_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev, * not possible to retrieve the key, -ENOENT if it doesn't exist. * */ -static int rwnx_cfg80211_get_key(struct wiphy *wiphy, struct net_device *netdev, +static int rwnx_cfg80211_get_key(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct wireless_dev *wdev, +#else + struct net_device *netdev, +#endif #if (LINUX_VERSION_CODE >= HIGH_KERNEL_VERSION2) int link_id, #endif @@ -3075,7 +3089,12 @@ static int rwnx_cfg80211_get_key(struct wiphy *wiphy, struct net_device *netdev, * @del_key: remove a key given the @mac_addr (%NULL for a group key) * and @key_index, return -ENOENT if the key doesn't exist. */ -static int rwnx_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev, +static int rwnx_cfg80211_del_key(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct wireless_dev *wdev, +#else + struct net_device *netdev, +#endif #if (LINUX_VERSION_CODE >= HIGH_KERNEL_VERSION2) int link_id, #endif @@ -3083,7 +3102,11 @@ static int rwnx_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool pairwise, const u8 *mac_addr) { struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct rwnx_vif *vif = netdev_priv(wdev->netdev); +#else struct rwnx_vif *vif = netdev_priv(netdev); +#endif int error; struct rwnx_sta *sta = NULL; struct rwnx_key *rwnx_key; @@ -3131,7 +3154,11 @@ static int rwnx_cfg80211_set_default_key(struct wiphy *wiphy, * @set_default_mgmt_key: set the default management frame key on an interface */ static int rwnx_cfg80211_set_default_mgmt_key(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct wireless_dev *wdev, +#else struct net_device *netdev, +#endif #if (LINUX_VERSION_CODE >= HIGH_KERNEL_VERSION2) int link_id, #endif @@ -3221,7 +3248,12 @@ static int rwnx_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, key_params.key_len = sme->key_len; key_params.seq_len = 0; key_params.cipher = sme->crypto.cipher_group; - rwnx_cfg80211_add_key(wiphy, dev, + rwnx_cfg80211_add_key(wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + &rwnx_vif->wdev, +#else + dev, +#endif #if (LINUX_VERSION_CODE >= HIGH_KERNEL_VERSION2) 0, #endif @@ -3448,7 +3480,11 @@ static int rwnx_cfg80211_external_auth(struct wiphy *wiphy, struct net_device *d * @add_station: Add a new station. */ static int rwnx_cfg80211_add_station(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct wireless_dev *wdev, +#else struct net_device *dev, +#endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)) u8 *mac, #else @@ -3457,7 +3493,11 @@ static int rwnx_cfg80211_add_station(struct wiphy *wiphy, struct station_parameters *params) { struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct rwnx_vif *rwnx_vif = netdev_priv(wdev->netdev); +#else struct rwnx_vif *rwnx_vif = netdev_priv(dev); +#endif struct me_sta_add_cfm me_sta_add_cfm; int error = 0; @@ -3548,7 +3588,13 @@ static int rwnx_cfg80211_add_station(struct wiphy *wiphy, #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) sinfo.filled |= STATION_INFO_ASSOC_REQ_IES; #endif - cfg80211_new_sta(rwnx_vif->ndev, sta->mac_addr, &sinfo, GFP_KERNEL); + cfg80211_new_sta( +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + &rwnx_vif->wdev, +#else + rwnx_vif->ndev, +#endif + sta->mac_addr, &sinfo, GFP_KERNEL); } #ifdef CONFIG_BAND_STEERING @@ -3573,7 +3619,13 @@ static int rwnx_cfg80211_add_station(struct wiphy *wiphy, #define PRINT_STA_FLAG(f) \ (params->sta_flags_set & BIT(NL80211_STA_FLAG_##f) ? "["#f"]" : "") - netdev_info(dev, "Add sta %d (%pM) flags=%s%s%s%s%s%s%s", + netdev_info( +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + wdev->netdev, +#else + dev, +#endif + "Add sta %d (%pM) flags=%s%s%s%s%s%s%s", sta->sta_idx, mac, PRINT_STA_FLAG(AUTHORIZED), PRINT_STA_FLAG(SHORT_PREAMBLE), @@ -3599,7 +3651,11 @@ static int rwnx_cfg80211_add_station(struct wiphy *wiphy, * @del_station: Remove a station */ static int rwnx_cfg80211_del_station_compat(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct wireless_dev *wdev, +#else struct net_device *dev, +#endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)) u8 *mac #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)) @@ -3610,7 +3666,11 @@ static int rwnx_cfg80211_del_station_compat(struct wiphy *wiphy, ) { struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct rwnx_vif *rwnx_vif = netdev_priv(wdev->netdev); +#else struct rwnx_vif *rwnx_vif = netdev_priv(dev); +#endif struct rwnx_sta *cur, *tmp; int error = 0, found = 0; #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) @@ -3650,7 +3710,13 @@ static int rwnx_cfg80211_del_station_compat(struct wiphy *wiphy, spin_unlock_bh(&rwnx_hw->cb_lock); if(found) { - netdev_info(dev, "Del sta %d (%pM)", cur->sta_idx, cur->mac_addr); + netdev_info( +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + wdev->netdev, +#else + dev, +#endif + "Del sta %d (%pM)", cur->sta_idx, cur->mac_addr); if (cur->vif_idx != cur->vlan_idx) { struct rwnx_vif *vlan_vif; vlan_vif = rwnx_hw->vif_table[cur->vlan_idx]; @@ -3663,9 +3729,15 @@ static int rwnx_cfg80211_del_station_compat(struct wiphy *wiphy, } } } - if (rwnx_vif->wdev.iftype == NL80211_IFTYPE_AP || rwnx_vif->wdev.iftype == NL80211_IFTYPE_P2P_GO) { - cfg80211_del_sta(rwnx_vif->ndev, cur->mac_addr, GFP_KERNEL); - } + if (rwnx_vif->wdev.iftype == NL80211_IFTYPE_AP || rwnx_vif->wdev.iftype == NL80211_IFTYPE_P2P_GO) { + cfg80211_del_sta( +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + &rwnx_vif->wdev, +#else + rwnx_vif->ndev, +#endif + cur->mac_addr, GFP_KERNEL); + } #ifdef AICWF_RX_REORDER #ifdef AICWF_SDIO_SUPPORT @@ -3889,7 +3961,12 @@ void apm_probe_sta_work_process(struct work_struct *work) * them, also against the existing state! Drivers must call * cfg80211_check_station_change() to validate the information. */ -static int rwnx_cfg80211_change_station(struct wiphy *wiphy, struct net_device *dev, +static int rwnx_cfg80211_change_station(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct wireless_dev *wdev, +#else + struct net_device *dev, +#endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)) u8 *mac, #else @@ -3898,7 +3975,11 @@ static int rwnx_cfg80211_change_station(struct wiphy *wiphy, struct net_device * struct station_parameters *params) { struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct rwnx_vif *vif = netdev_priv(wdev->netdev); +#else struct rwnx_vif *vif = netdev_priv(dev); +#endif struct rwnx_sta *sta; sta = rwnx_get_sta(rwnx_hw, mac); @@ -3907,7 +3988,11 @@ static int rwnx_cfg80211_change_station(struct wiphy *wiphy, struct net_device * /* Add the TDLS station */ if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct rwnx_vif *rwnx_vif = netdev_priv(wdev->netdev); +#else struct rwnx_vif *rwnx_vif = netdev_priv(dev); +#endif struct me_sta_add_cfm me_sta_add_cfm; int error = 0; @@ -3978,7 +4063,13 @@ static int rwnx_cfg80211_change_station(struct wiphy *wiphy, struct net_device * #define PRINT_STA_FLAG(f) \ (params->sta_flags_set & BIT(NL80211_STA_FLAG_##f) ? "["#f"]" : "") - netdev_info(dev, "Add %s TDLS sta %d (%pM) flags=%s%s%s%s%s%s%s", + netdev_info( +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + wdev->netdev, +#else + dev, +#endif + "Add %s TDLS sta %d (%pM) flags=%s%s%s%s%s%s%s", sta->tdls.initiator ? "initiator" : "responder", sta->sta_idx, mac, PRINT_STA_FLAG(AUTHORIZED), @@ -4261,7 +4352,13 @@ static int rwnx_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) /* delete any remaining STA*/ while (!list_empty(&rwnx_vif->ap.sta_list)) { - rwnx_cfg80211_del_station_compat(wiphy, dev, NULL); + rwnx_cfg80211_del_station_compat(wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + &rwnx_vif->wdev, +#else + dev, +#endif + NULL); } #ifdef CONFIG_BAND_STEERING @@ -4516,7 +4613,9 @@ static int rwnx_cfg80211_get_tx_power(struct wiphy *wiphy, #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0) int radio_idx, -unsigned int changed, +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 14, 0) +unsigned int link_id, #endif int *mbm) { @@ -5882,7 +5981,11 @@ int rwnx_fill_station_info(struct rwnx_sta *sta, struct rwnx_vif *vif, * @get_station: get station information for the station identified by @mac */ static int rwnx_cfg80211_get_station(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct wireless_dev *wdev, +#else struct net_device *dev, +#endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)) u8 *mac, #else @@ -5890,7 +5993,11 @@ static int rwnx_cfg80211_get_station(struct wiphy *wiphy, #endif struct station_info *sinfo) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct rwnx_vif *vif = netdev_priv(wdev->netdev); +#else struct rwnx_vif *vif = netdev_priv(dev); +#endif struct rwnx_sta *sta = NULL; if (RWNX_VIF_TYPE(vif) == NL80211_IFTYPE_MONITOR) @@ -5923,10 +6030,19 @@ static int rwnx_cfg80211_get_station(struct wiphy *wiphy, /** * @dump_station: dump station callback -- resume dump at index @idx */ -static int rwnx_cfg80211_dump_station(struct wiphy *wiphy, struct net_device *dev, +static int rwnx_cfg80211_dump_station(struct wiphy *wiphy, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct wireless_dev *wdev, +#else + struct net_device *dev, +#endif int idx, u8 *mac, struct station_info *sinfo) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + struct rwnx_vif *rwnx_vif = netdev_priv(wdev->netdev); +#else struct rwnx_vif *rwnx_vif = netdev_priv(dev); +#endif //struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy); struct rwnx_sta *sta_iter, *sta = NULL; //struct mesh_peer_info_cfm peer_info_cfm; diff --git a/drivers/aic8800/aic8800_fdrv/rwnx_tdls.c b/drivers/aic8800/aic8800_fdrv/rwnx_tdls.c index ce400ce..5def8b7 100644 --- a/drivers/aic8800/aic8800_fdrv/rwnx_tdls.c +++ b/drivers/aic8800/aic8800_fdrv/rwnx_tdls.c @@ -115,12 +115,21 @@ rwnx_prep_tdls_direct(struct rwnx_hw *rwnx_hw, struct rwnx_vif *rwnx_vif, switch (action_code) { case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0) + skb_put(skb, 1 + sizeof(mgmt->u.action.tdls_discover_resp)); + mgmt->u.action.category = WLAN_CATEGORY_PUBLIC; + mgmt->u.action.action_code = WLAN_PUB_ACTION_TDLS_DISCOVER_RES; + mgmt->u.action.tdls_discover_resp.dialog_token = dialog_token; + mgmt->u.action.tdls_discover_resp.capability = + cpu_to_le16(rwnx_get_tdls_sta_capab(rwnx_vif, status_code)); +#else skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp)); mgmt->u.action.category = WLAN_CATEGORY_PUBLIC; mgmt->u.action.u.tdls_discover_resp.action_code = WLAN_PUB_ACTION_TDLS_DISCOVER_RES; mgmt->u.action.u.tdls_discover_resp.dialog_token = dialog_token; mgmt->u.action.u.tdls_discover_resp.capability = cpu_to_le16(rwnx_get_tdls_sta_capab(rwnx_vif, status_code)); +#endif break; default: return -EINVAL; diff --git a/install.sh b/install.sh index 97cbc18..eb9306a 100755 --- a/install.sh +++ b/install.sh @@ -548,7 +548,7 @@ main() { echo -e "${CYAN}" echo "╔════════════════════════════════════════════════════════════════╗" - echo "║ AIC8800D80 WiFi 6 Driver - Universal Installer (DKMS) ║" + echo "║ AIC8800D80 WiFi 6 Driver - Universal Installer (DKMS) ║" echo "║ Version 2.0.4 (Fixed) ║" echo "╚════════════════════════════════════════════════════════════════╝" echo -e "${NC}"