[rdkb][common][bsp][Refactor and sync wifi from openwrt]

[Description]
ced8594f [MAC80211][WiFi6][Misc][Fix the MT76 WiFi6 Makefile]
7221999e [MAC80211][WiFi7][Misc][Correct the MAC80211 WiFi7 Makefile.]
9d87794a [MAC80211][WiFi7][Misc][Correct the MT76 WiFi7 Makefile.]
ff24e1b2 [openwrt-24][Mac80211][Fix patch conflict with upstream openwrt]
3a6c13e2 [mac80211][misc][fix patch fail due to openwrt update]
05763faa [MAC80211][WiFi7][misc][fix patch failed of wifi-scripts]
f34fd014 [mac80211][misc][fix patch fail due to openwrt update]
f6796660 [openwrt-24][Release][Fix build fail of Wi-Fi7 MT76]
7076d96c [MAC80211][WiFi7][Misc][Fix release build fail because of mt76 version upgradation]
1f748b17 [mac80211][misc][fix patch fail due to openwrt update]
95ba6722 [mac80211][misc][fix patch fail due to openwrt update]
17680d7f [MAC80211][WiFi7][misc][Rename eeprom of eFEM variants]
b97cefa1 [MAC80211][WiFi7][app][Add Griffin support for atenl/iwpriv]
6de718a4 [MAC80211][WiFi7][misc][fix wifi-scripts patch failed]
9f1ace86 [MAC80211][WiFi7][misc][fix hostapd Makefile patch]
e4d0d28e [MAC80211][Misc][Add MT7990 Firmware OpenWrt config]
f3a8a8f7 [MAC80211][Release][Fix build fail of Wi-Fi6 MT76]
dabe8eae [openwrt-24][common][bsp][Fix line ending]
6d438a9d [openwrt-24][common][bsp][Use zstd to compress rootfs debug symbols for unified autobuild]
c268e47e [openwrt][common][bsp][Change SMC ID of wdt nonrst reg of reset-boot-count to 0x570]
c6819fbc [openwrt-24][Release][Update release note for Filogic 880 alpha release]
6897b4de [openwrt-24][common][bsp][Adjust unified autobuild for internal build detection]
fb9b9762 [MAC80211][WiFi6/7][app][Add ext eeprom write back cmd support]
d42b42a3 [openwrt-24][common][bsp][Add kernel6.6 Filogic880 BE19000/BE14000]
3806f047 [MAC80211][misc][Add Bpi-R4 support]
ddbda753 [MAC80211][WiFi7][Misc][Fix build fail because of mt76 version upgradation]
90959b08 [MAC80211][WiFi6][mt76][Rebase mt76 pathes]
728a3362 [MAC80211][WiFi6][mt76][Refactor Qos Map]
b46277b5 [MAC80211][WiFi6][mt76][Fix add ba issue on tid not equal to zero]
c084ee8b [MAC80211][WiFi7][mt76][split mt76 Makefile patch]
bbaec094 [MAC80211][Release][Update Filogic 830/820/630 firmware]
5ce2eece [MAC80211][wifi6][MT76][Fix build fail]
5ac1121f [MAC80211][wifi6][MT76][Fix mt76 version to 2024-07-13]
485f92b1 [MAC80211][WiFi7][misc][synchronize PP bitmap when association]
84db8818 [MAC80211][WiFi6/7][app][Add ATETXNSS in iwpriv wrapper]
cc5a4605 [MAC80211][WiFi7][mt76][fix patch failed of Makefile]

[Release-log]

