developer | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame^] | 1 | From f606394c86514dd140cb4ab0d7065c3c1ff584f5 Mon Sep 17 00:00:00 2001 |
developer | 78848c6 | 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 | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 1006/1034] wifi: mt76: mt7915: add mt76 vendor muru onoff |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 5 | command |
developer | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 6 | |
| 7 | --- |
developer | 27b5525 | 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 | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 12 | 4 files changed, 63 insertions(+) |
| 13 | |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 14 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame^] | 15 | index d5420cb5..1f5f938e 100644 |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 16 | --- a/mt7915/mcu.c |
| 17 | +++ b/mt7915/mcu.c |
developer | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame^] | 18 | @@ -4149,6 +4149,13 @@ void mt7915_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif) |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 19 | if (val == 0) |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 20 | phy->muru_onoff = MUMIMO_DL_CERT | MUMIMO_DL; |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 21 | break; |
developer | e0a1e0e | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 22 | + case RATE_PARAM_AUTO_MU: |
developer | 42b6328 | 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 | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 27 | + phy->muru_onoff = val; |
developer | 42b6328 | 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 | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame^] | 33 | index 7b7c2d1d..b6e21369 100644 |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 34 | --- a/mt7915/mcu.h |
| 35 | +++ b/mt7915/mcu.h |
developer | ad9333b | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 36 | @@ -478,6 +478,7 @@ enum { |
developer | 42b6328 | 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 | e0a1e0e | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 40 | + RATE_PARAM_AUTO_MU = 32, |
developer | 42b6328 | 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 | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame^] | 45 | index 5a1cce13..df1cac3f 100644 |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 46 | --- a/mt7915/vendor.c |
| 47 | +++ b/mt7915/vendor.c |
| 48 | @@ -34,6 +34,11 @@ wireless_ctrl_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL] = { |
| 49 | [MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT] = {.type = NLA_U8 }, |
| 50 | }; |
| 51 | |
| 52 | +static const struct nla_policy |
developer | e0a1e0e | 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 | 42b6328 | 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 | ad9333b | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 60 | @@ -944,6 +949,33 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy, |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
developer | e0a1e0e | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 64 | +static int mt7915_vendor_mu_ctrl(struct wiphy *wiphy, |
developer | 42b6328 | 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 | e0a1e0e | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 70 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_MU_CTRL]; |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 71 | + int err; |
| 72 | + u8 val8; |
| 73 | + u32 val32 = 0; |
| 74 | + |
developer | e0a1e0e | 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 | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 77 | + if (err) |
| 78 | + return err; |
| 79 | + |
developer | e0a1e0e | 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 | 42b6328 | 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 | ad9333b | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 94 | @@ -990,6 +1022,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | 42b6328 | 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 | e0a1e0e | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 102 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_MU_CTRL, |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 103 | + }, |
| 104 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 105 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
developer | e0a1e0e | 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 | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 109 | } |
| 110 | }; |
| 111 | |
| 112 | diff --git a/mt7915/vendor.h b/mt7915/vendor.h |
developer | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame^] | 113 | index 1b08321c..2be5fc89 100644 |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 114 | --- a/mt7915/vendor.h |
| 115 | +++ b/mt7915/vendor.h |
| 116 | @@ -8,6 +8,7 @@ enum mtk_nl80211_vendor_subcmds { |
| 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 | e0a1e0e | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 120 | + MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | enum mtk_capi_control_changed { |
| 124 | @@ -33,6 +34,17 @@ enum mtk_vendor_attr_wireless_ctrl { |
| 125 | NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1 |
| 126 | }; |
| 127 | |
developer | e0a1e0e | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 128 | +enum mtk_vendor_attr_mu_ctrl { |
| 129 | + MTK_VENDOR_ATTR_MU_CTRL_UNSPEC, |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 130 | + |
developer | e0a1e0e | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 131 | + MTK_VENDOR_ATTR_MU_CTRL_ONOFF, |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 132 | + |
| 133 | + /* keep last */ |
developer | e0a1e0e | 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 | 42b6328 | 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 | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 142 | -- |
developer | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame^] | 143 | 2.39.2 |
developer | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 144 | |