From bedbef8ad3e75a304af6361af235302bcc61d06b Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Tue, 14 May 2024 06:39:01 +0000
Subject: [PATCH] 修改内核路径

---
 kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfg80211.c |  629 +++++++++-----------------------------------------------
 1 files changed, 108 insertions(+), 521 deletions(-)

diff --git a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfg80211.c b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfg80211.c
old mode 100644
new mode 100755
index 69c8dc3..08de44a
--- a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfg80211.c
+++ b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfg80211.c
@@ -241,9 +241,9 @@
 		 */
 		REG_RULE(2484-10, 2484+10, 20, 6, 20, 0),
 		/* IEEE 802.11a, channel 36..64 */
-		REG_RULE(5150-10, 5350+10, 80, 6, 20, 0),
+		REG_RULE(5150-10, 5350+10, 40, 6, 20, 0),
 		/* IEEE 802.11a, channel 100..165 */
-		REG_RULE(5470-10, 5850+10, 80, 6, 20, 0),
+		REG_RULE(5470-10, 5850+10, 40, 6, 20, 0),
 #ifdef WL_6G_BAND
 		REG_RULE(6025-80, 6985+80, 160, 6, 20, 0),
 		REG_RULE(5935-10, 7115+10, 20, 6, 20, 0),
@@ -475,34 +475,18 @@
 #endif /* WL_CFG80211_P2P_DEV_IF */
 static s32 wl_cfg80211_config_default_key(struct wiphy *wiphy,
 	struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
 	u8 key_idx, bool unicast, bool multicast);
 static s32 wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
 	u8 key_idx, bool pairwise, const u8 *mac_addr,
 	struct key_params *params);
 static s32 wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
 	u8 key_idx, bool pairwise, const u8 *mac_addr);
 static s32 wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
 	u8 key_idx, bool pairwise, const u8 *mac_addr,
 	void *cookie, void (*callback) (void *cookie,
 	struct key_params *params));
 static s32 wl_cfg80211_config_default_mgmt_key(struct wiphy *wiphy,
-	struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
-	u8 key_idx);
+	struct net_device *dev,	u8 key_idx);
 #if defined(WL_SUPPORT_BACKPORTED_KPATCHES) || (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0))
 static s32 wl_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
 	bcm_struct_cfgdev *cfgdev, u64 cookie);
@@ -595,8 +579,10 @@
 	bcm_struct_cfgdev *cfgdev, const wl_event_msg_t *e, void *data);
 static s32 wl_bss_connect_done(struct bcm_cfg80211 *cfg, struct net_device *ndev,
 	const wl_event_msg_t *e, void *data, bool completed);
+#ifdef DHD_LOSSLESS_ROAMING
 static s32 wl_bss_roaming_done(struct bcm_cfg80211 *cfg, struct net_device *ndev,
 	const wl_event_msg_t *e, void *data);
+#endif /* DHD_LOSSLESS_ROAMING */
 static s32 wl_notify_mic_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
 	const wl_event_msg_t *e, void *data);
 #ifdef BT_WIFI_HANDOVER
@@ -1089,86 +1075,12 @@
 };
 #endif /* CFG80211_6G_SUPPORT */
 
-#ifdef WL_CAP_HE
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) || defined(CONFIG_6GHZ_BKPORT)
-static struct ieee80211_sband_iftype_data __wl_he_cap = {
-	.types_mask = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP),
-	.he_cap = {
-		.has_he = true,
-		.he_cap_elem = {
-			.mac_cap_info[0] = (IEEE80211_HE_MAC_CAP0_HTC_HE |
-			IEEE80211_HE_MAC_CAP0_TWT_REQ),
-			.mac_cap_info[1] = IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US,
-			.mac_cap_info[2] = IEEE80211_HE_MAC_CAP2_BSR,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
-			.mac_cap_info[5] = IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX,
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) */
-
-			.phy_cap_info[0] =
-			IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G |
-			IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G,
-			.phy_cap_info[1] =
-			IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A |
-			IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD,
-			.phy_cap_info[2] =
-			IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US,
-			.phy_cap_info[3] =
-			IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER,
-			.phy_cap_info[4] =
-			IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE |
-			IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK |
-			IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4,
-			.phy_cap_info[5] =
-			IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2,
-			.phy_cap_info[6] =
-			IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU |
-			IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU |
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0))
-			IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB |
-			IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB |
-#else
-			IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMER_FB |
-			IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMER_FB |
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0) */
-			IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB |
-			IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT,
-			.phy_cap_info[7] =
-			IEEE80211_HE_PHY_CAP7_MAX_NC_1,
-			.phy_cap_info[8] =
-			IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU |
-			IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0))
-			.phy_cap_info[9] =
-			IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU |
-			IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU,
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0) */
-			},
-			.he_mcs_nss_supp = {
-			.rx_mcs_80 = cpu_to_le16(0xfffa),
-			.tx_mcs_80 = cpu_to_le16(0xfffa),
-			.rx_mcs_160 = cpu_to_le16((0xfffa)),
-			.tx_mcs_160 = cpu_to_le16((0xfffa)),
-			}
-	},
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
-	.he_6ghz_capa = {.capa = cpu_to_le16(0x3038)},
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) */
-};
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) */
-#endif /* WL_CAP_HE */
-
 static struct ieee80211_supported_band __wl_band_2ghz = {
 	.band = IEEE80211_BAND_2GHZ,
 	.channels = __wl_2ghz_channels,
 	.n_channels = ARRAY_SIZE(__wl_2ghz_channels),
 	.bitrates = wl_g_rates,
-	.n_bitrates = wl_g_rates_size,
-#ifdef WL_CAP_HE
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) || defined(CONFIG_6GHZ_BKPORT)
-	.iftype_data = &__wl_he_cap,
-	.n_iftype_data = 1
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) */
-#endif /* WL_CAP_HE */
+	.n_bitrates = wl_g_rates_size
 };
 
 static struct ieee80211_supported_band __wl_band_5ghz_a = {
@@ -1176,13 +1088,7 @@
 	.channels = __wl_5ghz_a_channels,
 	.n_channels = ARRAY_SIZE(__wl_5ghz_a_channels),
 	.bitrates = wl_a_rates,
-	.n_bitrates = wl_a_rates_size,
-#ifdef WL_CAP_HE
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) || defined(CONFIG_6GHZ_BKPORT)
-	.iftype_data = &__wl_he_cap,
-	.n_iftype_data = 1
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) */
-#endif /* WL_CAP_HE */
+	.n_bitrates = wl_a_rates_size
 };
 
 #ifdef CFG80211_6G_SUPPORT
@@ -1191,13 +1097,7 @@
 	.channels = __wl_6ghz_channels,
 	.n_channels = ARRAY_SIZE(__wl_6ghz_channels),
 	.bitrates = wl_a_rates,
-	.n_bitrates = wl_a_rates_size,
-#ifdef WL_CAP_HE
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) || defined(CONFIG_6GHZ_BKPORT)
-	.iftype_data = &__wl_he_cap,
-	.n_iftype_data = 1
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) */
-#endif /* WL_CAP_HE */
+	.n_bitrates = wl_a_rates_size
 };
 #endif /* CFG80211_6G_SUPPORT */
 
