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

Peddolla Harshavardhan Reddy peddolla.reddy at oss.qualcomm.com
Fri Jul 31 02:52:27 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() as a tiebreaker so that among op
classes with equal bandwidth a higher-band channel is preferred
(6 GHz > 5 GHz > 2.4 GHz). Higher bands usually provide higher
throughput due to less congestion and interference compared to the
2.4 GHz band, making them a more suitable choice for ranging when
bandwidth is equal.

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 bc177d50d..86418ac30 100644
--- a/src/common/proximity_ranging.c
+++ b/src/common/proximity_ranging.c
@@ -1414,11 +1414,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;
 
@@ -1437,10 +1455,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