P2P: Add a mechanism for allowing 6 GHz channels in channel lists

Introduce a new allow_6ghz parameter to allow 6 GHz channels to be
filtered out when copying channel lists.

Signed-off-by: Sreeramya Soratkal <ssramya@codeaurora.org>
This commit is contained in:
Sreeramya Soratkal 2021-05-04 13:01:49 +05:30 committed by Jouni Malinen
parent 6423c23e3d
commit f7d4f1cbec
4 changed files with 42 additions and 4 deletions

View file

@ -1397,8 +1397,8 @@ static int p2p_prepare_channel_pref(struct p2p_data *p2p,
p2p->channels.reg_class[0].reg_class = p2p->op_reg_class; p2p->channels.reg_class[0].reg_class = p2p->op_reg_class;
p2p->channels.reg_class[0].channel[0] = p2p->op_channel; p2p->channels.reg_class[0].channel[0] = p2p->op_channel;
} else { } else {
os_memcpy(&p2p->channels, &p2p->cfg->channels, p2p_copy_channels(&p2p->channels, &p2p->cfg->channels,
sizeof(struct p2p_channels)); p2p->allow_6ghz);
} }
return 0; return 0;
@ -1485,8 +1485,7 @@ static void p2p_prepare_channel_best(struct p2p_data *p2p)
p2p->op_channel, p2p->op_reg_class); p2p->op_channel, p2p->op_reg_class);
} }
os_memcpy(&p2p->channels, &p2p->cfg->channels, p2p_copy_channels(&p2p->channels, &p2p->cfg->channels, p2p->allow_6ghz);
sizeof(struct p2p_channels));
} }
@ -5593,6 +5592,7 @@ bool p2p_is_peer_6ghz_capab(struct p2p_data *p2p, const u8 *addr)
void p2p_set_6ghz_dev_capab(struct p2p_data *p2p, bool allow_6ghz) void p2p_set_6ghz_dev_capab(struct p2p_data *p2p, bool allow_6ghz)
{ {
p2p->p2p_6ghz_capable = allow_6ghz; p2p->p2p_6ghz_capable = allow_6ghz;
p2p->allow_6ghz = allow_6ghz;
p2p_dbg(p2p, "Set 6 GHz capability to %d", allow_6ghz); p2p_dbg(p2p, "Set 6 GHz capability to %d", allow_6ghz);
if (allow_6ghz) if (allow_6ghz)
@ -5629,3 +5629,15 @@ bool p2p_peer_wfd_enabled(struct p2p_data *p2p, const u8 *peer_addr)
return false; return false;
#endif /* CONFIG_WIFI_DISPLAY */ #endif /* CONFIG_WIFI_DISPLAY */
} }
bool is_p2p_allow_6ghz(struct p2p_data *p2p)
{
return p2p->allow_6ghz;
}
void set_p2p_allow_6ghz(struct p2p_data *p2p, bool value)
{
p2p->allow_6ghz = value;
}

View file

@ -2420,5 +2420,7 @@ bool is_p2p_6ghz_capable(struct p2p_data *p2p);
bool p2p_is_peer_6ghz_capab(struct p2p_data *p2p, const u8 *addr); bool p2p_is_peer_6ghz_capab(struct p2p_data *p2p, const u8 *addr);
bool p2p_peer_wfd_enabled(struct p2p_data *p2p, const u8 *peer_addr); bool p2p_peer_wfd_enabled(struct p2p_data *p2p, const u8 *peer_addr);
bool p2p_wfd_enabled(struct p2p_data *p2p); bool p2p_wfd_enabled(struct p2p_data *p2p);
bool is_p2p_allow_6ghz(struct p2p_data *p2p);
void set_p2p_allow_6ghz(struct p2p_data *p2p, bool value);
#endif /* P2P_H */ #endif /* P2P_H */

View file

@ -550,6 +550,7 @@ struct p2p_data {
u8 override_pref_channel; u8 override_pref_channel;
bool p2p_6ghz_capable; bool p2p_6ghz_capable;
bool include_6ghz; bool include_6ghz;
bool allow_6ghz;
}; };
/** /**
@ -700,6 +701,8 @@ int p2p_channel_random_social(struct p2p_channels *chans, u8 *op_class,
u8 *op_channel, u8 *op_channel,
struct wpa_freq_range_list *avoid_list, struct wpa_freq_range_list *avoid_list,
struct wpa_freq_range_list *disallow_list); struct wpa_freq_range_list *disallow_list);
void p2p_copy_channels(struct p2p_channels *dst, const struct p2p_channels *src,
bool allow_6ghz);
/* p2p_parse.c */ /* p2p_parse.c */
void p2p_copy_filter_devname(char *dst, size_t dst_len, void p2p_copy_filter_devname(char *dst, size_t dst_len,

View file

@ -496,3 +496,24 @@ int p2p_channels_to_freqs(const struct p2p_channels *channels, int *freq_list,
return idx; return idx;
} }
void p2p_copy_channels(struct p2p_channels *dst,
const struct p2p_channels *src, bool allow_6ghz)
{
size_t i, j;
if (allow_6ghz) {
os_memcpy(dst, src, sizeof(struct p2p_channels));
return;
}
for (i = 0, j = 0; i < P2P_MAX_REG_CLASSES; i++) {
if (is_6ghz_op_class(src->reg_class[i].reg_class))
continue;
os_memcpy(&dst->reg_class[j], &src->reg_class[i],
sizeof(struct p2p_reg_class));
j++;
}
dst->reg_classes = j;
}