@@ -2391,7 +2291,7 @@
 
 	WL_ERR(("%s: starts to read %s. Axi error \n", __FUNCTION__, filename));
 
-	fp = dhd_filp_open(filename, O_RDONLY, 0);
+	fp = filp_open(filename, O_RDONLY, 0);
 
 	if (IS_ERR(fp) || (fp == NULL)) {
 		WL_ERR(("%s: Couldn't read the file, err %ld,File [%s]  No previous axi error \n",
@@ -2399,8 +2299,8 @@
 		return ret;
 	}
 
-	dhd_kernel_read_compat(fp, fp->f_pos, (char *)dhd->axi_err_dump, sizeof(dhd_axi_error_dump_t));
-	dhd_filp_close(fp, NULL);
+	kernel_read_compat(fp, fp->f_pos, (char *)dhd->axi_err_dump, sizeof(dhd_axi_error_dump_t));
+	filp_close(fp, NULL);
 
 	/* Delete axi error info file */
 	if (dhd_file_delete(filename) < 0) {
@@ -3282,7 +3182,7 @@
 
 	if (addr) {
 		ifflags |= WL_INTERFACE_MAC_USE;
-		if (dhd_conf_legacy_chip_check(cfg->pub)) {
+		if (wl_legacy_chip_check(ndev)) {
 			iface.flags = ifflags;
 			memcpy(&iface.mac_addr.octet, addr, ETH_ALEN);
 		}
@@ -3295,7 +3195,7 @@
 #endif /* WLEASYMESH */
 
 	/* Pass ver = 0 for fetching the interface_create iovar version */
-	if (dhd_conf_legacy_chip_check(cfg->pub)) {
+	if (wl_legacy_chip_check(ndev)) {
 		bzero(&iface_v0, sizeof(iface_v0));
 		iface_v0.ver = WL_INTERFACE_CREATE_VER_0;
 		iface_v0.flags = iftype | ifflags;
@@ -6483,9 +6383,6 @@
 
 	if (assoc_info.reassoc) {
 		/* Handle roam to same ESS */
-#ifdef DHD_LOSSLESS_ROAMING
-		wl_ext_send_event_msg(dev, WLC_E_ROAM_PREP, WLC_E_STATUS_SUCCESS, WLC_E_REASON_LOW_RSSI);
-#endif
 		if ((err = wl_handle_reassoc(cfg, dev, &assoc_info)) != BCME_OK) {
 			goto fail;
 		}
@@ -6640,16 +6537,7 @@
 			WL_TRACE_HW4(("Aborting the scan! \n"));
 			wl_cfgscan_cancel_scan(cfg);
 		}
-		if (conn_in_progress || connected ||
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
-			wdev->u.client.ssid_len)
-#else
-			wdev->ssid_len)
-#endif /* CFG80211_BKPORT_MLO */
-		{
-#ifdef WL_EXT_IAPSTA
-				wl_ext_in4way_sync(dev, 0, WL_EXT_STATUS_PRE_DISCONNECTING, NULL);
-#endif
+		if (conn_in_progress || connected || wdev->ssid_len) {
 				scbval.val = reason_code;
 				memcpy(&scbval.ea, curbssid, ETHER_ADDR_LEN);
 				scbval.val = htod32(scbval.val);
@@ -6693,12 +6581,8 @@
 		 * disassoc indicates state mismatch with upper layer. Check for state
 		 * and issue disconnect indication if required.
 		 */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
-		if (wdev->connected || wdev->u.client.ssid_len)
-#else
-		if (wdev->current_bss || wdev->ssid_len)
-#endif /* CFG80211_BKPORT_MLO */
-		{
+
+		if (wdev->current_bss || wdev->ssid_len) {
 			WL_INFORM_MEM(("report disconnect event\n"));
 			CFG80211_DISCONNECTED(dev, 0, NULL, 0, false, GFP_KERNEL);
 		}
@@ -6803,9 +6687,6 @@
 
 static s32
 wl_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
 	u8 key_idx, bool unicast, bool multicast)
 {
 	struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
@@ -6850,7 +6731,7 @@
 	s32 bssidx;
 	s32 mode = wl_get_mode_by_netdev(cfg, dev);
 
-	WL_MSG(dev->name, "key index (%d) for %pM\n", key_idx, mac_addr);
+	WL_MSG(dev->name, "key index (%d)\n", key_idx);
 	if ((bssidx = wl_get_bssidx_by_wdev(cfg, dev->ieee80211_ptr)) < 0) {
 		WL_ERR(("Find p2p index from wdev(%p) failed\n", dev->ieee80211_ptr));
 		return BCME_ERROR;
@@ -7017,9 +6898,6 @@
 
 static s32
 wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
 	u8 key_idx, bool pairwise, const u8 *mac_addr,
 	struct key_params *params)
 {
@@ -7219,9 +7097,6 @@
 
 static s32
 wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
 	u8 key_idx, bool pairwise, const u8 *mac_addr)
 {
 	struct wl_wsec_key key;
@@ -7285,9 +7160,6 @@
 /* NOTE : this function cannot work as is and is never called */
 static s32
 wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
 	u8 key_idx, bool pairwise, const u8 *mac_addr, void *cookie,
 	void (*callback) (void *cookie, struct key_params * params))
 {
@@ -7362,11 +7234,7 @@
 
 static s32
 wl_cfg80211_config_default_mgmt_key(struct wiphy *wiphy,
-	struct net_device *dev,
-#if defined(CFG80211_BKPORT_MLO)
-	int link_id,
-#endif
-	u8 key_idx)
+	struct net_device *dev, u8 key_idx)
 {
 #ifdef MFP
 	/* Firmware seems to use hard coded index for Group Mgmt Key.
@@ -10267,7 +10135,7 @@
 	chan = &band->channels[idx];
 	/* Setting current channel to the requested channel */
 	if ((err = wl_cfg80211_set_channel(wiphy, ndev, chan,
-			NL80211_CHAN_WIDTH_20) < 0)) {
+		NL80211_CHAN_HT20) < 0)) {
 		/*
 		 * FIXME:
 		 *
@@ -10349,34 +10217,6 @@
 	return err;
 }
 #endif /* WL_SUPPORT_ACS */
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
-static int
-wl_cfg80211_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
-	unsigned int link_id,
-#endif
-	struct cfg80211_chan_def *chandef)
-{
-	struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
-	u32 chanspec = 0;
-	int ret = 0;
-
-	RETURN_EIO_IF_NOT_UP(cfg);
-	if (NULL == wdev->netdev) {
-		/* the P2P interface may temporary use wdev without ndev */
-		return -EINVAL;
-	}
-
-	if ((ret = wldev_iovar_getint(wdev->netdev, "chanspec", (s32 *)&chanspec) != BCME_OK)) {
-		return ret;
-	}
-	if (!chandef || (wl_chspec_chandef(chanspec, chandef, wiphy) != BCME_OK)) {
-		return BCME_ERROR;
-	}
-	return 0;
-}
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION (3, 6, 0) */
 
 static struct cfg80211_ops wl_cfg80211_ops = {
 	.add_virtual_intf = wl_cfg80211_add_virtual_iface,
@@ -10475,9 +10315,6 @@
 	.update_ft_ies = wl_cfg80211_update_ft_ies,
 #endif /* WLFBT */
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION (3, 6, 0)
-	.get_channel = wl_cfg80211_get_channel,
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION (3, 6, 0) */
 };
 
 s32 wl_mode_to_nl80211_iftype(s32 mode)
@@ -10516,7 +10353,7 @@
 		GCC_DIAGNOSTIC_POP();
 		if (iter->ndev) {
 			if (wl_get_drv_status(cfg, AP_CREATED, iter->ndev)) {
-				WL_ERR(("AP active. skip coutry ccode change\n"));
+				WL_ERR(("AP active. skip coutry ccode change"));
 				return false;
 			}
 		}
@@ -10524,7 +10361,7 @@
 
 #ifdef WL_NAN
 	if (wl_cfgnan_is_enabled(cfg) && wl_cfgnan_is_dp_active(net)) {
-		WL_ERR(("NDP established. skip coutry ccode change\n"));
+		WL_ERR(("NDP established. skip coutry ccode change"));
 		return false;
 	}
 #endif /* WL_NAN */
@@ -11061,7 +10898,7 @@
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && defined(SUPPORT_RANDOM_MAC_SCAN) */
 
 #if defined(WL_SAE) || defined(WL_CLIENT_SAE)
-	if (dhd_conf_extsae_chip(dhd))
+	if (wl_extsae_chip(dhd))
 		wdev->wiphy->features |= NL80211_FEATURE_SAE;
 #endif /* WL_SAE || WL_CLIENT_SAE */
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)) && defined(BCMSUP_4WAY_HANDSHAKE)
@@ -11078,6 +10915,10 @@
 	wiphy_ext_feature_set(wdev->wiphy, NL80211_EXT_FEATURE_HIGH_ACCURACY_SCAN);
 	wdev->wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN;
 #endif /* WL_SCAN_TYPE */
+
+#ifdef DHD_PNO_FLAG
+	wiphy_ext_feature_set(wdev->wiphy, NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI);
+#endif
 
 	/* Now we can register wiphy with cfg80211 module */
 	err = wiphy_register(wdev->wiphy);
@@ -12414,7 +12255,7 @@
 		memcpy(&emsg, as->event_msg, sizeof(wl_event_msg_t));
 		ret = wl_ext_in4way_sync(ndev, STA_REASSOC_RETRY,
 			WL_EXT_STATUS_RECONNECT, &emsg);
-		if (ret == BCME_ERROR)
+		if (ret)
 			return 0;
 	}
 	wl_ext_iapsta_enable_master_if(ndev, FALSE);
@@ -12570,13 +12411,7 @@
 		memcpy(&emsg, as->event_msg, sizeof(wl_event_msg_t));
 		ret = wl_ext_in4way_sync(ndev, STA_REASSOC_RETRY,
 			WL_EXT_STATUS_RECONNECT, &emsg);
-		if (ret == BCME_BADADDR) {
-			u8 *curbssid = NULL;
-			curbssid = wl_read_prof(cfg, ndev, WL_PROF_BSSID);
-			if (curbssid)
-				(void)memcpy_s(as->addr, ETH_ALEN, curbssid, ETH_ALEN);
-		}
-		else if (ret == BCME_ERROR)
+		if (ret)
 			return 0;
 	}
 #endif
@@ -12700,11 +12535,6 @@
 		wl_ext_iapsta_restart_master(ndev);
 	}
 #endif
-
-	if (wl_get_drv_status(cfg, DISCONNECTING, ndev)) {
-		/* If DISCONNECTING bit is set, mark locally generated */
-		loc_gen = 1;
-	}
 
 	CFG80211_DISCONNECTED(ndev, reason, ie_ptr, ie_len,
 		loc_gen, GFP_KERNEL);
@@ -12953,22 +12783,6 @@
 		goto exit;
 	}
 
-#ifdef WL_ROAM_WAR
-	if (event_type == WLC_E_JOIN)
-		bzero((u8*)&cfg->roaming_bssid, ETHER_ADDR_LEN);
-	else if (wl_get_drv_status(cfg, CONNECTED, ndev)) {
-		if (event_type == WLC_E_AUTH && ntoh32(e->status) == WLC_E_STATUS_SUCCESS)
-			bcopy(&e->addr, &cfg->roaming_bssid, ETHER_ADDR_LEN);
-		else if (event_type == WLC_E_DEAUTH &&
-				!ETHER_ISNULLADDR(&cfg->roaming_bssid.octet) &&
-				memcmp(&e->addr, &cfg->roaming_bssid, ETHER_ADDR_LEN)) {
-			WL_MSG(ndev->name, "skip WLC_E_DEAUTH(%pM), roaming_bssid %pM\n",
-				&e->addr, &cfg->roaming_bssid);
-			goto exit;
-		}
-	}
-#endif /* WL_ROAM_WAR */
-
 	if (wl_get_drv_status(cfg, CONNECTING, ndev)) {
 		assoc_state = WL_STATE_ASSOCIATING;
 	} else if (wl_get_drv_status(cfg, CONNECTED, ndev)) {
@@ -13117,14 +12931,8 @@
 			ndev = cfgdev_to_wlc_ndev(cfgdev, cfg);
 			if (ndev) {
 				wdev = ndev->ieee80211_ptr;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
-				wdev->u.client.ssid_len =
-					min(ssid->SSID_len, (uint32)DOT11_MAX_SSID_LEN);
-				memcpy(wdev->u.client.ssid, ssid->SSID, wdev->u.client.ssid_len);
-#else
 				wdev->ssid_len = min(ssid->SSID_len, (uint32)DOT11_MAX_SSID_LEN);
 				memcpy(wdev->ssid, ssid->SSID, wdev->ssid_len);
-#endif /* CFG80211_BKPORT_MLO */
 				WL_ERR(("SSID is %s\n", ssid->SSID));
 				wl_update_prof(cfg, ndev, NULL, ssid, WL_PROF_SSID);
 			} else {
@@ -13671,6 +13479,7 @@
 	return err;
 }
 
+#ifdef DHD_LOSSLESS_ROAMING
 static s32
 wl_bss_roaming_done(struct bcm_cfg80211 *cfg, struct net_device *ndev,
 	const wl_event_msg_t *e, void *data)
@@ -13678,14 +13487,14 @@
 	struct wl_connect_info *conn_info = wl_to_conn(cfg);
 	s32 err = 0;
 	u8 *curbssid;
-	chanspec_t *chanspec, cur_chanspec;
+	chanspec_t *chanspec;
 	scb_val_t scbval;
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)) || \
 	defined(WL_COMPAT_WIRELESS)
 	struct wiphy *wiphy = bcmcfg_to_wiphy(cfg);
 	struct ieee80211_channel *notify_channel = NULL;
 	u32 freq;
-	u32 cur_channel, orig_channel;
+	u32 cur_channel, cur_chanspec, orig_channel;
 #endif /* LINUX_VERSION > 2.6.39 || WL_COMPAT_WIRELESS */
 #if (defined(CONFIG_ARCH_MSM) && defined(CFG80211_ROAMED_API_UNIFIED)) || \
 	(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) || \
@@ -13726,13 +13535,10 @@
 	cur_channel = wf_chspec_ctlchan(wl_chspec_driver_to_host(cur_chanspec));
 	orig_channel = wf_chspec_ctlchan(wl_chspec_driver_to_host(*chanspec));
 	if (dhdp->conf->chip != BCM43569_CHIP_ID) {
-	if (((orig_channel == cur_channel) && memcmp(&ether_null, &cfg->last_roamed_addr, ETHER_ADDR_LEN)) &&
+	if ((orig_channel == cur_channel) &&
 			((memcmp(curbssid, &e->addr, ETHER_ADDR_LEN) == 0) ||
 			(memcmp(&cfg->last_roamed_addr, &e->addr, ETHER_ADDR_LEN) == 0))) {
-		WL_INFORM_MEM(("BSS already present, Skipping roamed event to upper layer\n"));
-		WL_INFORM_MEM(("orig_chan/cur_chan=%d/%d, addr/curbssid/last_roamed_addr=%pM/%pM/%pM\n",
-			orig_channel, cur_channel,
-			(const u8*)(&e->addr), curbssid, (const u8*)(&cfg->last_roamed_addr)));
+		WL_DBG(("BSS already present, Skipping roamed event to upper layer\n"));
 		goto fail;
 	}
 	}
@@ -13766,15 +13572,13 @@
 	}
 	rssi = dtoh32(scbval.val);
 
-	WL_MSG(ndev->name, "%pM(chan=%s-%d/%sMHz) => %pM(chan=%s-%d/%sMHz, rssi: %3d)\n",
-		curbssid,
-		CHSPEC2BANDSTR(*chanspec), wf_chspec_ctlchan(*chanspec),
+	WL_MSG(ndev->name, "%pM(ch:%3d/%sMHz) => %pM(ch:%3d/%sMHz, rssi: %3d)\n",
+		curbssid, orig_channel,
 		CHSPEC_IS20(*chanspec)?"20":
 		CHSPEC_IS40(*chanspec)?"40":
 		CHSPEC_IS80(*chanspec)?"80":
 		CHSPEC_IS160(*chanspec)?"160":"??",
-		(const u8*)(&e->addr),
-		CHSPEC2BANDSTR(cur_chanspec), wf_chspec_ctlchan(cur_chanspec),
+		(const u8*)(&e->addr), cur_channel,
 		CHSPEC_IS20(cur_chanspec)?"20":
 		CHSPEC_IS40(cur_chanspec)?"40":
 		CHSPEC_IS80(cur_chanspec)?"80":
@@ -13815,20 +13619,15 @@
 	DHD_STATLOG_CTRL(dhdp, ST(REASSOC_INFORM),
 		dhd_net2idx(dhdp->info, ndev), 0);
 #ifdef WL_EXT_IAPSTA
-	wl_ext_in4way_sync(ndev, 0, WL_EXT_STATUS_ROAMED, NULL);
+	wl_ext_in4way_sync(ndev, 0, WL_EXT_STATUS_CONNECTED, NULL);
 #endif
 
 #if (defined(CONFIG_ARCH_MSM) && defined(CFG80211_ROAMED_API_UNIFIED)) || \
 	(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) || \
 	defined(WL_FILS_ROAM_OFFLD) || defined(CFG80211_ROAM_API_GE_4_12)
 	memset(&roam_info, 0, sizeof(struct cfg80211_roam_info));
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) || defined(CFG80211_BKPORT_MLO)
-	roam_info.links[0].channel = notify_channel;
-	roam_info.links[0].bssid = curbssid;
-#else
 	roam_info.channel = notify_channel;
 	roam_info.bssid = curbssid;
-#endif /* CFG80211_BKPORT_MLO */
 	roam_info.req_ie = conn_info->req_ie;
 	roam_info.req_ie_len = conn_info->req_ie_len;
 	roam_info.resp_ie = conn_info->resp_ie;
@@ -13881,15 +13680,12 @@
 	return err;
 
 fail:
-#ifdef WL_EXT_IAPSTA
-	if (err)
-		wl_ext_in4way_sync(ndev, STA_NO_BTC_IN4WAY, WL_EXT_STATUS_DISCONNECTED, NULL);
-#endif
 #ifdef DHD_LOSSLESS_ROAMING
 	wl_del_roam_timeout(cfg);
 #endif  /* DHD_LOSSLESS_ROAMING */
 	return err;
 }
+#endif /* DHD_LOSSLESS_ROAMING */
 
 static bool
 wl_cfg80211_verify_bss(struct bcm_cfg80211 *cfg, struct net_device *ndev,
@@ -14025,21 +13821,10 @@
 
 	resp_params = (struct cfg80211_connect_resp_params *)params;
 	resp_params->status = status;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) || defined(CFG80211_BKPORT_MLO)
-	resp_params->links[0].bssid = curbssid;
-	resp_params->links[0].bss = CFG80211_GET_BSS(wiphy, NULL, curbssid,
-		ssid->SSID, ssid->SSID_len);
-#else
 	resp_params->bssid = curbssid;
 	resp_params->bss = CFG80211_GET_BSS(wiphy, NULL, curbssid,
 		ssid->SSID, ssid->SSID_len);
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) || defined(CFG80211_BKPORT_MLO)
-	if (!resp_params->links[0].bss)
-#else
-	if (!resp_params->bss)
-#endif /* CFG80211_BKPORT_MLO */
-	{
+	if (!resp_params->bss) {
 		WL_ERR(("null bss\n"));
 		return BCME_ERROR;
 	}
@@ -14149,12 +13934,7 @@
 			completed = false;
 			sec->auth_assoc_res_status = WLAN_STATUS_UNSPECIFIED_FAILURE;
 		}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
