[PATCH] Avoid channel reselection, if any of the best channel is selected as operating channel
Sreenath
sreenats
Tue Jan 22 06:13:51 PST 2013
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 <sreenats at broadcom.com>
---
src/p2p/p2p.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
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;
@@ -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;
--
1.7.9.5
More information about the Hostap
mailing list