]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
PR: Add EDCA capabilities in USD PR element
authorPeddolla Harshavardhan Reddy <peddolla@qti.qualcomm.com>
Sat, 26 Apr 2025 18:21:45 +0000 (23:51 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 17 Oct 2025 10:22:51 +0000 (13:22 +0300)
Create a buffer that contains EDCA (802.11mc) based ranging capabilities
of a device which will be part of a Proximity Ranging element used to
advertise ranging capabilities of a device. These capabilities are added
to USD frames to enable their exchange with peer devices. The EDCA based
ranging capabilities have attributes such as the ability to act as an
EDCA based ranging initiator, the ability to act as a EDCA based ranging
responder, the channels on which the EDCA Ranging is supported by the
device and other device specific capabilities.

Signed-off-by: Peddolla Harshavardhan Reddy <peddolla@qti.qualcomm.com>
src/common/proximity_ranging.c
src/common/proximity_ranging.h

index a41c1005d3bcf789bf619f084a6110f2755a106f..15c71cd4e506af19cb3d79635e1b59d585e800c7 100644 (file)
@@ -161,6 +161,48 @@ 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_FORMAT_AND_BW;
+       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,
+                                   const struct pr_channels *chan)
+{
+       size_t i;
+
+       wpabuf_put_data(buf, country, 3); /* Country String */
+       wpabuf_put(buf, chan->op_classes); /* Number of Channel Entries */
+
+       /* Channel Entry List */
+       for (i = 0; i < chan->op_classes; i++) {
+               const struct pr_op_class *c = &chan->op_class[i];
+
+               wpabuf_put_u8(buf, c->op_class);
+               wpabuf_put_u8(buf, c->channels);
+               wpabuf_put_data(buf, c->channel, c->channels);
+       }
+}
+
+
 static void pr_buf_add_ranging_capa_info(struct wpabuf *buf,
                                         const struct pr_capabilities *capab)
 {
@@ -201,6 +243,36 @@ static void pr_buf_add_ranging_capa_info(struct wpabuf *buf,
 }
 
 
+static void pr_buf_add_edca_capa_info(struct wpabuf *buf,
+                                     const struct edca_capabilities *edca_data)
+{
+       u8 *len;
+       u8 ranging_role = 0;
+       size_t _len;
+
+       /* Proximity Ranging EDCA Capability Attribute */
+       wpabuf_put_u8(buf, PR_ATTR_EDCA_CAPABILITY);
+       len = wpabuf_put(buf, 2); /* Attribute length to be filled */
+
+       /* Ranging Role */
+       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);
+
+       /* Ranging Parameters */
+       wpabuf_put_le16(buf, edca_data->edca_hw_caps);
+
+       pr_buf_add_channel_list(buf, edca_data->country, &edca_data->channels);
+
+       _len = (u8 *) wpabuf_put(buf, 0) - len - 2;
+       WPA_PUT_LE16(len, _len);
+       wpa_hexdump(MSG_DEBUG, "PR: * EDCA Capability Attribute",
+                   len + 2, _len);
+}
+
+
 struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr)
 {
        u32 ie_type;
@@ -214,6 +286,13 @@ struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr)
        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) {
+               struct edca_capabilities edca_caps;
+
+               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_elem(buf, ie_type);
        wpabuf_free(buf);
index f2f0ca488eee07e52925e8b22a80e61e0c06da2f..b87030629164c9bc173831351a5f04c448f94e74 100644 (file)
@@ -105,6 +105,30 @@ struct pr_capabilities {
        bool support_6ghz;
 };
 
+struct edca_capabilities {
+       bool ista_support;
+
+       bool rsta_support;
+
+/**
+ * Ranging Parameters field for device specific EDCA capabilities
+ * Proximity Ranging Implementation Considerations for P2P Operation Draft 1.8,
+ * Table 8 (Proximity Ranging EDCA Capability Attribute format).
+ */
+#define EDCA_FORMAT_AND_BW  0
+#define EDCA_MAX_TX_ANTENNA 4
+#define EDCA_MAX_RX_ANTENNA 7
+
+#define EDCA_FORMAT_AND_BW_MASK  0x000F
+#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;
+};
+
 /*
  * Proximity Ranging Attribute IDs
  * Proximity Ranging Implementation Considerations for P2P Operation Draft 1.8,
@@ -130,6 +154,14 @@ enum pr_attr_id {
 #define PR_NTB_SECURE_LTF_BASED_RANGING BIT(1)
 #define PR_NTB_OPEN_BASED_RANGING BIT(2)
 
+/**
+ * Ranging Role field in EDCA capabilities
+ * Proximity Ranging Implementation Considerations for P2P Operation Draft 1.8,
+ * Table 8 (Proximity Ranging EDCA Capability Attribute format).
+ */
+#define PR_ISTA_SUPPORT BIT(0)
+#define PR_RSTA_SUPPORT BIT(1)
+
 /**
  * struct pr_device_info - Proximity ranging peer information
  */