developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 1 | From 771112746f82ed8fc6f1ad6078c615f62da5745c Mon Sep 17 00:00:00 2001 |
developer | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 2 | From: MeiChia Chiu <meichia.chiu@mediatek.com> |
| 3 | Date: Wed, 22 Jun 2022 10:53:43 +0800 |
| 4 | Subject: [PATCH 1008/1008] mt76: mt7915: add mt76 vendor muru onoff command |
| 5 | |
| 6 | --- |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 7 | .../net/wireless/mediatek/mt76/mt7915/mcu.c | 7 +++ |
| 8 | .../net/wireless/mediatek/mt76/mt7915/mcu.h | 1 + |
| 9 | .../wireless/mediatek/mt76/mt7915/vendor.c | 43 +++++++++++++++++++ |
| 10 | .../wireless/mediatek/mt76/mt7915/vendor.h | 12 ++++++ |
developer | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 11 | 4 files changed, 63 insertions(+) |
| 12 | |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 13 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 14 | index 224f3ab2..0f71356b 100644 |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 15 | --- a/mt7915/mcu.c |
| 16 | +++ b/mt7915/mcu.c |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 17 | @@ -3675,6 +3675,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] | 18 | if (val == 0) |
| 19 | dev->dbg.muru_onoff = MUMIMO_DL_CERT | MUMIMO_DL; |
| 20 | break; |
| 21 | + case RATE_PARAM_AUTO_HEMU: |
| 22 | + if (val < 0 || val > 15) { |
| 23 | + printk("Wrong value! The value is between 0-15.\n"); |
| 24 | + break; |
| 25 | + } |
| 26 | + dev->dbg.muru_onoff = val; |
| 27 | + break; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 32 | index c4850644..0a77ad0d 100644 |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 33 | --- a/mt7915/mcu.h |
| 34 | +++ b/mt7915/mcu.h |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 35 | @@ -403,6 +403,7 @@ enum { |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 36 | #ifdef CONFIG_MTK_VENDOR |
| 37 | RATE_PARAM_FIXED_MIMO = 30, |
| 38 | RATE_PARAM_FIXED_OFDMA = 31, |
| 39 | + RATE_PARAM_AUTO_HEMU = 32, |
| 40 | #endif |
| 41 | }; |
| 42 | |
| 43 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 44 | index 7456c577..c7551848 100644 |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 45 | --- a/mt7915/vendor.c |
| 46 | +++ b/mt7915/vendor.c |
| 47 | @@ -34,6 +34,11 @@ wireless_ctrl_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL] = { |
| 48 | [MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT] = {.type = NLA_U8 }, |
| 49 | }; |
| 50 | |
| 51 | +static const struct nla_policy |
| 52 | +hemu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_HEMU_CTRL] = { |
| 53 | + [MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF] = {.type = NLA_U8 }, |
| 54 | +}; |
| 55 | + |
| 56 | static const struct nla_policy |
| 57 | rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = { |
| 58 | [MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI] = {.type = NLA_U8 }, |
developer | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 59 | @@ -942,6 +947,33 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy, |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | +static int mt7915_vendor_hemu_ctrl(struct wiphy *wiphy, |
| 64 | + struct wireless_dev *wdev, |
| 65 | + const void *data, |
| 66 | + int data_len) |
| 67 | +{ |
| 68 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 69 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_HEMU_CTRL]; |
| 70 | + int err; |
| 71 | + u8 val8; |
| 72 | + u32 val32 = 0; |
| 73 | + |
| 74 | + err = nla_parse(tb, MTK_VENDOR_ATTR_HEMU_CTRL_MAX, data, data_len, |
| 75 | + hemu_ctrl_policy, NULL); |
| 76 | + if (err) |
| 77 | + return err; |
| 78 | + |
| 79 | + if (tb[MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF]) { |
| 80 | + val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF]); |
| 81 | + val32 |= FIELD_PREP(RATE_CFG_MODE, RATE_PARAM_AUTO_HEMU) | |
| 82 | + FIELD_PREP(RATE_CFG_VAL, val8); |
| 83 | + ieee80211_iterate_active_interfaces_atomic(hw, IEEE80211_IFACE_ITER_RESUME_ALL, |
| 84 | + mt7915_set_wireless_vif, &val32); |
| 85 | + } |
| 86 | + |
| 87 | + return 0; |
| 88 | +} |
| 89 | + |
| 90 | static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 91 | { |
| 92 | .info = { |
developer | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 93 | @@ -988,6 +1020,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 94 | .doit = mt7915_vendor_wireless_ctrl, |
| 95 | .policy = wireless_ctrl_policy, |
| 96 | .maxattr = MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX, |
| 97 | + }, |
| 98 | + { |
| 99 | + .info = { |
| 100 | + .vendor_id = MTK_NL80211_VENDOR_ID, |
| 101 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL, |
| 102 | + }, |
| 103 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 104 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 105 | + .doit = mt7915_vendor_hemu_ctrl, |
| 106 | + .policy = hemu_ctrl_policy, |
| 107 | + .maxattr = MTK_VENDOR_ATTR_HEMU_CTRL_MAX, |
| 108 | } |
| 109 | }; |
| 110 | |
| 111 | diff --git a/mt7915/vendor.h b/mt7915/vendor.h |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 112 | index 1b08321c..a8e4ebf9 100644 |
developer | 42b6328 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 113 | --- a/mt7915/vendor.h |
| 114 | +++ b/mt7915/vendor.h |
| 115 | @@ -8,6 +8,7 @@ enum mtk_nl80211_vendor_subcmds { |
| 116 | MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2, |
| 117 | MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3, |
| 118 | MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4, |
| 119 | + MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5, |
| 120 | }; |
| 121 | |
| 122 | enum mtk_capi_control_changed { |
| 123 | @@ -33,6 +34,17 @@ enum mtk_vendor_attr_wireless_ctrl { |
| 124 | NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1 |
| 125 | }; |
| 126 | |
| 127 | +enum mtk_vendor_attr_hemu_ctrl { |
| 128 | + MTK_VENDOR_ATTR_HEMU_CTRL_UNSPEC, |
| 129 | + |
| 130 | + MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF, |
| 131 | + |
| 132 | + /* keep last */ |
| 133 | + NUM_MTK_VENDOR_ATTRS_HEMU_CTRL, |
| 134 | + MTK_VENDOR_ATTR_HEMU_CTRL_MAX = |
| 135 | + NUM_MTK_VENDOR_ATTRS_HEMU_CTRL - 1 |
| 136 | +}; |
| 137 | + |
| 138 | enum mtk_vendor_attr_rfeature_ctrl { |
| 139 | MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC, |
| 140 | |
developer | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 141 | -- |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 142 | 2.25.1 |
developer | aace7f5 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 143 | |