blob: bdcb87676c4fe6ae5bfe75ba1b8718e43b0848ad [file] [log] [blame]
developer28b11e22022-09-05 19:09:45 +08001From 96aa5b1fd4b17bc3aadeff2d04fb9818aa549639 Mon Sep 17 00:00:00 2001
developer7c3a5082022-06-24 13:40:42 +08002From: MeiChia Chiu <meichia.chiu@mediatek.com>
3Date: Wed, 22 Jun 2022 10:53:43 +0800
developer28b11e22022-09-05 19:09:45 +08004Subject: [PATCH 1008/1009] mt76: mt7915: add mt76 vendor muru onoff command
developer7c3a5082022-06-24 13:40:42 +08005
6---
developer28b11e22022-09-05 19:09:45 +08007 mt7915/mcu.c | 7 +++++++
8 mt7915/mcu.h | 1 +
9 mt7915/vendor.c | 43 +++++++++++++++++++++++++++++++++++++++++++
10 mt7915/vendor.h | 12 ++++++++++++
developer7c3a5082022-06-24 13:40:42 +080011 4 files changed, 63 insertions(+)
12
developer6caa5e22022-06-16 13:33:13 +080013diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer28b11e22022-09-05 19:09:45 +080014index 09a130d..9a7c9d3 100644
developer6caa5e22022-06-16 13:33:13 +080015--- a/mt7915/mcu.c
16+++ b/mt7915/mcu.c
developer28b11e22022-09-05 19:09:45 +080017@@ -3668,6 +3668,13 @@ void mt7915_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
developer6caa5e22022-06-16 13:33:13 +080018 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
31diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer28b11e22022-09-05 19:09:45 +080032index c485064..0a77ad0 100644
developer6caa5e22022-06-16 13:33:13 +080033--- a/mt7915/mcu.h
34+++ b/mt7915/mcu.h
developer072c5612022-07-15 18:30:03 +080035@@ -403,6 +403,7 @@ enum {
developer6caa5e22022-06-16 13:33:13 +080036 #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
43diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developer28b11e22022-09-05 19:09:45 +080044index 7456c57..c755184 100644
developer6caa5e22022-06-16 13:33:13 +080045--- 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 },
developer7c3a5082022-06-24 13:40:42 +080059@@ -942,6 +947,33 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy,
developer6caa5e22022-06-16 13:33:13 +080060 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);
developer6caa5e22022-06-16 13:33:13 +080069+ 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 = {
developer7c3a5082022-06-24 13:40:42 +080093@@ -988,6 +1020,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer6caa5e22022-06-16 13:33:13 +080094 .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
111diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer28b11e22022-09-05 19:09:45 +0800112index 1b08321..a8e4ebf 100644
developer6caa5e22022-06-16 13:33:13 +0800113--- 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
developer7c3a5082022-06-24 13:40:42 +0800141--
developer28b11e22022-09-05 19:09:45 +08001422.18.0
developer7c3a5082022-06-24 13:40:42 +0800143