All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ATH11K DFS Support
@ 2019-05-14  4:41 Sriram R
  2019-05-14  4:41 ` [PATCH 1/3] ath11k: Process radar detected event Sriram R
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sriram R @ 2019-05-14  4:41 UTC (permalink / raw)
  To: ath11k; +Cc: Sriram R

This patchset enables dfs support in ath11k driver.
Firmware provides support for offloading certain modules
required for dfs implementation such as radar detection
and NOL implementation.

Sriram R (3):
  ath11k: Process radar detected event
  ath11k: Initialize and enable dfs radar detection
  ath11k: Add dfs debug and test interface

 drivers/net/wireless/ath/ath11k/core.h  |   1 +
 drivers/net/wireless/ath/ath11k/debug.c |  28 ++++++
 drivers/net/wireless/ath/ath11k/dp_rx.c |  20 +++-
 drivers/net/wireless/ath/ath11k/mac.c   |  54 +++++++++--
 drivers/net/wireless/ath/ath11k/wmi.c   | 164 +++++++++++++++++++++++++++++++-
 drivers/net/wireless/ath/ath11k/wmi.h   |  42 ++++++++
 6 files changed, 295 insertions(+), 14 deletions(-)

-- 
2.7.4


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] ath11k: Process radar detected event
  2019-05-14  4:41 [PATCH 0/3] ATH11K DFS Support Sriram R
@ 2019-05-14  4:41 ` Sriram R
  2019-05-20  8:25   ` Kalle Valo
  2019-05-14  4:41 ` [PATCH 2/3] ath11k: Initialize and enable dfs radar detection Sriram R
  2019-05-14  4:41 ` [PATCH 3/3] ath11k: Add dfs debug and test interface Sriram R
  2 siblings, 1 reply; 5+ messages in thread
From: Sriram R @ 2019-05-14  4:41 UTC (permalink / raw)
  To: ath11k; +Cc: Sriram R

Add support for processing radar detected event
coming from the firmware. The detected radar
is indicated to mac80211 after checking the
validity of detection.

Signed-off-by: Sriram R <srirrama@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/wmi.c | 56 +++++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath11k/wmi.h | 13 ++++++++
 2 files changed, 69 insertions(+)

diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index 5712ac0..434508f 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -5770,6 +5770,59 @@ ath11k_wmi_pdev_csa_switch_count_status_event(struct ath11k_base *ab,
 	kfree(tb);
 }
 
+static void
+ath11k_wmi_pdev_dfs_radar_detected_event(struct ath11k_base *ab,
+					 u8 *evt_buf,
+					 u32 len)
+{
+	const void **tb;
+	const struct wmi_pdev_radar_ev *ev;
+	struct ath11k *ar;
+	int ret;
+
+	tb = ath11k_wmi_tlv_parse_alloc(ab, evt_buf, len, GFP_ATOMIC);
+	if (IS_ERR(tb)) {
+		ret = PTR_ERR(tb);
+		ath11k_warn(ab, "failed to parse tlv: %d\n", ret);
+		return;
+	}
+
+	ev = tb[WMI_TAG_PDEV_DFS_RADAR_DETECTION_EVENT];
+
+	if (!ev) {
+		ath11k_warn(ab, "failed to fetch pdev dfs radar detected ev");
+		kfree(tb);
+		return;
+	}
+
+	ath11k_dbg(ab, ATH11K_DBG_WMI,
+		   "pdev dfs radar detected on pdev %d, detection mode %d, chan freq %d, chan_width %d, detector id %d, seg id %d, timestamp %d, chirp %d, freq offset %d, sidx %d",
+		   ev->pdev_id, ev->detection_mode, ev->chan_freq, ev->chan_width,
+		   ev->detector_id, ev->segment_id, ev->timestamp, ev->is_chirp,
+		   ev->freq_offset, ev->sidx);
+
+	ar = ath11k_get_ar_by_pdev_id(ab, ev->pdev_id);
+
+	if (!ar) {
+		ath11k_warn(ab, "radar detected in invalid pdev %d\n",
+			    ev->pdev_id);
+		goto exit;
+	}
+
+	if (ar->rx_channel && ar->rx_channel->center_freq != (ev->chan_freq
+	    - ev->freq_offset)) {
+		ath11k_warn(ab, "Radar detected in non-operating channel");
+		goto exit;
+	}
+
+	ath11k_dbg(ar->ab, ATH11K_DBG_REG, "Radar Detected in pdev %d\n",
+		   ev->pdev_id);
+
+	ieee80211_radar_detected(ar->hw);
+
+exit:
+	kfree(tb);
+}
 static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb)
 {
 	struct wmi_cmd_hdr *cmd_hdr;
@@ -5858,6 +5911,9 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb)
 		ath11k_dbg(ab, ATH11K_DBG_WMI,
 			   "ignoring unsupported event 0x%x\n", id);
 		break;
+	case WMI_PDEV_DFS_RADAR_DETECTION_EVENTID:
+		ath11k_wmi_pdev_dfs_radar_detected_event(ab, data, len);
+		break;
 	/* TODO: Add remaining events */
 	default:
 		ath11k_warn(ab, "Unknown eventid: 0x%x\n", id);
diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h
index 5d20f57..d640cdf 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.h
+++ b/drivers/net/wireless/ath/ath11k/wmi.h
@@ -4557,6 +4557,19 @@ struct wmi_pdev_csa_switch_ev {
 	u32 num_vdevs;
 } __packed;
 
+struct wmi_pdev_radar_ev {
+	u32 pdev_id;
+	u32 detection_mode;
+	u32 chan_freq;
+	u32 chan_width;
+	u32 detector_id;
+	u32 segment_id;
+	u32 timestamp;
+	u32 is_chirp;
+	s32 freq_offset;
+	s32 sidx;
+} __packed;
+
 enum wlan_phymode {
 	WLAN_PHYMODE_AUTO             = 0,
 	WLAN_PHYMODE_11A              = 1,
-- 
2.7.4


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] ath11k: Initialize and enable dfs radar detection
  2019-05-14  4:41 [PATCH 0/3] ATH11K DFS Support Sriram R
  2019-05-14  4:41 ` [PATCH 1/3] ath11k: Process radar detected event Sriram R
@ 2019-05-14  4:41 ` Sriram R
  2019-05-14  4:41 ` [PATCH 3/3] ath11k: Add dfs debug and test interface Sriram R
  2 siblings, 0 replies; 5+ messages in thread
From: Sriram R @ 2019-05-14  4:41 UTC (permalink / raw)
  To: ath11k; +Cc: Sriram R

IPQ8074 firmware supports radar detection offload, which
enables complete radar detection algorithm to be offloaded to firmware.
Initialize dfs support by adding supported radar detect
widths and introduce the CAC_RUNNING flag to be used
when mac80211 triggers cac for the dfs channel.
This flag is used to check and drop any
rx packets if received during the CAC period.

Signed-off-by: Sriram R <srirrama@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/core.h  |  1 +
 drivers/net/wireless/ath/ath11k/dp_rx.c | 20 +++++++++---
 drivers/net/wireless/ath/ath11k/mac.c   | 54 +++++++++++++++++++++++++++++----
 drivers/net/wireless/ath/ath11k/wmi.c   |  8 ++---
 drivers/net/wireless/ath/ath11k/wmi.h   |  1 +
 5 files changed, 70 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index c8c1cd6..7b98649 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -438,6 +438,7 @@ struct ath11k {
 	struct {
 		struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
 	} mac;
+	unsigned long dev_flags;
 	unsigned int filter_flags;
 	unsigned long monitor_flags;
 	u32 min_tx_power;
diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c
index 0796f3b..323b021 100644
--- a/drivers/net/wireless/ath/ath11k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
@@ -1779,10 +1779,6 @@ static void ath11k_dp_rx_process_amsdu(struct ath11k *ar,
 	if (first_mpdu)
 		ath11k_dp_rx_h_ppdu(ar, rx_desc, rx_status);
 
-	/* TODO: Check if we need to drop frames in certain cases something
-	 * like while in the middle of CAC.
-	 */
-
 	ath11k_dp_rx_h_mpdu(ar, amsdu_list, rx_desc, rx_status);
 }
 
@@ -2039,6 +2035,11 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int mac_id,
 		goto rcu_unlock;
 	}
 
