blob: f663f2f1779adaf4d9bbd82cd57a362478427f4a [file] [log] [blame]
From 0b7c164634820842ce1d64057328d3eca657e4bd Mon Sep 17 00:00:00 2001
From: Howard Hsu <howard-yh.hsu@mediatek.com>
Date: Mon, 25 Sep 2023 19:20:49 +0800
Subject: [PATCH 1037/1044] mtk: wifi: mt76: mt7996: support enable/disable pp
feature by nl80211 vendor commands
User can enable/disable preamble puncture feature through hostapd
configuration and hostapd_cli. Driver can receive the nl80211 vendor
message and convert it to mcu commands.
Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
---
mt7996/vendor.c | 38 ++++++++++++++++++++++++++++++++++++++
mt7996/vendor.h | 12 ++++++++++++
2 files changed, 50 insertions(+)
diff --git a/mt7996/vendor.c b/mt7996/vendor.c
index c7fd3278..9732ed28 100644
--- a/mt7996/vendor.c
+++ b/mt7996/vendor.c
@@ -107,6 +107,11 @@ background_radar_ctrl_policy[NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL] = {
[MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MODE] = {.type = NLA_U8 },
};
+static struct nla_policy
+pp_ctrl_policy[NUM_MTK_VENDOR_ATTRS_PP_CTRL] = {
+ [MTK_VENDOR_ATTR_PP_MODE] = { .type = NLA_U8 },
+};
+
struct mt7996_amnt_data {
u8 idx;
u8 addr[ETH_ALEN];
@@ -877,6 +882,28 @@ static int mt7996_vendor_background_radar_mode_ctrl(struct wiphy *wiphy,
return mt7996_mcu_rdd_background_disable_timer(dev, !!background_radar_mode);
}
+static int mt7996_vendor_pp_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_PP_CTRL];
+ struct mt7996_phy *phy = mt7996_hw_phy(hw);
+ int err;
+ u8 val8;
+
+ err = nla_parse(tb, MTK_VENDOR_ATTR_PP_CTRL_MAX, data, data_len,
+ pp_ctrl_policy, NULL);
+ if (err)
+ return err;
+
+ if (tb[MTK_VENDOR_ATTR_PP_MODE]) {
+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_PP_MODE]);
+ err = mt7996_mcu_set_pp_en(phy, !!val8, 0, 0);
+ }
+
+ return err;
+}
+
static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
{
.info = {
@@ -982,6 +1009,17 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
.policy = background_radar_ctrl_policy,
.maxattr = MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MAX,
},
+ {
+ .info = {
+ .vendor_id = MTK_NL80211_VENDOR_ID,
+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_PP_CTRL,
+ },
+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
+ WIPHY_VENDOR_CMD_NEED_RUNNING,
+ .doit = mt7996_vendor_pp_ctrl,
+ .policy = pp_ctrl_policy,
+ .maxattr = MTK_VENDOR_ATTR_PP_CTRL_MAX,
+ },
};
void mt7996_vendor_register(struct mt7996_phy *phy)
diff --git a/mt7996/vendor.h b/mt7996/vendor.h
index 920b6e6a..98128965 100644
--- a/mt7996/vendor.h
+++ b/mt7996/vendor.h
@@ -15,6 +15,7 @@ enum mtk_nl80211_vendor_subcmds {
MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9,
MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca,
MTK_NL80211_VENDOR_SUBCMD_BACKGROUND_RADAR_CTRL = 0xcb,
+ MTK_NL80211_VENDOR_SUBCMD_PP_CTRL = 0xcc,
};
enum mtk_vendor_attr_edcca_ctrl {
@@ -214,6 +215,17 @@ enum mtk_vendor_attr_ibf_dump {
NUM_MTK_VENDOR_ATTRS_IBF_DUMP - 1
};
+enum mtk_vendor_attr_pp_ctrl {
+ MTK_VENDOR_ATTR_PP_CTRL_UNSPEC,
+
+ MTK_VENDOR_ATTR_PP_MODE,
+
+ /* keep last */
+ NUM_MTK_VENDOR_ATTRS_PP_CTRL,
+ MTK_VENDOR_ATTR_PP_CTRL_MAX =
+ NUM_MTK_VENDOR_ATTRS_PP_CTRL - 1
+};
+
#endif
#endif
--
2.18.0