]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
PR: Add NTB capabilities in USD PR element
authorPeddolla Harshavardhan Reddy <peddolla@qti.qualcomm.com>
Sat, 26 Apr 2025 18:24:43 +0000 (23:54 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 17 Oct 2025 10:22:51 +0000 (13:22 +0300)
Create a buffer that contains the NTB (802.11az) ranging capabilities of
a device. This buffer will be part of the Proximity Ranging Information
element used to advertise the device's ranging capabilities. These
capabilities are added to USD frames to enable their exchange with peer
devices.

The NTB-based ranging capabilities include attributes such as the
ability to act as an NTB ranging initiator, the ability to act as an NTB
ranging responder, the channels on which NTB 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 15c71cd4e506af19cb3d79635e1b59d585e800c7..8eb951eb28d9604c1328d01ecd036ef0a4d602b4 100644 (file)
@@ -184,6 +184,45 @@ static void pr_get_edca_capabilities(struct pr_data *pr,
 }
 
 
+static void pr_get_ntb_capabilities(struct pr_data *pr,
+                                   struct ntb_capabilities *capab)
+{
+       u32 ntb_hw_caps = 0;
+
+       os_memset(capab, 0, sizeof(struct ntb_capabilities));
+       capab->ista_support = pr->cfg->ntb_ista_support;
+       capab->rsta_support = pr->cfg->ntb_rsta_support;
+       os_memcpy(capab->country, pr->cfg->country, 3);
+       capab->secure_he_ltf = pr->cfg->secure_he_ltf;
+
+       ntb_hw_caps |= (pr->cfg->ntb_format_and_bw & NTB_FORMAT_AND_BW_MASK) <<
+               NTB_FORMAT_AND_BW;
+       ntb_hw_caps |= (pr->cfg->max_tx_ltf_repetations &
+                       MAX_TX_LTF_REPETATIONS_MASK) << MAX_TX_LTF_REPETATIONS;
+       ntb_hw_caps |= (pr->cfg->max_rx_ltf_repetations &
+                       MAX_RX_LTF_REPETATIONS_MASK) << MAX_RX_LTF_REPETATIONS;
+
+       ntb_hw_caps |= (pr->cfg->max_rx_ltf_total & MAX_RX_LTF_TOTAL_MASK) <<
+               MAX_RX_LTF_TOTAL;
+       ntb_hw_caps |= (pr->cfg->max_tx_ltf_total & MAX_TX_LTF_TOTAL_MASK) <<
+               MAX_TX_LTF_TOTAL;
+
+       ntb_hw_caps |= (pr->cfg->max_rx_sts_le_80 & MAX_RX_STS_LE_80_MASK) <<
+               MAX_RX_STS_LE_80;
+       ntb_hw_caps |= (pr->cfg->max_rx_sts_gt_80 & MAX_RX_STS_GT_80_MASK) <<
+               MAX_RX_STS_GT_80;
+
+       ntb_hw_caps |= (pr->cfg->max_tx_sts_le_80 & MAX_TX_STS_LE_80_MASK) <<
+               MAX_TX_STS_LE_80;
+       ntb_hw_caps |= (pr->cfg->max_tx_sts_gt_80 & MAX_TX_STS_GT_80_MASK) <<
+               MAX_TX_STS_GT_80;
+
+       capab->ntb_hw_caps = ntb_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)
 {
@@ -273,6 +312,35 @@ static void pr_buf_add_edca_capa_info(struct wpabuf *buf,
 }
 
 
+static void pr_buf_add_ntb_capa_info(struct wpabuf *buf,
+                                    const struct ntb_capabilities *ntb_data)
+{
+       u8 *len;
+       u8 ranging_role = 0;
+       size_t _len;
+
+       /* Proximity Ranging 11az NTB Capability Attribute */
+       wpabuf_put_u8(buf, PR_ATTR_NTB_CAPABILITY);
+       len = wpabuf_put(buf, 2);
+
+       /* Ranging Role */
+       if (ntb_data->ista_support)
+               ranging_role |= PR_ISTA_SUPPORT;
+       if (ntb_data->rsta_support)
+               ranging_role |= PR_RSTA_SUPPORT;
+       wpabuf_put_u8(buf, ranging_role);
+
+       /* Ranging Parameter */
+       wpabuf_put_le32(buf, ntb_data->ntb_hw_caps);
+
+       pr_buf_add_channel_list(buf, ntb_data->country, &ntb_data->channels);
+
+       _len = (u8 *) wpabuf_put(buf, 0) - len - 2;
+       WPA_PUT_LE16(len, _len);
+       wpa_hexdump(MSG_DEBUG, "PR: * NTB Capability Attribute", len + 2, _len);
+}
+
+
 struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr)
 {
        u32 ie_type;
@@ -293,6 +361,13 @@ struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr)
                pr_buf_add_edca_capa_info(buf, &edca_caps);
        }
 
