developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From d6ae847c0cea20f781970198a2aed4dc7e4daffa Mon Sep 17 00:00:00 2001 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Tue, 4 Apr 2023 02:27:44 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 1005/1052] wifi: mt76: mt7915: add mt76 vendor muru onoff |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 5 | command |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 6 | |
| 7 | --- |
developer | 28b11e2 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 8 | mt7915/mcu.c | 7 +++++++ |
| 9 | mt7915/mcu.h | 1 + |
| 10 | mt7915/vendor.c | 43 +++++++++++++++++++++++++++++++++++++++++++ |
| 11 | mt7915/vendor.h | 12 ++++++++++++ |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 12 | 4 files changed, 63 insertions(+) |
| 13 | |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 14 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 15 | index c819a3be..cd5363c6 100644 |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 16 | --- a/mt7915/mcu.c |
| 17 | +++ b/mt7915/mcu.c |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 18 | @@ -4422,6 +4422,13 @@ void mt7915_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif) |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 19 | if (val == 0) |
developer | 4d58186 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 20 | phy->muru_onoff = MUMIMO_DL_CERT | MUMIMO_DL; |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 21 | break; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 22 | + case RATE_PARAM_AUTO_MU: |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 23 | + if (val < 0 || val > 15) { |
| 24 | + printk("Wrong value! The value is between 0-15.\n"); |
| 25 | + break; |
| 26 | + } |
developer | 4d58186 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 27 | + phy->muru_onoff = val; |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 28 | + break; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 33 | index eef2fc00..86500536 100644 |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 34 | --- a/mt7915/mcu.h |
| 35 | +++ b/mt7915/mcu.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 36 | @@ -493,6 +493,7 @@ enum { |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 37 | #ifdef CONFIG_MTK_VENDOR |
| 38 | RATE_PARAM_FIXED_MIMO = 30, |
| 39 | RATE_PARAM_FIXED_OFDMA = 31, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 40 | + RATE_PARAM_AUTO_MU = 32, |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 41 | #endif |
| 42 | }; |
| 43 | |
| 44 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 45 | index e4317af3..cf09b513 100644 |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 46 | --- a/mt7915/vendor.c |
| 47 | +++ b/mt7915/vendor.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 48 | @@ -36,6 +36,11 @@ wireless_ctrl_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL] = { |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 49 | [MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT] = {.type = NLA_U8 }, |
| 50 | }; |
| 51 | |
| 52 | +static const struct nla_policy |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 53 | +mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = { |
| 54 | + [MTK_VENDOR_ATTR_MU_CTRL_ONOFF] = {.type = NLA_U8 }, |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 55 | +}; |
| 56 | + |
| 57 | static const struct nla_policy |
| 58 | rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = { |
| 59 | [MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI] = {.type = NLA_U8 }, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 60 | @@ -1099,6 +1104,33 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy, |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 64 | +static int mt7915_vendor_mu_ctrl(struct wiphy *wiphy, |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 65 | + struct wireless_dev *wdev, |
| 66 | + const void *data, |
| 67 | + int data_len) |
| 68 | +{ |
| 69 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 70 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_MU_CTRL]; |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 71 | + int err; |
| 72 | + u8 val8; |
| 73 | + u32 val32 = 0; |
| 74 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 75 | + err = nla_parse(tb, MTK_VENDOR_ATTR_MU_CTRL_MAX, data, data_len, |
| 76 | + mu_ctrl_policy, NULL); |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 77 | + if (err) |
| 78 | + return err; |
| 79 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 80 | + if (tb[MTK_VENDOR_ATTR_MU_CTRL_ONOFF]) { |
| 81 | + val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_MU_CTRL_ONOFF]); |
| 82 | + val32 |= FIELD_PREP(RATE_CFG_MODE, RATE_PARAM_AUTO_MU) | |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 83 | + FIELD_PREP(RATE_CFG_VAL, val8); |
| 84 | + ieee80211_iterate_active_interfaces_atomic(hw, IEEE80211_IFACE_ITER_RESUME_ALL, |
| 85 | + mt7915_set_wireless_vif, &val32); |
| 86 | + } |
| 87 | + |
| 88 | + return 0; |
| 89 | +} |
| 90 | + |
| 91 | static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 92 | { |
| 93 | .info = { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 94 | @@ -1145,6 +1177,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 95 | .doit = mt7915_vendor_wireless_ctrl, |
| 96 | .policy = wireless_ctrl_policy, |
| 97 | .maxattr = MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX, |
| 98 | + }, |
| 99 | + { |
| 100 | + .info = { |
| 101 | + .vendor_id = MTK_NL80211_VENDOR_ID, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 102 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_MU_CTRL, |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 103 | + }, |
| 104 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 105 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 106 | + .doit = mt7915_vendor_mu_ctrl, |
| 107 | + .policy = mu_ctrl_policy, |
| 108 | + .maxattr = MTK_VENDOR_ATTR_MU_CTRL_MAX, |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 109 | } |
| 110 | }; |
| 111 | |
| 112 | diff --git a/mt7915/vendor.h b/mt7915/vendor.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 113 | index 1a0139d7..9cb67551 100644 |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 114 | --- a/mt7915/vendor.h |
| 115 | +++ b/mt7915/vendor.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 116 | @@ -9,6 +9,7 @@ enum mtk_nl80211_vendor_subcmds { |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 117 | MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2, |
| 118 | MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3, |
| 119 | MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 120 | + MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | enum mtk_capi_control_changed { |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 124 | @@ -34,6 +35,17 @@ enum mtk_vendor_attr_wireless_ctrl { |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 125 | NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1 |
| 126 | }; |
| 127 | |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 128 | +enum mtk_vendor_attr_mu_ctrl { |
| 129 | + MTK_VENDOR_ATTR_MU_CTRL_UNSPEC, |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 130 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 131 | + MTK_VENDOR_ATTR_MU_CTRL_ONOFF, |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 132 | + |
| 133 | + /* keep last */ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 134 | + NUM_MTK_VENDOR_ATTRS_MU_CTRL, |
| 135 | + MTK_VENDOR_ATTR_MU_CTRL_MAX = |
| 136 | + NUM_MTK_VENDOR_ATTRS_MU_CTRL - 1 |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 137 | +}; |
| 138 | + |
| 139 | enum mtk_vendor_attr_rfeature_ctrl { |
| 140 | MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC, |
| 141 | |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 142 | -- |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 143 | 2.18.0 |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 144 | |