From: Aishwarya R Add debugfs support to simulate incumbent signal interference from the host for testing purposes. The debugfs entry is created only for 6 GHz radio when firmware advertises the support through WMI_TLV_SERVICE_DCS_INCUMBENT_SIGNAL_INTERFERENCE_SUPPORT flag. Debugfs command: echo > /sys/kernel/debug/ath12k/pci-000X/macX/simulate_incumbent_signal_interference Each bit in the interference_bitmap represents a 20 MHz segment. Bit 0 corresponds to the primary 20 MHz segment, regardless of its position within the operating bandwidth. Bit 1 represents the next adjacent 20 MHz segment, bit 2 the lower 20 MHz segment of the adjacent 40 MHz segment, and so on-progressing sequentially across the bandwidth.. Example: echo 0xF0 > /sys/kernel/debug/ath12k/pci-0002:01:00.0/mac0/simulate_incumbent_signal_interference This indicates that all the subchannels in the secondary 80 MHz segment were affected. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.5-01651-QCAHKSWPL_SILICONZ-1 Signed-off-by: Aishwarya R Signed-off-by: Amith A --- drivers/net/wireless/ath/ath12k/debugfs.c | 46 +++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/wmi.c | 36 ++++++++++++++++++ drivers/net/wireless/ath/ath12k/wmi.h | 14 +++++++ 3 files changed, 96 insertions(+) diff --git a/drivers/net/wireless/ath/ath12k/debugfs.c b/drivers/net/wireless/ath/ath12k/debugfs.c index 8c81a1c22449..d17d4a8f1cb7 100644 --- a/drivers/net/wireless/ath/ath12k/debugfs.c +++ b/drivers/net/wireless/ath/ath12k/debugfs.c @@ -1450,6 +1450,44 @@ static const struct file_operations fops_pdev_stats = { .llseek = default_llseek, }; +static ssize_t +ath12k_write_simulate_incumbent_signal_interference(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath12k *ar = file->private_data; + struct ath12k_hw *ah = ath12k_ar_to_ah(ar); + struct wiphy *wiphy = ath12k_ar_to_hw(ar)->wiphy; + u32 chan_bw_interference_bitmap; + int ret; + + if (ah->state != ATH12K_HW_STATE_ON) + return -ENETDOWN; + + /* + * Bitmap uses the firmware primary-based ordering documented in + * ath12k_wmi_transform_interference_bitmap() & intf_map_80. + */ + if (kstrtou32_from_user(user_buf, count, 0, &chan_bw_interference_bitmap)) + return -EINVAL; + + wiphy_lock(wiphy); + ret = ath12k_wmi_simulate_incumbent_signal_interference(ar, chan_bw_interference_bitmap); + if (ret) + goto exit; + + ret = count; + +exit: + wiphy_unlock(wiphy); + return ret; +} + +static const struct file_operations fops_simulate_incumbent_signal_interference = { + .write = ath12k_write_simulate_incumbent_signal_interference, + .open = simple_open, +}; + static void ath12k_debugfs_fw_stats_register(struct ath12k *ar) { @@ -1515,6 +1553,14 @@ void ath12k_debugfs_register(struct ath12k *ar) ar, &fops_tpc_stats_type); init_completion(&ar->debug.tpc_complete); + if (ar->mac.sbands[NL80211_BAND_6GHZ].channels && + test_bit(WMI_TLV_SERVICE_DCS_INCUMBENT_SIGNAL_INTERFERENCE_SUPPORT, + ar->ab->wmi_ab.svc_map)) { + debugfs_create_file("simulate_incumbent_signal_interference", 0200, + ar->debug.debugfs_pdev, ar, + &fops_simulate_incumbent_signal_interference); + } + ath12k_debugfs_htt_stats_register(ar); ath12k_debugfs_fw_stats_register(ar); diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c index b9e107cfd869..4ec5b12f703b 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.c +++ b/drivers/net/wireless/ath/ath12k/wmi.c @@ -10561,6 +10561,42 @@ int ath12k_wmi_send_tpc_stats_request(struct ath12k *ar, return ret; } +int ath12k_wmi_simulate_incumbent_signal_interference(struct ath12k *ar, + u32 chan_bw_interference_bitmap) +{ + struct wmi_unit_test_arg wmi_ut = {}; + struct ath12k_link_vif *arvif; + struct ath12k_vif *ahvif; + bool arvif_found = false; + + list_for_each_entry(arvif, &ar->arvifs, list) { + ahvif = arvif->ahvif; + if (arvif->is_started && ahvif->vdev_type == WMI_VDEV_TYPE_AP) { + arvif_found = true; + break; + } + } + + if (!arvif_found) + return -EINVAL; + + wmi_ut.args[ATH12K_WMI_INCUMBENT_SIGNAL_TEST_INTF] = + ATH12K_WMI_UNIT_TEST_INCUMBENT_SIGNAL_INTF_TYPE; + wmi_ut.args[ATH12K_WMI_INCUMBENT_SIGNAL_TEST_BITMAP] = + chan_bw_interference_bitmap; + + wmi_ut.vdev_id = arvif->vdev_id; + wmi_ut.module_id = ATH12K_WMI_INCUMBENT_SIGNAL_UNIT_TEST_MODULE; + wmi_ut.num_args = ATH12K_WMI_INCUMBENT_SIGNAL_MAX_TEST_ARGS; + wmi_ut.diag_token = ATH12K_WMI_INCUMBENT_SIGNAL_UNIT_TEST_TOKEN; + + ath12k_dbg(ar->ab, ATH12K_DBG_WMI, + "Triggering incumbent signal interference simulation, interference bitmap: 0x%x\n", + chan_bw_interference_bitmap); + + return ath12k_wmi_send_unit_test_cmd(ar, &wmi_ut); +} + int ath12k_wmi_connect(struct ath12k_base *ab) { u32 i; diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h index d74f7fca7678..b5b3e472631c 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.h +++ b/drivers/net/wireless/ath/ath12k/wmi.h @@ -2269,6 +2269,8 @@ enum wmi_tlv_service { WMI_TLV_SERVICE_REG_CC_EXT_EVENT_SUPPORT = 281, + WMI_TLV_SERVICE_DCS_INCUMBENT_SIGNAL_INTERFERENCE_SUPPORT = 286, + WMI_TLV_SERVICE_11BE = 289, WMI_TLV_SERVICE_WMSK_COMPACTION_RX_TLVS = 361, @@ -4244,6 +4246,10 @@ struct wmi_addba_clear_resp_cmd { #define DFS_UNIT_TEST_MODULE 0x2b #define DFS_UNIT_TEST_TOKEN 0xAA +#define ATH12K_WMI_INCUMBENT_SIGNAL_UNIT_TEST_MODULE 0x18 +#define ATH12K_WMI_INCUMBENT_SIGNAL_UNIT_TEST_TOKEN 0 +#define ATH12K_WMI_UNIT_TEST_INCUMBENT_SIGNAL_INTF_TYPE 1 + enum dfs_test_args_idx { DFS_TEST_CMDID = 0, DFS_TEST_PDEV_ID, @@ -4251,6 +4257,12 @@ enum dfs_test_args_idx { DFS_MAX_TEST_ARGS, }; +enum ath12k_wmi_incumbent_signal_test_args_idx { + ATH12K_WMI_INCUMBENT_SIGNAL_TEST_INTF, + ATH12K_WMI_INCUMBENT_SIGNAL_TEST_BITMAP, + ATH12K_WMI_INCUMBENT_SIGNAL_MAX_TEST_ARGS, +}; + /* update if another test command requires more */ #define WMI_UNIT_TEST_ARGS_MAX DFS_MAX_TEST_ARGS @@ -6682,6 +6694,8 @@ int ath12k_wmi_send_vdev_set_tpc_power(struct ath12k *ar, struct ath12k_reg_tpc_power_info *param); int ath12k_wmi_send_mlo_link_set_active_cmd(struct ath12k_base *ab, struct wmi_mlo_link_set_active_arg *param); +int ath12k_wmi_simulate_incumbent_signal_interference(struct ath12k *ar, + u32 chan_bw_interference_bitmap); int ath12k_wmi_alloc(void); void ath12k_wmi_free(void); -- 2.34.1