blob: d110348be0292f34d20a23365f1f0a603f263cc8 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From d6ae847c0cea20f781970198a2aed4dc7e4daffa Mon Sep 17 00:00:00 2001
developerda18a742023-04-06 13:44:00 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Tue, 4 Apr 2023 02:27:44 +0800
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 1005/1052] wifi: mt76: mt7915: add mt76 vendor muru onoff
developer753619c2024-02-22 13:42:45 +08005 command
developer7c3a5082022-06-24 13:40:42 +08006
7---
developer28b11e22022-09-05 19:09:45 +08008 mt7915/mcu.c | 7 +++++++
9 mt7915/mcu.h | 1 +
10 mt7915/vendor.c | 43 +++++++++++++++++++++++++++++++++++++++++++
11 mt7915/vendor.h | 12 ++++++++++++
developer7c3a5082022-06-24 13:40:42 +080012 4 files changed, 63 insertions(+)
13
developer6caa5e22022-06-16 13:33:13 +080014diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer05f3b2b2024-08-19 19:17:34 +080015index c819a3be..cd5363c6 100644
developer6caa5e22022-06-16 13:33:13 +080016--- a/mt7915/mcu.c
17+++ b/mt7915/mcu.c
developera46f6132024-03-26 14:09:54 +080018@@ -4422,6 +4422,13 @@ void mt7915_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
developer6caa5e22022-06-16 13:33:13 +080019 if (val == 0)
developer4d581862023-02-13 16:01:56 +080020 phy->muru_onoff = MUMIMO_DL_CERT | MUMIMO_DL;
developer6caa5e22022-06-16 13:33:13 +080021 break;
developer2c78ce72023-02-24 11:26:12 +080022+ case RATE_PARAM_AUTO_MU:
developer6caa5e22022-06-16 13:33:13 +080023+ if (val < 0 || val > 15) {
24+ printk("Wrong value! The value is between 0-15.\n");
25+ break;
26+ }
developer4d581862023-02-13 16:01:56 +080027+ phy->muru_onoff = val;
developer6caa5e22022-06-16 13:33:13 +080028+ break;
29 }
30 }
31
32diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer05f3b2b2024-08-19 19:17:34 +080033index eef2fc00..86500536 100644
developer6caa5e22022-06-16 13:33:13 +080034--- a/mt7915/mcu.h
35+++ b/mt7915/mcu.h
developer753619c2024-02-22 13:42:45 +080036@@ -493,6 +493,7 @@ enum {
developer6caa5e22022-06-16 13:33:13 +080037 #ifdef CONFIG_MTK_VENDOR
38 RATE_PARAM_FIXED_MIMO = 30,
39 RATE_PARAM_FIXED_OFDMA = 31,
developer2c78ce72023-02-24 11:26:12 +080040+ RATE_PARAM_AUTO_MU = 32,
developer6caa5e22022-06-16 13:33:13 +080041 #endif
42 };
43
44diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developer05f3b2b2024-08-19 19:17:34 +080045index e4317af3..cf09b513 100644
developer6caa5e22022-06-16 13:33:13 +080046--- a/mt7915/vendor.c
47+++ b/mt7915/vendor.c
developer05f3b2b2024-08-19 19:17:34 +080048@@ -36,6 +36,11 @@ wireless_ctrl_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL] = {
developer6caa5e22022-06-16 13:33:13 +080049 [MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT] = {.type = NLA_U8 },
50 };
51
52+static const struct nla_policy
developer2c78ce72023-02-24 11:26:12 +080053+mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = {
54+ [MTK_VENDOR_ATTR_MU_CTRL_ONOFF] = {.type = NLA_U8 },
developer6caa5e22022-06-16 13:33:13 +080055+};
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 },
developer05f3b2b2024-08-19 19:17:34 +080060@@ -1099,6 +1104,33 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy,
developer6caa5e22022-06-16 13:33:13 +080061 return 0;
62 }
63
developer2c78ce72023-02-24 11:26:12 +080064+static int mt7915_vendor_mu_ctrl(struct wiphy *wiphy,
developer6caa5e22022-06-16 13:33:13 +080065+ struct wireless_dev *wdev,
66+ const void *data,
67+ int data_len)
68+{
69+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
developer2c78ce72023-02-24 11:26:12 +080070+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_MU_CTRL];
developer6caa5e22022-06-16 13:33:13 +080071+ int err;
72+ u8 val8;
73+ u32 val32 = 0;
74+
developer2c78ce72023-02-24 11:26:12 +080075+ err = nla_parse(tb, MTK_VENDOR_ATTR_MU_CTRL_MAX, data, data_len,
76+ mu_ctrl_policy, NULL);
developer6caa5e22022-06-16 13:33:13 +080077+ if (err)
78+ return err;
79+
developer2c78ce72023-02-24 11:26:12 +080080+ 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) |
developer6caa5e22022-06-16 13:33:13 +080083+ 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 = {
developer05f3b2b2024-08-19 19:17:34 +080094@@ -1145,6 +1177,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer6caa5e22022-06-16 13:33:13 +080095 .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,
developer2c78ce72023-02-24 11:26:12 +0800102+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_MU_CTRL,
developer6caa5e22022-06-16 13:33:13 +0800103+ },
104+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
105+ WIPHY_VENDOR_CMD_NEED_RUNNING,
developer2c78ce72023-02-24 11:26:12 +0800106+ .doit = mt7915_vendor_mu_ctrl,
107+ .policy = mu_ctrl_policy,
108+ .maxattr = MTK_VENDOR_ATTR_MU_CTRL_MAX,
developer6caa5e22022-06-16 13:33:13 +0800109 }
110 };
111
112diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer05f3b2b2024-08-19 19:17:34 +0800113index 1a0139d7..9cb67551 100644
developer6caa5e22022-06-16 13:33:13 +0800114--- a/mt7915/vendor.h
115+++ b/mt7915/vendor.h
developer753619c2024-02-22 13:42:45 +0800116@@ -9,6 +9,7 @@ enum mtk_nl80211_vendor_subcmds {
developer6caa5e22022-06-16 13:33:13 +0800117 MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2,
118 MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3,
119 MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4,
developer2c78ce72023-02-24 11:26:12 +0800120+ MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developer6caa5e22022-06-16 13:33:13 +0800121 };
122
123 enum mtk_capi_control_changed {
developer753619c2024-02-22 13:42:45 +0800124@@ -34,6 +35,17 @@ enum mtk_vendor_attr_wireless_ctrl {
developer6caa5e22022-06-16 13:33:13 +0800125 NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1
126 };
127
developer2c78ce72023-02-24 11:26:12 +0800128+enum mtk_vendor_attr_mu_ctrl {
129+ MTK_VENDOR_ATTR_MU_CTRL_UNSPEC,
developer6caa5e22022-06-16 13:33:13 +0800130+
developer2c78ce72023-02-24 11:26:12 +0800131+ MTK_VENDOR_ATTR_MU_CTRL_ONOFF,
developer6caa5e22022-06-16 13:33:13 +0800132+
133+ /* keep last */
developer2c78ce72023-02-24 11:26:12 +0800134+ NUM_MTK_VENDOR_ATTRS_MU_CTRL,
135+ MTK_VENDOR_ATTR_MU_CTRL_MAX =
136+ NUM_MTK_VENDOR_ATTRS_MU_CTRL - 1
developer6caa5e22022-06-16 13:33:13 +0800137+};
138+
139 enum mtk_vendor_attr_rfeature_ctrl {
140 MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC,
141
developer7c3a5082022-06-24 13:40:42 +0800142--
developerbd9fa1e2023-10-16 11:04:00 +08001432.18.0
developer7c3a5082022-06-24 13:40:42 +0800144