From patchwork Tue Mar 13 17:09:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fabienx.marotte@linux.intel.com X-Patchwork-Id: 146450 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C0D02B6EF1 for ; Wed, 14 Mar 2012 04:11:17 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id DFF5717C00D; Tue, 13 Mar 2012 13:11:15 -0400 (EDT) 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 Y2hFM5v8iwyG; Tue, 13 Mar 2012 13:11:15 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C020717C032; Tue, 13 Mar 2012 13:11:11 -0400 (EDT) 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 D5DE517C032 for ; Tue, 13 Mar 2012 13:11:10 -0400 (EDT) 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 V7Rf0epmEJQA for ; Tue, 13 Mar 2012 13:11:05 -0400 (EDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 8058917C00D for ; Tue, 13 Mar 2012 13:11:05 -0400 (EDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 13 Mar 2012 10:10:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="138159883" Received: from si16 (HELO localhost.localdomain) ([10.237.166.156]) by fmsmga002.fm.intel.com with ESMTP; 13 Mar 2012 10:10:11 -0700 From: fabienx.marotte@linux.intel.com To: hostap@lists.shmoo.com Subject: [PATCH] Complete the support of P2P in the 5GHz band Date: Tue, 13 Mar 2012 18:09:35 +0100 Message-Id: <1331658575-32432-1-git-send-email-fabienx.marotte@linux.intel.com> X-Mailer: git-send-email 1.7.0.4 Cc: Fabien Marotte 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: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Fabien Marotte The 5GHz band was not fully supported in the P2P case. This patch fixes the P2P code lacks. Signed-off-by: Fabien Marotte --- src/p2p/p2p_utils.c | 51 ++++++++++++++++++++++++++------------- wpa_supplicant/p2p_supplicant.c | 29 +++++++++++++--------- 2 files changed, 51 insertions(+), 29 deletions(-) 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,