+	if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) {
+		__skb_queue_purge(&msdu_list);
+		goto rcu_unlock;
+	}
+
 	while (!skb_queue_empty(&msdu_list)) {
 		__skb_queue_head_init(&amsdu_list);
 		ret = ath11k_dp_rx_retrieve_amsdu(ar, &msdu_list, &amsdu_list);
@@ -2536,6 +2537,11 @@ ath11k_dp_process_rx_err_buf(struct ath11k *ar, struct napi_struct *napi,
 		goto exit;
 	}
 
+	if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) {
+		dev_kfree_skb_any(msdu);
+		goto exit;
+	}
+
 	rx_desc = msdu->data;
 	msdu_len = ath11k_dp_rx_h_msdu_start_msdu_len(rx_desc);
 	skb_put(msdu, HAL_RX_DESC_SIZE + msdu_len);
@@ -2956,6 +2962,12 @@ int ath11k_dp_rx_process_wbm_err(struct ath11k_base *ab,
 		}
 
 		ar = ab->pdevs[i].ar;
+
+		if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) {
+			__skb_queue_purge(&msdu_list[i]);
+			continue;
+		}
+
 		while ((msdu = __skb_dequeue(&msdu_list[i])) != NULL)
 			ath11k_dp_rx_wbm_err(ar, napi, msdu, &msdu_list[i]);
 	}
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index dc2733c..bb9bf61 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -3351,6 +3351,13 @@ static int ath11k_start(struct ieee80211_hw *hw)
 		goto err;
 	}
 
