From patchwork Tue Jan 22 14:13:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreenath X-Patchwork-Id: 214559 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 CDC5F2C007C for ; Wed, 23 Jan 2013 01:14:10 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 186919C10C; Tue, 22 Jan 2013 09:14:06 -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 cQBBUru2++Z5; Tue, 22 Jan 2013 09:14:05 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9CAF49C114; Tue, 22 Jan 2013 09:14:01 -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 CF2499C114 for ; Tue, 22 Jan 2013 09:14:00 -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 jt5JCYUaPejP for ; Tue, 22 Jan 2013 09:14:00 -0500 (EST) Received: from mms1.broadcom.com (mms1.broadcom.com [216.31.210.17]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7DA449C10C for ; Tue, 22 Jan 2013 09:14:00 -0500 (EST) Received: from [10.9.208.53] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Tue, 22 Jan 2013 06:11:51 -0800 X-Server-Uuid: 06151B78-6688-425E-9DE2-57CB27892261 Received: from mail-irva-13.broadcom.com (10.11.16.103) by irvexchcas06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server id 14.1.355.2; Tue, 22 Jan 2013 06:13:53 -0800 Received: from [10.132.21.138] (sreenats-linux.ban.broadcom.com [10.132.21.138]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id D81B340FE6 for ; Tue, 22 Jan 2013 06:13:52 -0800 (PST) Message-ID: <50FE9E9F.8040900@broadcom.com> Date: Tue, 22 Jan 2013 19:43:51 +0530 From: Sreenath User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: "HostAP mailing list" Subject: [PATCH] Avoid channel reselection, if any of the best channel is selected as operating channel X-WSS-ID: 7CE041AD1Z4531771-01-01 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 Set P2P_DEV_FORCE_FREQ flag if any of the best channel is selected as the operating channel, to prevent channel reselection in GO channel selection. Signed-hostap: Sreenath Sharma --- src/p2p/p2p.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) @@ -1172,6 +1173,7 @@ static void p2p_prepare_channel_best(struct p2p_data *p2p) "overall channel as operating channel preference"); p2p->op_reg_class = op_class; p2p->op_channel = op_channel; + *best_freq = 1; } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_5 > 0 && p2p_supported_freq(p2p, p2p->best_freq_5) && p2p_freq_to_channel(p2p->cfg->country, p2p->best_freq_5, @@ -1180,6 +1182,7 @@ static void p2p_prepare_channel_best(struct p2p_data *p2p) "channel as operating channel preference"); p2p->op_reg_class = op_class; p2p->op_channel = op_channel; + *best_freq = 1; } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_24 > 0 && p2p_supported_freq(p2p, p2p->best_freq_24) && p2p_freq_to_channel(p2p->cfg->country, p2p->best_freq_24, @@ -1188,9 +1191,11 @@ static void p2p_prepare_channel_best(struct p2p_data *p2p) "GHz channel as operating channel preference"); p2p->op_reg_class = op_class; p2p->op_channel = op_channel; + *best_freq = 1; } else { p2p->op_reg_class = p2p->cfg->op_reg_class; p2p->op_channel = p2p->cfg->op_channel; + *best_freq = 0; } os_memcpy(&p2p->channels, &p2p->cfg->channels, @@ -1214,19 +1219,22 @@ static void p2p_prepare_channel_best(struct p2p_data *p2p) static int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev, unsigned int force_freq, unsigned int pref_freq) { + unsigned int best_freq = 0; + if (force_freq || pref_freq) { if (p2p_prepare_channel_pref(p2p, force_freq, pref_freq) < 0) return -1; } else { - p2p_prepare_channel_best(p2p); + p2p_prepare_channel_best(p2p, &best_freq); } wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Own preference for operation channel: " "Operating Class %u Channel %u%s", p2p->op_reg_class, p2p->op_channel, - force_freq ? " (forced)" : ""); + force_freq ? " (forced)" : + best_freq ? " (best)" : ""); - if (force_freq) + if (force_freq || best_freq) dev->flags |= P2P_DEV_FORCE_FREQ; else dev->flags &= ~P2P_DEV_FORCE_FREQ; diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 43f8673..c616112 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -1160,7 +1160,8 @@ static int p2p_prepare_channel_pref(struct p2p_data *p2p, } -static void p2p_prepare_channel_best(struct p2p_data *p2p) +static void p2p_prepare_channel_best(struct p2p_data *p2p, + unsigned int *best_freq) { u8 op_class, op_channel;