-		if (!ndev->ieee80211_ptr->u.client.ssid_len)
-#else
-		if (!ndev->ieee80211_ptr->ssid_len)
-#endif /* CFG80211_BKPORT_MLO */
-		{
+		if (!ndev->ieee80211_ptr->ssid_len) {
 			/* In certain cases, the delayed cfg80211 work from
 				* disconnect context will induce race conditions in
 				* which the ssid_len will be cleared, but dhd is in
@@ -14182,6 +13962,10 @@
 
 	if (completed) {
 		WL_MSG(ndev->name, "Report connect result - connection succeeded\n");
+#ifdef WL_EXT_IAPSTA
+		wl_ext_in4way_sync(ndev, 0, WL_EXT_STATUS_CONNECTED, NULL);
+		wl_ext_iapsta_enable_master_if(ndev, TRUE);
+#endif
 	} else {
 		WL_MSG(ndev->name, "Report connect result - connection failed\n");
 #ifdef WL_EXT_IAPSTA
@@ -14230,13 +14014,6 @@
 		}
 #endif /* WAPI */
 	}
-
-#ifdef WL_EXT_IAPSTA
-	if (completed) {
-		wl_ext_in4way_sync(ndev, 0, WL_EXT_STATUS_CONNECTED, NULL);
-		wl_ext_iapsta_enable_master_if(ndev, TRUE);
-	}
-#endif
 
 exit:
 	CLR_TS(cfg, conn_start);
@@ -14847,11 +14624,11 @@
 wl_cfg80211_ccode_evt_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
 	const wl_event_msg_t *event, void *data)
 {
-	dhd_pub_t *dhd = cfg->pub;
 	s32 err = 0;
 	struct wiphy *wiphy = bcmcfg_to_wiphy(cfg);
 	char country_str[WLC_CNTRY_BUF_SZ] = { 0 };
 	struct net_device *dev = bcmcfg_to_prmry_ndev(cfg);
+	wl_country_t cspec = {{0}, 0, {0}};
 
 	if (strlcpy(country_str, data, WL_CCODE_LEN + 1) >= WLC_CNTRY_BUF_SZ) {
 		return -EINVAL;
@@ -14864,7 +14641,18 @@
 	}
 
 	WL_MSG(dev->name, "Updating new country %s\n", country_str);
-	dhd_conf_country(dhd, "country", country_str);
+
+	strlcpy(cspec.country_abbrev, country_str, WL_CCODE_LEN + 1);
+	strlcpy(cspec.ccode, country_str, WL_CCODE_LEN + 1);
+	err = dhd_conf_map_country_list(dhd_get_pub(dev), &cspec);
+	if (err)
+		dhd_get_customized_country_code(dev, (char *)&cspec.country_abbrev, &cspec);
+	err = dhd_conf_set_country(dhd_get_pub(dev), &cspec);
+	if (err < 0) {
+		WL_ERR(("set country for %s as %s rev %d failed\n",
+			country_str, cspec.ccode, cspec.rev));
+	}
+	dhd_conf_fix_country(dhd_get_pub(dev));
 
 	/* Indicate to upper layer for regdom change */
 	err = wl_update_wiphybands(cfg, true);
@@ -15010,11 +14798,9 @@
 	cfg->evt_handler[WLC_E_BSS_LOAD] = wl_cfg80211_bssload_report_event_handler;
 #endif /* WL_CHAN_UTIL */
 #ifdef WL_TWT
-	cfg->evt_handler[WLC_E_TWT] = wl_notify_twt_event;
-#else
-#ifdef WL_TWT_HAL_IF
-	cfg->evt_handler[WLC_E_TWT] = wl_cfgvendor_notify_twt_event;
-#endif /* WL_TWT_HAL_IF */
+	cfg->evt_handler[WLC_E_TWT_SETUP] = wl_notify_twt_event;
+	cfg->evt_handler[WLC_E_TWT_TEARDOWN] = wl_notify_twt_event;
+	cfg->evt_handler[WLC_E_TWT_INFO_FRM] = wl_notify_twt_event;
 #endif /* WL_TWT */
 #ifdef WL_CLIENT_SAE
 	cfg->evt_handler[WLC_E_JOIN_START] = wl_notify_start_auth;
@@ -15394,7 +15180,7 @@
 
 	wdev = ndev_to_wdev(dev);
 	if (!wdev) {
-		WL_DBG(("wdev(%s) null. Do nothing\n", dev->name));
+		WL_ERR(("wdev null. Do nothing\n"));
 		return NOTIFY_DONE;
 	}
 
@@ -15901,6 +15687,9 @@
 	wl_destroy_event_handler(cfg);
 	wl_flush_eq(cfg);
 	wl_link_down(cfg);
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
+	cancel_delayed_work_sync(&cfg->sched_scan_stop_work);
+#endif /* WL_SCHED_SCAN */
 	del_timer_sync(&cfg->scan_timeout);
 #ifdef DHD_LOSSLESS_ROAMING
 	del_timer_sync(&cfg->roam_timeout);
@@ -16167,6 +15956,9 @@
 	INIT_WORK(&cfg->wlan_work, wl_cfg80211_work_handler);
 #endif /* DHCP_SCAN_SUPPRESS */
 
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
+	INIT_DELAYED_WORK(&cfg->sched_scan_stop_work, wl_cfgscan_sched_scan_stop_work);
+#endif /* WL_SCHED_SCAN */
 	INIT_DELAYED_WORK(&cfg->pm_enable_work, wl_cfg80211_work_handler);
 	INIT_DELAYED_WORK(&cfg->loc.work, wl_cfgscan_listen_complete_work);
 	INIT_DELAYED_WORK(&cfg->ap_work, wl_cfg80211_ap_timeout_work);
@@ -16433,7 +16225,7 @@
 
 #ifdef OEM_ANDROID
 	if (cfg->event_workq == NULL) {
-		WL_ERR(("Event handler is not created (%s)\n", bcmevent_get_name(event_type)));
+		WL_ERR(("Event handler is not created\n"));
 		return;
 	}
 #endif /* OEM_ANDROID */
@@ -16820,8 +16612,7 @@
 	return err;
 }
 
