[][MAC80211][WiFi6][mt76][Fix incomplete QoS-map setting to FW]

[Description]
Fix incomplete QoS-map setting to FW.
Specifically, default QoS map, which uses three most significant bits of DSCP as UP, was not incorporated.

[Release-log]
N/A

Change-Id: Ic6ef68031c141ca4608db02d1bdd54c6b845e6fb
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9411427
diff --git a/autobuild/autobuild_5.4_mac80211_release/package/kernel/mt76/patches/0018-wifi-mt76-mt7915-fix-inconsistent-QoS-mapping-betwee.patch b/autobuild/autobuild_5.4_mac80211_release/package/kernel/mt76/patches/0018-wifi-mt76-mt7915-fix-inconsistent-QoS-mapping-betwee.patch
index 5d43e47..6eed8bd 100644
--- a/autobuild/autobuild_5.4_mac80211_release/package/kernel/mt76/patches/0018-wifi-mt76-mt7915-fix-inconsistent-QoS-mapping-betwee.patch
+++ b/autobuild/autobuild_5.4_mac80211_release/package/kernel/mt76/patches/0018-wifi-mt76-mt7915-fix-inconsistent-QoS-mapping-betwee.patch
@@ -1,8 +1,8 @@
-From e136a8aafc7ee1a3b39c698491b9c2b6f4dfb87b Mon Sep 17 00:00:00 2001
+From 6e6fb69bc4f57d622fae76d8d5a3102b8e98e10f Mon Sep 17 00:00:00 2001
 From: Benjamin Lin <benjamin-jw.lin@mediatek.com>
 Date: Thu, 25 Apr 2024 17:17:13 +0800
-Subject: [PATCH 18/21] wifi: mt76: mt7915: fix inconsistent QoS mapping
- between SW and HW
+Subject: [PATCH] wifi: mt76: mt7915: fix inconsistent QoS mapping between SW
+ and HW
 
 The mapping from IP DSCP to IEEE 802.11 user priority may be customized.
 Therefore, the mapping needs to be passed to HW, so that the QoS type of traffic can be mapped in a consistent manner for both SW and HW paths.
@@ -10,11 +10,11 @@
 Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com>
 ---
  mt76_connac_mcu.h |  1 +
- mt7915/main.c     | 44 ++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 45 insertions(+)
+ mt7915/main.c     | 51 +++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 52 insertions(+)
 
 diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
-index 46dcd1c6..e0255a23 100644
+index 46dcd1c..e0255a2 100644
 --- a/mt76_connac_mcu.h
 +++ b/mt76_connac_mcu.h
 @@ -1238,6 +1238,7 @@ enum {
@@ -26,15 +26,15 @@
  
  enum {
 diff --git a/mt7915/main.c b/mt7915/main.c
-index f40a9007..3a8b9404 100644
+index f40a900..f82d0b1 100644
 --- a/mt7915/main.c
 +++ b/mt7915/main.c
-@@ -1619,6 +1619,49 @@ mt7915_set_frag_threshold(struct ieee80211_hw *hw, u32 val)
+@@ -1619,6 +1619,56 @@ mt7915_set_frag_threshold(struct ieee80211_hw *hw, u32 val)
  	return 0;
  }
  
 +static int
-+mt7915_set_qos_map(struct ieee80211_vif *vif, struct cfg80211_qos_map *qos_map)
++mt7915_set_qos_map(struct ieee80211_vif *vif, struct cfg80211_qos_map *usr_qos_map)
 +{
 +#define IP_DSCP_NUM	64
 +	struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
@@ -45,18 +45,25 @@
 +		s8 qos_map[IP_DSCP_NUM];
 +	} __packed req = {
 +		.bss_idx = mvif->mt76.idx,
-+		.qos_map_enable = qos_map ? true : false,
++		.qos_map_enable = usr_qos_map ? true : false,
 +	};
 +
 +	/* Prevent access to members of mt7915_vif before its initialization. */
 +	if (!mvif->phy)
 +		return -EPERM;
 +
-+	if (qos_map) {
-+		struct cfg80211_dscp_exception *exception = qos_map->dscp_exception;
-+		struct cfg80211_dscp_range *range = qos_map->up;
++	if (usr_qos_map) {
++		struct cfg80211_dscp_exception *exception = usr_qos_map->dscp_exception;
++		struct cfg80211_dscp_range *range = usr_qos_map->up;
 +		s8 i;
 +
++		/* Default QoS map, defined in section 2.3 of RFC8325.
++		 * Three most significant bits of DSCP are used as UP.
++		 */
++		for (i = 0; i < IP_DSCP_NUM; ++i)
++			req.qos_map[i] = i >> 3;
++
++		/* User-defined QoS map */
 +		for (i = 0; i < IEEE80211_NUM_UPS; ++i) {
 +			u8 low = range[i].low, high = range[i].high;
 +
@@ -64,7 +71,7 @@
 +				memset(req.qos_map + low, i, high - low + 1);
 +		}
 +
-+		for (i = 0; i < qos_map->num_des; ++i) {
++		for (i = 0; i < usr_qos_map->num_des; ++i) {
 +			u8 dscp = exception[i].dscp, up = exception[i].up;
 +
 +			if (dscp < IP_DSCP_NUM && up < IEEE80211_NUM_UPS)
@@ -79,7 +86,7 @@
  static int
  mt7915_set_radar_background(struct ieee80211_hw *hw,
  			    struct cfg80211_chan_def *chandef)
-@@ -1751,6 +1794,7 @@ const struct ieee80211_ops mt7915_ops = {
+@@ -1751,6 +1801,7 @@ const struct ieee80211_ops mt7915_ops = {
  	.add_twt_setup = mt7915_mac_add_twt_setup,
  	.twt_teardown_request = mt7915_twt_teardown_request,
  	.set_frag_threshold = mt7915_set_frag_threshold,
@@ -88,5 +95,5 @@
  	CFG80211_TESTMODE_DUMP(mt76_testmode_dump)
  #ifdef CONFIG_MAC80211_DEBUGFS
 -- 
-2.18.0
+2.45.2