developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1 | From 6e6fb69bc4f57d622fae76d8d5a3102b8e98e10f Mon Sep 17 00:00:00 2001 |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 2 | From: Benjamin Lin <benjamin-jw.lin@mediatek.com> |
| 3 | Date: Thu, 25 Apr 2024 17:17:13 +0800 |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 4 | Subject: [PATCH] wifi: mt76: mt7915: fix inconsistent QoS mapping between SW |
| 5 | and HW |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 6 | |
| 7 | The mapping from IP DSCP to IEEE 802.11 user priority may be customized. |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 8 | 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. |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 9 | |
| 10 | Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com> |
| 11 | --- |
| 12 | mt76_connac_mcu.h | 1 + |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 13 | mt7915/main.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ |
| 14 | 2 files changed, 52 insertions(+) |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 15 | |
| 16 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 17 | index 46dcd1c..e0255a2 100644 |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 18 | --- a/mt76_connac_mcu.h |
| 19 | +++ b/mt76_connac_mcu.h |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 20 | @@ -1238,6 +1238,7 @@ enum { |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 21 | 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 { |
| 28 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 29 | index f40a900..f82d0b1 100644 |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 30 | --- a/mt7915/main.c |
| 31 | +++ b/mt7915/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 32 | @@ -1619,6 +1619,56 @@ mt7915_set_frag_threshold(struct ieee80211_hw *hw, u32 val) |
developer | 66bc8fb | 2024-05-06 17:14:15 +0800 | [diff] [blame] | 33 | return 0; |
| 34 | } |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 35 | |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 36 | +static int |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 37 | +mt7915_set_qos_map(struct ieee80211_vif *vif, struct cfg80211_qos_map *usr_qos_map) |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 38 | +{ |
| 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, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 48 | + .qos_map_enable = usr_qos_map ? true : false, |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 49 | + }; |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 50 | + |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 51 | + /* Prevent access to members of mt7915_vif before its initialization. */ |
| 52 | + if (!mvif->phy) |
| 53 | + return -EPERM; |
| 54 | + |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 55 | + if (usr_qos_map) { |
| 56 | + struct cfg80211_dscp_exception *exception = usr_qos_map->dscp_exception; |
| 57 | + struct cfg80211_dscp_range *range = usr_qos_map->up; |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 58 | + s8 i; |
| 59 | + |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 60 | + /* Default QoS map, defined in section 2.3 of RFC8325. |
| 61 | + * Three most significant bits of DSCP are used as UP. |
| 62 | + */ |
| 63 | + for (i = 0; i < IP_DSCP_NUM; ++i) |
| 64 | + req.qos_map[i] = i >> 3; |
| 65 | + |
| 66 | + /* User-defined QoS map */ |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 67 | + for (i = 0; i < IEEE80211_NUM_UPS; ++i) { |
| 68 | + u8 low = range[i].low, high = range[i].high; |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 69 | + |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 70 | + if (low < IP_DSCP_NUM && high < IP_DSCP_NUM && low <= high) |
| 71 | + memset(req.qos_map + low, i, high - low + 1); |
| 72 | + } |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 73 | + |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 74 | + for (i = 0; i < usr_qos_map->num_des; ++i) { |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 75 | + u8 dscp = exception[i].dscp, up = exception[i].up; |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 76 | + |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 77 | + if (dscp < IP_DSCP_NUM && up < IEEE80211_NUM_UPS) |
| 78 | + req.qos_map[dscp] = up; |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 79 | + } |
| 80 | + } |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 81 | + |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 82 | + return mt76_mcu_send_msg(&mvif->phy->dev->mt76, MCU_WA_EXT_CMD(SET_QOS_MAP), |
| 83 | + &req, sizeof(req), true); |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 84 | +} |
developer | 66bc8fb | 2024-05-06 17:14:15 +0800 | [diff] [blame] | 85 | + |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 86 | static int |
| 87 | mt7915_set_radar_background(struct ieee80211_hw *hw, |
| 88 | struct cfg80211_chan_def *chandef) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 89 | @@ -1751,6 +1801,7 @@ const struct ieee80211_ops mt7915_ops = { |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 90 | .add_twt_setup = mt7915_mac_add_twt_setup, |
| 91 | .twt_teardown_request = mt7915_twt_teardown_request, |
| 92 | .set_frag_threshold = mt7915_set_frag_threshold, |
| 93 | + .set_qos_map = mt7915_set_qos_map, |
| 94 | CFG80211_TESTMODE_CMD(mt76_testmode_cmd) |
| 95 | CFG80211_TESTMODE_DUMP(mt76_testmode_dump) |
| 96 | #ifdef CONFIG_MAC80211_DEBUGFS |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 97 | -- |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 98 | 2.45.2 |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 99 | |