-static int wl_construct_reginfo(struct bcm_cfg80211 *cfg, s32 bw_cap_2g,
-	s32 bw_cap_5g, s32 bw_cap_6g)
+static int wl_construct_reginfo(struct bcm_cfg80211 *cfg, s32 bw_cap)
 {
 	struct net_device *dev = bcmcfg_to_prmry_ndev(cfg);
 	struct ieee80211_channel *band_chan_arr = NULL;
@@ -16889,13 +16680,14 @@
 			(channel <= CH_MAX_2G_CHANNEL)) {
 			band_chan_arr = __wl_2ghz_channels;
 			array_size = ARRAYSIZE(__wl_2ghz_channels);
+			ht40_allowed = (bw_cap  == WLC_N_BW_40ALL)? true : false;
 		}
 #ifdef CFG80211_6G_SUPPORT
 		else if (CHSPEC_IS6G(chspec) && (channel >= CH_MIN_6G_CHANNEL) &&
 			(channel <= CH_MAX_6G_CHANNEL)) {
 			band_chan_arr = __wl_6ghz_channels;
 			array_size = ARRAYSIZE(__wl_6ghz_channels);
-			ht40_allowed = WL_BW_CAP_40MHZ(bw_cap_6g);
+			ht40_allowed = (bw_cap  == WLC_N_BW_20ALL)? false : true;
 		}
 #endif /* CFG80211_6G_SUPPORT */
 		else if (
@@ -16909,7 +16701,7 @@
 			(CHSPEC_IS5G(chspec) && channel >= CH_MIN_5G_CHANNEL)) {
 				band_chan_arr = __wl_5ghz_a_channels;
 				array_size = ARRAYSIZE(__wl_5ghz_a_channels);
-			ht40_allowed = WL_BW_CAP_40MHZ(bw_cap_5g);
+			ht40_allowed = (bw_cap  == WLC_N_BW_20ALL)? false : true;
 		} else {
 			WL_ERR(("Invalid channel Sepc. 0x%x.\n", chspec));
 			continue;
@@ -16917,7 +16709,7 @@
 		if (!ht40_allowed && CHSPEC_IS40(chspec))
 			continue;
 		for (j = 0; j < array_size; j++) {
-			if (band_chan_arr[j].hw_value == wf_chspec_primary20_chspec(chspec)) {
+			if (band_chan_arr[j].hw_value == chspec) {
 				break;
 			}
 		}
@@ -16932,7 +16724,7 @@
 			band_chan_arr[index].center_freq =
 				wl_channel_to_frequency(channel, CHSPEC_BAND(chspec));
 #endif
-			band_chan_arr[index].hw_value = wf_chspec_primary20_chspec(chspec);
+			band_chan_arr[index].hw_value = chspec;
 			band_chan_arr[index].beacon_found = false;
 			band_chan_arr[index].flags &= ~IEEE80211_CHAN_DISABLED;
 
@@ -16940,14 +16732,12 @@
 				/* assuming the order is HT20, HT40 Upper,
 				 *  HT40 lower from chanspecs
 				 */
-				u32 ht40_flag =
-					band_chan_arr[index].flags & IEEE80211_CHAN_NO_HT40;
+				u32 ht40_flag = band_chan_arr[index].flags & IEEE80211_CHAN_NO_HT40;
 				if (CHSPEC_SB_UPPER(chspec)) {
 					if (ht40_flag == IEEE80211_CHAN_NO_HT40)
 						band_chan_arr[index].flags &=
 							~IEEE80211_CHAN_NO_HT40;
-					band_chan_arr[index].flags |=
-						IEEE80211_CHAN_NO_HT40PLUS;
+					band_chan_arr[index].flags |= IEEE80211_CHAN_NO_HT40PLUS;
 				} else {
 					/* It should be one of
 					 * IEEE80211_CHAN_NO_HT40 or IEEE80211_CHAN_NO_HT40PLUS
@@ -16972,12 +16762,6 @@
 		}
 
 	}
-
-	WL_CHANNEL_COPY_FLAG(__wl_2ghz_channels);
-	WL_CHANNEL_COPY_FLAG(__wl_5ghz_a_channels);
-#ifdef CFG80211_6G_SUPPORT
-	WL_CHANNEL_COPY_FLAG(__wl_6ghz_channels);
-#endif /* CFG80211_6G_SUPPORT */
 
 	__wl_band_2ghz.n_channels = ARRAYSIZE(__wl_2ghz_channels);
 	__wl_band_5ghz_a.n_channels = ARRAYSIZE(__wl_5ghz_a_channels);
@@ -17017,8 +16801,8 @@
 	s32 err = 0;
 	s32 index = 0;
 	s32 nmode = 0;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) || defined(CUSTOMER_HW5)
 	u32 j = 0;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
 	s32 vhtmode = 0;
 	s32 txstreams = 0;
 	s32 rxstreams = 0;
@@ -17027,14 +16811,11 @@
 	s32 stbc_tx = 0;
 	s32 txbf_bfe_cap = 0;
 	s32 txbf_bfr_cap = 0;
-#endif
-	s32 txchain = 0;
-	s32 rxchain = 0;
-	s32 bw_cap_2g = 0, bw_cap_5g = 0, bw_cap_6g = 0;
+#endif /* KERNEL >= 3.6 || CUSTOMER_HW5 */
+	s32 bw_cap = 0;
 	s32 cur_band = -1;
 	struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS] = {NULL, };
 
-	WL_INFORM(("%s: Enter\n", __FUNCTION__));
 	bzero(bandlist, sizeof(bandlist));
 	err = wldev_ioctl_get(dev, WLC_GET_BANDLIST, bandlist,
 		sizeof(bandlist));
@@ -17054,7 +16835,7 @@
 		WL_ERR(("error reading nmode (%d)\n", err));
 	}
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) || defined(CUSTOMER_HW5)
 	err = wldev_iovar_getint(dev, "vhtmode", &vhtmode);
 	if (unlikely(err)) {
 		WL_ERR(("error reading vhtmode (%d)\n", err));
@@ -17096,58 +16877,25 @@
 			WL_ERR(("error reading txbf_bfr_cap (%d)\n", err));
 		}
 	}
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) */
-
-	err = wldev_iovar_getint(dev, "txchain", &txchain);
-	if (unlikely(err)) {
-		WL_ERR(("error reading txchain (%d)\n", err));
-	} else if (txchain == 0x03) {
-		txchain = 2;
-	} else {
-		txchain = 1;
-	}
-	err = wldev_iovar_getint(dev, "rxchain", &rxchain);
-	if (unlikely(err)) {
-		WL_ERR(("error reading rxchain (%d)\n", err));
-	} else if (rxchain == 0x03) {
-		rxchain = 2;
-	} else {
-		rxchain = 1;
-	}
+#endif /* KERNEL >= 3.6 || CUSTOMER_HW5 */
 
 	/* For nmode and vhtmode   check bw cap */
 	if (nmode ||
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) || defined(CUSTOMER_HW5)
 		vhtmode ||
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) */
+#endif /* KERNEL >= 3.6 || CUSTOMER_HW5 */
 		0) {
-		uint32 value;
-
-		value = WLC_BAND_2G;
-		err = wldev_iovar_getint(dev, "bw_cap", &value);
+		err = wldev_iovar_getint(dev, "mimo_bw_cap", &bw_cap);
 		if (unlikely(err)) {
-			WL_ERR(("error get bw_cap 2g (%d)\n", err));
+			WL_ERR(("error get mimo_bw_cap (%d)\n", err));
 		}
-		bw_cap_2g = dtoh32(value);
-		value = WLC_BAND_5G;
-		err = wldev_iovar_getint(dev, "bw_cap", &value);
-		if (unlikely(err)) {
-			WL_ERR(("error get bw_cap 5g (%d)\n", err));
-		}
-		bw_cap_5g = dtoh32(value);
-		value = WLC_BAND_6G;
-		err = wldev_iovar_getint(dev, "bw_cap", &value);
-		if (unlikely(err)) {
-			WL_ERR(("error get bw_cap 6g (%d)\n", err));
-		}
-		bw_cap_6g = dtoh32(value);
 	}
 
 #ifdef WL_6G_BAND
 	wl_is_6g_supported(cfg, bandlist, bandlist[0]);
 #endif /* WL_6G_BAND */
 
