blob: fee0ffe5887a95cbcba62619479f8490b1487a69 [file] [log] [blame]
From 4f69ec4d4ea08bcc24fcfbaada9e1f82d70800ea Mon Sep 17 00:00:00 2001
From: Evelyn Tsai <evelyn.tsai@mediatek.com>
Date: Tue, 4 Apr 2023 02:27:44 +0800
Subject: [PATCH 1006/1034] wifi: mt76: mt7915: add mt76 vendor muru onoff
command
---
mt7915/mcu.c | 7 +++++++
mt7915/mcu.h | 1 +
mt7915/vendor.c | 43 +++++++++++++++++++++++++++++++++++++++++++
mt7915/vendor.h | 12 ++++++++++++
4 files changed, 63 insertions(+)
diff --git a/mt7915/mcu.c b/mt7915/mcu.c
index d5420cb..1f5f938 100644
--- a/mt7915/mcu.c
+++ b/mt7915/mcu.c
@@ -4149,6 +4149,13 @@ void mt7915_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
if (val == 0)
phy->muru_onoff = MUMIMO_DL_CERT | MUMIMO_DL;
break;
+ case RATE_PARAM_AUTO_MU:
+ if (val < 0 || val > 15) {
+ printk("Wrong value! The value is between 0-15.\n");
+ break;
+ }
+ phy->muru_onoff = val;
+ break;
}
}
diff --git a/mt7915/mcu.h b/mt7915/mcu.h
index 765ad11..84afa7f 100644
--- a/mt7915/mcu.h
+++ b/mt7915/mcu.h
@@ -478,6 +478,7 @@ enum {
#ifdef CONFIG_MTK_VENDOR
RATE_PARAM_FIXED_MIMO = 30,
RATE_PARAM_FIXED_OFDMA = 31,
+ RATE_PARAM_AUTO_MU = 32,
#endif
};
diff --git a/mt7915/vendor.c b/mt7915/vendor.c
index 5a1cce1..df1cac3 100644
--- a/mt7915/vendor.c
+++ b/mt7915/vendor.c
@@ -34,6 +34,11 @@ wireless_ctrl_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL] = {
[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT] = {.type = NLA_U8 },
};
+static const struct nla_policy
+mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = {
+ [MTK_VENDOR_ATTR_MU_CTRL_ONOFF] = {.type = NLA_U8 },
+};
+
static const struct nla_policy
rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = {
[MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI] = {.type = NLA_U8 },
@@ -944,6 +949,33 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy,
return 0;
}
+static int mt7915_vendor_mu_ctrl(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ const void *data,
+ int data_len)
+{
+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_MU_CTRL];
+ int err;
+ u8 val8;
+ u32 val32 = 0;
+
+ err = nla_parse(tb, MTK_VENDOR_ATTR_MU_CTRL_MAX, data, data_len,
+ mu_ctrl_policy, NULL);
+ if (err)
+ return err;
+
+ if (tb[MTK_VENDOR_ATTR_MU_CTRL_ONOFF]) {
+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_MU_CTRL_ONOFF]);
+ val32 |= FIELD_PREP(RATE_CFG_MODE, RATE_PARAM_AUTO_MU) |
+ FIELD_PREP(RATE_CFG_VAL, val8);
+ ieee80211_iterate_active_interfaces_atomic(hw, IEEE80211_IFACE_ITER_RESUME_ALL,
+ mt7915_set_wireless_vif, &val32);
+ }
+
+ return 0;
+}
+
static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
{
.info = {
@@ -990,6 +1022,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
.doit = mt7915_vendor_wireless_ctrl,
.policy = wireless_ctrl_policy,
.maxattr = MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX,
+ },
+ {
+ .info = {
+ .vendor_id = MTK_NL80211_VENDOR_ID,
+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_MU_CTRL,
+ },
+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
+ WIPHY_VENDOR_CMD_NEED_RUNNING,
+ .doit = mt7915_vendor_mu_ctrl,
+ .policy = mu_ctrl_policy,
+ .maxattr = MTK_VENDOR_ATTR_MU_CTRL_MAX,
}
};
diff --git a/mt7915/vendor.h b/mt7915/vendor.h
index 1b08321..2be5fc8 100644
--- a/mt7915/vendor.h
+++ b/mt7915/vendor.h
@@ -8,6 +8,7 @@ enum mtk_nl80211_vendor_subcmds {
MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2,
MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3,
MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4,
+ MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
};
enum mtk_capi_control_changed {
@@ -33,6 +34,17 @@ enum mtk_vendor_attr_wireless_ctrl {
NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1
};
+enum mtk_vendor_attr_mu_ctrl {
+ MTK_VENDOR_ATTR_MU_CTRL_UNSPEC,
+
+ MTK_VENDOR_ATTR_MU_CTRL_ONOFF,
+
+ /* keep last */
+ NUM_MTK_VENDOR_ATTRS_MU_CTRL,
+ MTK_VENDOR_ATTR_MU_CTRL_MAX =
+ NUM_MTK_VENDOR_ATTRS_MU_CTRL - 1
+};
+
enum mtk_vendor_attr_rfeature_ctrl {
MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC,
--
2.18.0