Patchwork [RFC,1/4] P2P: Handling single channel concurrency

login
register
mail settings
Submitter Jouni Malinen
Date April 8, 2012, 6:35 p.m.
Message ID <20120408183516.GB12438@w1.fi>
Download mbox | patch
Permalink /patch/151368/
State Accepted
Commit b9cfc09a81b1f6449bbd0754a2bdc4d790766662
Headers show

Comments

Jouni Malinen - April 8, 2012, 6:35 p.m.
On Tue, Mar 06, 2012 at 10:33:50AM +0530, Jithu Jance wrote:
> diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
> @@ -3418,6 +3418,20 @@ static int p2p_ctrl_set(struct wpa_supplicant
> + if (os_strcmp(cmd, "conc_priority") == 0) {
> + if(os_strncmp(cmd+strlen("conc_priority")+1, "sta", 3) == 0)
> + os_strncpy(wpa_s->global->conc_priority, "sta", 3);
> + else if(os_strncmp(cmd+strlen("conc_priority")+1, "p2p", 3) == 0)
> + os_strncpy(wpa_s->global->conc_priority, "p2p", 3);
> + else {
> + wpa_printf(MSG_ERROR, " conc_priority arg should be either sta or p2p");
> + return -1;
> + }

Is there any specific reason for storing this as a string instead of an
integer or enum? A bit cleaned up version below.


[PATCH 1/3] P2P: Add preference setting for concurrent use cases

Add an additional parameter to prioritize either sta or p2p connection
to resolve conflicts arising during single channel concurrency.

Signed-hostap: Jithu Jance <jithu@broadcom.com>
---
 wpa_supplicant/ctrl_iface.c       |   14 ++++++++++++++
 wpa_supplicant/wpa_supplicant.c   |   10 ++++++++++
 wpa_supplicant/wpa_supplicant_i.h |    6 ++++++
 3 files changed, 30 insertions(+), 0 deletions(-)
Jithu Jance - April 9, 2012, 7:17 a.m.
Hi Jouni,

> Is there any specific reason for storing this as a string instead of an
> integer or enum? A bit cleaned up version below.
No specific reason as such. Your cleaned up version looks better. Please
apply the same.

- Jithu

*
*
On Mon, Apr 9, 2012 at 12:05 AM, Jouni Malinen <j@w1.fi> wrote:

> Is there any specific reason for storing this as a string instead of an
> integer or enum? A bit cleaned up version below.
>
Jouni Malinen - June 10, 2012, 5:55 p.m.
On Mon, Apr 09, 2012 at 12:47:16PM +0530, Jithu Jance wrote:
> No specific reason as such. Your cleaned up version looks better. Please
> apply the same.

Thanks, applied.

Patch

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 3ddae95..07d3819 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -3576,6 +3576,20 @@  static int p2p_ctrl_set(struct wpa_supplicant *wpa_s, char *cmd)
 		return 0;
 	}
 
+	if (os_strcmp(cmd, "conc_pref") == 0) {
+		if (os_strcmp(param, "sta") == 0)
+			wpa_s->global->conc_pref = WPA_CONC_PREF_STA;
+		else if (os_strcmp(param, "p2p") == 0)
+			wpa_s->global->conc_pref = WPA_CONC_PREF_P2P;
+		else {
+			wpa_printf(MSG_INFO, "Invalid conc_pref value");
+			return -1;
+		}
+		wpa_printf(MSG_DEBUG, "Single channel concurrency preference: "
+			   "%s", param);
+		return 0;
+	}
+
 	if (os_strcmp(cmd, "force_long_sd") == 0) {
 		wpa_s->force_long_sd = atoi(param);
 		return 0;
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index c5a7115..1c88949 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -3216,3 +3216,13 @@  int wpas_driver_bss_selection(struct wpa_supplicant *wpa_s)
 	return wpa_s->conf->ap_scan == 2 ||
 		(wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION);
 }
+
+
+int wpas_is_p2p_prioritized(struct wpa_supplicant *wpa_s)
+{
+	if (wpa_s->global->conc_pref == WPA_CONC_PREF_P2P)
+		return 1;
+	if (wpa_s->global->conc_pref == WPA_CONC_PREF_STA)
+		return 0;
+	return -1;
+}
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index a494c49..3f1f589 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -233,6 +233,11 @@  struct wpa_global {
 	int cross_connection;
 	struct wpa_freq_range *p2p_disallow_freq;
 	unsigned int num_p2p_disallow_freq;
+	enum wpa_conc_pref {
+		WPA_CONC_PREF_NOT_SET,
+		WPA_CONC_PREF_STA,
+		WPA_CONC_PREF_P2P
+	} conc_pref;
 };
 
 
@@ -623,6 +628,7 @@  void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
 void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s);
 void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid);
 int wpas_driver_bss_selection(struct wpa_supplicant *wpa_s);
+int wpas_is_p2p_prioritized(struct wpa_supplicant *wpa_s);
 
 /* events.c */
 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);