Change-Id: I06704c04c4b5571af4ffd189d636c1fc9f0567fd
diff --git a/recipes-wifi/linux-mt76/files/patches-3.x/0076-mtk-mt76-mt7996-implement-and-switch-to-chanctx-call.patch b/recipes-wifi/linux-mt76/files/patches-3.x/0076-mtk-mt76-mt7996-implement-and-switch-to-chanctx-call.patch
new file mode 100644
index 0000000..0a5ab02
--- /dev/null
+++ b/recipes-wifi/linux-mt76/files/patches-3.x/0076-mtk-mt76-mt7996-implement-and-switch-to-chanctx-call.patch
@@ -0,0 +1,384 @@
+From f6889bcb95884df285d628c93b78fe28a5008262 Mon Sep 17 00:00:00 2001
+From: Shayne Chen <shayne.chen@mediatek.com>
+Date: Mon, 6 Nov 2023 16:17:11 +0800
+Subject: [PATCH 076/223] mtk: mt76: mt7996: implement and switch to chanctx
+ callbacks
+
+To support MLO, chanctx callbacks are mandatory, since one VIF (MLD) could
+operate on multiple channels (links).
+This is a preliminary patch to add MLO support for mt7996 chipsets.
+
+Change-Id: Ie4530a3bc2ac9e51045184d5aecca14118177042
+Co-developed-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
+---
+ mt7996/init.c   |  22 ++++++
+ mt7996/mac.c    |  10 ++-
+ mt7996/main.c   | 178 ++++++++++++++++++++++++++++++++++++++++++++----
+ mt7996/mcu.c    |   2 +-
+ mt7996/mt7996.h |  17 +++++
+ 5 files changed, 211 insertions(+), 18 deletions(-)
+
+diff --git a/mt7996/init.c b/mt7996/init.c
+index a188fa1d..7afbd46a 100644
+--- a/mt7996/init.c
++++ b/mt7996/init.c
+@@ -384,6 +384,7 @@ mt7996_init_wiphy(struct ieee80211_hw *hw, struct mtk_wed_device *wed)
+ 
+ 	hw->sta_data_size = sizeof(struct mt7996_sta);
+ 	hw->vif_data_size = sizeof(struct mt7996_vif);
++	hw->chanctx_data_size = sizeof(struct mt7996_chanctx);
+ 
+ 	wiphy->iface_combinations = if_comb;
+ 	wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
+@@ -419,6 +420,7 @@ mt7996_init_wiphy(struct ieee80211_hw *hw, struct mtk_wed_device *wed)
+ 	ieee80211_hw_set(hw, SUPPORTS_RX_DECAP_OFFLOAD);
+ 	ieee80211_hw_set(hw, WANT_MONITOR_VIF);
+ 	ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
++	ieee80211_hw_set(hw, CHANCTX_STA_CSA);
+ 
+ 	hw->max_tx_fragments = 4;
+ 
+@@ -639,6 +641,22 @@ static int mt7996_vow_init(struct mt7996_phy *phy)
+ 	return mt7996_mcu_set_vow_feature_ctrl(phy);
+ }
+ 
++static void mt7996_init_chanctx(struct mt7996_phy *phy)
++{
++	struct ieee80211_supported_band *sband;
++	struct ieee80211_channel *chan;
++
++	if (phy->mt76->band_idx == MT_BAND2)
++		sband = &phy->mt76->sband_6g.sband;
++	else if (phy->mt76->band_idx == MT_BAND1)
++		sband = &phy->mt76->sband_5g.sband;
++	else
++		sband = &phy->mt76->sband_2g.sband;
++
++	chan = &sband->channels[0];
++	cfg80211_chandef_create(&phy->mt76->chandef, chan, NL80211_CHAN_HT20);
++}
++
+ static int mt7996_register_phy(struct mt7996_dev *dev, struct mt7996_phy *phy,
+ 			       enum mt76_band_id band)
+ {
+@@ -722,6 +740,8 @@ static int mt7996_register_phy(struct mt7996_dev *dev, struct mt7996_phy *phy,
+ 	if (ret)
+ 		goto error;
+ 
++	mt7996_init_chanctx(phy);
++
+ 	ret = mt7996_thermal_init(phy);
+ 	if (ret)
+ 		goto error;
+@@ -1629,6 +1649,8 @@ int mt7996_register_device(struct mt7996_dev *dev)
+ 	if (ret)
+ 		return ret;
+ 
++	mt7996_init_chanctx(&dev->phy);
++
+ 	ret = mt7996_thermal_init(&dev->phy);
+ 	if (ret)
+ 		return ret;
+diff --git a/mt7996/mac.c b/mt7996/mac.c
+index 5c29fe7f..7cfc25ba 100644
+--- a/mt7996/mac.c
++++ b/mt7996/mac.c
+@@ -2797,7 +2797,10 @@ void mt7996_scan_work(struct work_struct *work)
+ 		mt7996_scan_complete(phy, false);
+ 		mutex_unlock(&phy->dev->mt76.mutex);
+ 
+-		mt7996_set_channel(phy, &hw->conf.chandef);
++		if (phy->chanctx)
++			mt7996_set_channel(phy, &phy->chanctx->chandef);
++		else
++			mt7996_set_channel(phy, &phy->mt76->chandef);
+ 
+ 		return;
+ 	}
+@@ -2809,7 +2812,10 @@ void mt7996_scan_work(struct work_struct *work)
+ 		phy->scan_chan = NULL;
+ 		mutex_unlock(&phy->dev->mt76.mutex);
+ 
+-		mt7996_set_channel(phy, &phy->mt76->chandef);
++		if (phy->chanctx)
++			mt7996_set_channel(phy, &phy->chanctx->chandef);
++		else
++			mt7996_set_channel(phy, &phy->mt76->chandef);
+ 
+ 		ieee80211_queue_delayed_work(hw, &phy->scan_work, HZ / 10);
+ 
+diff --git a/mt7996/main.c b/mt7996/main.c
+index 475763e4..cbd64681 100644
+--- a/mt7996/main.c
++++ b/mt7996/main.c
+@@ -76,6 +76,11 @@ int mt7996_run(struct ieee80211_hw *hw)
+ 	if (ret)
+ 		goto out;
+ 
++	/* set a parking channel */
++	ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH);
++	if (ret)
++		goto out;
++
+ 	ret = mt7996_mcu_set_thermal_throttling(phy, MT7996_THERMAL_THROTTLE_MAX);
+ 	if (ret)
+ 		goto out;
+@@ -508,21 +513,6 @@ static int mt7996_config(struct ieee80211_hw *hw, u32 changed)
+ 	struct mt7996_phy *phy = mt7996_hw_phy(hw);
+ 	int ret;
+ 
+-	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
+-		if (!mt76_testmode_enabled(phy->mt76) && !phy->mt76->test.bf_en) {
+-			ret = mt7996_mcu_edcca_enable(phy, true);
+-			if (ret)
+-				return ret;
+-		}
+-
+-		ret = mt7996_mcu_set_pp_en(phy, PP_USR_MODE,
+-					   phy->mt76->chandef.punctured);
+-		if (ret)
+-			return ret;
+-
+-		mt7996_set_channel(phy, &hw->conf.chandef);
+-	}
+-
+ 	if (changed & (IEEE80211_CONF_CHANGE_POWER |
+ 		       IEEE80211_CONF_CHANGE_CHANNEL)) {
+ 		ret = mt7996_mcu_set_txpower_sku(phy);
+@@ -1723,6 +1713,158 @@ mt7996_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
+ 	mutex_unlock(&phy->dev->mt76.mutex);
+ }
+ 
++static int
++mt7996_add_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf)
++{
++	struct mt7996_phy *phy = mt7996_hw_phy(hw);
++	struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
++	int ret;
++
++	wiphy_info(hw->wiphy, "%s: add %u\n", __func__, conf->def.chan->hw_value);
++	mutex_lock(&phy->dev->mt76.mutex);
++
++	if (ctx->assigned) {
++		mutex_unlock(&phy->dev->mt76.mutex);
++		return -ENOSPC;
++	}
++
++	ctx->assigned = true;
++	ctx->chandef = conf->def;
++	ctx->phy = phy;
++	if (phy->chanctx) {
++		mutex_unlock(&phy->dev->mt76.mutex);
++		return 0;
++	}
++
++	phy->chanctx = ctx;
++	mutex_unlock(&phy->dev->mt76.mutex);
++
++	if (!mt76_testmode_enabled(phy->mt76) && !phy->mt76->test.bf_en) {
++		ret = mt7996_mcu_edcca_enable(phy, true);
++		if (ret)
++			return ret;
++	}
++
++	ret = mt7996_mcu_set_pp_en(phy, PP_USR_MODE, ctx->chandef.punctured);
++	if (ret)
++		return ret;
++
++	return mt7996_set_channel(phy, &ctx->chandef);
++}
++
++static void
++mt7996_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf)
++{
++	struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
++	struct mt7996_phy *phy = ctx->phy;
++
++	wiphy_info(hw->wiphy, "%s: remove %u\n", __func__, conf->def.chan->hw_value);
++	cancel_delayed_work_sync(&phy->scan_work);
++	cancel_delayed_work_sync(&phy->mt76->mac_work);
++
++	mutex_lock(&phy->dev->mt76.mutex);
++	ctx->assigned = false;
++	if (ctx == phy->chanctx)
++		phy->chanctx = NULL;
++	mutex_unlock(&phy->dev->mt76.mutex);
++}
++
++static void
++mt7996_change_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf,
++		      u32 changed)
++{
++	struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
++	struct mt7996_phy *phy = ctx->phy;
++
++	wiphy_info(hw->wiphy, "%s: change %u, 0x%x\n", __func__, conf->def.chan->hw_value, changed);
++	if (changed & IEEE80211_CHANCTX_CHANGE_WIDTH) {
++		ctx->chandef = conf->def;
++
++		mt7996_set_channel(phy, &ctx->chandef);
++	}
++}
++
++static int
++mt7996_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
++			  struct ieee80211_bss_conf *link_conf,
++			  struct ieee80211_chanctx_conf *conf)
++{
++	struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
++	struct mt7996_phy *phy = ctx->phy;
++	struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
++
++	wiphy_info(hw->wiphy, "Assign VIF (addr: %pM, type: %d, link_id: %d) to channel context: %d MHz\n",
++		    vif->addr, vif->type, link_conf->link_id,
++		    conf->def.chan->center_freq);
++
++	mutex_lock(&phy->dev->mt76.mutex);
++
++	mvif->chanctx = ctx;
++	ctx->nbss_assigned++;
++
++	mutex_unlock(&phy->dev->mt76.mutex);
++
++	return 0;
++}
++
++static void
++mt7996_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
++			    struct ieee80211_bss_conf *link_conf,
++			    struct ieee80211_chanctx_conf *conf)
++{
++	struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
++	struct mt7996_phy *phy = ctx->phy;
++	struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
++
++	wiphy_info(hw->wiphy, "Remove VIF (addr: %pM, type: %d, link_id: %d) from channel context: %d MHz\n",
++		   vif->addr, vif->type, link_conf->link_id,
++		   conf->def.chan->center_freq);
++	cancel_delayed_work_sync(&phy->scan_work);
++
++	mutex_lock(&phy->dev->mt76.mutex);
++
++	if (test_bit(MT76_SCANNING, &phy->mt76->state))
++		mt7996_scan_complete(phy, true);
++
++	mvif->chanctx = NULL;
++	ctx->nbss_assigned--;
++
++	mutex_unlock(&phy->dev->mt76.mutex);
++}
++
++static int
++mt7996_switch_vif_chanctx(struct ieee80211_hw *hw,
++			  struct ieee80211_vif_chanctx_switch *vifs,
++			  int n_vifs,
++			  enum ieee80211_chanctx_switch_mode mode)
++{
++	struct mt7996_chanctx *old_ctx = mt7996_chanctx_get(vifs->old_ctx);
++	struct mt7996_chanctx *new_ctx = mt7996_chanctx_get(vifs->new_ctx);
++	struct mt7996_phy *phy = old_ctx->phy;
++
++	wiphy_info(hw->wiphy, "%s: old=%d, new=%d\n", __func__, vifs->old_ctx->def.chan->hw_value, vifs->new_ctx->def.chan->hw_value);
++
++	if (new_ctx->nbss_assigned && phy->chanctx == new_ctx) {
++		new_ctx->nbss_assigned += n_vifs;
++		return 0;
++	}
++
++	if (WARN_ON(old_ctx != phy->chanctx))
++		return -EINVAL;
++
++	mutex_lock(&phy->dev->mt76.mutex);
++
++	phy->chanctx = new_ctx;
++	new_ctx->assigned = true;
++	new_ctx->chandef = vifs->new_ctx->def;
++	new_ctx->phy = phy;
++	new_ctx->nbss_assigned += n_vifs;
++
++	mutex_unlock(&phy->dev->mt76.mutex);
++
++	return mt7996_set_channel(phy, &new_ctx->chandef);
++}
++
+ const struct ieee80211_ops mt7996_ops = {
+ 	.add_chanctx = ieee80211_emulate_add_chanctx,
+ 	.remove_chanctx = ieee80211_emulate_remove_chanctx,
+@@ -1777,4 +1919,10 @@ const struct ieee80211_ops mt7996_ops = {
+ 	.net_fill_forward_path = mt7996_net_fill_forward_path,
+ 	.net_setup_tc = mt76_wed_net_setup_tc,
+ #endif
++	.add_chanctx = mt7996_add_chanctx,
++	.remove_chanctx = mt7996_remove_chanctx,
++	.change_chanctx = mt7996_change_chanctx,
++	.assign_vif_chanctx = mt7996_assign_vif_chanctx,
++	.unassign_vif_chanctx = mt7996_unassign_vif_chanctx,
++	.switch_vif_chanctx = mt7996_switch_vif_chanctx,
+ };
+diff --git a/mt7996/mcu.c b/mt7996/mcu.c
+index 746fc223..ba53c3fc 100644
+--- a/mt7996/mcu.c
++++ b/mt7996/mcu.c
+@@ -5322,7 +5322,7 @@ int mt7996_mcu_set_pp_en(struct mt7996_phy *phy, u8 mode, u16 bitmap)
+ 		.bitmap = cpu_to_le16(bitmap),
+ 	};
+ 
+-	if (phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ ||
++	if (phy->chanctx->chandef.chan->band == NL80211_BAND_2GHZ ||
+ 	    mode > PP_USR_MODE)
+ 		return 0;
+ 
+diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
+index 87b166aa..07790257 100644
+--- a/mt7996/mt7996.h
++++ b/mt7996/mt7996.h
+@@ -334,6 +334,8 @@ struct mt7996_vif {
+ 
+ 	struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
+ 	struct cfg80211_bitrate_mask bitrate_mask;
++
++	struct mt7996_chanctx *chanctx;
+ };
+ 
+ /* crash-dump */
+@@ -423,6 +425,14 @@ struct mt7996_rro_ba_session {
+ 	u32 last_in_rxtime :12;
+ };
+ 
++struct mt7996_chanctx {
++	struct cfg80211_chan_def chandef;
++	struct mt7996_phy *phy;
++
++	bool assigned;
++	u8 nbss_assigned;
++};
++
+ struct mt7996_phy {
+ 	struct mt76_phy *mt76;
+ 	struct mt7996_dev *dev;
+@@ -466,6 +476,7 @@ struct mt7996_phy {
+ 	struct cfg80211_scan_request *scan_req;
+ 	struct ieee80211_vif *scan_vif;
+ 	int scan_chan_idx;
++	struct mt7996_chanctx *chanctx;
+ 
+ 	struct mt7996_scs_ctrl scs_ctrl;
+ 	u32 red_drop;
+@@ -757,6 +768,12 @@ mt7996_has_background_radar(struct mt7996_dev *dev)
+ 	return true;
+ }
+ 
++static inline struct mt7996_chanctx *
++mt7996_chanctx_get(struct ieee80211_chanctx_conf *ctx)
++{
++	return (struct mt7996_chanctx *)&ctx->drv_priv;
++}
++
+ extern const struct ieee80211_ops mt7996_ops;
+ extern struct pci_driver mt7996_pci_driver;
+ extern struct pci_driver mt7996_hif_driver;
+-- 
+2.45.2
+