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
diff --git a/os_if/linux/scan/src/wlan_cfg80211_scan.c b/os_if/linux/scan/src/wlan_cfg80211_scan.c
index 8f6d757..9ce0d0c 100644
--- a/os_if/linux/scan/src/wlan_cfg80211_scan.c
+++ b/os_if/linux/scan/src/wlan_cfg80211_scan.c
@@ -903,7 +903,7 @@
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 @@
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 @@
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 @@
* 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:
diff --git a/umac/scan/dispatcher/inc/wlan_scan_utils_api.h b/umac/scan/dispatcher/inc/wlan_scan_utils_api.h
index 394e4fb..2ff72e8 100644
--- a/umac/scan/dispatcher/inc/wlan_scan_utils_api.h
+++ b/umac/scan/dispatcher/inc/wlan_scan_utils_api.h
@@ -1467,4 +1467,16 @@
* 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
diff --git a/umac/scan/dispatcher/src/wlan_scan_utils_api.c b/umac/scan/dispatcher/src/wlan_scan_utils_api.c
index 4e129f1..024d8ce 100644
--- a/umac/scan/dispatcher/src/wlan_scan_utils_api.c
+++ b/umac/scan/dispatcher/src/wlan_scan_utils_api.c
@@ -987,3 +987,22 @@
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;
+}
+