+       if (pr->cfg->ntb_ista_support || pr->cfg->ntb_rsta_support) {
+               struct ntb_capabilities ntb_caps;
+
+               pr_get_ntb_capabilities(pr, &ntb_caps);
+               pr_buf_add_ntb_capa_info(buf, &ntb_caps);
+       }
+
        ie_type = (OUI_WFA << 8) | PR_OUI_TYPE;
        buf2 = pr_encaps_elem(buf, ie_type);
        wpabuf_free(buf);
index b87030629164c9bc173831351a5f04c448f94e74..830ac5f8b4c4445e7a4dd55883a235137023b6d9 100644 (file)
@@ -129,6 +129,60 @@ struct edca_capabilities {
        struct pr_channels channels;
 };
 
+struct ntb_capabilities {
+       bool ista_support;
+
+       bool rsta_support;
+
+       bool secure_he_ltf;
+
+/**
+ * Ranging Parameter field for NTB capabilities
+ * Proximity Ranging Implementation Considerations for P2P Operation Draft 1.8,
+ * Table 9 (Proximity Ranging 11az NTB Capability Attribute format).
+ */
+#define NTB_FORMAT_AND_BW      0
+#define MAX_TX_LTF_REPETATIONS 3
+#define MAX_RX_LTF_REPETATIONS 6
+#define MAX_RX_LTF_TOTAL       9
+#define MAX_TX_LTF_TOTAL       11
+#define MAX_RX_STS_LE_80       13
+#define MAX_RX_STS_GT_80       16
+#define MAX_TX_STS_LE_80       19
+#define MAX_TX_STS_GT_80       22
+
+#define NTB_FORMAT_AND_BW_MASK  0x00000007
+
+/* Max TX LTF repetations supported for non trigger based ranging */
+#define MAX_TX_LTF_REPETATIONS_MASK    0x00000007
+
+/* Max RX LTF repetations supported for non trigger based ranging */
+#define MAX_RX_LTF_REPETATIONS_MASK    0x00000007
+
+/* Max RX LTF total supported for non trigger based ranging */
+#define MAX_RX_LTF_TOTAL_MASK          0x00000003
+
+/* Max TX LTF total supported for non trigger based ranging */
+#define MAX_TX_LTF_TOTAL_MASK          0x00000003
+
+/* To configure max R2I STS for Bandwidth less than or equal to 80 MHz */
+#define MAX_RX_STS_LE_80_MASK          0x00000007
+
+/* To configure max R2I STS for Bandwidth greater than 80Mz */
+#define MAX_RX_STS_GT_80_MASK          0x00000007
+
+/* To configure max I2R STS for Bandwidth less than or equal to 80 MHz */
+#define MAX_TX_STS_LE_80_MASK          0x00000007
+
+/* To configure max I2R STS for Bandwidth greater than 80 MHz */
+#define MAX_TX_STS_GT_80_MASK          0x00000007
+       u32 ntb_hw_caps;
+
+       char country[3];
+
+       struct pr_channels channels;
+};
+
 /*
  * Proximity Ranging Attribute IDs
  * Proximity Ranging Implementation Considerations for P2P Operation Draft 1.8,