From fa6cd439890d98927cc5d229a5a9ce63d85d38e2 Mon Sep 17 00:00:00 2001 From: Peddolla Harshavardhan Reddy Date: Sat, 26 Apr 2025 23:54:43 +0530 Subject: [PATCH] PR: Add NTB capabilities in USD PR element 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 --- src/common/proximity_ranging.c | 75 ++++++++++++++++++++++++++++++++++ src/common/proximity_ranging.h | 54 ++++++++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c index 15c71cd4e..8eb951eb2 100644 --- a/src/common/proximity_ranging.c +++ b/src/common/proximity_ranging.c @@ -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); diff --git a/src/common/proximity_ranging.h b/src/common/proximity_ranging.h index b87030629..830ac5f8b 100644 --- a/src/common/proximity_ranging.h +++ b/src/common/proximity_ranging.h @@ -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, -- 2.47.3