blob: c871c6091323f358341383c110b9a9cfcfa9d3a1 [file] [log] [blame]
developer42c7a432024-07-12 14:39:29 +08001From 5fd6278fa4d62c140f40fe2d7ae0bd86074b2d36 Mon Sep 17 00:00:00 2001
developerdad89a32024-04-29 14:17:17 +08002From: Benjamin Lin <benjamin-jw.lin@mediatek.com>
3Date: Thu, 25 Apr 2024 17:17:13 +0800
developer42c7a432024-07-12 14:39:29 +08004Subject: [PATCH] wifi: mt76: mt7915: fix inconsistent QoS mapping between SW
5 and HW
developerdad89a32024-04-29 14:17:17 +08006
7The mapping from IP DSCP to IEEE 802.11 user priority may be customized.
developer42c7a432024-07-12 14:39:29 +08008Therefore, 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.
developerdad89a32024-04-29 14:17:17 +08009
10Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com>
11---
12 mt76_connac_mcu.h | 1 +
developer42c7a432024-07-12 14:39:29 +080013 mt7915/main.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 45 insertions(+)
developerdad89a32024-04-29 14:17:17 +080015
16diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developer42c7a432024-07-12 14:39:29 +080017index 8899eea..5c25f1a 100644
developerdad89a32024-04-29 14:17:17 +080018--- a/mt76_connac_mcu.h
19+++ b/mt76_connac_mcu.h
developer42c7a432024-07-12 14:39:29 +080020@@ -1238,6 +1238,7 @@ enum {
developerdad89a32024-04-29 14:17:17 +080021 MCU_EXT_CMD_GROUP_PRE_CAL_INFO = 0xab,
22 MCU_EXT_CMD_DPD_PRE_CAL_INFO = 0xac,
23 MCU_EXT_CMD_PHY_STAT_INFO = 0xad,
24+ MCU_EXT_CMD_SET_QOS_MAP = 0xb4,
25 };
26
27 enum {
28diff --git a/mt7915/main.c b/mt7915/main.c
developer42c7a432024-07-12 14:39:29 +080029index 5ed84bc..be11e4f 100644
developerdad89a32024-04-29 14:17:17 +080030--- a/mt7915/main.c
31+++ b/mt7915/main.c
developer42c7a432024-07-12 14:39:29 +080032@@ -1619,6 +1619,49 @@ mt7915_set_frag_threshold(struct ieee80211_hw *hw, u32 val)
developer66bc8fb2024-05-06 17:14:15 +080033 return 0;
34 }
developerdad89a32024-04-29 14:17:17 +080035
developer42c7a432024-07-12 14:39:29 +080036+static int
37+mt7915_set_qos_map(struct ieee80211_vif *vif, struct cfg80211_qos_map *qos_map)
developerdad89a32024-04-29 14:17:17 +080038+{
39+#define IP_DSCP_NUM 64
40+ struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
41+ struct {
42+ u8 bss_idx;
43+ u8 qos_map_enable;
44+ u8 __rsv[2];
45+ s8 qos_map[IP_DSCP_NUM];
46+ } __packed req = {
47+ .bss_idx = mvif->mt76.idx,
developer42c7a432024-07-12 14:39:29 +080048+ .qos_map_enable = qos_map ? true : false,
developerdad89a32024-04-29 14:17:17 +080049+ };
developerdad89a32024-04-29 14:17:17 +080050+
developer42c7a432024-07-12 14:39:29 +080051+ /* Prevent access to members of mt7915_vif before its initialization. */
52+ if (!mvif->phy)
53+ return -EPERM;
54+
developerdad89a32024-04-29 14:17:17 +080055+ if (qos_map) {
developer42c7a432024-07-12 14:39:29 +080056+ struct cfg80211_dscp_exception *exception = qos_map->dscp_exception;
57+ struct cfg80211_dscp_range *range = qos_map->up;
58+ s8 i;
59+
60+ for (i = 0; i < IEEE80211_NUM_UPS; ++i) {
61+ u8 low = range[i].low, high = range[i].high;
developerdad89a32024-04-29 14:17:17 +080062+
developer42c7a432024-07-12 14:39:29 +080063+ if (low < IP_DSCP_NUM && high < IP_DSCP_NUM && low <= high)
64+ memset(req.qos_map + low, i, high - low + 1);
65+ }
developerdad89a32024-04-29 14:17:17 +080066+
developer42c7a432024-07-12 14:39:29 +080067+ for (i = 0; i < qos_map->num_des; ++i) {
68+ u8 dscp = exception[i].dscp, up = exception[i].up;
developerdad89a32024-04-29 14:17:17 +080069+
developer42c7a432024-07-12 14:39:29 +080070+ if (dscp < IP_DSCP_NUM && up < IEEE80211_NUM_UPS)
71+ req.qos_map[dscp] = up;
developerdad89a32024-04-29 14:17:17 +080072+ }
73+ }
developerdad89a32024-04-29 14:17:17 +080074+
developer42c7a432024-07-12 14:39:29 +080075+ return mt76_mcu_send_msg(&mvif->phy->dev->mt76, MCU_WA_EXT_CMD(SET_QOS_MAP),
76+ &req, sizeof(req), true);
developerdad89a32024-04-29 14:17:17 +080077+}
developer66bc8fb2024-05-06 17:14:15 +080078+
developer42c7a432024-07-12 14:39:29 +080079 static int
80 mt7915_set_radar_background(struct ieee80211_hw *hw,
81 struct cfg80211_chan_def *chandef)
82@@ -1747,6 +1790,7 @@ const struct ieee80211_ops mt7915_ops = {
83 .add_twt_setup = mt7915_mac_add_twt_setup,
84 .twt_teardown_request = mt7915_twt_teardown_request,
85 .set_frag_threshold = mt7915_set_frag_threshold,
86+ .set_qos_map = mt7915_set_qos_map,
87 CFG80211_TESTMODE_CMD(mt76_testmode_cmd)
88 CFG80211_TESTMODE_DUMP(mt76_testmode_dump)
89 #ifdef CONFIG_MAC80211_DEBUGFS
developerdad89a32024-04-29 14:17:17 +080090--
912.18.0
92