mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
nFAPI: Add SRS TOAs from multiple antennas as vendor extension in nFAPI
Currently, SCF doesnt support the distributed antenna scenario, where, antennas can be distributed and multiple valid timing advance offset nsec values can be generated and would require to be sent over fapi. Therefore, we add this specific scenario as a vendor extension without impacting the exisiting FAPI messages. We require this scenario for the positioning, where, distribute multiple antennas are used for ToA estimation at different locations. We also add a unit test for this message. Signed-off-by: Rakesh Mundlamuri <rakesh.mundlamuri@openairinterface.org>
This commit is contained in:
@@ -30,6 +30,8 @@ uint8_t pack_nr_uci_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *e
|
||||
uint8_t unpack_nr_uci_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg);
|
||||
uint8_t pack_nr_srs_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg);
|
||||
uint8_t pack_nr_srs_toa_vendor_ext_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
uint8_t unpack_nr_srs_toa_vendor_ext_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg);
|
||||
uint8_t unpack_nr_srs_report_tlv_value(nfapi_srs_report_tlv_t *report_tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
|
||||
uint8_t pack_nr_rach_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
uint8_t unpack_nr_rach_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg);
|
||||
|
||||
@@ -23,6 +23,8 @@ bool eq_rx_data_indication(const nfapi_nr_rx_data_indication_t *a, const nfapi_n
|
||||
bool eq_crc_indication(const nfapi_nr_crc_indication_t *a, const nfapi_nr_crc_indication_t *b);
|
||||
bool eq_uci_indication(const nfapi_nr_uci_indication_t *a, const nfapi_nr_uci_indication_t *b);
|
||||
bool eq_srs_indication(const nfapi_nr_srs_indication_t *a, const nfapi_nr_srs_indication_t *b);
|
||||
bool eq_srs_toa_vendor_ext_indication(const nfapi_nr_srs_toa_vendor_ext_indication_t *a,
|
||||
const nfapi_nr_srs_toa_vendor_ext_indication_t *b);
|
||||
bool eq_rach_indication(const nfapi_nr_rach_indication_t *a, const nfapi_nr_rach_indication_t *b);
|
||||
|
||||
void free_dl_tti_request(nfapi_nr_dl_tti_request_t *msg);
|
||||
@@ -34,6 +36,7 @@ void free_rx_data_indication(nfapi_nr_rx_data_indication_t *msg);
|
||||
void free_crc_indication(nfapi_nr_crc_indication_t *msg);
|
||||
void free_uci_indication(nfapi_nr_uci_indication_t *msg);
|
||||
void free_srs_indication(nfapi_nr_srs_indication_t *msg);
|
||||
void free_srs_toa_vendor_ext_indication(nfapi_nr_srs_toa_vendor_ext_indication_t *msg);
|
||||
void free_rach_indication(nfapi_nr_rach_indication_t *msg);
|
||||
|
||||
void copy_dl_tti_request(const nfapi_nr_dl_tti_request_t *src, nfapi_nr_dl_tti_request_t *dst);
|
||||
@@ -45,6 +48,8 @@ void copy_rx_data_indication(const nfapi_nr_rx_data_indication_t *src, nfapi_nr_
|
||||
void copy_crc_indication(const nfapi_nr_crc_indication_t *src, nfapi_nr_crc_indication_t *dst);
|
||||
void copy_uci_indication(const nfapi_nr_uci_indication_t *src, nfapi_nr_uci_indication_t *dst);
|
||||
void copy_srs_indication(const nfapi_nr_srs_indication_t *src, nfapi_nr_srs_indication_t *dst);
|
||||
void copy_srs_toa_vendor_ext_indication(const nfapi_nr_srs_toa_vendor_ext_indication_t *src,
|
||||
nfapi_nr_srs_toa_vendor_ext_indication_t *dst);
|
||||
void copy_rach_indication(const nfapi_nr_rach_indication_t *src, nfapi_nr_rach_indication_t *dst);
|
||||
|
||||
|
||||
@@ -53,6 +58,7 @@ size_t get_rx_data_indication_size(const nfapi_nr_rx_data_indication_t *msg);
|
||||
size_t get_crc_indication_size(const nfapi_nr_crc_indication_t *msg);
|
||||
size_t get_uci_indication_size(const nfapi_nr_uci_indication_t *msg);
|
||||
size_t get_srs_indication_size(const nfapi_nr_srs_indication_t *msg);
|
||||
size_t get_srs_toa_vendor_ext_indication_size(const nfapi_nr_srs_toa_vendor_ext_indication_t *msg);
|
||||
size_t get_rach_indication_size(nfapi_nr_rach_indication_t *msg);
|
||||
|
||||
void dump_dl_tti_request(const nfapi_nr_dl_tti_request_t *msg);
|
||||
@@ -64,6 +70,7 @@ void dump_rx_data_indication(const nfapi_nr_rx_data_indication_t *msg);
|
||||
void dump_crc_indication(const nfapi_nr_crc_indication_t *msg);
|
||||
void dump_uci_indication(const nfapi_nr_uci_indication_t *msg);
|
||||
void dump_srs_indication(const nfapi_nr_srs_indication_t *msg);
|
||||
void dump_srs_toa_vendor_ext_indication(const nfapi_nr_srs_toa_vendor_ext_indication_t *msg);
|
||||
void dump_rach_indication(const nfapi_nr_rach_indication_t *msg);
|
||||
|
||||
#endif // OPENAIRINTERFACE_NR_FAPI_P7_UTILS_H
|
||||
|
||||
@@ -130,6 +130,10 @@ int check_nr_fapi_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpacked
|
||||
if (unpackedBufLen >= sizeof(nfapi_nr_srs_indication_t))
|
||||
retLen = sizeof(nfapi_nr_srs_indication_t);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION:
|
||||
if (unpackedBufLen >= sizeof(nfapi_nr_srs_toa_vendor_ext_indication_t))
|
||||
retLen = sizeof(nfapi_nr_srs_toa_vendor_ext_indication_t);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
|
||||
if (unpackedBufLen >= sizeof(nfapi_nr_dl_node_sync_t))
|
||||
retLen = sizeof(nfapi_nr_dl_node_sync_t);
|
||||
|
||||
@@ -42,6 +42,9 @@ uint8_t fapi_nr_p7_message_body_pack(nfapi_nr_p7_message_header_t *header,
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION:
|
||||
result = pack_nr_srs_indication(header, ppWritePackedMsg, end);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION:
|
||||
result = pack_nr_srs_toa_vendor_ext_indication(header, ppWritePackedMsg, end);
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
result = pack_nr_rach_indication(header, ppWritePackedMsg, end);
|
||||
break;
|
||||
@@ -191,6 +194,11 @@ bool fapi_nr_p7_message_unpack(void *pMessageBuf,
|
||||
result = unpack_nr_srs_indication(&pReadPackedMessage, end, pMessageHeader);
|
||||
}
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION:
|
||||
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION, unpackedBufLen)) {
|
||||
result = unpack_nr_srs_toa_vendor_ext_indication(&pReadPackedMessage, end, pMessageHeader);
|
||||
}
|
||||
break;
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION, unpackedBufLen)) {
|
||||
result = unpack_nr_rach_indication(&pReadPackedMessage, end, pMessageHeader);
|
||||
@@ -2403,6 +2411,29 @@ uint8_t pack_nr_srs_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *e
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t pack_nr_srs_toa_vendor_ext_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end)
|
||||
{
|
||||
nfapi_nr_srs_toa_vendor_ext_indication_t *pNfapiMsg = (nfapi_nr_srs_toa_vendor_ext_indication_t *)msg;
|
||||
|
||||
if (!(push16(pNfapiMsg->sfn, ppWritePackedMsg, end) && push16(pNfapiMsg->slot, ppWritePackedMsg, end)
|
||||
&& push16(pNfapiMsg->rnti, ppWritePackedMsg, end) && push8(pNfapiMsg->num_ta, ppWritePackedMsg, end))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
AssertFatal(pNfapiMsg->num_ta <= NFAPI_NR_MAX_NUM_TA_NSEC,
|
||||
"pNfapiMsg->num_ta %d cannot be greater than %d\n",
|
||||
pNfapiMsg->num_ta,
|
||||
NFAPI_NR_MAX_NUM_TA_NSEC);
|
||||
|
||||
for (int i = 0; i < pNfapiMsg->num_ta; i++) {
|
||||
if (!pushs16(pNfapiMsg->ta_offset_nsec[i], ppWritePackedMsg, end)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t unpack_nr_srs_report_tlv_value(nfapi_srs_report_tlv_t *report_tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
|
||||
{
|
||||
#ifndef ENABLE_AERIAL
|
||||
@@ -2474,6 +2505,28 @@ uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t unpack_nr_srs_toa_vendor_ext_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg)
|
||||
{
|
||||
nfapi_nr_srs_toa_vendor_ext_indication_t *pNfapiMsg = (nfapi_nr_srs_toa_vendor_ext_indication_t *)msg;
|
||||
if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn, end) && pull16(ppReadPackedMsg, &pNfapiMsg->slot, end)
|
||||
&& pull16(ppReadPackedMsg, &pNfapiMsg->rnti, end) && pull8(ppReadPackedMsg, &pNfapiMsg->num_ta, end))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
AssertFatal(pNfapiMsg->num_ta <= NFAPI_NR_MAX_NUM_TA_NSEC,
|
||||
"pNfapiMsg->num_ta %d cannot be greater than %d\n",
|
||||
pNfapiMsg->num_ta,
|
||||
NFAPI_NR_MAX_NUM_TA_NSEC);
|
||||
|
||||
for (int i = 0; i < pNfapiMsg->num_ta; i++) {
|
||||
if (!pulls16(ppReadPackedMsg, &pNfapiMsg->ta_offset_nsec[i], end)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint8_t pack_nr_rach_indication_body(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
|
||||
{
|
||||
nfapi_nr_prach_indication_pdu_t *value = (nfapi_nr_prach_indication_pdu_t *)tlv;
|
||||
|
||||
@@ -808,6 +808,21 @@ bool eq_srs_indication(const nfapi_nr_srs_indication_t *a, const nfapi_nr_srs_in
|
||||
return true;
|
||||
}
|
||||
|
||||
bool eq_srs_toa_vendor_ext_indication(const nfapi_nr_srs_toa_vendor_ext_indication_t *a,
|
||||
const nfapi_nr_srs_toa_vendor_ext_indication_t *b)
|
||||
{
|
||||
EQ(a->header.message_id, b->header.message_id);
|
||||
EQ(a->header.message_length, b->header.message_length);
|
||||
EQ(a->sfn, b->sfn);
|
||||
EQ(a->slot, b->slot);
|
||||
EQ(a->rnti, b->rnti);
|
||||
EQ(a->num_ta, b->num_ta);
|
||||
for (int ta_idx = 0; ta_idx < a->num_ta; ++ta_idx) {
|
||||
EQ(a->ta_offset_nsec[ta_idx], b->ta_offset_nsec[ta_idx]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool eq_rach_indication_PDU(const nfapi_nr_prach_indication_pdu_t *a, const nfapi_nr_prach_indication_pdu_t *b)
|
||||
{
|
||||
EQ(a->phy_cell_id, b->phy_cell_id);
|
||||
@@ -964,6 +979,12 @@ void free_srs_indication(nfapi_nr_srs_indication_t *msg)
|
||||
free(msg->pdu_list);
|
||||
}
|
||||
|
||||
void free_srs_toa_vendor_ext_indication(nfapi_nr_srs_toa_vendor_ext_indication_t *msg)
|
||||
{
|
||||
// Nothing to free
|
||||
UNUSED(msg);
|
||||
}
|
||||
|
||||
void free_rach_indication(nfapi_nr_rach_indication_t *msg)
|
||||
{
|
||||
free(msg->pdu_list);
|
||||
@@ -1740,6 +1761,20 @@ void copy_srs_indication(const nfapi_nr_srs_indication_t *src, nfapi_nr_srs_indi
|
||||
}
|
||||
}
|
||||
|
||||
void copy_srs_toa_vendor_ext_indication(const nfapi_nr_srs_toa_vendor_ext_indication_t *src,
|
||||
nfapi_nr_srs_toa_vendor_ext_indication_t *dst)
|
||||
{
|
||||
dst->header.message_id = src->header.message_id;
|
||||
dst->header.message_length = src->header.message_length;
|
||||
dst->sfn = src->sfn;
|
||||
dst->slot = src->slot;
|
||||
dst->rnti = src->rnti;
|
||||
dst->num_ta = src->num_ta;
|
||||
for (int ta_idx = 0; ta_idx < src->num_ta; ++ta_idx) {
|
||||
memcpy(dst->ta_offset_nsec, src->ta_offset_nsec, sizeof(dst->ta_offset_nsec));
|
||||
}
|
||||
}
|
||||
|
||||
size_t get_srs_indication_size(const nfapi_nr_srs_indication_t *msg)
|
||||
{
|
||||
// Get size of the message (allocated pointer included)
|
||||
@@ -1756,6 +1791,22 @@ size_t get_srs_indication_size(const nfapi_nr_srs_indication_t *msg)
|
||||
return total_size;
|
||||
}
|
||||
|
||||
size_t get_srs_toa_vendor_ext_indication_size(const nfapi_nr_srs_toa_vendor_ext_indication_t *msg)
|
||||
{
|
||||
// Get size of the message (allocated pointer included)
|
||||
size_t total_size = 0;
|
||||
|
||||
// Header and fixed-size fields
|
||||
total_size += sizeof(msg->header);
|
||||
total_size += sizeof(msg->sfn);
|
||||
total_size += sizeof(msg->slot);
|
||||
total_size += sizeof(msg->rnti);
|
||||
total_size += sizeof(msg->num_ta);
|
||||
total_size += sizeof(msg->ta_offset_nsec);
|
||||
|
||||
return total_size;
|
||||
}
|
||||
|
||||
static void copy_rach_indication_PDU(const nfapi_nr_prach_indication_pdu_t *src, nfapi_nr_prach_indication_pdu_t *dst)
|
||||
{
|
||||
dst->phy_cell_id = src->phy_cell_id;
|
||||
@@ -2687,6 +2738,21 @@ void dump_srs_indication(const nfapi_nr_srs_indication_t *msg)
|
||||
}
|
||||
}
|
||||
|
||||
void dump_srs_toa_vendor_ext_indication(const nfapi_nr_srs_toa_vendor_ext_indication_t *msg)
|
||||
{
|
||||
int depth = 0;
|
||||
dump_p7_message_header(&msg->header, depth);
|
||||
depth++;
|
||||
INDENTED_PRINTF("SFN = %d\n", msg->sfn);
|
||||
INDENTED_PRINTF("Slot = %d\n", msg->slot);
|
||||
INDENTED_PRINTF("RNTI = 0x%02x\n", msg->rnti);
|
||||
INDENTED_PRINTF("Number of TA_NSEC = %d\n", msg->num_ta);
|
||||
depth++;
|
||||
for (int i = 0; i < msg->num_ta; i++) {
|
||||
INDENTED_PRINTF("Timing advance offset in nanoseconds [%d] = 0x%02x\n", i, msg->ta_offset_nsec[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void dump_rach_indication(const nfapi_nr_rach_indication_t *msg)
|
||||
{
|
||||
int depth = 0;
|
||||
|
||||
@@ -75,7 +75,8 @@ typedef enum {
|
||||
|
||||
NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC = 0x0180,
|
||||
NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC,
|
||||
NFAPI_NR_PHY_MSG_TYPE_TIMING_INFO
|
||||
NFAPI_NR_PHY_MSG_TYPE_TIMING_INFO,
|
||||
NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION = 0x0300 // vendor extension for positioning
|
||||
} nfapi_nr_phy_msg_type_e;
|
||||
|
||||
// SCF222_5G-FAPI_PHY_SPI_Specificayion.pdf Section 3.3
|
||||
@@ -1979,6 +1980,15 @@ typedef struct {
|
||||
nfapi_nr_srs_indication_pdu_t *pdu_list;
|
||||
} nfapi_nr_srs_indication_t;
|
||||
|
||||
#define NFAPI_NR_MAX_NUM_TA_NSEC 32
|
||||
typedef struct {
|
||||
nfapi_nr_p7_message_header_t header;
|
||||
uint16_t sfn; // SFN. Value: 0 -> 1023
|
||||
uint16_t slot; // Slot. Value: 0 -> 159
|
||||
uint16_t rnti;
|
||||
uint8_t num_ta;
|
||||
int16_t ta_offset_nsec[NFAPI_NR_MAX_NUM_TA_NSEC];
|
||||
} nfapi_nr_srs_toa_vendor_ext_indication_t;
|
||||
|
||||
//3.4.11 rach_indication
|
||||
#define NFAPI_NR_RACH_IND_MAX_PDU 100
|
||||
|
||||
@@ -279,6 +279,10 @@ int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packe
|
||||
result = pack_nr_srs_indication(pMessageHeader, &pWritePackedMessage, end);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION:
|
||||
result = pack_nr_srs_toa_vendor_ext_indication(pMessageHeader, &pWritePackedMessage, end);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
result = pack_nr_rach_indication(pMessageHeader, &pWritePackedMessage, end);
|
||||
break;
|
||||
@@ -650,6 +654,12 @@ bool nfapi_nr_p7_message_unpack(void *pMessageBuf,
|
||||
}
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION:
|
||||
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION, unpackedBufLen)) {
|
||||
result = unpack_nr_srs_toa_vendor_ext_indication(&pReadPackedMessage, end, pMessageHeader);
|
||||
}
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION, unpackedBufLen)) {
|
||||
result = unpack_nr_rach_indication(&pReadPackedMessage, end, pMessageHeader);
|
||||
|
||||
@@ -61,6 +61,8 @@ char *message_id_to_str(uint32_t message_id)
|
||||
return "NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION";
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION:
|
||||
return "NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION";
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION:
|
||||
return "NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION";
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
return "NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION";
|
||||
default:
|
||||
@@ -173,6 +175,11 @@ void unpack_and_dump_message(void *buf, fapi_message_header_t hdr)
|
||||
free_srs_indication(unpacked_req);
|
||||
return;
|
||||
}
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION: {
|
||||
dump_srs_toa_vendor_ext_indication(unpacked_req);
|
||||
free_srs_toa_vendor_ext_indication(unpacked_req);
|
||||
return;
|
||||
}
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION: {
|
||||
dump_rach_indication(unpacked_req);
|
||||
free_rach_indication(unpacked_req);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: LicenseRef-CSSL-1.0
|
||||
|
||||
set(Test_Labels fapi p7)
|
||||
set(_fapi_p7_messages "dci_inversion;dl_tti_request;ul_tti_request;slot_indication;ul_dci_request;tx_data_request;rx_data_indication;crc_indication;uci_indication;srs_indication;rach_indication")
|
||||
set(_fapi_p7_messages "dci_inversion;dl_tti_request;ul_tti_request;slot_indication;ul_dci_request;tx_data_request;rx_data_indication;crc_indication;uci_indication;srs_indication;rach_indication;srs_toa_vendor_ext_indication")
|
||||
foreach (fapi_p7_message IN LISTS _fapi_p7_messages)
|
||||
add_executable(nr_fapi_${fapi_p7_message}_test nr_fapi_${fapi_p7_message}_test.c)
|
||||
target_link_libraries(nr_fapi_${fapi_p7_message}_test PUBLIC nr_fapi_p7)
|
||||
|
||||
78
nfapi/tests/p7/nr_fapi_srs_toa_vendor_ext_indication_test.c
Normal file
78
nfapi/tests/p7/nr_fapi_srs_toa_vendor_ext_indication_test.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
|
||||
*/
|
||||
#include "dci_payload_utils.h"
|
||||
#include "nr_fapi_p7.h"
|
||||
#include "nr_fapi_p7_utils.h"
|
||||
|
||||
static void fill_srs_toa_vendor_ext_indication(nfapi_nr_srs_toa_vendor_ext_indication_t *msg)
|
||||
{
|
||||
msg->sfn = rand16_range(0, 1023);
|
||||
msg->slot = rand16_range(0, 159);
|
||||
msg->rnti = rand16_range(1, 65535);
|
||||
msg->num_ta = rand8_range(1, NFAPI_NR_MAX_NUM_TA_NSEC);
|
||||
for (int ta_idx = 0; ta_idx < msg->num_ta; ++ta_idx) {
|
||||
msg->ta_offset_nsec[ta_idx] = rands16_range(-16800, 16800);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_pack_unpack(nfapi_nr_srs_toa_vendor_ext_indication_t *req)
|
||||
{
|
||||
size_t message_size = get_srs_toa_vendor_ext_indication_size(req);
|
||||
uint8_t *msg_buf = calloc_or_fail(message_size, sizeof(uint8_t));
|
||||
// first test the packing procedure
|
||||
int pack_result = fapi_nr_p7_message_pack(req, msg_buf, message_size, NULL);
|
||||
DevAssert(pack_result >= 0 + NFAPI_HEADER_LENGTH);
|
||||
// update req message_length value with value calculated in message_pack procedure
|
||||
req->header.message_length = pack_result; //- NFAPI_HEADER_LENGTH;
|
||||
// test the unpacking of the header
|
||||
// copy first NFAPI_HEADER_LENGTH bytes into a new buffer, to simulate SCTP PEEK
|
||||
fapi_message_header_t header;
|
||||
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
|
||||
uint8_t header_buffer[header_buffer_size];
|
||||
for (int idx = 0; idx < header_buffer_size; idx++) {
|
||||
header_buffer[idx] = msg_buf[idx];
|
||||
}
|
||||
uint8_t *pReadPackedMessage = header_buffer;
|
||||
int unpack_header_result = fapi_nr_p7_message_header_unpack(pReadPackedMessage, NFAPI_HEADER_LENGTH, &header, sizeof(header), 0);
|
||||
DevAssert(unpack_header_result >= 0);
|
||||
DevAssert(header.message_id == req->header.message_id);
|
||||
DevAssert(header.message_length == req->header.message_length);
|
||||
// test the unpacking and compare with initial message
|
||||
nfapi_nr_srs_toa_vendor_ext_indication_t unpacked_req = {0};
|
||||
int unpack_result =
|
||||
fapi_nr_p7_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), 0);
|
||||
DevAssert(unpack_result >= 0);
|
||||
DevAssert(eq_srs_toa_vendor_ext_indication(&unpacked_req, req));
|
||||
free_srs_toa_vendor_ext_indication(&unpacked_req);
|
||||
free(msg_buf);
|
||||
}
|
||||
|
||||
static void test_copy(const nfapi_nr_srs_toa_vendor_ext_indication_t *msg)
|
||||
{
|
||||
// Test copy function
|
||||
nfapi_nr_srs_toa_vendor_ext_indication_t copy = {0};
|
||||
copy_srs_toa_vendor_ext_indication(msg, ©);
|
||||
DevAssert(eq_srs_toa_vendor_ext_indication(msg, ©));
|
||||
free_srs_toa_vendor_ext_indication(©);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
fapi_test_init();
|
||||
|
||||
nfapi_nr_srs_toa_vendor_ext_indication_t *req = calloc_or_fail(1, sizeof(nfapi_nr_srs_toa_vendor_ext_indication_t));
|
||||
req->header.message_id = NFAPI_NR_PHY_MSG_TYPE_SRS_TOA_VENDOR_EXTENSION_INDICATION;
|
||||
// Get the actual allocated size
|
||||
printf("Allocated size before filling: %zu bytes\n", get_srs_toa_vendor_ext_indication_size(req));
|
||||
// Fill TX_DATA request
|
||||
fill_srs_toa_vendor_ext_indication(req);
|
||||
printf("Allocated size after filling: %zu bytes\n", get_srs_toa_vendor_ext_indication_size(req));
|
||||
// Perform tests
|
||||
test_pack_unpack(req);
|
||||
test_copy(req);
|
||||
// All tests successful!
|
||||
free_srs_toa_vendor_ext_indication(req);
|
||||
free(req);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user