Commit d6b8fe93 authored by Rúben Soares Silva's avatar Rúben Soares Silva Committed by Robert Schmidt

Provide peek_nr_nfapi_p7_sfn_slot() for fast msg dec

The next commits refactor the rx handling of messages in the PNF. To
efficiently handle them, provide a "peek()" function that gives us the
frame/slot for which a message is destined. This allows to decide if a
message is on time and select a destination buffer, before unpacking it
completely, avoiding copies.
parent 17e36029
...@@ -716,6 +716,7 @@ set(NFAPI_PNF_SRC ...@@ -716,6 +716,7 @@ set(NFAPI_PNF_SRC
) )
add_library(NFAPI_PNF_LIB ${NFAPI_PNF_SRC}) add_library(NFAPI_PNF_LIB ${NFAPI_PNF_SRC})
target_link_libraries(NFAPI_PNF_LIB PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) target_link_libraries(NFAPI_PNF_LIB PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
target_link_libraries(NFAPI_PNF_LIB PUBLIC nr_fapi_p7)
include_directories(${NFAPI_DIR}/pnf/public_inc) include_directories(${NFAPI_DIR}/pnf/public_inc)
include_directories(${NFAPI_DIR}/pnf/inc) include_directories(${NFAPI_DIR}/pnf/inc)
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#define _NFAPI_NR_INTERFACE_H_ #define _NFAPI_NR_INTERFACE_H_
#include "nfapi_common_interface.h" #include "nfapi_common_interface.h"
#include <stdbool.h>
#define NFAPI_NR_P5_HEADER_LENGTH 10 #define NFAPI_NR_P5_HEADER_LENGTH 10
#define NFAPI_NR_P7_HEADER_LENGTH 18 #define NFAPI_NR_P7_HEADER_LENGTH 18
...@@ -177,6 +179,18 @@ int nfapi_nr_p7_message_unpack(void *pMessageBuf, ...@@ -177,6 +179,18 @@ int nfapi_nr_p7_message_unpack(void *pMessageBuf,
uint32_t unpackedBufLen, uint32_t unpackedBufLen,
nfapi_p7_codec_config_t *config); nfapi_p7_codec_config_t *config);
/*! \brief Peeks the SFN and Slot of an (n)FAPI P7 message
* \param pMessageBuf A pointer to an encoded P7 message header
* \param messageBufLen The size of the encoded P7 message header
* \param SFN A pointer to store the peeked SFN
* \param Slot A pointer to store the peeked Slot
* \return true on success, false, otherwise.
*
* The function will decode the encoded SFN and Slot from an encoded P7 (n)FAPI message
*/
bool peek_nr_nfapi_p7_sfn_slot(void *pMessageBuf, uint32_t messageBufLen, uint16_t *SFN, uint16_t *Slot);
/*! \brief Calculates the checksum of a message /*! \brief Calculates the checksum of a message
* *
* \param buffer Pointer to the packed message * \param buffer Pointer to the packed message
......
...@@ -6202,6 +6202,18 @@ int nfapi_p7_message_unpack(void *pMessageBuf, ...@@ -6202,6 +6202,18 @@ int nfapi_p7_message_unpack(void *pMessageBuf,
return 0; return 0;
} }
bool peek_nr_nfapi_p7_sfn_slot(void *pMessageBuf, uint32_t messageBufLen, uint16_t *SFN, uint16_t *Slot)
{
uint8_t *pReadPackedMessage = &((uint8_t *)pMessageBuf)[NFAPI_NR_P7_HEADER_LENGTH];
uint8_t *end = (uint8_t*)pMessageBuf + messageBufLen;
if(!(pull16(&pReadPackedMessage, SFN, end) && pull16(&pReadPackedMessage, Slot, end))) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to peek SFN.Slot\n");
return false;
}
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "Peeked SFN.Slot is (%d.%d)\n", *SFN, *Slot);
return true;
}
int nfapi_nr_p7_message_unpack(void *pMessageBuf, int nfapi_nr_p7_message_unpack(void *pMessageBuf,
uint32_t messageBufLen, uint32_t messageBufLen,
void *pUnpackedBuf, void *pUnpackedBuf,
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <stdio.h> #include <stdio.h>
#include "pnf_p7.h" #include "pnf_p7.h"
#include "nr_fapi_p7_utils.h" // for 5G/NR message utils
#define FAPI2_IP_DSCP 0 #define FAPI2_IP_DSCP 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