[PATCH] P2P: Allow GO on IR-concurrent channels while associated in the same band
Xuenan Zhang
zxnnet at gmail.com
Tue Nov 10 06:13:32 PST 2026
The kernel marks some channels NO_IR and additionally
NL80211_FREQUENCY_ATTR_GO_CONCURRENT (e.g., U-NII-1 with Intel LAR). With
CONFIG_CFG80211_REG_RELAX_NO_IR and a driver that sets
REGULATORY_ENABLE_RELAX_NO_IR, cfg80211 allows a P2P GO on such a channel
while a station interface on the same wiphy is associated with an AP on
the same channel or in the same U-NII band (cfg80211_ir_permissive_chan()).
wpa_supplicant parsed this flag into HOSTAPD_CHAN_GO_CONCURRENT, but never
used it: has_channel() reported NO_IR and hostapd_get_hw_features()
marked the channel disabled, so a GO could not be started there even
though the kernel would allow it.
Allow such channels for a GO when an interface on the same radio is in
WPA_COMPLETED state in infrastructure mode and its association frequency
is in the same 5 GHz U-NII band, following the cfg80211 rules (including
the channel 165 exception). On the AP side, this is done with an optional
callback in struct hostapd_iface that only wpa_supplicant sets for P2P GO
interfaces, so hostapd behavior does not change.
When the station disconnects, the existing state change handling updates
the P2P channel list and moves the GO away from the now invalid
frequency.
Tested with Intel AX200 (iwlmvm) and cfg80211 built with
CONFIG_CFG80211_REG_RELAX_NO_IR, station on channel 36: the GO starts on
channel 36 (80 MHz) and moves to channel 149 with CSA about 5 seconds
after the station disconnects. Without the kernel option, the kernel
rejects the channel with -EINVAL, as before.
Signed-off-by: Xuenan Zhang <zxnnet at gmail.com>
---
src/ap/hostapd.h | 8 +++
src/ap/hw_features.c | 16 ++++++
wpa_supplicant/ap.c | 15 ++++++
wpa_supplicant/p2p_supplicant.c | 88 +++++++++++++++++++++++++++++----
wpa_supplicant/p2p_supplicant.h | 8 +++
5 files changed, 125 insertions(+), 10 deletions(-)
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index 6ce29653b..8d189bb2a 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -748,6 +748,14 @@ struct hostapd_iface {
/* Configured freq of interface is NO_IR */
bool is_no_ir;
+ /*
+ * Optional callback for a P2P GO: return true if a channel that is
+ * marked NO_IR, but also HOSTAPD_CHAN_GO_CONCURRENT, may be used
+ * because another interface on the same radio is associated with an
+ * AP in the same band. If not set, such channels are not used.
+ */
+ bool (*go_concurrent_allowed_cb)(struct hostapd_iface *iface, int freq);
+
bool is_ch_switch_dfs; /* Channel switch from ACS to DFS */
struct hostapd_multi_hw_info *multi_hw_info;
diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c
index 2af3d3b57..8e9f8a2cd 100644
--- a/src/ap/hw_features.c
+++ b/src/ap/hw_features.c
@@ -178,10 +178,26 @@ int hostapd_get_hw_features(struct hostapd_iface *iface)
* to initiate radiation (a.k.a. passive scan and no
* IBSS).
* Use radar channels only if the driver supports DFS.
+ * A P2P GO may use a NO_IR channel that allows
+ * concurrent GO operation while the owner reports
+ * that the conditions for that are met.
*/
if ((feature->channels[j].flag &
HOSTAPD_CHAN_RADAR) && dfs_enabled) {
dfs = 1;
+ } else if ((feature->channels[j].flag &
+ HOSTAPD_CHAN_NO_IR) &&
+ !(feature->channels[j].flag &
+ (HOSTAPD_CHAN_RADAR |
+ HOSTAPD_CHAN_DISABLED)) &&
+ (feature->channels[j].flag &
+ HOSTAPD_CHAN_GO_CONCURRENT) &&
+ iface->go_concurrent_allowed_cb &&
+ iface->go_concurrent_allowed_cb(
+ iface, feature->channels[j].freq)) {
+ wpa_printf(MSG_DEBUG,
+ "Allow NO_IR channel %d MHz for concurrent GO operation",
+ feature->channels[j].freq);
} else if (((feature->channels[j].flag &
HOSTAPD_CHAN_RADAR) &&
!(iface->drv_flags &
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index aa3eef9b6..237ab2e4a 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -987,6 +987,17 @@ static void wpas_ap_configured_cb(void *ctx)
}
+#ifdef CONFIG_P2P
+static bool wpas_ap_go_concurrent_allowed(struct hostapd_iface *iface,
+ int freq)
+{
+ struct wpa_supplicant *wpa_s = iface->owner;
+
+ return freq > 0 && wpas_p2p_go_concurrent_allowed(wpa_s, freq);
+}
+#endif /* CONFIG_P2P */
+
+
int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
{
@@ -1127,6 +1138,10 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER |
P2P_GROUP_FORMATION;
+ if (ssid->mode == WPAS_MODE_P2P_GO ||
+ ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
+ hapd_iface->go_concurrent_allowed_cb =
+ wpas_ap_go_concurrent_allowed;
#endif /* CONFIG_P2P */
hapd_iface->num_bss = conf->num_bss;
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 2b9e7f890..26e1f9082 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -4427,7 +4427,68 @@ static int wpas_p2p_default_channels(struct wpa_supplicant *wpa_s,
}
-static enum chan_allowed has_channel(struct wpa_global *global,
+static int wpas_p2p_unii_band(unsigned int freq)
+{
+ if (freq >= 5150 && freq < 5250)
+ return 1; /* U-NII-1 */
+ if (freq >= 5250 && freq < 5350)
+ return 2; /* U-NII-2A */
+ if (freq >= 5470 && freq < 5730)
+ return 3; /* U-NII-2C */
+ if (freq >= 5730 && freq < 5850)
+ return 4; /* U-NII-3 */
+ return -1;
+}
+
+
+/**
+ * wpas_p2p_go_concurrent_allowed - Check whether a GO may use a NO_IR channel
+ * @wpa_s: Pointer to wpa_supplicant data (any interface on the radio)
+ * @freq: Frequency (MHz) of a channel marked NO_IR and GO_CONCURRENT
+ * Returns: true if a station interface on the same radio is associated with
+ * an AP on a channel in the same 5 GHz U-NII band
+ *
+ * This follows the IR-concurrent relaxation implemented by cfg80211
+ * (cfg80211_ir_permissive_chan()): the AP is assumed to be an authorized
+ * master, so a P2P GO may initiate radiation in the same band while the
+ * association lasts.
+ */
+bool wpas_p2p_go_concurrent_allowed(struct wpa_supplicant *wpa_s,
+ unsigned int freq)
+{
+ struct wpa_supplicant *ifs;
+ int band = wpas_p2p_unii_band(freq);
+
+ if (band < 0)
+ return false;
+
+ for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
+ if (ifs->radio != wpa_s->radio ||
+ ifs->wpa_state != WPA_COMPLETED ||
+ !ifs->current_ssid ||
+ ifs->current_ssid->mode != WPAS_MODE_INFRA ||
+ ifs->current_ssid->p2p_group || !ifs->assoc_freq)
+ continue;
+ if (wpas_p2p_unii_band(ifs->assoc_freq) != band)
+ continue;
+ /*
+ * Channel 165 is not part of the 149-161 bundle in some
+ * regulatory domains; cfg80211 only allows it with an AP on
+ * 165 itself.
+ */
+ if (freq == 5825 && ifs->assoc_freq != 5825)
+ continue;
+ wpa_printf(MSG_EXCESSIVE,
+ "P2P: Allow NO_IR channel %u MHz for GO: %s is associated on %d MHz",
+ freq, ifs->ifname, ifs->assoc_freq);
+ return true;
+ }
+
+ return false;
+}
+
+
+static enum chan_allowed has_channel(struct wpa_supplicant *wpa_s,
struct hostapd_hw_modes *mode, u8 op_class,
u8 chan, int *flags)
{
@@ -4435,7 +4496,7 @@ static enum chan_allowed has_channel(struct wpa_global *global,
unsigned int freq;
freq = ieee80211_chan_to_freq(NULL, op_class, chan);
- if (wpas_p2p_disallowed_freq(global, freq))
+ if (wpas_p2p_disallowed_freq(wpa_s->global, freq))
return NOT_ALLOWED;
for (i = 0; i < mode->num_channels; i++) {
@@ -4444,8 +4505,15 @@ static enum chan_allowed has_channel(struct wpa_global *global,
*flags = mode->channels[i].flag;
if (mode->channels[i].flag & HOSTAPD_CHAN_DISABLED)
return NOT_ALLOWED;
- if (mode->channels[i].flag & HOSTAPD_CHAN_NO_IR)
+ if (mode->channels[i].flag & HOSTAPD_CHAN_NO_IR) {
+ if ((mode->channels[i].flag &
+ HOSTAPD_CHAN_GO_CONCURRENT) &&
+ !(mode->channels[i].flag &
+ HOSTAPD_CHAN_RADAR) &&
+ wpas_p2p_go_concurrent_allowed(wpa_s, freq))
+ return ALLOWED;
return NO_IR;
+ }
if (mode->channels[i].flag & HOSTAPD_CHAN_RADAR)
return RADAR;
return ALLOWED;
@@ -4515,7 +4583,7 @@ static enum chan_allowed wpas_p2p_verify_80mhz(struct wpa_supplicant *wpa_s,
for (i = 0; i < 4; i++) {
int adj_chan = center_chan - 6 + i * 4;
- res = has_channel(wpa_s->global, mode, op_class, adj_chan,
+ res = has_channel(wpa_s, mode, op_class, adj_chan,
&flags);
if (res == NOT_ALLOWED)
return NOT_ALLOWED;
@@ -4591,7 +4659,7 @@ static enum chan_allowed wpas_p2p_verify_160mhz(struct wpa_supplicant *wpa_s,
for (i = 0; i < 8; i++) {
int adj_chan = center_chan - 14 + i * 4;
- res = has_channel(wpa_s->global, mode, op_class, adj_chan,
+ res = has_channel(wpa_s, mode, op_class, adj_chan,
&flags);
if (res == NOT_ALLOWED)
return NOT_ALLOWED;
@@ -4642,25 +4710,25 @@ static enum chan_allowed wpas_p2p_verify_channel(struct wpa_supplicant *wpa_s,
p2p_channel_to_freq(op_class, channel)))
return NOT_ALLOWED;
- res2 = res = has_channel(wpa_s->global, mode, op_class, channel, &flag);
+ res2 = res = has_channel(wpa_s, mode, op_class, channel, &flag);
if (bw == BW40MINUS) {
if (!(flag & HOSTAPD_CHAN_HT40MINUS))
return NOT_ALLOWED;
- res2 = has_channel(wpa_s->global, mode, op_class, channel - 4,
+ res2 = has_channel(wpa_s, mode, op_class, channel - 4,
NULL);
} else if (bw == BW40PLUS) {
if (!(flag & HOSTAPD_CHAN_HT40PLUS))
return NOT_ALLOWED;
- res2 = has_channel(wpa_s->global, mode, op_class, channel + 4,
+ res2 = has_channel(wpa_s, mode, op_class, channel + 4,
NULL);
} else if (is_6ghz_op_class(op_class) && bw == BW40) {
if (mode->mode != HOSTAPD_MODE_IEEE80211A)
return NOT_ALLOWED;
if (get_6ghz_sec_channel(channel) < 0)
- res2 = has_channel(wpa_s->global, mode, op_class,
+ res2 = has_channel(wpa_s, mode, op_class,
channel - 4, NULL);
else
- res2 = has_channel(wpa_s->global, mode, op_class,
+ res2 = has_channel(wpa_s, mode, op_class,
channel + 4, NULL);
} else if (bw == BW80) {
res2 = wpas_p2p_verify_80mhz(wpa_s, mode, op_class, channel,
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index bf145de89..7257805a0 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -206,6 +206,8 @@ void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
enum wpas_p2p_channel_update_trig trig);
+bool wpas_p2p_go_concurrent_allowed(struct wpa_supplicant *wpa_s,
+ unsigned int freq);
void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
int freq_24, int freq_5, int freq_overall);
@@ -290,6 +292,12 @@ wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
{
}
+static inline bool
+wpas_p2p_go_concurrent_allowed(struct wpa_supplicant *wpa_s, unsigned int freq)
+{
+ return false;
+}
+
static inline void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
int freq_24, int freq_5,
int freq_overall)
--
2.56.0
More information about the Hostap
mailing list