blob: 9c926db274c85d3829cf652e4fdf4691b53bb733 [file] [log] [blame]
developer36fe7092023-09-27 12:24:47 +08001From f606394c86514dd140cb4ab0d7065c3c1ff584f5 Mon Sep 17 00:00:00 2001
developer78848c62023-04-06 13:44:00 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Tue, 4 Apr 2023 02:27:44 +0800
developer36fe7092023-09-27 12:24:47 +08004Subject: [PATCH 1006/1034] wifi: mt76: mt7915: add mt76 vendor muru onoff
developer78848c62023-04-06 13:44:00 +08005 command
developeraace7f52022-06-24 13:40:42 +08006
7---
developer27b55252022-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 ++++++++++++
developeraace7f52022-06-24 13:40:42 +080012 4 files changed, 63 insertions(+)
13
developer42b63282022-06-16 13:33:13 +080014diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer36fe7092023-09-27 12:24:47 +080015index d5420cb5..1f5f938e 100644
developer42b63282022-06-16 13:33:13 +080016--- a/mt7915/mcu.c
17+++ b/mt7915/mcu.c
developer36fe7092023-09-27 12:24:47 +080018@@ -4149,6 +4149,13 @@ void mt7915_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
developer42b63282022-06-16 13:33:13 +080019 if (val == 0)
developer5eddc512023-02-13 16:01:56 +080020 phy->muru_onoff = MUMIMO_DL_CERT | MUMIMO_DL;
developer42b63282022-06-16 13:33:13 +080021 break;
developere0a1e0e2023-02-24 11:26:12 +080022+ case RATE_PARAM_AUTO_MU:
developer42b63282022-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+ }
developer5eddc512023-02-13 16:01:56 +080027+ phy->muru_onoff = val;
developer42b63282022-06-16 13:33:13 +080028+ break;
29 }
30 }
31
32diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer36fe7092023-09-27 12:24:47 +080033index 7b7c2d1d..b6e21369 100644
developer42b63282022-06-16 13:33:13 +080034--- a/mt7915/mcu.h
35+++ b/mt7915/mcu.h
developerad9333b2023-05-22 15:16:16 +080036@@ -478,6 +478,7 @@ enum {
developer42b63282022-06-16 13:33:13 +080037 #ifdef CONFIG_MTK_VENDOR
38 RATE_PARAM_FIXED_MIMO = 30,
39 RATE_PARAM_FIXED_OFDMA = 31,
developere0a1e0e2023-02-24 11:26:12 +080040+ RATE_PARAM_AUTO_MU = 32,
developer42b63282022-06-16 13:33:13 +080041 #endif
42 };
43
44diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developer36fe7092023-09-27 12:24:47 +080045index 5a1cce13..df1cac3f 100644
developer42b63282022-06-16 13:33:13 +080046--- 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
developere0a1e0e2023-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 },
developer42b63282022-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 },
developerad9333b2023-05-22 15:16:16 +080060@@ -944,6 +949,33 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy,
developer42b63282022-06-16 13:33:13 +080061 return 0;
62 }
63
developere0a1e0e2023-02-24 11:26:12 +080064+static int mt7915_vendor_mu_ctrl(struct wiphy *wiphy,
developer42b63282022-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);
developere0a1e0e2023-02-24 11:26:12 +080070+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_MU_CTRL];
developer42b63282022-06-16 13:33:13 +080071+ int err;
72+ u8 val8;
73+ u32 val32 = 0;
74+
developere0a1e0e2023-02-24 11:26:12 +080075+ err = nla_parse(tb, MTK_VENDOR_ATTR_MU_CTRL_MAX, data, data_len,
76+ mu_ctrl_policy, NULL);
developer42b63282022-06-16 13:33:13 +080077+ if (err)
78+ return err;
79+
developere0a1e0e2023-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) |
developer42b63282022-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 = {
developerad9333b2023-05-22 15:16:16 +080094@@ -990,6 +1022,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer42b63282022-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,
developere0a1e0e2023-02-24 11:26:12 +0800102+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_MU_CTRL,
developer42b63282022-06-16 13:33:13 +0800103+ },
104+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
105+ WIPHY_VENDOR_CMD_NEED_RUNNING,
developere0a1e0e2023-02-24 11:26:12 +0800106+ .doit = mt7915_vendor_mu_ctrl,
107+ .policy = mu_ctrl_policy,
108+ .maxattr = MTK_VENDOR_ATTR_MU_CTRL_MAX,
developer42b63282022-06-16 13:33:13 +0800109 }
110 };
111
112diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer36fe7092023-09-27 12:24:47 +0800113index 1b08321c..2be5fc89 100644
developer42b63282022-06-16 13:33:13 +0800114--- 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,
developere0a1e0e2023-02-24 11:26:12 +0800120+ MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developer42b63282022-06-16 13:33:13 +0800121 };
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
developere0a1e0e2023-02-24 11:26:12 +0800128+enum mtk_vendor_attr_mu_ctrl {
129+ MTK_VENDOR_ATTR_MU_CTRL_UNSPEC,
developer42b63282022-06-16 13:33:13 +0800130+
developere0a1e0e2023-02-24 11:26:12 +0800131+ MTK_VENDOR_ATTR_MU_CTRL_ONOFF,
developer42b63282022-06-16 13:33:13 +0800132+
133+ /* keep last */
developere0a1e0e2023-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
developer42b63282022-06-16 13:33:13 +0800137+};
138+
139 enum mtk_vendor_attr_rfeature_ctrl {
140 MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC,
141
developeraace7f52022-06-24 13:40:42 +0800142--
developer36fe7092023-09-27 12:24:47 +08001432.39.2
developeraace7f52022-06-24 13:40:42 +0800144