blob: 050a40b6b24403f6d3446100fdcc4f45760d66bd [file] [log] [blame]
developer5eddc512023-02-13 16:01:56 +08001From 7197b9ba537a486c3ba398d2e0a806f093b682a3 Mon Sep 17 00:00:00 2001
developeraace7f52022-06-24 13:40:42 +08002From: MeiChia Chiu <meichia.chiu@mediatek.com>
3Date: Wed, 22 Jun 2022 10:53:43 +0800
developer2aa1e642022-12-19 11:33:22 +08004Subject: [PATCH 1007/1009] mt76: mt7915: add mt76 vendor muru onoff command
developeraace7f52022-06-24 13:40:42 +08005
6---
developer27b55252022-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 ++++++++++++
developeraace7f52022-06-24 13:40:42 +080011 4 files changed, 63 insertions(+)
12
developer42b63282022-06-16 13:33:13 +080013diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer5eddc512023-02-13 16:01:56 +080014index 3a0e87a..62d83bf 100644
developer42b63282022-06-16 13:33:13 +080015--- a/mt7915/mcu.c
16+++ b/mt7915/mcu.c
developer5eddc512023-02-13 16:01:56 +080017@@ -3958,6 +3958,13 @@ void mt7915_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
developer42b63282022-06-16 13:33:13 +080018 if (val == 0)
developer5eddc512023-02-13 16:01:56 +080019 phy->muru_onoff = MUMIMO_DL_CERT | MUMIMO_DL;
developer42b63282022-06-16 13:33:13 +080020 break;
developere0a1e0e2023-02-24 11:26:12 +080021+ case RATE_PARAM_AUTO_MU:
developer42b63282022-06-16 13:33:13 +080022+ if (val < 0 || val > 15) {
23+ printk("Wrong value! The value is between 0-15.\n");
24+ break;
25+ }
developer5eddc512023-02-13 16:01:56 +080026+ phy->muru_onoff = val;
developer42b63282022-06-16 13:33:13 +080027+ break;
28 }
29 }
30
31diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer5eddc512023-02-13 16:01:56 +080032index 714bc44..aaea323 100644
developer42b63282022-06-16 13:33:13 +080033--- a/mt7915/mcu.h
34+++ b/mt7915/mcu.h
developerf3f5d9b2023-02-07 15:24:34 +080035@@ -423,6 +423,7 @@ enum {
developer42b63282022-06-16 13:33:13 +080036 #ifdef CONFIG_MTK_VENDOR
37 RATE_PARAM_FIXED_MIMO = 30,
38 RATE_PARAM_FIXED_OFDMA = 31,
developere0a1e0e2023-02-24 11:26:12 +080039+ RATE_PARAM_AUTO_MU = 32,
developer42b63282022-06-16 13:33:13 +080040 #endif
41 };
42
43diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developer5eddc512023-02-13 16:01:56 +080044index beb0583..5acbd2d 100644
developer42b63282022-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
developere0a1e0e2023-02-24 11:26:12 +080052+mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = {
53+ [MTK_VENDOR_ATTR_MU_CTRL_ONOFF] = {.type = NLA_U8 },
developer42b63282022-06-16 13:33:13 +080054+};
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 },
developeraace7f52022-06-24 13:40:42 +080059@@ -942,6 +947,33 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy,
developer42b63282022-06-16 13:33:13 +080060 return 0;
61 }
62
developere0a1e0e2023-02-24 11:26:12 +080063+static int mt7915_vendor_mu_ctrl(struct wiphy *wiphy,
developer42b63282022-06-16 13:33:13 +080064+ struct wireless_dev *wdev,
65+ const void *data,
66+ int data_len)
67+{
68+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
developere0a1e0e2023-02-24 11:26:12 +080069+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_MU_CTRL];
developer42b63282022-06-16 13:33:13 +080070+ int err;
71+ u8 val8;
72+ u32 val32 = 0;
73+
developere0a1e0e2023-02-24 11:26:12 +080074+ err = nla_parse(tb, MTK_VENDOR_ATTR_MU_CTRL_MAX, data, data_len,
75+ mu_ctrl_policy, NULL);
developer42b63282022-06-16 13:33:13 +080076+ if (err)
77+ return err;
78+
developere0a1e0e2023-02-24 11:26:12 +080079+ if (tb[MTK_VENDOR_ATTR_MU_CTRL_ONOFF]) {
80+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_MU_CTRL_ONOFF]);
81+ val32 |= FIELD_PREP(RATE_CFG_MODE, RATE_PARAM_AUTO_MU) |
developer42b63282022-06-16 13:33:13 +080082+ 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 = {
developeraace7f52022-06-24 13:40:42 +080093@@ -988,6 +1020,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer42b63282022-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,
developere0a1e0e2023-02-24 11:26:12 +0800101+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_MU_CTRL,
developer42b63282022-06-16 13:33:13 +0800102+ },
103+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
104+ WIPHY_VENDOR_CMD_NEED_RUNNING,
developere0a1e0e2023-02-24 11:26:12 +0800105+ .doit = mt7915_vendor_mu_ctrl,
106+ .policy = mu_ctrl_policy,
107+ .maxattr = MTK_VENDOR_ATTR_MU_CTRL_MAX,
developer42b63282022-06-16 13:33:13 +0800108 }
109 };
110
111diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer5eddc512023-02-13 16:01:56 +0800112index 1b08321..a8e4ebf 100644
developer42b63282022-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,
developere0a1e0e2023-02-24 11:26:12 +0800119+ MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developer42b63282022-06-16 13:33:13 +0800120 };
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
developere0a1e0e2023-02-24 11:26:12 +0800127+enum mtk_vendor_attr_mu_ctrl {
128+ MTK_VENDOR_ATTR_MU_CTRL_UNSPEC,
developer42b63282022-06-16 13:33:13 +0800129+
developere0a1e0e2023-02-24 11:26:12 +0800130+ MTK_VENDOR_ATTR_MU_CTRL_ONOFF,
developer42b63282022-06-16 13:33:13 +0800131+
132+ /* keep last */
developere0a1e0e2023-02-24 11:26:12 +0800133+ NUM_MTK_VENDOR_ATTRS_MU_CTRL,
134+ MTK_VENDOR_ATTR_MU_CTRL_MAX =
135+ NUM_MTK_VENDOR_ATTRS_MU_CTRL - 1
developer42b63282022-06-16 13:33:13 +0800136+};
137+
138 enum mtk_vendor_attr_rfeature_ctrl {
139 MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC,
140
developeraace7f52022-06-24 13:40:42 +0800141--
developer5eddc512023-02-13 16:01:56 +08001422.39.0
developeraace7f52022-06-24 13:40:42 +0800143