Patchwork Complete the support of P2P in the 5GHz band

login
register
mail settings
Submitter fabienx.marotte@linux.intel.com
Date March 13, 2012, 5:09 p.m.
Message ID <1331658575-32432-1-git-send-email-fabienx.marotte@linux.intel.com>
Download mbox | patch
Permalink /patch/146450/
State Deferred
Headers show

Comments

fabienx.marotte@linux.intel.com - March 13, 2012, 5:09 p.m.
From: Fabien Marotte <fabien.marotte@intel.com>

The 5GHz band was not fully supported in the P2P case.
This patch fixes the P2P code lacks.

Signed-off-by: Fabien Marotte <fabien.marotte@intel.com>
---
 src/p2p/p2p_utils.c             |   51 ++++++++++++++++++++++++++-------------
 wpa_supplicant/p2p_supplicant.c |   29 +++++++++++++---------
 2 files changed, 51 insertions(+), 29 deletions(-)
Jouni Malinen - April 1, 2012, 9:36 a.m.
On Tue, Mar 13, 2012 at 06:09:35PM +0100, fabienx.marotte@linux.intel.com wrote:
> The 5GHz band was not fully supported in the P2P case.
> This patch fixes the P2P code lacks.

This was left out on purpose to avoid enabling some channels
(especially, anything requiring DFS). Similarly, HT40 negotiation is
quite unclear topic and it seems it would be clearer to just negotiate
HT20 and have the GO enable HT40 on its own.

What are you trying to achieve with the changes in this patch?

> diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
> @@ -2177,9 +2177,16 @@ static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
> +		{ HOSTAPD_MODE_IEEE80211A, 118, 52, 64, 4, BW20 },
> +		{ HOSTAPD_MODE_IEEE80211A, 119, 52, 60, 8, BW40PLUS },
> +		{ HOSTAPD_MODE_IEEE80211A, 120, 56, 64, 8, BW40MINUS },
> +		{ HOSTAPD_MODE_IEEE80211A, 121, 100, 140, 4, BW20 },
> +		{ HOSTAPD_MODE_IEEE80211A, 122, 100, 132, 8, BW40PLUS },
> +		{ HOSTAPD_MODE_IEEE80211A, 123, 104, 136, 8, BW40MINUS },

I'm not planning on enabling DFS channels for P2P use cases, so
especially this section would require quite a bit more justification.
Marotte, Fabien - April 2, 2012, 9:39 a.m.
> > The 5GHz band was not fully supported in the P2P case.
> > This patch fixes the P2P code lacks.
> 
> This was left out on purpose to avoid enabling some channels (especially, anything requiring DFS). Similarly, HT40 negotiation is quite unclear topic and it seems it would be clearer to just negotiate
> HT20 and have the GO enable HT40 on its own.
I see what you mean for HT40.
However, some HT40 classes were already defined in the 5GHz band before my patch. That's why I added the others.

>
> > What are you trying to achieve with the changes in this patch?
My primary goal was to activate channel 165 that is not supported.
However, I wanted my patch to be "complete". That's why I added all the classes.

>
> > diff --git a/wpa_supplicant/p2p_supplicant.c 
> > b/wpa_supplicant/p2p_supplicant.c @@ -2177,9 +2177,16 @@ static int 
> > wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
> > +		{ HOSTAPD_MODE_IEEE80211A, 118, 52, 64, 4, BW20 },
> > +		{ HOSTAPD_MODE_IEEE80211A, 119, 52, 60, 8, BW40PLUS },
> > +		{ HOSTAPD_MODE_IEEE80211A, 120, 56, 64, 8, BW40MINUS },
> > +		{ HOSTAPD_MODE_IEEE80211A, 121, 100, 140, 4, BW20 },
> > +		{ HOSTAPD_MODE_IEEE80211A, 122, 100, 132, 8, BW40PLUS },
> > +		{ HOSTAPD_MODE_IEEE80211A, 123, 104, 136, 8, BW40MINUS },
>
> I'm not planning on enabling DFS channels for P2P use cases, so especially this section would require quite a bit more justification.
I understand why you don't plan to activate DFS channels.
However, define the class 118 to 123 is not a problem because the function has_channel(), (lower is setup_channels() ) will filter the DFS channels.
So according to me, it should not be a matter to define them here.

