[][MAC80211][WiFi6][core][Fix inconsistent QoS mapping between AP and AP_VLAN VIFs]

[Description]
Fix inconsistent QoS mapping between AP and AP_VLAN IFs.
Specifically, when WDS AP IF is connected by a WDS STA, the QoS map of the AP_VLAN VIF is NULL.
So the QoS types of packets to the WDS STA will be determined using the default mapping rule.
However, SoftMAC driver uses the QoS map of the AP VIF, which may already be set.
Therefore, it is possible that the QoS mappings of SW and HW are inconsistent.
Thus, sync QoS map of AP VIF to that of AP_VLAN VIF.

[Release-log]
N/A

Change-Id: Ic1e51cd3ba832c7f63bd2320e3cd23cef8f3a996
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9014202
diff --git a/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0032-mac80211-mtk-fix-inconsistent-QoS-mapping-between-AP.patch b/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0032-mac80211-mtk-fix-inconsistent-QoS-mapping-between-AP.patch
new file mode 100644
index 0000000..c05b086
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0032-mac80211-mtk-fix-inconsistent-QoS-mapping-between-AP.patch
@@ -0,0 +1,56 @@
+From de4d3e25a555dedd70793d0362b1e501ed1a77f1 Mon Sep 17 00:00:00 2001
+From: Benjamin Lin <benjamin-jw.lin@mediatek.com>
+Date: Tue, 30 Apr 2024 10:28:29 +0800
+Subject: [PATCH] mac80211: mtk: fix inconsistent QoS mapping between AP and
+ AP_VLAN VIFs
+
+Fix inconsistent QoS mapping between AP and AP_VLAN IFs.
+Specifically, when WDS AP IF is connected by a WDS STA, the QoS map of the AP_VLAN VIF is NULL.
+So the QoS types of packets to the WDS STA will be determined using the default mapping rule.
+However, SoftMAC driver uses the QoS map of the AP VIF, which may already be set.
+Therefore, it is possible that the QoS mappings of SW and HW are inconsistent.
+Thus, sync QoS map of AP VIF to that of AP_VLAN VIF.
+
+Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com>
+---
+ net/mac80211/iface.c | 23 ++++++++++++++++++++++-
+ 1 file changed, 22 insertions(+), 1 deletion(-)
+
+diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
+index ef32d53..138ad79 100644
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -297,8 +297,29 @@ static int ieee80211_check_concurrent_iface(struct ieee80211_sub_if_data *sdata,
+ 			 * can only add VLANs to enabled APs
+ 			 */
+ 			if (iftype == NL80211_IFTYPE_AP_VLAN &&
+-			    nsdata->vif.type == NL80211_IFTYPE_AP)
++			    nsdata->vif.type == NL80211_IFTYPE_AP) {
++				struct mac80211_qos_map *old_qos_map, *new_qos_map = NULL;
++
+ 				sdata->bss = &nsdata->u.ap;
++
++				rcu_read_lock();
++				old_qos_map = rcu_dereference(nsdata->qos_map);
++				if (old_qos_map) {
++					new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
++					if (!new_qos_map) {
++						rcu_read_unlock();
++						return -ENOMEM;
++					}
++					memcpy(&new_qos_map->qos_map, &old_qos_map->qos_map,
++					       sizeof(new_qos_map->qos_map));
++				}
++				rcu_read_unlock();
++
++				old_qos_map = sdata_dereference(sdata->qos_map, sdata);
++				rcu_assign_pointer(sdata->qos_map, new_qos_map);
++				if (old_qos_map)
++					kfree_rcu(old_qos_map, rcu_head);
++			}
+ 		}
+ 	}
+ 
+-- 
+2.18.0
+