rtw88: add h2c command in debugfs
authorTzu-En Huang <tehuang@realtek.com>
Fri, 17 Jul 2020 06:49:37 +0000 (14:49 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Sun, 2 Aug 2020 15:05:19 +0000 (18:05 +0300)
It's very useful to send H2C command for debug usage. Add an entry
for sending H2C command to firmware.

usage example:
echo 42,00,00,43,02,00,00,00 > /sys/kernel/debug/ieee80211/phyX/rtw88

Signed-off-by: Tzu-En Huang <tehuang@realtek.com>
Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200717064937.27966-8-yhchuang@realtek.com
drivers/net/wireless/realtek/rtw88/debug.c
drivers/net/wireless/realtek/rtw88/fw.c
drivers/net/wireless/realtek/rtw88/fw.h

index 09f04fe..f769c98 100644 (file)
@@ -344,6 +344,31 @@ static ssize_t rtw_debugfs_set_write_reg(struct file *filp,
        return count;
 }
 
+static ssize_t rtw_debugfs_set_h2c(struct file *filp,
+                                  const char __user *buffer,
+                                  size_t count, loff_t *loff)
+{
+       struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
+       struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+       char tmp[32 + 1];
+       u8 param[8];
+       int num;
+
+       rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
+
+       num = sscanf(tmp, "%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx",
+                    &param[0], &param[1], &param[2], &param[3],
+                    &param[4], &param[5], &param[6], &param[7]);
+       if (num != 8) {
+               rtw_info(rtwdev, "invalid H2C command format for debug\n");
+               return -EINVAL;
+       }
+
+       rtw_fw_h2c_cmd_dbg(rtwdev, param);
+
+       return count;
+}
+
 static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
                                        const char __user *buffer,
                                        size_t count, loff_t *loff)
@@ -808,6 +833,10 @@ static struct rtw_debugfs_priv rtw_debug_priv_write_reg = {
        .cb_write = rtw_debugfs_set_write_reg,
 };
 
+static struct rtw_debugfs_priv rtw_debug_priv_h2c = {
+       .cb_write = rtw_debugfs_set_h2c,
+};
+
 static struct rtw_debugfs_priv rtw_debug_priv_rf_write = {
        .cb_write = rtw_debugfs_set_rf_write,
 };
@@ -877,6 +906,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev)
        rtw_debugfs_add_r(phy_info);
        rtw_debugfs_add_r(coex_info);
        rtw_debugfs_add_rw(coex_enable);
+       rtw_debugfs_add_w(h2c);
        rtw_debugfs_add_r(mac_0);
        rtw_debugfs_add_r(mac_1);
        rtw_debugfs_add_r(mac_2);
index c922b4b..63b00bc 100644 (file)
@@ -253,6 +253,11 @@ out:
        spin_unlock(&rtwdev->h2c.lock);
 }
 
+void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c)
+{
+       rtw_fw_send_h2c_command(rtwdev, h2c);
+}
+
 static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt)
 {
        int ret;
index 470e180..686dcd3 100644 (file)
@@ -563,4 +563,6 @@ void rtw_fw_set_nlo_info(struct rtw_dev *rtwdev, bool enable);
 void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev,
                                 struct cfg80211_ssid *ssid);
 void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable);
+void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c);
+
 #endif