From e3e12f52b214121840b44c91de5b3e5af5d3eb84 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 06 Nov 2023 03:04:41 +0000 Subject: [PATCH] rk3568 rt init --- kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfgvif.c | 103 +++++++++++++++++++++++++++++++++++---------------- 1 files changed, 71 insertions(+), 32 deletions(-) diff --git a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfgvif.c b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfgvif.c index f5d6910..4980e82 100644 --- a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfgvif.c +++ b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfgvif.c @@ -519,7 +519,7 @@ * role to station type while bringing down the interface */ if (p2p_ndev->ieee80211_ptr->iftype == NL80211_IFTYPE_STATION) { - WL_DBG_MEM(("%s, Change to GC base role\n", __FUNCTION__)); + WL_DBG_MEM(("%s, Change to GC base role\n", p2p_ndev->name)); return WL_IF_TYPE_P2P_GC; } @@ -888,6 +888,7 @@ WL_DBG(("%s:Mac addr" MACDBG "\n", __FUNCTION__, MAC2STRDBG(mac_addr))); +#if defined(SPECIFIC_MAC_GEN_SCHEME) if ((wl_iftype == WL_IF_TYPE_P2P_DISC) || (wl_iftype == WL_IF_TYPE_AP) || (wl_iftype == WL_IF_TYPE_P2P_GO) || (wl_iftype == WL_IF_TYPE_P2P_GC)) { /* Avoid invoking release mac addr code for interfaces using @@ -895,6 +896,11 @@ */ return BCME_OK; } +#else + if (wl_iftype == WL_IF_TYPE_P2P_DISC) { + return BCME_OK; + } +#endif /* SPECIFIC_MAC_GEN_SCHEME */ /* Fetch last two bytes of mac address */ org_toggle_bytes = ntoh16(*((u16 *)&ndev->dev_addr[4])); @@ -951,7 +957,7 @@ * released. Ensure to call wl_release_vif_macaddress to free up * the mac address. */ -#if defined (SPECIFIC_MAC_GEN_SCHEME) +#if defined(SPECIFIC_MAC_GEN_SCHEME) if (wl_iftype == WL_IF_TYPE_P2P_DISC || wl_iftype == WL_IF_TYPE_AP) { mac_addr[0] |= 0x02; } else if ((wl_iftype == WL_IF_TYPE_P2P_GO) || (wl_iftype == WL_IF_TYPE_P2P_GC)) { @@ -962,7 +968,7 @@ if (wl_iftype == WL_IF_TYPE_P2P_DISC) { mac_addr[0] |= 0x02; } -#endif /* SEPCIFIC_MAC_GEN_SCHEME */ +#endif /* SPECIFIC_MAC_GEN_SCHEME */ else { /* For locally administered mac addresses, we keep the * OUI part constant and just work on the last two bytes. @@ -1331,9 +1337,9 @@ if (is_p2p_group_iface(ndev->ieee80211_ptr) && (type == NL80211_IFTYPE_STATION)) { /* For role downgrade cases, we keep interface role as GC */ netinfo->iftype = WL_IF_TYPE_P2P_GC; - WL_DBG_MEM(("[%s] Set base role to GC, current role" + WL_DBG_MEM(("[%s] Set base role to GC, current role" "ndev->ieee80211_ptr->iftype = %d\n", - __FUNCTION__, ndev->ieee80211_ptr->iftype)); + ndev->name, ndev->ieee80211_ptr->iftype)); } else { netinfo->iftype = wl_iftype; } @@ -1538,11 +1544,16 @@ s32 wl_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev, struct ieee80211_channel *chan, - enum nl80211_channel_type channel_type) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) + enum nl80211_channel_type channel_type +#else + enum nl80211_chan_width width +#endif +) { chanspec_t chspec = INVCHANSPEC; chanspec_t cur_chspec = INVCHANSPEC; - u32 bw = WL_CHANSPEC_BW_20; + u32 band_width = WL_CHANSPEC_BW_20, bw = WL_CHANSPEC_BW_20; s32 err = BCME_OK; struct bcm_cfg80211 *cfg = wiphy_priv(wiphy); #if defined(CUSTOM_SET_CPUCORE) || defined(APSTA_RESTRICTED_CHANNEL) @@ -1551,6 +1562,39 @@ u16 center_freq = chan->center_freq; dev = ndev_to_wlc_ndev(dev, cfg); + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) + switch (channel_type) { + case NL80211_CHAN_HT40MINUS: + /* secondary channel is below the control channel */ + band_width = WL_CHANSPEC_BW_40; + break; + case NL80211_CHAN_HT40PLUS: + /* secondary channel is above the control channel */ + band_width = WL_CHANSPEC_BW_40; + break; + default: + band_width = WL_CHANSPEC_BW_20; + } +#else + switch (width) + { + case NL80211_CHAN_WIDTH_160: + band_width = WL_CHANSPEC_BW_160; + break; + case NL80211_CHAN_WIDTH_80P80: + case NL80211_CHAN_WIDTH_80: + band_width = WL_CHANSPEC_BW_80; + break; + case NL80211_CHAN_WIDTH_40: + band_width = WL_CHANSPEC_BW_40; + break; + default: + band_width = WL_CHANSPEC_BW_20; + break; + } +#endif + #ifdef WL_EXT_IAPSTA if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP || dev->ieee80211_ptr->iftype == NL80211_IFTYPE_P2P_GO) { @@ -1571,9 +1615,9 @@ #endif chspec = wl_freq_to_chanspec(center_freq); - WL_MSG(dev->name, "netdev_ifidx(%d) chan_type(%d) target channel(%s-%d %sMHz)\n", - dev->ifindex, channel_type, CHSPEC2BANDSTR(chspec), - CHSPEC_CHANNEL(chspec), wf_chspec_to_bw_str(chspec)); + WL_MSG(dev->name, "netdev_ifidx(%d) chan_width(%d) target channel(%s-%d %sMHz)\n", + dev->ifindex, width, CHSPEC2BANDSTR(chspec), + CHSPEC_CHANNEL(chspec), WLCWIDTH2STR(band_width)); #ifdef WL_P2P_6G if (!(cfg->p2p_6g_enabled)) { @@ -1585,22 +1629,6 @@ #ifdef WL_P2P_6G } #endif /* WL_P2P_6G */ - -#ifdef NOT_YET - switch (channel_type) { - case NL80211_CHAN_HT40MINUS: - /* secondary channel is below the control channel */ - chspec = CH40MHZ_CHSPEC(CHSPEC_CHANNEL(chspec), WL_CHANSPEC_CTL_SB_UPPER); - break; - case NL80211_CHAN_HT40PLUS: - /* secondary channel is above the control channel */ - chspec = CH40MHZ_CHSPEC(CHSPEC_CHANNEL(chspec), WL_CHANSPEC_CTL_SB_LOWER); - break; - default: - chspec = CH20MHZ_CHSPEC(CHSPEC_CHANNEL(chspec)); - - } -#endif /* NOT_YET */ #if defined(APSTA_RESTRICTED_CHANNEL) /* Some customer platform used limited number of channels @@ -1643,7 +1671,18 @@ if (err < 0) { WL_ERR(("Failed to get bandwidth information, err=%d\n", err)); return err; + } else if (bw < band_width) { + WL_ERR(("capability force band_width=0x%X to be 0x%X\n", band_width, bw)); + band_width = bw; } +#ifdef HOSTAPD_BW_SUPPORT + WL_MSG(dev->name, "hostapd bw(%sMHz) <= chip bw(%sMHz)\n", + wf_chspec_to_bw_str(band_width), wf_chspec_to_bw_str(bw)); +#else + WL_MSG(dev->name, "hostapd bw(%sMHz) => chip bw(%sMHz)\n", + wf_chspec_to_bw_str(band_width), wf_chspec_to_bw_str(bw)); + band_width = bw; +#endif /* In case of 5G downgrade BW to 80MHz as 160MHz channels falls in DFS */ if (CHSPEC_IS5G(chspec) && (bw == WL_CHANSPEC_BW_160)) { @@ -1651,7 +1690,7 @@ } set_channel: cur_chspec = wf_create_chspec_from_primary(wf_chspec_primary20_chan(chspec), - bw, CHSPEC_BAND(chspec)); + band_width, CHSPEC_BAND(chspec)); #ifdef WL_6G_BAND if (cfg->acs_chspec && CHSPEC_IS6G(cfg->acs_chspec) && @@ -3694,8 +3733,8 @@ dev->ieee80211_ptr->u.ap.preset_chandef.chan, #else dev->ieee80211_ptr->preset_chandef.chan, -#endif - NL80211_CHAN_HT20) < 0)) { +#endif /* CFG80211_BKPORT_MLO */ + info->chandef.width) < 0)) { WL_ERR(("Set channel failed \n")); goto fail; } @@ -3793,7 +3832,7 @@ wl_cfg80211_stop_ap(wiphy, dev, 0); #else wl_cfg80211_stop_ap(wiphy, dev); -#endif +#endif /* CFG80211_BKPORT_MLO */ if (dev_role == NL80211_IFTYPE_AP) { #ifdef WL_EXT_IAPSTA if (!wl_ext_iapsta_iftype_enabled(dev, WL_IF_TYPE_AP)) { @@ -3837,7 +3876,7 @@ struct net_device *dev #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO) , unsigned int link_id -#endif +#endif /* CFG80211_BKPORT_MLO */ ) { int err = 0; @@ -5246,7 +5285,7 @@ cfg80211_ch_switch_notify(dev, &chandef, 0); #else cfg80211_ch_switch_notify(dev, &chandef); -#endif +#endif /* CFG80211_BKPORT_MLO */ #elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, 0))) freq = chandef.freq; cfg80211_ch_switch_notify(dev, freq, chandef.chan_type); -- Gitblit v1.6.2