[RFC PATCH 06/34] API to add EDCA capabilities in USD PR IE

Peddolla Harshavardhan Reddy peddolla at qti.qualcomm.com
Thu May 15 00:17:29 PDT 2025


Signed-off-by: Peddolla Harshavardhan Reddy <peddolla at qti.qualcomm.com>
---
 src/common/proximity_ranging.c | 77 ++++++++++++++++++++++++++++++++++
 src/common/proximity_ranging.h | 24 +++++++++++
 2 files changed, 101 insertions(+)

diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c
index c39753b33..5e0872749 100644
--- a/src/common/proximity_ranging.c
+++ b/src/common/proximity_ranging.c
@@ -163,6 +163,53 @@ static void pr_get_ranging_capabilities(struct pr_data *pr,
 }
 
 
+static void pr_get_edca_capabilities(struct pr_data *pr,
+				     struct edca_capabilities *capab)
+{
+	u16 edca_hw_caps = 0;
+
+	os_memset(capab, 0, sizeof(struct edca_capabilities));
+	capab->ista_support = pr->cfg->edca_ista_support;
+	capab->rsta_support = pr->cfg->edca_rsta_support;
+	os_memcpy(capab->country, pr->cfg->country, 3);
+
+	edca_hw_caps |= (pr->cfg->edca_format_and_bw & EDCA_FORMAT_AND_BW_MASK);
+	edca_hw_caps |= ((pr->cfg->max_tx_antenna & EDCA_MAX_TX_ANTENNA_MASK) << EDCA_MAX_TX_ANTENNA);
+	edca_hw_caps |= ((pr->cfg->max_rx_antenna & EDCA_MAX_RX_ANTENNA_MASK) << EDCA_MAX_RX_ANTENNA);
+
+	capab->edca_hw_caps = edca_hw_caps;
+	os_memcpy(&capab->channels, &pr->cfg->edca_channels,
+		  sizeof(struct pr_channels));
+}
+
+
+static void pr_buf_add_channel_list(struct wpabuf *buf, const char *country,
+				    struct pr_channels *chan)
+{
+	u8 *len;
+	size_t i;
+
+	wpabuf_put_data(buf, country, 3);
+	len = wpabuf_put(buf, 1); /* IE length to be filled */
+
+	/* Channel List */
+	for (i = 0; i < chan->reg_classes; i++) {
+		struct pr_reg_class *c = &chan->reg_class[i];
+
+		//if (is_6ghz_op_class(c->reg_class) && !is_6ghz_capab)
+		//	continue;
+		wpabuf_put_u8(buf, c->reg_class);
+		wpabuf_put_u8(buf, c->channels);
+		wpabuf_put_data(buf, c->channel, c->channels);
+	}
+
+	/* Update attribute length */
+	*len = chan->reg_classes;
+	wpa_hexdump(MSG_DEBUG, "PR: * Channel List",
+		    len + 1, (u8 *) wpabuf_put(buf, 0) - len - 1);
+}
+
+
 static void pr_buf_add_ranging_capa_info(struct wpabuf *buf,
 					 struct pr_capabilities *capab)
 {
@@ -202,11 +249,36 @@ static void pr_buf_add_ranging_capa_info(struct wpabuf *buf,
 }
 
 
+static void pr_buf_add_edca_capa_info(struct wpabuf *buf,
+				      struct edca_capabilities *edca_data)
+{
+	u8 *len;
+	u8 ranging_role = 0;
+
+	wpabuf_put_u8(buf, PR_ATTR_EDCA_CAPABILITY);
+	len = wpabuf_put(buf, 2);
+
+	if (edca_data->ista_support)
+		ranging_role |= PR_ISTA_SUPPORT;
+	if (edca_data->rsta_support)
+		ranging_role |= PR_RSTA_SUPPORT;
+
+	wpabuf_put_u8(buf, ranging_role);
+	wpabuf_put_be16(buf, edca_data->edca_hw_caps);
+	pr_buf_add_channel_list(buf, edca_data->country, &edca_data->channels);
+
+	WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
+	wpa_hexdump(MSG_DEBUG, "PR: * EDCA data",
+		    len + 2, (u8 *) wpabuf_put(buf, 0) - len - 2);
+}
+
+
 struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr, const char *country)
 {
 	u32 ie_type;
 	struct wpabuf *buf, *buf2;
 	struct pr_capabilities pr_caps;
+	struct edca_capabilities edca_caps;
 
 	buf = wpabuf_alloc(1000);
 	if (!buf)
@@ -215,6 +287,11 @@ struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr, const char *country)
 	pr_get_ranging_capabilities(pr, &pr_caps);
 	pr_buf_add_ranging_capa_info(buf, &pr_caps);
 
+	if (pr->cfg->edca_ista_support || pr->cfg->edca_rsta_support) {
+		pr_get_edca_capabilities(pr, &edca_caps);
+		pr_buf_add_edca_capa_info(buf, &edca_caps);
+	}
+
 	ie_type = (OUI_WFA << 8) | PR_OUI_TYPE;
 	buf2 = pr_encaps_ie(buf, ie_type);
 	wpabuf_free(buf);
diff --git a/src/common/proximity_ranging.h b/src/common/proximity_ranging.h
index 0d31fb1a0..0b3dc0a06 100644
--- a/src/common/proximity_ranging.h
+++ b/src/common/proximity_ranging.h
@@ -28,6 +28,7 @@
  */
 #define PR_MAX_PEER 100
 
+
 /**
  * struct pr_channels - List of supported channels
  */
@@ -72,6 +73,25 @@ struct pr_capabilities {
 	bool support_6ghz;
 };
 
+struct edca_capabilities {
+	bool ista_support;
+
+	bool rsta_support;
+
+#define EDCA_FORMAT_AND_BW  0
+#define EDCA_MAX_TX_ANTENNA 6
+#define EDCA_MAX_RX_ANTENNA 9
+
+#define EDCA_FORMAT_AND_BW_MASK  0x003F
+#define EDCA_MAX_TX_ANTENNA_MASK 0x0007
+#define EDCA_MAX_RX_ANTENNA_MASK 0x0007
+	u16 edca_hw_caps;
+
+	char country[3];
+
+	struct pr_channels channels;
+};
+
 
 enum pr_attr_id {
 	PR_ATTR_STATUS = 0,
@@ -89,6 +109,10 @@ enum pr_attr_id {
 #define PR_NTB_SECURE_LTF_BASED_RANGING BIT(1)
 #define PR_NTB_OPEN_BASED_RANGING BIT(2)
 
+/* Initiator and Responder support */
+#define PR_ISTA_SUPPORT BIT(0)
+#define PR_RSTA_SUPPORT BIT(1)
+
 /**
  * struct pr_device_info - Proximity ranging peer information
  */
-- 
2.34.1




More information about the Hostap mailing list