From patchwork Mon Feb 11 11:15:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arend van Spriel X-Patchwork-Id: 219576 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 62D542C02A4 for ; Mon, 11 Feb 2013 22:17:02 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2E5C29C2E5; Mon, 11 Feb 2013 06:16:46 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W5fgMskr6AlF; Mon, 11 Feb 2013 06:16:45 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 99A829C20B; Mon, 11 Feb 2013 06:16:14 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A54E99C1CB for ; Mon, 11 Feb 2013 06:16:12 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sJV0bXrXzt2L for ; Mon, 11 Feb 2013 06:16:07 -0500 (EST) Received: from mms3.broadcom.com (mms3.broadcom.com [216.31.210.19]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4FC469C1E3 for ; Mon, 11 Feb 2013 06:16:02 -0500 (EST) Received: from [10.9.208.57] by mms3.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Mon, 11 Feb 2013 03:10:14 -0800 X-Server-Uuid: B86B6450-0931-4310-942E-F00ED04CA7AF Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Mon, 11 Feb 2013 03:15:53 -0800 Received: from mail-sj1-12.sj.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.1.438.0; Mon, 11 Feb 2013 03:15:53 -0800 Received: from linux-e6410-1 (unknown [10.176.68.31]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id 9FC05207D9; Mon, 11 Feb 2013 03:15:52 -0800 (PST) Received: from arend by linux-e6410-1 with local (Exim 4.80) ( envelope-from ) id 1U4rMV-0006z8-M9; Mon, 11 Feb 2013 12:15:51 +0100 From: "Arend van Spriel" To: hostap@lists.shmoo.com Subject: [RFC 09/10] wpa_supplicant: use p2p device wrappers for p2p device flows Date: Mon, 11 Feb 2013 12:15:46 +0100 Message-ID: <1360581347-26766-10-git-send-email-arend@broadcom.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360581347-26766-1-git-send-email-arend@broadcom.com> References: <1360581347-26766-1-git-send-email-arend@broadcom.com> MIME-Version: 1.0 X-WSS-ID: 7D060E1C3OG1999398-01-01 Cc: Jouni Malinen , Johannes Berg X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: David Spinadel Signed-hostap: David Spinadel --- wpa_supplicant/gas_query.c | 4 +-- wpa_supplicant/offchannel.c | 58 ++++++++++++++++++++++++++++++--------- wpa_supplicant/offchannel.h | 4 +-- wpa_supplicant/p2p_supplicant.c | 21 +++++++------- 4 files changed, 60 insertions(+), 27 deletions(-) diff --git a/wpa_supplicant/gas_query.c b/wpa_supplicant/gas_query.c index 27bcc7a..43bd87a 100644 --- a/wpa_supplicant/gas_query.c +++ b/wpa_supplicant/gas_query.c @@ -82,7 +82,7 @@ static void gas_query_done(struct gas_query *gas, enum gas_query_result result) { if (query->offchannel_tx_started) - offchannel_send_action_done(gas->wpa_s); + offchannel_send_action_done(gas->wpa_s, 0); eloop_cancel_timeout(gas_query_tx_comeback_timeout, gas, query); eloop_cancel_timeout(gas_query_timeout, gas, query); dl_list_del(&query->list); @@ -148,7 +148,7 @@ static int gas_query_tx(struct gas_query *gas, struct gas_query_pending *query, res = offchannel_send_action(gas->wpa_s, query->freq, query->addr, gas->wpa_s->own_addr, query->addr, wpabuf_head(req), wpabuf_len(req), 1000, - NULL, 0); + NULL, 0, 0); if (res == 0) query->offchannel_tx_started = 1; return res; diff --git a/wpa_supplicant/offchannel.c b/wpa_supplicant/offchannel.c index 856eca7..0e0a111 100644 --- a/wpa_supplicant/offchannel.c +++ b/wpa_supplicant/offchannel.c @@ -205,8 +205,9 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, const u8 *data, size_t data_len, enum offchannel_send_action_result result), - int no_cck) + int no_cck, int p2p_dev) { + int ret; wpa_printf(MSG_DEBUG, "Off-channel: Send action frame: freq=%d dst=" MACSTR " src=" MACSTR " bssid=" MACSTR " len=%d", freq, MAC2STR(dst), MAC2STR(src), MAC2STR(bssid), @@ -241,13 +242,26 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, wpa_s->pending_action_src); wpa_s->action_tx_wait_time = wait_time; - return wpa_drv_send_action( - iface, wpa_s->pending_action_freq, - wait_time, wpa_s->pending_action_dst, - wpa_s->pending_action_src, wpa_s->pending_action_bssid, - wpabuf_head(wpa_s->pending_action_tx), - wpabuf_len(wpa_s->pending_action_tx), - wpa_s->pending_action_no_cck); +#ifdef CONFIG_P2P + if (p2p_dev) + return wpa_drv_p2p_send_action( + iface, wpa_s->pending_action_freq, + wait_time, wpa_s->pending_action_dst, + wpa_s->pending_action_src, + wpa_s->pending_action_bssid, + wpabuf_head(wpa_s->pending_action_tx), + wpabuf_len(wpa_s->pending_action_tx), + wpa_s->pending_action_no_cck); + else +#endif + return wpa_drv_send_action( + iface, wpa_s->pending_action_freq, + wait_time, wpa_s->pending_action_dst, + wpa_s->pending_action_src, + wpa_s->pending_action_bssid, + wpabuf_head(wpa_s->pending_action_tx), + wpabuf_len(wpa_s->pending_action_tx), + wpa_s->pending_action_no_cck); } if (freq) { @@ -285,7 +299,14 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, "channel"); if (wait_time > wpa_s->max_remain_on_chan) wait_time = wpa_s->max_remain_on_chan; - if (wpa_drv_remain_on_channel(wpa_s, freq, wait_time) < 0) { + +#ifdef CONFIG_P2P + if (p2p_dev) + ret = wpa_drv_p2p_remain_on_channel(wpa_s, freq, wait_time); + else +#endif + ret = wpa_drv_remain_on_channel(wpa_s, freq, wait_time); + if (ret < 0) { wpa_printf(MSG_DEBUG, "Off-channel: Failed to request driver " "to remain on channel (%u MHz) for Action " "Frame TX", freq); @@ -305,18 +326,29 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, * This function can be used to cancel a wait for additional response frames on * the channel that was used with offchannel_send_action(). */ -void offchannel_send_action_done(struct wpa_supplicant *wpa_s) +void offchannel_send_action_done(struct wpa_supplicant *wpa_s, int p2p_dev) { wpa_printf(MSG_DEBUG, "Off-channel: Action frame sequence done " "notification"); wpabuf_free(wpa_s->pending_action_tx); wpa_s->pending_action_tx = NULL; if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_OFFCHANNEL_TX && - wpa_s->action_tx_wait_time) - wpa_drv_send_action_cancel_wait(wpa_s); + wpa_s->action_tx_wait_time) { +#ifdef CONFIG_P2P + if (p2p_dev) + wpa_drv_p2p_send_action_cancel_wait(wpa_s); + else +#endif + wpa_drv_send_action_cancel_wait(wpa_s); + } if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { - wpa_drv_cancel_remain_on_channel(wpa_s); +#ifdef CONFIG_P2P + if (p2p_dev) + wpa_drv_p2p_cancel_remain_on_channel(wpa_s); + else +#endif + wpa_drv_cancel_remain_on_channel(wpa_s); wpa_s->off_channel_freq = 0; wpa_s->roc_waiting_drv_freq = 0; } diff --git a/wpa_supplicant/offchannel.h b/wpa_supplicant/offchannel.h index 0ad7e18..0dcc398 100644 --- a/wpa_supplicant/offchannel.h +++ b/wpa_supplicant/offchannel.h @@ -19,8 +19,8 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, const u8 *data, size_t data_len, enum offchannel_send_action_result result), - int no_cck); -void offchannel_send_action_done(struct wpa_supplicant *wpa_s); + int no_cck, int p2p_dev); +void offchannel_send_action_done(struct wpa_supplicant *wpa_s, int p2p_dev); void offchannel_remain_on_channel_cb(struct wpa_supplicant *wpa_s, unsigned int freq, unsigned int duration); void offchannel_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s, diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 7d4f2bf..87dae65 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -185,7 +185,7 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, break; } - ret = wpa_drv_scan(wpa_s, ¶ms); + ret = wpa_drv_p2p_scan(wpa_s, ¶ms); wpabuf_free(ies); @@ -745,14 +745,14 @@ static int wpas_send_action(void *ctx, unsigned int freq, const u8 *dst, struct wpa_supplicant *wpa_s = ctx; return offchannel_send_action(wpa_s, freq, dst, src, bssid, buf, len, wait_time, - wpas_p2p_send_action_tx_status, 1); + wpas_p2p_send_action_tx_status, 1, 1); } static void wpas_send_action_done(void *ctx) { struct wpa_supplicant *wpa_s = ctx; - offchannel_send_action_done(wpa_s); + offchannel_send_action_done(wpa_s, 1); } @@ -1085,7 +1085,7 @@ void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res) struct wpa_supplicant *wpa_s = ctx; if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { - wpa_drv_cancel_remain_on_channel(wpa_s); + wpa_drv_p2p_cancel_remain_on_channel(wpa_s); wpa_s->off_channel_freq = 0; wpa_s->roc_waiting_drv_freq = 0; } @@ -1219,7 +1219,7 @@ static int wpas_start_listen(void *ctx, unsigned int freq, wpa_s->pending_listen_freq = freq; wpa_s->pending_listen_duration = duration; - if (wpa_drv_remain_on_channel(wpa_s, freq, duration) < 0) { + if (wpa_drv_p2p_remain_on_channel(wpa_s, freq, duration) < 0) { wpa_printf(MSG_DEBUG, "P2P: Failed to request the driver " "to remain on channel (%u MHz) for Listen " "state", freq); @@ -1237,7 +1237,7 @@ static void wpas_stop_listen(void *ctx) { struct wpa_supplicant *wpa_s = ctx; if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { - wpa_drv_cancel_remain_on_channel(wpa_s); + wpa_drv_p2p_cancel_remain_on_channel(wpa_s); wpa_s->off_channel_freq = 0; wpa_s->roc_waiting_drv_freq = 0; } @@ -1249,7 +1249,8 @@ static void wpas_stop_listen(void *ctx) static int wpas_send_probe_resp(void *ctx, const struct wpabuf *buf) { struct wpa_supplicant *wpa_s = ctx; - return wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1); + return wpa_drv_p2p_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), + 1); } @@ -3438,7 +3439,7 @@ static void wpas_p2p_join_scan_req(struct wpa_supplicant *wpa_s, int freq) * Run a scan to update BSS table and start Provision Discovery once * the new scan results become available. */ - ret = wpa_drv_scan(wpa_s, ¶ms); + ret = wpa_drv_p2p_scan(wpa_s, ¶ms); if (!ret) wpa_s->scan_res_handler = wpas_p2p_scan_res_join; @@ -3526,7 +3527,7 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s) if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { wpa_printf(MSG_DEBUG, "P2P: Cancel remain-on-channel prior to " "starting client"); - wpa_drv_cancel_remain_on_channel(wpa_s); + wpa_drv_p2p_cancel_remain_on_channel(wpa_s); wpa_s->off_channel_freq = 0; wpa_s->roc_waiting_drv_freq = 0; } @@ -5453,7 +5454,7 @@ static void wpas_p2p_fallback_to_go_neg(struct wpa_supplicant *wpa_s, if (wpa_s->global->p2p_group_formation) group = wpa_s->global->p2p_group_formation; wpa_s = wpa_s->parent; - offchannel_send_action_done(wpa_s); + offchannel_send_action_done(wpa_s, 1); if (group_added) wpas_p2p_group_delete(group, P2P_GROUP_REMOVAL_SILENT); wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Fall back to GO Negotiation");