blob: 1a3d22e51ade6456a4909773f79d34aab0e04217 [file] [log] [blame]
From e4a6bac2e1b29a00396adc9bdd1b276eb3e0ee4a Mon Sep 17 00:00:00 2001
From: Howard Hsu <howard-yh.hsu@mediatek.com>
Date: Tue, 13 Jun 2023 14:49:02 +0800
Subject: [PATCH 036/223] mtk: mt76: mt7996: add build the following MURU mcu
command tlvs
It includes the following tlvs:
1. MURU tlv id 0x10, 0x33, 0xC8, 0xC9, 0xCA, 0xCC, 0xCD
2. BF tlv id 0x1c
Change-Id: I0ae5cbed5b4370d39a6cfca50721873845659006
---
mt7996/mcu.h | 1 +
mt7996/mt7996.h | 3 ++
mt7996/mtk_debugfs.c | 123 +++++++++++++++++++++++++++++++++++++++++++
mt7996/mtk_mcu.c | 78 +++++++++++++++++++++++++++
mt7996/mtk_mcu.h | 14 +++++
5 files changed, 219 insertions(+)
diff --git a/mt7996/mcu.h b/mt7996/mcu.h
index 8a718513..a98b174e 100644
--- a/mt7996/mcu.h
+++ b/mt7996/mcu.h
@@ -776,6 +776,7 @@ enum {
BF_MOD_EN_CTRL = 20,
BF_FBRPT_DBG_INFO_READ = 23,
BF_TXSND_INFO = 24,
+ BF_CFG_PHY = 28,
};
enum {
diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
index 8d986dee..ed998c0e 100644
--- a/mt7996/mt7996.h
+++ b/mt7996/mt7996.h
@@ -852,6 +852,9 @@ void mt7996_mcu_rx_bf_event(struct mt7996_dev *dev, struct sk_buff *skb);
int mt7996_mcu_set_muru_fixed_rate_enable(struct mt7996_dev *dev, u8 action, int val);
int mt7996_mcu_set_muru_fixed_rate_parameter(struct mt7996_dev *dev, u8 action, void *para);
int mt7996_mcu_set_txbf_snd_info(struct mt7996_phy *phy, void *para);
+int mt7996_mcu_set_muru_cmd(struct mt7996_dev *dev, u16 action, int val);
+int mt7996_mcu_muru_set_prot_frame_thr(struct mt7996_dev *dev, u32 val);
+int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val);
#endif
#ifdef CONFIG_NET_MEDIATEK_SOC_WED
diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c
index 51449df4..1c4e2c90 100644
--- a/mt7996/mtk_debugfs.c
+++ b/mt7996/mtk_debugfs.c
@@ -2911,6 +2911,127 @@ mt7996_sr_scene_cond_show(struct seq_file *file, void *data)
}
DEFINE_SHOW_ATTRIBUTE(mt7996_sr_scene_cond);
+static int
+mt7996_starec_bf_read_set(void *data, u64 wlan_idx)
+{
+ struct mt7996_phy *phy = data;
+
+ return mt7996_mcu_set_txbf_internal(phy, BF_STA_REC_READ, wlan_idx);
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_starec_bf_read, NULL,
+ mt7996_starec_bf_read_set, "%lld\n");
+
+static ssize_t
+mt7996_bf_txsnd_info_set(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct mt7996_phy *phy = file->private_data;
+ char buf[40];
+ int ret;
+
+ if (count >= sizeof(buf))
+ return -EINVAL;
+
+ if (copy_from_user(buf, user_buf, count))
+ return -EFAULT;
+
+ if (count && buf[count - 1] == '\n')
+ buf[count - 1] = '\0';
+ else
+ buf[count] = '\0';
+
+ ret = mt7996_mcu_set_txbf_snd_info(phy, buf);
+
+ if (ret) return -EFAULT;
+
+ return count;
+}
+
+static const struct file_operations fops_bf_txsnd_info = {
+ .write = mt7996_bf_txsnd_info_set,
+ .read = NULL,
+ .open = simple_open,
+ .llseek = default_llseek,
+};
+
+static int
+mt7996_bf_fbk_rpt_set(void *data, u64 wlan_idx)
+{
+ struct mt7996_phy *phy = data;
+
+ return mt7996_mcu_set_txbf_internal(phy, BF_FBRPT_DBG_INFO_READ, wlan_idx);
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_bf_fbk_rpt, NULL,
+ mt7996_bf_fbk_rpt_set, "%lld\n");
+
+static int
+mt7996_bf_pfmu_tag_read_set(void *data, u64 wlan_idx)
+{
+ struct mt7996_phy *phy = data;
+
+ return mt7996_mcu_set_txbf_internal(phy, BF_PFMU_TAG_READ, wlan_idx);
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_bf_pfmu_tag_read, NULL,
+ mt7996_bf_pfmu_tag_read_set, "%lld\n");
+
+static int
+mt7996_muru_fixed_rate_set(void *data, u64 val)
+{
+ struct mt7996_dev *dev = data;
+
+ return mt7996_mcu_set_muru_fixed_rate_enable(dev, UNI_CMD_MURU_FIXED_RATE_CTRL,
+ val);
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_muru_fixed_rate_enable, NULL,
+ mt7996_muru_fixed_rate_set, "%lld\n");
+
+static ssize_t
+mt7996_muru_fixed_rate_parameter_set(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct mt7996_dev *dev = file->private_data;
+ char buf[40];
+ int ret;
+
+ if (count >= sizeof(buf))
+ return -EINVAL;
+
+ if (copy_from_user(buf, user_buf, count))
+ return -EFAULT;
+
+ if (count && buf[count - 1] == '\n')
+ buf[count - 1] = '\0';
+ else
+ buf[count] = '\0';
+
+
+ ret = mt7996_mcu_set_muru_fixed_rate_parameter(dev, UNI_CMD_MURU_FIXED_GROUP_RATE_CTRL,
+ buf);
+
+ if (ret) return -EFAULT;
+
+ return count;
+}
+
+static const struct file_operations fops_muru_fixed_group_rate = {
+ .write = mt7996_muru_fixed_rate_parameter_set,
+ .read = NULL,
+ .open = simple_open,
+ .llseek = default_llseek,
+};
+
+static int mt7996_muru_prot_thr_set(void *data, u64 val)
+{
+ struct mt7996_phy *phy = data;
+
+ return mt7996_mcu_muru_set_prot_frame_thr(phy->dev, (u32)val);
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(fops_muru_prot_thr, NULL,
+ mt7996_muru_prot_thr_set, "%lld\n");
+
int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir)
{
struct mt7996_dev *dev = phy->dev;
@@ -3005,6 +3126,8 @@ int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir)
debugfs_create_file("bf_fbk_rpt", 0600, dir, phy, &fops_bf_fbk_rpt);
debugfs_create_file("pfmu_tag_read", 0600, dir, phy, &fops_bf_pfmu_tag_read);
+ debugfs_create_file("muru_prot_thr", 0200, dir, phy, &fops_muru_prot_thr);
+
return 0;
}
diff --git a/mt7996/mtk_mcu.c b/mt7996/mtk_mcu.c
index 6b2cdad6..68650623 100644
--- a/mt7996/mtk_mcu.c
+++ b/mt7996/mtk_mcu.c
@@ -904,4 +904,82 @@ error:
return -EINVAL;
}
+/**
+ * This function can be used to build the following commands
+ * MURU_SUTX_CTRL (0x10)
+ * SET_FORCE_MU (0x33)
+ * SET_MUDL_ACK_POLICY (0xC8)
+ * SET_TRIG_TYPE (0xC9)
+ * SET_20M_DYN_ALGO (0xCA)
+ * SET_CERT_MU_EDCA_OVERRIDE (0xCD)
+ */
+int mt7996_mcu_set_muru_cmd(struct mt7996_dev *dev, u16 action, int val)
+{
+ struct {
+ u8 _rsv[4];
+
+ __le16 tag;
+ __le16 len;
+
+ u8 config;
+ u8 rsv[3];
+ } __packed data = {
+ .tag = cpu_to_le16(action),
+ .len = cpu_to_le16(sizeof(data) - 4),
+ .config = (u8) val,
+ };
+
+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &data, sizeof(data),
+ false);
+}
+
+int mt7996_mcu_muru_set_prot_frame_thr(struct mt7996_dev *dev, u32 val)
+{
+ struct {
+ u8 _rsv[4];
+
+ __le16 tag;
+ __le16 len;
+
+ __le32 prot_frame_thr;
+ } __packed data = {
+ .tag = cpu_to_le16(UNI_CMD_MURU_PROT_FRAME_THR),
+ .len = cpu_to_le16(sizeof(data) - 4),
+ .prot_frame_thr = cpu_to_le32(val),
+ };
+
+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &data, sizeof(data),
+ false);
+}
+
+int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val)
+{
+#define BF_PHY_SMTH_INT_BYPASS 0
+#define BYPASS_VAL 1
+ struct mt7996_dev *dev = phy->dev;
+ struct {
+ u8 _rsv[4];
+
+ u16 tag;
+ u16 len;
+
+ u8 action;
+ u8 band_idx;
+ u8 smthintbypass;
+ u8 __rsv2[5];
+ } __packed data = {
+ .tag = cpu_to_le16(BF_CFG_PHY),
+ .len = cpu_to_le16(sizeof(data) - 4),
+ .action = BF_PHY_SMTH_INT_BYPASS,
+ .band_idx = phy->mt76->band_idx,
+ .smthintbypass = val,
+ };
+
+ if (val != BYPASS_VAL)
+ return -EINVAL;
+
+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(BF), &data, sizeof(data),
+ true);
+}
+
#endif
diff --git a/mt7996/mtk_mcu.h b/mt7996/mtk_mcu.h
index 27d6a05b..d9686ebb 100644
--- a/mt7996/mtk_mcu.h
+++ b/mt7996/mtk_mcu.h
@@ -119,6 +119,20 @@ enum {
EDCCA_FCC = 1,
EDCCA_ETSI = 2,
EDCCA_JAPAN = 3
+};
+
+enum {
+ UNI_CMD_MURU_SUTX_CTRL = 0x10,
+ UNI_CMD_MURU_FIXED_RATE_CTRL,
+ UNI_CMD_MURU_FIXED_GROUP_RATE_CTRL,
+ UNI_CMD_MURU_SET_FORCE_MU = 0x33,
+ UNI_CMD_MURU_MUNUAL_CONFIG = 0x64,
+ UNI_CMD_MURU_SET_MUDL_ACK_POLICY = 0xC9,
+ UNI_CMD_MURU_SET_TRIG_TYPE,
+ UNI_CMD_MURU_SET_20M_DYN_ALGO,
+ UNI_CMD_MURU_PROT_FRAME_THR = 0xCC,
+ UNI_CMD_MURU_SET_CERT_MU_EDCA_OVERRIDE,
+};
struct bf_pfmu_tag {
__le16 tag;
--
2.45.2