+	ret = ath11k_wmi_send_dfs_phyerr_offload_enable_cmd(ar, pdev->pdev_id);
+	if (ret) {
+		ath11k_err(ab, "failed to offload radar detection: %d\n",
+			   ret);
+		goto err;
+	}
+
 	ret = ath11k_dp_htt_h2t_ppdu_stats_req(ar, HTT_PPDU_STATS_TAG_DEFAULT);
 	if (ret) {
 		ath11k_err(ab, "failed to req ppdu stats: %d\n", ret);
@@ -3388,6 +3395,7 @@ static void ath11k_stop(struct ieee80211_hw *hw)
 	ath11k_drain_tx(ar);
 
 	mutex_lock(&ar->conf_mutex);
+	clear_bit(ATH11K_CAC_RUNNING, &ar->dev_flags);
 	ar->state = ATH11K_STATE_OFF;
 	mutex_unlock(&ar->conf_mutex);
 
@@ -3822,8 +3830,6 @@ static int ath11k_mac_op_add_chanctx(struct ieee80211_hw *hw,
 	ar->rx_channel = ctx->def.chan;
 	spin_unlock_bh(&ar->data_lock);
 
-	/* TODO: CAC */
-
 	mutex_unlock(&ar->conf_mutex);
 
 	return 0;
@@ -3848,8 +3854,6 @@ static void ath11k_mac_op_remove_chanctx(struct ieee80211_hw *hw,
 	ar->rx_channel = NULL;
 	spin_unlock_bh(&ar->data_lock);
 
-	/* TODO: CAC */
-
 	mutex_unlock(&ar->conf_mutex);
 }
 
@@ -3907,9 +3911,25 @@ ath11k_mac_vdev_start_restart(struct ath11k_vif *arvif,
 		arg.channel.chan_radar =
 			!!(chandef->chan->flags & IEEE80211_CHAN_RADAR);
 
+		arg.channel.passive = arg.channel.chan_radar;
+
+		spin_lock_bh(&ab->data_lock);
+
+		/* Use the new reg info if available */
+		if (ar->ab->new_regd[ar->pdev_idx])
+			arg.regdomain =
+				ar->ab->new_regd[ar->pdev_idx]->dfs_region;
+		else
+			arg.regdomain =
+				ar->ab->default_regd[ar->pdev_idx]->dfs_region;
+
+		spin_unlock_bh(&ab->data_lock);
+
 		/* TODO: Notify if secondary 80Mhz also needs radar detection */
 	}
 
+	arg.channel.passive |= !!(chandef->chan->flags & IEEE80211_CHAN_NO_IR);
+
 	ath11k_dbg(ab, ATH11K_DBG_MAC,
 		   "mac vdev %d start center_freq %d phymode %s\n",
 		   arg.vdev_id, arg.channel.freq,
@@ -3931,7 +3951,21 @@ ath11k_mac_vdev_start_restart(struct ath11k_vif *arvif,
 
 	ar->num_started_vdevs++;
 
-	/* TODO: Recalc radar */
+	/* Enable CAC Flag in the driver by checking the channel DFS cac time,
+	 * i.e dfs_cac_ms value which will be valid only for radar channels
+	 * and state as NL80211_DFS_USABLE which indicates CAC needs to be
+	 * done before channel usage. This flags is used to drop rx packets.
+	 * during CAC.
+	 */
+	/* TODO Set the flag for other interface types as required */
+	if (arvif->vdev_type == WMI_VDEV_TYPE_AP &&
+	    chandef->chan->dfs_cac_ms &&
+	    chandef->chan->dfs_state == NL80211_DFS_USABLE) {
+		set_bit(ATH11K_CAC_RUNNING, &ar->dev_flags);
+		ath11k_dbg(ab, ATH11K_DBG_MAC,
+			   "CAC Started in chan_freq %d for vdev %d\n",
+			   arg.channel.freq, arg.vdev_id);
+	}
 
 	return 0;
 }
@@ -3970,7 +4004,11 @@ static int ath11k_mac_vdev_stop(struct ath11k_vif *arvif)
 
 	ar->num_started_vdevs--;
 
-	/* TODO: Recalc radar */
+	if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) {
+		clear_bit(ATH11K_CAC_RUNNING, &ar->dev_flags);
+		ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "CAC Stopped for vdev %d\n",
+			   arvif->vdev_id);
+	}
 
 	return 0;
 err:
@@ -4797,6 +4835,10 @@ static const struct ieee80211_iface_combination ath11k_if_comb[] = {
 		.max_interfaces = 16,
 		.num_different_channels = 1,
 		.beacon_int_infra_match = true,
+		.radar_detect_widths =	BIT(NL80211_CHAN_WIDTH_20_NOHT) |
+					BIT(NL80211_CHAN_WIDTH_20) |
+					BIT(NL80211_CHAN_WIDTH_40) |
+					BIT(NL80211_CHAN_WIDTH_80),
 	},
 };
 
diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index 434508f..8364e44 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -788,6 +788,7 @@ int ath11k_wmi_vdev_start(struct ath11k *ar, struct wmi_vdev_start_req_arg *arg,
 	cmd->preferred_rx_streams = arg->pref_rx_streams;
 	cmd->preferred_tx_streams = arg->pref_tx_streams;
 	cmd->cac_duration_ms = arg->cac_duration_ms;
+	cmd->regdomain = arg->regdomain;
 	cmd->he_ops = arg->he_ops;
 
 	if (!restart) {
@@ -5151,10 +5152,9 @@ void ath11k_mgmt_rx_event(struct ath11k_base *ab, struct sk_buff *skb)
 		goto exit;
 	}
 
-	/* TODO: Check CAC running state */
-
-	if (rx_ev.status & (WMI_RX_STATUS_ERR_DECRYPT |
-	    WMI_RX_STATUS_ERR_KEY_CACHE_MISS | WMI_RX_STATUS_ERR_CRC)) {
+	if ((test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) ||
+	    (rx_ev.status & (WMI_RX_STATUS_ERR_DECRYPT |
+	    WMI_RX_STATUS_ERR_KEY_CACHE_MISS | WMI_RX_STATUS_ERR_CRC))) {
 		dev_kfree_skb(skb);
 		goto exit;
 	}
diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h
index d640cdf..bd7e88a 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.h
+++ b/drivers/net/wireless/ath/ath11k/wmi.h
@@ -3134,6 +3134,7 @@ struct wmi_vdev_start_req_arg {
 	bool pmf_enabled;
 	u32 he_ops;
 	u32 cac_duration_ms;
+	u32 regdomain;
 	u32 pref_rx_streams;
 	u32 pref_tx_streams;
 	u32 num_noa_descriptors;
-- 
2.7.4


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] ath11k: Add dfs debug and test interface
  2019-05-14  4:41 [PATCH 0/3] ATH11K DFS Support Sriram R
  2019-05-14  4:41 ` [PATCH 1/3] ath11k: Process radar detected event Sriram R
  2019-05-14  4:41 ` [PATCH 2/3] ath11k: Initialize and enable dfs radar detection Sriram R
@ 2019-05-14  4:41 ` Sriram R
  2 siblings, 0 replies; 5+ messages in thread
From: Sriram R @ 2019-05-14  4:41 UTC (permalink / raw)
  To: ath11k; +Cc: Sriram R

Add support to simulate radar to validate DFS implementation of NOL, NOP in firmware,
host and CSA offload. This is done with the help of FW Unit test commands.
Also block_radar_events is used to validate the firmware/host DFS implementation
and behavior when the detected radar is not indicated to mac80211.

Signed-off-by: Sriram R <srirrama@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/core.h  |   1 +
 drivers/net/wireless/ath/ath11k/debug.c |  28 +++++++++
 drivers/net/wireless/ath/ath11k/wmi.c   | 104 +++++++++++++++++++++++++++++++-
 drivers/net/wireless/ath/ath11k/wmi.h   |  28 +++++++++
 4 files changed, 159 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index 7b98649..148c9a4 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -515,6 +515,7 @@ struct ath11k {
 #ifdef CONFIG_ATH11K_DEBUGFS
 	struct ath11k_debug debug;
 #endif
+	bool dfs_block_radar_events;
 };
 
 struct ath11k_band_cap {
diff --git a/drivers/net/wireless/ath/ath11k/debug.c b/drivers/net/wireless/ath/ath11k/debug.c
index b6e1893..4580c15 100644
--- a/drivers/net/wireless/ath/ath11k/debug.c
+++ b/drivers/net/wireless/ath/ath11k/debug.c
@@ -1099,12 +1099,31 @@ static ssize_t ath11k_read_pktlog_filter(struct file *file,
 	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
 }
 
+static ssize_t ath11k_write_simulate_radar(struct file *file,
+					   const char __user *user_buf,
+					   size_t count, loff_t *ppos)
+{
+	struct ath11k *ar = file->private_data;
+	int ret;
+
+	ret = ath11k_wmi_simulate_radar(ar);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static const struct file_operations fops_pktlog_filter = {
 	.read = ath11k_read_pktlog_filter,
 	.write = ath11k_write_pktlog_filter,
 	.open = simple_open
 };
 
+static const struct file_operations fops_simulate_radar = {
+	.write = ath11k_write_simulate_radar,
+	.open = simple_open
+};
+
 int ath11k_debug_register(struct ath11k *ar)
 {
 	struct ath11k_base *ab = ar->ab;
@@ -1140,6 +1159,15 @@ int ath11k_debug_register(struct ath11k *ar)
 			    ar->debug.debugfs_pdev, ar,
 			    &fops_pktlog_filter);
 
+	if (ar->hw->wiphy->bands[NL80211_BAND_5GHZ]) {
+		debugfs_create_file("dfs_simulate_radar", 0200,
+				    ar->debug.debugfs_pdev, ar,
+				    &fops_simulate_radar);
+		debugfs_create_bool("dfs_block_radar_events", 0200,
+				    ar->debug.debugfs_pdev,
+				    &ar->dfs_block_radar_events);
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index 8364e44..4f2ac21 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -5815,10 +5815,13 @@ ath11k_wmi_pdev_dfs_radar_detected_event(struct ath11k_base *ab,
 		goto exit;
 	}
 
-	ath11k_dbg(ar->ab, ATH11K_DBG_REG, "Radar Detected in pdev %d\n",
+	ath11k_dbg(ar->ab, ATH11K_DBG_REG, "DFS Radar Detected in pdev %d\n",
 		   ev->pdev_id);
 
-	ieee80211_radar_detected(ar->hw);
+	if (ar->dfs_block_radar_events)
+		ath11k_info(ab, "DFS Radar detected, but ignored as requested\n");
+	else
+		ieee80211_radar_detected(ar->hw);
 
 exit:
 	kfree(tb);
@@ -5960,6 +5963,103 @@ static int ath11k_connect_pdev_htc_service(struct ath11k_base *sc,
 	return 0;
 }
 
+static int
+ath11k_wmi_send_unit_test_cmd(struct ath11k *ar,
+			      struct wmi_unit_test_cmd ut_cmd,
+			      u32 *test_args)
+{
+	struct ath11k_pdev_wmi *wmi = ar->wmi;
+	struct wmi_unit_test_cmd *cmd;
+	struct sk_buff *skb;
+	struct wmi_tlv *tlv;
+	void *ptr;
+	u32 *ut_cmd_args;
+	int buf_len, arg_len;
+	int ret;
+	int i;
+
+	arg_len = (sizeof(u32) * ut_cmd.num_args);
+	buf_len = sizeof(ut_cmd) + arg_len + TLV_HDR_SIZE;
+
+	skb = ath11k_wmi_alloc_skb(wmi->wmi_sc, buf_len);
+	if (!skb)
+		return -ENOMEM;
+
+	cmd = (struct wmi_unit_test_cmd *)skb->data;
+	cmd->tlv_header =
+		FIELD_PREP(WMI_TLV_TAG,
+			   WMI_TAG_UNIT_TEST_CMD) |
+		FIELD_PREP(WMI_TLV_LEN, sizeof(ut_cmd) - TLV_HDR_SIZE);
+
+	cmd->vdev_id = ut_cmd.vdev_id;
+	cmd->module_id = ut_cmd.module_id;
+	cmd->num_args = ut_cmd.num_args;
+	cmd->diag_token = ut_cmd.diag_token;
+
+	ptr = skb->data + sizeof(ut_cmd);
+
+	tlv = ptr;
+	tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_UINT32) |
+		      FIELD_PREP(WMI_TLV_LEN, arg_len);
+
+	ptr += TLV_HDR_SIZE;
+
+	ut_cmd_args = ptr;
+	for (i = 0; i < ut_cmd.num_args; i++)
+		ut_cmd_args[i] = test_args[i];
+
+	ret = ath11k_wmi_cmd_send(wmi, skb,
+				  WMI_UNIT_TEST_CMDID);
+
+	if (ret) {
+		ath11k_warn(ar->ab,
+			    "failed to send WMI_UNIT_TEST CMD :%d\n",
+			    ret);
+		dev_kfree_skb(skb);
+	}
+	ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
+		   "WMI unit test : module %d vdev %d n_args %d token %d\n",
+		   cmd->module_id, cmd->vdev_id, cmd->num_args,
+		   cmd->diag_token);
+
+	return ret;
+}
+
+int ath11k_wmi_simulate_radar(struct ath11k *ar)
+{
+	struct ath11k_vif *arvif;
+	u32 dfs_args[DFS_MAX_TEST_ARGS];
+	struct wmi_unit_test_cmd wmi_ut;
+	bool arvif_found = false;
+
+	list_for_each_entry(arvif, &ar->arvifs, list) {
+		if (arvif->is_started && arvif->vdev_type == WMI_VDEV_TYPE_AP) {
+			arvif_found = true;
+			break;
+		}
+	}
+
+	if (!arvif_found)
+		return -EINVAL;
+
+	dfs_args[DFS_TEST_CMDID] = 0;
+	dfs_args[DFS_TEST_PDEV_ID] = ar->pdev->pdev_id;
+	/* Currently we could pass segment_id(b0 - b1), chirp(b2)
+	 * freq offset (b3 - b10) to unit test. For simulation
+	 * purpose this can be set to 0 which is valid.
+	 */
+	dfs_args[DFS_TEST_RADAR_PARAM] = 0;
+
+	wmi_ut.vdev_id = arvif->vdev_id;
+	wmi_ut.module_id = DFS_UNIT_TEST_MODULE;
+	wmi_ut.num_args = DFS_MAX_TEST_ARGS;
+	wmi_ut.diag_token = DFS_UNIT_TEST_TOKEN;
+
+	ath11k_dbg(ar->ab, ATH11K_DBG_REG, "Triggering Radar Simulation\n");
+
+	return ath11k_wmi_send_unit_test_cmd(ar, wmi_ut, dfs_args);
+}
+
 int ath11k_wmi_connect(struct ath11k_base *sc)
 {
 	u32 i;
diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h
index bd7e88a..e972154 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.h
+++ b/drivers/net/wireless/ath/ath11k/wmi.h
@@ -4113,6 +4113,32 @@ struct wmi_pktlog_disable_cmd {
 	u32 pdev_id;
 } __packed;
 
+#define DFS_PHYERR_UNIT_TEST_CMD 0
+#define DFS_UNIT_TEST_MODULE	0x2b
+#define DFS_UNIT_TEST_TOKEN	0xAA
+
+enum dfs_test_args_idx {
+	DFS_TEST_CMDID = 0,
+	DFS_TEST_PDEV_ID,
+	DFS_TEST_RADAR_PARAM,
+	DFS_MAX_TEST_ARGS,
+};
+
+struct wmi_dfs_unit_test_arg {
+	u32 cmd_id;
+	u32 pdev_id;
+	u32 radar_param;
+};
+
+struct wmi_unit_test_cmd {
+	u32 tlv_header;
+	u32 vdev_id;
+	u32 module_id;
+	u32 num_args;
+	u32 diag_token;
+	/* Followed by test args*/
+} __packed;
+
 #define MAX_SUPPORTED_RATES 128
 
 #define WMI_PEER_AUTH           0x00000001
@@ -4199,6 +4225,7 @@ enum wmi_vdev_start_resp_status_code {
 	WMI_VDEV_START_RESPONSE_DFS_VIOLATION = 3,
 };
 
+;
 enum cc_setting_code {
 	REG_SET_CC_STATUS_PASS = 0,
 	REG_CURRENT_ALPHA2_NOT_FOUND = 1,
@@ -5204,4 +5231,5 @@ size_t ath11k_wmi_fw_stats_num_vdevs(struct list_head *head);
 void ath11k_wmi_fw_stats_fill(struct ath11k *ar,
 			      struct ath11k_fw_stats *fw_stats, u32 stats_id,
 			      char *buf);
+int ath11k_wmi_simulate_radar(struct ath11k *ar);
 #endif
-- 
2.7.4


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] ath11k: Process radar detected event
  2019-05-14  4:41 ` [PATCH 1/3] ath11k: Process radar detected event Sriram R
@ 2019-05-20  8:25   ` Kalle Valo
  0 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2019-05-20  8:25 UTC (permalink / raw)
  To: Sriram R; +Cc: ath11k

Sriram R <srirrama@codeaurora.org> wrote:

> Add support for processing radar detected event
> coming from the firmware. The detected radar
> is indicated to mac80211 after checking the
> validity of detection.
> 
> Signed-off-by: Sriram R <srirrama@codeaurora.org>

3 patches applied to ath.git, thanks.

844193a286b5 ath11k: Process radar detected event
1256bb1040d9 ath11k: Initialize and enable dfs radar detection
83c457124fa5 ath11k: Add dfs debug and test interface

-- 
https://patchwork.kernel.org/patch/10942009/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-05-20  8:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-14  4:41 [PATCH 0/3] ATH11K DFS Support Sriram R
2019-05-14  4:41 ` [PATCH 1/3] ath11k: Process radar detected event Sriram R
2019-05-20  8:25   ` Kalle Valo
2019-05-14  4:41 ` [PATCH 2/3] ath11k: Initialize and enable dfs radar detection Sriram R
2019-05-14  4:41 ` [PATCH 3/3] ath11k: Add dfs debug and test interface Sriram R

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.