blob: 9ab0aa14aaac9091945e8e7e8e327303e4d4114c [file] [log] [blame]
From 57a5dbbde09c23122671c936872b1f6fa41dcb9c 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 1035/1044] mtk: wifi: 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 5b5ddafb..69718654 100644
--- a/mt7996/mcu.c
+++ b/mt7996/mcu.c
@@ -4516,18 +4516,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,
@@ -4540,6 +4529,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 054a616b..398bf3d2 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 2f76a0af..f937008f 100644
--- a/mt7996/mt7996.h
+++ b/mt7996/mt7996.h
@@ -517,8 +517,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)
{
@@ -660,6 +663,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 477c5c42..c7fd3278 100644
--- a/mt7996/vendor.c
+++ b/mt7996/vendor.c
@@ -102,6 +102,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];
@@ -851,6 +856,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 = {
@@ -945,6 +971,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 7011914b..920b6e6a 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,
};
enum mtk_vendor_attr_edcca_ctrl {
@@ -126,6 +127,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.18.0