-	err = wl_construct_reginfo(cfg, bw_cap_2g, bw_cap_5g, bw_cap_6g);
+	err = wl_construct_reginfo(cfg, bw_cap);
 	if (err) {
 		WL_ERR(("wl_construct_reginfo() fails err=%d\n", err));
 		if (err != BCME_UNSUPPORTED)
@@ -17157,9 +16905,6 @@
 	wiphy = bcmcfg_to_wiphy(cfg);
 	nband = bandlist[0];
 
-	wiphy->available_antennas_tx = txchain;
-	wiphy->available_antennas_rx = rxchain;
-
 	for (i = 1; i <= nband && i < ARRAYSIZE(bandlist); i++) {
 		index = -1;
 
@@ -17167,18 +16912,8 @@
 			bands[IEEE80211_BAND_2GHZ] =
 				&__wl_band_2ghz;
 			index = IEEE80211_BAND_2GHZ;
-			(void)memset_s(bands[index]->ht_cap.mcs.rx_mask, IEEE80211_HT_MCS_MASK_LEN,
-				0, IEEE80211_HT_MCS_MASK_LEN);
-			if (nmode && (WL_BW_CAP_40MHZ(bw_cap_2g))) {
-				bands[index]->ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
-					IEEE80211_HT_CAP_SGI_40;
-				bands[index]->ht_cap.mcs.rx_mask[4] = 0x01;
-				bands[index]->ht_cap.mcs.rx_highest =
-					cpu_to_le16(150 * rxchain); /* Mbps */
-			} else {
-				bands[index]->ht_cap.mcs.rx_highest =
-					cpu_to_le16(72 * rxchain); /* Mbps */
-			}
+			if (bw_cap == WLC_N_BW_40ALL)
+				bands[index]->ht_cap.cap |= IEEE80211_HT_CAP_SGI_40;
 		} else {
 			if (bandlist[i] == WLC_BAND_6G) {
 #ifdef CFG80211_6G_SUPPORT
@@ -17209,26 +16944,14 @@
 				continue;
 			}
 
-			(void)memset_s(bands[index]->ht_cap.mcs.rx_mask, IEEE80211_HT_MCS_MASK_LEN,
-				0, IEEE80211_HT_MCS_MASK_LEN);
-			if (nmode && (WL_BW_CAP_40MHZ(bw_cap_5g))) {
-				bands[index]->ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
-					IEEE80211_HT_CAP_SGI_40;
-				bands[index]->ht_cap.mcs.rx_mask[4] = 0x01;
-				bands[index]->ht_cap.mcs.rx_highest = cpu_to_le16(150 * rxchain);
-			} else {
-				bands[index]->ht_cap.mcs.rx_highest = cpu_to_le16(72 * rxchain);
-			}
+			if (nmode && (bw_cap == WLC_N_BW_40ALL || bw_cap == WLC_N_BW_20IN2G_40IN5G))
+				bands[index]->ht_cap.cap |= IEEE80211_HT_CAP_SGI_40;
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) || defined(CUSTOMER_HW5)
 			/* VHT capabilities. */
 			if (vhtmode) {
 				/* Supported */
 				bands[index]->vht_cap.vht_supported = TRUE;
-				bands[index]->vht_cap.vht_mcs.tx_highest =
-					cpu_to_le16(433 * txstreams); /* Mbps */
-				bands[index]->vht_cap.vht_mcs.rx_highest =
-					cpu_to_le16(433 * txstreams); /* Mbps */
 
 				for (j = 1; j <= VHT_CAP_MCS_MAP_NSS_MAX; j++) {
 					/* TX stream rates. */
@@ -17251,13 +16974,11 @@
 				}
 
 				/* Capabilities */
-				bands[index]->vht_cap.cap |=   IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN
-				                             | IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
 				/* 80 MHz is mandatory */
 				bands[index]->vht_cap.cap |=
 					IEEE80211_VHT_CAP_SHORT_GI_80;
 
-				if (WL_BW_CAP_160MHZ(bw_cap_5g)) {
+				if (WL_BW_CAP_160MHZ(bw_cap)) {
 					bands[index]->vht_cap.cap |=
 						IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
 					bands[index]->vht_cap.cap |=
@@ -17309,7 +17030,7 @@
 					bands[index]->vht_cap.vht_mcs.rx_mcs_map,
 					bands[index]->vht_cap.vht_mcs.tx_mcs_map));
 			}
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) */
+#endif /* KERNEL >= 3.6 || CUSTOMER_HW5 */
 		}
 
 		if ((index >= 0) && nmode) {
@@ -17319,10 +17040,7 @@
 			bands[index]->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
 			bands[index]->ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16;
 			/* An HT shall support all EQM rates for one spatial stream */
-			for (j = 0; j < rxchain; j++) {
-				bands[index]->ht_cap.mcs.rx_mask[j] = 0xff;
-			}
-			bands[index]->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
+			bands[index]->ht_cap.mcs.rx_mask[0] = 0xff;
 		}
 
 	}
