developer | 12a4279 | 2023-07-29 05:30:55 +0800 | [diff] [blame^] | 1 | From 84a267f527926ffd85f4cf8043ec34ff4ef791fb Mon Sep 17 00:00:00 2001 |
developer | c923344 | 2023-04-04 06:06:17 +0800 | [diff] [blame] | 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Tue, 4 Apr 2023 02:27:44 +0800 |
developer | 8f0d89b | 2023-07-28 07:16:44 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1006/1034] wifi: mt76: mt7915: add mt76 vendor muru onoff |
developer | c923344 | 2023-04-04 06:06:17 +0800 | [diff] [blame] | 5 | command |
developer | f64861f | 2022-06-22 11:44:53 +0800 | [diff] [blame] | 6 | |
| 7 | --- |
developer | 5ce5ea4 | 2022-08-31 14:12:29 +0800 | [diff] [blame] | 8 | mt7915/mcu.c | 7 +++++++ |
| 9 | mt7915/mcu.h | 1 + |
| 10 | mt7915/vendor.c | 43 +++++++++++++++++++++++++++++++++++++++++++ |
| 11 | mt7915/vendor.h | 12 ++++++++++++ |
developer | f64861f | 2022-06-22 11:44:53 +0800 | [diff] [blame] | 12 | 4 files changed, 63 insertions(+) |
| 13 | |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 14 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 8f0d89b | 2023-07-28 07:16:44 +0800 | [diff] [blame] | 15 | index d5420cb..1f5f938 100644 |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 16 | --- a/mt7915/mcu.c |
| 17 | +++ b/mt7915/mcu.c |
developer | 8f0d89b | 2023-07-28 07:16:44 +0800 | [diff] [blame] | 18 | @@ -4149,6 +4149,13 @@ void mt7915_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif) |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 19 | if (val == 0) |
developer | eb2bd8e | 2023-02-09 11:16:04 +0800 | [diff] [blame] | 20 | phy->muru_onoff = MUMIMO_DL_CERT | MUMIMO_DL; |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 21 | break; |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 22 | + case RATE_PARAM_AUTO_MU: |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 23 | + if (val < 0 || val > 15) { |
| 24 | + printk("Wrong value! The value is between 0-15.\n"); |
| 25 | + break; |
| 26 | + } |
developer | eb2bd8e | 2023-02-09 11:16:04 +0800 | [diff] [blame] | 27 | + phy->muru_onoff = val; |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 28 | + break; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 12a4279 | 2023-07-29 05:30:55 +0800 | [diff] [blame^] | 33 | index 7b7c2d1..b6e2136 100644 |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 34 | --- a/mt7915/mcu.h |
| 35 | +++ b/mt7915/mcu.h |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 36 | @@ -478,6 +478,7 @@ enum { |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 37 | #ifdef CONFIG_MTK_VENDOR |
| 38 | RATE_PARAM_FIXED_MIMO = 30, |
| 39 | RATE_PARAM_FIXED_OFDMA = 31, |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 40 | + RATE_PARAM_AUTO_MU = 32, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 41 | #endif |
| 42 | }; |
| 43 | |
| 44 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 45 | index 5a1cce1..df1cac3 100644 |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [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 | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 53 | +mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = { |
| 54 | + [MTK_VENDOR_ATTR_MU_CTRL_ONOFF] = {.type = NLA_U8 }, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 60 | @@ -944,6 +949,33 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 64 | +static int mt7915_vendor_mu_ctrl(struct wiphy *wiphy, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [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 | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 70 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_MU_CTRL]; |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 71 | + int err; |
| 72 | + u8 val8; |
| 73 | + u32 val32 = 0; |
| 74 | + |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 75 | + err = nla_parse(tb, MTK_VENDOR_ATTR_MU_CTRL_MAX, data, data_len, |
| 76 | + mu_ctrl_policy, NULL); |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 77 | + if (err) |
| 78 | + return err; |
| 79 | + |
developer | 57de9b7 | 2023-02-20 11:15:54 +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 | 7f1a58f | 2022-05-26 16:00:32 -0700 | [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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 94 | @@ -990,6 +1022,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [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 | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 102 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_MU_CTRL, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 103 | + }, |
| 104 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 105 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 106 | + .doit = mt7915_vendor_mu_ctrl, |
| 107 | + .policy = mu_ctrl_policy, |
| 108 | + .maxattr = MTK_VENDOR_ATTR_MU_CTRL_MAX, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 109 | } |
| 110 | }; |
| 111 | |
| 112 | diff --git a/mt7915/vendor.h b/mt7915/vendor.h |
developer | 1d9da7d | 2023-04-15 12:45:34 +0800 | [diff] [blame] | 113 | index 1b08321..2be5fc8 100644 |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [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 | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 120 | + MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [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 | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 128 | +enum mtk_vendor_attr_mu_ctrl { |
| 129 | + MTK_VENDOR_ATTR_MU_CTRL_UNSPEC, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 130 | + |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 131 | + MTK_VENDOR_ATTR_MU_CTRL_ONOFF, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 132 | + |
| 133 | + /* keep last */ |
developer | 57de9b7 | 2023-02-20 11:15:54 +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 | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 137 | +}; |
| 138 | + |
| 139 | enum mtk_vendor_attr_rfeature_ctrl { |
| 140 | MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC, |
| 141 | |
developer | f64861f | 2022-06-22 11:44:53 +0800 | [diff] [blame] | 142 | -- |
developer | 2324aa2 | 2023-04-12 11:30:15 +0800 | [diff] [blame] | 143 | 2.18.0 |
developer | f64861f | 2022-06-22 11:44:53 +0800 | [diff] [blame] | 144 | |