[PATCH 13/16] PR: Prefer higher band when selecting best channel at equal bandwidth

Peddolla Harshavardhan Reddy peddolla.reddy at oss.qualcomm.com
Sun Jul 12 23:30:01 PDT 2026


Currently pr_choose_best_channel() picks the first channel it finds
with the highest bandwidth, with no tiebreaker when two op classes
offer the same bandwidth on different bands.

Add pr_op_class_band_priority() to assign a preference value by band
(6 GHz = 2, 5 GHz = 1, 2.4 GHz = 0) and use it as a tiebreaker in
pr_choose_best_channel() so that among op classes with equal bandwidth
a higher-band channel is preferred.

Signed-off-by: Peddolla Harshavardhan Reddy <peddolla.reddy at oss.qualcomm.com>
---
 src/common/proximity_ranging.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c
index 40abf9809..2df768e1c 100644
--- a/src/common/proximity_ranging.c
+++ b/src/common/proximity_ranging.c
@@ -1425,11 +1425,29 @@ static void pr_process_op_mode(const u8 *caps, size_t caps_len,
 }
 
 
+/* pr_op_class_band_priority - Return band preference for channel selection
+ *
+ * Higher value means higher preference when bandwidth is equal:
+ *   0 = 2.4 GHz
+ *   1 = 5 GHz
+ *   2 = 6 GHz
+ */
+static int pr_op_class_band_priority(const struct oper_class_map *map)
+{
+	if (is_6ghz_op_class(map->op_class))
+		return 2;
+	if (map->mode == HOSTAPD_MODE_IEEE80211A)
+		return 1;
+	return 0;
+}
+
+
 static void pr_choose_best_channel(struct pr_channels *common_channel,
 				   u8 *op_class, u8 *op_channel)
 {
-	int bw;
+	int bw, band;
 	int max_bw = 0;
+	int max_band = -1;
 	const struct oper_class_map *map;
 	size_t i;
 
@@ -1448,10 +1466,12 @@ static void pr_choose_best_channel(struct pr_channels *common_channel,
 		if (!map)
 			continue;
 		bw = oper_class_bw_to_int(map);
-		if (bw > max_bw) {
+		band = pr_op_class_band_priority(map);
+		if (bw > max_bw || (bw == max_bw && band > max_band)) {
 			*op_class = common_channel->op_class[i].op_class;
 			*op_channel = common_channel->op_class[i].channel[0];
 			max_bw = bw;
+			max_band = band;
 		}
 	}
 
-- 
2.34.1




More information about the Hostap mailing list