P2P: Prefer U-NII-3 over U-NII-1 during channel selection

Some devices disable use of U-NII-1 (channels 36-48) for P2P due to it
being indoor use only in number of locations. If U-NII-3 (channels
149-161) is available, try to pick a channel from that range first
during random channel selection to reduce likelihood of interoperability
issues.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2013-11-19 13:04:21 +02:00 committed by Jouni Malinen
parent 1b665cbf51
commit 0004374025
3 changed files with 20 additions and 23 deletions

View File

@ -1180,8 +1180,8 @@ static int p2p_prepare_channel_pref(struct p2p_data *p2p,
static void p2p_prepare_channel_best(struct p2p_data *p2p)
{
u8 op_class, op_channel;
const int op_classes_5ghz[] = { 115, 124, 0 };
const int op_classes_ht40[] = { 116, 117, 126, 127, 0 };
const int op_classes_5ghz[] = { 124, 115, 0 };
const int op_classes_ht40[] = { 126, 127, 116, 117, 0 };
const int op_classes_vht[] = { 128, 0 };
p2p_dbg(p2p, "Prepare channel best");

View File

@ -348,8 +348,8 @@ void p2p_reselect_channel(struct p2p_data *p2p,
int freq;
u8 op_reg_class, op_channel;
unsigned int i;
const int op_classes_5ghz[] = { 115, 124, 0 };
const int op_classes_ht40[] = { 116, 117, 126, 127, 0 };
const int op_classes_5ghz[] = { 124, 115, 0 };
const int op_classes_ht40[] = { 126, 127, 116, 117, 0 };
const int op_classes_vht[] = { 128, 0 };
if (p2p->own_freq_preference > 0 &&

View File

@ -446,28 +446,25 @@ int p2p_channel_select(struct p2p_channels *chans, const int *classes,
{
unsigned int i, j, r;
for (i = 0; i < chans->reg_classes; i++) {
struct p2p_reg_class *c = &chans->reg_class[i];
for (j = 0; classes[j]; j++) {
for (i = 0; i < chans->reg_classes; i++) {
struct p2p_reg_class *c = &chans->reg_class[i];
if (c->channels == 0)
continue;
if (c->channels == 0)
continue;
for (j = 0; classes[j]; j++) {
if (c->reg_class == classes[j])
break;
if (c->reg_class == classes[j]) {
/*
* Pick one of the available channels in the
* operating class at random.
*/
os_get_random((u8 *) &r, sizeof(r));
r %= c->channels;
*op_class = c->reg_class;
*op_channel = c->channel[r];
return 0;
}
}
if (!classes[j])
continue;
/*
* Pick one of the available channels in the operating class at
* random.
*/
os_get_random((u8 *) &r, sizeof(r));
r %= c->channels;
*op_class = c->reg_class;
*op_channel = c->channel[r];
return 0;
}
return -1;