From adc09605d4c170735ca73390c8340476ccc19214 Mon Sep 17 00:00:00 2001 From: Manikanta Pubbisetty Date: Thu, 19 Dec 2019 19:16:44 +0530 Subject: [PATCH 1/2] ath11k: add counter to create delete monitor interface Signed-off-by: Manikanta Pubbisetty --- drivers/net/wireless/ath/ath11k/core.h | 2 ++ drivers/net/wireless/ath/ath11k/mac.c | 24 ++++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -613,6 +613,8 @@ struct ath11k { struct completion fw_mode_reset; int ap_ps_enabled; enum ath11k_ap_ps_state ap_ps_state; + + int monitor_vdev_cnt; }; struct ath11k_band_cap { --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -863,7 +863,7 @@ static int ath11k_mac_monitor_start(stru lockdep_assert_held(&ar->conf_mutex); - if (test_bit(ATH11K_MONITOR_FLAG_STARTED, &ar->monitor_flags)) + if (ar->monitor_vdev_cnt > 0) goto set_monitor_status; ret = ath11k_mac_monitor_vdev_create(ar); @@ -879,6 +879,7 @@ static int ath11k_mac_monitor_start(stru return ret; } + ar->monitor_vdev_cnt++; set_bit(ATH11K_MONITOR_FLAG_STARTED, &ar->monitor_flags); set_monitor_status: ret = ath11k_dp_tx_htt_monitor_mode_ring_config(ar, false); @@ -893,8 +894,8 @@ static int ath11k_mac_monitor_stop(struc lockdep_assert_held(&ar->conf_mutex); - if (!test_bit(ATH11K_MONITOR_FLAG_STARTED, &ar->monitor_flags)) - goto clear_monitor_status; + if (!ar->monitor_vdev_cnt) + goto clear_monitor_status; ret = ath11k_mac_monitor_vdev_stop(ar); if (ret) { @@ -906,17 +907,18 @@ static int ath11k_mac_monitor_stop(struc ath11k_warn(ar->ab, "failed to delete monitor vdev: %d\n", ret); return ret; } - clear_bit(ATH11K_MONITOR_FLAG_STARTED, &ar->monitor_flags); + ar->monitor_vdev_cnt--; clear_monitor_status: - ret = ath11k_mac_config_mon_status_default(ar, true); + ret = ath11k_dp_tx_htt_monitor_mode_ring_config(ar, true); ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac monitor stopped ret %d\n", ret); - + if(ar->monitor_vdev_cnt <= 0) + clear_bit(ATH11K_MONITOR_FLAG_STARTED, &ar->monitor_flags); return ret; } int ath11k_mac_monitor_recalc(struct ath11k *ar, bool needed) { - bool started = test_bit(ATH11K_MONITOR_FLAG_STARTED, &ar->monitor_flags); + bool started = !!ar->monitor_vdev_cnt; lockdep_assert_held(&ar->conf_mutex); ath11k_dbg(ar->ab, ATH11K_DBG_MAC, @@ -5034,7 +5036,7 @@ static int ath11k_mac_op_add_interface(s } break; case WMI_VDEV_TYPE_MONITOR: - ar->monitor_vdev_id = arvif->vdev_id; + ar->monitor_vdev_cnt++; break; default: break; @@ -5157,7 +5159,7 @@ static void ath11k_mac_op_remove_interfa } if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) - ar->monitor_vdev_id = -1; + ar->monitor_vdev_cnt--; err_vdev_del: spin_lock_bh(&ar->data_lock); @@ -5685,11 +5687,12 @@ ath11k_mac_op_assign_vif_chanctx(struct ctx->def.chan->center_freq, ret); goto err; } + if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { ret = ath11k_wmi_vdev_up(ar, arvif->vdev_id, 0, ar->mac_addr); if (ret) goto err; - set_bit(ATH11K_MONITOR_FLAG_STARTED, &ar->monitor_flags); + ar->monitor_vdev_cnt++; } arvif->is_started = true; @@ -5730,7 +5733,7 @@ ath11k_mac_op_unassign_vif_chanctx(struc ath11k_warn(ar->ab, "failed to down monitor vdev %i: %d\n", arvif->vdev_id, ret); arvif->is_up = false; - clear_bit(ATH11K_MONITOR_FLAG_STARTED, &ar->monitor_flags); + ar->monitor_vdev_cnt--; } ret = ath11k_mac_vdev_stop(arvif); @@ -7061,6 +7064,7 @@ int ath11k_mac_allocate(struct ath11k_ba skb_queue_head_init(&ar->wmi_mgmt_tx_queue); clear_bit(ATH11K_MONITOR_FLAG_STARTED, &ar->monitor_flags); ar->monitor_vdev_id = -1; + ar->monitor_vdev_cnt = 0; } return 0; --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -1014,8 +1014,11 @@ int ath11k_dp_tx_htt_monitor_mode_ring_c if (!reset) tlv_filter.rx_filter = HTT_RX_MON_FILTER_TLV_FLAGS_MON_STATUS_RING; - else + else { tlv_filter = ath11k_mac_mon_status_filter_default; + if (ar->debug.extd_rx_stats) + tlv_filter.rx_filter = ar->debug.rx_filter; + } ret = ath11k_dp_tx_htt_rx_filter_setup(ar->ab, ring_id, dp->mac_id, HAL_RXDMA_MONITOR_STATUS,