Explorar o código

qcacmn: Add an API to check if scan is completed

Add a new scan util API to check if scan is completed and
if scan is success.

Change-Id: Id60056b999a7ec23df3d3458d4498d547f6ec4d9
CRs-Fixed: 2248972
Sandeep Puligilla %!s(int64=7) %!d(string=hai) anos
pai
achega
f57464c549

+ 4 - 28
os_if/linux/scan/src/wlan_cfg80211_scan.c

@@ -903,7 +903,7 @@ static void wlan_cfg80211_scan_done_callback(
 					void *args)
 {
 	struct cfg80211_scan_request *req = NULL;
-	bool aborted = false;
+	bool success = false;
 	uint32_t scan_id = event->scan_id;
 	uint8_t source = NL_SCAN;
 	struct wlan_objmgr_pdev *pdev;
@@ -911,9 +911,7 @@ static void wlan_cfg80211_scan_done_callback(
 	struct net_device *netdev = NULL;
 	QDF_STATUS status;
 
-	if ((event->type != SCAN_EVENT_TYPE_COMPLETED) &&
-	    (event->type != SCAN_EVENT_TYPE_DEQUEUED) &&
-	    (event->type != SCAN_EVENT_TYPE_START_FAILED))
+	if (!util_is_scan_completed(event, &success))
 		return;
 
 	cfg80211_info("scan ID = %d vdev id = %d, event type %s(%d) reason = %s(%d)",
@@ -923,28 +921,6 @@ static void wlan_cfg80211_scan_done_callback(
 		util_scan_get_ev_reason_name(event->reason),
 		event->reason);
 
-	/*
-	 * cfg80211_scan_done informing NL80211 about completion
-	 * of scanning
-	 */
-	if ((event->type == SCAN_EVENT_TYPE_COMPLETED) &&
-	    ((event->reason == SCAN_REASON_CANCELLED) ||
-	     (event->reason == SCAN_REASON_TIMEDOUT) ||
-	     (event->reason == SCAN_REASON_INTERNAL_FAILURE))) {
-		aborted = true;
-	} else if ((event->type == SCAN_EVENT_TYPE_COMPLETED) &&
-		   (event->reason == SCAN_REASON_COMPLETED))
-		aborted = false;
-	else if ((event->type == SCAN_EVENT_TYPE_DEQUEUED) &&
-		 (event->reason == SCAN_REASON_CANCELLED))
-		aborted = true;
-	else if ((event->type == SCAN_EVENT_TYPE_START_FAILED) &&
-		 (event->reason == SCAN_REASON_COMPLETED))
-		aborted = true;
-	else
-		/* cfg80211 is not interested on all other scan events */
-		return;
-
 	pdev = wlan_vdev_get_pdev(vdev);
 	status = wlan_scan_request_dequeue(
 			pdev, scan_id, &req, &source, &netdev);
@@ -975,9 +951,9 @@ static void wlan_cfg80211_scan_done_callback(
 	 * scan done event will be posted
 	 */
 	if (NL_SCAN == source)
-		wlan_cfg80211_scan_done(netdev, req, aborted);
+		wlan_cfg80211_scan_done(netdev, req, !success);
 	else
-		wlan_vendor_scan_callback(req, aborted);
+		wlan_vendor_scan_callback(req, !success);
 
 	wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID);
 allow_suspend:

+ 12 - 0
umac/scan/dispatcher/inc/wlan_scan_utils_api.h

@@ -1467,4 +1467,16 @@ enum wlan_band util_scan_scm_chan_to_band(uint32_t chan);
  * Return: Band information as per frequency
  */
 enum wlan_band util_scan_scm_freq_to_band(uint16_t freq);
+
+/**
+ * util_is_scan_completed() - function to get scan complete status
+ * @event: scan event
+ * @success: true if scan complete success, false otherwise
+ *
+ * API, function to get the scan result
+ *
+ * Return: true if scan complete, false otherwise
+ */
+bool util_is_scan_completed(struct scan_event *event, bool *success);
+
 #endif

+ 19 - 0
umac/scan/dispatcher/src/wlan_scan_utils_api.c

@@ -987,3 +987,22 @@ util_scan_entry_update_mlme_info(struct wlan_objmgr_pdev *pdev,
 
 	return scm_update_scan_mlme_info(pdev, scan_entry);
 }
+
+bool util_is_scan_completed(struct scan_event *event, bool *success)
+{
+	if ((event->type == SCAN_EVENT_TYPE_COMPLETED) ||
+	    (event->type == SCAN_EVENT_TYPE_DEQUEUED) ||
+	    (event->type == SCAN_EVENT_TYPE_START_FAILED)) {
+		if ((event->type == SCAN_EVENT_TYPE_COMPLETED) &&
+		    (event->reason == SCAN_REASON_COMPLETED))
+			*success = true;
+		else
+			*success = false;
+
+		return true;
+	}
+
+	*success = false;
+	return false;
+}
+