@@ -17407,10 +17125,6 @@
 	/* Start the event logging */
 	wl_add_remove_eventmsg(ndev, WLC_E_TRACE, TRUE);
 #endif /* SHOW_LOGTRACE */
-#if defined(BCMDBUS)
-	if (!dhd->dhd_console_ms)
-		wl_add_remove_eventmsg(ndev, WLC_E_TRACE, FALSE);
-#endif
 
 	(void)memcpy_s(wdev->wiphy->perm_addr, ETHER_ADDR_LEN,
 		bcmcfg_to_prmry_ndev(cfg)->perm_addr, ETHER_ADDR_LEN);
@@ -17567,77 +17281,6 @@
 	return err;
 }
 
-#ifdef BCMDBUS
-s32
-__wl_cfg80211_up_resume(dhd_pub_t *dhd)
-{
-	struct net_device *ndev = dhd_linux_get_primary_netdev(dhd);
-	struct bcm_cfg80211 *cfg;
-	struct wireless_dev *wdev;
-	s32 err = 0;
-#ifdef WL_HOST_BAND_MGMT
-	s32 ret = 0;
-#endif /* WL_HOST_BAND_MGMT */
-	u16 wl_iftype = 0;
-	u16 wl_mode = 0;
-
-	WL_DBG(("In\n"));
-
-	if (!ndev)
-		return -EINVAL;
-	cfg = wl_get_cfg(ndev);
-	wdev = ndev->ieee80211_ptr;
-	if (!cfg || !wdev)
-		return -EINVAL;
-
-#if defined(BCMDONGLEHOST)
-	err = dhd_config_dongle(cfg);
-	if (unlikely(err))
-		return err;
-#endif /* defined(BCMDONGLEHOST) */
-
-#ifdef SHOW_LOGTRACE
-	/* Start the event logging */
-	wl_add_remove_eventmsg(ndev, WLC_E_TRACE, TRUE);
-#endif /* SHOW_LOGTRACE */
-#if defined(BCMDBUS)
-	if (!dhd->dhd_console_ms)
-		wl_add_remove_eventmsg(ndev, WLC_E_TRACE, FALSE);
-#endif
-
-	if (cfg80211_to_wl_iftype(wdev->iftype, &wl_iftype, &wl_mode) < 0) {
-		return -EINVAL;
-	}
-	if (!dhd->fw_preinit) {
-		err = wl_config_infra(cfg, ndev, wl_iftype);
-		if (unlikely(err && err != -EINPROGRESS)) {
-			WL_ERR(("wl_config_infra failed\n"));
-			if (err == -1) {
-				WL_ERR(("return error %d\n", err));
-				return err;
-			}
-		}
-	}
-
-#ifdef WL_HOST_BAND_MGMT
-	/* By default the curr_band is initialized to BAND_AUTO */
-	if ((ret = wl_cfg80211_set_band(ndev, WLC_BAND_AUTO)) < 0) {
-		if (ret == BCME_UNSUPPORTED) {
-			/* Don't fail the initialization, lets just
-			 * fall back to the original method
-			 */
-			WL_ERR(("WL_HOST_BAND_MGMT defined, "
-				"but roam_band iovar not supported \n"));
-		} else {
-			WL_ERR(("roam_band failed. ret=%d", ret));
-			err = -1;
-		}
-	}
-#endif /* WL_HOST_BAND_MGMT */
-	return err;
-}
-#endif /* BCMDBUS */
-
 static s32 __wl_cfg80211_down(struct bcm_cfg80211 *cfg)
 {
 	s32 err = 0;
@@ -17786,11 +17429,7 @@
 			struct wiphy *wiphy = bcmcfg_to_wiphy(cfg);
 			struct wireless_dev *wdev = ndev->ieee80211_ptr;
 			struct cfg80211_bss *bss = CFG80211_GET_BSS(wiphy, NULL, latest_bssid,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
-				wdev->u.client.ssid, wdev->u.client.ssid_len);
-#else
 				wdev->ssid, wdev->ssid_len);
