blob: 34d3fac0421a24cce3f812a05c3c081ef9535747 [file] [log] [blame]
From 3d569a8df7ab86ada17a30c6e3a969441ff87a1e Mon Sep 17 00:00:00 2001
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Date: Fri, 22 Sep 2023 12:33:06 +0800
Subject: [PATCH 039/193] mtk: mt76: mt7996: add zwdfs cert mode
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
---
mt7996/mcu.c | 44 ++++++++++++++++++++++++++++++++------------
mt7996/mcu.h | 14 ++++++++++++++
mt7996/mt7996.h | 5 +++++
mt7996/vendor.c | 37 +++++++++++++++++++++++++++++++++++++
mt7996/vendor.h | 12 ++++++++++++
5 files changed, 100 insertions(+), 12 deletions(-)
diff --git a/mt7996/mcu.c b/mt7996/mcu.c
index cf7b200..b6de1b5 100644
--- a/mt7996/mcu.c
+++ b/mt7996/mcu.c
@@ -4532,18 +4532,7 @@ int mt7996_mcu_set_radio_en(struct mt7996_phy *phy, bool enable)
int mt7996_mcu_rdd_cmd(struct mt7996_dev *dev, int cmd, u8 index,
u8 rx_sel, u8 val)
{
- struct {
- u8 _rsv[4];
-
- __le16 tag;
- __le16 len;
-
- u8 ctrl;
- u8 rdd_idx;
- u8 rdd_rx_sel;
- u8 val;
- u8 rsv[4];
- } __packed req = {
+ struct mt7996_rdd_ctrl req = {
.tag = cpu_to_le16(UNI_RDD_CTRL_PARM),
.len = cpu_to_le16(sizeof(req) - 4),
.ctrl = cmd,
@@ -4556,6 +4545,37 @@ int mt7996_mcu_rdd_cmd(struct mt7996_dev *dev, int cmd, u8 index,
&req, sizeof(req), true);
}
+int mt7996_mcu_rdd_background_disable_timer(struct mt7996_dev *dev, bool disable_timer)
+{
+ struct mt7996_rdd_ctrl req = {
+ .tag = cpu_to_le16(UNI_RDD_CTRL_PARM),
+ .len = cpu_to_le16(sizeof(req) - 4),
+ .ctrl = RDD_DISABLE_ZW_TIMER,
+ .rdd_idx = MT_RX_SEL2,
+ .disable_timer = disable_timer,
+ };
+
+ if (!is_mt7996(&dev->mt76) ||
+ (mt76_get_field(dev, MT_PAD_GPIO, MT_PAD_GPIO_ADIE_COMB) % 2))
+ return 0;
+
+ switch (dev->mt76.region) {
+ case NL80211_DFS_ETSI:
+ req.val = 0;
+ break;
+ case NL80211_DFS_JP:
+ req.val = 2;
+ break;
+ case NL80211_DFS_FCC:
+ default:
+ req.val = 1;
+ break;
+ }
+
+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(RDD_CTRL),
+ &req, sizeof(req), true);
+}
+
int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
diff --git a/mt7996/mcu.h b/mt7996/mcu.h
index c6bb93b..3025f84 100644
--- a/mt7996/mcu.h
+++ b/mt7996/mcu.h
@@ -119,6 +119,20 @@ struct mt7996_mcu_rdd_report {
} hw_pulse[32];
} __packed;
+struct mt7996_rdd_ctrl {
+ u8 _rsv[4];
+
+ __le16 tag;
+ __le16 len;
+
+ u8 ctrl;
+ u8 rdd_idx;
+ u8 rdd_rx_sel;
+ u8 val;
+ u8 disable_timer;
+ u8 rsv[3];
+} __packed;
+
struct mt7996_mcu_background_chain_ctrl {
u8 _rsv[4];
diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
index 32a0ffd..e406dc8 100644
--- a/mt7996/mt7996.h
+++ b/mt7996/mt7996.h
@@ -536,8 +536,11 @@ enum mt7996_rdd_cmd {
RDD_READ_PULSE,
RDD_RESUME_BF,
RDD_IRQ_OFF,
+ RDD_DISABLE_ZW_TIMER,
};
+#define RDD_ZW_TIMER_OFF BIT(31)
+
static inline struct mt7996_phy *
mt7996_hw_phy(struct ieee80211_hw *hw)
{
@@ -697,6 +700,8 @@ int mt7996_mcu_set_thermal_protect(struct mt7996_phy *phy, bool enable);
int mt7996_mcu_set_txpower_sku(struct mt7996_phy *phy);
int mt7996_mcu_rdd_cmd(struct mt7996_dev *dev, int cmd, u8 index,
u8 rx_sel, u8 val);
+int mt7996_mcu_rdd_background_disable_timer(struct mt7996_dev *dev,
+ bool disable_timer);
int mt7996_mcu_rdd_background_enable(struct mt7996_phy *phy,
struct cfg80211_chan_def *chandef);
int mt7996_mcu_set_fixed_rate_table(struct mt7996_phy *phy, u8 table_idx,
diff --git a/mt7996/vendor.c b/mt7996/vendor.c
index 7ab6447..ba00ef3 100644
--- a/mt7996/vendor.c
+++ b/mt7996/vendor.c
@@ -108,6 +108,11 @@ rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = {
[MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TXBF] = { .type = NLA_U8 },
};
+static const struct nla_policy
+background_radar_ctrl_policy[NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL] = {
+ [MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MODE] = {.type = NLA_U8 },
+};
+
struct mt7996_amnt_data {
u8 idx;
u8 addr[ETH_ALEN];
@@ -916,6 +921,27 @@ static int mt7996_vendor_wireless_ctrl(struct wiphy *wiphy,
return 0;
}
+static int mt7996_vendor_background_radar_mode_ctrl(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ const void *data,
+ int data_len)
+{
+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL];
+ int err;
+ u8 background_radar_mode;
+
+ err = nla_parse(tb, MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MAX, data, data_len,
+ background_radar_ctrl_policy, NULL);
+ if (err)
+ return err;
+
+ background_radar_mode = nla_get_u8(tb[MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MODE]);
+
+ return mt7996_mcu_rdd_background_disable_timer(dev, !!background_radar_mode);
+}
+
static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
{
.info = {
@@ -1021,6 +1047,17 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
.policy = rfeature_ctrl_policy,
.maxattr = MTK_VENDOR_ATTR_RFEATURE_CTRL_MAX,
},
+ {
+ .info = {
+ .vendor_id = MTK_NL80211_VENDOR_ID,
+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_BACKGROUND_RADAR_CTRL,
+ },
+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
+ WIPHY_VENDOR_CMD_NEED_RUNNING,
+ .doit = mt7996_vendor_background_radar_mode_ctrl,
+ .policy = background_radar_ctrl_policy,
+ .maxattr = MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MAX,
+ },
};
void mt7996_vendor_register(struct mt7996_phy *phy)
diff --git a/mt7996/vendor.h b/mt7996/vendor.h
index 2ee1339..7c812f9 100644
--- a/mt7996/vendor.h
+++ b/mt7996/vendor.h
@@ -14,6 +14,7 @@ enum mtk_nl80211_vendor_subcmds {
MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8,
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,
};
@@ -127,6 +128,17 @@ enum mtk_vendor_attr_wireless_dump {
NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP - 1
};
+enum mtk_vendor_attr_background_radar_ctrl {
+ MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_UNSPEC,
+
+ MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MODE,
+
+ /* keep last */
+ NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL,
+ MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MAX =
+ NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL - 1
+};
+
enum bw_sig {
BW_SIGNALING_DISABLE,
BW_SIGNALING_STATIC,
--
2.45.2