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.
This commit is contained in:
committed by
Robert Schmidt
parent
17e36029fa
commit
d6b8fe93ab
@@ -10,6 +10,8 @@
|
||||
#define _NFAPI_NR_INTERFACE_H_
|
||||
#include "nfapi_common_interface.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define NFAPI_NR_P5_HEADER_LENGTH 10
|
||||
#define NFAPI_NR_P7_HEADER_LENGTH 18
|
||||
|
||||
@@ -177,6 +179,18 @@ int nfapi_nr_p7_message_unpack(void *pMessageBuf,
|
||||
uint32_t unpackedBufLen,
|
||||
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
|
||||
*
|
||||
* \param buffer Pointer to the packed message
|
||||
|
||||
@@ -6202,6 +6202,18 @@ int nfapi_p7_message_unpack(void *pMessageBuf,
|
||||
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,
|
||||
uint32_t messageBufLen,
|
||||
void *pUnpackedBuf,
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pnf_p7.h"
|
||||
#include "nr_fapi_p7_utils.h" // for 5G/NR message utils
|
||||
|
||||
#define FAPI2_IP_DSCP 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user