Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtw88: add h2c command in debugfs

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

authored by

Tzu-En Huang and committed by
Kalle Valo
c376c1fc 752310ed

+37
+30
drivers/net/wireless/realtek/rtw88/debug.c
··· 344 344 return count; 345 345 } 346 346 347 + static ssize_t rtw_debugfs_set_h2c(struct file *filp, 348 + const char __user *buffer, 349 + size_t count, loff_t *loff) 350 + { 351 + struct rtw_debugfs_priv *debugfs_priv = filp->private_data; 352 + struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 353 + char tmp[32 + 1]; 354 + u8 param[8]; 355 + int num; 356 + 357 + rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3); 358 + 359 + num = sscanf(tmp, "%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx", 360 + &param[0], &param[1], &param[2], &param[3], 361 + &param[4], &param[5], &param[6], &param[7]); 362 + if (num != 8) { 363 + rtw_info(rtwdev, "invalid H2C command format for debug\n"); 364 + return -EINVAL; 365 + } 366 + 367 + rtw_fw_h2c_cmd_dbg(rtwdev, param); 368 + 369 + return count; 370 + } 371 + 347 372 static ssize_t rtw_debugfs_set_rf_write(struct file *filp, 348 373 const char __user *buffer, 349 374 size_t count, loff_t *loff) ··· 833 808 .cb_write = rtw_debugfs_set_write_reg, 834 809 }; 835 810 811 + static struct rtw_debugfs_priv rtw_debug_priv_h2c = { 812 + .cb_write = rtw_debugfs_set_h2c, 813 + }; 814 + 836 815 static struct rtw_debugfs_priv rtw_debug_priv_rf_write = { 837 816 .cb_write = rtw_debugfs_set_rf_write, 838 817 }; ··· 906 877 rtw_debugfs_add_r(phy_info); 907 878 rtw_debugfs_add_r(coex_info); 908 879 rtw_debugfs_add_rw(coex_enable); 880 + rtw_debugfs_add_w(h2c); 909 881 rtw_debugfs_add_r(mac_0); 910 882 rtw_debugfs_add_r(mac_1); 911 883 rtw_debugfs_add_r(mac_2);
+5
drivers/net/wireless/realtek/rtw88/fw.c
··· 253 253 spin_unlock(&rtwdev->h2c.lock); 254 254 } 255 255 256 + void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c) 257 + { 258 + rtw_fw_send_h2c_command(rtwdev, h2c); 259 + } 260 + 256 261 static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt) 257 262 { 258 263 int ret;
+2
drivers/net/wireless/realtek/rtw88/fw.h
··· 563 563 void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev, 564 564 struct cfg80211_ssid *ssid); 565 565 void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable); 566 + void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c); 567 + 566 568 #endif