>

I can re-push a new patch depending on what you prefer to see in the code.

Fabien

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

Patch

diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index bcc690d..26ad51c 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -49,43 +49,43 @@  int p2p_random(char *buf, size_t len)
 static int p2p_channel_to_freq_j4(int reg_class, int channel)
 {
 	/* Table J-4 in P802.11REVmb/D4.0 - Global operating classes */
-	/* TODO: more regulatory classes */
 	switch (reg_class) {
 	case 81:
 		/* channels 1..13 */
+	case 83: /* channels 1.. 9; 40 MHz */
+	case 84: /* channels 5..13; 40 MHz */
 		if (channel < 1 || channel > 13)
 			return -1;
 		return 2407 + 5 * channel;
+
 	case 82:
 		/* channel 14 */
 		if (channel != 14)
 			return -1;
 		return 2414 + 5 * channel;
-	case 83: /* channels 1..9; 40 MHz */
-	case 84: /* channels 5..13; 40 MHz */
-		if (channel < 1 || channel > 13)
-			return -1;
-		return 2407 + 5 * channel;
+
 	case 115: /* channels 36,40,44,48; indoor only */
-	case 118: /* channels 52,56,60,64; dfs */
-		if (channel < 36 || channel > 64)
-			return -1;
-		return 5000 + 5 * channel;
-	case 124: /* channels 149,153,157,161 */
-	case 125: /* channels 149,153,157,161,165,169 */
-		if (channel < 149 || channel > 161)
-			return -1;
-		return 5000 + 5 * channel;
 	case 116: /* channels 36,44; 40 MHz; indoor only */
 	case 117: /* channels 40,48; 40 MHz; indoor only */
+	case 118: /* channels 52,56,60,64; dfs */
 	case 119: /* channels 52,60; 40 MHz; dfs */
 	case 120: /* channels 56,64; 40 MHz; dfs */
 		if (channel < 36 || channel > 64)
 			return -1;
 		return 5000 + 5 * channel;
+
+	case 121: /* channels 100 .. 140; 20MHz */
+	case 122: /* channels 100 108 116 124 132; 40MHz */
+	case 123: /* channels 104 112 120 128 136; 40Mhz */
+		if ((channel < 100) || (channel > 136))
+			return -1;
+		return 5000 + 5 * channel;
+
+	case 124: /* channels 149,153,157,161 */
+	case 125: /* channels 149,153,157,161,165,169 */
 	case 126: /* channels 149,157; 40 MHz */
 	case 127: /* channels 153,161; 40 MHz */
-		if (channel < 149 || channel > 161)
+		if (channel < 149 || channel > 169)
 			return -1;
 		return 5000 + 5 * channel;
 	}
@@ -142,7 +142,6 @@  int p2p_channel_to_freq(const char *country, int reg_class, int channel)
 int p2p_freq_to_channel(const char *country, unsigned int freq, u8 *reg_class,
 			u8 *channel)
 {
-	/* TODO: more operating classes */
 	if (freq >= 2412 && freq <= 2472) {
 		*reg_class = 81; /* 2.407 GHz, channels 1..13 */
 		*channel = (freq - 2407) / 5;
@@ -161,12 +160,30 @@  int p2p_freq_to_channel(const char *country, unsigned int freq, u8 *reg_class,
 		return 0;
 	}
 
+	if (freq >= 5260 && freq <= 5320) {
+		*reg_class = 118; /* 5 GHz, channels 52..64 */
+		*channel = (freq - 5000) / 5;
+		return 0;
+	}
+
+	if (freq >= 5500 && freq <= 5700) {
+		*reg_class = 121; /* 5 GHz, channels 100..140 */
+		*channel = (freq - 5000) / 5;
+		return 0;
+	}
+
 	if (freq >= 5745 && freq <= 5805) {
 		*reg_class = 124; /* 5 GHz, channels 149..161 */
 		*channel = (freq - 5000) / 5;
 		return 0;
 	}
 
+	if (freq >= 5825 && freq <= 5845) {
+		*reg_class = 125; /* 5 GHz, channels 165 169 */
+		*channel = (freq - 5000) / 5;
+		return 0;
+	}
+
 	return -1;
 }
 
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 486a551..f6aa3b2 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -2177,9 +2177,16 @@  static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
 		{ HOSTAPD_MODE_IEEE80211G, 84, 5, 13, 1, BW40MINUS },
 #endif
 		{ HOSTAPD_MODE_IEEE80211A, 115, 36, 48, 4, BW20 },
-		{ HOSTAPD_MODE_IEEE80211A, 124, 149, 161, 4, BW20 },
 		{ HOSTAPD_MODE_IEEE80211A, 116, 36, 44, 8, BW40PLUS },
 		{ HOSTAPD_MODE_IEEE80211A, 117, 40, 48, 8, BW40MINUS },
+		{ HOSTAPD_MODE_IEEE80211A, 118, 52, 64, 4, BW20 },
+		{ HOSTAPD_MODE_IEEE80211A, 119, 52, 60, 8, BW40PLUS },
+		{ HOSTAPD_MODE_IEEE80211A, 120, 56, 64, 8, BW40MINUS },
+		{ HOSTAPD_MODE_IEEE80211A, 121, 100, 140, 4, BW20 },
+		{ HOSTAPD_MODE_IEEE80211A, 122, 100, 132, 8, BW40PLUS },
+		{ HOSTAPD_MODE_IEEE80211A, 123, 104, 136, 8, BW40MINUS },
+		{ HOSTAPD_MODE_IEEE80211A, 124, 149, 161, 4, BW20 },
+		{ HOSTAPD_MODE_IEEE80211A, 125, 149, 169, 4, BW20 },
 		{ HOSTAPD_MODE_IEEE80211A, 126, 149, 157, 8, BW40PLUS },
 		{ HOSTAPD_MODE_IEEE80211A, 127, 153, 161, 8, BW40MINUS },
 		{ -1, 0, 0, 0, 0, BW20 }
@@ -3126,17 +3133,15 @@  static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
 		wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on forced "
 			   "frequency %d MHz", freq);
 		params->freq = freq;
-	} else if (wpa_s->conf->p2p_oper_reg_class == 81 &&
-		   wpa_s->conf->p2p_oper_channel >= 1 &&
-		   wpa_s->conf->p2p_oper_channel <= 11) {
-		params->freq = 2407 + 5 * wpa_s->conf->p2p_oper_channel;
-		wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured "
-			   "frequency %d MHz", params->freq);
-	} else if (wpa_s->conf->p2p_oper_reg_class == 115 ||
-		   wpa_s->conf->p2p_oper_reg_class == 124) {
-		params->freq = 5000 + 5 * wpa_s->conf->p2p_oper_channel;
-		wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured "
-			   "frequency %d MHz", params->freq);
+	} else if (wpa_s->conf->p2p_oper_reg_class != 0) {
+		params->freq = p2p_channel_to_freq("XX\x04",
+					wpa_s->conf->p2p_oper_reg_class,
+					wpa_s->conf->p2p_oper_channel);
+		if (params->freq == -1) {
+			params->freq = 2412;
+			wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz"
+				"(Preference invalid)", params->freq);
+		}
 	} else if (wpa_s->conf->p2p_oper_channel == 0 &&
 		   wpa_s->best_overall_freq > 0 &&
 		   p2p_supported_freq(wpa_s->global->p2p,