-#endif /* CFG80211_BKPORT_MLO */
 
 			BCM_REFERENCE(bss);
 
@@ -17949,7 +17588,7 @@
 	if (init_roam_cache(cfg, ioctl_version) == 0) {
 		/* Enable support for Roam cache */
 		cfg->rcc_enabled = true;
-		WL_MSG(net->name, "Roam channel cache enabled\n");
+		WL_ERR(("Roam channel cache enabled\n"));
 	} else {
 		WL_ERR(("Failed to enable RCC.\n"));
 	}
@@ -19699,12 +19338,7 @@
 	while (ie) {
 		if (count >= MAX_VNDR_IE_NUMBER)
 			break;
-#ifdef HOSTAPD_EID_EXTENSION_SUPPORT
-		if (ie->id == DOT11_MNG_VS_ID || (ie->id == DOT11_MNG_ID_EXT_ID))
-#else
-		if (ie->id == DOT11_MNG_VS_ID)
-#endif
-		{
+		if (ie->id == DOT11_MNG_VS_ID || (ie->id == DOT11_MNG_ID_EXT_ID)) {
 			vndrie = (const vndr_ie_t *) ie;
 			if (ie->id == DOT11_MNG_ID_EXT_ID) {
 				/* len should be bigger than sizeof ID extn field at least */
@@ -20044,40 +19678,6 @@
 	return 0;
 }
 
-#ifdef GET_FW_IE_DATA
-static void
-wl_dump_ie_buf(vndr_ie_buf_t *ie_getbuf)
-{
-	uchar *iebuf;
-	uchar *data;
-	int tot_ie, pktflag, iecount, datalen;
-	vndr_ie_info_t *ie_info;
-	vndr_ie_t *ie;
-
-	memcpy(&tot_ie, (void *)&ie_getbuf->iecount, sizeof(int));
-	tot_ie = dtoh32(tot_ie);
-	iebuf = (uchar *)&ie_getbuf->vndr_ie_list[0];
-
-	printf("-----------------\n");
-	printf("Total IEs %d\n", tot_ie);
-	for (iecount = 0; iecount < tot_ie; iecount++) {
-		ie_info = (vndr_ie_info_t *) iebuf;
-		memcpy(&pktflag, (void *)&ie_info->pktflag, sizeof(uint32));
-		pktflag = dtoh32(pktflag);
-		iebuf += sizeof(uint32);
-		ie = &ie_info->vndr_ie_data;
-		data = &ie->data[0];
-		datalen = ie->len - VNDR_IE_MIN_LEN;
-		printf("index=%d, pktflag=0x%x\n", iecount, pktflag);
-		prhex("IE", (u8 *)ie, ie->len+VNDR_IE_HDR_LEN);
-
-		iebuf += ie->len + VNDR_IE_HDR_LEN;
-	}
-	printf("-----------------\n");
-	printf("\n");
-}
-#endif /* GET_FW_IE_DATA */
-
 static void
 wl_print_fw_ie_data(struct bcm_cfg80211 *cfg, struct net_device *ndev, s32 bssidx)
 {
@@ -20089,10 +19689,18 @@
 		bssidx, &cfg->ioctl_buf_sync);
 	if (ret == BCME_OK) {
 		ies = (vndr_ie_buf_t *)cfg->ioctl_buf;
+		WL_INFORM_MEM(("FW IE count:%d ", ies->iecount));
 #ifdef GET_FW_IE_DATA
-		wl_dump_ie_buf((vndr_ie_buf_t *)cfg->ioctl_buf);
-#else
-		WL_MSG(ndev->name, "FW IE count:%d\n", ies->iecount);
+		if (wl_dbg_level & WL_DBG_DBG) {
+			int i = 0;
+			/* If debug enabled, print each IE */
+			for (i = 0; i < ies->iecount; i++) {
+				vndr_ie_info_t *info = &ies->vndr_ie_list[i];
+				WL_DBG_MEM(("pktflag:0x%x\n", info->pktflag));
+					prhex("IE:", (u8 *)&info->vndr_ie_data,
+						info->vndr_ie_data.len + TLV_HDR_LEN);
+			}
+		}
 #endif /* GET_FW_IE_DATA */
 	} else {
 		WL_ERR(("IE retrieval failed! ret:%d\n", ret));
@@ -20116,7 +19724,6 @@
 	u32 parsed_ie_buf_len = 0;
 	struct parsed_vndr_ies old_vndr_ies;
 	struct parsed_vndr_ies new_vndr_ies;
-	int del_add_cnt = 0;
 	s32 i;
 	u8 *ptr;
 	s32 remained_buf_len;
@@ -20260,7 +19867,6 @@
 
 				curr_ie_buf += del_add_ie_buf_len;
 				total_ie_buf_len += del_add_ie_buf_len;
-				del_add_cnt++;
 			}
 		}
 
@@ -20310,32 +19916,13 @@
 				*mgmt_ie_len += vndrie_info->ie_len;
 				curr_ie_buf += del_add_ie_buf_len;
 				total_ie_buf_len += del_add_ie_buf_len;
-				del_add_cnt++;
 			}
 		}
 
 		if (total_ie_buf_len && cfg->ioctl_buf != NULL) {
-#ifdef VNDR_IE_WAR
-			curr_ie_buf = g_mgmt_ie_buf;
-			for (i=0; i<del_add_cnt; i++) {
-				vndr_ie_setbuf_t *vndr_ie_setbuf = (vndr_ie_setbuf_t *)curr_ie_buf;
-				u32 curr_ie_buf_len;
-				curr_ie_buf_len =
-					(u8*)&vndr_ie_setbuf->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.oui[0] -
-					(u8*)vndr_ie_setbuf;
-				curr_ie_buf_len += vndr_ie_setbuf->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.len;
-				ret = wldev_iovar_setbuf_bsscfg(ndev, "vndr_ie", curr_ie_buf,
-					curr_ie_buf_len, cfg->ioctl_buf, WLC_IOCTL_MAXLEN,
-					bssidx, &cfg->ioctl_buf_sync);
-				if (ret)
-					break;
-				curr_ie_buf += curr_ie_buf_len;
-			}
-#else
-			ret = wldev_iovar_setbuf_bsscfg(ndev, "vndr_ie", g_mgmt_ie_buf,
+			ret  = wldev_iovar_setbuf_bsscfg(ndev, "vndr_ie", g_mgmt_ie_buf,
 				total_ie_buf_len, cfg->ioctl_buf, WLC_IOCTL_MAXLEN,
 				bssidx, &cfg->ioctl_buf_sync);
-#endif
 			if (ret) {
 				WL_ERR(("vndr_ie set error :%d\n", ret));
 				if (ret == BCME_NOTFOUND) {

--
Gitblit v1.6.2