P2P: Add support for automatic channel selection at GO
The driver wrapper may now indicate the preferred channel (e.g., based on scan results) on both 2.4 GHz and 5 GHz bands (and an overall best frequency). When setting up a GO, this preference information is used to select the operating channel if configuration does not include hardcoded channel. Similarly, this information can be used during GO Negotiation to indicate preference for a specific channel based on current channel conditions. p2p_group_add command can now use special values (freq=2 and freq=5) to indicate that the GO is to be started on the specified band.
This commit is contained in:
parent
bacc31286c
commit
7cfc4ac319
8 changed files with 215 additions and 17 deletions
|
@ -853,14 +853,52 @@ static int p2p_prepare_channel(struct p2p_data *p2p, unsigned int force_freq)
|
|||
p2p->channels.reg_class[0].reg_class = p2p->op_reg_class;
|
||||
p2p->channels.reg_class[0].channel[0] = p2p->op_channel;
|
||||
} else {
|
||||
p2p->op_reg_class = p2p->cfg->op_reg_class;
|
||||
p2p->op_channel = p2p->cfg->op_channel;
|
||||
u8 op_reg_class, op_channel;
|
||||
|
||||
if (!p2p->cfg->cfg_op_channel && p2p->best_freq_overall > 0 &&
|
||||
p2p_supported_freq(p2p, p2p->best_freq_overall) &&
|
||||
p2p_freq_to_channel(p2p->cfg->country,
|
||||
p2p->best_freq_overall,
|
||||
&op_reg_class, &op_channel) == 0) {
|
||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||
"P2P: Select best overall channel as "
|
||||
"operating channel preference");
|
||||
p2p->op_reg_class = op_reg_class;
|
||||
p2p->op_channel = op_channel;
|
||||
} 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,
|
||||
&op_reg_class, &op_channel) ==
|
||||
0) {
|
||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||
"P2P: Select best 5 GHz channel as "
|
||||
"operating channel preference");
|
||||
p2p->op_reg_class = op_reg_class;
|
||||
p2p->op_channel = op_channel;
|
||||
} 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,
|
||||
&op_reg_class, &op_channel) ==
|
||||
0) {
|
||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||
"P2P: Select best 2.4 GHz channel as "
|
||||
"operating channel preference");
|
||||
p2p->op_reg_class = op_reg_class;
|
||||
p2p->op_channel = op_channel;
|
||||
} else {
|
||||
p2p->op_reg_class = p2p->cfg->op_reg_class;
|
||||
p2p->op_channel = p2p->cfg->op_channel;
|
||||
}
|
||||
|
||||
os_memcpy(&p2p->channels, &p2p->cfg->channels,
|
||||
sizeof(struct p2p_channels));
|
||||
}
|
||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||
"P2P: Own preference for operation channel: "
|
||||
"Regulatory Class %u Channel %u%s",
|
||||
"Operating Class %u Channel %u%s",
|
||||
p2p->op_reg_class, p2p->op_channel,
|
||||
force_freq ? " (forced)" : "");
|
||||
|
||||
|
@ -3133,3 +3171,14 @@ int p2p_send_action(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
|
|||
return p2p->cfg->send_action(p2p->cfg->cb_ctx, freq, dst, src, bssid,
|
||||
buf, len, wait_time);
|
||||
}
|
||||
|
||||
|
||||
void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
|
||||
int freq_overall)
|
||||
{
|
||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Best channel: 2.4 GHz: %d,"
|
||||
" 5 GHz: %d, overall: %d", freq_24, freq_5, freq_overall);
|
||||
p2p->best_freq_24 = freq_24;
|
||||
p2p->best_freq_5 = freq_5;
|
||||
p2p->best_freq_overall = freq_overall;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue