Browse Source

qcacmn: Split DFS radar action

The process radar indication is huge making it difficult to read and debug.
It can be modularized into 3 high level functionalities based on whether
HW mode switch action is in progress or not, whether the radar found
detector id or segment id is the same as agile detector or segment and if
none of these conditions satisfy then the radar might be on the current
operating channel.

Classify DFS radar action based on HW mode switch status,
detector id and preCAC status into 3 sub-functions.
i)  dfs_radar_action_when_hw_mode_switch_in_progress()
ii) dfs_process_radar_ind_on_agile_chan()
iii) dfs_process_radar_ind_on_cur_chan()

Change-Id: I7d862eb08d6373fabaedda4b77deb966466f6b1a
CRs-Fixed: 2737273
Vignesh U 4 years ago
parent
commit
ccd366019b

+ 12 - 0
umac/dfs/core/src/dfs_process_radar_found_ind.h

@@ -137,6 +137,18 @@ void dfs_process_radar_found_indication(struct wlan_dfs *dfs,
 QDF_STATUS dfs_process_radar_ind(struct wlan_dfs *dfs,
 QDF_STATUS dfs_process_radar_ind(struct wlan_dfs *dfs,
 		struct radar_found_info *radar_found);
 		struct radar_found_info *radar_found);
 
 
+/**
+ * dfs_process_radar_ind_on_home_chan() - Process radar indication event on
+ * home channel.
+ * @dfs: Pointer to wlan_dfs structure.
+ * @radar_found: Pointer to radar_found_info structure.
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+dfs_process_radar_ind_on_home_chan(struct wlan_dfs *dfs,
+				   struct radar_found_info *radar_found);
+
 /**
 /**
  * dfs_radarfound_action_generic() - The dfs action on radar detection by host
  * dfs_radarfound_action_generic() - The dfs action on radar detection by host
  * for domains other than FCC.
  * for domains other than FCC.

+ 21 - 0
umac/dfs/core/src/dfs_zero_cac.h

@@ -1384,4 +1384,25 @@ static inline void dfs_stop_agile_rcac_timer(struct wlan_dfs *dfs)
 }
 }
 #endif /* QCA_SUPPORT_ADFS_RCAC */
 #endif /* QCA_SUPPORT_ADFS_RCAC */
 
 
+#if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) || \
+	defined(QCA_SUPPORT_ADFS_RCAC)
+/**
+ * dfs_process_radar_ind_on_agile_chan() - Process radar indication event on
+ * agile channel.
+ * @dfs: Pointer to wlan_dfs structure.
+ * @radar_found: Pointer to radar_found_info structure.
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+dfs_process_radar_ind_on_agile_chan(struct wlan_dfs *dfs,
+				    struct radar_found_info *radar_found);
+#else
+static inline QDF_STATUS
+dfs_process_radar_ind_on_agile_chan(struct wlan_dfs *dfs,
+				    struct radar_found_info *radar_found)
+{
+	return QDF_STATUS_E_FAILURE;
+}
+#endif
 #endif /* _DFS_ZERO_CAC_H_ */
 #endif /* _DFS_ZERO_CAC_H_ */

+ 73 - 27
umac/dfs/core/src/misc/dfs_process_radar_found_ind.c

@@ -1032,12 +1032,12 @@ dfs_radar_action_for_hw_mode_switch(struct wlan_dfs *dfs,
 	 * If in progress, defer the processing of radar event received till
 	 * If in progress, defer the processing of radar event received till
 	 * the mode switch is completed.
 	 * the mode switch is completed.
 	 */
 	 */
-	if (dfs_is_hw_mode_switch_in_progress(dfs)) {
-		struct radar_found_info *radar_params = NULL;
 
 
-		radar_params = qdf_mem_malloc(sizeof(*radar_params));
-		if (!radar_params)
-			return QDF_STATUS_SUCCESS;
+	struct radar_found_info *radar_params = NULL;
+
+	radar_params = qdf_mem_malloc(sizeof(*radar_params));
+	if (!radar_params)
+		return QDF_STATUS_E_NOMEM;
 
 
 	/* If CAC timer is running, cancel it here rather than
 	/* If CAC timer is running, cancel it here rather than
 	 * after processing to avoid handling unnecessary CAC timeouts.
 	 * after processing to avoid handling unnecessary CAC timeouts.
@@ -1053,10 +1053,8 @@ dfs_radar_action_for_hw_mode_switch(struct wlan_dfs *dfs,
 	qdf_mem_copy(radar_params, radar_found, sizeof(*radar_params));
 	qdf_mem_copy(radar_params, radar_found, sizeof(*radar_params));
 	dfs->dfs_defer_params.radar_params = radar_params;
 	dfs->dfs_defer_params.radar_params = radar_params;
 	dfs->dfs_defer_params.is_radar_detected = true;
 	dfs->dfs_defer_params.is_radar_detected = true;
-	return QDF_STATUS_SUCCESS;
-	}
 
 
-	return QDF_STATUS_E_FAILURE;
+	return QDF_STATUS_SUCCESS;
 }
 }
 
 
 #ifdef CONFIG_CHAN_FREQ_API
 #ifdef CONFIG_CHAN_FREQ_API
@@ -1156,8 +1154,72 @@ dfs_send_nol_ie_and_rcsa(struct wlan_dfs *dfs,
 }
 }
 #endif /* QCA_DFS_RCSA_SUPPORT */
 #endif /* QCA_DFS_RCSA_SUPPORT */
 
 
-QDF_STATUS dfs_process_radar_ind(struct wlan_dfs *dfs,
-				 struct radar_found_info *radar_found)
+#if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) || \
+	defined(QCA_SUPPORT_ADFS_RCAC)
+/**
+ * dfs_is_radarsource_agile() - Indicates whether the radar event is received
+ * on the agile channel.
+ * @dfs: Pointer to wlan_dfs structure.
+ * @radar_found: Pointer to radar_found_info structure.
+ *
+ * Return: QDF_STATUS
+ */
+static
+bool dfs_is_radarsource_agile(struct wlan_dfs *dfs,
+			      struct radar_found_info *radar_found)
+{
+	bool is_radar_from_agile_dfs =
+	    (radar_found->detector_id == dfs_get_agile_detector_id(dfs));
+	bool is_radar_from_zero_wait_dfs =
+	    (dfs_is_precac_timer_running(dfs) &&
+	     (radar_found->segment_id == SEG_ID_SECONDARY));
+
+	return (is_radar_from_agile_dfs || is_radar_from_zero_wait_dfs);
+}
+#else
+static
+bool dfs_is_radarsource_agile(struct wlan_dfs *dfs,
+			      struct radar_found_info *radar_found)
+{
+	return false;
+}
+#endif
+
+QDF_STATUS
+dfs_process_radar_ind(struct wlan_dfs *dfs,
+		      struct radar_found_info *radar_found)
+{
+	QDF_STATUS status;
+
+	/* Acquire a lock to avoid initiating mode switch till radar
+	 * processing is completed.
+	 */
+	DFS_RADAR_MODE_SWITCH_LOCK(dfs);
+
+	if (utils_dfs_can_ignore_radar_event(dfs->dfs_pdev_obj)) {
+		DFS_RADAR_MODE_SWITCH_UNLOCK(dfs);
+		return QDF_STATUS_SUCCESS;
+	}
+
+	/* Before processing radar, check if HW mode switch is in progress.
+	 * If in progress, defer the processing of radar event received till
+	 * the mode switch is completed.
+	 */
+	if (dfs_is_hw_mode_switch_in_progress(dfs))
+		status = dfs_radar_action_for_hw_mode_switch(dfs, radar_found);
+	else if (dfs_is_radarsource_agile(dfs, radar_found))
+		status = dfs_process_radar_ind_on_agile_chan(dfs, radar_found);
+	else
+		status = dfs_process_radar_ind_on_home_chan(dfs, radar_found);
+
+	DFS_RADAR_MODE_SWITCH_UNLOCK(dfs);
+
+	return status;
+}
+
+QDF_STATUS
+dfs_process_radar_ind_on_home_chan(struct wlan_dfs *dfs,
+				   struct radar_found_info *radar_found)
 {
 {
 	bool wait_for_csa = false;
 	bool wait_for_csa = false;
 	uint16_t freq_list[NUM_CHANNELS_160MHZ];
 	uint16_t freq_list[NUM_CHANNELS_160MHZ];
@@ -1168,17 +1230,6 @@ QDF_STATUS dfs_process_radar_ind(struct wlan_dfs *dfs,
 	uint32_t radarfound_freq;
 	uint32_t radarfound_freq;
 	struct dfs_channel *dfs_curchan;
 	struct dfs_channel *dfs_curchan;
 
 
-	if (utils_dfs_can_ignore_radar_event(dfs->dfs_pdev_obj))
-		return QDF_STATUS_SUCCESS;
-	/* Acquire a lock to avoid initiating mode switch till radar
-	 * processing is completed.
-	 */
-	DFS_RADAR_MODE_SWITCH_LOCK(dfs);
-
-	if (dfs_radar_action_for_hw_mode_switch(dfs, radar_found)
-		== QDF_STATUS_SUCCESS)
-		goto exit;
-
 	dfs_curchan = dfs->dfs_curchan;
 	dfs_curchan = dfs->dfs_curchan;
 
 
 	if (!dfs_curchan) {
 	if (!dfs_curchan) {
@@ -1288,11 +1339,7 @@ QDF_STATUS dfs_process_radar_ind(struct wlan_dfs *dfs,
 				 nol_freq_list,
 				 nol_freq_list,
 				 num_channels,
 				 num_channels,
 				 &wait_for_csa);
 				 &wait_for_csa);
-	/* If radar is found on preCAC or Agile CAC, return here since
-	 * channel change is not required.
-	 */
-	if (radar_found->detector_id == dfs_get_agile_detector_id(dfs))
-		goto exit;
+
 	if (!dfs->dfs_is_offload_enabled &&
 	if (!dfs->dfs_is_offload_enabled &&
 	    dfs->is_radar_found_on_secondary_seg) {
 	    dfs->is_radar_found_on_secondary_seg) {
 		dfs_second_segment_radar_disable(dfs);
 		dfs_second_segment_radar_disable(dfs);
@@ -1332,7 +1379,6 @@ QDF_STATUS dfs_process_radar_ind(struct wlan_dfs *dfs,
 				   dfs->dfs_curchan->dfs_ch_flags);
 				   dfs->dfs_curchan->dfs_ch_flags);
 
 
 exit:
 exit:
-	DFS_RADAR_MODE_SWITCH_UNLOCK(dfs);
 	return status;
 	return status;
 }
 }
 #endif
 #endif