Commit e72d50bf authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/nFAPI_P5_Common' into integration_2024_w26b

parents 541ef60c 6fc8eb0f
...@@ -723,20 +723,14 @@ target_link_libraries(SCHED_NR_UE_LIB PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs ...@@ -723,20 +723,14 @@ target_link_libraries(SCHED_NR_UE_LIB PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs
# nFAPI # nFAPI
################################# #################################
set(NFAPI_COMMON_SRC
${NFAPI_DIR}/common/src/debug.c
)
add_library(NFAPI_COMMON_LIB ${NFAPI_COMMON_SRC})
include_directories(${NFAPI_DIR}/common/public_inc)
set(NFAPI_SRC set(NFAPI_SRC
${NFAPI_DIR}/nfapi/src/nfapi.c
${NFAPI_DIR}/nfapi/src/nfapi_p4.c ${NFAPI_DIR}/nfapi/src/nfapi_p4.c
${NFAPI_DIR}/nfapi/src/nfapi_p5.c ${NFAPI_DIR}/nfapi/src/nfapi_p5.c
${NFAPI_DIR}/nfapi/src/nfapi_p7.c ${NFAPI_DIR}/nfapi/src/nfapi_p7.c
) )
add_library(NFAPI_LIB ${NFAPI_SRC}) add_library(NFAPI_LIB ${NFAPI_SRC})
target_link_libraries(NFAPI_LIB PUBLIC nfapi_common)
target_link_libraries(NFAPI_LIB PUBLIC nr_fapi_p5)
include_directories(${NFAPI_DIR}/nfapi/public_inc) include_directories(${NFAPI_DIR}/nfapi/public_inc)
include_directories(${NFAPI_DIR}/nfapi/inc) include_directories(${NFAPI_DIR}/nfapi/inc)
...@@ -761,7 +755,10 @@ set(NFAPI_VNF_SRC ...@@ -761,7 +755,10 @@ set(NFAPI_VNF_SRC
) )
add_library(NFAPI_VNF_LIB ${NFAPI_VNF_SRC}) add_library(NFAPI_VNF_LIB ${NFAPI_VNF_SRC})
target_link_libraries(NFAPI_VNF_LIB PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) target_link_libraries(NFAPI_VNF_LIB PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
target_link_libraries(NFAPI_VNF_LIB PRIVATE nr_fapi_p5)
if(OAI_AERIAL)
target_compile_definitions(NFAPI_VNF_LIB PRIVATE ENABLE_AERIAL)
endif()
include_directories(${NFAPI_DIR}/vnf/public_inc) include_directories(${NFAPI_DIR}/vnf/public_inc)
include_directories(${NFAPI_DIR}/vnf/inc) include_directories(${NFAPI_DIR}/vnf/inc)
...@@ -1457,6 +1454,9 @@ add_library(e1_if ...@@ -1457,6 +1454,9 @@ add_library(e1_if
target_link_libraries(e1_if PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs asn1_f1ap SECURITY ${OPENSSL_LIBRARIES} e1ap GTPV1U) target_link_libraries(e1_if PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs asn1_f1ap SECURITY ${OPENSSL_LIBRARIES} e1ap GTPV1U)
target_link_libraries(L2_NR PRIVATE f1ap x2ap s1ap ngap nr_rrc e1ap nr_rlc nr_common) target_link_libraries(L2_NR PRIVATE f1ap x2ap s1ap ngap nr_rrc e1ap nr_rlc nr_common)
if(OAI_AERIAL)
target_compile_definitions(L2_NR PRIVATE ENABLE_AERIAL)
endif()
if(E2_AGENT) if(E2_AGENT)
target_link_libraries(L2_NR PUBLIC e2_agent e2_agent_arg e2_ran_func_du_cucp_cuup) target_link_libraries(L2_NR PUBLIC e2_agent e2_agent_arg e2_ran_func_du_cucp_cuup)
target_compile_definitions(L2_NR PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT) target_compile_definitions(L2_NR PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT)
...@@ -1968,7 +1968,7 @@ add_dependencies(lte-softmodem oai_iqplayer) ...@@ -1968,7 +1968,7 @@ add_dependencies(lte-softmodem oai_iqplayer)
target_link_libraries(lte-softmodem PRIVATE target_link_libraries(lte-softmodem PRIVATE
-Wl,--start-group -Wl,--start-group
lte_rrc nr_rrc s1ap m2ap x2ap m3ap GTPV1U SECURITY UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB lte_rrc nr_rrc s1ap m2ap x2ap m3ap GTPV1U SECURITY UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB
PHY_COMMON PHY PHY_RU L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB PHY_COMMON PHY PHY_RU L2 L2_LTE NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB
${NAS_UE_LIB} ITTI SIMU SIMU_ETH shlib_loader ${NAS_UE_LIB} ITTI SIMU SIMU_ETH shlib_loader
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -2028,7 +2028,7 @@ target_link_libraries(lte-uesoftmodem PRIVATE ...@@ -2028,7 +2028,7 @@ target_link_libraries(lte-uesoftmodem PRIVATE
-Wl,--start-group -Wl,--start-group
lte_rrc nr_rrc s1ap x2ap m2ap m3ap lte_rrc nr_rrc s1ap x2ap m2ap m3ap
SECURITY UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON SECURITY UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON
PHY_UE PHY_RU L2_UE L2_LTE SIMU SIMU_ETH NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB PHY_UE PHY_RU L2_UE L2_LTE SIMU SIMU_ETH NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB
${NAS_UE_LIB} ITTI shlib_loader ${NAS_UE_LIB} ITTI shlib_loader
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -2061,13 +2061,11 @@ add_executable(nr-softmodem ...@@ -2061,13 +2061,11 @@ add_executable(nr-softmodem
${OPENAIR1_DIR}/PHY/TOOLS/phy_scope_interface.c ${OPENAIR1_DIR}/PHY/TOOLS/phy_scope_interface.c
) )
include(${OPENAIR_DIR}/nfapi/CMakeLists.txt)
target_link_libraries(nr-softmodem PRIVATE target_link_libraries(nr-softmodem PRIVATE
-Wl,--start-group -Wl,--start-group
UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU GTPV1U SECURITY UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU GTPV1U SECURITY
ITTI ${NAS_UE_LIB} lte_rrc nr_rrc ITTI ${NAS_UE_LIB} lte_rrc nr_rrc
ngap s1ap L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB SIMU SIMU_ETH ngap s1ap L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB SIMU SIMU_ETH
x2ap f1ap m2ap m3ap e1ap shlib_loader x2ap f1ap m2ap m3ap e1ap shlib_loader
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -2075,6 +2073,11 @@ target_link_libraries(nr-softmodem PRIVATE pthread m CONFIG_LIB rt sctp) ...@@ -2075,6 +2073,11 @@ target_link_libraries(nr-softmodem PRIVATE pthread m CONFIG_LIB rt sctp)
target_link_libraries(nr-softmodem PRIVATE ${T_LIB}) target_link_libraries(nr-softmodem PRIVATE ${T_LIB})
target_link_libraries(nr-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) target_link_libraries(nr-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
target_link_libraries(nr-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) target_link_libraries(nr-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
add_boolean_option(OAI_AERIAL OFF "Activate OAI's AERIAL driver" OFF)
if (OAI_AERIAL)
target_compile_definitions(nr-softmodem PUBLIC ENABLE_AERIAL)
target_link_libraries(nr-softmodem PUBLIC aerial_lib)
endif()
if(E2_AGENT) if(E2_AGENT)
target_compile_definitions(nr-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT) target_compile_definitions(nr-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT)
endif() endif()
...@@ -2131,7 +2134,7 @@ add_executable(nr-uesoftmodem ...@@ -2131,7 +2134,7 @@ add_executable(nr-uesoftmodem
target_link_libraries(nr-uesoftmodem PRIVATE target_link_libraries(nr-uesoftmodem PRIVATE
-Wl,--start-group -Wl,--start-group
nr_rrc SECURITY UTIL HASHTABLE SCHED_RU_LIB SCHED_NR_UE_LIB nr_rrc SECURITY UTIL HASHTABLE SCHED_RU_LIB SCHED_NR_UE_LIB
PHY_COMMON PHY_NR_COMMON PHY_NR_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB PHY_COMMON PHY_NR_COMMON PHY_NR_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_LIB NFAPI_PNF_LIB
NFAPI_USER_LIB MISC_NFAPI_NR_LIB NFAPI_USER_LIB MISC_NFAPI_NR_LIB
ITTI LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} SIMU SIMU_ETH shlib_loader ITTI LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} SIMU SIMU_ETH shlib_loader
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -2367,7 +2370,7 @@ if (${T_TRACER}) ...@@ -2367,7 +2370,7 @@ if (${T_TRACER})
params_libconfig oai_usrpdevif oai_bladerfdevif oai_lmssdrdevif oai_iqplayer params_libconfig oai_usrpdevif oai_bladerfdevif oai_lmssdrdevif oai_iqplayer
oai_eth_transpro oai_mobipass coding HASHTABLE UTIL OMG_SUMO oai_eth_transpro oai_mobipass coding HASHTABLE UTIL OMG_SUMO
SECURITY SCHED_LIB SCHED_NR_LIB SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB default_sched remote_sched RAL SECURITY SCHED_LIB SCHED_NR_LIB SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB default_sched remote_sched RAL
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB
MISC_NFAPI_LTE_LIB MISC_NFAPI_NR_LIB MISC_NFAPI_LTE_LIB MISC_NFAPI_NR_LIB
PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX
L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_UE_NR ngap L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_UE_NR ngap
...@@ -2488,6 +2491,7 @@ endif() ...@@ -2488,6 +2491,7 @@ endif()
add_subdirectory(common) add_subdirectory(common)
add_subdirectory(doc) add_subdirectory(doc)
add_subdirectory(nfapi)
add_subdirectory(openair1) add_subdirectory(openair1)
add_subdirectory(openair2) add_subdirectory(openair2)
add_subdirectory(openair3) add_subdirectory(openair3)
......
include(${OPENAIR_DIR}/nfapi/oai_integration/aerial/CMakeLists.txt) add_subdirectory(oai_integration/aerial)
\ No newline at end of file add_subdirectory(open-nFAPI)
add_subdirectory(tests)
add_boolean_option(OAI_AERIAL OFF "Activate OAI's AERIAL driver" OFF)
if (OAI_AERIAL) if (OAI_AERIAL)
message(STATUS "Building with support for Aerial") message(STATUS "Building with support for Aerial")
add_library(aerial_lib
target_sources( fapi_nvIPC.c
nr-softmodem fapi_vnf_p7.c
PRIVATE fapi_vnf_p5.c
${OPENAIR_DIR}/nfapi/oai_integration/aerial/fapi_nvIPC.c )
${OPENAIR_DIR}/nfapi/oai_integration/aerial/fapi_vnf_p7.c
${OPENAIR_DIR}/nfapi/oai_integration/aerial/fapi_vnf_p5.c )
find_library(NVIPC_LIB nvipc REQUIRED) find_library(NVIPC_LIB nvipc REQUIRED)
if (NOT NVIPC_LIB) if (NOT NVIPC_LIB)
message(FATAL_ERROR "-- nvipc library not found") message(FATAL_ERROR "-- nvipc library not found")
else () else ()
message(STATUS " nvipc library found in ${NVIPC_LIB}") message(STATUS " nvipc library found in ${NVIPC_LIB}")
#add_library(nvipc STATIC SHARED IMPORTED GLOBAL)
endif () endif ()
find_library(NVLOG_LIB nvlog REQUIRED) find_library(NVLOG_LIB nvlog REQUIRED)
...@@ -23,11 +19,10 @@ if (OAI_AERIAL) ...@@ -23,11 +19,10 @@ if (OAI_AERIAL)
else () else ()
message(STATUS " nvlog library found in ${NVLOG_LIB}") message(STATUS " nvlog library found in ${NVLOG_LIB}")
endif () endif ()
target_compile_definitions(aerial_lib PUBLIC ENABLE_L2_SLT_RSP ENABLE_AERIAL)
add_compile_definitions(ENABLE_L2_SLT_RSP) target_link_libraries(aerial_lib PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
add_compile_definitions(FAPI_BYTE_ORDERING_BIG_ENDIAN) target_link_libraries(aerial_lib PRIVATE nr_fapi_p5)
add_compile_definitions(ENABLE_AERIAL) target_link_libraries(aerial_lib PRIVATE "${NVLOG_LIB}" "${NVIPC_LIB}")
target_link_libraries(nr-softmodem PRIVATE "${NVLOG_LIB}" "${NVIPC_LIB}") else ()
else()
message(STATUS "No Support for Aerial") message(STATUS "No Support for Aerial")
endif() endif ()
\ No newline at end of file
...@@ -32,8 +32,9 @@ ...@@ -32,8 +32,9 @@
#ifdef ENABLE_AERIAL #ifdef ENABLE_AERIAL
#include "fapi_vnf_p5.h" #include "fapi_vnf_p5.h"
#include "fapi_vnf_p7.h" #include "fapi_vnf_p7.h"
#include "nfapi/open-nFAPI/nfapi/src/nfapi_p5.c"
#include "nfapi/open-nFAPI/vnf/inc/vnf_p7.h" #include "nfapi/open-nFAPI/vnf/inc/vnf_p7.h"
#include "nr_fapi.h"
#include "nr_fapi_p5.h"
extern RAN_CONTEXT_t RC; extern RAN_CONTEXT_t RC;
extern UL_RCC_IND_t UL_RCC_INFO; extern UL_RCC_IND_t UL_RCC_INFO;
...@@ -621,61 +622,6 @@ int aerial_nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t *config) ...@@ -621,61 +622,6 @@ int aerial_nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t *config)
return 0; return 0;
} }
int fapi_nr_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t *config){
nfapi_p4_p5_message_header_t *pMessageHeader = pMessageBuf;
uint8_t *pWritePackedMessage = pPackedBuf;
uint32_t packedMsgLen;
//uint16_t packedMsgLen16;
if (pMessageBuf == NULL || pPackedBuf == NULL) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 Pack supplied pointers are null\n");
return -1;
}
uint8_t *pPackMessageEnd = pPackedBuf + packedBufLen;
uint8_t *pPackedLengthField = &pWritePackedMessage[4];
uint8_t *pPacketBodyField = &pWritePackedMessage[8];
uint8_t *pPacketBodyFieldStart = &pWritePackedMessage[8];
pack_nr_p5_message_body(pMessageHeader, &pPacketBodyField, pPackMessageEnd, config);
// PHY API message header
push8(1, &pWritePackedMessage, pPackMessageEnd); // Number of messages
push8(0, &pWritePackedMessage, pPackMessageEnd); // Opaque handle
// PHY API Message structure
push16(pMessageHeader->message_id, &pWritePackedMessage, pPackMessageEnd); // Message type ID
if(1==1) {
// check for a valid message length
packedMsgLen = get_packed_msg_len((uintptr_t)pPacketBodyFieldStart, (uintptr_t)pPacketBodyField);
packedMsgLen-=1;
if(pMessageHeader->message_id == NFAPI_NR_PHY_MSG_TYPE_START_REQUEST){
//START.request doesn't have a body, length is 0
packedMsgLen = 0;
}else if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message 0x%02x length error %d, buffer supplied %d\n",pMessageHeader->message_id, packedMsgLen, packedBufLen);
return -1;
} else {
}
// Update the message length in the header
if(!push32(packedMsgLen, &pPackedLengthField, pPackMessageEnd))
return -1;
// return the packed length
return (packedMsgLen);
} else {
// Failed to pack the meassage
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 Failed to pack message\n");
return -1;
}
}
int oai_fapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req) int oai_fapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req)
{ {
nfapi_vnf_p7_config_t *p7_config = aerial_vnf.p7_vnfs[0].config; nfapi_vnf_p7_config_t *p7_config = aerial_vnf.p7_vnfs[0].config;
......
...@@ -65,7 +65,6 @@ uint8_t aerial_unpack_nr_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, ...@@ -65,7 +65,6 @@ uint8_t aerial_unpack_nr_param_response(uint8_t **ppReadPackedMsg, uint8_t *end,
uint8_t aerial_unpack_nr_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config); uint8_t aerial_unpack_nr_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
int aerial_pnf_nr_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx); int aerial_pnf_nr_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx);
int aerial_nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t *config); int aerial_nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t *config);
int fapi_nr_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
int oai_fapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req); int oai_fapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req);
int oai_fapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req); int oai_fapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
*/ */
#ifdef ENABLE_AERIAL #ifdef ENABLE_AERIAL
#include "fapi_vnf_p7.h" #include "fapi_vnf_p7.h"
#include "nfapi/open-nFAPI/nfapi/src/nfapi_p7.c" #include "nr_nfapi_p7.h"
extern RAN_CONTEXT_t RC; extern RAN_CONTEXT_t RC;
extern UL_RCC_IND_t UL_RCC_INFO; extern UL_RCC_IND_t UL_RCC_INFO;
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include "nfapi_interface.h"
#include "nfapi_nr_interface_scf.h" #include "nfapi_nr_interface_scf.h"
#include "nfapi_vnf_interface.h" #include "nfapi_vnf_interface.h"
#include "nfapi_vnf.h" #include "nfapi_vnf.h"
......
add_subdirectory(common)
add_subdirectory(fapi)
add_library(nfapi_common
src/debug.c
src/nfapi.c)
target_include_directories(nfapi_common PUBLIC public_inc/)
if (OAI_AERIAL)
target_compile_definitions(nfapi_common PRIVATE FAPI_BYTE_ORDERING_BIG_ENDIAN)
endif()
...@@ -77,8 +77,8 @@ uint8_t unpackarray(uint8_t **ppReadPackedMsg, ...@@ -77,8 +77,8 @@ uint8_t unpackarray(uint8_t **ppReadPackedMsg,
uint8_t *end, uint8_t *end,
unpack_array_elem_fn fn); unpack_array_elem_fn fn);
uint32_t pack_dci_payload(uint8_t payload[], uint16_t payloadSizeBits, uint8_t **out, uint8_t *end); uint32_t pack_dci_payload(uint8_t *payload, uint16_t payloadSizeBits, uint8_t **out, uint8_t *end);
uint32_t unpack_dci_payload(uint8_t payload[], uint16_t payloadSizeBits, uint8_t **in, uint8_t *end); uint32_t unpack_dci_payload(uint8_t *payload, uint16_t payloadSizeBits, uint8_t **in, uint8_t *end);
uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end); uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end); uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end);
...@@ -86,6 +86,7 @@ uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end); ...@@ -86,6 +86,7 @@ uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end);
typedef uint8_t (*pack_tlv_fn)(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end); typedef uint8_t (*pack_tlv_fn)(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn); uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn);
uint8_t pack_nr_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn); uint8_t pack_nr_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn);
uint8_t pack_nr_generic_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config); uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
int unpack_vendor_extension_tlv(nfapi_tl_t *tl, int unpack_vendor_extension_tlv(nfapi_tl_t *tl,
...@@ -94,6 +95,8 @@ int unpack_vendor_extension_tlv(nfapi_tl_t *tl, ...@@ -94,6 +95,8 @@ int unpack_vendor_extension_tlv(nfapi_tl_t *tl,
nfapi_p4_p5_codec_config_t *config, nfapi_p4_p5_codec_config_t *config,
nfapi_tl_t **ve_tlv); nfapi_tl_t **ve_tlv);
uint8_t unpack_nr_generic_tlv_list(void *tlv_list, uint8_t tlv_count, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t get_tlv_padding(uint16_t tlv_length); uint8_t get_tlv_padding(uint16_t tlv_length);
typedef uint8_t (*unpack_tlv_fn)(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end); typedef uint8_t (*unpack_tlv_fn)(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
...@@ -136,6 +139,50 @@ int unpack_nr_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], ...@@ -136,6 +139,50 @@ int unpack_nr_p7_tlv_list(unpack_p7_tlv_t unpack_fns[],
nfapi_p7_codec_config_t *config, nfapi_p7_codec_config_t *config,
nfapi_tl_t **ve); nfapi_tl_t **ve);
uint8_t pack_pnf_param_general_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_pnf_param_general_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_rf_config_info(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_rf_config_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_pnf_phy_info(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_pnf_phy_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_pnf_phy_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_pnf_phy_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_phy_rf_config_info(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_phy_rf_config_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_pnf_phy_rf_config_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_pnf_phy_rf_config_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_ipv4_address_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_ipv4_address_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_ipv6_address_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_ipv6_address_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_stop_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_stop_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_measurement_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_measurement_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_uint32_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_uint32_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_uint16_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_uint16_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_int16_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_int16_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint8_t pack_uint8_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
uint8_t unpack_uint8_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end);
uint32_t get_packed_msg_len(uintptr_t msgHead, uintptr_t msgEnd);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -59,23 +59,23 @@ static inline void on_error() ...@@ -59,23 +59,23 @@ static inline void on_error()
// show the call stack // show the call stack
int fd = STDERR_FILENO; int fd = STDERR_FILENO;
static const char msg[] = "---stack trace---\n"; static const char msg[] = "---stack trace---\n";
__attribute__((unused)) int r = __attribute__((unused)) int r = write(fd, msg, sizeof(msg) - 1);
write(fd, msg, sizeof(msg) - 1);
void *buffer[100]; void *buffer[100];
int nptrs = backtrace(buffer, sizeof(buffer) / sizeof(buffer[0])); int nptrs = backtrace(buffer, sizeof(buffer) / sizeof(buffer[0]));
backtrace_symbols_fd(buffer, nptrs, fd); backtrace_symbols_fd(buffer, nptrs, fd);
//abort(); // abort();
} }
// Fundamental routines // Fundamental routines
uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end) { uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end)
{
uint8_t *pOut = *out; uint8_t *pOut = *out;
if((end - pOut) >= 1) { if ((end - pOut) >= 1) {
pOut[0] = in; pOut[0] = in;
(*out)+=1; (*out) += 1;
return 1; return 1;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -84,12 +84,13 @@ uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end) { ...@@ -84,12 +84,13 @@ uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end) {
} }
} }
uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end) { uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end)
{
uint8_t *pOut = *out; uint8_t *pOut = *out;
if((end - pOut) >= 1) { if ((end - pOut) >= 1) {
pOut[0] = in; pOut[0] = in;
(*out)+=1; (*out) += 1;
return 1; return 1;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -98,10 +99,11 @@ uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end) { ...@@ -98,10 +99,11 @@ uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end) {
} }
} }
uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) { uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end)
{
uint8_t *pOut = *out; uint8_t *pOut = *out;
if((end - pOut) >= 2) { if ((end - pOut) >= 2) {
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN #ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
pOut[1] = (in & 0xFF00) >> 8; pOut[1] = (in & 0xFF00) >> 8;
pOut[0] = (in & 0xFF); pOut[0] = (in & 0xFF);
...@@ -109,7 +111,7 @@ uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) { ...@@ -109,7 +111,7 @@ uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) {
pOut[0] = (in & 0xFF00) >> 8; pOut[0] = (in & 0xFF00) >> 8;
pOut[1] = (in & 0xFF); pOut[1] = (in & 0xFF);
#endif #endif
(*out)+=2; (*out) += 2;
return 2; return 2;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -118,10 +120,11 @@ uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) { ...@@ -118,10 +120,11 @@ uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) {
} }
} }
uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) { uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end)
{
uint8_t *pOut = *out; uint8_t *pOut = *out;
if((end - pOut) >= 2) { if ((end - pOut) >= 2) {
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN #ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
pOut[1] = (in & 0xFF00) >> 8; pOut[1] = (in & 0xFF00) >> 8;
pOut[0] = (in & 0xFF); pOut[0] = (in & 0xFF);
...@@ -129,7 +132,7 @@ uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) { ...@@ -129,7 +132,7 @@ uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) {
pOut[0] = (in & 0xFF00) >> 8; pOut[0] = (in & 0xFF00) >> 8;
pOut[1] = (in & 0xFF); pOut[1] = (in & 0xFF);
#endif #endif
(*out)+=2; (*out) += 2;
return 2; return 2;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -138,10 +141,11 @@ uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) { ...@@ -138,10 +141,11 @@ uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) {
} }
} }
uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) { uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end)
{
uint8_t *pOut = *out; uint8_t *pOut = *out;
if((end - pOut) >= 4) { if ((end - pOut) >= 4) {
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN #ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
pOut[3] = (in & 0xFF000000) >> 24; pOut[3] = (in & 0xFF000000) >> 24;
pOut[2] = (in & 0xFF0000) >> 16; pOut[2] = (in & 0xFF0000) >> 16;
...@@ -153,7 +157,7 @@ uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) { ...@@ -153,7 +157,7 @@ uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) {
pOut[2] = (in & 0xFF00) >> 8; pOut[2] = (in & 0xFF00) >> 8;
pOut[3] = (in & 0xFF); pOut[3] = (in & 0xFF);
#endif #endif
(*out)+=4; (*out) += 4;
return 4; return 4;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -162,10 +166,11 @@ uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) { ...@@ -162,10 +166,11 @@ uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) {
} }
} }
uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) { uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end)
{
uint8_t *pOut = *out; uint8_t *pOut = *out;
if((end - pOut) >= 4) { if ((end - pOut) >= 4) {
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN #ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
pOut[3] = (in & 0xFF000000) >> 24; pOut[3] = (in & 0xFF000000) >> 24;
pOut[2] = (in & 0xFF0000) >> 16; pOut[2] = (in & 0xFF0000) >> 16;
...@@ -177,7 +182,7 @@ uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) { ...@@ -177,7 +182,7 @@ uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) {
pOut[2] = (in & 0xFF00) >> 8; pOut[2] = (in & 0xFF00) >> 8;
pOut[3] = (in & 0xFF); pOut[3] = (in & 0xFF);
#endif #endif
(*out)+=4; (*out) += 4;
return 4; return 4;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -186,12 +191,13 @@ uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) { ...@@ -186,12 +191,13 @@ uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) {
} }
} }
uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end) { uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end)
{
uint8_t *pIn = *in; uint8_t *pIn = *in;
if((end - pIn) >= 1 ) { if ((end - pIn) >= 1) {
*out = *pIn; *out = *pIn;
(*in)+=1; (*in) += 1;
return 1; return 1;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -200,12 +206,13 @@ uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end) { ...@@ -200,12 +206,13 @@ uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end) {
} }
} }
uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end) { uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end)
{
uint8_t *pIn = *in; uint8_t *pIn = *in;
if((end - pIn) >= 1 ) { if ((end - pIn) >= 1) {
*out = *pIn; *out = *pIn;
(*in)+=1; (*in) += 1;
return 1; return 1;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -214,16 +221,17 @@ uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end) { ...@@ -214,16 +221,17 @@ uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end) {
} }
} }
uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end) { uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end)
{
uint8_t *pIn = *in; uint8_t *pIn = *in;
if((end - pIn) >=2 ) { if ((end - pIn) >= 2) {
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN #ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
*out = ((pIn[1]) << 8) | pIn[0]; *out = ((pIn[1]) << 8) | pIn[0];
#else #else
*out = ((pIn[0]) << 8) | pIn[1]; *out = ((pIn[0]) << 8) | pIn[1];
#endif #endif
(*in)+=2; (*in) += 2;
return 2; return 2;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -232,16 +240,17 @@ uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end) { ...@@ -232,16 +240,17 @@ uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end) {
} }
} }
uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end) { uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end)
{
uint8_t *pIn = *in; uint8_t *pIn = *in;
if((end - pIn) >=2 ) { if ((end - pIn) >= 2) {
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN #ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
*out = ((pIn[1]) << 8) | pIn[0]; *out = ((pIn[1]) << 8) | pIn[0];
#else #else
*out = ((pIn[0]) << 8) | pIn[1]; *out = ((pIn[0]) << 8) | pIn[1];
#endif #endif
(*in)+=2; (*in) += 2;
return 2; return 2;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -250,10 +259,11 @@ uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end) { ...@@ -250,10 +259,11 @@ uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end) {
} }
} }
uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end) { uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end)
{
uint8_t *pIn = *in; uint8_t *pIn = *in;
if((end - pIn) >= 4) { if ((end - pIn) >= 4) {
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN #ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
*out = ((uint32_t)pIn[3] << 24) | (pIn[2] << 16) | (pIn[1] << 8) | pIn[0]; *out = ((uint32_t)pIn[3] << 24) | (pIn[2] << 16) | (pIn[1] << 8) | pIn[0];
#else #else
...@@ -268,16 +278,17 @@ uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end) { ...@@ -268,16 +278,17 @@ uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end) {
} }
} }
uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end) { uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end)
{
uint8_t *pIn = *in; uint8_t *pIn = *in;
if((end - pIn) >=4 ) { if ((end - pIn) >= 4) {
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN #ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
*out = (pIn[3] << 24) | (pIn[2] << 16) | (pIn[1] << 8) | pIn[0]; *out = (pIn[3] << 24) | (pIn[2] << 16) | (pIn[1] << 8) | pIn[0];
#else #else
*out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3];
#endif #endif
(*in)+=4; (*in) += 4;
return 4; return 4;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -292,21 +303,22 @@ inline void pusharray16(uint8_t **, uint16_t, uint32_t len) ...@@ -292,21 +303,22 @@ inline void pusharray16(uint8_t **, uint16_t, uint32_t len)
} }
*/ */
uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end)
if(len == 0) {
if (len == 0)
return 1; return 1;
if(len > max_len) { if (len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
on_error(); on_error();
return 0; return 0;
} }
if((end - (*in)) >= sizeof(uint16_t) * len) { if ((end - (*in)) >= sizeof(uint16_t) * len) {
uint32_t idx; uint32_t idx;
for(idx = 0; idx < len; ++idx) { for (idx = 0; idx < len; ++idx) {
if(!pull16(in, &out[idx], end)) if (!pull16(in, &out[idx], end))
return 0; return 0;
} }
...@@ -318,21 +330,22 @@ uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t le ...@@ -318,21 +330,22 @@ uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t le
} }
} }
uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end)
if(len == 0) {
if (len == 0)
return 1; return 1;
if(len > max_len) { if (len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
on_error(); on_error();
return 0; return 0;
} }
if((end - (*in)) >= sizeof(uint16_t) * len) { if ((end - (*in)) >= sizeof(uint16_t) * len) {
uint32_t idx; uint32_t idx;
for(idx = 0; idx < len; ++idx) { for (idx = 0; idx < len; ++idx) {
if(!pulls16(in, &out[idx], end)) if (!pulls16(in, &out[idx], end))
return 0; return 0;
} }
...@@ -343,21 +356,22 @@ uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t le ...@@ -343,21 +356,22 @@ uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t le
return 0; return 0;
} }
} }
uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end)
if(len == 0) {
if (len == 0)
return 1; return 1;
if(len > max_len) { if (len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
on_error(); on_error();
return 0; return 0;
} }
if((end - (*out)) >= sizeof(uint16_t) * len) { if ((end - (*out)) >= sizeof(uint16_t) * len) {
uint32_t idx; uint32_t idx;
for(idx = 0; idx < len; ++idx) { for (idx = 0; idx < len; ++idx) {
if(!push16(in[idx], out, end)) if (!push16(in[idx], out, end))
return 0; return 0;
} }
...@@ -368,20 +382,21 @@ uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **ou ...@@ -368,20 +382,21 @@ uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **ou
return 0; return 0;
} }
} }
uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end)
if(len == 0) {
if (len == 0)
return 1; return 1;
if(len > max_len) { if (len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
on_error(); on_error();
return 0; return 0;
} }
if((end - (*out)) >= sizeof(uint16_t) * len) { if ((end - (*out)) >= sizeof(uint16_t) * len) {
uint32_t idx; uint32_t idx;
for(idx = 0; idx < len; ++idx) { for (idx = 0; idx < len; ++idx) {
if (!pushs16(in[idx], out, end)) if (!pushs16(in[idx], out, end))
return 0; return 0;
} }
...@@ -397,14 +412,14 @@ uint32_t pullarray32(uint8_t **values_to_pull, ...@@ -397,14 +412,14 @@ uint32_t pullarray32(uint8_t **values_to_pull,
uint32_t out[], uint32_t out[],
uint32_t max_num_values_to_pull, uint32_t max_num_values_to_pull,
uint32_t num_values_to_pull, uint32_t num_values_to_pull,
uint8_t *out_end) { uint8_t *out_end)
{
if (num_values_to_pull == 0) if (num_values_to_pull == 0)
return 1; return 1;
if (num_values_to_pull > max_num_values_to_pull) { if (num_values_to_pull > max_num_values_to_pull) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, num_values_to_pull, max_num_values_to_pull);
__FUNCTION__, num_values_to_pull, max_num_values_to_pull);
on_error(); on_error();
return 0; return 0;
} }
...@@ -425,21 +440,22 @@ uint32_t pullarray32(uint8_t **values_to_pull, ...@@ -425,21 +440,22 @@ uint32_t pullarray32(uint8_t **values_to_pull,
} }
} }
uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t len, uint8_t *end)
if(len == 0) {
if (len == 0)
return 1; return 1;
if(len > max_len) { if (len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
on_error(); on_error();
return 0; return 0;
} }
if((end - (*in)) >= sizeof(uint32_t) * len) { if ((end - (*in)) >= sizeof(uint32_t) * len) {
uint32_t idx; uint32_t idx;
for(idx = 0; idx < len; ++idx) { for (idx = 0; idx < len; ++idx) {
if(!pulls32(in, &out[idx], end)) if (!pulls32(in, &out[idx], end))
return 0; return 0;
} }
...@@ -454,13 +470,13 @@ uint32_t pusharray32(const uint32_t *values_to_push, ...@@ -454,13 +470,13 @@ uint32_t pusharray32(const uint32_t *values_to_push,
uint32_t max_num_values_to_push, uint32_t max_num_values_to_push,
uint32_t num_values_to_push, uint32_t num_values_to_push,
uint8_t **out, uint8_t **out,
uint8_t *out_end) { uint8_t *out_end)
{
if (num_values_to_push == 0) if (num_values_to_push == 0)
return 1; return 1;
if (num_values_to_push > max_num_values_to_push) { if (num_values_to_push > max_num_values_to_push) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, num_values_to_push, max_num_values_to_push);
__FUNCTION__, num_values_to_push, max_num_values_to_push);
on_error(); on_error();
return 0; return 0;
} }
...@@ -480,20 +496,21 @@ uint32_t pusharray32(const uint32_t *values_to_push, ...@@ -480,20 +496,21 @@ uint32_t pusharray32(const uint32_t *values_to_push,
return 0; return 0;
} }
} }
uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end)
if(len == 0) {
if (len == 0)
return 1; return 1;
if(len > max_len) { if (len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
on_error(); on_error();
return 0; return 0;
} }
if((end - (*out)) >= sizeof(uint32_t) * len) { if ((end - (*out)) >= sizeof(uint32_t) * len) {
uint32_t idx; uint32_t idx;
for(idx = 0; idx < len; ++idx) { for (idx = 0; idx < len; ++idx) {
if (!pushs32(in[idx], out, end)) if (!pushs32(in[idx], out, end))
return 0; return 0;
} }
...@@ -505,19 +522,20 @@ uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **ou ...@@ -505,19 +522,20 @@ uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **ou
return 0; return 0;
} }
} }
uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end)
if(len == 0) {
if (len == 0)
return 1; return 1;
if(len > max_len) { if (len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
on_error(); on_error();
return 0; return 0;
} }
if((end - (*in)) >= sizeof(uint8_t) * len) { if ((end - (*in)) >= sizeof(uint8_t) * len) {
memcpy(out, (*in), len); memcpy(out, (*in), len);
(*in)+=len; (*in) += len;
return sizeof(uint8_t) * len; return sizeof(uint8_t) * len;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -526,19 +544,20 @@ uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, ...@@ -526,19 +544,20 @@ uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len,
} }
} }
uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end)
if(len == 0) {
if (len == 0)
return 1; return 1;
if(len > max_len) { if (len > max_len) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len);
on_error(); on_error();
return 0; return 0;
} }
if((end - (*out)) >= sizeof(uint8_t) * len) { if ((end - (*out)) >= sizeof(uint8_t) * len) {
memcpy((*out), in, len); memcpy((*out), in, len);
(*out)+=len; (*out) += len;
return sizeof(uint8_t) * len; return sizeof(uint8_t) * len;
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__);
...@@ -547,8 +566,15 @@ uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, ...@@ -547,8 +566,15 @@ uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out,
} }
} }
uint8_t packarray(void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t **ppwritepackedmsg, uint8_t *end, pack_array_elem_fn fn) { uint8_t packarray(void *array,
if(count > max_count) { uint16_t array_element_size,
uint16_t max_count,
uint16_t count,
uint8_t **ppwritepackedmsg,
uint8_t *end,
pack_array_elem_fn fn)
{
if (count > max_count) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count);
on_error(); on_error();
return 0; return 0;
...@@ -556,8 +582,8 @@ uint8_t packarray(void *array, uint16_t array_element_size, uint16_t max_count, ...@@ -556,8 +582,8 @@ uint8_t packarray(void *array, uint16_t array_element_size, uint16_t max_count,
uint16_t i = 0; uint16_t i = 0;
for(i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
if((fn)(array, ppwritepackedmsg, end) == 0) if ((fn)(array, ppwritepackedmsg, end) == 0)
return 0; return 0;
array += array_element_size; array += array_element_size;
...@@ -566,8 +592,15 @@ uint8_t packarray(void *array, uint16_t array_element_size, uint16_t max_count, ...@@ -566,8 +592,15 @@ uint8_t packarray(void *array, uint16_t array_element_size, uint16_t max_count,
return 1; return 1;
} }
uint8_t unpackarray(uint8_t **ppReadPackedMsg, void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t *end, unpack_array_elem_fn fn) { uint8_t unpackarray(uint8_t **ppReadPackedMsg,
if(count > max_count) { void *array,
uint16_t array_element_size,
uint16_t max_count,
uint16_t count,
uint8_t *end,
unpack_array_elem_fn fn)
{
if (count > max_count) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count);
on_error(); on_error();
return 0; return 0;
...@@ -575,8 +608,8 @@ uint8_t unpackarray(uint8_t **ppReadPackedMsg, void *array, uint16_t array_eleme ...@@ -575,8 +608,8 @@ uint8_t unpackarray(uint8_t **ppReadPackedMsg, void *array, uint16_t array_eleme
uint16_t i = 0; uint16_t i = 0;
for(i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
if((fn)(array, ppReadPackedMsg, end) == 0) if ((fn)(array, ppReadPackedMsg, end) == 0)
return 0; return 0;
array += array_element_size; array += array_element_size;
...@@ -585,55 +618,76 @@ uint8_t unpackarray(uint8_t **ppReadPackedMsg, void *array, uint16_t array_eleme ...@@ -585,55 +618,76 @@ uint8_t unpackarray(uint8_t **ppReadPackedMsg, void *array, uint16_t array_eleme
return 1; return 1;
} }
uint32_t pack_dci_payload(uint8_t payload[], uint16_t payloadSizeBits, uint8_t **out, uint8_t *end) uint32_t pack_dci_payload(uint8_t *payload, uint16_t payloadSizeBits, uint8_t **out, uint8_t *end)
{ {
// Helper vars for DCI Payload
uint8_t dci_bytes_inverted[DCI_PAYLOAD_BYTE_LEN];
uint8_t dci_byte_len = (payloadSizeBits + 7) / 8; uint8_t dci_byte_len = (payloadSizeBits + 7) / 8;
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
// Helper vars for DCI Payload
uint8_t dci_bytes_inverted[DCI_PAYLOAD_BYTE_LEN] = {0};
uint8_t payload_internal[DCI_PAYLOAD_BYTE_LEN] = {0}; // Used to not edit the "outside" pointer
uint8_t rotation_bits = 0;
// Align the dci payload bits to the left on the payload buffer // Align the dci payload bits to the left on the payload buffer
uint64_t *dci_pdu = (uint64_t *)payload;
if (payloadSizeBits % 8 != 0) { if (payloadSizeBits % 8 != 0) {
uint8_t rotation_bits = 8 - (payloadSizeBits % 8); rotation_bits = 8 - (payloadSizeBits % 8);
*dci_pdu = (*dci_pdu << rotation_bits); // Bit shifting value ( << )
uint64_t t = 0;
memcpy(&t, payload, dci_byte_len);
t = t << rotation_bits;
memcpy(payload_internal, &t, dci_byte_len);
} else {
// No rotation needed
memcpy(payload_internal, payload, dci_byte_len);
} }
// Invert the byte order of the DCI Payload // Invert the byte order of the DCI Payload
for (int j = 0; j < dci_byte_len; j++) { for (int j = 0; j < dci_byte_len; j++) {
dci_bytes_inverted[j] = payload[(dci_byte_len - 1) - j]; dci_bytes_inverted[j] = payload_internal[(dci_byte_len - 1) - j];
} }
return pusharray8(dci_bytes_inverted, DCI_PAYLOAD_BYTE_LEN, dci_byte_len, out, end); return pusharray8(dci_bytes_inverted, DCI_PAYLOAD_BYTE_LEN, dci_byte_len, out, end);
#else
return pusharray8(payload, DCI_PAYLOAD_BYTE_LEN, dci_byte_len, out, end);
#endif
} }
uint32_t unpack_dci_payload(uint8_t payload[], uint16_t payloadSizeBits, uint8_t **in, uint8_t *end) uint32_t unpack_dci_payload(uint8_t *payload, uint16_t payloadSizeBits, uint8_t **in, uint8_t *end)
{ {
// Pull the inverted DCI and invert it back // Pull the inverted DCI and invert it back
// Helper vars for DCI Payload // Helper vars for DCI Payload
uint8_t dci_bytes_inverted[DCI_PAYLOAD_BYTE_LEN];
uint8_t dci_byte_len = (payloadSizeBits + 7) / 8; uint8_t dci_byte_len = (payloadSizeBits + 7) / 8;
#ifdef FAPI_BYTE_ORDERING_BIG_ENDIAN
uint8_t dci_bytes_inverted[DCI_PAYLOAD_BYTE_LEN] = {0};
// Get DCI array inverted // Get DCI array inverted
uint32_t pullresult = pullarray8(in, dci_bytes_inverted, DCI_PAYLOAD_BYTE_LEN, dci_byte_len, end); uint32_t pullresult = pullarray8(in, dci_bytes_inverted, DCI_PAYLOAD_BYTE_LEN, dci_byte_len, end);
uint64_t *dci_pdu = (uint64_t *)payload;
// Reversing the byte order of the inverted DCI payload // Reversing the byte order of the inverted DCI payload
for (uint16_t j = 0; j < dci_byte_len; j++) { for (uint16_t j = 0; j < dci_byte_len; j++) {
payload[j] = dci_bytes_inverted[(dci_byte_len - 1) - j]; payload[j] = dci_bytes_inverted[(dci_byte_len - 1) - j];
} }
uint64_t t = 0;
memcpy(&t, payload, dci_byte_len);
if (payloadSizeBits % 8 != 0) { if (payloadSizeBits % 8 != 0) {
uint8_t rotation_bits = 8 - (payloadSizeBits % 8); uint8_t rotation_bits = 8 - (payloadSizeBits % 8);
*dci_pdu = (*dci_pdu >> rotation_bits); t = (t >> (uint64_t)rotation_bits);
} }
memcpy(payload, &t, dci_byte_len);
#else
uint32_t pullresult = pullarray8(in, payload, DCI_PAYLOAD_BYTE_LEN, dci_byte_len, end);
#endif
return pullresult; return pullresult;
} }
uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
if(ve != 0 && config != 0) { {
if(config->pack_vendor_extension_tlv) { if (ve != 0 && config != 0) {
if (config->pack_vendor_extension_tlv) {
uint8_t *pStartOfTlv = *ppWritePackedMsg; uint8_t *pStartOfTlv = *ppWritePackedMsg;
if(pack_tl(ve, ppWritePackedMsg, end) == 0) if (pack_tl(ve, ppWritePackedMsg, end) == 0)
return 0; return 0;
uint8_t *pStartOfValue = *ppWritePackedMsg; uint8_t *pStartOfValue = *ppWritePackedMsg;
if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) if ((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0)
return 0; return 0;
ve->length = (*ppWritePackedMsg) - pStartOfValue; ve->length = (*ppWritePackedMsg) - pStartOfValue;
...@@ -660,17 +714,18 @@ int unpack_vendor_extension_tlv(nfapi_tl_t *tl, ...@@ -660,17 +714,18 @@ int unpack_vendor_extension_tlv(nfapi_tl_t *tl,
return 1; return 1;
} }
uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end,nfapi_p7_codec_config_t *config) { uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
if(ve != 0 && config != 0) { {
if(config->pack_vendor_extension_tlv) { if (ve != 0 && config != 0) {
if (config->pack_vendor_extension_tlv) {
uint8_t *pStartOfTlv = *ppWritePackedMsg; uint8_t *pStartOfTlv = *ppWritePackedMsg;
if(pack_tl(ve, ppWritePackedMsg, end) == 0) if (pack_tl(ve, ppWritePackedMsg, end) == 0)
return 0; return 0;
uint8_t *pStartOfValue = *ppWritePackedMsg; uint8_t *pStartOfValue = *ppWritePackedMsg;
if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) if ((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0)
return 0; return 0;
ve->length = (*ppWritePackedMsg) - pStartOfValue; ve->length = (*ppWritePackedMsg) - pStartOfValue;
...@@ -682,9 +737,14 @@ uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg ...@@ -682,9 +737,14 @@ uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg
return 1; return 1;
} }
int unpack_p7_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve_tlv) { int unpack_p7_vendor_extension_tlv(nfapi_tl_t *tl,
if(ve_tlv != 0 && config != 0) { uint8_t **ppReadPackedMsg,
if(config->unpack_vendor_extension_tlv) { uint8_t *end,
nfapi_p7_codec_config_t *config,
nfapi_tl_t **ve_tlv)
{
if (ve_tlv != 0 && config != 0) {
if (config->unpack_vendor_extension_tlv) {
return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config); return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config);
} }
} }
...@@ -692,59 +752,67 @@ int unpack_p7_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, ui ...@@ -692,59 +752,67 @@ int unpack_p7_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, ui
return 1; return 1;
} }
uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end)
uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end) { {
return (push16(tl->tag, ppWritePackedMsg, end) && return (push16(tl->tag, ppWritePackedMsg, end) && push16(tl->length, ppWritePackedMsg, end));
push16(tl->length, ppWritePackedMsg, end));
} }
uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end) { uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end)
return (pull16(ppReadPackedMsg, &tl->tag, end) && {
pull16(ppReadPackedMsg, &tl->length, end)); return (pull16(ppReadPackedMsg, &tl->tag, end) && pull16(ppReadPackedMsg, &tl->length, end));
} }
int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve) { int unpack_tlv_list(unpack_tlv_t unpack_fns[],
uint16_t size,
uint8_t **ppReadPackedMsg,
uint8_t *end,
nfapi_p4_p5_codec_config_t *config,
nfapi_tl_t **ve)
{
nfapi_tl_t generic_tl; nfapi_tl_t generic_tl;
uint8_t numBadTags = 0; uint8_t numBadTags = 0;
uint16_t idx = 0; uint16_t idx = 0;
while ((uint8_t *)(*ppReadPackedMsg) < end) { while ((uint8_t *)(*ppReadPackedMsg) < end) {
// unpack the tl and process the values accordingly // unpack the tl and process the values accordingly
if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
return 0; return 0;
uint8_t tagMatch = 0; uint8_t tagMatch = 0;
uint8_t *pStartOfValue = *ppReadPackedMsg; uint8_t *pStartOfValue = *ppReadPackedMsg;
for(idx = 0; idx < size; ++idx) { for (idx = 0; idx < size; ++idx) {
if(unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list if (unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list
tagMatch = 1; tagMatch = 1;
nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv);
tl->tag = generic_tl.tag; tl->tag = generic_tl.tag;
tl->length = generic_tl.length; tl->length = generic_tl.length;
int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end); int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end);
if(result == 0) { if (result == 0) {
return 0; return 0;
} }
// check if the length was right; // check if the length was right;
if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { if (tl->length != (*ppReadPackedMsg - pStartOfValue)) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); NFAPI_TRACE(NFAPI_TRACE_ERROR,
"Warning tlv tag 0x%x length %d not equal to unpack %ld\n",
tl->tag,
tl->length,
(*ppReadPackedMsg - pStartOfValue));
on_error(); on_error();
} }
} }
} }
if(tagMatch == 0) { if (tagMatch == 0) {
if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && if (generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) {
generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) {
int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve);
if(result == 0) { if (result == 0) {
// got tot the end. // got tot the end.
return 0; return 0;
} else if(result < 0) { } else if (result < 0) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag); NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag);
on_error(); on_error();
...@@ -754,7 +822,7 @@ int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPa ...@@ -754,7 +822,7 @@ int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPa
return 0; return 0;
} }
if((end - *ppReadPackedMsg) >= generic_tl.length) { if ((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV // Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length; (*ppReadPackedMsg) += generic_tl.length;
} else { } else {
...@@ -772,7 +840,7 @@ int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPa ...@@ -772,7 +840,7 @@ int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPa
return 0; return 0;
} }
if((end - *ppReadPackedMsg) >= generic_tl.length) { if ((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV // Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length; (*ppReadPackedMsg) += generic_tl.length;
} else { } else {
...@@ -808,6 +876,19 @@ int unpack_nr_tlv_list(unpack_tlv_t unpack_fns[], ...@@ -808,6 +876,19 @@ int unpack_nr_tlv_list(unpack_tlv_t unpack_fns[],
for (idx = 0; idx < size; ++idx) { for (idx = 0; idx < size; ++idx) {
if (unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list if (unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list
tagMatch = 1; tagMatch = 1;
if (generic_tl.tag == NFAPI_NR_PARAM_TLV_NUM_CONFIG_TLVS_TO_REPORT_TAG) {
// padding and sub tlvs handled already
nfapi_nr_cell_param_t *cellParamTable = (nfapi_nr_cell_param_t *)unpack_fns[idx].tlv;
cellParamTable->num_config_tlvs_to_report.tl.tag = generic_tl.tag;
cellParamTable->num_config_tlvs_to_report.tl.length = generic_tl.length;
int result = (*unpack_fns[idx].unpack_func)(unpack_fns[idx].tlv, ppReadPackedMsg, end);
if (result == 0) {
return 0;
}
continue;
}
nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv);
tl->tag = generic_tl.tag; tl->tag = generic_tl.tag;
tl->length = generic_tl.length; tl->length = generic_tl.length;
...@@ -882,48 +963,57 @@ int unpack_nr_tlv_list(unpack_tlv_t unpack_fns[], ...@@ -882,48 +963,57 @@ int unpack_nr_tlv_list(unpack_tlv_t unpack_fns[],
return 1; return 1;
} }
int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve) { int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[],
uint16_t size,
uint8_t **ppReadPackedMsg,
uint8_t *end,
nfapi_p7_codec_config_t *config,
nfapi_tl_t **ve)
{
nfapi_tl_t generic_tl; nfapi_tl_t generic_tl;
uint8_t numBadTags = 0; uint8_t numBadTags = 0;
uint16_t idx = 0; uint16_t idx = 0;
while ((uint8_t *)(*ppReadPackedMsg) < end) { while ((uint8_t *)(*ppReadPackedMsg) < end) {
// unpack the tl and process the values accordingly // unpack the tl and process the values accordingly
if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
return 0; return 0;
uint8_t tagMatch = 0; uint8_t tagMatch = 0;
uint8_t *pStartOfValue = *ppReadPackedMsg; uint8_t *pStartOfValue = *ppReadPackedMsg;
for(idx = 0; idx < size; ++idx) { for (idx = 0; idx < size; ++idx) {
if(unpack_fns[idx].tag == generic_tl.tag) { if (unpack_fns[idx].tag == generic_tl.tag) {
tagMatch = 1; tagMatch = 1;
nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv);
tl->tag = generic_tl.tag; tl->tag = generic_tl.tag;
tl->length = generic_tl.length; tl->length = generic_tl.length;
int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end, config); int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end, config);
if(result == 0) { if (result == 0) {
return 0; return 0;
} }
// check if the length was right; // check if the length was right;
if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { if (tl->length != (*ppReadPackedMsg - pStartOfValue)) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); NFAPI_TRACE(NFAPI_TRACE_ERROR,
"Warning tlv tag 0x%x length %d not equal to unpack %ld\n",
tl->tag,
tl->length,
(*ppReadPackedMsg - pStartOfValue));
on_error(); on_error();
} }
} }
} }
if(tagMatch == 0) { if (tagMatch == 0) {
if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && if (generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) {
generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) {
int result = unpack_p7_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); int result = unpack_p7_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve);
if(result == 0) { if (result == 0) {
// got to end // got to end
return 0; return 0;
} else if(result < 0) { } else if (result < 0) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag);
on_error(); on_error();
...@@ -933,7 +1023,7 @@ int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **pp ...@@ -933,7 +1023,7 @@ int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **pp
return -1; return -1;
} }
if((end - *ppReadPackedMsg) >= generic_tl.length) { if ((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV // Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length; (*ppReadPackedMsg) += generic_tl.length;
} else { } else {
...@@ -951,7 +1041,7 @@ int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **pp ...@@ -951,7 +1041,7 @@ int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **pp
return -1; return -1;
} }
if((end - *ppReadPackedMsg) >= generic_tl.length) { if ((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV // Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length; (*ppReadPackedMsg) += generic_tl.length;
} else { } else {
...@@ -1064,22 +1154,23 @@ int unpack_nr_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], ...@@ -1064,22 +1154,23 @@ int unpack_nr_p7_tlv_list(unpack_p7_tlv_t unpack_fns[],
// This intermediate function deals with calculating the length of the value // This intermediate function deals with calculating the length of the value
// and writing into the tlv header. // and writing into the tlv header.
uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn) { uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn)
{
nfapi_tl_t *tl = (nfapi_tl_t *)tlv; nfapi_tl_t *tl = (nfapi_tl_t *)tlv;
// If the tag is defined // If the tag is defined
if(tl->tag == tag) { if (tl->tag == tag) {
uint8_t *pStartOfTlv = *ppWritePackedMsg; uint8_t *pStartOfTlv = *ppWritePackedMsg;
// write a dumy tlv header // write a dumy tlv header
if(pack_tl(tl, ppWritePackedMsg, end) == 0) if (pack_tl(tl, ppWritePackedMsg, end) == 0)
return 0; return 0;
// Record the start of the value // Record the start of the value
uint8_t *pStartOfValue = *ppWritePackedMsg; uint8_t *pStartOfValue = *ppWritePackedMsg;
// pack the tlv value // pack the tlv value
if(fn(tlv, ppWritePackedMsg, end) == 0) if (fn(tlv, ppWritePackedMsg, end) == 0)
return 0; return 0;
// calculate the length of the value and rewrite the tl header // calculate the length of the value and rewrite the tl header
...@@ -1087,10 +1178,10 @@ uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *e ...@@ -1087,10 +1178,10 @@ uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *e
// rewrite the header with the correct length // rewrite the header with the correct length
pack_tl(tl, &pStartOfTlv, end); pack_tl(tl, &pStartOfTlv, end);
} else { } else {
if(tl->tag != 0) { if (tl->tag != 0) {
NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", tl->tag, tag); NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", tl->tag, tag);
} else { } else {
//NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning pack_tlv tag 0x%x ZERO does not match expected 0x%x\n", tl->tag, tag); // NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning pack_tlv tag 0x%x ZERO does not match expected 0x%x\n", tl->tag, tag);
} }
} }
...@@ -1138,8 +1229,137 @@ uint8_t pack_nr_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t ...@@ -1138,8 +1229,137 @@ uint8_t pack_nr_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t
return 1; return 1;
} }
const char *nfapi_error_code_to_str(nfapi_error_code_e value) { uint8_t pack_nr_generic_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
switch(value) { {
nfapi_nr_generic_tlv_scf_t *toPack = (nfapi_nr_generic_tlv_scf_t *)tlv;
// If the tag is defined
if (toPack->tl.tag == tag && toPack->tl.length != 0) {
// write the tlv header, length comes with value
if (pack_tl(&(toPack->tl), ppWritePackedMsg, end) == 0)
return 0;
// pack the tlv value
switch (toPack->tl.length) {
case UINT_8:
if (push8(toPack->value.u8, ppWritePackedMsg, end) == 0) {
return 0;
}
break;
case UINT_16:
if (push16(toPack->value.u16, ppWritePackedMsg, end) == 0) {
return 0;
}
break;
case UINT_32:
if (push32(toPack->value.u32, ppWritePackedMsg, end) == 0) {
return 0;
}
break;
case ARRAY_UINT_16:
if ((push16(toPack->value.array_u16[0], ppWritePackedMsg, end) && push16(toPack->value.array_u16[1], ppWritePackedMsg, end)
&& push16(toPack->value.array_u16[2], ppWritePackedMsg, end)
&& push16(toPack->value.array_u16[3], ppWritePackedMsg, end)
&& push16(toPack->value.array_u16[4], ppWritePackedMsg, end))
== 0) {
return 0;
}
break;
default:
break;
}
// calculate the length of the value and rewrite the tl header
// in case of nfapi_nr_config_response_tlv_list_scf_t this is to come pre-calculated, possibly unnecessary
/*toPack->tl.length = (*ppWritePackedMsg) - pStartOfValue;
// rewrite the header with the correct length
pack_tl(&(toPack->tl), &pStartOfTlv, end);*/
// Add padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
int padding = get_tlv_padding(toPack->tl.length);
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "TLV 0x%x with padding of %d bytes\n", toPack->tl.tag, padding);
if (padding != 0) {
memset(*ppWritePackedMsg, 0, padding);
(*ppWritePackedMsg) += padding;
}
} else {
if (toPack->tl.tag != 0) {
NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", toPack->tl.tag, tag);
} else {
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning pack_tlv tag 0x%x ZERO does not match expected 0x%x\n", tl->tag, tag);
}
}
return 1;
}
uint8_t unpack_nr_generic_tlv()
{
return 1;
}
uint8_t unpack_nr_generic_tlv_list(void *tlv_list, uint8_t tlv_count, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_nr_generic_tlv_scf_t *toUnpack = (nfapi_nr_generic_tlv_scf_t *)tlv_list;
uint8_t numBadTags = 0;
for (int i = 0; i < tlv_count; ++i) {
nfapi_nr_generic_tlv_scf_t *element = &(toUnpack[i]);
// unpack each generic tlv
// unpack the tl and process the values accordingly
if (unpack_tl(ppReadPackedMsg, &(element->tl), end) == 0)
return 0;
uint8_t *pStartOfValue = *ppReadPackedMsg;
// check for valid tag
if (element->tl.tag < NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG || element->tl.tag > NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG) {
numBadTags++;
if (numBadTags > MAX_BAD_TAG) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n");
on_error();
return 0;
}
}
// if tag is valid, check length to determine which type to unpack
switch (element->tl.length) {
case UINT_8:
pull8(ppReadPackedMsg, &(element->value.u8), end);
break;
case UINT_16:
pull16(ppReadPackedMsg, &(element->value.u16), end);
break;
case UINT_32:
pull32(ppReadPackedMsg, &(element->value.u32), end);
break;
case ARRAY_UINT_16:
for (int j = 0; j < 5; ++j) {
pull16(ppReadPackedMsg, &(element->value.array_u16[j]), end);
}
break;
default:
printf("unknown length %d\n", element->tl.length);
break;
}
// check if the length was right;
if (element->tl.length != (*ppReadPackedMsg - pStartOfValue)) {
NFAPI_TRACE(NFAPI_TRACE_ERROR,
"Warning tlv tag 0x%x length %d not equal to unpack %ld\n",
element->tl.tag,
element->tl.length,
(*ppReadPackedMsg - pStartOfValue));
on_error();
}
// Remove padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
int padding = get_tlv_padding(element->tl.length);
if (padding != 0) {
(*ppReadPackedMsg) += padding;
}
}
return 1;
}
const char *nfapi_error_code_to_str(nfapi_error_code_e value)
{
switch (value) {
case NFAPI_MSG_OK: case NFAPI_MSG_OK:
return "NFAPI_MSG_OK"; return "NFAPI_MSG_OK";
...@@ -1176,3 +1396,313 @@ uint8_t get_tlv_padding(uint16_t tlv_length) ...@@ -1176,3 +1396,313 @@ uint8_t get_tlv_padding(uint16_t tlv_length)
{ {
return (4 - (tlv_length % 4)) % 4; return (4 - (tlv_length % 4)) % 4;
} }
uint8_t pack_pnf_param_general_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_pnf_param_general_t *value = (nfapi_pnf_param_general_t *)tlv;
return push8(value->nfapi_sync_mode, ppWritePackedMsg, end) && push8(value->location_mode, ppWritePackedMsg, end)
&& push16(value->location_coordinates_length, ppWritePackedMsg, end)
&& pusharray8(value->location_coordinates,
NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH,
value->location_coordinates_length,
ppWritePackedMsg,
end)
&& push32(value->dl_config_timing, ppWritePackedMsg, end) && push32(value->tx_timing, ppWritePackedMsg, end)
&& push32(value->ul_config_timing, ppWritePackedMsg, end) && push32(value->hi_dci0_timing, ppWritePackedMsg, end)
&& push16(value->maximum_number_phys, ppWritePackedMsg, end)
&& push16(value->maximum_total_bandwidth, ppWritePackedMsg, end)
&& push8(value->maximum_total_number_dl_layers, ppWritePackedMsg, end)
&& push8(value->maximum_total_number_ul_layers, ppWritePackedMsg, end) && push8(value->shared_bands, ppWritePackedMsg, end)
&& push8(value->shared_pa, ppWritePackedMsg, end) && pushs16(value->maximum_total_power, ppWritePackedMsg, end)
&& pusharray8(value->oui, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, ppWritePackedMsg, end);
}
uint8_t unpack_pnf_param_general_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_pnf_param_general_t *value = (nfapi_pnf_param_general_t *)tlv;
return pull8(ppReadPackedMsg, &value->nfapi_sync_mode, end) && pull8(ppReadPackedMsg, &value->location_mode, end)
&& pull16(ppReadPackedMsg, &value->location_coordinates_length, end)
&& pullarray8(ppReadPackedMsg,
value->location_coordinates,
NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH,
value->location_coordinates_length,
end)
&& pull32(ppReadPackedMsg, &value->dl_config_timing, end) && pull32(ppReadPackedMsg, &value->tx_timing, end)
&& pull32(ppReadPackedMsg, &value->ul_config_timing, end) && pull32(ppReadPackedMsg, &value->hi_dci0_timing, end)
&& pull16(ppReadPackedMsg, &value->maximum_number_phys, end)
&& pull16(ppReadPackedMsg, &value->maximum_total_bandwidth, end)
&& pull8(ppReadPackedMsg, &value->maximum_total_number_dl_layers, end)
&& pull8(ppReadPackedMsg, &value->maximum_total_number_ul_layers, end) && pull8(ppReadPackedMsg, &value->shared_bands, end)
&& pull8(ppReadPackedMsg, &value->shared_pa, end) && pulls16(ppReadPackedMsg, &value->maximum_total_power, end)
&& pullarray8(ppReadPackedMsg, value->oui, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, end);
}
uint8_t pack_rf_config_info(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_rf_config_info_t *rf = (nfapi_rf_config_info_t *)elem;
return push16(rf->rf_config_index, ppWritePackedMsg, end);
}
uint8_t unpack_rf_config_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_rf_config_info_t *info = (nfapi_rf_config_info_t *)elem;
return pull16(ppReadPackedMsg, &info->rf_config_index, end);
}
uint8_t pack_pnf_phy_info(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_pnf_phy_info_t *phy = (nfapi_pnf_phy_info_t *)elem;
return push16(phy->phy_config_index, ppWritePackedMsg, end) && push16(phy->number_of_rfs, ppWritePackedMsg, end)
&& packarray(phy->rf_config,
sizeof(nfapi_rf_config_info_t),
NFAPI_MAX_PNF_PHY_RF_CONFIG,
phy->number_of_rfs,
ppWritePackedMsg,
end,
&pack_rf_config_info)
&& push16(phy->number_of_rf_exclusions, ppWritePackedMsg, end)
&& packarray(phy->excluded_rf_config,
sizeof(nfapi_rf_config_info_t),
NFAPI_MAX_PNF_PHY_RF_CONFIG,
phy->number_of_rf_exclusions,
ppWritePackedMsg,
end,
&pack_rf_config_info)
&& push16(phy->downlink_channel_bandwidth_supported, ppWritePackedMsg, end)
&& push16(phy->uplink_channel_bandwidth_supported, ppWritePackedMsg, end)
&& push8(phy->number_of_dl_layers_supported, ppWritePackedMsg, end)
&& push8(phy->number_of_ul_layers_supported, ppWritePackedMsg, end)
&& push16(phy->maximum_3gpp_release_supported, ppWritePackedMsg, end)
&& push8(phy->nmm_modes_supported, ppWritePackedMsg, end);
}
uint8_t unpack_pnf_phy_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_pnf_phy_info_t *phy = (nfapi_pnf_phy_info_t *)elem;
return pull16(ppReadPackedMsg, &phy->phy_config_index, end) && pull16(ppReadPackedMsg, &phy->number_of_rfs, end)
&& unpackarray(ppReadPackedMsg,
phy->rf_config,
sizeof(nfapi_rf_config_info_t),
NFAPI_MAX_PNF_PHY_RF_CONFIG,
phy->number_of_rfs,
end,
&unpack_rf_config_info)
&& pull16(ppReadPackedMsg, &phy->number_of_rf_exclusions, end)
&& unpackarray(ppReadPackedMsg,
phy->excluded_rf_config,
sizeof(nfapi_rf_config_info_t),
NFAPI_MAX_PNF_PHY_RF_CONFIG,
phy->number_of_rf_exclusions,
end,
&unpack_rf_config_info)
&& pull16(ppReadPackedMsg, &phy->downlink_channel_bandwidth_supported, end)
&& pull16(ppReadPackedMsg, &phy->uplink_channel_bandwidth_supported, end)
&& pull8(ppReadPackedMsg, &phy->number_of_dl_layers_supported, end)
&& pull8(ppReadPackedMsg, &phy->number_of_ul_layers_supported, end)
&& pull16(ppReadPackedMsg, &phy->maximum_3gpp_release_supported, end)
&& pull8(ppReadPackedMsg, &phy->nmm_modes_supported, end);
}
uint8_t pack_pnf_phy_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_pnf_phy_t *value = (nfapi_pnf_phy_t *)tlv;
return push16(value->number_of_phys, ppWritePackedMsg, end)
&& packarray(value->phy,
sizeof(nfapi_pnf_phy_info_t),
NFAPI_MAX_PNF_PHY,
value->number_of_phys,
ppWritePackedMsg,
end,
&pack_pnf_phy_info);
}
uint8_t unpack_pnf_phy_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_pnf_phy_t *value = (nfapi_pnf_phy_t *)tlv;
return pull16(ppReadPackedMsg, &value->number_of_phys, end)
&& unpackarray(ppReadPackedMsg,
value->phy,
sizeof(nfapi_pnf_phy_info_t),
NFAPI_MAX_PNF_PHY,
value->number_of_phys,
end,
&unpack_pnf_phy_info);
}
uint8_t pack_phy_rf_config_info(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_phy_rf_config_info_t *rf = (nfapi_phy_rf_config_info_t *)elem;
return push16(rf->phy_id, ppWritePackedMsg, end) && push16(rf->phy_config_index, ppWritePackedMsg, end)
&& push16(rf->rf_config_index, ppWritePackedMsg, end);
}
uint8_t unpack_phy_rf_config_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_phy_rf_config_info_t *rf = (nfapi_phy_rf_config_info_t *)elem;
return pull16(ppReadPackedMsg, &rf->phy_id, end) && pull16(ppReadPackedMsg, &rf->phy_config_index, end)
&& pull16(ppReadPackedMsg, &rf->rf_config_index, end);
}
uint8_t pack_pnf_phy_rf_config_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_pnf_phy_rf_config_t *value = (nfapi_pnf_phy_rf_config_t *)tlv;
return push16(value->number_phy_rf_config_info, ppWritePackedMsg, end)
&& packarray(value->phy_rf_config,
sizeof(nfapi_phy_rf_config_info_t),
NFAPI_MAX_PHY_RF_INSTANCES,
value->number_phy_rf_config_info,
ppWritePackedMsg,
end,
&pack_phy_rf_config_info);
}
uint8_t unpack_pnf_phy_rf_config_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_pnf_phy_rf_config_t *value = (nfapi_pnf_phy_rf_config_t *)tlv;
return pull16(ppReadPackedMsg, &value->number_phy_rf_config_info, end)
&& unpackarray(ppReadPackedMsg,
value->phy_rf_config,
sizeof(nfapi_phy_rf_config_info_t),
NFAPI_MAX_PHY_RF_INSTANCES,
value->number_phy_rf_config_info,
end,
&unpack_phy_rf_config_info);
}
uint8_t pack_ipv4_address_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_ipv4_address_t *value = (nfapi_ipv4_address_t *)tlv;
return pusharray8(value->address, NFAPI_IPV4_ADDRESS_LENGTH, NFAPI_IPV4_ADDRESS_LENGTH, ppWritePackedMsg, end);
}
uint8_t unpack_ipv4_address_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_ipv4_address_t *value = (nfapi_ipv4_address_t *)tlv;
return pullarray8(ppReadPackedMsg, value->address, NFAPI_IPV4_ADDRESS_LENGTH, NFAPI_IPV4_ADDRESS_LENGTH, end);
}
uint8_t pack_ipv6_address_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_ipv6_address_t *value = (nfapi_ipv6_address_t *)tlv;
return pusharray8(value->address, NFAPI_IPV6_ADDRESS_LENGTH, NFAPI_IPV6_ADDRESS_LENGTH, ppWritePackedMsg, end);
}
uint8_t unpack_ipv6_address_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_ipv4_address_t *value = (nfapi_ipv4_address_t *)tlv;
return pullarray8(ppReadPackedMsg, value->address, NFAPI_IPV6_ADDRESS_LENGTH, NFAPI_IPV6_ADDRESS_LENGTH, end);
}
uint8_t pack_stop_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_stop_response_t *pNfapiMsg = (nfapi_stop_response_t *)msg;
return push32(pNfapiMsg->error_code, ppWritePackedMsg, end)
&& pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
}
uint8_t unpack_stop_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_stop_response_t *pNfapiMsg = (nfapi_stop_response_t *)msg;
return pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end)
&& unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
}
uint8_t pack_measurement_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_measurement_request_t *pNfapiMsg = (nfapi_measurement_request_t *)msg;
return pack_tlv(NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG,
&(pNfapiMsg->dl_rs_tx_power),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_tlv(NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG,
&(pNfapiMsg->received_interference_power),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_tlv(NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG,
&(pNfapiMsg->thermal_noise_power),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
}
uint8_t unpack_measurement_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_measurement_request_t *pNfapiMsg = (nfapi_measurement_request_t *)msg;
unpack_tlv_t unpack_fns[] = {
{NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG, &pNfapiMsg->dl_rs_tx_power, &unpack_uint16_tlv_value},
{NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG,
&pNfapiMsg->received_interference_power,
&unpack_uint16_tlv_value},
{NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG, &pNfapiMsg->thermal_noise_power, &unpack_uint16_tlv_value},
};
return unpack_tlv_list(unpack_fns,
sizeof(unpack_fns) / sizeof(unpack_tlv_t),
ppReadPackedMsg,
end,
config,
&(pNfapiMsg->vendor_extension));
}
uint8_t pack_uint32_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_uint32_tlv_t *value = (nfapi_uint32_tlv_t *)tlv;
return push32(value->value, ppWritePackedMsg, end);
}
uint8_t unpack_uint32_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_uint32_tlv_t *value = (nfapi_uint32_tlv_t *)tlv;
return pull32(ppReadPackedMsg, &value->value, end);
}
uint8_t pack_uint16_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_uint16_tlv_t *value = (nfapi_uint16_tlv_t *)tlv;
return push16(value->value, ppWritePackedMsg, end);
}
uint8_t unpack_uint16_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_uint16_tlv_t *value = (nfapi_uint16_tlv_t *)tlv;
return pull16(ppReadPackedMsg, &value->value, end);
}
uint8_t pack_int16_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_int16_tlv_t *value = (nfapi_int16_tlv_t *)tlv;
return pushs16(value->value, ppWritePackedMsg, end);
}
uint8_t unpack_int16_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_int16_tlv_t *value = (nfapi_int16_tlv_t *)tlv;
return pulls16(ppReadPackedMsg, &value->value, end);
}
uint8_t pack_uint8_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end)
{
nfapi_uint8_tlv_t *value = (nfapi_uint8_tlv_t *)tlv;
return push8(value->value, ppWritePackedMsg, end);
}
uint8_t unpack_uint8_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
nfapi_uint8_tlv_t *value = (nfapi_uint8_tlv_t *)tlv;
return pull8(ppReadPackedMsg, &value->value, end);
}
// helper function for message length calculation -
// takes the pointers to the start of message to end of message
uint32_t get_packed_msg_len(uintptr_t msgHead, uintptr_t msgEnd)
{
if (msgEnd < msgHead) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "get_packed_msg_len: Error in pointers supplied %p, %p\n", &msgHead, &msgEnd);
return 0;
}
return msgEnd - msgHead;
}
add_library(nr_fapi_p5
src/nr_fapi_p5.c
src/nr_fapi_p5_utils.c
)
target_include_directories(nr_fapi_p5 PUBLIC inc)
target_link_libraries(nr_fapi_p5 PUBLIC nfapi_common)
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/open-nFAPI/fapi/inc/nr_fapi.h
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#ifndef OPENAIRINTERFACE_NR_FAPI_H
#define OPENAIRINTERFACE_NR_FAPI_H
#include "stdint.h"
#include "string.h"
#include "nfapi_interface.h"
#include "nfapi_nr_interface.h"
#include "nfapi_nr_interface_scf.h"
#include "nfapi.h"
#include "nfapi/oai_integration/vendor_ext.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#include "assertions.h"
typedef struct {
uint8_t num_msg;
uint8_t opaque_handle;
uint16_t message_id;
uint32_t message_length;
} fapi_message_header_t;
int fapi_nr_p5_message_header_unpack(uint8_t **pMessageBuf,
uint32_t messageBufLen,
void *pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p4_p5_codec_config_t *config);
int fapi_nr_p5_message_pack(void *pMessageBuf,
uint32_t messageBufLen,
void *pPackedBuf,
uint32_t packedBufLen,
nfapi_p4_p5_codec_config_t *config);
int fapi_nr_p5_message_unpack(void *pMessageBuf,
uint32_t messageBufLen,
void *pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p4_p5_codec_config_t *config);
int check_nr_fapi_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpackedBufLen);
#endif // OPENAIRINTERFACE_NR_FAPI_H
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/open-nFAPI/fapi/inc/nr_fapi_p5.h
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#ifndef OPENAIRINTERFACE_NR_FAPI_P5_H
#define OPENAIRINTERFACE_NR_FAPI_P5_H
#include "stdint.h"
#include "nfapi_interface.h"
uint8_t pack_nr_param_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_nr_param_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_nr_param_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_nr_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_nr_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_nr_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_nr_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_nr_start_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_nr_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_nr_start_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_nr_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_nr_stop_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_nr_stop_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_nr_stop_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_nr_stop_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
uint8_t pack_nr_error_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
uint8_t unpack_nr_error_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config);
#endif // OPENAIRINTERFACE_NR_FAPI_P5_H
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/open-nFAPI/fapi/inc/nr_fapi_p5_utils.h
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#ifndef OPENAIRINTERFACE_NR_FAPI_P5_UTILS_H
#define OPENAIRINTERFACE_NR_FAPI_P5_UTILS_H
#include "stdio.h"
#include "stdint.h"
#include "nr_fapi.h"
#include "nfapi/oai_integration/vendor_ext.h"
#define EQ_TLV(_tlv_a, _tlv_b) \
do { \
EQ(_tlv_a.tl.tag, _tlv_b.tl.tag); \
EQ(_tlv_a.value, _tlv_b.value); \
} while (0)
#define EQ(_a, _b) \
do { \
if ((_a) != (_b)) { \
return false; \
} \
} while (0)
#define COPY_TL(_dst_tl, _src_tl) \
do { \
_dst_tl.tag = _src_tl.tag; \
_dst_tl.length = _src_tl.length; \
} while (0)
#define COPY_TLV(_dst, _src) \
do { \
COPY_TL(_dst.tl, _src.tl); \
_dst.value = _src.value; \
} while (0)
void copy_vendor_extension_value(nfapi_vendor_extension_tlv_t *dst, const nfapi_vendor_extension_tlv_t *src);
bool eq_param_request(const nfapi_nr_param_request_scf_t *unpacked_req, const nfapi_nr_param_request_scf_t *req);
bool eq_param_response(const nfapi_nr_param_response_scf_t *unpacked_req, const nfapi_nr_param_response_scf_t *req);
bool eq_config_request(const nfapi_nr_config_request_scf_t *unpacked_req, const nfapi_nr_config_request_scf_t *req);
bool eq_config_response(const nfapi_nr_config_response_scf_t *unpacked_req, const nfapi_nr_config_response_scf_t *req);
bool eq_start_request(const nfapi_nr_start_request_scf_t *unpacked_req, const nfapi_nr_start_request_scf_t *req);
bool eq_start_response(const nfapi_nr_start_response_scf_t *unpacked_req, const nfapi_nr_start_response_scf_t *req);
bool eq_stop_request(const nfapi_nr_stop_request_scf_t *unpacked_req, const nfapi_nr_stop_request_scf_t *req);
bool eq_stop_indication(const nfapi_nr_stop_indication_scf_t *unpacked_req, const nfapi_nr_stop_indication_scf_t *req);
bool eq_error_indication(const nfapi_nr_error_indication_scf_t *unpacked_req, const nfapi_nr_error_indication_scf_t *req);
void free_param_request(nfapi_nr_param_request_scf_t *msg);
void free_param_response(nfapi_nr_param_response_scf_t *msg);
void free_config_request(nfapi_nr_config_request_scf_t *msg);
void free_config_response(nfapi_nr_config_response_scf_t *msg);
void free_start_request(nfapi_nr_start_request_scf_t *msg);
void free_start_response(nfapi_nr_start_response_scf_t *msg);
void free_stop_request(nfapi_nr_stop_request_scf_t *msg);
void free_stop_indication(nfapi_nr_stop_indication_scf_t *msg);
void free_error_indication(nfapi_nr_error_indication_scf_t *msg);
void copy_param_request(const nfapi_nr_param_request_scf_t *src, nfapi_nr_param_request_scf_t *dst);
void copy_param_response(const nfapi_nr_param_response_scf_t *src, nfapi_nr_param_response_scf_t *dst);
void copy_config_request(const nfapi_nr_config_request_scf_t *src, nfapi_nr_config_request_scf_t *dst);
void copy_config_response(const nfapi_nr_config_response_scf_t *src, nfapi_nr_config_response_scf_t *dst);
void copy_start_request(const nfapi_nr_start_request_scf_t *src, nfapi_nr_start_request_scf_t *dst);
void copy_start_response(const nfapi_nr_start_response_scf_t *src, nfapi_nr_start_response_scf_t *dst);
void copy_stop_request(const nfapi_nr_stop_request_scf_t *src, nfapi_nr_stop_request_scf_t *dst);
void copy_stop_indication(const nfapi_nr_stop_indication_scf_t *src, nfapi_nr_stop_indication_scf_t *dst);
void copy_error_indication(const nfapi_nr_error_indication_scf_t *src, nfapi_nr_error_indication_scf_t *dst);
#endif // OPENAIRINTERFACE_NR_FAPI_P5_UTILS_H
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/open-nFAPI/fapi/src/nr_fapi_p5.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nr_fapi.h"
#include "nr_fapi_p5.h"
#include "nr_fapi_p5_utils.h"
#include "debug.h"
bool isFAPIMessageIDValid(uint16_t id)
{
// SCF 222.10.04 Table 3-5 PHY API message types
return (id >= NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST && id <= 0xFF) || id == NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE
|| id == NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC || id == NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC
|| id == NFAPI_NR_PHY_MSG_TYPE_TIMING_INFO;
}
int fapi_nr_p5_message_header_unpack(uint8_t **pMessageBuf,
uint32_t messageBufLen,
void *pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p4_p5_codec_config_t *config)
{
uint8_t **pReadPackedMessage = pMessageBuf;
nfapi_p4_p5_message_header_t *header = pUnpackedBuf;
fapi_message_header_t fapi_msg;
if(pMessageBuf == NULL || pUnpackedBuf == NULL || messageBufLen < NFAPI_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p4_p5_message_header_t)){
return -1;
}
uint8_t *end = *pMessageBuf + messageBufLen;
// process the header
int result =
(pull8(pReadPackedMessage, &fapi_msg.num_msg, end) && pull8(pReadPackedMessage, &fapi_msg.opaque_handle, end)
&& pull16(pReadPackedMessage, &header->message_id, end) && pull32(pReadPackedMessage, &fapi_msg.message_length, end));
DevAssert(fapi_msg.message_length <= 0xFFFF);
header->message_length = fapi_msg.message_length;
return (result);
}
uint8_t fapi_nr_p5_message_body_pack(nfapi_p4_p5_message_header_t *header,
uint8_t **ppWritePackedMsg,
uint8_t *end,
nfapi_p4_p5_codec_config_t *config)
{
uint8_t result = 0;
// look for the specific message
switch (header->message_id) {
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST:
result = 0;
break;
case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE:
result = pack_nr_param_response(header, ppWritePackedMsg, end, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST:
result = pack_nr_config_request(header, ppWritePackedMsg, end, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE:
result = pack_nr_config_response(header, ppWritePackedMsg, end, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST:
result = pack_nr_start_request(header, ppWritePackedMsg, end, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE:
result = pack_nr_start_response(header, ppWritePackedMsg, end, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST:
result = pack_nr_stop_request(header, ppWritePackedMsg, end, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION:
result = pack_nr_stop_indication(header, ppWritePackedMsg, end, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION:
result = pack_nr_error_indication(header, ppWritePackedMsg, end, config);
break;
default: {
AssertFatal(header->message_id >= 0x00 && header->message_id <= 0xFF,
"FAPI message IDs are defined between 0x00 and 0xFF the message provided 0x%02x, which is not a FAPI message",
header->message_id);
break;
}
}
return result;
}
int fapi_nr_p5_message_pack(void *pMessageBuf,
uint32_t messageBufLen,
void *pPackedBuf,
uint32_t packedBufLen,
nfapi_p4_p5_codec_config_t *config)
{
nfapi_p4_p5_message_header_t *pMessageHeader = pMessageBuf;
uint8_t *pWritePackedMessage = pPackedBuf;
AssertFatal(isFAPIMessageIDValid(pMessageHeader->message_id),
"FAPI message IDs are defined between 0x00 and 0xFF the message provided 0x%02x, which is not a FAPI message",
pMessageHeader->message_id);
uint32_t packedMsgLen;
uint32_t packedBodyLen;
uint16_t packedMsgLen16;
AssertFatal(pMessageBuf != NULL && pPackedBuf != NULL, "P5 Pack supplied pointers are null");
uint8_t *pPackMessageEnd = pPackedBuf + packedBufLen;
uint8_t *pPackedLengthField = &pWritePackedMessage[4];
uint8_t *pPacketBodyField = &pWritePackedMessage[8];
uint8_t *pPacketBodyFieldStart = &pWritePackedMessage[8];
uint8_t res = fapi_nr_p5_message_body_pack(pMessageHeader, &pPacketBodyField, pPackMessageEnd, config);
AssertFatal(res >= 0, "fapi_nr_p5_message_body_pack error packing message body %d\n", res);
// PHY API message header
push8(1, &pWritePackedMessage, pPackMessageEnd); // Number of messages
push8(0, &pWritePackedMessage, pPackMessageEnd); // Opaque handle
// PHY API Message structure
push16(pMessageHeader->message_id, &pWritePackedMessage, pPackMessageEnd); // Message type ID
// check for a valid message length
packedMsgLen = get_packed_msg_len((uintptr_t)pPackedBuf, (uintptr_t)pPacketBodyField);
packedBodyLen = get_packed_msg_len((uintptr_t)pPacketBodyFieldStart, (uintptr_t)pPacketBodyField);
packedMsgLen16 = (uint16_t)packedBodyLen;
if (pMessageHeader->message_id == NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST
|| pMessageHeader->message_id == NFAPI_NR_PHY_MSG_TYPE_START_REQUEST
|| pMessageHeader->message_id == NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST
|| pMessageHeader->message_id == NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION) {
// These messages don't have a body, length is 0
packedMsgLen16 = 0;
}
AssertFatal(packedMsgLen <= 0xFFFF && packedMsgLen <= packedBufLen,
"Packed message 0x%02x length error %d, buffer supplied %d\n",
pMessageHeader->message_id,
packedMsgLen,
packedBufLen);
// Update the message length in the header
if (!push32(packedMsgLen16, &pPackedLengthField, pPackMessageEnd))
return -1;
// return the packed length
return (int)(packedMsgLen);
}
int fapi_nr_p5_message_unpack(void *pMessageBuf,
uint32_t messageBufLen,
void *pUnpackedBuf,
uint32_t unpackedBufLen,
nfapi_p4_p5_codec_config_t *config)
{
fapi_message_header_t *pMessageHeader = pUnpackedBuf;
uint8_t *pReadPackedMessage = pMessageBuf;
AssertFatal(pMessageBuf != NULL && pUnpackedBuf != NULL, "P5 unpack supplied pointers are null");
uint8_t *end = (uint8_t *)pMessageBuf + messageBufLen;
AssertFatal(messageBufLen >= NFAPI_HEADER_LENGTH && unpackedBufLen >= sizeof(fapi_message_header_t),
"P5 unpack supplied message buffer is too small %d, %d\n",
messageBufLen,
unpackedBufLen);
// clean the supplied buffer for - tag value blanking
(void)memset(pUnpackedBuf, 0, unpackedBufLen);
if (fapi_nr_p5_message_header_unpack(&pReadPackedMessage, NFAPI_HEADER_LENGTH, pMessageHeader, sizeof(fapi_message_header_t), 0)
< 0) {
// failed to read the header
return -1;
}
int result = -1;
if (check_nr_fapi_unpack_length(pMessageHeader->message_id, unpackedBufLen) == 0) {
// the unpack buffer is not big enough for the struct
return -1;
}
// look for the specific message
switch (pMessageHeader->message_id) {
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST:
// PARAM request has no body;
result = 0;
break;
case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE:
result = unpack_nr_param_response(&pReadPackedMessage, end, pMessageHeader, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST:
result = unpack_nr_config_request(&pReadPackedMessage, end, pMessageHeader, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE:
result = unpack_nr_config_response(&pReadPackedMessage, end, pMessageHeader, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST:
result = unpack_nr_start_request(&pReadPackedMessage, end, pMessageHeader, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE:
result = unpack_nr_start_response(&pReadPackedMessage, end, pMessageHeader, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST:
result = unpack_nr_stop_request(&pReadPackedMessage, end, pMessageHeader, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION:
result = unpack_nr_stop_indication(&pReadPackedMessage, end, pMessageHeader, config);
break;
case NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION:
result = unpack_nr_error_indication(&pReadPackedMessage, end, pMessageHeader, config);
break;
default:
if (pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
NFAPI_TRACE(NFAPI_TRACE_ERROR,
"%s VE NFAPI message ID %d. No ve decoder provided\n",
__FUNCTION__,
pMessageHeader->message_id);
} else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown P5 message ID %d\n", __FUNCTION__, pMessageHeader->message_id);
}
break;
}
return result;
}
int check_nr_fapi_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpackedBufLen)
{
int retLen = 0;
/** NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST= 0x00,
NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE= 0x01,
NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST= 0x02,
NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE=0X03,
NFAPI_NR_PHY_MSG_TYPE_START_REQUEST= 0X04,
NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST= 0X05,
NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION=0X06,
NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION=0X07
*/
// check for size of nFAPI struct without the nFAPI specific parameters
switch (msgId) {
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_param_request_scf_t) - sizeof(nfapi_vendor_extension_tlv_t))
retLen = sizeof(fapi_message_header_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_nr_param_response_scf_t) - sizeof(nfapi_vendor_extension_tlv_t) - sizeof(nfapi_nr_nfapi_t))
retLen = sizeof(nfapi_nr_param_request_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_config_request_scf_t) - sizeof(nfapi_vendor_extension_tlv_t) - sizeof(nfapi_nr_nfapi_t))
retLen = sizeof(nfapi_nr_config_request_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_nr_config_response_scf_t) - sizeof(nfapi_vendor_extension_tlv_t))
retLen = sizeof(nfapi_nr_config_response_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_start_request_scf_t) - sizeof(nfapi_vendor_extension_tlv_t))
retLen = sizeof(fapi_message_header_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_nr_start_response_scf_t) - sizeof(nfapi_vendor_extension_tlv_t))
retLen = sizeof(fapi_message_header_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_stop_request_scf_t) - sizeof(nfapi_vendor_extension_tlv_t))
retLen = sizeof(fapi_message_header_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_nr_stop_indication_scf_t) - sizeof(nfapi_vendor_extension_tlv_t))
retLen = sizeof(fapi_message_header_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION:
if (unpackedBufLen >= sizeof(nfapi_nr_error_indication_scf_t) - sizeof(nfapi_vendor_extension_tlv_t))
retLen = sizeof(fapi_message_header_t);
break;
default:
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s Unknown message ID %d\n", __FUNCTION__, msgId);
break;
}
return retLen;
}
uint8_t pack_nr_param_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_param_request_scf_t *pNfapiMsg = (nfapi_nr_param_request_scf_t *)msg;
return (pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
uint8_t unpack_nr_param_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_param_request_scf_t *pNfapiMsg = (nfapi_nr_param_request_scf_t *)msg;
return unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
}
uint8_t pack_nr_param_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
printf("\nRUNNING pack_param_response\n");
nfapi_nr_param_response_scf_t *pNfapiMsg = (nfapi_nr_param_response_scf_t *)msg;
uint8_t retval = push8(pNfapiMsg->error_code, ppWritePackedMsg, end) && push8(pNfapiMsg->num_tlv, ppWritePackedMsg, end);
retval &= pack_nr_tlv(NFAPI_NR_PARAM_TLV_RELEASE_CAPABILITY_TAG,
&(pNfapiMsg->cell_param.release_capability),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PHY_STATE_TAG,
&(pNfapiMsg->cell_param.phy_state),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SKIP_BLANK_DL_CONFIG_TAG,
&(pNfapiMsg->cell_param.skip_blank_dl_config),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SKIP_BLANK_UL_CONFIG_TAG,
&(pNfapiMsg->cell_param.skip_blank_ul_config),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_NUM_CONFIG_TLVS_TO_REPORT_TAG,
&(pNfapiMsg->cell_param.num_config_tlvs_to_report),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
for (int i = 0; i < pNfapiMsg->cell_param.num_config_tlvs_to_report.value; ++i) {
/*retval &= pack_nr_tlv(pNfapiMsg->cell_param.config_tlvs_to_report_list[i].tl.tag,
&(pNfapiMsg->cell_param.config_tlvs_to_report_list[i]),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);*/
retval &= push16(pNfapiMsg->cell_param.config_tlvs_to_report_list[i].tl.tag, ppWritePackedMsg, end);
retval &= push8(pNfapiMsg->cell_param.config_tlvs_to_report_list[i].tl.length, ppWritePackedMsg, end);
retval &= push8(pNfapiMsg->cell_param.config_tlvs_to_report_list[i].value, ppWritePackedMsg, end);
// Add padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
int padding = get_tlv_padding(pNfapiMsg->cell_param.config_tlvs_to_report_list[i].tl.length);
NFAPI_TRACE(NFAPI_TRACE_DEBUG,
"TLV 0x%x with padding of %d bytes\n",
pNfapiMsg->cell_param.config_tlvs_to_report_list[i].tl.tag,
padding);
if (padding != 0) {
memset(*ppWritePackedMsg, 0, padding);
(*ppWritePackedMsg) += padding;
}
}
retval &= pack_nr_tlv(NFAPI_NR_PARAM_TLV_CYCLIC_PREFIX_TAG,
&(pNfapiMsg->carrier_param.cyclic_prefix),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_DL_TAG,
&(pNfapiMsg->carrier_param.supported_subcarrier_spacings_dl),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_DL_TAG,
&(pNfapiMsg->carrier_param.supported_bandwidth_dl),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_UL_TAG,
&(pNfapiMsg->carrier_param.supported_subcarrier_spacings_ul),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_UL_TAG,
&(pNfapiMsg->carrier_param.supported_bandwidth_ul),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_CCE_MAPPING_TYPE_TAG,
&(pNfapiMsg->pdcch_param.cce_mapping_type),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG,
&(pNfapiMsg->pdcch_param.coreset_outside_first_3_of_ofdm_syms_of_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PRECODER_GRANULARITY_CORESET_TAG,
&(pNfapiMsg->pdcch_param.coreset_precoder_granularity_coreset),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDCCH_MU_MIMO_TAG,
&(pNfapiMsg->pdcch_param.pdcch_mu_mimo),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDCCH_PRECODER_CYCLING_TAG,
&(pNfapiMsg->pdcch_param.pdcch_precoder_cycling),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PDCCHS_PER_SLOT_TAG,
&(pNfapiMsg->pdcch_param.max_pdcch_per_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUCCH_FORMATS_TAG,
&(pNfapiMsg->pucch_param.pucch_formats),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PUCCHS_PER_SLOT_TAG,
&(pNfapiMsg->pucch_param.max_pucchs_per_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_MAPPING_TYPE_TAG,
&(pNfapiMsg->pdsch_param.pdsch_mapping_type),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_ALLOCATION_TYPES_TAG,
&(pNfapiMsg->pdsch_param.pdsch_allocation_types),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_VRB_TO_PRB_MAPPING_TAG,
&(pNfapiMsg->pdsch_param.pdsch_vrb_to_prb_mapping),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_CBG_TAG,
&(pNfapiMsg->pdsch_param.pdsch_cbg),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_DMRS_CONFIG_TYPES_TAG,
&(pNfapiMsg->pdsch_param.pdsch_dmrs_config_types),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_DMRS_MAX_LENGTH_TAG,
&(pNfapiMsg->pdsch_param.pdsch_dmrs_max_length),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_DMRS_ADDITIONAL_POS_TAG,
&(pNfapiMsg->pdsch_param.pdsch_dmrs_additional_pos),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PDSCH_S_TBS_PER_SLOT_TAG,
&(pNfapiMsg->pdsch_param.max_pdsch_tbs_per_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG,
&(pNfapiMsg->pdsch_param.max_number_mimo_layers_pdsch),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG,
&(pNfapiMsg->pdsch_param.supported_max_modulation_order_dl),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_DL_TAG,
&(pNfapiMsg->pdsch_param.max_mu_mimo_users_dl),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG,
&(pNfapiMsg->pdsch_param.pdsch_data_in_dmrs_symbols),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PREMPTION_SUPPORT_TAG,
&(pNfapiMsg->pdsch_param.premption_support),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_NON_SLOT_SUPPORT_TAG,
&(pNfapiMsg->pdsch_param.pdsch_non_slot_support),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_UCI_MUX_ULSCH_IN_PUSCH_TAG,
&(pNfapiMsg->pusch_param.uci_mux_ulsch_in_pusch),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_UCI_ONLY_PUSCH_TAG,
&(pNfapiMsg->pusch_param.uci_only_pusch),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_FREQUENCY_HOPPING_TAG,
&(pNfapiMsg->pusch_param.pusch_frequency_hopping),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_DMRS_CONFIG_TYPES_TAG,
&(pNfapiMsg->pusch_param.pusch_dmrs_config_types),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_DMRS_MAX_LEN_TAG,
&(pNfapiMsg->pusch_param.pusch_dmrs_max_len),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_DMRS_ADDITIONAL_POS_TAG,
&(pNfapiMsg->pusch_param.pusch_dmrs_additional_pos),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_CBG_TAG,
&(pNfapiMsg->pusch_param.pusch_cbg),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_MAPPING_TYPE_TAG,
&(pNfapiMsg->pusch_param.pusch_mapping_type),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_ALLOCATION_TYPES_TAG,
&(pNfapiMsg->pusch_param.pusch_allocation_types),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_VRB_TO_PRB_MAPPING_TAG,
&(pNfapiMsg->pusch_param.pusch_vrb_to_prb_mapping),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_MAX_PTRS_PORTS_TAG,
&(pNfapiMsg->pusch_param.pusch_max_ptrs_ports),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PDUSCHS_TBS_PER_SLOT_TAG,
&(pNfapiMsg->pusch_param.max_pduschs_tbs_per_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG,
&(pNfapiMsg->pusch_param.max_number_mimo_layers_non_cb_pusch),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_MODULATION_ORDER_UL_TAG,
&(pNfapiMsg->pusch_param.supported_modulation_order_ul),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_UL_TAG,
&(pNfapiMsg->pusch_param.max_mu_mimo_users_ul),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_DFTS_OFDM_SUPPORT_TAG,
&(pNfapiMsg->pusch_param.dfts_ofdm_support),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_AGGREGATION_FACTOR_TAG,
&(pNfapiMsg->pusch_param.pusch_aggregation_factor),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PRACH_LONG_FORMATS_TAG,
&(pNfapiMsg->prach_param.prach_long_formats),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PRACH_SHORT_FORMATS_TAG,
&(pNfapiMsg->prach_param.prach_short_formats),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PRACH_RESTRICTED_SETS_TAG,
&(pNfapiMsg->prach_param.prach_restricted_sets),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG,
&(pNfapiMsg->prach_param.max_prach_fd_occasions_in_a_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_RSSI_MEASUREMENT_SUPPORT_TAG,
&(pNfapiMsg->measurement_param.rssi_measurement_support),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&&
// config:
pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4),
ppWritePackedMsg,
end,
&pack_ipv4_address_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6),
ppWritePackedMsg,
end,
&pack_ipv6_address_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_PORT_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_port),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG,
&(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4),
ppWritePackedMsg,
end,
&pack_ipv4_address_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG,
&(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6),
ppWritePackedMsg,
end,
&pack_ipv6_address_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_PNF_PORT_TAG,
&(pNfapiMsg->nfapi_config.p7_pnf_port),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_WINDOW_TAG,
&(pNfapiMsg->nfapi_config.timing_window),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG,
&(pNfapiMsg->nfapi_config.timing_info_mode),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG,
&(pNfapiMsg->nfapi_config.timing_info_period),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
return retval;
}
static uint8_t unpack_config_tlvs_to_report(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
{
uint8_t *pStartOfValue = *ppReadPackedMsg;
nfapi_nr_cell_param_t *cellParamTable = (nfapi_nr_cell_param_t *)tlv;
uint8_t retval = pull16(ppReadPackedMsg, &cellParamTable->num_config_tlvs_to_report.value, end);
// check if the length was right;
if (cellParamTable->num_config_tlvs_to_report.tl.length != (*ppReadPackedMsg - pStartOfValue)) {
NFAPI_TRACE(NFAPI_TRACE_ERROR,
"Warning tlv tag 0x%x length %d not equal to unpack %ld\n",
cellParamTable->num_config_tlvs_to_report.tl.tag,
cellParamTable->num_config_tlvs_to_report.tl.length,
(*ppReadPackedMsg - pStartOfValue));
}
// Remove padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
int padding = get_tlv_padding(cellParamTable->num_config_tlvs_to_report.tl.length);
if (padding != 0) {
(*ppReadPackedMsg) += padding;
}
// after this value, get the tlv list
cellParamTable->config_tlvs_to_report_list = calloc(cellParamTable->num_config_tlvs_to_report.value, sizeof(nfapi_uint8_tlv_t *));
for (int i = 0; i < cellParamTable->num_config_tlvs_to_report.value; ++i) {
pull16(ppReadPackedMsg, &cellParamTable->config_tlvs_to_report_list[i].tl.tag, end);
pull8(ppReadPackedMsg, (uint8_t *)&cellParamTable->config_tlvs_to_report_list[i].tl.length, end);
pull8(ppReadPackedMsg, &cellParamTable->config_tlvs_to_report_list[i].value, end);
// Remove padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
padding = get_tlv_padding(cellParamTable->config_tlvs_to_report_list[i].tl.length);
if (padding != 0) {
(*ppReadPackedMsg) += padding;
}
}
return retval;
}
uint8_t unpack_nr_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_param_response_scf_t *pNfapiMsg = (nfapi_nr_param_response_scf_t *)msg;
unpack_tlv_t unpack_fns[] = {
{NFAPI_NR_PARAM_TLV_RELEASE_CAPABILITY_TAG, &(pNfapiMsg->cell_param.release_capability), &unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_PHY_STATE_TAG, &(pNfapiMsg->cell_param.phy_state), &unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_SKIP_BLANK_DL_CONFIG_TAG, &(pNfapiMsg->cell_param.skip_blank_dl_config), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_SKIP_BLANK_UL_CONFIG_TAG, &(pNfapiMsg->cell_param.skip_blank_ul_config), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_NUM_CONFIG_TLVS_TO_REPORT_TAG, &(pNfapiMsg->cell_param), &unpack_config_tlvs_to_report},
{NFAPI_NR_PARAM_TLV_CYCLIC_PREFIX_TAG, &(pNfapiMsg->carrier_param.cyclic_prefix), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_DL_TAG,
&(pNfapiMsg->carrier_param.supported_subcarrier_spacings_dl),
&unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_DL_TAG, &(pNfapiMsg->carrier_param.supported_bandwidth_dl), &unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_UL_TAG,
&(pNfapiMsg->carrier_param.supported_subcarrier_spacings_ul),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_UL_TAG, &(pNfapiMsg->carrier_param.supported_bandwidth_ul), &unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_CCE_MAPPING_TYPE_TAG, &(pNfapiMsg->pdcch_param.cce_mapping_type), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG,
&(pNfapiMsg->pdcch_param.coreset_outside_first_3_of_ofdm_syms_of_slot),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PRECODER_GRANULARITY_CORESET_TAG,
&(pNfapiMsg->pdcch_param.coreset_precoder_granularity_coreset),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDCCH_MU_MIMO_TAG, &(pNfapiMsg->pdcch_param.pdcch_mu_mimo), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDCCH_PRECODER_CYCLING_TAG, &(pNfapiMsg->pdcch_param.pdcch_precoder_cycling), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PDCCHS_PER_SLOT_TAG, &(pNfapiMsg->pdcch_param.max_pdcch_per_slot), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUCCH_FORMATS_TAG, &(pNfapiMsg->pucch_param.pucch_formats), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PUCCHS_PER_SLOT_TAG, &(pNfapiMsg->pucch_param.max_pucchs_per_slot), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_MAPPING_TYPE_TAG, &(pNfapiMsg->pdsch_param.pdsch_mapping_type), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_ALLOCATION_TYPES_TAG, &(pNfapiMsg->pdsch_param.pdsch_allocation_types), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_VRB_TO_PRB_MAPPING_TAG,
&(pNfapiMsg->pdsch_param.pdsch_vrb_to_prb_mapping),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_CBG_TAG, &(pNfapiMsg->pdsch_param.pdsch_cbg), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_DMRS_CONFIG_TYPES_TAG, &(pNfapiMsg->pdsch_param.pdsch_dmrs_config_types), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_DMRS_MAX_LENGTH_TAG, &(pNfapiMsg->pdsch_param.pdsch_dmrs_max_length), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_DMRS_ADDITIONAL_POS_TAG,
&(pNfapiMsg->pdsch_param.pdsch_dmrs_additional_pos),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PDSCH_S_TBS_PER_SLOT_TAG, &(pNfapiMsg->pdsch_param.max_pdsch_tbs_per_slot), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG,
&(pNfapiMsg->pdsch_param.max_number_mimo_layers_pdsch),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG,
&(pNfapiMsg->pdsch_param.supported_max_modulation_order_dl),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_DL_TAG, &(pNfapiMsg->pdsch_param.max_mu_mimo_users_dl), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG,
&(pNfapiMsg->pdsch_param.pdsch_data_in_dmrs_symbols),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PREMPTION_SUPPORT_TAG, &(pNfapiMsg->pdsch_param.premption_support), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_NON_SLOT_SUPPORT_TAG, &(pNfapiMsg->pdsch_param.pdsch_non_slot_support), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_UCI_MUX_ULSCH_IN_PUSCH_TAG, &(pNfapiMsg->pusch_param.uci_mux_ulsch_in_pusch), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_UCI_ONLY_PUSCH_TAG, &(pNfapiMsg->pusch_param.uci_only_pusch), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_FREQUENCY_HOPPING_TAG, &(pNfapiMsg->pusch_param.pusch_frequency_hopping), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_DMRS_CONFIG_TYPES_TAG, &(pNfapiMsg->pusch_param.pusch_dmrs_config_types), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_DMRS_MAX_LEN_TAG, &(pNfapiMsg->pusch_param.pusch_dmrs_max_len), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_DMRS_ADDITIONAL_POS_TAG,
&(pNfapiMsg->pusch_param.pusch_dmrs_additional_pos),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_CBG_TAG, &(pNfapiMsg->pusch_param.pusch_cbg), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_MAPPING_TYPE_TAG, &(pNfapiMsg->pusch_param.pusch_mapping_type), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_ALLOCATION_TYPES_TAG, &(pNfapiMsg->pusch_param.pusch_allocation_types), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_VRB_TO_PRB_MAPPING_TAG,
&(pNfapiMsg->pusch_param.pusch_vrb_to_prb_mapping),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_MAX_PTRS_PORTS_TAG, &(pNfapiMsg->pusch_param.pusch_max_ptrs_ports), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PDUSCHS_TBS_PER_SLOT_TAG,
&(pNfapiMsg->pusch_param.max_pduschs_tbs_per_slot),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG,
&(pNfapiMsg->pusch_param.max_number_mimo_layers_non_cb_pusch),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_MODULATION_ORDER_UL_TAG,
&(pNfapiMsg->pusch_param.supported_modulation_order_ul),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_UL_TAG, &(pNfapiMsg->pusch_param.max_mu_mimo_users_ul), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_DFTS_OFDM_SUPPORT_TAG, &(pNfapiMsg->pusch_param.dfts_ofdm_support), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_AGGREGATION_FACTOR_TAG,
&(pNfapiMsg->pusch_param.pusch_aggregation_factor),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PRACH_LONG_FORMATS_TAG, &(pNfapiMsg->prach_param.prach_long_formats), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PRACH_SHORT_FORMATS_TAG, &(pNfapiMsg->prach_param.prach_short_formats), &unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_PRACH_RESTRICTED_SETS_TAG, &(pNfapiMsg->prach_param.prach_restricted_sets), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG,
&(pNfapiMsg->prach_param.max_prach_fd_occasions_in_a_slot),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_RSSI_MEASUREMENT_SUPPORT_TAG,
&(pNfapiMsg->measurement_param.rssi_measurement_support),
&unpack_uint8_tlv_value},
// config
{NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &pNfapiMsg->nfapi_config.p7_vnf_address_ipv4, &unpack_ipv4_address_value},
{NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &pNfapiMsg->nfapi_config.p7_vnf_address_ipv6, &unpack_ipv6_address_value},
{NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, &pNfapiMsg->nfapi_config.p7_vnf_port, &unpack_uint16_tlv_value},
{NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv4, &unpack_ipv4_address_value},
{NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv6, &unpack_ipv6_address_value},
{NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &pNfapiMsg->nfapi_config.p7_pnf_port, &unpack_uint16_tlv_value},
{NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &pNfapiMsg->nfapi_config.timing_window, &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &pNfapiMsg->nfapi_config.timing_info_mode, &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &pNfapiMsg->nfapi_config.timing_info_period, &unpack_uint8_tlv_value},
};
// print ppReadPackedMsg
uint8_t *ptr = *ppReadPackedMsg;
printf("\n Read message unpack_param_response: ");
while (ptr < end) {
printf(" 0x%02x", *ptr);
ptr++;
}
printf("\n");
return (pull8(ppReadPackedMsg, &pNfapiMsg->error_code, end) && pull8(ppReadPackedMsg, &pNfapiMsg->num_tlv, end)
&& unpack_nr_tlv_list(unpack_fns,
sizeof(unpack_fns) / sizeof(unpack_tlv_t),
ppReadPackedMsg,
end,
config,
&pNfapiMsg->vendor_extension));
}
uint8_t pack_nr_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
uint8_t *pNumTLVFields = (uint8_t *)*ppWritePackedMsg;
nfapi_nr_config_request_scf_t *pNfapiMsg = (nfapi_nr_config_request_scf_t *)msg;
uint8_t numTLVs = 0;
*ppWritePackedMsg += 1; // Advance the buffer past the 'location' to push numTLVs
// START Carrier Configuration
uint8_t retval = pack_nr_tlv(NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG,
&(pNfapiMsg->carrier_config.dl_bandwidth),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_DL_FREQUENCY_TAG,
&(pNfapiMsg->carrier_config.dl_frequency),
ppWritePackedMsg,
end,
&pack_uint32_tlv_value);
numTLVs++;
retval &= push16(NFAPI_NR_CONFIG_DL_K0_TAG, ppWritePackedMsg, end) && push16(5 * sizeof(uint16_t), ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[0].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[1].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[2].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[3].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[4].value, ppWritePackedMsg, end)
&& push16(0, ppWritePackedMsg, end); // Padding
numTLVs++;
retval &= push16(NFAPI_NR_CONFIG_DL_GRID_SIZE_TAG, ppWritePackedMsg, end) && push16(5 * sizeof(uint16_t), ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[0].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[1].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[2].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[3].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[4].value, ppWritePackedMsg, end)
&& push16(0, ppWritePackedMsg, end); // Padding
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_TX_ANT_TAG,
&(pNfapiMsg->carrier_config.num_tx_ant),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_UPLINK_BANDWIDTH_TAG,
&(pNfapiMsg->carrier_config.uplink_bandwidth),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_UPLINK_FREQUENCY_TAG,
&(pNfapiMsg->carrier_config.uplink_frequency),
ppWritePackedMsg,
end,
&pack_uint32_tlv_value);
numTLVs++;
retval &= push16(NFAPI_NR_CONFIG_UL_K0_TAG, ppWritePackedMsg, end) && push16(5 * sizeof(uint16_t), ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[0].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[1].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[2].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[3].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[4].value, ppWritePackedMsg, end)
&& push16(0, ppWritePackedMsg, end); // Padding
numTLVs++;
retval &= push16(NFAPI_NR_CONFIG_UL_GRID_SIZE_TAG, ppWritePackedMsg, end) && push16(5 * sizeof(uint16_t), ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[0].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[1].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[2].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[3].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[4].value, ppWritePackedMsg, end)
&& push16(0, ppWritePackedMsg, end); // Padding
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_RX_ANT_TAG,
&(pNfapiMsg->carrier_config.num_rx_ant),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
#ifndef ENABLE_AERIAL
// TLV not supported by Aerial L1
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_FREQUENCY_SHIFT_7P5KHZ_TAG,
&(pNfapiMsg->carrier_config.frequency_shift_7p5khz),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
#endif
// END Carrier Configuration
// START Cell Configuration
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PHY_CELL_ID_TAG,
&(pNfapiMsg->cell_config.phy_cell_id),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_FRAME_DUPLEX_TYPE_TAG,
&(pNfapiMsg->cell_config.frame_duplex_type),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
// END Cell Configuration
// START SSB Configuration
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SS_PBCH_POWER_TAG,
&(pNfapiMsg->ssb_config.ss_pbch_power),
ppWritePackedMsg,
end,
&pack_uint32_tlv_value);
numTLVs++;
#ifndef ENABLE_AERIAL
// TLV not supported by Aerial L1
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_BCH_PAYLOAD_TAG,
&(pNfapiMsg->ssb_config.bch_payload),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
#endif
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SCS_COMMON_TAG,
&(pNfapiMsg->ssb_config.scs_common),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
// END SSB Configuration
// START PRACH Configuration
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_SEQUENCE_LENGTH_TAG,
&(pNfapiMsg->prach_config.prach_sequence_length),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_SUB_C_SPACING_TAG,
&(pNfapiMsg->prach_config.prach_sub_c_spacing),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_RESTRICTED_SET_CONFIG_TAG,
&(pNfapiMsg->prach_config.restricted_set_config),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_PRACH_FD_OCCASIONS_TAG,
&(pNfapiMsg->prach_config.num_prach_fd_occasions),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_CONFIG_INDEX_TAG,
&(pNfapiMsg->prach_config.prach_ConfigurationIndex),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
for (int i = 0; i < pNfapiMsg->prach_config.num_prach_fd_occasions.value; i++) {
nfapi_nr_num_prach_fd_occasions_t prach_fd_occasion = pNfapiMsg->prach_config.num_prach_fd_occasions_list[i];
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG,
&(prach_fd_occasion.prach_root_sequence_index),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG,
&(prach_fd_occasion.num_root_sequences),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_K1_TAG, &(prach_fd_occasion.k1), ppWritePackedMsg, end, &pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG,
&(prach_fd_occasion.prach_zero_corr_conf),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_UNUSED_ROOT_SEQUENCES_TAG,
&(prach_fd_occasion.num_unused_root_sequences),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
for (int k = 0; k < prach_fd_occasion.num_unused_root_sequences.value; k++) {
prach_fd_occasion.unused_root_sequences_list[k].tl.tag = NFAPI_NR_CONFIG_UNUSED_ROOT_SEQUENCES_TAG;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_UNUSED_ROOT_SEQUENCES_TAG,
&(prach_fd_occasion.unused_root_sequences_list[k]),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
}
}
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_PER_RACH_TAG,
&(pNfapiMsg->prach_config.ssb_per_rach),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
pNfapiMsg->prach_config.prach_multiple_carriers_in_a_band.tl.tag = NFAPI_NR_CONFIG_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG,
&(pNfapiMsg->prach_config.prach_multiple_carriers_in_a_band),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
// END PRACH Configuration
// START SSB Table
#ifndef ENABLE_AERIAL
// TLV not supported by Aerial L1
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG,
&(pNfapiMsg->ssb_table.ssb_offset_point_a),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
#endif
retval &=
pack_nr_tlv(NFAPI_NR_CONFIG_SSB_PERIOD_TAG, &(pNfapiMsg->ssb_table.ssb_period), ppWritePackedMsg, end, &pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG,
&(pNfapiMsg->ssb_table.ssb_subcarrier_offset),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
/* was unused */
pNfapiMsg->ssb_table.MIB.tl.tag = NFAPI_NR_CONFIG_MIB_TAG;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_MIB_TAG, &(pNfapiMsg->ssb_table.MIB), ppWritePackedMsg, end, &pack_uint32_tlv_value);
numTLVs++;
// SCF222.10.02 Table 3-25 : If included there must be two instances of this TLV
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_MASK_TAG,
&(pNfapiMsg->ssb_table.ssb_mask_list[0].ssb_mask),
ppWritePackedMsg,
end,
&pack_uint32_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_MASK_TAG,
&(pNfapiMsg->ssb_table.ssb_mask_list[1].ssb_mask),
ppWritePackedMsg,
end,
&pack_uint32_tlv_value);
numTLVs++;
#ifndef ENABLE_AERIAL
// TLV not supported by Aerial L1
for (int i = 0; i < 64; i++) {
// SCF222.10.02 Table 3-25 : If included there must be 64 instances of this TLV
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_BEAM_ID_TAG,
&(pNfapiMsg->ssb_table.ssb_beam_id_list[i].beam_id),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
}
// END SSB Table
// START TDD Table
retval &=
pack_nr_tlv(NFAPI_NR_CONFIG_TDD_PERIOD_TAG, &(pNfapiMsg->tdd_table.tdd_period), ppWritePackedMsg, end, &pack_uint8_tlv_value);
numTLVs++;
const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160};
// Assuming always CP_Normal, because Cyclic prefix is not included in CONFIG.request 10.02, but is present in 10.04
uint8_t cyclicprefix = 1;
bool normal_CP = cyclicprefix ? false : true;
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
uint8_t number_of_symbols_per_slot = normal_CP ? 14 : 12;
for (int i = 0; i < slotsperframe[pNfapiMsg->ssb_config.scs_common.value]; i++) { // TODO check right number of slots
for (int k = 0; k < number_of_symbols_per_slot; k++) { // TODO can change?
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SLOT_CONFIG_TAG,
&pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list[k].slot_config,
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
}
}
// END TDD Table
#endif
// START Measurement Config
// SCF222.10.02 Table 3-27 : Contains only one TLV and is currently unused
pNfapiMsg->measurement_config.rssi_measurement.tl.tag = NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG;
pNfapiMsg->measurement_config.rssi_measurement.value = 1;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG,
&(pNfapiMsg->measurement_config.rssi_measurement),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
// END Measurement Config
// START Digital Beam Table (DBT) PDU
// Struct in nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h nfapi_nr_dbt_pdu_t, currently unused
// END Digital Beam Table (DBT) PDU
// START Precoding Matrix (PM) PDU
// Struct in nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h nfapi_nr_pm_pdu_t, currently unused, tag to use for AERIAL
// is 0xA011 END Precoding Matrix (PM) PDU
#ifndef ENABLE_AERIAL
// START nFAPI TLVs included in CONFIG.request for IDLE and CONFIGURED states
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4),
ppWritePackedMsg,
end,
&pack_ipv4_address_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6),
ppWritePackedMsg,
end,
&pack_ipv6_address_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_PORT_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_port),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_WINDOW_TAG,
&(pNfapiMsg->nfapi_config.timing_window),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG,
&(pNfapiMsg->nfapi_config.timing_info_mode),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG,
&(pNfapiMsg->nfapi_config.timing_info_period),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
// END nFAPI TLVs included in CONFIG.request for IDLE and CONFIGURED states
if (pNfapiMsg->vendor_extension != 0 && config != 0) {
retval &= pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "Packing CONFIG.request vendor_extension_tlv %d\n", pNfapiMsg->vendor_extension->tag);
numTLVs++;
}
#endif
pNfapiMsg->num_tlv = numTLVs;
retval &= push8(pNfapiMsg->num_tlv, &pNumTLVFields, end);
return retval;
}
uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
// Helper vars for indexed TLVs
int prach_root_seq_idx = 0;
int unused_root_seq_idx = 0;
int ssb_mask_idx = 0;
int config_beam_idx = 0;
int tdd_periodicity_idx = 0;
int symbol_per_slot_idx = 0;
nfapi_nr_config_request_scf_t *pNfapiMsg = (nfapi_nr_config_request_scf_t *)msg;
// unpack TLVs
unpack_tlv_t unpack_fns[] = {
{NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG, &(pNfapiMsg->carrier_config.dl_bandwidth), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_DL_FREQUENCY_TAG, &(pNfapiMsg->carrier_config.dl_frequency), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_DL_GRID_SIZE_TAG, &(pNfapiMsg->carrier_config.dl_grid_size[1]), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_DL_K0_TAG, &(pNfapiMsg->carrier_config.dl_k0[1]), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_NUM_TX_ANT_TAG, &(pNfapiMsg->carrier_config.num_tx_ant), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_UPLINK_BANDWIDTH_TAG, &(pNfapiMsg->carrier_config.uplink_bandwidth), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_UPLINK_FREQUENCY_TAG, &(pNfapiMsg->carrier_config.uplink_frequency), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_UL_GRID_SIZE_TAG, &(pNfapiMsg->carrier_config.ul_grid_size[1]), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_UL_K0_TAG, &(pNfapiMsg->carrier_config.ul_k0[1]), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_NUM_RX_ANT_TAG, &(pNfapiMsg->carrier_config.num_rx_ant), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_FREQUENCY_SHIFT_7P5KHZ_TAG, &(pNfapiMsg->carrier_config.frequency_shift_7p5khz), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PHY_CELL_ID_TAG, &(pNfapiMsg->cell_config.phy_cell_id), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_FRAME_DUPLEX_TYPE_TAG, &(pNfapiMsg->cell_config.frame_duplex_type), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SS_PBCH_POWER_TAG, &(pNfapiMsg->ssb_config.ss_pbch_power), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_BCH_PAYLOAD_TAG, &(pNfapiMsg->ssb_config.bch_payload), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SCS_COMMON_TAG, &(pNfapiMsg->ssb_config.scs_common), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_SEQUENCE_LENGTH_TAG, &(pNfapiMsg->prach_config.prach_sequence_length), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_SUB_C_SPACING_TAG, &(pNfapiMsg->prach_config.prach_sub_c_spacing), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_RESTRICTED_SET_CONFIG_TAG, &(pNfapiMsg->prach_config.restricted_set_config), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_NUM_PRACH_FD_OCCASIONS_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_CONFIG_INDEX_TAG, &(pNfapiMsg->prach_config.prach_ConfigurationIndex), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG, NULL, &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG, NULL, &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_K1_TAG, NULL, &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG, NULL, &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_NUM_UNUSED_ROOT_SEQUENCES_TAG, NULL, &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_UNUSED_ROOT_SEQUENCES_TAG, NULL, &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_SSB_PER_RACH_TAG, &(pNfapiMsg->prach_config.ssb_per_rach), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG,
&(pNfapiMsg->prach_config.prach_multiple_carriers_in_a_band),
&unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG, &(pNfapiMsg->ssb_table.ssb_offset_point_a), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_BETA_PSS_TAG, &(pNfapiMsg->ssb_table.beta_pss), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SSB_PERIOD_TAG, &(pNfapiMsg->ssb_table.ssb_period), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG, &(pNfapiMsg->ssb_table.ssb_subcarrier_offset), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_MIB_TAG, &(pNfapiMsg->ssb_table.MIB), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_SSB_MASK_TAG, &(pNfapiMsg->ssb_table.ssb_mask_list[0].ssb_mask), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_BEAM_ID_TAG, &(pNfapiMsg->ssb_table.ssb_beam_id_list[0].beam_id), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG,
&(pNfapiMsg->ssb_table.ss_pbch_multiple_carriers_in_a_band),
&unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG,
&(pNfapiMsg->ssb_table.multiple_cells_ss_pbch_in_a_carrier),
&unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_TDD_PERIOD_TAG, &(pNfapiMsg->tdd_table.tdd_period), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SLOT_CONFIG_TAG, NULL, &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG, &(pNfapiMsg->measurement_config.rssi_measurement), &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), &unpack_ipv4_address_value},
{NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6), &unpack_ipv6_address_value},
{NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_port), &unpack_uint16_tlv_value},
{NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), &unpack_ipv6_address_value},
{NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), &unpack_uint16_tlv_value}};
pull8(ppReadPackedMsg, &pNfapiMsg->num_tlv, end);
pNfapiMsg->vendor_extension = malloc(sizeof(&(pNfapiMsg->vendor_extension)));
nfapi_tl_t generic_tl;
uint8_t numBadTags = 0;
unsigned long idx = 0;
while ((uint8_t *)(*ppReadPackedMsg) < end) {
// unpack the tl and process the values accordingly
if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
return 0;
uint8_t tagMatch = 0;
uint8_t *pStartOfValue = 0;
for (idx = 0; idx < sizeof(unpack_fns) / sizeof(unpack_tlv_t); ++idx) {
if (unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list
pStartOfValue = *ppReadPackedMsg;
tagMatch = 1;
nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv);
if (tl) {
tl->tag = generic_tl.tag;
tl->length = generic_tl.length;
}
int result = 0;
switch (generic_tl.tag) {
case NFAPI_NR_CONFIG_NUM_PRACH_FD_OCCASIONS_TAG:
pNfapiMsg->prach_config.num_prach_fd_occasions.tl.tag = generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->prach_config.num_prach_fd_occasions, ppReadPackedMsg, end);
pNfapiMsg->prach_config.num_prach_fd_occasions_list = (nfapi_nr_num_prach_fd_occasions_t *)malloc(
pNfapiMsg->prach_config.num_prach_fd_occasions.value * sizeof(nfapi_nr_num_prach_fd_occasions_t));
prach_root_seq_idx = 0;
break;
case NFAPI_NR_CONFIG_SCS_COMMON_TAG:
pNfapiMsg->ssb_config.scs_common.tl.tag = generic_tl.tag;
pNfapiMsg->ssb_config.scs_common.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->ssb_config.scs_common, ppReadPackedMsg, end);
const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160};
// Assuming always CP_Normal, because Cyclic prefix is not included in CONFIG.request 10.02, but is present in 10.04
uint8_t cyclicprefix = 1;
bool normal_CP = cyclicprefix ? false : true;
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
uint8_t number_of_symbols_per_slot = normal_CP ? 14 : 12;
pNfapiMsg->tdd_table.max_tdd_periodicity_list = (nfapi_nr_max_tdd_periodicity_t *)malloc(
slotsperframe[pNfapiMsg->ssb_config.scs_common.value] * sizeof(nfapi_nr_max_tdd_periodicity_t));
for (int i = 0; i < slotsperframe[pNfapiMsg->ssb_config.scs_common.value]; i++) {
pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list =
(nfapi_nr_max_num_of_symbol_per_slot_t *)malloc(number_of_symbols_per_slot
* sizeof(nfapi_nr_max_num_of_symbol_per_slot_t));
}
break;
case NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG:
unpack_fns[idx].tlv =
&(pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_root_sequence_index);
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_root_sequence_index.tl.tag =
generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_root_sequence_index.tl.length =
generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(
&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_root_sequence_index,
ppReadPackedMsg,
end);
break;
case NFAPI_NR_CONFIG_K1_TAG:
unpack_fns[idx].tlv = &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].k1);
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].k1.tl.tag = generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].k1.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].k1,
ppReadPackedMsg,
end);
break;
case NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG:
unpack_fns[idx].tlv = &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_zero_corr_conf);
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_zero_corr_conf.tl.tag = generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_zero_corr_conf.tl.length =
generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(
&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_zero_corr_conf,
ppReadPackedMsg,
end);
break;
case NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG:
unpack_fns[idx].tlv = &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_root_sequences);
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_root_sequences.tl.tag = generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_root_sequences.tl.length =
generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(
&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_root_sequences,
ppReadPackedMsg,
end);
break;
case NFAPI_NR_CONFIG_NUM_UNUSED_ROOT_SEQUENCES_TAG:
unpack_fns[idx].tlv =
&(pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_unused_root_sequences);
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_unused_root_sequences.tl.tag =
generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_unused_root_sequences.tl.length =
generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(
&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_unused_root_sequences,
ppReadPackedMsg,
end);
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].unused_root_sequences_list =
(nfapi_uint8_tlv_t *)malloc(
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_unused_root_sequences.value
* sizeof(nfapi_uint8_tlv_t));
unused_root_seq_idx = 0;
break;
case NFAPI_NR_CONFIG_UNUSED_ROOT_SEQUENCES_TAG:
unpack_fns[idx].tlv = &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx]
.unused_root_sequences_list[unused_root_seq_idx]);
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx]
.unused_root_sequences_list[unused_root_seq_idx]
.tl.tag = generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx]
.unused_root_sequences_list[unused_root_seq_idx]
.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx]
.unused_root_sequences_list[unused_root_seq_idx],
ppReadPackedMsg,
end);
unused_root_seq_idx++;
// last tlv of the list
if (unused_root_seq_idx
>= pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_unused_root_sequences.value) {
prach_root_seq_idx++;
unused_root_seq_idx = 0;
}
break;
case NFAPI_NR_CONFIG_SSB_MASK_TAG:
pNfapiMsg->ssb_table.ssb_mask_list[ssb_mask_idx].ssb_mask.tl.tag = generic_tl.tag;
pNfapiMsg->ssb_table.ssb_mask_list[ssb_mask_idx].ssb_mask.tl.length = generic_tl.length;
result = unpack_uint32_tlv_value(&pNfapiMsg->ssb_table.ssb_mask_list[ssb_mask_idx].ssb_mask, ppReadPackedMsg, end);
ssb_mask_idx++;
break;
case NFAPI_NR_CONFIG_DL_GRID_SIZE_TAG:
for (int i = 0; i < 5; i++) {
pNfapiMsg->carrier_config.dl_grid_size[i].tl.tag = generic_tl.tag;
result = unpack_uint16_tlv_value(&pNfapiMsg->carrier_config.dl_grid_size[i], ppReadPackedMsg, end);
}
break;
case NFAPI_NR_CONFIG_DL_K0_TAG:
for (int i = 0; i < 5; i++) {
pNfapiMsg->carrier_config.dl_k0[i].tl.tag = generic_tl.tag;
result = unpack_uint16_tlv_value(&pNfapiMsg->carrier_config.dl_k0[i], ppReadPackedMsg, end);
}
break;
case NFAPI_NR_CONFIG_UL_GRID_SIZE_TAG:
for (int i = 0; i < 5; i++) {
pNfapiMsg->carrier_config.ul_grid_size[i].tl.tag = generic_tl.tag;
result = unpack_uint16_tlv_value(&pNfapiMsg->carrier_config.ul_grid_size[i], ppReadPackedMsg, end);
}
break;
case NFAPI_NR_CONFIG_UL_K0_TAG:
for (int i = 0; i < 5; i++) {
pNfapiMsg->carrier_config.ul_k0[i].tl.tag = generic_tl.tag;
result = unpack_uint16_tlv_value(&pNfapiMsg->carrier_config.ul_k0[i], ppReadPackedMsg, end);
}
break;
case NFAPI_NR_CONFIG_BEAM_ID_TAG:
pNfapiMsg->ssb_table.ssb_beam_id_list[config_beam_idx].beam_id.tl.tag = generic_tl.tag;
pNfapiMsg->ssb_table.ssb_beam_id_list[config_beam_idx].beam_id.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->ssb_table.ssb_beam_id_list[config_beam_idx].beam_id,
ppReadPackedMsg,
end);
config_beam_idx++;
break;
case NFAPI_NR_CONFIG_SLOT_CONFIG_TAG:
unpack_fns[idx].tlv = &(pNfapiMsg->tdd_table.max_tdd_periodicity_list[tdd_periodicity_idx]
.max_num_of_symbol_per_slot_list[symbol_per_slot_idx]
.slot_config);
pNfapiMsg->tdd_table.max_tdd_periodicity_list[tdd_periodicity_idx]
.max_num_of_symbol_per_slot_list[symbol_per_slot_idx]
.slot_config.tl.tag = generic_tl.tag;
pNfapiMsg->tdd_table.max_tdd_periodicity_list[tdd_periodicity_idx]
.max_num_of_symbol_per_slot_list[symbol_per_slot_idx]
.slot_config.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->tdd_table.max_tdd_periodicity_list[tdd_periodicity_idx]
.max_num_of_symbol_per_slot_list[symbol_per_slot_idx]
.slot_config,
ppReadPackedMsg,
end);
symbol_per_slot_idx = (symbol_per_slot_idx + 1) % number_of_symbols_per_slot;
if (symbol_per_slot_idx == 0) {
tdd_periodicity_idx++;
}
break;
default:
result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end);
break;
}
// update tl pointer with updated value, if it was set in the switch (it was inside lists)
if (!tl) {
tl = (nfapi_tl_t *)(unpack_fns[idx].tlv);
tl->tag = generic_tl.tag;
tl->length = generic_tl.length;
}
if (result == 0)
return 0;
// check if the length was right;
if (tl->length != (((*ppReadPackedMsg)) - pStartOfValue))
NFAPI_TRACE(NFAPI_TRACE_ERROR,
"Warning tlv tag 0x%x length %d not equal to unpack %lu\n",
tl->tag,
tl->length,
(*ppReadPackedMsg - pStartOfValue));
// Remove padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
int padding = get_tlv_padding(tl->length);
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "TLV 0x%x length %d with padding of %d bytes\n", tl->tag, tl->length, padding);
if (padding != 0)
(*ppReadPackedMsg) += padding;
}
}
if (tagMatch == 0) {
if (generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) {
int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
if (result == 0) {
// got to the end.
return 0;
} else if (result < 0) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag);
if (++numBadTags > MAX_BAD_TAG) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n");
return 0;
}
if ((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length;
int padding = get_tlv_padding(generic_tl.length);
(*ppReadPackedMsg) += padding;
} else {
// go to the end
return 0;
}
}
} else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag);
if (++numBadTags > MAX_BAD_TAG) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n");
return 0;
}
if ((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length;
int padding = get_tlv_padding(generic_tl.length);
(*ppReadPackedMsg) += padding;
} else {
// go to the end
return 0;
}
}
}
}
struct sockaddr_in vnf_p7_sockaddr;
memcpy(&vnf_p7_sockaddr.sin_addr.s_addr, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), 4);
printf("[PNF] vnf p7 %s:%d\n", inet_ntoa(vnf_p7_sockaddr.sin_addr), pNfapiMsg->nfapi_config.p7_vnf_port.value);
return 1;
}
uint8_t pack_nr_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_config_response_scf_t *pNfapiMsg = (nfapi_nr_config_response_scf_t *)msg;
uint8_t retval = push8(pNfapiMsg->error_code, ppWritePackedMsg, end);
retval &= push8(pNfapiMsg->num_invalid_tlvs, ppWritePackedMsg, end);
retval &= push8(pNfapiMsg->num_invalid_tlvs_configured_in_idle, ppWritePackedMsg, end);
retval &= push8(pNfapiMsg->num_invalid_tlvs_configured_in_running, ppWritePackedMsg, end);
retval &= push8(pNfapiMsg->num_missing_tlvs, ppWritePackedMsg, end);
// pack lists
for (int i = 0; i < pNfapiMsg->num_invalid_tlvs; ++i) {
nfapi_nr_generic_tlv_scf_t *element = &(pNfapiMsg->invalid_tlvs_list[i]);
pack_nr_generic_tlv(element->tl.tag, element, ppWritePackedMsg, end);
}
for (int i = 0; i < pNfapiMsg->num_invalid_tlvs_configured_in_idle; ++i) {
nfapi_nr_generic_tlv_scf_t *element = &(pNfapiMsg->invalid_tlvs_configured_in_idle_list[i]);
pack_nr_generic_tlv(element->tl.tag, element, ppWritePackedMsg, end);
}
for (int i = 0; i < pNfapiMsg->num_invalid_tlvs_configured_in_running; ++i) {
nfapi_nr_generic_tlv_scf_t *element = &(pNfapiMsg->invalid_tlvs_configured_in_running_list[i]);
pack_nr_generic_tlv(element->tl.tag, element, ppWritePackedMsg, end);
}
for (int i = 0; i < pNfapiMsg->num_missing_tlvs; ++i) {
nfapi_nr_generic_tlv_scf_t *element = &(pNfapiMsg->missing_tlvs_list[i]);
pack_nr_generic_tlv(element->tl.tag, element, ppWritePackedMsg, end);
}
retval &= pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
return retval;
}
uint8_t unpack_nr_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_config_response_scf_t *nfapi_resp = (nfapi_nr_config_response_scf_t *)msg;
uint8_t retval = pull8(ppReadPackedMsg, &nfapi_resp->error_code, end)
&& pull8(ppReadPackedMsg, &nfapi_resp->num_invalid_tlvs, end)
&& pull8(ppReadPackedMsg, &nfapi_resp->num_invalid_tlvs_configured_in_idle, end)
&& pull8(ppReadPackedMsg, &nfapi_resp->num_invalid_tlvs_configured_in_running, end)
&& pull8(ppReadPackedMsg, &nfapi_resp->num_missing_tlvs, end);
// First unpack the invalid_tlvs_list
// allocate the memory
nfapi_resp->invalid_tlvs_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(nfapi_resp->num_invalid_tlvs * sizeof(nfapi_nr_generic_tlv_scf_t));
nfapi_resp->invalid_tlvs_configured_in_idle_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(nfapi_resp->num_invalid_tlvs_configured_in_idle * sizeof(nfapi_nr_generic_tlv_scf_t));
nfapi_resp->invalid_tlvs_configured_in_running_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(nfapi_resp->num_invalid_tlvs_configured_in_running * sizeof(nfapi_nr_generic_tlv_scf_t));
nfapi_resp->missing_tlvs_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(nfapi_resp->num_missing_tlvs * sizeof(nfapi_nr_generic_tlv_scf_t));
// unpack the TLV lists
unpack_nr_generic_tlv_list(nfapi_resp->invalid_tlvs_list, nfapi_resp->num_invalid_tlvs, ppReadPackedMsg, end);
unpack_nr_generic_tlv_list(nfapi_resp->invalid_tlvs_configured_in_idle_list,
nfapi_resp->num_invalid_tlvs_configured_in_idle,
ppReadPackedMsg,
end);
unpack_nr_generic_tlv_list(nfapi_resp->invalid_tlvs_configured_in_running_list,
nfapi_resp->num_invalid_tlvs_configured_in_running,
ppReadPackedMsg,
end);
unpack_nr_generic_tlv_list(nfapi_resp->missing_tlvs_list, nfapi_resp->num_missing_tlvs, ppReadPackedMsg, end);
// TODO: Process and use the invalid TLVs fields
retval &= unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(nfapi_resp->vendor_extension));
return retval;
}
uint8_t pack_nr_start_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_start_request_scf_t *pNfapiMsg = (nfapi_nr_start_request_scf_t *)msg;
return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
}
uint8_t unpack_nr_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_start_request_scf_t *pNfapiMsg = (nfapi_nr_start_request_scf_t *)msg;
return unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
}
uint8_t pack_nr_start_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_start_response_scf_t *pNfapiMsg = (nfapi_nr_start_response_scf_t *)msg;
return (push8(pNfapiMsg->error_code, ppWritePackedMsg, end)
&& pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
uint8_t unpack_nr_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_start_response_scf_t *pNfapiMsg = (nfapi_nr_start_response_scf_t *)msg;
return (pull8(ppReadPackedMsg, (uint8_t *)&pNfapiMsg->error_code, end)
&& unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)));
}
uint8_t pack_nr_stop_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_stop_request_scf_t *pNfapiMsg = (nfapi_nr_stop_request_scf_t *)msg;
return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
}
uint8_t unpack_nr_stop_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_stop_request_scf_t *pNfapiMsg = (nfapi_nr_stop_request_scf_t *)msg;
return unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
}
uint8_t pack_nr_stop_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_stop_indication_scf_t *pNfapiMsg = (nfapi_nr_stop_indication_scf_t *)msg;
return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
}
uint8_t unpack_nr_stop_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_stop_indication_scf_t *pNfapiMsg = (nfapi_nr_stop_indication_scf_t *)msg;
return unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
}
uint8_t pack_nr_error_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_error_indication_scf_t *pNfapiMsg = (nfapi_nr_error_indication_scf_t *)msg;
uint8_t retval = push16(pNfapiMsg->sfn, ppWritePackedMsg, end);
retval &= push16(pNfapiMsg->slot, ppWritePackedMsg, end);
retval &= push8(pNfapiMsg->message_id, ppWritePackedMsg, end);
retval &= push8(pNfapiMsg->error_code, ppWritePackedMsg, end);
retval &= pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
return retval;
}
uint8_t unpack_nr_error_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_error_indication_scf_t *pNfapiMsg = (nfapi_nr_error_indication_scf_t *)msg;
uint8_t retval = pull16(ppReadPackedMsg, &pNfapiMsg->sfn, end);
retval &= pull16(ppReadPackedMsg, &pNfapiMsg->slot, end);
retval &= pull8(ppReadPackedMsg, &pNfapiMsg->message_id, end);
retval &= pull8(ppReadPackedMsg, &pNfapiMsg->error_code, end);
retval &= unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
return retval;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/open-nFAPI/fapi/src/nr_fapi_p5_utils.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nr_fapi_p5_utils.h"
void copy_vendor_extension_value(nfapi_vendor_extension_tlv_t *dst, const nfapi_vendor_extension_tlv_t *src)
{
nfapi_tl_t *dst_tlv = (nfapi_tl_t *)dst;
nfapi_tl_t *src_tlv = (nfapi_tl_t *)src;
switch (dst_tlv->tag) {
case VENDOR_EXT_TLV_2_TAG: {
vendor_ext_tlv_2 *dst_ve = (vendor_ext_tlv_2 *)dst_tlv;
vendor_ext_tlv_2 *src_ve = (vendor_ext_tlv_2 *)src_tlv;
dst_ve->dummy = src_ve->dummy;
} break;
case VENDOR_EXT_TLV_1_TAG: {
vendor_ext_tlv_1 *dst_ve = (vendor_ext_tlv_1 *)dst_tlv;
vendor_ext_tlv_1 *src_ve = (vendor_ext_tlv_1 *)src_tlv;
dst_ve->dummy = src_ve->dummy;
} break;
}
}
bool eq_param_request(const nfapi_nr_param_request_scf_t *unpacked_req, const nfapi_nr_param_request_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(unpacked_req->header.message_length, req->header.message_length);
return true;
}
bool eq_param_response(const nfapi_nr_param_response_scf_t *unpacked_req, const nfapi_nr_param_response_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(unpacked_req->header.message_length, req->header.message_length);
EQ(unpacked_req->num_tlv, req->num_tlv);
EQ(unpacked_req->error_code, req->error_code);
EQ_TLV(unpacked_req->cell_param.release_capability, req->cell_param.release_capability);
EQ_TLV(unpacked_req->cell_param.phy_state, req->cell_param.phy_state);
EQ_TLV(unpacked_req->cell_param.skip_blank_dl_config, req->cell_param.skip_blank_dl_config);
EQ_TLV(unpacked_req->cell_param.skip_blank_ul_config, req->cell_param.skip_blank_ul_config);
EQ_TLV(unpacked_req->cell_param.num_config_tlvs_to_report, req->cell_param.num_config_tlvs_to_report);
for (int i = 0; i < unpacked_req->cell_param.num_config_tlvs_to_report.value; ++i) {
EQ_TLV(unpacked_req->cell_param.config_tlvs_to_report_list[i], req->cell_param.config_tlvs_to_report_list[i]);
}
EQ_TLV(unpacked_req->carrier_param.cyclic_prefix, req->carrier_param.cyclic_prefix);
EQ_TLV(unpacked_req->carrier_param.supported_subcarrier_spacings_dl, req->carrier_param.supported_subcarrier_spacings_dl);
EQ_TLV(unpacked_req->carrier_param.supported_bandwidth_dl, req->carrier_param.supported_bandwidth_dl);
EQ_TLV(unpacked_req->carrier_param.supported_subcarrier_spacings_ul, req->carrier_param.supported_subcarrier_spacings_ul);
EQ_TLV(unpacked_req->carrier_param.supported_bandwidth_ul, req->carrier_param.supported_bandwidth_ul);
EQ_TLV(unpacked_req->pdcch_param.cce_mapping_type, req->pdcch_param.cce_mapping_type);
EQ_TLV(unpacked_req->pdcch_param.coreset_outside_first_3_of_ofdm_syms_of_slot,
req->pdcch_param.coreset_outside_first_3_of_ofdm_syms_of_slot);
EQ_TLV(unpacked_req->pdcch_param.coreset_precoder_granularity_coreset, req->pdcch_param.coreset_precoder_granularity_coreset);
EQ_TLV(unpacked_req->pdcch_param.pdcch_mu_mimo, req->pdcch_param.pdcch_mu_mimo);
EQ_TLV(unpacked_req->pdcch_param.pdcch_precoder_cycling, req->pdcch_param.pdcch_precoder_cycling);
EQ_TLV(unpacked_req->pdcch_param.max_pdcch_per_slot, req->pdcch_param.max_pdcch_per_slot);
EQ_TLV(unpacked_req->pucch_param.pucch_formats, req->pucch_param.pucch_formats);
EQ_TLV(unpacked_req->pucch_param.max_pucchs_per_slot, req->pucch_param.max_pucchs_per_slot);
EQ_TLV(unpacked_req->pdsch_param.pdsch_mapping_type, req->pdsch_param.pdsch_mapping_type);
EQ_TLV(unpacked_req->pdsch_param.pdsch_allocation_types, req->pdsch_param.pdsch_allocation_types);
EQ_TLV(unpacked_req->pdsch_param.pdsch_vrb_to_prb_mapping, req->pdsch_param.pdsch_vrb_to_prb_mapping);
EQ_TLV(unpacked_req->pdsch_param.pdsch_cbg, req->pdsch_param.pdsch_cbg);
EQ_TLV(unpacked_req->pdsch_param.pdsch_dmrs_config_types, req->pdsch_param.pdsch_dmrs_config_types);
EQ_TLV(unpacked_req->pdsch_param.pdsch_dmrs_max_length, req->pdsch_param.pdsch_dmrs_max_length);
EQ_TLV(unpacked_req->pdsch_param.pdsch_dmrs_additional_pos, req->pdsch_param.pdsch_dmrs_additional_pos);
EQ_TLV(unpacked_req->pdsch_param.max_pdsch_tbs_per_slot, req->pdsch_param.max_pdsch_tbs_per_slot);
EQ_TLV(unpacked_req->pdsch_param.max_number_mimo_layers_pdsch, req->pdsch_param.max_number_mimo_layers_pdsch);
EQ_TLV(unpacked_req->pdsch_param.supported_max_modulation_order_dl, req->pdsch_param.supported_max_modulation_order_dl);
EQ_TLV(unpacked_req->pdsch_param.max_mu_mimo_users_dl, req->pdsch_param.max_mu_mimo_users_dl);
EQ_TLV(unpacked_req->pdsch_param.pdsch_data_in_dmrs_symbols, req->pdsch_param.pdsch_data_in_dmrs_symbols);
EQ_TLV(unpacked_req->pdsch_param.premption_support, req->pdsch_param.premption_support);
EQ_TLV(unpacked_req->pdsch_param.pdsch_non_slot_support, req->pdsch_param.pdsch_non_slot_support);
EQ_TLV(unpacked_req->pusch_param.uci_mux_ulsch_in_pusch, req->pusch_param.uci_mux_ulsch_in_pusch);
EQ_TLV(unpacked_req->pusch_param.uci_only_pusch, req->pusch_param.uci_only_pusch);
EQ_TLV(unpacked_req->pusch_param.pusch_frequency_hopping, req->pusch_param.pusch_frequency_hopping);
EQ_TLV(unpacked_req->pusch_param.pusch_dmrs_config_types, req->pusch_param.pusch_dmrs_config_types);
EQ_TLV(unpacked_req->pusch_param.pusch_dmrs_max_len, req->pusch_param.pusch_dmrs_max_len);
EQ_TLV(unpacked_req->pusch_param.pusch_dmrs_additional_pos, req->pusch_param.pusch_dmrs_additional_pos);
EQ_TLV(unpacked_req->pusch_param.pusch_cbg, req->pusch_param.pusch_cbg);
EQ_TLV(unpacked_req->pusch_param.pusch_mapping_type, req->pusch_param.pusch_mapping_type);
EQ_TLV(unpacked_req->pusch_param.pusch_allocation_types, req->pusch_param.pusch_allocation_types);
EQ_TLV(unpacked_req->pusch_param.pusch_vrb_to_prb_mapping, req->pusch_param.pusch_vrb_to_prb_mapping);
EQ_TLV(unpacked_req->pusch_param.pusch_max_ptrs_ports, req->pusch_param.pusch_max_ptrs_ports);
EQ_TLV(unpacked_req->pusch_param.max_pduschs_tbs_per_slot, req->pusch_param.max_pduschs_tbs_per_slot);
EQ_TLV(unpacked_req->pusch_param.max_number_mimo_layers_non_cb_pusch, req->pusch_param.max_number_mimo_layers_non_cb_pusch);
EQ_TLV(unpacked_req->pusch_param.supported_modulation_order_ul, req->pusch_param.supported_modulation_order_ul);
EQ_TLV(unpacked_req->pusch_param.max_mu_mimo_users_ul, req->pusch_param.max_mu_mimo_users_ul);
EQ_TLV(unpacked_req->pusch_param.dfts_ofdm_support, req->pusch_param.dfts_ofdm_support);
EQ_TLV(unpacked_req->pusch_param.pusch_aggregation_factor, req->pusch_param.pusch_aggregation_factor);
EQ_TLV(unpacked_req->prach_param.prach_long_formats, req->prach_param.prach_long_formats);
EQ_TLV(unpacked_req->prach_param.prach_short_formats, req->prach_param.prach_short_formats);
EQ_TLV(unpacked_req->prach_param.prach_restricted_sets, req->prach_param.prach_restricted_sets);
EQ_TLV(unpacked_req->prach_param.max_prach_fd_occasions_in_a_slot, req->prach_param.max_prach_fd_occasions_in_a_slot);
EQ_TLV(unpacked_req->measurement_param.rssi_measurement_support, req->measurement_param.rssi_measurement_support);
return true;
}
bool eq_config_request(const nfapi_nr_config_request_scf_t *unpacked_req, const nfapi_nr_config_request_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(unpacked_req->header.message_length, req->header.message_length);
EQ(unpacked_req->num_tlv, req->num_tlv);
EQ_TLV(unpacked_req->carrier_config.dl_bandwidth, req->carrier_config.dl_bandwidth);
EQ_TLV(unpacked_req->carrier_config.dl_frequency, req->carrier_config.dl_frequency);
for (int i = 0; i < 5; ++i) {
EQ_TLV(unpacked_req->carrier_config.dl_k0[i], req->carrier_config.dl_k0[i]);
EQ_TLV(unpacked_req->carrier_config.dl_grid_size[i], req->carrier_config.dl_grid_size[i]);
}
EQ_TLV(unpacked_req->carrier_config.num_tx_ant, req->carrier_config.num_tx_ant);
EQ_TLV(unpacked_req->carrier_config.uplink_bandwidth, req->carrier_config.uplink_bandwidth);
EQ_TLV(unpacked_req->carrier_config.uplink_frequency, req->carrier_config.uplink_frequency);
for (int i = 0; i < 5; ++i) {
EQ_TLV(unpacked_req->carrier_config.ul_k0[i], req->carrier_config.ul_k0[i]);
EQ_TLV(unpacked_req->carrier_config.ul_grid_size[i], req->carrier_config.ul_grid_size[i]);
}
EQ_TLV(unpacked_req->carrier_config.num_rx_ant, req->carrier_config.num_rx_ant);
EQ_TLV(unpacked_req->carrier_config.frequency_shift_7p5khz, req->carrier_config.frequency_shift_7p5khz);
EQ_TLV(unpacked_req->cell_config.phy_cell_id, req->cell_config.phy_cell_id);
EQ_TLV(unpacked_req->cell_config.frame_duplex_type, req->cell_config.frame_duplex_type);
EQ_TLV(unpacked_req->ssb_config.ss_pbch_power, req->ssb_config.ss_pbch_power);
EQ_TLV(unpacked_req->ssb_config.bch_payload, req->ssb_config.bch_payload);
EQ_TLV(unpacked_req->ssb_config.scs_common, req->ssb_config.scs_common);
EQ_TLV(unpacked_req->prach_config.prach_sequence_length, req->prach_config.prach_sequence_length);
EQ_TLV(unpacked_req->prach_config.prach_sub_c_spacing, req->prach_config.prach_sub_c_spacing);
EQ_TLV(unpacked_req->prach_config.restricted_set_config, req->prach_config.restricted_set_config);
EQ_TLV(unpacked_req->prach_config.num_prach_fd_occasions, req->prach_config.num_prach_fd_occasions);
EQ_TLV(unpacked_req->prach_config.prach_ConfigurationIndex, req->prach_config.prach_ConfigurationIndex);
for (int i = 0; i < unpacked_req->prach_config.num_prach_fd_occasions.value; i++) {
nfapi_nr_num_prach_fd_occasions_t unpacked_prach_fd_occasion = unpacked_req->prach_config.num_prach_fd_occasions_list[i];
nfapi_nr_num_prach_fd_occasions_t req_prach_fd_occasion = req->prach_config.num_prach_fd_occasions_list[i];
EQ_TLV(unpacked_prach_fd_occasion.prach_root_sequence_index, req_prach_fd_occasion.prach_root_sequence_index);
EQ_TLV(unpacked_prach_fd_occasion.num_root_sequences, req_prach_fd_occasion.num_root_sequences);
EQ_TLV(unpacked_prach_fd_occasion.k1, req_prach_fd_occasion.k1);
EQ_TLV(unpacked_prach_fd_occasion.prach_zero_corr_conf, req_prach_fd_occasion.prach_zero_corr_conf);
EQ_TLV(unpacked_prach_fd_occasion.num_unused_root_sequences, req_prach_fd_occasion.num_unused_root_sequences);
for (int k = 0; k < unpacked_prach_fd_occasion.num_unused_root_sequences.value; k++) {
EQ_TLV(unpacked_prach_fd_occasion.unused_root_sequences_list[k], req_prach_fd_occasion.unused_root_sequences_list[k]);
}
}
EQ_TLV(unpacked_req->prach_config.ssb_per_rach, req->prach_config.ssb_per_rach);
EQ_TLV(unpacked_req->prach_config.prach_multiple_carriers_in_a_band, req->prach_config.prach_multiple_carriers_in_a_band);
EQ_TLV(unpacked_req->ssb_table.ssb_offset_point_a, req->ssb_table.ssb_offset_point_a);
EQ_TLV(unpacked_req->ssb_table.ssb_period, req->ssb_table.ssb_period);
EQ_TLV(unpacked_req->ssb_table.ssb_subcarrier_offset, req->ssb_table.ssb_subcarrier_offset);
EQ_TLV(unpacked_req->ssb_table.MIB, req->ssb_table.MIB);
EQ_TLV(unpacked_req->ssb_table.ssb_mask_list[0].ssb_mask, req->ssb_table.ssb_mask_list[0].ssb_mask);
EQ_TLV(unpacked_req->ssb_table.ssb_mask_list[1].ssb_mask, req->ssb_table.ssb_mask_list[1].ssb_mask);
for (int i = 0; i < 64; i++) {
EQ_TLV(unpacked_req->ssb_table.ssb_beam_id_list[i].beam_id, req->ssb_table.ssb_beam_id_list[i].beam_id);
}
EQ_TLV(unpacked_req->tdd_table.tdd_period, req->tdd_table.tdd_period);
const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160};
// Assuming always CP_Normal, because Cyclic prefix is not included in CONFIG.request 10.02, but is present in 10.04
uint8_t cyclicprefix = 1;
bool normal_CP = cyclicprefix ? false : true;
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
uint8_t number_of_symbols_per_slot = normal_CP ? 14 : 12;
for (int i = 0; i < slotsperframe[unpacked_req->ssb_config.scs_common.value]; i++) {
for (int k = 0; k < number_of_symbols_per_slot; k++) {
EQ_TLV(unpacked_req->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list[k].slot_config,
req->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list[k].slot_config);
}
}
EQ_TLV(unpacked_req->measurement_config.rssi_measurement, req->measurement_config.rssi_measurement);
EQ(unpacked_req->nfapi_config.p7_vnf_address_ipv4.tl.tag, req->nfapi_config.p7_vnf_address_ipv4.tl.tag);
for (int i = 0; i < NFAPI_IPV4_ADDRESS_LENGTH; ++i) {
EQ(unpacked_req->nfapi_config.p7_vnf_address_ipv4.address[i], req->nfapi_config.p7_vnf_address_ipv4.address[i]);
}
EQ(unpacked_req->nfapi_config.p7_vnf_address_ipv6.tl.tag, req->nfapi_config.p7_vnf_address_ipv6.tl.tag);
for (int i = 0; i < NFAPI_IPV6_ADDRESS_LENGTH; ++i) {
EQ(unpacked_req->nfapi_config.p7_vnf_address_ipv6.address[i], req->nfapi_config.p7_vnf_address_ipv6.address[i]);
}
EQ_TLV(unpacked_req->nfapi_config.p7_vnf_port, req->nfapi_config.p7_vnf_port);
EQ_TLV(unpacked_req->nfapi_config.timing_window, req->nfapi_config.timing_window);
EQ_TLV(unpacked_req->nfapi_config.timing_info_mode, req->nfapi_config.timing_info_mode);
EQ_TLV(unpacked_req->nfapi_config.timing_info_period, req->nfapi_config.timing_info_period);
return true;
}
static bool eq_config_response_tlv_lists(nfapi_nr_generic_tlv_scf_t *unpacked_list,
nfapi_nr_generic_tlv_scf_t *req_list,
uint8_t size)
{
for (int i = 0; i < size; ++i) {
nfapi_nr_generic_tlv_scf_t *unpacked_element = &(unpacked_list[i]);
nfapi_nr_generic_tlv_scf_t *req_element = &(req_list[i]);
EQ(unpacked_element->tl.tag, req_element->tl.tag);
EQ(unpacked_element->tl.length, req_element->tl.length);
// check according to value type
switch (unpacked_element->tl.length) {
case UINT_8:
EQ(unpacked_element->value.u8, req_element->value.u8);
break;
case UINT_16:
EQ(unpacked_element->value.u16, req_element->value.u16);
break;
case UINT_32:
EQ(unpacked_element->value.u32, req_element->value.u32);
break;
case ARRAY_UINT_16:
for (int j = 0; j < 5; ++j) {
EQ(unpacked_element->value.array_u16[j], req_element->value.array_u16[j]);
}
break;
default:
printf("unknown length %d\n", unpacked_element->tl.length);
DevAssert(1 == 0);
break;
}
}
return true;
}
bool eq_config_response(const nfapi_nr_config_response_scf_t *unpacked_req, const nfapi_nr_config_response_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(unpacked_req->header.message_length, req->header.message_length);
EQ(unpacked_req->error_code, req->error_code);
EQ(unpacked_req->num_invalid_tlvs, req->num_invalid_tlvs);
EQ(unpacked_req->num_invalid_tlvs_configured_in_idle, req->num_invalid_tlvs_configured_in_idle);
EQ(unpacked_req->num_invalid_tlvs_configured_in_running, req->num_invalid_tlvs_configured_in_running);
EQ(unpacked_req->num_missing_tlvs, req->num_missing_tlvs);
// compare the list elements
EQ(eq_config_response_tlv_lists(unpacked_req->invalid_tlvs_list, req->invalid_tlvs_list, req->num_invalid_tlvs), true);
EQ(eq_config_response_tlv_lists(unpacked_req->invalid_tlvs_configured_in_idle_list,
req->invalid_tlvs_configured_in_idle_list,
req->num_invalid_tlvs_configured_in_idle),
true);
EQ(eq_config_response_tlv_lists(unpacked_req->invalid_tlvs_configured_in_running_list,
req->invalid_tlvs_configured_in_running_list,
req->num_invalid_tlvs_configured_in_running),
true);
EQ(eq_config_response_tlv_lists(unpacked_req->missing_tlvs_list, req->missing_tlvs_list, req->num_missing_tlvs), true);
return true;
}
bool eq_start_request(const nfapi_nr_start_request_scf_t *unpacked_req, const nfapi_nr_start_request_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(unpacked_req->header.message_length, req->header.message_length);
return true;
}
bool eq_start_response(const nfapi_nr_start_response_scf_t *unpacked_req, const nfapi_nr_start_response_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(unpacked_req->header.message_length, req->header.message_length);
EQ(unpacked_req->error_code, req->error_code);
return true;
}
bool eq_stop_request(const nfapi_nr_stop_request_scf_t *unpacked_req, const nfapi_nr_stop_request_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(unpacked_req->header.message_length, req->header.message_length);
return true;
}
bool eq_stop_indication(const nfapi_nr_stop_indication_scf_t *unpacked_req, const nfapi_nr_stop_indication_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(unpacked_req->header.message_length, req->header.message_length);
return true;
}
bool eq_error_indication(const nfapi_nr_error_indication_scf_t *unpacked_req, const nfapi_nr_error_indication_scf_t *req)
{
EQ(unpacked_req->header.message_id, req->header.message_id);
EQ(unpacked_req->header.message_length, req->header.message_length);
EQ(unpacked_req->sfn, req->sfn);
EQ(unpacked_req->slot, req->slot);
EQ(unpacked_req->message_id, req->message_id);
EQ(unpacked_req->error_code, req->error_code);
return true;
}
void free_param_request(nfapi_nr_param_request_scf_t *msg)
{
if (msg->vendor_extension) {
free(msg->vendor_extension);
}
}
void free_param_response(nfapi_nr_param_response_scf_t *msg)
{
if (msg->vendor_extension) {
free(msg->vendor_extension);
}
if (msg->cell_param.config_tlvs_to_report_list) {
free(msg->cell_param.config_tlvs_to_report_list);
}
}
void free_config_request(nfapi_nr_config_request_scf_t *msg)
{
if (msg->vendor_extension) {
free(msg->vendor_extension);
}
if (msg->prach_config.num_prach_fd_occasions_list) {
for (int i = 0; i < msg->prach_config.num_prach_fd_occasions.value; i++) {
nfapi_nr_num_prach_fd_occasions_t *prach_fd_occasion = &(msg->prach_config.num_prach_fd_occasions_list[i]);
if (prach_fd_occasion->unused_root_sequences_list) {
free(prach_fd_occasion->unused_root_sequences_list);
}
}
free(msg->prach_config.num_prach_fd_occasions_list);
}
const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160};
if (msg->tdd_table.max_tdd_periodicity_list) {
for (int i = 0; i < slotsperframe[msg->ssb_config.scs_common.value]; i++) {
free(msg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list);
}
free(msg->tdd_table.max_tdd_periodicity_list);
}
if (msg->pmi_list.pmi_pdu) {
free(msg->pmi_list.pmi_pdu);
}
}
void free_config_response(nfapi_nr_config_response_scf_t *msg)
{
if (msg->vendor_extension) {
free(msg->vendor_extension);
}
if (msg->invalid_tlvs_list) {
free(msg->invalid_tlvs_list);
}
if (msg->invalid_tlvs_configured_in_idle_list) {
free(msg->invalid_tlvs_configured_in_idle_list);
}
if (msg->invalid_tlvs_configured_in_running_list) {
free(msg->invalid_tlvs_configured_in_running_list);
}
if (msg->missing_tlvs_list) {
free(msg->missing_tlvs_list);
}
}
void free_start_request(nfapi_nr_start_request_scf_t *msg)
{
if (msg->vendor_extension) {
free(msg->vendor_extension);
}
}
void free_start_response(nfapi_nr_start_response_scf_t *msg)
{
if (msg->vendor_extension) {
free(msg->vendor_extension);
}
}
void free_stop_request(nfapi_nr_stop_request_scf_t *msg)
{
if (msg->vendor_extension) {
free(msg->vendor_extension);
}
}
void free_stop_indication(nfapi_nr_stop_indication_scf_t *msg)
{
if (msg->vendor_extension) {
free(msg->vendor_extension);
}
}
void free_error_indication(nfapi_nr_error_indication_scf_t *msg)
{
if (msg->vendor_extension) {
free(msg->vendor_extension);
}
}
void copy_param_request(const nfapi_nr_param_request_scf_t *src, nfapi_nr_param_request_scf_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
if (src->vendor_extension) {
dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
dst->vendor_extension->tag = src->vendor_extension->tag;
dst->vendor_extension->length = src->vendor_extension->length;
copy_vendor_extension_value(&dst->vendor_extension, &src->vendor_extension);
}
}
void copy_param_response(const nfapi_nr_param_response_scf_t *src, nfapi_nr_param_response_scf_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
if (src->vendor_extension) {
dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
dst->vendor_extension->tag = src->vendor_extension->tag;
dst->vendor_extension->length = src->vendor_extension->length;
copy_vendor_extension_value(&dst->vendor_extension, &src->vendor_extension);
}
dst->error_code = src->error_code;
dst->num_tlv = src->num_tlv;
COPY_TLV(dst->cell_param.release_capability, src->cell_param.release_capability);
COPY_TLV(dst->cell_param.phy_state, src->cell_param.phy_state);
COPY_TLV(dst->cell_param.skip_blank_dl_config, src->cell_param.skip_blank_dl_config);
COPY_TLV(dst->cell_param.skip_blank_ul_config, src->cell_param.skip_blank_ul_config);
COPY_TLV(dst->cell_param.num_config_tlvs_to_report, src->cell_param.num_config_tlvs_to_report);
if (src->cell_param.config_tlvs_to_report_list) {
dst->cell_param.config_tlvs_to_report_list =
calloc(src->cell_param.num_config_tlvs_to_report.value, sizeof(nfapi_uint8_tlv_t *));
for (int i = 0; i < src->cell_param.num_config_tlvs_to_report.value; ++i) {
COPY_TLV(dst->cell_param.config_tlvs_to_report_list[i], src->cell_param.config_tlvs_to_report_list[i]);
}
}
COPY_TLV(dst->carrier_param.cyclic_prefix, src->carrier_param.cyclic_prefix);
COPY_TLV(dst->carrier_param.supported_subcarrier_spacings_dl, src->carrier_param.supported_subcarrier_spacings_dl);
COPY_TLV(dst->carrier_param.supported_bandwidth_dl, src->carrier_param.supported_bandwidth_dl);
COPY_TLV(dst->carrier_param.supported_subcarrier_spacings_ul, src->carrier_param.supported_subcarrier_spacings_ul);
COPY_TLV(dst->carrier_param.supported_bandwidth_ul, src->carrier_param.supported_bandwidth_ul);
COPY_TLV(dst->pdcch_param.cce_mapping_type, src->pdcch_param.cce_mapping_type);
COPY_TLV(dst->pdcch_param.coreset_outside_first_3_of_ofdm_syms_of_slot,
src->pdcch_param.coreset_outside_first_3_of_ofdm_syms_of_slot);
COPY_TLV(dst->pdcch_param.coreset_precoder_granularity_coreset, src->pdcch_param.coreset_precoder_granularity_coreset);
COPY_TLV(dst->pdcch_param.pdcch_mu_mimo, src->pdcch_param.pdcch_mu_mimo);
COPY_TLV(dst->pdcch_param.pdcch_precoder_cycling, src->pdcch_param.pdcch_precoder_cycling);
COPY_TLV(dst->pdcch_param.max_pdcch_per_slot, src->pdcch_param.max_pdcch_per_slot);
COPY_TLV(dst->pucch_param.pucch_formats, src->pucch_param.pucch_formats);
COPY_TLV(dst->pucch_param.max_pucchs_per_slot, src->pucch_param.max_pucchs_per_slot);
COPY_TLV(dst->pdsch_param.pdsch_mapping_type, src->pdsch_param.pdsch_mapping_type);
COPY_TLV(dst->pdsch_param.pdsch_allocation_types, src->pdsch_param.pdsch_allocation_types);
COPY_TLV(dst->pdsch_param.pdsch_vrb_to_prb_mapping, src->pdsch_param.pdsch_vrb_to_prb_mapping);
COPY_TLV(dst->pdsch_param.pdsch_cbg, src->pdsch_param.pdsch_cbg);
COPY_TLV(dst->pdsch_param.pdsch_dmrs_config_types, src->pdsch_param.pdsch_dmrs_config_types);
COPY_TLV(dst->pdsch_param.pdsch_dmrs_max_length, src->pdsch_param.pdsch_dmrs_max_length);
COPY_TLV(dst->pdsch_param.pdsch_dmrs_additional_pos, src->pdsch_param.pdsch_dmrs_additional_pos);
COPY_TLV(dst->pdsch_param.max_pdsch_tbs_per_slot, src->pdsch_param.max_pdsch_tbs_per_slot);
COPY_TLV(dst->pdsch_param.max_number_mimo_layers_pdsch, src->pdsch_param.max_number_mimo_layers_pdsch);
COPY_TLV(dst->pdsch_param.supported_max_modulation_order_dl, src->pdsch_param.supported_max_modulation_order_dl);
COPY_TLV(dst->pdsch_param.max_mu_mimo_users_dl, src->pdsch_param.max_mu_mimo_users_dl);
COPY_TLV(dst->pdsch_param.pdsch_data_in_dmrs_symbols, src->pdsch_param.pdsch_data_in_dmrs_symbols);
COPY_TLV(dst->pdsch_param.premption_support, src->pdsch_param.premption_support);
COPY_TLV(dst->pdsch_param.pdsch_non_slot_support, src->pdsch_param.pdsch_non_slot_support);
COPY_TLV(dst->pusch_param.uci_mux_ulsch_in_pusch, src->pusch_param.uci_mux_ulsch_in_pusch);
COPY_TLV(dst->pusch_param.uci_only_pusch, src->pusch_param.uci_only_pusch);
COPY_TLV(dst->pusch_param.pusch_frequency_hopping, src->pusch_param.pusch_frequency_hopping);
COPY_TLV(dst->pusch_param.pusch_dmrs_config_types, src->pusch_param.pusch_dmrs_config_types);
COPY_TLV(dst->pusch_param.pusch_dmrs_max_len, src->pusch_param.pusch_dmrs_max_len);
COPY_TLV(dst->pusch_param.pusch_dmrs_additional_pos, src->pusch_param.pusch_dmrs_additional_pos);
COPY_TLV(dst->pusch_param.pusch_cbg, src->pusch_param.pusch_cbg);
COPY_TLV(dst->pusch_param.pusch_mapping_type, src->pusch_param.pusch_mapping_type);
COPY_TLV(dst->pusch_param.pusch_allocation_types, src->pusch_param.pusch_allocation_types);
COPY_TLV(dst->pusch_param.pusch_vrb_to_prb_mapping, src->pusch_param.pusch_vrb_to_prb_mapping);
COPY_TLV(dst->pusch_param.pusch_max_ptrs_ports, src->pusch_param.pusch_max_ptrs_ports);
COPY_TLV(dst->pusch_param.max_pduschs_tbs_per_slot, src->pusch_param.max_pduschs_tbs_per_slot);
COPY_TLV(dst->pusch_param.max_number_mimo_layers_non_cb_pusch, src->pusch_param.max_number_mimo_layers_non_cb_pusch);
COPY_TLV(dst->pusch_param.supported_modulation_order_ul, src->pusch_param.supported_modulation_order_ul);
COPY_TLV(dst->pusch_param.max_mu_mimo_users_ul, src->pusch_param.max_mu_mimo_users_ul);
COPY_TLV(dst->pusch_param.dfts_ofdm_support, src->pusch_param.dfts_ofdm_support);
COPY_TLV(dst->pusch_param.pusch_aggregation_factor, src->pusch_param.pusch_aggregation_factor);
COPY_TLV(dst->prach_param.prach_long_formats, src->prach_param.prach_long_formats);
COPY_TLV(dst->prach_param.prach_short_formats, src->prach_param.prach_short_formats);
COPY_TLV(dst->prach_param.prach_restricted_sets, src->prach_param.prach_restricted_sets);
COPY_TLV(dst->prach_param.max_prach_fd_occasions_in_a_slot, src->prach_param.max_prach_fd_occasions_in_a_slot);
COPY_TLV(dst->measurement_param.rssi_measurement_support, src->measurement_param.rssi_measurement_support);
COPY_TL(dst->nfapi_config.p7_vnf_address_ipv4.tl, src->nfapi_config.p7_vnf_address_ipv4.tl);
memcpy(dst->nfapi_config.p7_vnf_address_ipv4.address,
src->nfapi_config.p7_vnf_address_ipv4.address,
sizeof(dst->nfapi_config.p7_vnf_address_ipv4.address));
COPY_TL(dst->nfapi_config.p7_vnf_address_ipv6.tl, src->nfapi_config.p7_vnf_address_ipv6.tl);
memcpy(dst->nfapi_config.p7_vnf_address_ipv6.address,
src->nfapi_config.p7_vnf_address_ipv6.address,
sizeof(dst->nfapi_config.p7_vnf_address_ipv6.address));
COPY_TLV(dst->nfapi_config.p7_vnf_port, src->nfapi_config.p7_vnf_port);
COPY_TL(dst->nfapi_config.p7_pnf_address_ipv4.tl, src->nfapi_config.p7_pnf_address_ipv4.tl);
memcpy(dst->nfapi_config.p7_pnf_address_ipv4.address,
src->nfapi_config.p7_pnf_address_ipv4.address,
sizeof(dst->nfapi_config.p7_pnf_address_ipv4.address));
COPY_TL(dst->nfapi_config.p7_pnf_address_ipv6.tl, src->nfapi_config.p7_pnf_address_ipv6.tl);
memcpy(dst->nfapi_config.p7_pnf_address_ipv6.address,
src->nfapi_config.p7_pnf_address_ipv6.address,
sizeof(dst->nfapi_config.p7_pnf_address_ipv6.address));
COPY_TLV(dst->nfapi_config.p7_pnf_port, src->nfapi_config.p7_pnf_port);
COPY_TLV(dst->nfapi_config.timing_window, src->nfapi_config.timing_window);
COPY_TLV(dst->nfapi_config.timing_info_mode, src->nfapi_config.timing_info_mode);
COPY_TLV(dst->nfapi_config.timing_info_period, src->nfapi_config.timing_info_period);
COPY_TLV(dst->nfapi_config.dl_tti_timing_offset, src->nfapi_config.dl_tti_timing_offset);
COPY_TLV(dst->nfapi_config.ul_tti_timing_offset, src->nfapi_config.ul_tti_timing_offset);
COPY_TLV(dst->nfapi_config.ul_dci_timing_offset, src->nfapi_config.ul_dci_timing_offset);
COPY_TLV(dst->nfapi_config.tx_data_timing_offset, src->nfapi_config.tx_data_timing_offset);
}
void copy_config_request(const nfapi_nr_config_request_scf_t *src, nfapi_nr_config_request_scf_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
if (src->vendor_extension) {
dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
dst->vendor_extension->tag = src->vendor_extension->tag;
dst->vendor_extension->length = src->vendor_extension->length;
copy_vendor_extension_value(&dst->vendor_extension, &src->vendor_extension);
}
dst->num_tlv = src->num_tlv;
COPY_TLV(dst->carrier_config.dl_bandwidth, src->carrier_config.dl_bandwidth);
COPY_TLV(dst->carrier_config.dl_frequency, src->carrier_config.dl_frequency);
for (int i = 0; i < 5; ++i) {
COPY_TLV(dst->carrier_config.dl_k0[i], src->carrier_config.dl_k0[i]);
COPY_TLV(dst->carrier_config.dl_grid_size[i], src->carrier_config.dl_grid_size[i]);
}
COPY_TLV(dst->carrier_config.num_tx_ant, src->carrier_config.num_tx_ant);
COPY_TLV(dst->carrier_config.uplink_bandwidth, src->carrier_config.uplink_bandwidth);
COPY_TLV(dst->carrier_config.uplink_frequency, src->carrier_config.uplink_frequency);
COPY_TLV(dst->carrier_config.uplink_frequency, src->carrier_config.uplink_frequency);
for (int i = 0; i < 5; ++i) {
COPY_TLV(dst->carrier_config.ul_k0[i], src->carrier_config.ul_k0[i]);
COPY_TLV(dst->carrier_config.ul_grid_size[i], src->carrier_config.ul_grid_size[i]);
}
COPY_TLV(dst->carrier_config.num_rx_ant, src->carrier_config.num_rx_ant);
COPY_TLV(dst->carrier_config.frequency_shift_7p5khz, src->carrier_config.frequency_shift_7p5khz);
COPY_TLV(dst->cell_config.phy_cell_id, src->cell_config.phy_cell_id);
COPY_TLV(dst->cell_config.frame_duplex_type, src->cell_config.frame_duplex_type);
COPY_TLV(dst->ssb_config.ss_pbch_power, src->ssb_config.ss_pbch_power);
COPY_TLV(dst->ssb_config.bch_payload, src->ssb_config.bch_payload);
COPY_TLV(dst->ssb_config.scs_common, src->ssb_config.scs_common);
COPY_TLV(dst->prach_config.prach_sequence_length, src->prach_config.prach_sequence_length);
COPY_TLV(dst->prach_config.prach_sub_c_spacing, src->prach_config.prach_sub_c_spacing);
COPY_TLV(dst->prach_config.restricted_set_config, src->prach_config.restricted_set_config);
COPY_TLV(dst->prach_config.num_prach_fd_occasions, src->prach_config.num_prach_fd_occasions);
COPY_TLV(dst->prach_config.prach_ConfigurationIndex, src->prach_config.prach_ConfigurationIndex);
COPY_TLV(dst->prach_config.prach_ConfigurationIndex, src->prach_config.prach_ConfigurationIndex);
dst->prach_config.num_prach_fd_occasions_list = (nfapi_nr_num_prach_fd_occasions_t *)malloc(
dst->prach_config.num_prach_fd_occasions.value * sizeof(nfapi_nr_num_prach_fd_occasions_t));
for (int i = 0; i < dst->prach_config.num_prach_fd_occasions.value; i++) {
nfapi_nr_num_prach_fd_occasions_t *src_prach_fd_occasion = &(src->prach_config.num_prach_fd_occasions_list[i]);
nfapi_nr_num_prach_fd_occasions_t *dst_prach_fd_occasion = &(dst->prach_config.num_prach_fd_occasions_list[i]);
COPY_TLV(dst_prach_fd_occasion->prach_root_sequence_index, src_prach_fd_occasion->prach_root_sequence_index);
COPY_TLV(dst_prach_fd_occasion->num_root_sequences, src_prach_fd_occasion->num_root_sequences);
COPY_TLV(dst_prach_fd_occasion->k1, src_prach_fd_occasion->k1);
COPY_TLV(dst_prach_fd_occasion->prach_zero_corr_conf, src_prach_fd_occasion->prach_zero_corr_conf);
COPY_TLV(dst_prach_fd_occasion->num_unused_root_sequences, src_prach_fd_occasion->num_unused_root_sequences);
dst_prach_fd_occasion->unused_root_sequences_list =
(nfapi_uint8_tlv_t *)malloc(dst_prach_fd_occasion->num_unused_root_sequences.value * sizeof(nfapi_uint8_tlv_t));
for (int k = 0; k < dst_prach_fd_occasion->num_unused_root_sequences.value; k++) {
COPY_TLV(dst_prach_fd_occasion->unused_root_sequences_list[k], src_prach_fd_occasion->unused_root_sequences_list[k]);
}
}
COPY_TLV(dst->prach_config.ssb_per_rach, src->prach_config.ssb_per_rach);
COPY_TLV(dst->prach_config.prach_multiple_carriers_in_a_band, src->prach_config.prach_multiple_carriers_in_a_band);
COPY_TLV(dst->ssb_table.ssb_offset_point_a, src->ssb_table.ssb_offset_point_a);
COPY_TLV(dst->ssb_table.ssb_period, src->ssb_table.ssb_period);
COPY_TLV(dst->ssb_table.ssb_subcarrier_offset, src->ssb_table.ssb_subcarrier_offset);
COPY_TLV(dst->ssb_table.MIB, src->ssb_table.MIB);
COPY_TLV(dst->ssb_table.ssb_mask_list[0].ssb_mask, src->ssb_table.ssb_mask_list[0].ssb_mask);
COPY_TLV(dst->ssb_table.ssb_mask_list[1].ssb_mask, src->ssb_table.ssb_mask_list[1].ssb_mask);
for (int i = 0; i < 64; i++) {
COPY_TLV(dst->ssb_table.ssb_beam_id_list[i].beam_id, src->ssb_table.ssb_beam_id_list[i].beam_id);
}
COPY_TLV(dst->tdd_table.tdd_period, src->tdd_table.tdd_period);
const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160};
// Assuming always CP_Normal, because Cyclic prefix is not included in CONFIG.request 10.02, but is present in 10.04
uint8_t cyclicprefix = 1;
bool normal_CP = cyclicprefix ? false : true;
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
uint8_t number_of_symbols_per_slot = normal_CP ? 14 : 12;
dst->tdd_table.max_tdd_periodicity_list = (nfapi_nr_max_tdd_periodicity_t *)malloc(slotsperframe[dst->ssb_config.scs_common.value]
* sizeof(nfapi_nr_max_tdd_periodicity_t));
for (int i = 0; i < slotsperframe[dst->ssb_config.scs_common.value]; i++) {
dst->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list =
(nfapi_nr_max_num_of_symbol_per_slot_t *)malloc(number_of_symbols_per_slot * sizeof(nfapi_nr_max_num_of_symbol_per_slot_t));
}
for (int i = 0; i < slotsperframe[dst->ssb_config.scs_common.value]; i++) { // TODO check right number of slots
for (int k = 0; k < number_of_symbols_per_slot; k++) { // TODO can change?
COPY_TLV(dst->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list[k].slot_config,
src->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list[k].slot_config);
}
}
COPY_TLV(dst->measurement_config.rssi_measurement, src->measurement_config.rssi_measurement);
COPY_TL(dst->nfapi_config.p7_vnf_address_ipv4.tl, src->nfapi_config.p7_vnf_address_ipv4.tl);
memcpy(dst->nfapi_config.p7_vnf_address_ipv4.address,
src->nfapi_config.p7_vnf_address_ipv4.address,
sizeof(dst->nfapi_config.p7_vnf_address_ipv4.address));
COPY_TL(dst->nfapi_config.p7_vnf_address_ipv6.tl, src->nfapi_config.p7_vnf_address_ipv6.tl);
memcpy(dst->nfapi_config.p7_vnf_address_ipv6.address,
src->nfapi_config.p7_vnf_address_ipv6.address,
sizeof(dst->nfapi_config.p7_vnf_address_ipv6.address));
COPY_TLV(dst->nfapi_config.p7_vnf_port, src->nfapi_config.p7_vnf_port);
COPY_TL(dst->nfapi_config.p7_pnf_address_ipv4.tl, src->nfapi_config.p7_pnf_address_ipv4.tl);
memcpy(dst->nfapi_config.p7_pnf_address_ipv4.address,
src->nfapi_config.p7_pnf_address_ipv4.address,
sizeof(dst->nfapi_config.p7_pnf_address_ipv4.address));
COPY_TL(dst->nfapi_config.p7_pnf_address_ipv6.tl, src->nfapi_config.p7_pnf_address_ipv6.tl);
memcpy(dst->nfapi_config.p7_pnf_address_ipv6.address,
src->nfapi_config.p7_pnf_address_ipv6.address,
sizeof(dst->nfapi_config.p7_pnf_address_ipv6.address));
COPY_TLV(dst->nfapi_config.p7_pnf_port, src->nfapi_config.p7_pnf_port);
COPY_TLV(dst->nfapi_config.timing_window, src->nfapi_config.timing_window);
COPY_TLV(dst->nfapi_config.timing_info_mode, src->nfapi_config.timing_info_mode);
COPY_TLV(dst->nfapi_config.timing_info_period, src->nfapi_config.timing_info_period);
COPY_TLV(dst->nfapi_config.dl_tti_timing_offset, src->nfapi_config.dl_tti_timing_offset);
COPY_TLV(dst->nfapi_config.ul_tti_timing_offset, src->nfapi_config.ul_tti_timing_offset);
COPY_TLV(dst->nfapi_config.ul_dci_timing_offset, src->nfapi_config.ul_dci_timing_offset);
COPY_TLV(dst->nfapi_config.tx_data_timing_offset, src->nfapi_config.tx_data_timing_offset);
}
void copy_config_response(const nfapi_nr_config_response_scf_t *src, nfapi_nr_config_response_scf_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
if (src->vendor_extension) {
dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
dst->vendor_extension->tag = src->vendor_extension->tag;
dst->vendor_extension->length = src->vendor_extension->length;
copy_vendor_extension_value(&dst->vendor_extension, &src->vendor_extension);
}
dst->error_code = src->error_code;
dst->num_invalid_tlvs = src->num_invalid_tlvs;
dst->num_invalid_tlvs_configured_in_idle = src->num_invalid_tlvs_configured_in_idle;
dst->num_invalid_tlvs_configured_in_running = src->num_invalid_tlvs_configured_in_running;
dst->num_missing_tlvs = src->num_missing_tlvs;
dst->invalid_tlvs_list = (nfapi_nr_generic_tlv_scf_t *)malloc(dst->num_invalid_tlvs * sizeof(nfapi_nr_generic_tlv_scf_t));
dst->invalid_tlvs_configured_in_idle_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(dst->num_invalid_tlvs_configured_in_idle * sizeof(nfapi_nr_generic_tlv_scf_t));
dst->invalid_tlvs_configured_in_running_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(dst->num_invalid_tlvs_configured_in_running * sizeof(nfapi_nr_generic_tlv_scf_t));
dst->missing_tlvs_list = (nfapi_nr_generic_tlv_scf_t *)malloc(dst->num_missing_tlvs * sizeof(nfapi_nr_generic_tlv_scf_t));
for (int i = 0; i < dst->num_invalid_tlvs; ++i) {
COPY_TLV(dst->invalid_tlvs_list[i], src->invalid_tlvs_list[i]);
}
for (int i = 0; i < dst->num_invalid_tlvs_configured_in_idle; ++i) {
COPY_TLV(dst->invalid_tlvs_configured_in_idle_list[i], src->invalid_tlvs_configured_in_idle_list[i]);
}
for (int i = 0; i < dst->num_invalid_tlvs_configured_in_running; ++i) {
COPY_TLV(dst->invalid_tlvs_configured_in_running_list[i], src->invalid_tlvs_configured_in_running_list[i]);
}
for (int i = 0; i < dst->num_missing_tlvs; ++i) {
COPY_TLV(dst->missing_tlvs_list[i], src->missing_tlvs_list[i]);
}
}
void copy_start_request(const nfapi_nr_start_request_scf_t *src, nfapi_nr_start_request_scf_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
if (src->vendor_extension) {
dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
dst->vendor_extension->tag = src->vendor_extension->tag;
dst->vendor_extension->length = src->vendor_extension->length;
copy_vendor_extension_value(&dst->vendor_extension, &src->vendor_extension);
}
}
void copy_start_response(const nfapi_nr_start_response_scf_t *src, nfapi_nr_start_response_scf_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
if (src->vendor_extension) {
dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
dst->vendor_extension->tag = src->vendor_extension->tag;
dst->vendor_extension->length = src->vendor_extension->length;
copy_vendor_extension_value(&dst->vendor_extension, &src->vendor_extension);
}
dst->error_code = src->error_code;
}
void copy_stop_request(const nfapi_nr_stop_request_scf_t *src, nfapi_nr_stop_request_scf_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
if (src->vendor_extension) {
dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
dst->vendor_extension->tag = src->vendor_extension->tag;
dst->vendor_extension->length = src->vendor_extension->length;
copy_vendor_extension_value(&dst->vendor_extension, &src->vendor_extension);
}
}
void copy_stop_indication(const nfapi_nr_stop_indication_scf_t *src, nfapi_nr_stop_indication_scf_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
if (src->vendor_extension) {
dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
dst->vendor_extension->tag = src->vendor_extension->tag;
dst->vendor_extension->length = src->vendor_extension->length;
copy_vendor_extension_value(&dst->vendor_extension, &src->vendor_extension);
}
}
void copy_error_indication(const nfapi_nr_error_indication_scf_t *src, nfapi_nr_error_indication_scf_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
if (src->vendor_extension) {
dst->vendor_extension = calloc(1, sizeof(nfapi_vendor_extension_tlv_t));
dst->vendor_extension->tag = src->vendor_extension->tag;
dst->vendor_extension->length = src->vendor_extension->length;
copy_vendor_extension_value(&dst->vendor_extension, &src->vendor_extension);
}
dst->sfn = src->sfn;
dst->slot = src->slot;
dst->message_id = src->message_id;
dst->error_code = src->error_code;
}
...@@ -3981,6 +3981,20 @@ int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn ...@@ -3981,6 +3981,20 @@ int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn
int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config); int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
int nfapi_nr_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config); int nfapi_nr_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
/*! \brief Packs a NFAPI P5 message body
* \param header A pointer to the header of the P5 message
* \param ppWritePackedMsg A pointer to the buffer where to pack the P5 message
* \param end Pointer to the end of the packing buffer
* \param config A pointer to the nfapi configuration structure
* \return 0 means success, -1 means failure.
*
* The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf
*/
uint8_t pack_nr_p5_message_body(nfapi_p4_p5_message_header_t* header,
uint8_t** ppWritePackedMsg,
uint8_t* end,
nfapi_p4_p5_codec_config_t* config);
/*! \brief Decodes an NFAPI P5 message header /*! \brief Decodes an NFAPI P5 message header
* \param pMessageBuf A pointer to an encoded P5 message header * \param pMessageBuf A pointer to an encoded P5 message header
* \param messageBufLen The size of the encoded P5 message header * \param messageBufLen The size of the encoded P5 message header
......
...@@ -44,36 +44,36 @@ typedef struct { ...@@ -44,36 +44,36 @@ typedef struct {
//PHY API message types //PHY API message types
typedef enum { typedef enum {
NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST= 0x00, NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST = 0x00,
NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE= 0x01, NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE = 0x01,
NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST= 0x02, NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST = 0x02,
NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE=0X03, NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE = 0X03,
NFAPI_NR_PHY_MSG_TYPE_START_REQUEST= 0X04, NFAPI_NR_PHY_MSG_TYPE_START_REQUEST = 0X04,
NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST= 0X05, NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST = 0X05,
NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION=0X06, NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION = 0X06,
NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION=0X07, NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION = 0X07,
NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE=0X010D, NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE = 0X0108, // SCF 222.10.04 Section 3.2 Start.Response - 0x108, as of nFAPIv2
NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE=0X010F, NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE = 0X010F,
//RESERVED 0X08 ~ 0X7F // RESERVED 0X08 ~ 0X7F
NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST= 0X80, NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST = 0X80,
NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST= 0X81, NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST = 0X81,
NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION=0X82, NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION = 0X82,
NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST= 0X83, NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST = 0X83,
NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST=0X84, // CHANGED TO 0X84 NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST = 0X84, // CHANGED TO 0X84
NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION=0X85, NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION = 0X85,
NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION= 0X86, NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION = 0X86,
NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION= 0X87, NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION = 0X87,
NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION= 0X88, NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION = 0X88,
NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION= 0X89, NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION = 0X89,
//RESERVED 0X8a ~ 0xff // RESERVED 0X8a ~ 0xff
NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_REQUEST = 0x0100, NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_REQUEST = 0x0100,
NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_RESPONSE = 0x0101, NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_RESPONSE = 0x0101,
NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_REQUEST= 0x0102, NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_REQUEST = 0x0102,
NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_RESPONSE= 0x0103, NFAPI_NR_PHY_MSG_TYPE_PNF_CONFIG_RESPONSE = 0x0103,
NFAPI_NR_PHY_MSG_TYPE_PNF_START_REQUEST= 0x0104, NFAPI_NR_PHY_MSG_TYPE_PNF_START_REQUEST = 0x0104,
NFAPI_NR_PHY_MSG_TYPE_PNF_START_RESPONSE= 0x0105, NFAPI_NR_PHY_MSG_TYPE_PNF_START_RESPONSE = 0x0105,
NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_REQUEST= 0x0106, NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_REQUEST = 0x0106,
NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_RESPONSE= 0x0107, NFAPI_NR_PHY_MSG_TYPE_PNF_STOP_RESPONSE = 0x0107,
NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC = 0x0180, NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC = 0x0180,
NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC, NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC,
...@@ -129,7 +129,7 @@ typedef enum { ...@@ -129,7 +129,7 @@ typedef enum {
#define NFAPI_NR_PARAM_TLV_PDSCH_DMRS_CONFIG_TYPES_TAG 0x0017 #define NFAPI_NR_PARAM_TLV_PDSCH_DMRS_CONFIG_TYPES_TAG 0x0017
#define NFAPI_NR_PARAM_TLV_PDSCH_DMRS_MAX_LENGTH_TAG 0x0018 #define NFAPI_NR_PARAM_TLV_PDSCH_DMRS_MAX_LENGTH_TAG 0x0018
#define NFAPI_NR_PARAM_TLV_PDSCH_DMRS_ADDITIONAL_POS_TAG 0x0019 #define NFAPI_NR_PARAM_TLV_PDSCH_DMRS_ADDITIONAL_POS_TAG 0x0019
#define NFAPI_NR_PARAM_TLV_MAX_PDSCH_S_YBS_PER_SLOT_TAG 0x001A #define NFAPI_NR_PARAM_TLV_MAX_PDSCH_S_TBS_PER_SLOT_TAG 0x001A
#define NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG 0x001B #define NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG 0x001B
#define NFAPI_NR_PARAM_TLV_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG 0x001C #define NFAPI_NR_PARAM_TLV_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG 0x001C
#define NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_DL_TAG 0x001D #define NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_DL_TAG 0x001D
...@@ -577,6 +577,23 @@ typedef struct { ...@@ -577,6 +577,23 @@ typedef struct {
nfapi_nr_pm_list_t pmi_list; nfapi_nr_pm_list_t pmi_list;
} nfapi_nr_config_request_scf_t; } nfapi_nr_config_request_scf_t;
typedef enum {
UINT_8 = sizeof(uint8_t),
UINT_16 = sizeof(uint16_t),
UINT_32 = sizeof(uint32_t),
ARRAY_UINT_16 = 5 * sizeof(uint16_t),
UNKNOWN = 0xffff
} nfapi_nr_config_response_tlv_value_type_t;
typedef struct {
nfapi_tl_t tl;
union {
uint8_t u8;
uint16_t u16;
uint32_t u32;
uint16_t array_u16[5]; // 4 TLVs defined as array ( dlK0, dlGridSize, ulK0, ulGridSize )
} value;
} nfapi_nr_generic_tlv_scf_t;
/* CONFIG.RESPONSE */ /* CONFIG.RESPONSE */
typedef struct { typedef struct {
...@@ -586,7 +603,10 @@ typedef struct { ...@@ -586,7 +603,10 @@ typedef struct {
uint8_t num_invalid_tlvs_configured_in_idle; uint8_t num_invalid_tlvs_configured_in_idle;
uint8_t num_invalid_tlvs_configured_in_running; uint8_t num_invalid_tlvs_configured_in_running;
uint8_t num_missing_tlvs; uint8_t num_missing_tlvs;
// TODO: add list of invalid/unsupported TLVs (see Table 3.18) nfapi_nr_generic_tlv_scf_t* invalid_tlvs_list;
nfapi_nr_generic_tlv_scf_t* invalid_tlvs_configured_in_idle_list;
nfapi_nr_generic_tlv_scf_t* invalid_tlvs_configured_in_running_list;
nfapi_nr_generic_tlv_scf_t* missing_tlvs_list;
nfapi_vendor_extension_tlv_t vendor_extension; nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_config_response_scf_t; } nfapi_nr_config_response_scf_t;
...@@ -609,13 +629,21 @@ typedef struct { ...@@ -609,13 +629,21 @@ typedef struct {
typedef struct { typedef struct {
nfapi_p4_p5_message_header_t header; nfapi_p4_p5_message_header_t header;
nfapi_vendor_extension_tlv_t vendor_extension; nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_stop_request_t; } nfapi_nr_stop_request_scf_t;
typedef struct {
nfapi_p4_p5_message_header_t header;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_stop_indication_scf_t;
typedef struct { typedef struct {
nfapi_p4_p5_message_header_t header; nfapi_p4_p5_message_header_t header;
uint16_t sfn;
uint16_t slot;
uint8_t message_id; // Which message received on the PNF has an error
uint8_t error_code;
nfapi_vendor_extension_tlv_t vendor_extension; nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_stop_indication_t; } nfapi_nr_error_indication_scf_t;
typedef enum { typedef enum {
NFAPI_NR_STOP_MSG_INVALID_STATE NFAPI_NR_STOP_MSG_INVALID_STATE
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/open-nFAPI/nfapi/public_inc/nr_nfapi_p7.h
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#ifndef OPENAIRINTERFACE_NR_NFAPI_P7_H
#define OPENAIRINTERFACE_NR_NFAPI_P7_H
#include "nfapi_interface.h"
#include "nfapi_nr_interface_scf.h"
uint8_t unpack_nr_slot_indication(uint8_t **ppReadPackedMsg,
uint8_t *end,
nfapi_nr_slot_indication_scf_t *msg,
nfapi_p7_codec_config_t *config);
void *nfapi_p7_allocate(size_t size, nfapi_p7_codec_config_t *config);
uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg,
uint8_t *end,
nfapi_nr_srs_indication_t *pNfapiMsg,
nfapi_p7_codec_config_t *config);
uint8_t pack_dl_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_ul_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_ul_dci_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_ue_release_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_ue_release_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_slot_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_rx_data_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_crc_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_uci_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_srs_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_rach_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_ul_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t pack_nr_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
uint8_t unpack_nr_crc_indication(uint8_t **ppReadPackedMsg,
uint8_t *end,
nfapi_nr_crc_indication_t *msg,
nfapi_p7_codec_config_t *config);
uint8_t unpack_nr_uci_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config);
uint8_t unpack_nr_rach_indication(uint8_t **ppReadPackedMsg,
uint8_t *end,
nfapi_nr_rach_indication_t *msg,
nfapi_p7_codec_config_t *config);
#endif // OPENAIRINTERFACE_NR_NFAPI_P7_H
...@@ -27,15 +27,6 @@ ...@@ -27,15 +27,6 @@
#include <nfapi.h> #include <nfapi.h>
#include <debug.h> #include <debug.h>
static uint32_t get_packed_msg_len(uintptr_t msgHead, uintptr_t msgEnd) {
if (msgEnd < msgHead) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "get_packed_msg_len: Error in pointers supplied %lu, %lu\n", msgHead, msgEnd);
return 0;
}
return (msgEnd - msgHead);
}
static uint8_t pack_opaque_data_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { static uint8_t pack_opaque_data_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_opaqaue_data_t *value = (nfapi_opaqaue_data_t *)tlv; nfapi_opaqaue_data_t *value = (nfapi_opaqaue_data_t *)tlv;
return pusharray8(value->value, NFAPI_MAX_OPAQUE_DATA, value->length, ppWritePackedMsg, end); return pusharray8(value->value, NFAPI_MAX_OPAQUE_DATA, value->length, ppWritePackedMsg, end);
......
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
#include "nfapi_nr_interface_scf.h" #include "nfapi_nr_interface_scf.h"
#include "nfapi/oai_integration/vendor_ext.h" #include "nfapi/oai_integration/vendor_ext.h"
#include <debug.h> #include <debug.h>
#include "nr_fapi_p5.h"
#include "nr_fapi.h"
// Pack routines // Pack routines
//TODO: Add pacl/unpack fns for uint32 and uint64 //TODO: Add pacl/unpack fns for uint32 and uint64
...@@ -51,53 +52,6 @@ static uint8_t pack_pnf_param_request(void *msg, uint8_t **ppWritePackedMsg, uin ...@@ -51,53 +52,6 @@ static uint8_t pack_pnf_param_request(void *msg, uint8_t **ppWritePackedMsg, uin
return pack_vendor_extension_tlv(request->vendor_extension, ppWritePackedMsg, end, config); return pack_vendor_extension_tlv(request->vendor_extension, ppWritePackedMsg, end, config);
} }
static uint8_t pack_pnf_param_general_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_pnf_param_general_t *value = (nfapi_pnf_param_general_t *)tlv;
return ( push8(value->nfapi_sync_mode, ppWritePackedMsg, end) &&
push8(value->location_mode, ppWritePackedMsg, end) &&
push16(value->location_coordinates_length, ppWritePackedMsg, end) &&
pusharray8(value->location_coordinates, NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH, value->location_coordinates_length, ppWritePackedMsg, end) &&
push32(value->dl_config_timing, ppWritePackedMsg, end) &&
push32(value->tx_timing, ppWritePackedMsg, end) &&
push32(value->ul_config_timing, ppWritePackedMsg, end) &&
push32(value->hi_dci0_timing, ppWritePackedMsg, end) &&
push16(value->maximum_number_phys, ppWritePackedMsg, end) &&
push16(value->maximum_total_bandwidth, ppWritePackedMsg, end) &&
push8(value->maximum_total_number_dl_layers, ppWritePackedMsg, end) &&
push8(value->maximum_total_number_ul_layers, ppWritePackedMsg, end) &&
push8(value->shared_bands, ppWritePackedMsg, end) &&
push8(value->shared_pa, ppWritePackedMsg, end) &&
pushs16(value->maximum_total_power, ppWritePackedMsg, end) &&
pusharray8(value->oui, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, ppWritePackedMsg, end));
}
static uint8_t pack_rf_config_info(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_rf_config_info_t *rf = (nfapi_rf_config_info_t *)elem;
return (push16(rf->rf_config_index, ppWritePackedMsg, end));
}
static uint8_t pack_pnf_phy_info(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_pnf_phy_info_t *phy = (nfapi_pnf_phy_info_t *)elem;
return ( push16(phy->phy_config_index, ppWritePackedMsg, end) &&
push16(phy->number_of_rfs, ppWritePackedMsg, end) &&
packarray(phy->rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rfs, ppWritePackedMsg, end, &pack_rf_config_info) &&
push16(phy->number_of_rf_exclusions, ppWritePackedMsg, end) &&
packarray(phy->excluded_rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rf_exclusions, ppWritePackedMsg, end, &pack_rf_config_info) &&
push16(phy->downlink_channel_bandwidth_supported, ppWritePackedMsg, end) &&
push16(phy->uplink_channel_bandwidth_supported, ppWritePackedMsg, end) &&
push8(phy->number_of_dl_layers_supported, ppWritePackedMsg, end) &&
push8(phy->number_of_ul_layers_supported, ppWritePackedMsg, end) &&
push16(phy->maximum_3gpp_release_supported, ppWritePackedMsg, end) &&
push8(phy->nmm_modes_supported, ppWritePackedMsg, end));
}
static uint8_t pack_pnf_phy_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_pnf_phy_t *value = (nfapi_pnf_phy_t *)tlv;
return ( push16(value->number_of_phys, ppWritePackedMsg, end) &&
packarray(value->phy, sizeof(nfapi_pnf_phy_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, ppWritePackedMsg, end, &pack_pnf_phy_info));
}
static uint8_t pack_pnf_rf_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { static uint8_t pack_pnf_rf_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_pnf_rf_t *value = (nfapi_pnf_rf_t *)tlv; nfapi_pnf_rf_t *value = (nfapi_pnf_rf_t *)tlv;
uint16_t rf_index = 0; uint16_t rf_index = 0;
...@@ -241,21 +195,6 @@ static uint8_t pack_pnf_param_response(void *msg, uint8_t **ppWritePackedMsg, ui ...@@ -241,21 +195,6 @@ static uint8_t pack_pnf_param_response(void *msg, uint8_t **ppWritePackedMsg, ui
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_phy_rf_config_info(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_phy_rf_config_info_t *rf = (nfapi_phy_rf_config_info_t *)elem;
return (push16(rf->phy_id, ppWritePackedMsg, end) &&
push16(rf->phy_config_index, ppWritePackedMsg, end) &&
push16(rf->rf_config_index, ppWritePackedMsg, end));
}
static uint8_t pack_pnf_phy_rf_config_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_pnf_phy_rf_config_t *value = (nfapi_pnf_phy_rf_config_t *)tlv;
return(push16(value->number_phy_rf_config_info, ppWritePackedMsg, end) &&
packarray(value->phy_rf_config, sizeof(nfapi_phy_rf_config_info_t), NFAPI_MAX_PHY_RF_INSTANCES, value->number_phy_rf_config_info, ppWritePackedMsg, end, &pack_phy_rf_config_info));
}
static uint8_t pack_nr_pnf_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) static uint8_t pack_nr_pnf_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{ {
nfapi_nr_pnf_config_request_t *pNfapiMsg = (nfapi_nr_pnf_config_request_t *)msg; nfapi_nr_pnf_config_request_t *pNfapiMsg = (nfapi_nr_pnf_config_request_t *)msg;
...@@ -335,78 +274,17 @@ static uint8_t pack_pnf_stop_response(void *msg, uint8_t **ppWritePackedMsg, uin ...@@ -335,78 +274,17 @@ static uint8_t pack_pnf_stop_response(void *msg, uint8_t **ppWritePackedMsg, uin
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_nr_param_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
nfapi_nr_param_request_scf_t *pNfapiMsg = (nfapi_nr_param_request_scf_t *)msg;
return (pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
static uint8_t pack_param_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { static uint8_t pack_param_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
nfapi_param_request_t *pNfapiMsg = (nfapi_param_request_t *)msg; nfapi_param_request_t *pNfapiMsg = (nfapi_param_request_t *)msg;
return (pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); return (pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_uint32_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_uint32_tlv_t *value = (nfapi_uint32_tlv_t *)tlv;
return push32(value->value, ppWritePackedMsg, end);
}
static uint8_t unpack_uint32_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_uint32_tlv_t *value = (nfapi_uint32_tlv_t *)tlv;
return pull32(ppReadPackedMsg, &value->value, end);
}
static uint8_t pack_uint16_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_uint16_tlv_t *value = (nfapi_uint16_tlv_t *)tlv;
return push16(value->value, ppWritePackedMsg, end);
}
static uint8_t unpack_uint16_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_uint16_tlv_t *value = (nfapi_uint16_tlv_t *)tlv;
return pull16(ppReadPackedMsg, &value->value, end);
}
static uint8_t pack_int16_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_int16_tlv_t *value = (nfapi_int16_tlv_t *)tlv;
return pushs16(value->value, ppWritePackedMsg, end);
}
static uint8_t unpack_int16_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_int16_tlv_t *value = (nfapi_int16_tlv_t *)tlv;
return pulls16(ppReadPackedMsg, &value->value, end);
}
static uint8_t pack_uint8_tlv_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_uint8_tlv_t *value = (nfapi_uint8_tlv_t *)tlv;
return push8(value->value, ppWritePackedMsg, end);
}
static uint8_t unpack_uint8_tlv_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_uint8_tlv_t *value = (nfapi_uint8_tlv_t *)tlv;
return pull8(ppReadPackedMsg, &value->value, end);
}
static uint8_t pack_ipv4_address_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_ipv4_address_t *value = (nfapi_ipv4_address_t *)tlv;
return pusharray8(value->address, NFAPI_IPV4_ADDRESS_LENGTH, NFAPI_IPV4_ADDRESS_LENGTH, ppWritePackedMsg, end);
}
static uint8_t unpack_ipv4_address_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_ipv4_address_t *value = (nfapi_ipv4_address_t *)tlv;
return pullarray8(ppReadPackedMsg, value->address, NFAPI_IPV4_ADDRESS_LENGTH, NFAPI_IPV4_ADDRESS_LENGTH, end);
}
static uint8_t pack_ipv6_address_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_ipv6_address_t *value = (nfapi_ipv6_address_t *)tlv;
return pusharray8(value->address, NFAPI_IPV6_ADDRESS_LENGTH, NFAPI_IPV6_ADDRESS_LENGTH, ppWritePackedMsg, end);
}
static uint8_t unpack_ipv6_address_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_ipv4_address_t *value = (nfapi_ipv4_address_t *)tlv;
return pullarray8(ppReadPackedMsg, value->address, NFAPI_IPV6_ADDRESS_LENGTH, NFAPI_IPV6_ADDRESS_LENGTH, end);
}
static uint8_t pack_rf_bands_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { static uint8_t pack_rf_bands_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_rf_bands_t *value = (nfapi_rf_bands_t *)tlv; nfapi_rf_bands_t *value = (nfapi_rf_bands_t *)tlv;
return ( push16(value->number_rf_bands, ppWritePackedMsg, end) && return ( push16(value->number_rf_bands, ppWritePackedMsg, end) &&
pusharray16(value->rf_band, NFAPI_MAX_NUM_RF_BANDS, value->number_rf_bands, ppWritePackedMsg, end)); pusharray16(value->rf_band, NFAPI_MAX_NUM_RF_BANDS, value->number_rf_bands, ppWritePackedMsg, end));
} }
static uint8_t unpack_rf_bands_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { static uint8_t unpack_rf_bands_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_rf_bands_t *value = (nfapi_rf_bands_t *)tlv; nfapi_rf_bands_t *value = (nfapi_rf_bands_t *)tlv;
return ( pull16(ppReadPackedMsg, &value->number_rf_bands, end) && return ( pull16(ppReadPackedMsg, &value->number_rf_bands, end) &&
...@@ -418,11 +296,13 @@ static uint8_t pack_nmm_frequency_bands_value(void *tlv, uint8_t **ppWritePacked ...@@ -418,11 +296,13 @@ static uint8_t pack_nmm_frequency_bands_value(void *tlv, uint8_t **ppWritePacked
return( push16(value->number_of_rf_bands, ppWritePackedMsg, end) && return( push16(value->number_of_rf_bands, ppWritePackedMsg, end) &&
pusharray16(value->bands, NFAPI_MAX_NMM_FREQUENCY_BANDS, value->number_of_rf_bands, ppWritePackedMsg, end)); pusharray16(value->bands, NFAPI_MAX_NMM_FREQUENCY_BANDS, value->number_of_rf_bands, ppWritePackedMsg, end));
} }
static uint8_t unpack_nmm_frequency_bands_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { static uint8_t unpack_nmm_frequency_bands_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_nmm_frequency_bands_t *value = (nfapi_nmm_frequency_bands_t *)tlv; nfapi_nmm_frequency_bands_t *value = (nfapi_nmm_frequency_bands_t *)tlv;
return ( pull16(ppReadPackedMsg, &value->number_of_rf_bands, end) && return ( pull16(ppReadPackedMsg, &value->number_of_rf_bands, end) &&
pullarray16(ppReadPackedMsg, value->bands, NFAPI_MAX_NMM_FREQUENCY_BANDS, value->number_of_rf_bands, end)); pullarray16(ppReadPackedMsg, value->bands, NFAPI_MAX_NMM_FREQUENCY_BANDS, value->number_of_rf_bands, end));
} }
static uint8_t pack_embms_mbsfn_config_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { static uint8_t pack_embms_mbsfn_config_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_embms_mbsfn_config_t *value = (nfapi_embms_mbsfn_config_t *)tlv; nfapi_embms_mbsfn_config_t *value = (nfapi_embms_mbsfn_config_t *)tlv;
return ( push16(value->num_mbsfn_config, ppWritePackedMsg, end) && return ( push16(value->num_mbsfn_config, ppWritePackedMsg, end) &&
...@@ -781,326 +661,6 @@ static uint8_t pack_param_response(void *msg, uint8_t **ppWritePackedMsg, uint8_ ...@@ -781,326 +661,6 @@ static uint8_t pack_param_response(void *msg, uint8_t **ppWritePackedMsg, uint8_
&& pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); && pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_nr_param_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
printf("\nRUNNING pack_param_response\n");
nfapi_nr_param_response_scf_t *pNfapiMsg = (nfapi_nr_param_response_scf_t *)msg;
return (push8(pNfapiMsg->error_code, ppWritePackedMsg, end) && push8(pNfapiMsg->num_tlv, ppWritePackedMsg, end)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_RELEASE_CAPABILITY_TAG,
&(pNfapiMsg->cell_param.release_capability),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PHY_STATE_TAG,
&(pNfapiMsg->cell_param.phy_state),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SKIP_BLANK_DL_CONFIG_TAG,
&(pNfapiMsg->cell_param.skip_blank_dl_config),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SKIP_BLANK_UL_CONFIG_TAG,
&(pNfapiMsg->cell_param.skip_blank_ul_config),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_NUM_CONFIG_TLVS_TO_REPORT_TAG,
&(pNfapiMsg->cell_param.num_config_tlvs_to_report),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_CYCLIC_PREFIX_TAG,
&(pNfapiMsg->carrier_param.cyclic_prefix),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_DL_TAG,
&(pNfapiMsg->carrier_param.supported_subcarrier_spacings_dl),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_DL_TAG,
&(pNfapiMsg->carrier_param.supported_bandwidth_dl),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_UL_TAG,
&(pNfapiMsg->carrier_param.supported_subcarrier_spacings_ul),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_UL_TAG,
&(pNfapiMsg->carrier_param.supported_bandwidth_ul),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_CCE_MAPPING_TYPE_TAG,
&(pNfapiMsg->pdcch_param.cce_mapping_type),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG,
&(pNfapiMsg->pdcch_param.coreset_outside_first_3_of_ofdm_syms_of_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PRECODER_GRANULARITY_CORESET_TAG,
&(pNfapiMsg->pdcch_param.coreset_precoder_granularity_coreset),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDCCH_MU_MIMO_TAG,
&(pNfapiMsg->pdcch_param.pdcch_mu_mimo),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDCCH_PRECODER_CYCLING_TAG,
&(pNfapiMsg->pdcch_param.pdcch_precoder_cycling),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PDCCHS_PER_SLOT_TAG,
&(pNfapiMsg->pdcch_param.max_pdcch_per_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUCCH_FORMATS_TAG,
&(pNfapiMsg->pucch_param.pucch_formats),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PUCCHS_PER_SLOT_TAG,
&(pNfapiMsg->pucch_param.max_pucchs_per_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_MAPPING_TYPE_TAG,
&(pNfapiMsg->pdsch_param.pdsch_mapping_type),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_ALLOCATION_TYPES_TAG,
&(pNfapiMsg->pdsch_param.pdsch_allocation_types),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_VRB_TO_PRB_MAPPING_TAG,
&(pNfapiMsg->pdsch_param.pdsch_vrb_to_prb_mapping),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_CBG_TAG,
&(pNfapiMsg->pdsch_param.pdsch_cbg),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_DMRS_CONFIG_TYPES_TAG,
&(pNfapiMsg->pdsch_param.pdsch_dmrs_config_types),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_DMRS_MAX_LENGTH_TAG,
&(pNfapiMsg->pdsch_param.pdsch_dmrs_max_length),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_DMRS_ADDITIONAL_POS_TAG,
&(pNfapiMsg->pdsch_param.pdsch_dmrs_additional_pos),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PDSCH_S_YBS_PER_SLOT_TAG,
&(pNfapiMsg->pdsch_param.max_pdsch_tbs_per_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG,
&(pNfapiMsg->pdsch_param.max_number_mimo_layers_pdsch),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_DL_TAG,
&(pNfapiMsg->pdsch_param.max_mu_mimo_users_dl),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG,
&(pNfapiMsg->pdsch_param.pdsch_data_in_dmrs_symbols),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PREMPTION_SUPPORT_TAG,
&(pNfapiMsg->pdsch_param.premption_support),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PDSCH_NON_SLOT_SUPPORT_TAG,
&(pNfapiMsg->pdsch_param.pdsch_non_slot_support),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_UCI_MUX_ULSCH_IN_PUSCH_TAG,
&(pNfapiMsg->pusch_param.uci_mux_ulsch_in_pusch),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_UCI_ONLY_PUSCH_TAG,
&(pNfapiMsg->pusch_param.uci_only_pusch),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_FREQUENCY_HOPPING_TAG,
&(pNfapiMsg->pusch_param.pusch_frequency_hopping),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_DMRS_CONFIG_TYPES_TAG,
&(pNfapiMsg->pusch_param.pusch_dmrs_config_types),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_DMRS_MAX_LEN_TAG,
&(pNfapiMsg->pusch_param.pusch_dmrs_max_len),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_DMRS_ADDITIONAL_POS_TAG,
&(pNfapiMsg->pusch_param.pusch_dmrs_additional_pos),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_CBG_TAG,
&(pNfapiMsg->pusch_param.pusch_cbg),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_MAPPING_TYPE_TAG,
&(pNfapiMsg->pusch_param.pusch_mapping_type),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_ALLOCATION_TYPES_TAG,
&(pNfapiMsg->pusch_param.pusch_allocation_types),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_VRB_TO_PRB_MAPPING_TAG,
&(pNfapiMsg->pusch_param.pusch_vrb_to_prb_mapping),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_MAX_PTRS_PORTS_TAG,
&(pNfapiMsg->pusch_param.pusch_max_ptrs_ports),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PDUSCHS_TBS_PER_SLOT_TAG,
&(pNfapiMsg->pusch_param.max_pduschs_tbs_per_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG,
&(pNfapiMsg->pusch_param.max_number_mimo_layers_non_cb_pusch),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_SUPPORTED_MODULATION_ORDER_UL_TAG,
&(pNfapiMsg->pusch_param.supported_modulation_order_ul),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_UL_TAG,
&(pNfapiMsg->pusch_param.max_mu_mimo_users_ul),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_DFTS_OFDM_SUPPORT_TAG,
&(pNfapiMsg->pusch_param.dfts_ofdm_support),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PUSCH_AGGREGATION_FACTOR_TAG,
&(pNfapiMsg->pusch_param.pusch_aggregation_factor),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PRACH_LONG_FORMATS_TAG,
&(pNfapiMsg->prach_param.prach_long_formats),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PRACH_SHORT_FORMATS_TAG,
&(pNfapiMsg->prach_param.prach_short_formats),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_PRACH_RESTRICTED_SETS_TAG,
&(pNfapiMsg->prach_param.prach_restricted_sets),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG,
&(pNfapiMsg->prach_param.max_prach_fd_occasions_in_a_slot),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_PARAM_TLV_RSSI_MEASUREMENT_SUPPORT_TAG,
&(pNfapiMsg->measurement_param.rssi_measurement_support),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&&
// config:
pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4),
ppWritePackedMsg,
end,
&pack_ipv4_address_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6),
ppWritePackedMsg,
end,
&pack_ipv6_address_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_PORT_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_port),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG,
&(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4),
ppWritePackedMsg,
end,
&pack_ipv4_address_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG,
&(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6),
ppWritePackedMsg,
end,
&pack_ipv6_address_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_P7_PNF_PORT_TAG,
&(pNfapiMsg->nfapi_config.p7_pnf_port),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_WINDOW_TAG,
&(pNfapiMsg->nfapi_config.timing_window),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG,
&(pNfapiMsg->nfapi_config.timing_info_mode),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG,
&(pNfapiMsg->nfapi_config.timing_info_period),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
static uint8_t pack_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) static uint8_t pack_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{ {
nfapi_config_request_t *pNfapiMsg = (nfapi_config_request_t *)msg; nfapi_config_request_t *pNfapiMsg = (nfapi_config_request_t *)msg;
...@@ -1517,462 +1077,73 @@ static uint8_t pack_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_ ...@@ -1517,462 +1077,73 @@ static uint8_t pack_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint16_tlv_value) &pack_uint16_tlv_value)
&& pack_tlv(NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, && pack_tlv(NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG,
&(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4), &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4),
ppWritePackedMsg,
end,
&pack_ipv4_address_value)
&& pack_tlv(NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG,
&(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6),
ppWritePackedMsg,
end,
&pack_ipv6_address_value)
&& pack_tlv(NFAPI_NFAPI_P7_PNF_PORT_TAG,
&(pNfapiMsg->nfapi_config.p7_pnf_port),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_tlv(NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG,
&(pNfapiMsg->nfapi_config.dl_ue_per_sf),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_tlv(NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG,
&(pNfapiMsg->nfapi_config.ul_ue_per_sf),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_tlv(NFAPI_PHY_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), ppWritePackedMsg, end, &pack_rf_bands_value)
&& pack_tlv(NFAPI_NFAPI_TIMING_WINDOW_TAG,
&(pNfapiMsg->nfapi_config.timing_window),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_tlv(NFAPI_NFAPI_TIMING_INFO_MODE_TAG,
&(pNfapiMsg->nfapi_config.timing_info_mode),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_tlv(NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG,
&(pNfapiMsg->nfapi_config.timing_info_period),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value)
&& pack_tlv(NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG,
&(pNfapiMsg->nfapi_config.max_transmit_power),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value)
&& pack_tlv(NFAPI_NFAPI_EARFCN_TAG, &(pNfapiMsg->nfapi_config.earfcn), ppWritePackedMsg, end, &pack_uint16_tlv_value)
&& pack_tlv(NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG,
&(pNfapiMsg->nfapi_config.nmm_gsm_frequency_bands),
ppWritePackedMsg,
end,
&pack_nmm_frequency_bands_value)
&& pack_tlv(NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG,
&(pNfapiMsg->nfapi_config.nmm_umts_frequency_bands),
ppWritePackedMsg,
end,
&pack_nmm_frequency_bands_value)
&& pack_tlv(NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG,
&(pNfapiMsg->nfapi_config.nmm_lte_frequency_bands),
ppWritePackedMsg,
end,
&pack_nmm_frequency_bands_value)
&& pack_tlv(NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG,
&(pNfapiMsg->nfapi_config.nmm_uplink_rssi_supported),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value));
}
static uint8_t pack_nr_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
uint8_t *pNumTLVFields = (uint8_t *)*ppWritePackedMsg;
nfapi_nr_config_request_scf_t *pNfapiMsg = (nfapi_nr_config_request_scf_t *)msg;
uint8_t numTLVs = 0;
*ppWritePackedMsg += 1; // Advance the buffer past the 'location' to push numTLVs
// START Carrier Configuration
uint8_t retval = pack_nr_tlv(NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG,
&(pNfapiMsg->carrier_config.dl_bandwidth),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_DL_FREQUENCY_TAG,
&(pNfapiMsg->carrier_config.dl_frequency),
ppWritePackedMsg,
end,
&pack_uint32_tlv_value);
numTLVs++;
retval &= push16(NFAPI_NR_CONFIG_DL_K0_TAG, ppWritePackedMsg, end) && push16(5 * sizeof(uint16_t), ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[0].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[1].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[2].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[3].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_k0[4].value, ppWritePackedMsg, end)
&& push16(0, ppWritePackedMsg, end); // Padding
numTLVs++;
retval &= push16(NFAPI_NR_CONFIG_DL_GRID_SIZE_TAG, ppWritePackedMsg, end) && push16(5 * sizeof(uint16_t), ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[0].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[1].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[2].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[3].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.dl_grid_size[4].value, ppWritePackedMsg, end)
&& push16(0, ppWritePackedMsg, end); // Padding
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_TX_ANT_TAG,
&(pNfapiMsg->carrier_config.num_tx_ant),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_UPLINK_BANDWIDTH_TAG,
&(pNfapiMsg->carrier_config.uplink_bandwidth),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_UPLINK_FREQUENCY_TAG,
&(pNfapiMsg->carrier_config.uplink_frequency),
ppWritePackedMsg,
end,
&pack_uint32_tlv_value);
numTLVs++;
retval &= push16(NFAPI_NR_CONFIG_UL_K0_TAG, ppWritePackedMsg, end) && push16(5 * sizeof(uint16_t), ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[0].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[1].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[2].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[3].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_k0[4].value, ppWritePackedMsg, end)
&& push16(0, ppWritePackedMsg, end); // Padding
numTLVs++;
retval &= push16(NFAPI_NR_CONFIG_UL_GRID_SIZE_TAG, ppWritePackedMsg, end) && push16(5 * sizeof(uint16_t), ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[0].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[1].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[2].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[3].value, ppWritePackedMsg, end)
&& push16(pNfapiMsg->carrier_config.ul_grid_size[4].value, ppWritePackedMsg, end)
&& push16(0, ppWritePackedMsg, end); // Padding
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_RX_ANT_TAG,
&(pNfapiMsg->carrier_config.num_rx_ant),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
if (NFAPI_MODE != NFAPI_MODE_AERIAL) {
// TLV not supported by Aerial L1
pack_nr_tlv(NFAPI_NR_CONFIG_FREQUENCY_SHIFT_7P5KHZ_TAG,
&(pNfapiMsg->carrier_config.frequency_shift_7p5khz),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
}
// END Carrier Configuration
// START Cell Configuration
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PHY_CELL_ID_TAG,
&(pNfapiMsg->cell_config.phy_cell_id),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_FRAME_DUPLEX_TYPE_TAG,
&(pNfapiMsg->cell_config.frame_duplex_type),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
// END Cell Configuration
// START SSB Configuration
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SS_PBCH_POWER_TAG,
&(pNfapiMsg->ssb_config.ss_pbch_power),
ppWritePackedMsg,
end,
&pack_uint32_tlv_value);
numTLVs++;
if (NFAPI_MODE != NFAPI_MODE_AERIAL) {
// TLV not supported by Aerial L1
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_BCH_PAYLOAD_TAG,
&(pNfapiMsg->ssb_config.bch_payload),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
}
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SCS_COMMON_TAG,
&(pNfapiMsg->ssb_config.scs_common),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
// END SSB Configuration
// START PRACH Configuration
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_SEQUENCE_LENGTH_TAG,
&(pNfapiMsg->prach_config.prach_sequence_length),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_SUB_C_SPACING_TAG,
&(pNfapiMsg->prach_config.prach_sub_c_spacing),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_RESTRICTED_SET_CONFIG_TAG,
&(pNfapiMsg->prach_config.restricted_set_config),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_PRACH_FD_OCCASIONS_TAG,
&(pNfapiMsg->prach_config.num_prach_fd_occasions),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_CONFIG_INDEX_TAG,
&(pNfapiMsg->prach_config.prach_ConfigurationIndex),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
for (int i = 0; i < pNfapiMsg->prach_config.num_prach_fd_occasions.value; i++) {
nfapi_nr_num_prach_fd_occasions_t prach_fd_occasion = pNfapiMsg->prach_config.num_prach_fd_occasions_list[i];
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG,
&(prach_fd_occasion.prach_root_sequence_index),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG,
&(prach_fd_occasion.num_root_sequences),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_K1_TAG, &(prach_fd_occasion.k1), ppWritePackedMsg, end, &pack_uint16_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG,
&(prach_fd_occasion.prach_zero_corr_conf),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_NUM_UNUSED_ROOT_SEQUENCES_TAG,
&(prach_fd_occasion.num_unused_root_sequences),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
for (int k = 0; k < prach_fd_occasion.num_unused_root_sequences.value; k++) {
prach_fd_occasion.unused_root_sequences_list[k].tl.tag = NFAPI_NR_CONFIG_UNUSED_ROOT_SEQUENCES_TAG;
prach_fd_occasion.unused_root_sequences_list[k].value = 0;
pack_nr_tlv(NFAPI_NR_CONFIG_UNUSED_ROOT_SEQUENCES_TAG,
&(prach_fd_occasion.unused_root_sequences_list[k]),
ppWritePackedMsg,
end,
&pack_uint16_tlv_value);
numTLVs++;
}
}
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_PER_RACH_TAG,
&(pNfapiMsg->prach_config.ssb_per_rach),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
pNfapiMsg->prach_config.prach_multiple_carriers_in_a_band.tl.tag = NFAPI_NR_CONFIG_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG;
pNfapiMsg->prach_config.prach_multiple_carriers_in_a_band.value = 0;
pack_nr_tlv(NFAPI_NR_CONFIG_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG,
&(pNfapiMsg->prach_config.prach_multiple_carriers_in_a_band),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
// END PRACH Configuration
// START SSB Table
if (NFAPI_MODE != NFAPI_MODE_AERIAL) {
// TLV not supported by Aerial L1
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG,
&(pNfapiMsg->ssb_table.ssb_offset_point_a),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint16_tlv_value); &pack_ipv4_address_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG,
} &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6),
retval &=
pack_nr_tlv(NFAPI_NR_CONFIG_SSB_PERIOD_TAG, &(pNfapiMsg->ssb_table.ssb_period), ppWritePackedMsg, end, &pack_uint8_tlv_value);
numTLVs++;
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG,
&(pNfapiMsg->ssb_table.ssb_subcarrier_offset),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint8_tlv_value); &pack_ipv6_address_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_P7_PNF_PORT_TAG,
/* was unused */ &(pNfapiMsg->nfapi_config.p7_pnf_port),
pNfapiMsg->ssb_table.MIB.tl.tag = NFAPI_NR_CONFIG_MIB_TAG;
pack_nr_tlv(NFAPI_NR_CONFIG_MIB_TAG, &(pNfapiMsg->ssb_table.MIB), ppWritePackedMsg, end, &pack_uint32_tlv_value);
numTLVs++;
// SCF222.10.02 Table 3-25 : If included there must be two instances of this TLV
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_MASK_TAG,
&(pNfapiMsg->ssb_table.ssb_mask_list[0].ssb_mask),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint32_tlv_value); &pack_uint16_tlv_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG,
&(pNfapiMsg->nfapi_config.dl_ue_per_sf),
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_SSB_MASK_TAG,
&(pNfapiMsg->ssb_table.ssb_mask_list[1].ssb_mask),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint32_tlv_value); &pack_uint8_tlv_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG,
if (NFAPI_MODE != NFAPI_MODE_AERIAL) { &(pNfapiMsg->nfapi_config.ul_ue_per_sf),
// TLV not supported by Aerial L1
for (int i = 0; i < 64; i++) {
// SCF222.10.02 Table 3-25 : If included there must be 64 instances of this TLV
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_BEAM_ID_TAG,
&(pNfapiMsg->ssb_table.ssb_beam_id_list[i].beam_id),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint8_tlv_value); &pack_uint8_tlv_value)
numTLVs++; && pack_tlv(NFAPI_PHY_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), ppWritePackedMsg, end, &pack_rf_bands_value)
} && pack_tlv(NFAPI_NFAPI_TIMING_WINDOW_TAG,
&(pNfapiMsg->nfapi_config.timing_window),
// END SSB Table
// START TDD Table
retval &= pack_nr_tlv(NFAPI_NR_CONFIG_TDD_PERIOD_TAG,
&(pNfapiMsg->tdd_table.tdd_period),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint8_tlv_value); &pack_uint8_tlv_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_TIMING_INFO_MODE_TAG,
// END TDD Table &(pNfapiMsg->nfapi_config.timing_info_mode),
for (int i = 0; i < 40; i++) {
for (int k = 0; k < 14; k++) {
pack_nr_tlv(NFAPI_NR_CONFIG_SLOT_CONFIG_TAG,
&(pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list[k].slot_config),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint8_tlv_value); &pack_uint8_tlv_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG,
} &(pNfapiMsg->nfapi_config.timing_info_period),
}
}
// START Measurement Config
// SCF222.10.02 Table 3-27 : Contains only one TLV and is currently unused
pNfapiMsg->measurement_config.rssi_measurement.tl.tag = NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG;
pNfapiMsg->measurement_config.rssi_measurement.value = 1;
pack_nr_tlv(NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG,
&(pNfapiMsg->measurement_config.rssi_measurement),
ppWritePackedMsg,
end,
&pack_uint8_tlv_value);
numTLVs++;
// END Measurement Config
// START Digital Beam Table (DBT) PDU
// Struct in nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h nfapi_nr_dbt_pdu_t, currently unused
// END Digital Beam Table (DBT) PDU
// START Precoding Matrix (PM) PDU
// Struct in nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h nfapi_nr_pm_pdu_t, currently unused, tag to use for AERIAL
// is 0xA011 END Precoding Matrix (PM) PDU
if(NFAPI_MODE != NFAPI_MODE_AERIAL){
// START nFAPI TLVs included in CONFIG.request for IDLE and CONFIGURED states
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_ipv4_address_value); &pack_uint8_tlv_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG,
&(pNfapiMsg->nfapi_config.max_transmit_power),
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG,
&(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_ipv6_address_value); &pack_uint16_tlv_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_EARFCN_TAG, &(pNfapiMsg->nfapi_config.earfcn), ppWritePackedMsg, end, &pack_uint16_tlv_value)
&& pack_tlv(NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG,
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, &(pNfapiMsg->nfapi_config.nmm_gsm_frequency_bands),
&(pNfapiMsg->nfapi_config.p7_vnf_port),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint16_tlv_value); &pack_nmm_frequency_bands_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG,
&(pNfapiMsg->nfapi_config.nmm_umts_frequency_bands),
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_WINDOW_TAG,
&(pNfapiMsg->nfapi_config.timing_window),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint8_tlv_value); &pack_nmm_frequency_bands_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG,
&(pNfapiMsg->nfapi_config.nmm_lte_frequency_bands),
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG,
&(pNfapiMsg->nfapi_config.timing_info_mode),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint8_tlv_value); &pack_nmm_frequency_bands_value)
numTLVs++; && pack_tlv(NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG,
&(pNfapiMsg->nfapi_config.nmm_uplink_rssi_supported),
retval &= pack_nr_tlv(NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG,
&(pNfapiMsg->nfapi_config.timing_info_period),
ppWritePackedMsg, ppWritePackedMsg,
end, end,
&pack_uint8_tlv_value); &pack_uint8_tlv_value));
numTLVs++;
// END nFAPI TLVs included in CONFIG.request for IDLE and CONFIGURED states
if (pNfapiMsg->vendor_extension != 0 && config != 0) {
retval &= pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "Packing CONFIG.request vendor_extension_tlv %d\n", pNfapiMsg->vendor_extension->tag);
numTLVs++;
}
}
pNfapiMsg->num_tlv = numTLVs;
retval &= push8(pNfapiMsg->num_tlv, &pNumTLVFields, end);
return retval;
}
static uint8_t pack_nr_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_config_response_scf_t *pNfapiMsg = (nfapi_nr_config_response_scf_t *)msg;
return (push8(pNfapiMsg->error_code, ppWritePackedMsg, end) && push8(pNfapiMsg->num_invalid_tlvs, ppWritePackedMsg, end)
&& push8(pNfapiMsg->num_invalid_tlvs_configured_in_idle, ppWritePackedMsg, end)
&& push8(pNfapiMsg->num_invalid_tlvs_configured_in_running, ppWritePackedMsg, end)
&& push8(pNfapiMsg->num_missing_tlvs, ppWritePackedMsg, end)
&& pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { static uint8_t pack_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
...@@ -1981,48 +1152,23 @@ static uint8_t pack_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8 ...@@ -1981,48 +1152,23 @@ static uint8_t pack_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) );
} }
static uint8_t pack_nr_start_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
nfapi_nr_start_request_scf_t *pNfapiMsg = (nfapi_nr_start_request_scf_t *)msg;
return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
}
static uint8_t pack_start_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { static uint8_t pack_start_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
nfapi_start_request_t *pNfapiMsg = (nfapi_start_request_t *)msg; nfapi_start_request_t *pNfapiMsg = (nfapi_start_request_t *)msg;
return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
} }
static uint8_t pack_nr_start_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
nfapi_nr_start_response_scf_t *pNfapiMsg = (nfapi_nr_start_response_scf_t *)msg;
return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end ) &&
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) );
}
static uint8_t pack_start_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { static uint8_t pack_start_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
nfapi_start_response_t *pNfapiMsg = (nfapi_start_response_t *)msg; nfapi_start_response_t *pNfapiMsg = (nfapi_start_response_t *)msg;
return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end ) && return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end ) &&
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) );
} }
static uint8_t pack_stop_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config)
static uint8_t pack_stop_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { {
nfapi_stop_request_t *pNfapiMsg = (nfapi_stop_request_t *)msg; nfapi_stop_request_t *pNfapiMsg = (nfapi_stop_request_t *)msg;
return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
} }
static uint8_t pack_stop_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
nfapi_stop_response_t *pNfapiMsg = (nfapi_stop_response_t *)msg;
return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end) &&
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) );
}
static uint8_t pack_measurement_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
nfapi_measurement_request_t *pNfapiMsg = (nfapi_measurement_request_t *)msg;
return( pack_tlv(NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG, &(pNfapiMsg->dl_rs_tx_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) &&
pack_tlv(NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG, &(pNfapiMsg->received_interference_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) &&
pack_tlv(NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG, &(pNfapiMsg->thermal_noise_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) &&
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
}
static uint8_t pack_recevied_interference_power_measurement_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { static uint8_t pack_recevied_interference_power_measurement_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_received_interference_power_measurement_t *value = (nfapi_received_interference_power_measurement_t *)tlv; nfapi_received_interference_power_measurement_t *value = (nfapi_received_interference_power_measurement_t *)tlv;
return ( push16(value->number_of_resource_blocks, ppWritePackedMsg, end) && return ( push16(value->number_of_resource_blocks, ppWritePackedMsg, end) &&
...@@ -2039,7 +1185,11 @@ static uint8_t pack_measurement_response(void *msg, uint8_t **ppWritePackedMsg, ...@@ -2039,7 +1185,11 @@ static uint8_t pack_measurement_response(void *msg, uint8_t **ppWritePackedMsg,
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_nr_p5_message_body(nfapi_p4_p5_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { uint8_t pack_nr_p5_message_body(nfapi_p4_p5_message_header_t *header,
uint8_t **ppWritePackedMsg,
uint8_t *end,
nfapi_p4_p5_codec_config_t *config)
{
uint8_t result = 0; uint8_t result = 0;
// look for the specific message // look for the specific message
...@@ -2109,9 +1259,8 @@ static uint8_t pack_nr_p5_message_body(nfapi_p4_p5_message_header_t *header, uin ...@@ -2109,9 +1259,8 @@ static uint8_t pack_nr_p5_message_body(nfapi_p4_p5_message_header_t *header, uin
break; break;
default: { default: {
if(header->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && if (header->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && header->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
header->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) { if (config && config->pack_p4_p5_vendor_extension) {
if(config && config->pack_p4_p5_vendor_extension) {
result = (config->pack_p4_p5_vendor_extension)(header, ppWritePackedMsg, end, config); result = (config->pack_p4_p5_vendor_extension)(header, ppWritePackedMsg, end, config);
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve ecoder provided\n", __FUNCTION__, header->message_id); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve ecoder provided\n", __FUNCTION__, header->message_id);
...@@ -2119,14 +1268,12 @@ static uint8_t pack_nr_p5_message_body(nfapi_p4_p5_message_header_t *header, uin ...@@ -2119,14 +1268,12 @@ static uint8_t pack_nr_p5_message_body(nfapi_p4_p5_message_header_t *header, uin
} else { } else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, header->message_id); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, header->message_id);
} }
} } break;
break;
} }
return result; return result;
} }
static uint8_t pack_p5_message_body(nfapi_p4_p5_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { static uint8_t pack_p5_message_body(nfapi_p4_p5_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) {
uint8_t result = 0; uint8_t result = 0;
...@@ -2222,19 +1369,6 @@ static uint8_t pack_p5_message_body(nfapi_p4_p5_message_header_t *header, uint8_ ...@@ -2222,19 +1369,6 @@ static uint8_t pack_p5_message_body(nfapi_p4_p5_message_header_t *header, uint8_
return result; return result;
} }
// helper function for message length calculation -
// takes the pointers to the start of message to end of message
static uint32_t get_packed_msg_len(uintptr_t msgHead, uintptr_t msgEnd) {
if (msgEnd < msgHead) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "get_packed_msg_len: Error in pointers supplied %p, %p\n", &msgHead, &msgEnd);
return 0;
}
return (msgEnd - msgHead);
}
// Main pack function - public // Main pack function - public
int nfapi_nr_p5_message_pack(void *pMessageBuf, int nfapi_nr_p5_message_pack(void *pMessageBuf,
...@@ -2332,8 +1466,6 @@ int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPack ...@@ -2332,8 +1466,6 @@ int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPack
} }
} }
// Unpack routines // Unpack routines
static uint8_t unpack_nr_pnf_param_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) static uint8_t unpack_nr_pnf_param_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
...@@ -2347,53 +1479,6 @@ static uint8_t unpack_pnf_param_request(uint8_t **ppReadPackedMsg, uint8_t *end ...@@ -2347,53 +1479,6 @@ static uint8_t unpack_pnf_param_request(uint8_t **ppReadPackedMsg, uint8_t *end
return unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); return unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
} }
static uint8_t unpack_pnf_param_general_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_pnf_param_general_t *value = (nfapi_pnf_param_general_t *)tlv;
return( pull8(ppReadPackedMsg, &value->nfapi_sync_mode, end) &&
pull8(ppReadPackedMsg, &value->location_mode, end) &&
pull16(ppReadPackedMsg, &value->location_coordinates_length, end) &&
pullarray8(ppReadPackedMsg, value->location_coordinates, NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH, value->location_coordinates_length, end) &&
pull32(ppReadPackedMsg, &value->dl_config_timing, end) &&
pull32(ppReadPackedMsg, &value->tx_timing, end) &&
pull32(ppReadPackedMsg, &value->ul_config_timing, end) &&
pull32(ppReadPackedMsg, &value->hi_dci0_timing, end) &&
pull16(ppReadPackedMsg, &value->maximum_number_phys, end) &&
pull16(ppReadPackedMsg, &value->maximum_total_bandwidth, end) &&
pull8(ppReadPackedMsg, &value->maximum_total_number_dl_layers, end) &&
pull8(ppReadPackedMsg, &value->maximum_total_number_ul_layers, end) &&
pull8(ppReadPackedMsg, &value->shared_bands, end) &&
pull8(ppReadPackedMsg, &value->shared_pa, end) &&
pulls16(ppReadPackedMsg, &value->maximum_total_power, end) &&
pullarray8(ppReadPackedMsg, value->oui, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, end));
}
static uint8_t unpack_rf_config_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_rf_config_info_t *info = (nfapi_rf_config_info_t *)elem;
return pull16(ppReadPackedMsg, &info->rf_config_index, end);
}
static uint8_t unpack_pnf_phy_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_pnf_phy_info_t *phy = (nfapi_pnf_phy_info_t *)elem;
return ( pull16(ppReadPackedMsg, &phy->phy_config_index, end) &&
pull16(ppReadPackedMsg, &phy->number_of_rfs, end) &&
unpackarray(ppReadPackedMsg, phy->rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rfs, end, &unpack_rf_config_info) &&
pull16(ppReadPackedMsg, &phy->number_of_rf_exclusions, end) &&
unpackarray(ppReadPackedMsg, phy->excluded_rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rf_exclusions, end, &unpack_rf_config_info) &&
pull16(ppReadPackedMsg, &phy->downlink_channel_bandwidth_supported, end) &&
pull16(ppReadPackedMsg, &phy->uplink_channel_bandwidth_supported, end) &&
pull8(ppReadPackedMsg, &phy->number_of_dl_layers_supported, end) &&
pull8(ppReadPackedMsg, &phy->number_of_ul_layers_supported, end) &&
pull16(ppReadPackedMsg, &phy->maximum_3gpp_release_supported, end) &&
pull8(ppReadPackedMsg, &phy->nmm_modes_supported, end));
}
static uint8_t unpack_pnf_phy_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_pnf_phy_t *value = (nfapi_pnf_phy_t *)tlv;
return ( pull16(ppReadPackedMsg, &value->number_of_phys, end) &&
unpackarray(ppReadPackedMsg, value->phy, sizeof(nfapi_pnf_phy_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, end, &unpack_pnf_phy_info));
}
static uint8_t unpack_pnf_rf_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end) { static uint8_t unpack_pnf_rf_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_pnf_rf_info_t *rf = (nfapi_pnf_rf_info_t *)elem; nfapi_pnf_rf_info_t *rf = (nfapi_pnf_rf_info_t *)elem;
return( pull16(ppReadPackedMsg, &rf->rf_config_index, end) && return( pull16(ppReadPackedMsg, &rf->rf_config_index, end) &&
...@@ -2406,6 +1491,7 @@ static uint8_t unpack_pnf_rf_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t ...@@ -2406,6 +1491,7 @@ static uint8_t unpack_pnf_rf_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t
pull32(ppReadPackedMsg, &rf->minimum_uplink_frequency, end) && pull32(ppReadPackedMsg, &rf->minimum_uplink_frequency, end) &&
pull32(ppReadPackedMsg, &rf->maximum_uplink_frequency, end)); pull32(ppReadPackedMsg, &rf->maximum_uplink_frequency, end));
} }
static uint8_t unpack_pnf_rf_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { static uint8_t unpack_pnf_rf_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_pnf_rf_t *value = (nfapi_pnf_rf_t *)tlv; nfapi_pnf_rf_t *value = (nfapi_pnf_rf_t *)tlv;
return ( pull16(ppReadPackedMsg, &value->number_of_rfs, end) && return ( pull16(ppReadPackedMsg, &value->number_of_rfs, end) &&
...@@ -2422,13 +1508,13 @@ static uint8_t unpack_pnf_phy_rel10_info(void *elem, uint8_t **ppReadPackedMsg, ...@@ -2422,13 +1508,13 @@ static uint8_t unpack_pnf_phy_rel10_info(void *elem, uint8_t **ppReadPackedMsg,
pull16(ppReadPackedMsg, &phy->simultaneous_pucch_pusch, end) && pull16(ppReadPackedMsg, &phy->simultaneous_pucch_pusch, end) &&
pull16(ppReadPackedMsg, &phy->four_layer_tx_with_tm3_and_tm4, end)); pull16(ppReadPackedMsg, &phy->four_layer_tx_with_tm3_and_tm4, end));
} }
static uint8_t unpack_pnf_phy_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { static uint8_t unpack_pnf_phy_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_pnf_phy_rel10_t *value = (nfapi_pnf_phy_rel10_t *)tlv; nfapi_pnf_phy_rel10_t *value = (nfapi_pnf_phy_rel10_t *)tlv;
return ( pull16(ppReadPackedMsg, &value->number_of_phys, end) && return ( pull16(ppReadPackedMsg, &value->number_of_phys, end) &&
unpackarray(ppReadPackedMsg, value->phy, sizeof(nfapi_pnf_phy_rel10_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, end, &unpack_pnf_phy_rel10_info)); unpackarray(ppReadPackedMsg, value->phy, sizeof(nfapi_pnf_phy_rel10_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, end, &unpack_pnf_phy_rel10_info));
} }
static uint8_t unpack_pnf_phy_rel11_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end) { static uint8_t unpack_pnf_phy_rel11_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_pnf_phy_rel11_info_t *phy = (nfapi_pnf_phy_rel11_info_t *)elem; nfapi_pnf_phy_rel11_info_t *phy = (nfapi_pnf_phy_rel11_info_t *)elem;
return( pull16(ppReadPackedMsg, &phy->phy_config_index, end) && return( pull16(ppReadPackedMsg, &phy->phy_config_index, end) &&
...@@ -2536,20 +1622,6 @@ static uint8_t unpack_pnf_param_response(uint8_t **ppReadPackedMsg, uint8_t *end ...@@ -2536,20 +1622,6 @@ static uint8_t unpack_pnf_param_response(uint8_t **ppReadPackedMsg, uint8_t *end
unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
} }
static uint8_t unpack_phy_rf_config_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_phy_rf_config_info_t *rf = (nfapi_phy_rf_config_info_t *)elem;
return( pull16(ppReadPackedMsg, &rf->phy_id, end) &&
pull16(ppReadPackedMsg, &rf->phy_config_index, end) &&
pull16(ppReadPackedMsg, &rf->rf_config_index, end));
}
static uint8_t unpack_pnf_phy_rf_config_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_pnf_phy_rf_config_t *value = (nfapi_pnf_phy_rf_config_t *)tlv;
return ( pull16(ppReadPackedMsg, &value->number_phy_rf_config_info, end) &&
unpackarray(ppReadPackedMsg, value->phy_rf_config, sizeof(nfapi_phy_rf_config_info_t), NFAPI_MAX_PHY_RF_INSTANCES, value->number_phy_rf_config_info, end, &unpack_phy_rf_config_info));
}
static uint8_t unpack_nr_pnf_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) static uint8_t unpack_nr_pnf_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{ {
nfapi_nr_pnf_config_request_t *pNfapiMsg = (nfapi_nr_pnf_config_request_t *)msg; nfapi_nr_pnf_config_request_t *pNfapiMsg = (nfapi_nr_pnf_config_request_t *)msg;
...@@ -2598,7 +1670,6 @@ static uint8_t unpack_pnf_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, ...@@ -2598,7 +1670,6 @@ static uint8_t unpack_pnf_start_request(uint8_t **ppReadPackedMsg, uint8_t *end,
return unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); return unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
} }
static uint8_t unpack_pnf_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) { static uint8_t unpack_pnf_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) {
nfapi_pnf_start_response_t *pNfapiMsg = (nfapi_pnf_start_response_t *)msg; nfapi_pnf_start_response_t *pNfapiMsg = (nfapi_pnf_start_response_t *)msg;
return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end ) && return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end ) &&
...@@ -2628,12 +1699,6 @@ static uint8_t unpack_param_request(uint8_t **ppReadPackedMsg, uint8_t *end, voi ...@@ -2628,12 +1699,6 @@ static uint8_t unpack_param_request(uint8_t **ppReadPackedMsg, uint8_t *end, voi
return unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); return unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
} }
static uint8_t unpack_nr_param_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_param_request_scf_t *pNfapiMsg = (nfapi_nr_param_request_scf_t *)msg;
return unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
}
static uint8_t unpack_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) static uint8_t unpack_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{ {
nfapi_param_response_t *pNfapiMsg = (nfapi_param_response_t *)msg; nfapi_param_response_t *pNfapiMsg = (nfapi_param_response_t *)msg;
...@@ -2776,134 +1841,6 @@ static uint8_t unpack_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, vo ...@@ -2776,134 +1841,6 @@ static uint8_t unpack_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, vo
&pNfapiMsg->vendor_extension)); &pNfapiMsg->vendor_extension));
} }
static uint8_t unpack_nr_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_param_response_scf_t *pNfapiMsg = (nfapi_nr_param_response_scf_t *)msg;
unpack_tlv_t unpack_fns[] = {
{NFAPI_NR_PARAM_TLV_RELEASE_CAPABILITY_TAG, &(pNfapiMsg->cell_param.release_capability), &unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_PHY_STATE_TAG, &(pNfapiMsg->cell_param.phy_state), &unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_SKIP_BLANK_DL_CONFIG_TAG, &(pNfapiMsg->cell_param.skip_blank_dl_config), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_SKIP_BLANK_UL_CONFIG_TAG, &(pNfapiMsg->cell_param.skip_blank_ul_config), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_NUM_CONFIG_TLVS_TO_REPORT_TAG,
&(pNfapiMsg->cell_param.num_config_tlvs_to_report),
&unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_CYCLIC_PREFIX_TAG, &(pNfapiMsg->carrier_param.cyclic_prefix), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_DL_TAG,
&(pNfapiMsg->carrier_param.supported_subcarrier_spacings_dl),
&unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_DL_TAG, &(pNfapiMsg->carrier_param.supported_bandwidth_dl), &unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_UL_TAG,
&(pNfapiMsg->carrier_param.supported_subcarrier_spacings_ul),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_UL_TAG, &(pNfapiMsg->carrier_param.supported_bandwidth_ul), &unpack_uint16_tlv_value},
{NFAPI_NR_PARAM_TLV_CCE_MAPPING_TYPE_TAG, &(pNfapiMsg->pdcch_param.cce_mapping_type), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG,
&(pNfapiMsg->pdcch_param.coreset_outside_first_3_of_ofdm_syms_of_slot),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PRECODER_GRANULARITY_CORESET_TAG,
&(pNfapiMsg->pdcch_param.coreset_precoder_granularity_coreset),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDCCH_MU_MIMO_TAG, &(pNfapiMsg->pdcch_param.pdcch_mu_mimo), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDCCH_PRECODER_CYCLING_TAG, &(pNfapiMsg->pdcch_param.pdcch_precoder_cycling), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PDCCHS_PER_SLOT_TAG, &(pNfapiMsg->pdcch_param.max_pdcch_per_slot), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUCCH_FORMATS_TAG, &(pNfapiMsg->pucch_param.pucch_formats), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PUCCHS_PER_SLOT_TAG, &(pNfapiMsg->pucch_param.max_pucchs_per_slot), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_MAPPING_TYPE_TAG, &(pNfapiMsg->pdsch_param.pdsch_mapping_type), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_ALLOCATION_TYPES_TAG, &(pNfapiMsg->pdsch_param.pdsch_allocation_types), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_VRB_TO_PRB_MAPPING_TAG,
&(pNfapiMsg->pdsch_param.pdsch_vrb_to_prb_mapping),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_CBG_TAG, &(pNfapiMsg->pdsch_param.pdsch_cbg), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_DMRS_CONFIG_TYPES_TAG, &(pNfapiMsg->pdsch_param.pdsch_dmrs_config_types), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_DMRS_MAX_LENGTH_TAG, &(pNfapiMsg->pdsch_param.pdsch_dmrs_max_length), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_DMRS_ADDITIONAL_POS_TAG,
&(pNfapiMsg->pdsch_param.pdsch_dmrs_additional_pos),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PDSCH_S_YBS_PER_SLOT_TAG, &(pNfapiMsg->pdsch_param.max_pdsch_tbs_per_slot), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG,
&(pNfapiMsg->pdsch_param.max_number_mimo_layers_pdsch),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_DL_TAG, &(pNfapiMsg->pdsch_param.max_mu_mimo_users_dl), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG,
&(pNfapiMsg->pdsch_param.pdsch_data_in_dmrs_symbols),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PREMPTION_SUPPORT_TAG, &(pNfapiMsg->pdsch_param.premption_support), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PDSCH_NON_SLOT_SUPPORT_TAG, &(pNfapiMsg->pdsch_param.pdsch_non_slot_support), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_UCI_MUX_ULSCH_IN_PUSCH_TAG, &(pNfapiMsg->pusch_param.uci_mux_ulsch_in_pusch), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_UCI_ONLY_PUSCH_TAG, &(pNfapiMsg->pusch_param.uci_only_pusch), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_FREQUENCY_HOPPING_TAG, &(pNfapiMsg->pusch_param.pusch_frequency_hopping), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_DMRS_CONFIG_TYPES_TAG, &(pNfapiMsg->pusch_param.pusch_dmrs_config_types), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_DMRS_MAX_LEN_TAG, &(pNfapiMsg->pusch_param.pusch_dmrs_max_len), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_DMRS_ADDITIONAL_POS_TAG,
&(pNfapiMsg->pusch_param.pusch_dmrs_additional_pos),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_CBG_TAG, &(pNfapiMsg->pusch_param.pusch_cbg), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_MAPPING_TYPE_TAG, &(pNfapiMsg->pusch_param.pusch_mapping_type), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_ALLOCATION_TYPES_TAG, &(pNfapiMsg->pusch_param.pusch_allocation_types), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_VRB_TO_PRB_MAPPING_TAG,
&(pNfapiMsg->pusch_param.pusch_vrb_to_prb_mapping),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_MAX_PTRS_PORTS_TAG, &(pNfapiMsg->pusch_param.pusch_max_ptrs_ports), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PDUSCHS_TBS_PER_SLOT_TAG,
&(pNfapiMsg->pusch_param.max_pduschs_tbs_per_slot),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG,
&(pNfapiMsg->pusch_param.max_number_mimo_layers_non_cb_pusch),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_SUPPORTED_MODULATION_ORDER_UL_TAG,
&(pNfapiMsg->pusch_param.supported_modulation_order_ul),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_UL_TAG, &(pNfapiMsg->pusch_param.max_mu_mimo_users_ul), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_DFTS_OFDM_SUPPORT_TAG, &(pNfapiMsg->pusch_param.dfts_ofdm_support), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PUSCH_AGGREGATION_FACTOR_TAG,
&(pNfapiMsg->pusch_param.pusch_aggregation_factor),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PRACH_LONG_FORMATS_TAG, &(pNfapiMsg->prach_param.prach_long_formats), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PRACH_SHORT_FORMATS_TAG, &(pNfapiMsg->prach_param.prach_short_formats), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_PRACH_RESTRICTED_SETS_TAG, &(pNfapiMsg->prach_param.prach_restricted_sets), &unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG,
&(pNfapiMsg->prach_param.max_prach_fd_occasions_in_a_slot),
&unpack_uint8_tlv_value},
{NFAPI_NR_PARAM_TLV_RSSI_MEASUREMENT_SUPPORT_TAG,
&(pNfapiMsg->measurement_param.rssi_measurement_support),
&unpack_uint8_tlv_value},
// config
{NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &pNfapiMsg->nfapi_config.p7_vnf_address_ipv4, &unpack_ipv4_address_value},
{NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &pNfapiMsg->nfapi_config.p7_vnf_address_ipv6, &unpack_ipv6_address_value},
{NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, &pNfapiMsg->nfapi_config.p7_vnf_port, &unpack_uint16_tlv_value},
{NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv4, &unpack_ipv4_address_value},
{NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv6, &unpack_ipv6_address_value},
{NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &pNfapiMsg->nfapi_config.p7_pnf_port, &unpack_uint16_tlv_value},
{NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &pNfapiMsg->nfapi_config.timing_window, &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &pNfapiMsg->nfapi_config.timing_info_mode, &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &pNfapiMsg->nfapi_config.timing_info_period, &unpack_uint8_tlv_value},
};
// print ppReadPackedMsg
uint8_t *ptr = *ppReadPackedMsg;
printf("\n Read message unpack_param_response: ");
while (ptr < end) {
printf(" %02x ", *ptr);
ptr++;
}
printf("\n");
return (pull8(ppReadPackedMsg, &pNfapiMsg->error_code, end) && pull8(ppReadPackedMsg, &pNfapiMsg->num_tlv, end)
&& unpack_nr_tlv_list(unpack_fns,
sizeof(unpack_fns) / sizeof(unpack_tlv_t),
ppReadPackedMsg,
end,
config,
&pNfapiMsg->vendor_extension));
}
static uint8_t unpack_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) static uint8_t unpack_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{ {
nfapi_config_request_t *pNfapiMsg = (nfapi_config_request_t *)msg; nfapi_config_request_t *pNfapiMsg = (nfapi_config_request_t *)msg;
...@@ -3121,324 +2058,11 @@ static uint8_t unpack_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, vo ...@@ -3121,324 +2058,11 @@ static uint8_t unpack_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, vo
&pNfapiMsg->vendor_extension)); &pNfapiMsg->vendor_extension));
} }
static uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) static uint8_t unpack_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{ {
// Helper vars for indexed TLVs
int prach_root_seq_idx = 0;
int unused_root_seq_idx = 0;
int ssb_mask_idx = 0;
int config_beam_idx = 0;
int tdd_periodicity_idx = 0;
int symbol_per_slot_idx = 0;
nfapi_nr_config_request_scf_t *pNfapiMsg = (nfapi_nr_config_request_scf_t *)msg;
// Memory allocations
pNfapiMsg->tdd_table.max_tdd_periodicity_list =
(nfapi_nr_max_tdd_periodicity_t *)malloc(40 * sizeof(nfapi_nr_max_tdd_periodicity_t));
for (int i = 0; i < 40; i++) {
pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list =
(nfapi_nr_max_num_of_symbol_per_slot_t *)malloc(14 * sizeof(nfapi_nr_max_num_of_symbol_per_slot_t));
}
pNfapiMsg->prach_config.num_prach_fd_occasions_list =
(nfapi_nr_num_prach_fd_occasions_t *)malloc(sizeof(nfapi_nr_num_prach_fd_occasions_t));
// unpack TLVs
unpack_tlv_t unpack_fns[] = {
{NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG, &(pNfapiMsg->carrier_config.dl_bandwidth), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_DL_FREQUENCY_TAG, &(pNfapiMsg->carrier_config.dl_frequency), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_DL_GRID_SIZE_TAG, &(pNfapiMsg->carrier_config.dl_grid_size[1]), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_DL_K0_TAG, &(pNfapiMsg->carrier_config.dl_k0[1]), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_NUM_TX_ANT_TAG, &(pNfapiMsg->carrier_config.num_tx_ant), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_UPLINK_BANDWIDTH_TAG, &(pNfapiMsg->carrier_config.uplink_bandwidth), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_UPLINK_FREQUENCY_TAG, &(pNfapiMsg->carrier_config.uplink_frequency), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_UL_GRID_SIZE_TAG, &(pNfapiMsg->carrier_config.ul_grid_size[1]), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_UL_K0_TAG, &(pNfapiMsg->carrier_config.ul_k0[1]), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_NUM_RX_ANT_TAG, &(pNfapiMsg->carrier_config.num_rx_ant), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_FREQUENCY_SHIFT_7P5KHZ_TAG, &(pNfapiMsg->carrier_config.frequency_shift_7p5khz), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PHY_CELL_ID_TAG, &(pNfapiMsg->cell_config.phy_cell_id), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_FRAME_DUPLEX_TYPE_TAG, &(pNfapiMsg->cell_config.frame_duplex_type), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SS_PBCH_POWER_TAG, &(pNfapiMsg->ssb_config.ss_pbch_power), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_BCH_PAYLOAD_TAG, &(pNfapiMsg->ssb_config.bch_payload), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SCS_COMMON_TAG, &(pNfapiMsg->ssb_config.scs_common), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_SEQUENCE_LENGTH_TAG, &(pNfapiMsg->prach_config.prach_sequence_length), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_SUB_C_SPACING_TAG, &(pNfapiMsg->prach_config.prach_sub_c_spacing), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_RESTRICTED_SET_CONFIG_TAG, &(pNfapiMsg->prach_config.restricted_set_config), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_NUM_PRACH_FD_OCCASIONS_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_CONFIG_INDEX_TAG, &(pNfapiMsg->prach_config.prach_ConfigurationIndex), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG,
&(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].prach_root_sequence_index),
&unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG,
&(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].num_root_sequences),
&unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_K1_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].k1), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG,
&(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].prach_zero_corr_conf),
&unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_NUM_UNUSED_ROOT_SEQUENCES_TAG,
&(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].num_unused_root_sequences),
&unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_UNUSED_ROOT_SEQUENCES_TAG,
&(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].unused_root_sequences_list[0]),
&unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_SSB_PER_RACH_TAG, &(pNfapiMsg->prach_config.ssb_per_rach), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG,
&(pNfapiMsg->prach_config.prach_multiple_carriers_in_a_band),
&unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG, &(pNfapiMsg->ssb_table.ssb_offset_point_a), &unpack_uint16_tlv_value},
{NFAPI_NR_CONFIG_BETA_PSS_TAG, &(pNfapiMsg->ssb_table.beta_pss), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SSB_PERIOD_TAG, &(pNfapiMsg->ssb_table.ssb_period), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG, &(pNfapiMsg->ssb_table.ssb_subcarrier_offset), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_MIB_TAG, &(pNfapiMsg->ssb_table.MIB), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_SSB_MASK_TAG, &(pNfapiMsg->ssb_table.ssb_mask_list[0].ssb_mask), &unpack_uint32_tlv_value},
{NFAPI_NR_CONFIG_BEAM_ID_TAG, &(pNfapiMsg->ssb_table.ssb_beam_id_list[0].beam_id), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG,
&(pNfapiMsg->ssb_table.ss_pbch_multiple_carriers_in_a_band),
&unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG,
&(pNfapiMsg->ssb_table.multiple_cells_ss_pbch_in_a_carrier),
&unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_TDD_PERIOD_TAG, &(pNfapiMsg->tdd_table.tdd_period), &unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_SLOT_CONFIG_TAG,
&(pNfapiMsg->tdd_table.max_tdd_periodicity_list[0].max_num_of_symbol_per_slot_list[0].slot_config),
&unpack_uint8_tlv_value},
{NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG, &(pNfapiMsg->measurement_config.rssi_measurement), &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), &unpack_ipv4_address_value},
{NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6), &unpack_ipv6_address_value},
{NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_port), &unpack_uint16_tlv_value},
{NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), &unpack_uint8_tlv_value},
{NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), &unpack_ipv6_address_value},
{NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), &unpack_uint16_tlv_value}};
pull8(ppReadPackedMsg, &pNfapiMsg->num_tlv, end);
pNfapiMsg->vendor_extension = malloc(sizeof(&(pNfapiMsg->vendor_extension)));
nfapi_tl_t generic_tl;
uint8_t numBadTags = 0;
unsigned long idx = 0;
while ((uint8_t *)(*ppReadPackedMsg) < end) {
// unpack the tl and process the values accordingly
if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
return 0;
uint8_t tagMatch = 0;
uint8_t *pStartOfValue = 0;
for (idx = 0; idx < sizeof(unpack_fns) / sizeof(unpack_tlv_t); ++idx) {
if (unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list
pStartOfValue = *ppReadPackedMsg;
tagMatch = 1;
nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv);
tl->tag = generic_tl.tag;
tl->length = generic_tl.length;
int result = 0;
switch (generic_tl.tag) {
case NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG:
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_root_sequence_index.tl.tag =
generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_root_sequence_index.tl.length =
generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(
&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_root_sequence_index,
ppReadPackedMsg,
end);
prach_root_seq_idx++;
break;
case NFAPI_NR_CONFIG_K1_TAG:
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].k1.tl.tag = generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].k1.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].k1,
ppReadPackedMsg,
end);
break;
case NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG:
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_zero_corr_conf.tl.tag = generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_zero_corr_conf.tl.length =
generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(
&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].prach_zero_corr_conf,
ppReadPackedMsg,
end);
break;
case NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG:
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_root_sequences.tl.tag = generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_root_sequences.tl.length =
generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(
&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_root_sequences,
ppReadPackedMsg,
end);
break;
case NFAPI_NR_CONFIG_NUM_UNUSED_ROOT_SEQUENCES_TAG:
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_unused_root_sequences.tl.tag =
generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_unused_root_sequences.tl.length =
generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(
&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx].num_unused_root_sequences,
ppReadPackedMsg,
end);
break;
case NFAPI_NR_CONFIG_UNUSED_ROOT_SEQUENCES_TAG:
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx]
.unused_root_sequences_list[unused_root_seq_idx]
.tl.tag = generic_tl.tag;
pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx]
.unused_root_sequences_list[unused_root_seq_idx]
.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->prach_config.num_prach_fd_occasions_list[prach_root_seq_idx]
.unused_root_sequences_list[unused_root_seq_idx],
ppReadPackedMsg,
end);
unused_root_seq_idx++;
break;
case NFAPI_NR_CONFIG_SSB_MASK_TAG:
pNfapiMsg->ssb_table.ssb_mask_list[ssb_mask_idx].ssb_mask.tl.tag = generic_tl.tag;
pNfapiMsg->ssb_table.ssb_mask_list[ssb_mask_idx].ssb_mask.tl.length = generic_tl.length;
result = unpack_uint32_tlv_value(&pNfapiMsg->ssb_table.ssb_mask_list[ssb_mask_idx].ssb_mask, ppReadPackedMsg, end);
ssb_mask_idx++;
break;
case NFAPI_NR_CONFIG_DL_GRID_SIZE_TAG:
for (int i = 0; i < 5; i++) {
result = unpack_uint16_tlv_value(&pNfapiMsg->carrier_config.dl_grid_size[i], ppReadPackedMsg, end);
}
break;
case NFAPI_NR_CONFIG_DL_K0_TAG:
for (int i = 0; i < 5; i++) {
result = unpack_uint16_tlv_value(&pNfapiMsg->carrier_config.dl_k0[i], ppReadPackedMsg, end);
}
break;
case NFAPI_NR_CONFIG_UL_GRID_SIZE_TAG:
for (int i = 0; i < 5; i++) {
result = unpack_uint16_tlv_value(&pNfapiMsg->carrier_config.ul_grid_size[i], ppReadPackedMsg, end);
}
break;
case NFAPI_NR_CONFIG_UL_K0_TAG:
for (int i = 0; i < 5; i++) {
result = unpack_uint16_tlv_value(&pNfapiMsg->carrier_config.ul_k0[i], ppReadPackedMsg, end);
}
break;
case NFAPI_NR_CONFIG_BEAM_ID_TAG:
pNfapiMsg->ssb_table.ssb_beam_id_list[config_beam_idx].beam_id.tl.tag = generic_tl.tag;
pNfapiMsg->ssb_table.ssb_beam_id_list[config_beam_idx].beam_id.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->ssb_table.ssb_beam_id_list[config_beam_idx].beam_id,
ppReadPackedMsg,
end);
config_beam_idx++;
break;
case NFAPI_NR_CONFIG_SLOT_CONFIG_TAG:
pNfapiMsg->tdd_table.max_tdd_periodicity_list[tdd_periodicity_idx]
.max_num_of_symbol_per_slot_list[symbol_per_slot_idx]
.slot_config.tl.tag = generic_tl.tag;
pNfapiMsg->tdd_table.max_tdd_periodicity_list[tdd_periodicity_idx]
.max_num_of_symbol_per_slot_list[symbol_per_slot_idx]
.slot_config.tl.length = generic_tl.length;
result = (*unpack_fns[idx].unpack_func)(&pNfapiMsg->tdd_table.max_tdd_periodicity_list[tdd_periodicity_idx]
.max_num_of_symbol_per_slot_list[symbol_per_slot_idx]
.slot_config,
ppReadPackedMsg,
end);
symbol_per_slot_idx = (symbol_per_slot_idx + 1) % 14;
if (symbol_per_slot_idx == 0) {
tdd_periodicity_idx++;
}
break;
default:
result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end);
break;
}
if (result == 0)
return 0;
// check if the length was right;
if (tl->length != (((*ppReadPackedMsg)) - pStartOfValue))
NFAPI_TRACE(NFAPI_TRACE_ERROR,
"Warning tlv tag 0x%x length %d not equal to unpack %lu\n",
tl->tag,
tl->length,
(*ppReadPackedMsg - pStartOfValue));
// Remove padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
int padding = get_tlv_padding(tl->length);
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "TLV 0x%x length %d with padding of %d bytes\n", tl->tag, tl->length, padding);
if (padding != 0)
(*ppReadPackedMsg) += padding;
}
}
if (tagMatch == 0) {
if (generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) {
int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
if (result == 0) {
// got to the end.
return 0;
} else if (result < 0) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag);
if (++numBadTags > MAX_BAD_TAG) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n");
return 0;
}
if ((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length;
int padding = get_tlv_padding(generic_tl.length);
(*ppReadPackedMsg) += padding;
} else {
// go to the end
return 0;
}
}
} else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag);
if (++numBadTags > MAX_BAD_TAG) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n");
return 0;
}
if ((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length;
int padding = get_tlv_padding(generic_tl.length);
(*ppReadPackedMsg) += padding;
} else {
// go to the end
return 0;
}
}
}
}
struct sockaddr_in vnf_p7_sockaddr;
memcpy(&vnf_p7_sockaddr.sin_addr.s_addr, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), 4);
printf("[PNF] vnf p7 %s:%d\n", inet_ntoa(vnf_p7_sockaddr.sin_addr), pNfapiMsg->nfapi_config.p7_vnf_port.value);
return 1;
}
static uint8_t unpack_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) {
nfapi_config_response_t *pNfapiMsg = (nfapi_config_response_t *)msg; nfapi_config_response_t *pNfapiMsg = (nfapi_config_response_t *)msg;
return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end)
unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); && unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)));
}
static uint8_t unpack_nr_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_config_response_scf_t *pNfapiMsg = (nfapi_nr_config_response_scf_t *)msg;
uint8_t invalid_unsupported_TLVs, invalidTLVsIdle, InvalidTLVsRunning, missingTLVS;
uint8_t retVal = (pull8(ppReadPackedMsg, &pNfapiMsg->error_code, end) && pull8(ppReadPackedMsg, &invalid_unsupported_TLVs, end)
&& pull8(ppReadPackedMsg, &invalidTLVsIdle, end) && pull8(ppReadPackedMsg, &InvalidTLVsRunning, end)
&& pull8(ppReadPackedMsg, &missingTLVS, end)
&& unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)));
// TODO: Process and use the invalid TLVs fields
return retVal;
}
static uint8_t unpack_nr_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_start_request_scf_t *pNfapiMsg = (nfapi_nr_start_request_scf_t *)msg;
return unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
} }
static uint8_t unpack_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) { static uint8_t unpack_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) {
...@@ -3452,40 +2076,17 @@ static uint8_t unpack_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, vo ...@@ -3452,40 +2076,17 @@ static uint8_t unpack_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, vo
unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)));
} }
static uint8_t unpack_nr_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config)
{
nfapi_nr_start_response_scf_t *pNfapiMsg = (nfapi_nr_start_response_scf_t *)msg;
return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end)
&& unpack_nr_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)));
}
static uint8_t unpack_stop_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) { static uint8_t unpack_stop_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) {
nfapi_stop_request_t *pNfapiMsg = (nfapi_stop_request_t *)msg; nfapi_stop_request_t *pNfapiMsg = (nfapi_stop_request_t *)msg;
return unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); return unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
} }
static uint8_t unpack_stop_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) {
nfapi_stop_response_t *pNfapiMsg = (nfapi_stop_response_t *)msg;
return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) &&
unpack_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)));
}
static uint8_t unpack_measurement_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) {
nfapi_measurement_request_t *pNfapiMsg = (nfapi_measurement_request_t *)msg;
unpack_tlv_t unpack_fns[] = {
{ NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG, &pNfapiMsg->dl_rs_tx_power, &unpack_uint16_tlv_value},
{ NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG, &pNfapiMsg->received_interference_power, &unpack_uint16_tlv_value},
{ NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG, &pNfapiMsg->thermal_noise_power, &unpack_uint16_tlv_value},
};
return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension));
}
static uint8_t unpack_received_interference_power_measurement_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { static uint8_t unpack_received_interference_power_measurement_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) {
nfapi_received_interference_power_measurement_t *value = (nfapi_received_interference_power_measurement_t *)tlv; nfapi_received_interference_power_measurement_t *value = (nfapi_received_interference_power_measurement_t *)tlv;
return ( pull16(ppReadPackedMsg, &value->number_of_resource_blocks, end) && return ( pull16(ppReadPackedMsg, &value->number_of_resource_blocks, end) &&
pullarrays16(ppReadPackedMsg, value->received_interference_power, NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS, value->number_of_resource_blocks, end)); pullarrays16(ppReadPackedMsg, value->received_interference_power, NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS, value->number_of_resource_blocks, end));
} }
static uint8_t unpack_measurement_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) { static uint8_t unpack_measurement_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) {
nfapi_measurement_response_t *pNfapiMsg = (nfapi_measurement_response_t *)msg; nfapi_measurement_response_t *pNfapiMsg = (nfapi_measurement_response_t *)msg;
unpack_tlv_t unpack_fns[] = { unpack_tlv_t unpack_fns[] = {
...@@ -3550,47 +2151,16 @@ static int check_nr_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpack ...@@ -3550,47 +2151,16 @@ static int check_nr_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpack
retLen = sizeof(nfapi_nr_pnf_stop_response_t); retLen = sizeof(nfapi_nr_pnf_stop_response_t);
break; break;
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST: case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_param_request_scf_t))
retLen = sizeof(nfapi_nr_param_request_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE: case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_nr_param_response_scf_t))
retLen = sizeof(nfapi_nr_param_response_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST: case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_nr_config_request_scf_t))
retLen = sizeof(nfapi_nr_config_request_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE: case NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_nr_config_response_scf_t))
retLen = sizeof(nfapi_nr_config_response_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST: case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST:
if (unpackedBufLen >= sizeof( nfapi_nr_start_request_scf_t))
retLen = sizeof( nfapi_nr_start_request_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE: case NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_nr_start_response_scf_t))
retLen = sizeof(nfapi_nr_start_response_scf_t);
break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST: case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST:
if (unpackedBufLen >= sizeof(nfapi_stop_request_t)) case NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION:
retLen = sizeof(nfapi_stop_request_t); case NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION:
retLen = check_nr_fapi_unpack_length(msgId, unpackedBufLen);
break; break;
case NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE: case NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE:
...@@ -3607,7 +2177,6 @@ static int check_nr_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpack ...@@ -3607,7 +2177,6 @@ static int check_nr_unpack_length(nfapi_nr_phy_msg_type_e msgId, uint32_t unpack
return retLen; return retLen;
} }
static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen) { static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen) {
int retLen = 0; int retLen = 0;
...@@ -3728,7 +2297,6 @@ static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen ...@@ -3728,7 +2297,6 @@ static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen
return retLen; return retLen;
} }
// Main unpack functions - public // Main unpack functions - public
int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t *config) { int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t *config) {
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <nfapi.h> #include <nfapi.h>
#include <debug.h> #include <debug.h>
#include "nfapi_nr_interface_scf.h" #include "nfapi_nr_interface_scf.h"
#include "nr_nfapi_p7.h"
extern int nfapi_unpack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppReadPackedMsg, void *user_data); extern int nfapi_unpack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppReadPackedMsg, void *user_data);
extern int nfapi_pack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppWritePackedMsg, void *user_data); extern int nfapi_pack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppWritePackedMsg, void *user_data);
...@@ -829,7 +830,7 @@ static uint8_t pack_dl_config_request_body_value(void *tlv, uint8_t **ppWritePac ...@@ -829,7 +830,7 @@ static uint8_t pack_dl_config_request_body_value(void *tlv, uint8_t **ppWritePac
return 1; return 1;
} }
static uint8_t pack_dl_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) uint8_t pack_dl_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{ {
nfapi_nr_dl_tti_request_t *pNfapiMsg = (nfapi_nr_dl_tti_request_t *)msg; nfapi_nr_dl_tti_request_t *pNfapiMsg = (nfapi_nr_dl_tti_request_t *)msg;
...@@ -1658,7 +1659,7 @@ static uint8_t pack_ul_config_request_body_value(void *tlv, uint8_t **ppWritePac ...@@ -1658,7 +1659,7 @@ static uint8_t pack_ul_config_request_body_value(void *tlv, uint8_t **ppWritePac
return 1; return 1;
} }
static uint8_t pack_ul_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) uint8_t pack_ul_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{ {
nfapi_nr_ul_tti_request_t *pNfapiMsg = (nfapi_nr_ul_tti_request_t *)msg; nfapi_nr_ul_tti_request_t *pNfapiMsg = (nfapi_nr_ul_tti_request_t *)msg;
pNfapiMsg->n_ulcch = 0; pNfapiMsg->n_ulcch = 0;
...@@ -1987,25 +1988,22 @@ static uint8_t pack_ul_dci_pdu_list_value(void *tlv, uint8_t **ppWritePackedMsg, ...@@ -1987,25 +1988,22 @@ static uint8_t pack_ul_dci_pdu_list_value(void *tlv, uint8_t **ppWritePackedMsg,
return push16(value->PDUSize, &pPackedLengthField, end); return push16(value->PDUSize, &pPackedLengthField, end);
} }
static uint8_t pack_ul_dci_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { uint8_t pack_ul_dci_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{
nfapi_nr_ul_dci_request_t *pNfapiMsg = (nfapi_nr_ul_dci_request_t *)msg; nfapi_nr_ul_dci_request_t *pNfapiMsg = (nfapi_nr_ul_dci_request_t *)msg;
if (!(push16(pNfapiMsg->SFN, ppWritePackedMsg, end) && if (!(push16(pNfapiMsg->SFN, ppWritePackedMsg, end) && push16(pNfapiMsg->Slot, ppWritePackedMsg, end)
push16(pNfapiMsg->Slot, ppWritePackedMsg, end) && && push8(pNfapiMsg->numPdus, ppWritePackedMsg, end)))
push8(pNfapiMsg->numPdus, ppWritePackedMsg, end)
))
return 0; return 0;
for(int i=0; i<pNfapiMsg->numPdus; i++) { for (int i = 0; i < pNfapiMsg->numPdus; i++) {
if(!pack_ul_dci_pdu_list_value(&pNfapiMsg->ul_dci_pdu_list[i], ppWritePackedMsg, end)) if (!pack_ul_dci_pdu_list_value(&pNfapiMsg->ul_dci_pdu_list[i], ppWritePackedMsg, end))
return 0; return 0;
} }
return 1; return 1;
} }
static uint8_t pack_hi_dci0_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { static uint8_t pack_hi_dci0_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
nfapi_hi_dci0_request_t *pNfapiMsg = (nfapi_hi_dci0_request_t *)msg; nfapi_hi_dci0_request_t *pNfapiMsg = (nfapi_hi_dci0_request_t *)msg;
return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) &&
...@@ -2159,10 +2157,15 @@ static uint8_t pack_release_request_body_value(void *tlv, uint8_t **ppWritePacke ...@@ -2159,10 +2157,15 @@ static uint8_t pack_release_request_body_value(void *tlv, uint8_t **ppWritePacke
return 1; return 1;
} }
static uint8_t pack_ue_release_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { uint8_t pack_ue_release_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{
nfapi_ue_release_request_t *pNfapiMsg = (nfapi_ue_release_request_t *)msg; nfapi_ue_release_request_t *pNfapiMsg = (nfapi_ue_release_request_t *)msg;
int x = push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end); int x = push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end);
int y = pack_tlv(NFAPI_UE_RELEASE_BODY_TAG, &pNfapiMsg->ue_release_request_body, ppWritePackedMsg, end, &pack_release_request_body_value); int y = pack_tlv(NFAPI_UE_RELEASE_BODY_TAG,
&pNfapiMsg->ue_release_request_body,
ppWritePackedMsg,
end,
&pack_release_request_body_value);
int z = pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); int z = pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
return x && y && z; return x && y && z;
} }
...@@ -2179,7 +2182,8 @@ static uint8_t pack_nr_ue_release_request(void *msg, uint8_t **ppWritePackedMsg, ...@@ -2179,7 +2182,8 @@ static uint8_t pack_nr_ue_release_request(void *msg, uint8_t **ppWritePackedMsg,
&& pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); && pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
} }
static uint8_t pack_ue_release_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { uint8_t pack_ue_release_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{
nfapi_ue_release_response_t *pNfapiMsg = (nfapi_ue_release_response_t *)msg; nfapi_ue_release_response_t *pNfapiMsg = (nfapi_ue_release_response_t *)msg;
int x = push32(pNfapiMsg->error_code, ppWritePackedMsg, end); int x = push32(pNfapiMsg->error_code, ppWritePackedMsg, end);
int z = pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); int z = pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
...@@ -3087,11 +3091,11 @@ static uint8_t pack_nrach_indication(void *msg, uint8_t **ppWritePackedMsg, uint ...@@ -3087,11 +3091,11 @@ static uint8_t pack_nrach_indication(void *msg, uint8_t **ppWritePackedMsg, uint
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_nr_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { uint8_t pack_nr_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{
nfapi_nr_dl_node_sync_t *pNfapiMsg = (nfapi_nr_dl_node_sync_t *)msg; nfapi_nr_dl_node_sync_t *pNfapiMsg = (nfapi_nr_dl_node_sync_t *)msg;
return ( push32(pNfapiMsg->t1, ppWritePackedMsg, end) && return (push32(pNfapiMsg->t1, ppWritePackedMsg, end) && pushs32(pNfapiMsg->delta_sfn_slot, ppWritePackedMsg, end)
pushs32(pNfapiMsg->delta_sfn_slot, ppWritePackedMsg, end) && && pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { static uint8_t pack_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
...@@ -3101,12 +3105,12 @@ static uint8_t pack_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t ...@@ -3101,12 +3105,12 @@ static uint8_t pack_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_nr_ul_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { uint8_t pack_nr_ul_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{
nfapi_nr_ul_node_sync_t *pNfapiMsg = (nfapi_nr_ul_node_sync_t *)msg; nfapi_nr_ul_node_sync_t *pNfapiMsg = (nfapi_nr_ul_node_sync_t *)msg;
return (push32(pNfapiMsg->t1, ppWritePackedMsg, end) && return (push32(pNfapiMsg->t1, ppWritePackedMsg, end) && push32(pNfapiMsg->t2, ppWritePackedMsg, end)
push32(pNfapiMsg->t2, ppWritePackedMsg, end) && && push32(pNfapiMsg->t3, ppWritePackedMsg, end)
push32(pNfapiMsg->t3, ppWritePackedMsg, end) && && pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_ul_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { static uint8_t pack_ul_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
...@@ -3136,40 +3140,37 @@ static uint8_t pack_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t * ...@@ -3136,40 +3140,37 @@ static uint8_t pack_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
static uint8_t pack_nr_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { uint8_t pack_nr_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{
nfapi_nr_timing_info_t *pNfapiMsg = (nfapi_nr_timing_info_t *)msg; nfapi_nr_timing_info_t *pNfapiMsg = (nfapi_nr_timing_info_t *)msg;
return (push32(pNfapiMsg->last_sfn, ppWritePackedMsg, end) && return (push32(pNfapiMsg->last_sfn, ppWritePackedMsg, end) && push32(pNfapiMsg->last_slot, ppWritePackedMsg, end)
push32(pNfapiMsg->last_slot, ppWritePackedMsg, end) && && push32(pNfapiMsg->time_since_last_timing_info, ppWritePackedMsg, end)
push32(pNfapiMsg->time_since_last_timing_info, ppWritePackedMsg, end) && && push32(pNfapiMsg->dl_tti_jitter, ppWritePackedMsg, end)
push32(pNfapiMsg->dl_tti_jitter, ppWritePackedMsg, end) && && push32(pNfapiMsg->tx_data_request_jitter, ppWritePackedMsg, end)
push32(pNfapiMsg->tx_data_request_jitter, ppWritePackedMsg, end) && && push32(pNfapiMsg->ul_tti_jitter, ppWritePackedMsg, end) && push32(pNfapiMsg->ul_dci_jitter, ppWritePackedMsg, end)
push32(pNfapiMsg->ul_tti_jitter, ppWritePackedMsg, end) && && pushs32(pNfapiMsg->dl_tti_latest_delay, ppWritePackedMsg, end)
push32(pNfapiMsg->ul_dci_jitter, ppWritePackedMsg, end) && && pushs32(pNfapiMsg->tx_data_request_latest_delay, ppWritePackedMsg, end)
pushs32(pNfapiMsg->dl_tti_latest_delay, ppWritePackedMsg, end) && && pushs32(pNfapiMsg->ul_tti_latest_delay, ppWritePackedMsg, end)
pushs32(pNfapiMsg->tx_data_request_latest_delay, ppWritePackedMsg, end) && && pushs32(pNfapiMsg->ul_dci_latest_delay, ppWritePackedMsg, end)
pushs32(pNfapiMsg->ul_tti_latest_delay, ppWritePackedMsg, end) && && pushs32(pNfapiMsg->dl_tti_earliest_arrival, ppWritePackedMsg, end)
pushs32(pNfapiMsg->ul_dci_latest_delay, ppWritePackedMsg, end) && && pushs32(pNfapiMsg->tx_data_request_earliest_arrival, ppWritePackedMsg, end)
pushs32(pNfapiMsg->dl_tti_earliest_arrival, ppWritePackedMsg, end) && && pushs32(pNfapiMsg->ul_tti_earliest_arrival, ppWritePackedMsg, end)
pushs32(pNfapiMsg->tx_data_request_earliest_arrival, ppWritePackedMsg, end) && && pushs32(pNfapiMsg->ul_dci_earliest_arrival, ppWritePackedMsg, end)
pushs32(pNfapiMsg->ul_tti_earliest_arrival, ppWritePackedMsg, end) && && pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
pushs32(pNfapiMsg->ul_dci_earliest_arrival, ppWritePackedMsg, end) &&
pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config));
} }
//NR UPLINK indication function packing //NR UPLINK indication function packing
//SLOT INDICATION //SLOT INDICATION
static uint8_t pack_nr_slot_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) uint8_t pack_nr_slot_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{ {
nfapi_nr_slot_indication_scf_t *pNfapiMsg = (nfapi_nr_slot_indication_scf_t*)msg; nfapi_nr_slot_indication_scf_t *pNfapiMsg = (nfapi_nr_slot_indication_scf_t *)msg;
if (!(push16((uint16_t)pNfapiMsg->sfn , ppWritePackedMsg, end) && if (!(push16((uint16_t)pNfapiMsg->sfn, ppWritePackedMsg, end) && push16((uint16_t)pNfapiMsg->slot, ppWritePackedMsg, end)))
push16((uint16_t)pNfapiMsg->slot , ppWritePackedMsg, end)
))
return 0; return 0;
return 1; return 1;
} }
//RX DATA INDICATION //RX DATA INDICATION
...@@ -3193,20 +3194,16 @@ static uint8_t pack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t *value, ui ...@@ -3193,20 +3194,16 @@ static uint8_t pack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t *value, ui
return 1; return 1;
} }
uint8_t pack_nr_rx_data_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
static uint8_t pack_nr_rx_data_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
{ {
nfapi_nr_rx_data_indication_t *pNfapiMsg = (nfapi_nr_rx_data_indication_t*)msg; nfapi_nr_rx_data_indication_t *pNfapiMsg = (nfapi_nr_rx_data_indication_t *)msg;
if (!(push16(pNfapiMsg->sfn , ppWritePackedMsg, end) && if (!(push16(pNfapiMsg->sfn, ppWritePackedMsg, end) && push16(pNfapiMsg->slot, ppWritePackedMsg, end)
push16(pNfapiMsg->slot , ppWritePackedMsg, end) && && push16(pNfapiMsg->number_of_pdus, ppWritePackedMsg, end)))
push16(pNfapiMsg->number_of_pdus, ppWritePackedMsg, end)
))
return 0; return 0;
for (int i = 0; i < pNfapiMsg->number_of_pdus; i++) for (int i = 0; i < pNfapiMsg->number_of_pdus; i++) {
{ if (!pack_nr_rx_data_indication_body(&(pNfapiMsg->pdu_list[i]), ppWritePackedMsg, end))
if(!pack_nr_rx_data_indication_body(&(pNfapiMsg->pdu_list[i]), ppWritePackedMsg, end))
return 0; return 0;
} }
...@@ -3238,19 +3235,16 @@ static uint8_t pack_nr_crc_indication_body(nfapi_nr_crc_t *value, uint8_t **ppWr ...@@ -3238,19 +3235,16 @@ static uint8_t pack_nr_crc_indication_body(nfapi_nr_crc_t *value, uint8_t **ppWr
return 1; return 1;
} }
static uint8_t pack_nr_crc_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) uint8_t pack_nr_crc_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{ {
nfapi_nr_crc_indication_t *pNfapiMsg = (nfapi_nr_crc_indication_t*)msg; nfapi_nr_crc_indication_t *pNfapiMsg = (nfapi_nr_crc_indication_t *)msg;
if (!(push16(pNfapiMsg->sfn , ppWritePackedMsg, end) && if (!(push16(pNfapiMsg->sfn, ppWritePackedMsg, end) && push16(pNfapiMsg->slot, ppWritePackedMsg, end)
push16(pNfapiMsg->slot , ppWritePackedMsg, end) && && push16(pNfapiMsg->number_crcs, ppWritePackedMsg, end)))
push16(pNfapiMsg->number_crcs, ppWritePackedMsg, end)
))
return 0; return 0;
for (int i = 0; i < pNfapiMsg->number_crcs; i++) for (int i = 0; i < pNfapiMsg->number_crcs; i++) {
{ if (!pack_nr_crc_indication_body(&pNfapiMsg->crc_list[i], ppWritePackedMsg, end))
if(!pack_nr_crc_indication_body(&pNfapiMsg->crc_list[i], ppWritePackedMsg, end))
return 0; return 0;
} }
...@@ -3366,19 +3360,17 @@ static uint8_t pack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t *value, ...@@ -3366,19 +3360,17 @@ static uint8_t pack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t *value,
return 1; return 1;
} }
static uint8_t pack_nr_srs_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) { uint8_t pack_nr_srs_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{
nfapi_nr_srs_indication_t *pNfapiMsg = (nfapi_nr_srs_indication_t*)msg; nfapi_nr_srs_indication_t *pNfapiMsg = (nfapi_nr_srs_indication_t *)msg;
if (!(push16(pNfapiMsg->sfn , ppWritePackedMsg, end) && if (!(push16(pNfapiMsg->sfn, ppWritePackedMsg, end) && push16(pNfapiMsg->slot, ppWritePackedMsg, end)
push16(pNfapiMsg->slot , ppWritePackedMsg, end) && && push16(pNfapiMsg->control_length, ppWritePackedMsg, end) && push8(pNfapiMsg->number_of_pdus, ppWritePackedMsg, end))) {
push16(pNfapiMsg->control_length , ppWritePackedMsg, end) &&
push8(pNfapiMsg->number_of_pdus, ppWritePackedMsg, end))) {
return 0; return 0;
} }
for(int i=0; i<pNfapiMsg->number_of_pdus;i++) { for (int i = 0; i < pNfapiMsg->number_of_pdus; i++) {
if(!pack_nr_srs_indication_body(&(pNfapiMsg->pdu_list[i]),ppWritePackedMsg, end)) { if (!pack_nr_srs_indication_body(&(pNfapiMsg->pdu_list[i]), ppWritePackedMsg, end)) {
return 0; return 0;
} }
} }
...@@ -3412,26 +3404,22 @@ static uint8_t pack_nr_rach_indication_body(void* tlv, uint8_t **ppWritePackedMs ...@@ -3412,26 +3404,22 @@ static uint8_t pack_nr_rach_indication_body(void* tlv, uint8_t **ppWritePackedMs
return 1; return 1;
} }
static uint8_t pack_nr_rach_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) uint8_t pack_nr_rach_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{ {
nfapi_nr_rach_indication_t *pNfapiMsg = (nfapi_nr_rach_indication_t*)msg; nfapi_nr_rach_indication_t *pNfapiMsg = (nfapi_nr_rach_indication_t *)msg;
if (!(push16(pNfapiMsg->sfn , ppWritePackedMsg, end) && if (!(push16(pNfapiMsg->sfn, ppWritePackedMsg, end) && push16(pNfapiMsg->slot, ppWritePackedMsg, end)
push16(pNfapiMsg->slot , ppWritePackedMsg, end) && && push8(pNfapiMsg->number_of_pdus, ppWritePackedMsg, end)))
push8(pNfapiMsg->number_of_pdus, ppWritePackedMsg, end)
))
return 0; return 0;
for(int i=0; i<pNfapiMsg->number_of_pdus;i++) for (int i = 0; i < pNfapiMsg->number_of_pdus; i++) {
{ if (!pack_nr_rach_indication_body(&(pNfapiMsg->pdu_list[i]), ppWritePackedMsg, end))
if(!pack_nr_rach_indication_body(&(pNfapiMsg->pdu_list[i]),ppWritePackedMsg,end))
return 0; return 0;
} }
return 1; return 1;
} }
//UCI INDICATION //UCI INDICATION
static uint8_t pack_nr_uci_pucch_0_1(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { static uint8_t pack_nr_uci_pucch_0_1(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
...@@ -3637,28 +3625,25 @@ static uint8_t pack_nr_uci_indication_body(nfapi_nr_uci_t* value, uint8_t **ppWr ...@@ -3637,28 +3625,25 @@ static uint8_t pack_nr_uci_indication_body(nfapi_nr_uci_t* value, uint8_t **ppWr
return 1; return 1;
} }
static uint8_t pack_nr_uci_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) uint8_t pack_nr_uci_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
{ {
nfapi_nr_uci_indication_t *pNfapiMsg = (nfapi_nr_uci_indication_t*)msg; nfapi_nr_uci_indication_t *pNfapiMsg = (nfapi_nr_uci_indication_t *)msg;
if (!push16(pNfapiMsg->sfn , ppWritePackedMsg, end)) if (!push16(pNfapiMsg->sfn, ppWritePackedMsg, end))
return 0; return 0;
if (!push16(pNfapiMsg->slot , ppWritePackedMsg, end)) if (!push16(pNfapiMsg->slot, ppWritePackedMsg, end))
return 0; return 0;
if (!push16(pNfapiMsg->num_ucis, ppWritePackedMsg, end)) if (!push16(pNfapiMsg->num_ucis, ppWritePackedMsg, end))
return 0; return 0;
for (int i = 0; i < pNfapiMsg->num_ucis; i++) for (int i = 0; i < pNfapiMsg->num_ucis; i++) {
{
if (!pack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppWritePackedMsg, end)) if (!pack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppWritePackedMsg, end))
return 0; return 0;
} }
return 1; return 1;
} }
// Main pack function - public // Main pack function - public
int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t *config) int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t *config)
...@@ -6061,16 +6046,17 @@ static uint8_t unpack_tx_request(uint8_t **ppReadPackedMsg, uint8_t *end, void * ...@@ -6061,16 +6046,17 @@ static uint8_t unpack_tx_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *
//SLOT INDICATION //SLOT INDICATION
static uint8_t unpack_nr_slot_indication(uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_nr_slot_indication_scf_t *msg, nfapi_p7_codec_config_t* config) uint8_t unpack_nr_slot_indication(uint8_t **ppReadPackedMsg,
uint8_t *end,
nfapi_nr_slot_indication_scf_t *msg,
nfapi_p7_codec_config_t *config)
{ {
nfapi_nr_slot_indication_scf_t *pNfapiMsg = (nfapi_nr_slot_indication_scf_t*)msg; nfapi_nr_slot_indication_scf_t *pNfapiMsg = (nfapi_nr_slot_indication_scf_t *)msg;
if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn , end) && if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn, end) && pull16(ppReadPackedMsg, &pNfapiMsg->slot, end)))
pull16(ppReadPackedMsg, &pNfapiMsg->slot , end)
))
return 0; return 0;
return 1; return 1;
} }
//RX DATA INDICATION //RX DATA INDICATION
...@@ -6121,7 +6107,7 @@ static uint8_t unpack_nr_rx_data_indication(uint8_t **ppReadPackedMsg, uint8_t * ...@@ -6121,7 +6107,7 @@ static uint8_t unpack_nr_rx_data_indication(uint8_t **ppReadPackedMsg, uint8_t *
//NR CRC INDICATION //NR CRC INDICATION
static uint8_t unpack_nr_crc_indication_body(nfapi_nr_crc_t *value, uint8_t **ppReadPackedMsg, uint8_t *end) uint8_t unpack_nr_crc_indication_body(nfapi_nr_crc_t *value, uint8_t **ppReadPackedMsg, uint8_t *end)
{ {
if (!(pull32(ppReadPackedMsg, &value->handle, end) && pull16(ppReadPackedMsg, &value->rnti, end) if (!(pull32(ppReadPackedMsg, &value->handle, end) && pull16(ppReadPackedMsg, &value->rnti, end)
&& pull8(ppReadPackedMsg, &value->harq_id, end) && pull8(ppReadPackedMsg, &value->tb_crc_status, end) && pull8(ppReadPackedMsg, &value->harq_id, end) && pull8(ppReadPackedMsg, &value->tb_crc_status, end)
...@@ -6147,24 +6133,23 @@ static uint8_t unpack_nr_crc_indication_body(nfapi_nr_crc_t *value, uint8_t **pp ...@@ -6147,24 +6133,23 @@ static uint8_t unpack_nr_crc_indication_body(nfapi_nr_crc_t *value, uint8_t **pp
return 1; return 1;
} }
static uint8_t unpack_nr_crc_indication(uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_nr_crc_indication_t *msg, nfapi_p7_codec_config_t* config) uint8_t unpack_nr_crc_indication(uint8_t **ppReadPackedMsg,
uint8_t *end,
nfapi_nr_crc_indication_t *msg,
nfapi_p7_codec_config_t *config)
{ {
nfapi_nr_crc_indication_t *pNfapiMsg = (nfapi_nr_crc_indication_t*)msg; nfapi_nr_crc_indication_t *pNfapiMsg = (nfapi_nr_crc_indication_t *)msg;
if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn , end) && if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn, end) && pull16(ppReadPackedMsg, &pNfapiMsg->slot, end)
pull16(ppReadPackedMsg, &pNfapiMsg->slot , end) && && pull16(ppReadPackedMsg, &pNfapiMsg->number_crcs, end)))
pull16(ppReadPackedMsg, &pNfapiMsg->number_crcs, end)
))
return 0; return 0;
if (pNfapiMsg->number_crcs > 0) if (pNfapiMsg->number_crcs > 0) {
{
pNfapiMsg->crc_list = nfapi_p7_allocate(sizeof(*pNfapiMsg->crc_list) * pNfapiMsg->number_crcs, config); pNfapiMsg->crc_list = nfapi_p7_allocate(sizeof(*pNfapiMsg->crc_list) * pNfapiMsg->number_crcs, config);
} }
for (int i = 0; i < pNfapiMsg->number_crcs; i++) for (int i = 0; i < pNfapiMsg->number_crcs; i++) {
{ if (!unpack_nr_crc_indication_body(&pNfapiMsg->crc_list[i], ppReadPackedMsg, end))
if(!unpack_nr_crc_indication_body(&pNfapiMsg->crc_list[i], ppReadPackedMsg, end))
return 0; return 0;
} }
...@@ -6276,16 +6261,17 @@ static uint8_t unpack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t *valu ...@@ -6276,16 +6261,17 @@ static uint8_t unpack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t *valu
return 1; return 1;
} }
static uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_nr_srs_indication_t *pNfapiMsg, nfapi_p7_codec_config_t* config) { uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg,
uint8_t *end,
if (!(pull16(ppReadPackedMsg,&pNfapiMsg->sfn, end) && nfapi_nr_srs_indication_t *pNfapiMsg,
pull16(ppReadPackedMsg,&pNfapiMsg->slot, end) && nfapi_p7_codec_config_t *config)
pull16(ppReadPackedMsg,&pNfapiMsg->control_length, end) && {
pull8(ppReadPackedMsg,&pNfapiMsg->number_of_pdus, end))) { if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn, end) && pull16(ppReadPackedMsg, &pNfapiMsg->slot, end)
&& pull16(ppReadPackedMsg, &pNfapiMsg->control_length, end) && pull8(ppReadPackedMsg, &pNfapiMsg->number_of_pdus, end))) {
return 0; return 0;
} }
for(int i=0; i<pNfapiMsg->number_of_pdus; i++) { for (int i = 0; i < pNfapiMsg->number_of_pdus; i++) {
if (!unpack_nr_srs_indication_body(&pNfapiMsg->pdu_list[i], ppReadPackedMsg, end)) { if (!unpack_nr_srs_indication_body(&pNfapiMsg->pdu_list[i], ppReadPackedMsg, end)) {
return 0; return 0;
} }
...@@ -6318,7 +6304,7 @@ static uint8_t unpack_nr_rach_indication_body(nfapi_nr_prach_indication_pdu_t *v ...@@ -6318,7 +6304,7 @@ static uint8_t unpack_nr_rach_indication_body(nfapi_nr_prach_indication_pdu_t *v
return 1; return 1;
} }
static uint8_t unpack_nr_rach_indication(uint8_t **ppReadPackedMsg, uint8_t unpack_nr_rach_indication(uint8_t **ppReadPackedMsg,
uint8_t *end, uint8_t *end,
nfapi_nr_rach_indication_t *msg, nfapi_nr_rach_indication_t *msg,
nfapi_p7_codec_config_t *config) nfapi_p7_codec_config_t *config)
...@@ -6609,7 +6595,7 @@ static uint8_t unpack_nr_uci_indication_body(nfapi_nr_uci_t *value, ...@@ -6609,7 +6595,7 @@ static uint8_t unpack_nr_uci_indication_body(nfapi_nr_uci_t *value,
return 1; return 1;
} }
static uint8_t unpack_nr_uci_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) uint8_t unpack_nr_uci_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config)
{ {
nfapi_nr_uci_indication_t *pNfapiMsg = (nfapi_nr_uci_indication_t *)msg; nfapi_nr_uci_indication_t *pNfapiMsg = (nfapi_nr_uci_indication_t *)msg;
......
...@@ -214,7 +214,7 @@ typedef struct nfapi_pnf_config ...@@ -214,7 +214,7 @@ typedef struct nfapi_pnf_config
* STOP.request. This can be done in the call back. * STOP.request. This can be done in the call back.
*/ */
int (*stop_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_stop_request_t* req); int (*stop_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_stop_request_t* req);
int (*nr_stop_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nr_stop_request_t* req); int (*nr_stop_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nr_stop_request_scf_t* req);
/*! A callback for the MEASUREMENT.request /*! A callback for the MEASUREMENT.request
* \param config A pointer to the pnf configuration * \param config A pointer to the pnf configuration
......
...@@ -937,38 +937,28 @@ void pnf_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) ...@@ -937,38 +937,28 @@ void pnf_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
} }
} }
void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) void pnf_nr_handle_stop_request(pnf_t* pnf, void* pRecvMsg, int recvMsgLen)
{ {
// ensure it's valid // ensure it's valid
if (pRecvMsg == NULL || pnf == NULL) if (pRecvMsg == NULL || pnf == NULL) {
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__);
} } else {
else nfapi_nr_stop_request_scf_t req;
{
nfapi_nr_stop_request_t req;
NFAPI_TRACE(NFAPI_TRACE_INFO, "STOP.request received\n"); NFAPI_TRACE(NFAPI_TRACE_INFO, "STOP.request received\n");
nfapi_pnf_config_t* config = &(pnf->_public); nfapi_pnf_config_t* config = &(pnf->_public);
// unpack the message // unpack the message
if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) {
{ if (config->state == NFAPI_PNF_RUNNING) {
if(config->state == NFAPI_PNF_RUNNING)
{
nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id);
if(phy) if (phy) {
{ if (phy->state != NFAPI_PNF_PHY_RUNNING) {
if(phy->state != NFAPI_PNF_PHY_RUNNING) if (config->nr_stop_req) {
{
if(config->nr_stop_req)
{
(config->nr_stop_req)(config, phy, &req); (config->nr_stop_req)(config, phy, &req);
} }
} } else {
else
{
nfapi_stop_response_t resp; nfapi_stop_response_t resp;
memset(&resp, 0, sizeof(resp)); memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE; resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE;
...@@ -976,9 +966,7 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) ...@@ -976,9 +966,7 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
resp.error_code = NFAPI_MSG_INVALID_STATE; resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_pnf_stop_resp(config, &resp); nfapi_pnf_stop_resp(config, &resp);
} }
} } else {
else
{
nfapi_stop_response_t resp; nfapi_stop_response_t resp;
memset(&resp, 0, sizeof(resp)); memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE; resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE;
...@@ -986,9 +974,7 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) ...@@ -986,9 +974,7 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
resp.error_code = NFAPI_MSG_INVALID_CONFIG; resp.error_code = NFAPI_MSG_INVALID_CONFIG;
nfapi_pnf_stop_resp(config, &resp); nfapi_pnf_stop_resp(config, &resp);
} }
} } else {
else
{
nfapi_stop_response_t resp; nfapi_stop_response_t resp;
memset(&resp, 0, sizeof(resp)); memset(&resp, 0, sizeof(resp));
resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE; resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_RESPONSE;
...@@ -996,15 +982,12 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) ...@@ -996,15 +982,12 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen)
resp.error_code = NFAPI_MSG_INVALID_STATE; resp.error_code = NFAPI_MSG_INVALID_STATE;
nfapi_pnf_stop_resp(config, &resp); nfapi_pnf_stop_resp(config, &resp);
} }
} } else {
else
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__);
} }
if(req.vendor_extension) if (req.vendor_extension)
pnf->_public.codec_config.deallocate(req.vendor_extension); pnf->_public.codec_config.deallocate(req.vendor_extension);
} }
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#ifdef ENABLE_AERIAL #ifdef ENABLE_AERIAL
#include "nfapi/oai_integration/aerial/fapi_nvIPC.h" #include "nfapi/oai_integration/aerial/fapi_nvIPC.h"
#include "nfapi/oai_integration/aerial/fapi_vnf_p5.h" #include "nfapi/oai_integration/aerial/fapi_vnf_p5.h"
#include "nr_fapi.h"
#endif #endif
#include "nfapi/oai_integration/vendor_ext.h" #include "nfapi/oai_integration/vendor_ext.h"
......
if (ENABLE_TESTS)
add_subdirectory(p5)
add_subdirectory(p7)
endif ()
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_test.h
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#ifndef OPENAIRINTERFACE_NR_FAPI_TEST_H
#define OPENAIRINTERFACE_NR_FAPI_TEST_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <sys/wait.h>
#include <unistd.h>
#ifndef _STANDALONE_TESTING_
#include "common/utils/LOG/log.h"
#endif
#include "nfapi_nr_interface.h"
#include "nfapi_nr_interface_scf.h"
#define FILL_TLV(TlV, TaG, VaL) \
do { \
TlV.tl.tag = TaG; \
TlV.value = VaL; \
} while (0)
uint8_t rand8()
{
return (rand() & 0xff);
}
uint16_t rand16()
{
return rand8() << 8 | rand8();
}
uint32_t rand24()
{
return rand16() << 8 | rand8();
}
uint32_t rand32()
{
return rand24() << 8 | rand8();
}
uint64_t rand64()
{
return (uint64_t)rand32() << 32 | rand32();
}
uint8_t rand8_range(uint8_t lower, uint8_t upper)
{
return (rand() % (upper - lower + 1)) + lower;
}
uint16_t rand16_range(uint16_t lower, uint16_t upper)
{
return (rand() % (upper - lower + 1)) + lower;
}
int main(int n, char *v[]);
static inline void fapi_test_init_seeded(time_t seed)
{
srand(seed);
printf("srand seed is %ld\n", seed);
logInit();
set_glog(OAILOG_DISABLE);
}
static inline void fapi_test_init()
{
fapi_test_init_seeded(time(NULL));
}
#endif // OPENAIRINTERFACE_NR_FAPI_TEST_H
set(Test_Labels fapi p5)
set(_fapi_p5_messages "param_request;param_response;config_request;config_response;start_request;start_response;stop_request;stop_indication;error_indication")
foreach (fapi_p5_message IN LISTS _fapi_p5_messages)
add_executable(nr_fapi_${fapi_p5_message}_test nr_fapi_${fapi_p5_message}_test.c)
target_link_libraries(nr_fapi_${fapi_p5_message}_test PUBLIC nr_fapi_p5)
target_link_libraries(nr_fapi_${fapi_p5_message}_test PRIVATE pthread UTIL ${T_LIB} minimal_lib)
add_dependencies(tests nr_fapi_${fapi_p5_message}_test)
add_test(nr_fapi_${fapi_p5_message}_test nr_fapi_${fapi_p5_message}_test)
set_tests_properties(nr_fapi_${fapi_p5_message}_test PROPERTIES LABELS "${Test_Labels}")
endforeach ()
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_config_request_test.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5_utils.h"
void fill_config_request_tlv(nfapi_nr_config_request_scf_t *nfapi_resp)
{
FILL_TLV(nfapi_resp->carrier_config.dl_bandwidth, NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_config.dl_frequency, NFAPI_NR_CONFIG_DL_FREQUENCY_TAG, rand32());
nfapi_resp->num_tlv++;
for (int i = 0; i < 5; ++i) {
FILL_TLV(nfapi_resp->carrier_config.dl_k0[i], NFAPI_NR_CONFIG_DL_K0_TAG, rand16());
}
// these 5 are 1 tlv
nfapi_resp->num_tlv++;
for (int i = 0; i < 5; ++i) {
FILL_TLV(nfapi_resp->carrier_config.dl_grid_size[i], NFAPI_NR_CONFIG_DL_GRID_SIZE_TAG, rand16());
}
// these 5 are 1 tlv
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_config.num_tx_ant, NFAPI_NR_CONFIG_NUM_TX_ANT_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_config.uplink_bandwidth, NFAPI_NR_CONFIG_UPLINK_BANDWIDTH_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_config.uplink_frequency, NFAPI_NR_CONFIG_UPLINK_FREQUENCY_TAG, rand16());
nfapi_resp->num_tlv++;
for (int i = 0; i < 5; ++i) {
FILL_TLV(nfapi_resp->carrier_config.ul_k0[i], NFAPI_NR_CONFIG_UL_K0_TAG, rand16());
}
// these 5 are 1 tlv
nfapi_resp->num_tlv++;
for (int i = 0; i < 5; ++i) {
FILL_TLV(nfapi_resp->carrier_config.ul_grid_size[i], NFAPI_NR_CONFIG_UL_GRID_SIZE_TAG, rand16());
}
// these 5 are 1 tlv
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_config.num_rx_ant, NFAPI_NR_CONFIG_NUM_RX_ANT_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_config.frequency_shift_7p5khz, NFAPI_NR_CONFIG_FREQUENCY_SHIFT_7P5KHZ_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->cell_config.phy_cell_id, NFAPI_NR_CONFIG_PHY_CELL_ID_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->cell_config.frame_duplex_type, NFAPI_NR_CONFIG_FRAME_DUPLEX_TYPE_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->ssb_config.ss_pbch_power, NFAPI_NR_CONFIG_SS_PBCH_POWER_TAG, (int32_t)rand32());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->ssb_config.bch_payload, NFAPI_NR_CONFIG_BCH_PAYLOAD_TAG, rand8());
nfapi_resp->num_tlv++;
// NOTE: MUST be between 0 & 4 ( inclusive ) , since this value is used as index to obtain slots per frame
FILL_TLV(nfapi_resp->ssb_config.scs_common, NFAPI_NR_CONFIG_SCS_COMMON_TAG, rand8_range(0, 4));
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->prach_config.prach_sequence_length, NFAPI_NR_CONFIG_PRACH_SEQUENCE_LENGTH_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->prach_config.prach_sub_c_spacing, NFAPI_NR_CONFIG_PRACH_SUB_C_SPACING_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->prach_config.restricted_set_config, NFAPI_NR_CONFIG_RESTRICTED_SET_CONFIG_TAG, rand8());
nfapi_resp->num_tlv++;
/*Number of RACH frequency domain
occasions. Corresponds to the
parameter 𝑀𝑀 in [38.211, sec 6.3.3.2]
which equals the higher layer
parameter msg1FDM
Value: 1,2,4,8*/
const uint8_t num_prach_fd_ocasions[] = {1, 2, 4, 8};
FILL_TLV(nfapi_resp->prach_config.num_prach_fd_occasions,
NFAPI_NR_CONFIG_NUM_PRACH_FD_OCCASIONS_TAG,
num_prach_fd_ocasions[rand8_range(0, sizeof(num_prach_fd_ocasions) - 1)]);
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->prach_config.prach_ConfigurationIndex, NFAPI_NR_CONFIG_PRACH_CONFIG_INDEX_TAG, rand8());
nfapi_resp->num_tlv++;
nfapi_resp->prach_config.num_prach_fd_occasions_list = (nfapi_nr_num_prach_fd_occasions_t *)malloc(
nfapi_resp->prach_config.num_prach_fd_occasions.value * sizeof(nfapi_nr_num_prach_fd_occasions_t));
for (int i = 0; i < nfapi_resp->prach_config.num_prach_fd_occasions.value; i++) {
nfapi_nr_num_prach_fd_occasions_t *prach_fd_occasion = &(nfapi_resp->prach_config.num_prach_fd_occasions_list[i]);
FILL_TLV(prach_fd_occasion->prach_root_sequence_index, NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(prach_fd_occasion->num_root_sequences, NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(prach_fd_occasion->k1, NFAPI_NR_CONFIG_K1_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(prach_fd_occasion->prach_zero_corr_conf, NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG, rand8());
nfapi_resp->num_tlv++;
// This doesn't make sense to be more than the total num_root_sequences
/* SCF 222.10.02 : Number of unused sequences available
for noise estimation per FD occasion. At
least one unused root sequence is
required per FD occasion. */
if (prach_fd_occasion->num_root_sequences.value != 0) {
FILL_TLV(prach_fd_occasion->num_unused_root_sequences,
NFAPI_NR_CONFIG_NUM_UNUSED_ROOT_SEQUENCES_TAG,
rand8_range(1, prach_fd_occasion->num_root_sequences.value));
} else {
FILL_TLV(prach_fd_occasion->num_unused_root_sequences, NFAPI_NR_CONFIG_NUM_UNUSED_ROOT_SEQUENCES_TAG, 1);
}
nfapi_resp->num_tlv++;
prach_fd_occasion->unused_root_sequences_list =
(nfapi_uint8_tlv_t *)malloc(prach_fd_occasion->num_unused_root_sequences.value * sizeof(nfapi_uint8_tlv_t));
for (int k = 0; k < prach_fd_occasion->num_unused_root_sequences.value; k++) {
FILL_TLV(prach_fd_occasion->unused_root_sequences_list[k], NFAPI_NR_CONFIG_UNUSED_ROOT_SEQUENCES_TAG, rand16());
nfapi_resp->num_tlv++;
}
}
FILL_TLV(nfapi_resp->prach_config.ssb_per_rach, NFAPI_NR_CONFIG_SSB_PER_RACH_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->prach_config.prach_multiple_carriers_in_a_band,
NFAPI_NR_CONFIG_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG,
rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->ssb_table.ssb_offset_point_a, NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->ssb_table.ssb_period, NFAPI_NR_CONFIG_SSB_PERIOD_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->ssb_table.ssb_subcarrier_offset, NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->ssb_table.MIB, NFAPI_NR_CONFIG_MIB_TAG, rand32());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->ssb_table.ssb_mask_list[0].ssb_mask, NFAPI_NR_CONFIG_SSB_MASK_TAG, rand32());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->ssb_table.ssb_mask_list[1].ssb_mask, NFAPI_NR_CONFIG_SSB_MASK_TAG, rand32());
nfapi_resp->num_tlv++;
for (int i = 0; i < 64; i++) {
FILL_TLV(nfapi_resp->ssb_table.ssb_beam_id_list[i].beam_id, NFAPI_NR_CONFIG_BEAM_ID_TAG, rand8());
nfapi_resp->num_tlv++;
}
FILL_TLV(nfapi_resp->tdd_table.tdd_period, NFAPI_NR_CONFIG_TDD_PERIOD_TAG, rand8());
nfapi_resp->num_tlv++;
const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160};
// Assuming always CP_Normal, because Cyclic prefix is not included in CONFIG.request 10.02, but is present in 10.04
uint8_t cyclicprefix = 1;
bool normal_CP = cyclicprefix ? false : true;
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
uint8_t number_of_symbols_per_slot = normal_CP ? 14 : 12;
nfapi_resp->tdd_table.max_tdd_periodicity_list = (nfapi_nr_max_tdd_periodicity_t *)malloc(
slotsperframe[nfapi_resp->ssb_config.scs_common.value] * sizeof(nfapi_nr_max_tdd_periodicity_t));
for (int i = 0; i < slotsperframe[nfapi_resp->ssb_config.scs_common.value]; i++) {
nfapi_resp->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list =
(nfapi_nr_max_num_of_symbol_per_slot_t *)malloc(number_of_symbols_per_slot * sizeof(nfapi_nr_max_num_of_symbol_per_slot_t));
}
for (int i = 0; i < slotsperframe[nfapi_resp->ssb_config.scs_common.value]; i++) { // TODO check right number of slots
for (int k = 0; k < number_of_symbols_per_slot; k++) { // TODO can change?
FILL_TLV(nfapi_resp->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list[k].slot_config,
NFAPI_NR_CONFIG_SLOT_CONFIG_TAG,
rand8());
nfapi_resp->num_tlv++;
}
}
FILL_TLV(nfapi_resp->measurement_config.rssi_measurement, NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG, rand8());
nfapi_resp->num_tlv++;
nfapi_resp->nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG;
for (int i = 0; i < NFAPI_IPV4_ADDRESS_LENGTH; ++i) {
nfapi_resp->nfapi_config.p7_vnf_address_ipv4.address[i] = rand8();
}
nfapi_resp->num_tlv++;
nfapi_resp->nfapi_config.p7_vnf_address_ipv6.tl.tag = NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG;
for (int i = 0; i < NFAPI_IPV6_ADDRESS_LENGTH; ++i) {
nfapi_resp->nfapi_config.p7_vnf_address_ipv6.address[i] = rand8();
}
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->nfapi_config.p7_vnf_port, NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->nfapi_config.timing_window, NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->nfapi_config.timing_info_mode, NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->nfapi_config.timing_info_period, NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, rand8());
nfapi_resp->num_tlv++;
}
void test_pack_unpack(nfapi_nr_config_request_scf_t *req)
{
uint8_t msg_buf[65535];
uint16_t msg_len = sizeof(*req);
// first test the packing procedure
int pack_result = fapi_nr_p5_message_pack(req, msg_len, msg_buf, sizeof(msg_buf), NULL);
// PARAM.request message body length is 0
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_p5_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_config_request_scf_t unpacked_req = {0};
int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL);
DevAssert(unpack_result >= 0);
DevAssert(eq_config_request(&unpacked_req, req));
free_config_request(&unpacked_req);
}
void test_copy(const nfapi_nr_config_request_scf_t *msg)
{
// Test copy function
nfapi_nr_config_request_scf_t copy = {0};
copy_config_request(msg, &copy);
DevAssert(eq_config_request(msg, &copy));
free_config_request(&copy);
}
int main(int n, char *v[])
{
fapi_test_init();
nfapi_nr_config_request_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST};
// Fill CONFIG.request TVLs
fill_config_request_tlv(&req);
// Perform tests
test_pack_unpack(&req);
test_copy(&req);
// All tests successful!
free_config_request(&req);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_config_response_test.c
* \brief Defines a unitary test for the FAPI CONFIG.response message ( 0x03 )
* The test consists of filling a message with randomized data, filling each lists as well with random TLVs
* After the message is created, is is packed into a byte buffer
* After packing, the header is unpacked to mimic SCTP PEEK and the values unpacked checked against the original message
* After the header is checked, the whole message is unpacked.
* The test ends by checking all of the unpacked message contents against the original message
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5_utils.h"
void fill_config_response_tlv_list(nfapi_nr_generic_tlv_scf_t *list, uint8_t size)
{
uint8_t const TLVtypes[] = {UINT_8, UINT_16, UINT_32, ARRAY_UINT_16};
for (int i = 0; i < size; ++i) {
nfapi_nr_generic_tlv_scf_t *element = &(list[i]);
element->tl.tag = rand16_range(NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG, NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG);
element->tl.length = TLVtypes[rand8_range(0, sizeof(TLVtypes) - 1)];
switch (element->tl.length) {
case UINT_8:
element->value.u8 = rand8();
break;
case UINT_16:
element->value.u16 = rand16();
break;
case UINT_32:
element->value.u32 = rand32();
break;
case ARRAY_UINT_16:
for (int j = 0; j < 5; ++j) {
element->value.array_u16[j] = rand16();
}
break;
default:
break;
}
}
}
void fill_config_response_tlv(nfapi_nr_config_response_scf_t *nfapi_resp)
{
nfapi_resp->error_code = rand8();
nfapi_resp->num_invalid_tlvs = rand8();
nfapi_resp->num_invalid_tlvs_configured_in_idle = rand8();
nfapi_resp->num_invalid_tlvs_configured_in_running = rand8();
nfapi_resp->num_missing_tlvs = rand8();
// Lists
nfapi_resp->invalid_tlvs_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(nfapi_resp->num_invalid_tlvs * sizeof(nfapi_nr_generic_tlv_scf_t));
nfapi_resp->invalid_tlvs_configured_in_idle_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(nfapi_resp->num_invalid_tlvs_configured_in_idle * sizeof(nfapi_nr_generic_tlv_scf_t));
nfapi_resp->invalid_tlvs_configured_in_running_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(nfapi_resp->num_invalid_tlvs_configured_in_running * sizeof(nfapi_nr_generic_tlv_scf_t));
nfapi_resp->missing_tlvs_list =
(nfapi_nr_generic_tlv_scf_t *)malloc(nfapi_resp->num_missing_tlvs * sizeof(nfapi_nr_generic_tlv_scf_t));
fill_config_response_tlv_list(nfapi_resp->invalid_tlvs_list, nfapi_resp->num_invalid_tlvs);
fill_config_response_tlv_list(nfapi_resp->invalid_tlvs_configured_in_idle_list, nfapi_resp->num_invalid_tlvs_configured_in_idle);
fill_config_response_tlv_list(nfapi_resp->invalid_tlvs_configured_in_running_list,
nfapi_resp->num_invalid_tlvs_configured_in_running);
fill_config_response_tlv_list(nfapi_resp->missing_tlvs_list, nfapi_resp->num_missing_tlvs);
}
void test_pack_unpack(nfapi_nr_config_response_scf_t *req)
{
uint8_t msg_buf[65535];
uint16_t msg_len = sizeof(*req);
// first test the packing procedure
int pack_result = fapi_nr_p5_message_pack(req, msg_len, msg_buf, sizeof(msg_buf), 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_p5_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_config_response_scf_t unpacked_req = {0};
int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), 0);
DevAssert(unpack_result >= 0);
DevAssert(eq_config_response(&unpacked_req, req));
free_config_response(&unpacked_req);
}
void test_copy(const nfapi_nr_config_response_scf_t *msg)
{
// Test copy function
nfapi_nr_config_response_scf_t copy = {0};
copy_config_response(msg, &copy);
DevAssert(eq_config_response(msg, &copy));
free_config_response(&copy);
}
int main(int n, char *v[])
{
fapi_test_init();
nfapi_nr_config_response_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE};
// Fill Config response TVLs
fill_config_response_tlv(&req);
// Perform tests
test_pack_unpack(&req);
test_copy(&req);
// All tests successful!
free_config_response(&req);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_error_indication_test.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5_utils.h"
void test_pack_unpack(nfapi_nr_error_indication_scf_t *req)
{
uint8_t msg_buf[65535];
uint16_t msg_len = sizeof(*req);
// first test the packing procedure
int pack_result = fapi_nr_p5_message_pack(req, msg_len, msg_buf, sizeof(msg_buf), 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_p5_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_error_indication_scf_t unpacked_req = {0};
int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL);
DevAssert(unpack_result >= 0);
DevAssert(eq_error_indication(&unpacked_req, req));
free_error_indication(&unpacked_req);
}
void test_copy(const nfapi_nr_error_indication_scf_t *msg)
{
// Test copy function
nfapi_nr_error_indication_scf_t copy = {0};
copy_error_indication(msg, &copy);
DevAssert(eq_error_indication(msg, &copy));
free_error_indication(&copy);
}
int main(int n, char *v[])
{
fapi_test_init();
nfapi_nr_error_indication_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION};
// Fill the message with randomized data
req.sfn = rand16_range(0, 1023);
req.slot = rand16_range(0, 159);
req.message_id = rand8_range(0x00, 0xFF);
req.error_code = rand8_range(0x00, 0x08);
// Perform tests
test_pack_unpack(&req);
test_copy(&req);
// All tests successful!
free_error_indication(&req);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_param_request_test.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5_utils.h"
void test_pack_unpack(nfapi_nr_param_request_scf_t *req)
{
uint8_t msg_buf[65535];
uint16_t msg_len = sizeof(*req);
// first test the packing procedure
int pack_result = fapi_nr_p5_message_pack(req, msg_len, msg_buf, sizeof(msg_buf), NULL);
// PARAM.request message body length is 0
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_p5_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_param_request_scf_t unpacked_req = {0};
int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL);
DevAssert(unpack_result >= 0);
DevAssert(eq_param_request(&unpacked_req, req));
free_param_request(&unpacked_req);
}
void test_copy(const nfapi_nr_param_request_scf_t *msg)
{
// Test copy function
nfapi_nr_param_request_scf_t copy = {0};
copy_param_request(msg, &copy);
DevAssert(eq_param_request(msg, &copy));
free_param_request(&copy);
}
int main(int n, char *v[])
{
fapi_test_init();
nfapi_nr_param_request_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST};
// Perform tests
test_pack_unpack(&req);
test_copy(&req);
// All tests successful!
free_param_request(&req);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_param_response_test.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5_utils.h"
void fill_param_response_tlv(nfapi_nr_param_response_scf_t *nfapi_resp)
{
nfapi_resp->error_code = rand8_range(NFAPI_MSG_OK, NFAPI_MSG_INVALID_STATE);
FILL_TLV(nfapi_resp->cell_param.release_capability, NFAPI_NR_PARAM_TLV_RELEASE_CAPABILITY_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->cell_param.phy_state, NFAPI_NR_PARAM_TLV_PHY_STATE_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->cell_param.skip_blank_dl_config, NFAPI_NR_PARAM_TLV_SKIP_BLANK_DL_CONFIG_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->cell_param.skip_blank_ul_config, NFAPI_NR_PARAM_TLV_SKIP_BLANK_UL_CONFIG_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->cell_param.num_config_tlvs_to_report,
NFAPI_NR_PARAM_TLV_NUM_CONFIG_TLVS_TO_REPORT_TAG,
rand16_range(0, NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG - NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG));
nfapi_resp->num_tlv++;
nfapi_resp->cell_param.config_tlvs_to_report_list =
calloc(nfapi_resp->cell_param.num_config_tlvs_to_report.value, sizeof(nfapi_uint8_tlv_t *));
for (int i = 0; i < nfapi_resp->cell_param.num_config_tlvs_to_report.value; ++i) {
FILL_TLV(nfapi_resp->cell_param.config_tlvs_to_report_list[i],
rand16_range(NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG, NFAPI_NR_CONFIG_RSSI_MEASUREMENT_TAG),
rand8_range(0, 5));
nfapi_resp->cell_param.config_tlvs_to_report_list[i].tl.length = 1;
}
FILL_TLV(nfapi_resp->carrier_param.cyclic_prefix, NFAPI_NR_PARAM_TLV_CYCLIC_PREFIX_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_param.supported_subcarrier_spacings_dl,
NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_DL_TAG,
rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_param.supported_bandwidth_dl, NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_DL_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_param.supported_subcarrier_spacings_ul,
NFAPI_NR_PARAM_TLV_SUPPORTED_SUBCARRIER_SPACINGS_UL_TAG,
rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->carrier_param.supported_bandwidth_ul, NFAPI_NR_PARAM_TLV_SUPPORTED_BANDWIDTH_UL_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdcch_param.cce_mapping_type, NFAPI_NR_PARAM_TLV_CCE_MAPPING_TYPE_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdcch_param.coreset_outside_first_3_of_ofdm_syms_of_slot,
NFAPI_NR_PARAM_TLV_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG,
rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdcch_param.coreset_precoder_granularity_coreset,
NFAPI_NR_PARAM_TLV_PRECODER_GRANULARITY_CORESET_TAG,
rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdcch_param.pdcch_mu_mimo, NFAPI_NR_PARAM_TLV_PDCCH_MU_MIMO_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdcch_param.pdcch_precoder_cycling, NFAPI_NR_PARAM_TLV_PDCCH_PRECODER_CYCLING_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdcch_param.max_pdcch_per_slot, NFAPI_NR_PARAM_TLV_MAX_PDCCHS_PER_SLOT_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pucch_param.pucch_formats, NFAPI_NR_PARAM_TLV_PUCCH_FORMATS_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pucch_param.max_pucchs_per_slot, NFAPI_NR_PARAM_TLV_MAX_PUCCHS_PER_SLOT_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.pdsch_mapping_type, NFAPI_NR_PARAM_TLV_PDSCH_MAPPING_TYPE_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.pdsch_allocation_types, NFAPI_NR_PARAM_TLV_PDSCH_ALLOCATION_TYPES_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.pdsch_vrb_to_prb_mapping, NFAPI_NR_PARAM_TLV_PDSCH_VRB_TO_PRB_MAPPING_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.pdsch_cbg, NFAPI_NR_PARAM_TLV_PDSCH_CBG_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.pdsch_dmrs_config_types, NFAPI_NR_PARAM_TLV_PDSCH_DMRS_CONFIG_TYPES_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.pdsch_dmrs_max_length, NFAPI_NR_PARAM_TLV_PDSCH_DMRS_MAX_LENGTH_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.pdsch_dmrs_additional_pos, NFAPI_NR_PARAM_TLV_PDSCH_DMRS_ADDITIONAL_POS_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.max_pdsch_tbs_per_slot, NFAPI_NR_PARAM_TLV_MAX_PDSCH_S_TBS_PER_SLOT_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.max_number_mimo_layers_pdsch, NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.supported_max_modulation_order_dl,
NFAPI_NR_PARAM_TLV_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG,
rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.max_mu_mimo_users_dl, NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_DL_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.pdsch_data_in_dmrs_symbols, NFAPI_NR_PARAM_TLV_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.premption_support, NFAPI_NR_PARAM_TLV_PREMPTION_SUPPORT_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pdsch_param.pdsch_non_slot_support, NFAPI_NR_PARAM_TLV_PDSCH_NON_SLOT_SUPPORT_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.uci_mux_ulsch_in_pusch, NFAPI_NR_PARAM_TLV_UCI_MUX_ULSCH_IN_PUSCH_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.uci_only_pusch, NFAPI_NR_PARAM_TLV_UCI_ONLY_PUSCH_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_frequency_hopping, NFAPI_NR_PARAM_TLV_PUSCH_FREQUENCY_HOPPING_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_dmrs_config_types, NFAPI_NR_PARAM_TLV_PUSCH_DMRS_CONFIG_TYPES_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_dmrs_max_len, NFAPI_NR_PARAM_TLV_PUSCH_DMRS_MAX_LEN_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_dmrs_additional_pos, NFAPI_NR_PARAM_TLV_PUSCH_DMRS_ADDITIONAL_POS_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_cbg, NFAPI_NR_PARAM_TLV_PUSCH_CBG_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_mapping_type, NFAPI_NR_PARAM_TLV_PUSCH_MAPPING_TYPE_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_allocation_types, NFAPI_NR_PARAM_TLV_PUSCH_ALLOCATION_TYPES_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_vrb_to_prb_mapping, NFAPI_NR_PARAM_TLV_PUSCH_VRB_TO_PRB_MAPPING_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_max_ptrs_ports, NFAPI_NR_PARAM_TLV_PUSCH_MAX_PTRS_PORTS_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.max_pduschs_tbs_per_slot, NFAPI_NR_PARAM_TLV_MAX_PDUSCHS_TBS_PER_SLOT_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.max_number_mimo_layers_non_cb_pusch,
NFAPI_NR_PARAM_TLV_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG,
rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.supported_modulation_order_ul, NFAPI_NR_PARAM_TLV_SUPPORTED_MODULATION_ORDER_UL_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.max_mu_mimo_users_ul, NFAPI_NR_PARAM_TLV_MAX_MU_MIMO_USERS_UL_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.dfts_ofdm_support, NFAPI_NR_PARAM_TLV_DFTS_OFDM_SUPPORT_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->pusch_param.pusch_aggregation_factor, NFAPI_NR_PARAM_TLV_PUSCH_AGGREGATION_FACTOR_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->prach_param.prach_long_formats, NFAPI_NR_PARAM_TLV_PRACH_LONG_FORMATS_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->prach_param.prach_short_formats, NFAPI_NR_PARAM_TLV_PRACH_SHORT_FORMATS_TAG, rand16());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->prach_param.prach_restricted_sets, NFAPI_NR_PARAM_TLV_PRACH_RESTRICTED_SETS_TAG, rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->prach_param.max_prach_fd_occasions_in_a_slot,
NFAPI_NR_PARAM_TLV_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG,
rand8());
nfapi_resp->num_tlv++;
FILL_TLV(nfapi_resp->measurement_param.rssi_measurement_support, NFAPI_NR_PARAM_TLV_RSSI_MEASUREMENT_SUPPORT_TAG, rand8());
nfapi_resp->num_tlv++;
}
void test_pack_unpack(nfapi_nr_param_response_scf_t *req)
{
uint8_t msg_buf[65535];
uint16_t msg_len = sizeof(*req);
// first test the packing procedure
int pack_result = fapi_nr_p5_message_pack(req, msg_len, msg_buf, sizeof(msg_buf), NULL);
// PARAM.response message body length is AT LEAST 10 (NFAPI_HEADER_LENGTH + 1 byte error_code + 1 byte num_tlv)
DevAssert(pack_result >= NFAPI_HEADER_LENGTH + 1 + 1);
// 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
nfapi_p4_p5_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_p5_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 unpaking and compare with initial message
nfapi_nr_param_response_scf_t unpacked_req = {0};
int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL);
DevAssert(unpack_result >= 0);
DevAssert(eq_param_response(&unpacked_req, req));
free_param_response(&unpacked_req);
}
void test_copy(const nfapi_nr_param_response_scf_t *msg)
{
// Test copy function
nfapi_nr_param_response_scf_t copy = {0};
copy_param_response(msg, &copy);
DevAssert(eq_param_response(msg, &copy));
free_param_response(&copy);
}
int main(int n, char *v[])
{
fapi_test_init();
nfapi_nr_param_response_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE};
// Fill Param response TVLs
fill_param_response_tlv(&req);
// Perform tests
test_pack_unpack(&req);
test_copy(&req);
// All tests successful!
free_param_response(&req);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_start_request_test.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5_utils.h"
void test_pack_unpack(nfapi_nr_start_request_scf_t *req)
{
uint8_t msg_buf[65535];
uint16_t msg_len = sizeof(*req);
// first test the packing procedure
int pack_result = fapi_nr_p5_message_pack(req, msg_len, msg_buf, sizeof(msg_buf), NULL);
// START.request message body length is 0
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_p5_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_start_request_scf_t unpacked_req = {0};
int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL);
DevAssert(unpack_result >= 0);
DevAssert(eq_start_request(&unpacked_req, req));
free_start_request(&unpacked_req);
}
void test_copy(const nfapi_nr_start_request_scf_t *msg)
{
// Test copy function
nfapi_nr_start_request_scf_t copy = {0};
copy_start_request(msg, &copy);
DevAssert(eq_start_request(msg, &copy));
free_start_request(&copy);
}
int main(int n, char *v[])
{
fapi_test_init();
nfapi_nr_start_request_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_START_REQUEST};
// Perform tests
test_pack_unpack(&req);
test_copy(&req);
// All tests successful!
free_start_request(&req);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_start_response_test.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5_utils.h"
void test_pack_unpack(nfapi_nr_start_response_scf_t *req)
{
uint8_t msg_buf[65535];
uint16_t msg_len = sizeof(req);
// first test the packing procedure
int pack_result = fapi_nr_p5_message_pack(req, msg_len, msg_buf, sizeof(msg_buf), NULL);
// START.response message body length is 1
DevAssert(pack_result == 1 + 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_p5_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_start_response_scf_t unpacked_req = {0};
int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL);
DevAssert(unpack_result >= 0);
DevAssert(eq_start_response(&unpacked_req, req));
free_start_response(&unpacked_req);
}
void test_copy(const nfapi_nr_start_response_scf_t *msg)
{
// Test copy function
nfapi_nr_start_response_scf_t copy = {0};
copy_start_response(msg, &copy);
DevAssert(eq_start_response(msg, &copy));
free_start_response(&copy);
}
int main(int n, char *v[])
{
fapi_test_init();
nfapi_nr_start_response_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE};
// Fill the message with randomized data
req.error_code = rand8_range(0x00, 0x01);
// Perform tests
test_pack_unpack(&req);
test_copy(&req);
// All tests successful!
free_start_response(&req);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_stop_indication_test.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5_utils.h"
void test_pack_unpack(nfapi_nr_stop_indication_scf_t *req)
{
uint8_t msg_buf[65535];
uint16_t msg_len = sizeof(*req);
// first test the packing procedure
int pack_result = fapi_nr_p5_message_pack(req, msg_len, msg_buf, sizeof(msg_buf), NULL);
// STOP.indication message body length is 0
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_p5_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_stop_indication_scf_t unpacked_req = {0};
int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL);
DevAssert(unpack_result >= 0);
DevAssert(eq_stop_indication(&unpacked_req, req));
free_stop_indication(&unpacked_req);
}
void test_copy(const nfapi_nr_stop_indication_scf_t *msg)
{
// Test copy function
nfapi_nr_stop_indication_scf_t copy = {0};
copy_stop_indication(msg, &copy);
DevAssert(eq_stop_indication(msg, &copy));
free_stop_indication(&copy);
}
int main(int n, char *v[])
{
fapi_test_init();
nfapi_nr_stop_indication_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION};
// Perform tests
test_pack_unpack(&req);
test_copy(&req);
// All tests successful!
free_stop_indication(&req);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_stop_request_test.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5_utils.h"
void test_pack_unpack(nfapi_nr_stop_request_scf_t *req)
{
uint8_t msg_buf[65535];
uint16_t msg_len = sizeof(*req);
// first test the packing procedure
int pack_result = fapi_nr_p5_message_pack(req, msg_len, msg_buf, sizeof(msg_buf), NULL);
// STOP.request message body length is 0
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_p5_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_stop_request_scf_t unpacked_req = {0};
int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL);
DevAssert(unpack_result >= 0);
DevAssert(eq_stop_request(&unpacked_req, req));
free_stop_request(&unpacked_req);
}
void test_copy(const nfapi_nr_stop_request_scf_t *msg)
{
// Test copy function
nfapi_nr_stop_request_scf_t copy = {0};
copy_stop_request(msg, &copy);
DevAssert(eq_stop_request(msg, &copy));
free_stop_request(&copy);
}
int main(int n, char *v[])
{
fapi_test_init();
nfapi_nr_stop_request_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST};
// Perform tests
test_pack_unpack(&req);
test_copy(&req);
// All tests successful!
free_stop_request(&req);
return 0;
}
set(Test_Labels fapi p7)
set(_fapi_p7_messages "dci_inversion")
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_p5)
target_link_libraries(nr_fapi_${fapi_p7_message}_test PRIVATE pthread UTIL ${T_LIB} minimal_lib)
add_dependencies(tests nr_fapi_${fapi_p7_message}_test)
add_test(nr_fapi_${fapi_p7_message}_test nr_fapi_${fapi_p7_message}_test)
set_tests_properties(nr_fapi_${fapi_p7_message}_test PROPERTIES LABELS "${Test_Labels}")
endforeach ()
# Add the dci label for the dci payload test
set(dci_labels dci ${Test_Labels})
set_tests_properties(nr_fapi_dci_inversion_test PROPERTIES LABELS "dci ${Test_Labels}")
# Add the FAPI_BYTE_ORDERING_BIG_ENDIAN preprocessor define in order to test the invert/uninvert dci payload functions
target_compile_definitions(nfapi_common PRIVATE FAPI_BYTE_ORDERING_BIG_ENDIAN)
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nfapi/tests/p5/nr_fapi_param_request_test.c
* \brief
* \author Ruben S. Silva
* \date 2024
* \version 0.1
* \company OpenAirInterface Software Alliance
* \email: contact@openairinterface.org, rsilva@allbesmart.pt
* \note
* \warning
*/
#include "nfapi/tests/nr_fapi_test.h"
#include "nr_fapi_p5.h"
#include "nr_fapi.h"
void printbits(uint64_t n, uint8_t numBytesToPrint)
{
uint64_t i;
uint8_t counter = 0;
if (numBytesToPrint == 0) {
i = 1UL << (sizeof(n) * 8 - 1);
} else {
i = 1UL << (numBytesToPrint * 8 - 1);
}
while (i > 0) {
if (n & i)
printf("1");
else
printf("0");
i >>= 1;
counter++;
if (counter % 8 == 0) {
printf(" ");
}
}
}
/*! \brief Drops unwanted bits from a byte array, leaving only a specified number of payload bits
*
* \param payloadSizeBits How many bits the payload is to have, from 1 to 64 (8 * DCI_PAYLOAD_BYTE_LEN)
* \param payload[] A uint8_t array containing the payload bytes with random data
* \details This function creates a bitmask of payloadSizeBits width to truncate the data in payload[] to only have the specified
* number of payload bits\n
* For example, a payload of 39 bits needs 5 bytes, but on the last byte, the last bit is unused, this function makes sure that
* last bit is set to 0, allowing the payload to be then packed and unpacked and successfully compared with the original payload
*/
void truncate_unwanted_bits(uint8_t payloadSizeBits, uint8_t payload[])
{
uint8_t payloadSizeBytes = (payloadSizeBits + 7) / 8;
printf("Original Value:\t");
uint64_t t = 0;
memcpy(&t, payload, payloadSizeBytes);
printbits(t, payloadSizeBytes);
printf("\n");
uint64_t bitmask = 1;
for (int i = 0; i < payloadSizeBits - 1; i++) {
bitmask = bitmask << 1 | 1;
}
printf("Calculated Bitmask:\t");
printbits(bitmask, payloadSizeBytes);
printf("\n");
t = t & bitmask;
printf("Truncated Value:\t");
printbits(t, payloadSizeBytes);
printf("\n");
memcpy(payload, &t, payloadSizeBytes);
}
/*! \brief Generates a random payload payloadSizeBits long into payload[]
*
* \param payloadSizeBits How many bits the payload is to have, from 1 to 64 (8 * DCI_PAYLOAD_BYTE_LEN)
* \param payload[] A uint8_t array to contain the generated payload
* \details This function fills a uint8_t array with payloadSizeBits of random data, by first filling however many bytes are needed
* to contain payloadSizeBits with random data, and then truncating the excess bits
*/
void generate_payload(uint8_t payloadSizeBits, uint8_t payload[])
{
for (int i = 0; i < (payloadSizeBits + 7) / 8; ++i) {
payload[i] = rand8();
}
truncate_unwanted_bits(payloadSizeBits, payload);
}
void test_pack_payload(uint8_t payloadSizeBits, uint8_t payload[])
{
uint8_t msg_buf[8192] = {0};
uint8_t payloadSizeBytes = (payloadSizeBits + 7) / 8;
uint8_t *pWritePackedMessage = msg_buf;
uint8_t *pPackMessageEnd = msg_buf + sizeof(msg_buf);
pack_dci_payload(payload, payloadSizeBits, &pWritePackedMessage, pPackMessageEnd);
uint8_t unpack_buf[payloadSizeBytes];
pWritePackedMessage = msg_buf;
unpack_dci_payload(unpack_buf, payloadSizeBits, &pWritePackedMessage, pPackMessageEnd);
printf("\nOriginal:\t");
for (int j = payloadSizeBytes - 1; j >= 0; j--) {
printbits(payload[j], 1);
printf(" ");
}
printf("\n");
printf("Unpacked:\t");
for (int j = payloadSizeBytes - 1; j >= 0; j--) {
printbits(unpack_buf[j], 1);
printf(" ");
}
printf("\n");
DevAssert(memcmp(payload, unpack_buf, payloadSizeBytes) == 0);
// All tests successful!
}
int main(int n, char *v[])
{
fapi_test_init();
uint8_t upper = 8 * DCI_PAYLOAD_BYTE_LEN;
uint8_t lower = 1;
uint8_t payloadSizeBits = (rand() % (upper - lower + 1)) + lower; // from 1 bit to DCI_PAYLOAD_BYTE_LEN, in bits
printf("payloadSizeBits:%d\n", payloadSizeBits);
uint8_t payload[(payloadSizeBits + 7) / 8];
generate_payload(payloadSizeBits, payload);
test_pack_payload(payloadSizeBits, payload);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment