Add support to abort vendor scan

This commit enhances the existing implementation of abort scan to also
abort concurrent active vendor scans. This is achieved by passing the
the scan_cookie to the driver interface with the intention to abort
the specific scan request. This scan_cookie is returned from the driver
interface when the scan request is scheduled.

This scan_cookie is 0 if the scan is triggered through the upstream
cfg80211 interface. Thus, the scan_cookie is used to determine whether
to abort the cfg80211 or vendor scan request.

Also, the previous implementation of relying on scan_work/p2p_scan_work
for the active work to trigger the abort scan is enhanced to check for
the started state of either of these work operations. This should also
help to abort the concurrent active scan/p2p-scan operations.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Sunil Dutt 2016-11-30 10:09:38 +05:30 committed by Jouni Malinen
parent eeb34a432e
commit bf88401d23
3 changed files with 29 additions and 8 deletions

View file

@ -308,6 +308,8 @@ static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
} }
ret = wpa_drv_scan(wpa_s, params); ret = wpa_drv_scan(wpa_s, params);
if (ret == 0)
wpa_s->curr_scan_cookie = params->scan_cookie;
wpa_scan_free_params(params); wpa_scan_free_params(params);
work->ctx = NULL; work->ctx = NULL;
if (ret) { if (ret) {

View file

@ -176,6 +176,17 @@ static void wpas_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
params->only_new_results = 1; params->only_new_results = 1;
} }
ret = wpa_drv_scan(wpa_s, params); ret = wpa_drv_scan(wpa_s, params);
/*
* Store the obtained vendor scan cookie (if any) in wpa_s context.
* The current design is to allow only one scan request on each
* interface, hence having this scan cookie stored in wpa_s context is
* fine for now.
*
* Revisit this logic if concurrent scan operations per interface
* is supported.
*/
if (ret == 0)
wpa_s->curr_scan_cookie = params->scan_cookie;
wpa_scan_free_params(params); wpa_scan_free_params(params);
work->ctx = NULL; work->ctx = NULL;
if (ret) { if (ret) {
@ -2625,18 +2636,20 @@ int wpas_mac_addr_rand_scan_set(struct wpa_supplicant *wpa_s,
int wpas_abort_ongoing_scan(struct wpa_supplicant *wpa_s) int wpas_abort_ongoing_scan(struct wpa_supplicant *wpa_s)
{ {
int scan_work = !!wpa_s->scan_work; struct wpa_radio_work *work;
struct wpa_radio *radio = wpa_s->radio;
#ifdef CONFIG_P2P dl_list_for_each(work, &radio->work, struct wpa_radio_work, list) {
scan_work |= !!wpa_s->p2p_scan_work; if (work->wpa_s != wpa_s || !work->started ||
#endif /* CONFIG_P2P */ (os_strcmp(work->type, "scan") != 0 &&
os_strcmp(work->type, "p2p-scan") != 0))
if (scan_work && wpa_s->own_scan_running) { continue;
wpa_dbg(wpa_s, MSG_DEBUG, "Abort an ongoing scan"); wpa_dbg(wpa_s, MSG_DEBUG, "Abort an ongoing scan");
return wpa_drv_abort_scan(wpa_s, 0); return wpa_drv_abort_scan(wpa_s, wpa_s->curr_scan_cookie);
} }
return 0; wpa_dbg(wpa_s, MSG_DEBUG, "No ongoing scan/p2p-scan found to abort");
return -1;
} }

View file

@ -652,6 +652,12 @@ struct wpa_supplicant {
int normal_scans; /* normal scans run before sched_scan */ int normal_scans; /* normal scans run before sched_scan */
int scan_for_connection; /* whether the scan request was triggered for int scan_for_connection; /* whether the scan request was triggered for
* finding a connection */ * finding a connection */
/*
* A unique cookie representing the vendor scan request. This cookie is
* returned from the driver interface. 0 indicates that there is no
* pending vendor scan request.
*/
u64 curr_scan_cookie;
#define MAX_SCAN_ID 16 #define MAX_SCAN_ID 16
int scan_id[MAX_SCAN_ID]; int scan_id[MAX_SCAN_ID];
unsigned int scan_id_count; unsigned int scan_id_count;