Merge remote-tracking branch 'origin/nfapi-fixes' into integration_2025_w04 (!2999)
Repair nFAPI in 5G Add 5G nFAPI in OAI/Make it it work. Many commits in this branch are basically bug fixes of things that don't work properly, such as - check for correct conditions (e.g. instance numbers in the RAN context) - remove artificial limitation (e.g. only one PUCCH per TDD period in the PNF) - improve performance (reduce big mallocs, make some static buffers such as a global ring buffer for nFAPI messages in the PNF) - fix bugs in nFAPI (e.g., increase maximum message size to ~64kB instead of 1500 bytes, because the latter is way too small for many TX_data.requests in 5G, and it will delay message arrival unduly) - fix bugs in message enc/dec (e.g., handle FDD in config.request) - adjust the L1 such that the condition "we run monolithic" is not necessery (e.g., some message numbers in nFAPI struct where reset in MAC, instead of L1, and this breaks when running the PNF) There are instructions that explain how to set it up. Two CI tests have been added, one with COTS UE and MIMO in DL+UL in TDD numerology 1 (30kHz), and a second test with FDD mu=0 (15kHZ) in RFsimulator. These were some old to-dos that have been addressed. - test with COTS UE - 4x4 pipeline works good in DL, UL now also work - test in RFsim - make PNF status message - make FDD in u0 work
This commit is contained in:
@@ -66,7 +66,7 @@ void nfapi_trace(nfapi_trace_level_t level,
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
printf("%ld%06ld [%c] %10u: %s: ",
|
||||
printf("%ld.%06ld [%c] %10u: %s: ",
|
||||
ts.tv_sec,
|
||||
ts.tv_nsec / 1000,
|
||||
"XEWNID"[level], // NFAPI_TRACE_NONE, NFAPI_TRACE_ERROR, ...
|
||||
|
||||
@@ -714,16 +714,7 @@ uint8_t unpack_nr_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *
|
||||
{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),
|
||||
@@ -1017,22 +1008,24 @@ uint8_t pack_nr_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *e
|
||||
|
||||
// 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;
|
||||
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
|
||||
uint8_t number_of_symbols_per_slot = cyclicprefix ? 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++;
|
||||
if (pNfapiMsg->cell_config.frame_duplex_type.value == 1 /* TDD */) {
|
||||
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;
|
||||
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
|
||||
uint8_t number_of_symbols_per_slot = cyclicprefix ? 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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1232,27 +1225,28 @@ uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *
|
||||
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));
|
||||
pNfapiMsg->prach_config.num_prach_fd_occasions_list = calloc(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;
|
||||
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
|
||||
uint8_t number_of_symbols_per_slot = cyclicprefix ? 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));
|
||||
if (pNfapiMsg->cell_config.frame_duplex_type.value == 1 /* TDD */) {
|
||||
const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160};
|
||||
int n = slotsperframe[pNfapiMsg->ssb_config.scs_common.value];
|
||||
pNfapiMsg->tdd_table.max_tdd_periodicity_list = calloc(n, 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));
|
||||
for (int i = 0; i < n; i++) {
|
||||
pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list =
|
||||
calloc(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:
|
||||
|
||||
@@ -240,18 +240,20 @@ bool eq_config_request(const nfapi_nr_config_request_scf_t *unpacked_req, const
|
||||
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);
|
||||
if (req->cell_config.frame_duplex_type.value == 1 /* TDD */) {
|
||||
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;
|
||||
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
|
||||
uint8_t number_of_symbols_per_slot = cyclicprefix ? 14 : 12;
|
||||
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;
|
||||
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
|
||||
uint8_t number_of_symbols_per_slot = cyclicprefix ? 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -768,24 +770,26 @@ void copy_config_request(const nfapi_nr_config_request_scf_t *src, nfapi_nr_conf
|
||||
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);
|
||||
if (src->cell_config.frame_duplex_type.value == 1 /* TDD */) {
|
||||
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;
|
||||
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
|
||||
uint8_t number_of_symbols_per_slot = cyclicprefix ? 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));
|
||||
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;
|
||||
// 3GPP 38.211 Table 4.3.2.1 & Table 4.3.2.2
|
||||
uint8_t number_of_symbols_per_slot = cyclicprefix ? 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,16 +120,14 @@ typedef struct {
|
||||
#define NFAPI_TAG_LENGTH_PACKED_LEN 4
|
||||
|
||||
// Convenience methods to convert between SFN/SLOT formats
|
||||
#define NFAPI_SFNSLOT2DEC(_sfn,_slot) ( _sfn*20 + _slot ) // total count of slots
|
||||
#define NFAPI_SFNSLOTDEC2SFNSLOT(_sfnslot_dec) ((((_sfnslot_dec) / 20) << 6) | (((_sfnslot_dec) - (((_sfnslot_dec) / 20) * 20)) & 0x3F))
|
||||
#define NFAPI_SLOTNUM(_mu) (10 << (_mu))
|
||||
#define NFAPI_SLOTLEN(_mu) (1000.f / (1 << _mu))
|
||||
|
||||
#define NFAPI_SFNSLOT2SFN(_sfnslot) ((_sfnslot) >> 6)
|
||||
#define NFAPI_SFNSLOT2SLOT(_sfnslot) ((_sfnslot) & 0x3F)
|
||||
#define NFAPI_SFNSLOTDEC2SFN(_sfnslot_dec) ((_sfnslot_dec) / 20)
|
||||
#define NFAPI_SFNSLOTDEC2SLOT(_sfnslot_dec) ((_sfnslot_dec) % 20)
|
||||
#define NFAPI_SFNSLOT2HEX(_sfn,_slot) ((_sfn << 6) | (_slot & 0x3F))
|
||||
#define NFAPI_SFNSLOT2DEC(_mu, _sfn, _slot) ((_sfn) * NFAPI_SLOTNUM(_mu) + (_slot))
|
||||
#define NFAPI_SFNSLOTDEC2SFN(_mu, _sfnslot_dec) ((_sfnslot_dec) / NFAPI_SLOTNUM(_mu))
|
||||
#define NFAPI_SFNSLOTDEC2SLOT(_mu, _sfnslot_dec) ((_sfnslot_dec) % NFAPI_SLOTNUM(_mu))
|
||||
|
||||
#define NFAPI_MAX_SFNSLOTDEC 1024*20 // 20 is for numerology 1
|
||||
#define NFAPI_MAX_SFNSLOTDEC(_mu) (1024 * NFAPI_SLOTNUM(_mu))
|
||||
|
||||
// Convenience methods to convert between SFN/SFN formats
|
||||
#define NFAPI_SFNSF2DEC(_sfnsf) ((((_sfnsf) >> 4) * 10) + ((_sfnsf) & 0xF))
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -29,37 +29,32 @@
|
||||
|
||||
typedef struct {
|
||||
uint16_t dl_conf_ontime;
|
||||
uint16_t dl_tti_ontime;
|
||||
uint16_t dl_conf_late;
|
||||
uint16_t dl_tti_late;
|
||||
uint16_t ul_conf_ontime;
|
||||
uint16_t ul_tti_ontime;
|
||||
uint16_t ul_conf_late;
|
||||
uint16_t ul_tti_late;
|
||||
uint16_t hi_dci0_ontime;
|
||||
uint16_t hi_dci0_late;
|
||||
uint16_t ul_dci_ontime;
|
||||
uint16_t ul_dci_late;
|
||||
uint16_t tx_ontime;
|
||||
uint16_t tx_late;
|
||||
uint16_t tx_data_ontime;
|
||||
uint16_t tx_data_late;
|
||||
} pnf_p7_stats_t;
|
||||
|
||||
|
||||
typedef struct { // TODO: replace with the stats
|
||||
uint16_t dl_tti_ontime;
|
||||
uint16_t dl_tti_late;
|
||||
uint16_t ul_tti_ontime;
|
||||
uint16_t ul_tti_late;
|
||||
uint16_t ul_dci_ontime;
|
||||
uint16_t ul_dci_late;
|
||||
uint16_t tx_data_ontime;
|
||||
uint16_t tx_data_late;
|
||||
typedef struct pnf_p7_arr_time {
|
||||
uint16_t ontime;
|
||||
uint16_t late;
|
||||
} pnf_p7_arr_time_t;
|
||||
typedef struct pnf_p7_dir {
|
||||
uint32_t bytes;
|
||||
} pnf_p7_dir_t;
|
||||
typedef struct {
|
||||
pnf_p7_arr_time_t dl_tti;
|
||||
pnf_p7_arr_time_t ul_tti;
|
||||
pnf_p7_arr_time_t ul_dci;
|
||||
pnf_p7_arr_time_t tx_data;
|
||||
pnf_p7_dir_t dl;
|
||||
pnf_p7_dir_t ul;
|
||||
} pnf_p7_nr_stats_t;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t* buffer;
|
||||
uint16_t length;
|
||||
@@ -119,6 +114,7 @@ typedef struct {
|
||||
|
||||
uint16_t sfn;
|
||||
uint16_t slot;
|
||||
int mu;
|
||||
uint16_t sfn_slot;
|
||||
uint32_t slot_start_time_hr;
|
||||
int32_t slot_shift;
|
||||
|
||||
@@ -573,11 +573,10 @@ typedef struct
|
||||
//uint16_t sfn_slot
|
||||
uint16_t sfn;
|
||||
uint16_t slot;
|
||||
//TODO: Change P7 structs to NR
|
||||
nfapi_nr_dl_tti_request_t* dl_tti_req;//nfapi_dl_config_request_t* dl_config_req;
|
||||
nfapi_nr_ul_tti_request_t* ul_tti_req;//nfapi_ul_config_request_t* ul_config_req;
|
||||
nfapi_nr_ul_dci_request_t* ul_dci_req;//nfapi_hi_dci0_request_t* hi_dci0_req;
|
||||
nfapi_nr_tx_data_request_t* tx_data_req;//nfapi_tx_request_t* tx_req;
|
||||
nfapi_nr_dl_tti_request_t dl_tti_req;
|
||||
nfapi_nr_ul_tti_request_t ul_tti_req;
|
||||
nfapi_nr_ul_dci_request_t ul_dci_req;
|
||||
nfapi_nr_tx_data_request_t tx_data_req;
|
||||
|
||||
//TODO: check these two later
|
||||
//nfapi_lbt_dl_config_request_t* lbt_dl_config_req;
|
||||
|
||||
+271
-689
File diff suppressed because it is too large
Load Diff
@@ -21,14 +21,15 @@
|
||||
|
||||
nfapi_pnf_p7_config_t* nfapi_pnf_p7_config_create()
|
||||
{
|
||||
pnf_p7_t* _this = (pnf_p7_t*)calloc(1, sizeof(pnf_p7_t));
|
||||
pnf_p7_t* _this = NULL;
|
||||
int rc = posix_memalign((void**)&_this, 32, sizeof(pnf_p7_t));
|
||||
|
||||
if(_this == 0)
|
||||
return 0;
|
||||
if (_this == NULL || rc != 0)
|
||||
return 0;
|
||||
|
||||
|
||||
// set the default parameters
|
||||
_this->_public.segment_size = 1400;
|
||||
_this->_public.segment_size = 65000; // UDP max packet size is 65535
|
||||
_this->max_num_segments = 8;
|
||||
|
||||
_this->_public.subframe_buffer_size = 8;// TODO: Initialize the slot_buffer size
|
||||
@@ -271,7 +272,13 @@ int nfapi_pnf_p7_nr_rx_data_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rx_data_
|
||||
}
|
||||
|
||||
pnf_p7_t* _this = (pnf_p7_t*)(config);
|
||||
return pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_rx_data_indication_t));
|
||||
|
||||
int ret = pnf_nr_p7_pack_and_send_p7_message(_this, (nfapi_nr_p7_message_header_t*)ind, sizeof(nfapi_nr_rx_data_indication_t));
|
||||
if (ret == 0) {
|
||||
for (int i = 0; i < ind->number_of_pdus; ++i)
|
||||
_this->nr_stats.ul.bytes += ind->pdu_list[i].pdu_length;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int nfapi_pnf_p7_nr_crc_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_crc_indication_t* ind)
|
||||
|
||||
@@ -91,6 +91,8 @@ typedef struct nfapi_vnf_p7_connection_info {
|
||||
int sfn_sf;
|
||||
int sfn;
|
||||
int slot;
|
||||
int mu; // some 5G slot calculations need the numerology to know the number
|
||||
// of slots
|
||||
|
||||
int socket;
|
||||
struct sockaddr_in local_addr;
|
||||
|
||||
@@ -901,7 +901,6 @@ void nfapi_vnf_p7_config_destory(nfapi_vnf_p7_config_t* config);
|
||||
* This function is blocking and will not return until the nfapi_vnf_p7_stop
|
||||
* function is called.
|
||||
*/
|
||||
extern queue_t gnb_slot_ind_queue;
|
||||
int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config);
|
||||
int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config);
|
||||
|
||||
@@ -933,13 +932,14 @@ int nfapi_vnf_p7_release_pdu(nfapi_vnf_p7_config_t* config, void*);
|
||||
* \param pnf_p7_addr The udp address the pnf p7 entity has chosen
|
||||
* \param pnf_p7_port The udp port the pnf p7 entity has chosen
|
||||
* \param phy_id The unique phy id for the pnf p7 entity
|
||||
* \param mu The subcarrier spacing the PNF is operating with.
|
||||
* \return A status value. 0 equal success, -1 indicates failure
|
||||
*
|
||||
* This function should be used to each pnf p7 entity that is to be added to this
|
||||
* vnf p7 entity. Once added the vnf p7 entity will start establish sync with the
|
||||
* pnf p7 entity and that has been sucessfull will generate subframe indications for it
|
||||
*/
|
||||
int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr, int pnf_p7_port, int phy_id);
|
||||
int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr, int pnf_p7_port, int phy_id, int mu);
|
||||
|
||||
/*! Delete a vnf p7 instance to the vnf p7 module
|
||||
* \param config A pointer to the vnf p7 configuration
|
||||
|
||||
@@ -93,20 +93,14 @@ nfapi_vnf_pnf_info_t* nfapi_vnf_pnf_list_find(nfapi_vnf_config_t* config, int p5
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "config->pnf_list:%p\n", config->pnf_list);
|
||||
|
||||
nfapi_vnf_pnf_info_t* curr = config->pnf_list;
|
||||
while(curr != 0)
|
||||
{
|
||||
if(curr->p5_idx == p5_idx)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s : curr->p5_idx:%d p5_idx:%d\n", __FUNCTION__, curr->p5_idx, p5_idx);
|
||||
return curr;
|
||||
}
|
||||
while (curr != 0) {
|
||||
if (curr->p5_idx == p5_idx)
|
||||
return curr;
|
||||
curr = curr->next;
|
||||
}
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): could not find P5 connection for p5_idx %d\n", __func__, p5_idx);
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s : curr->next:%p\n", __FUNCTION__, curr->next);
|
||||
|
||||
curr = curr->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vnf_nr_handle_pnf_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
|
||||
@@ -129,7 +123,9 @@ void vnf_nr_handle_pnf_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_
|
||||
if(config->pnf_nr_param_resp)
|
||||
{
|
||||
(config->pnf_nr_param_resp)(config, p5_idx, &msg);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): no pnf_nr_param_resp cb installed\n", __func__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -162,7 +158,9 @@ void vnf_handle_pnf_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_con
|
||||
if(config->pnf_param_resp)
|
||||
{
|
||||
(config->pnf_param_resp)(config, p5_idx, &msg);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): no pnf_params_resp cb installed\n", __func__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -196,7 +194,9 @@ void vnf_nr_handle_pnf_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf
|
||||
if(config->pnf_nr_config_resp)
|
||||
{
|
||||
(config->pnf_nr_config_resp)(config, p5_idx, &msg);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): no pnf_nr_config_resp cb installed\n", __func__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -229,7 +229,9 @@ void vnf_handle_pnf_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_co
|
||||
if(config->pnf_config_resp)
|
||||
{
|
||||
(config->pnf_config_resp)(config, p5_idx, &msg);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): no pnf_config_resp cb installed\n", __func__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -261,7 +263,9 @@ void vnf_nr_handle_pnf_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_
|
||||
if(config->pnf_nr_start_resp)
|
||||
{
|
||||
(config->pnf_nr_start_resp)(config, p5_idx, &msg);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): no pnf_nr_start_resp cb installed\n", __func__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -293,7 +297,9 @@ void vnf_handle_pnf_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_con
|
||||
if(config->pnf_start_resp)
|
||||
{
|
||||
(config->pnf_start_resp)(config, p5_idx, &msg);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): no pnf_start_resp cb installed\n", __func__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -325,7 +331,9 @@ void vnf_handle_pnf_stop_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_conf
|
||||
if(config->pnf_stop_resp)
|
||||
{
|
||||
(config->pnf_stop_resp)(config, p5_idx, &msg);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): no pnf_stop_resp cb installed\n", __func__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -565,7 +573,9 @@ void vnf_handle_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_
|
||||
if(config->start_resp)
|
||||
{
|
||||
(config->start_resp)(config, p5_idx, &msg);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): no start_resp cb installed\n", __func__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -598,7 +608,9 @@ void vnf_nr_handle_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_conf
|
||||
if(config->nr_start_resp)
|
||||
{
|
||||
(config->nr_start_resp)(config, p5_idx, &msg);
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): no nr_start_resp cb installed\n", __func__);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -89,16 +89,14 @@ void vnf_p7_connection_info_list_add(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_i
|
||||
nfapi_vnf_p7_connection_info_t* vnf_p7_connection_info_list_find(vnf_p7_t* vnf_p7, uint16_t phy_id)
|
||||
{
|
||||
nfapi_vnf_p7_connection_info_t* curr = vnf_p7->p7_connections;
|
||||
while(curr != 0)
|
||||
{
|
||||
if(curr->phy_id == phy_id)
|
||||
{
|
||||
return curr;
|
||||
}
|
||||
curr = curr->next;
|
||||
}
|
||||
while (curr != 0) {
|
||||
if (curr->phy_id == phy_id)
|
||||
return curr;
|
||||
curr = curr->next;
|
||||
}
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(): could not find P7 connection for phy_id %d\n", __func__, phy_id);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
nfapi_vnf_p7_connection_info_t* vnf_p7_connection_info_list_delete(vnf_p7_t* vnf_p7, uint16_t phy_id)
|
||||
@@ -243,7 +241,7 @@ void vnf_p7_rx_reassembly_queue_remove_old_msgs(vnf_p7_t* vnf_p7, vnf_p7_rx_reas
|
||||
previous->next = iterator->next;
|
||||
}
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Deleting stale reassembly message (%u %u %d)\n", iterator->rx_hr_time, rx_hr_time, delta);
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Deleting stale reassembly message (packet rx_hr_time %u current rx_hr_time %u delta %d us)\n", iterator->rx_hr_time, rx_hr_time, delta);
|
||||
|
||||
vnf_p7_rx_message_t* to_delete = iterator;
|
||||
iterator = iterator->next;
|
||||
@@ -364,13 +362,13 @@ uint32_t calculate_t1(uint16_t sfn_sf, uint32_t sf_start_time_hr)
|
||||
return t1;
|
||||
}
|
||||
|
||||
uint32_t calculate_nr_t1(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
|
||||
uint32_t calculate_nr_t1(int mu, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
|
||||
{
|
||||
uint32_t now_time_hr = vnf_get_current_time_hr();
|
||||
|
||||
uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr);
|
||||
|
||||
uint32_t t1 = (NFAPI_SFNSLOT2DEC(sfn,slot) * 500) + slot_time_us;
|
||||
uint32_t t1 = NFAPI_SFNSLOT2DEC(mu, sfn,slot) * NFAPI_SLOTLEN(mu) + slot_time_us;
|
||||
|
||||
return t1;
|
||||
}
|
||||
@@ -386,24 +384,24 @@ uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_t
|
||||
|
||||
}
|
||||
|
||||
uint32_t calculate_nr_t4(uint32_t now_time_hr, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
|
||||
uint32_t calculate_nr_t4(uint32_t now_time_hr, int mu, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
|
||||
{
|
||||
uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr);
|
||||
|
||||
uint32_t t4 = (NFAPI_SFNSLOT2DEC(sfn,slot) * 500) + slot_time_us;
|
||||
uint32_t t4 = NFAPI_SFNSLOT2DEC(mu, sfn,slot) * NFAPI_SLOTLEN(mu) + slot_time_us;
|
||||
|
||||
return t4;
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint32_t calculate_transmit_timestamp(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
|
||||
uint32_t calculate_transmit_timestamp(int mu, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr)
|
||||
{
|
||||
uint32_t now_time_hr = vnf_get_current_time_hr();
|
||||
|
||||
uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr);
|
||||
|
||||
uint32_t tt = (NFAPI_SFNSLOT2DEC(sfn, slot) * 500) + slot_time_us;
|
||||
uint32_t tt = NFAPI_SFNSLOT2DEC(mu, sfn, slot) * NFAPI_SLOTLEN(mu) + slot_time_us;
|
||||
|
||||
return tt;
|
||||
}
|
||||
@@ -509,7 +507,7 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_nr_p7_message_header_
|
||||
int segment = 0;
|
||||
int offset = NFAPI_NR_P7_HEADER_LENGTH;
|
||||
uint8_t tx_buffer[vnf_p7->_public.segment_size];
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() MORE THAN ONE SEGMENT phy_id:%d nfapi_p7_message_pack()=len=%d vnf_p7->_public.segment_size:%u\n", __FUNCTION__, header->phy_id, len, vnf_p7->_public.segment_size);
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "%s() MORE THAN ONE SEGMENT phy_id:%d nfapi_p7_message_pack()=len=%d vnf_p7->_public.segment_size:%u\n", __FUNCTION__, header->phy_id, len, vnf_p7->_public.segment_size);
|
||||
for(segment = 0; segment < segment_count; ++segment)
|
||||
{
|
||||
uint8_t last = 0;
|
||||
@@ -540,7 +538,7 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_nr_p7_message_header_
|
||||
nfapi_nr_p7_update_checksum(tx_buffer, segment_size);
|
||||
}
|
||||
|
||||
nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->mu, p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
|
||||
send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &tx_buffer[0], segment_size);
|
||||
|
||||
@@ -553,7 +551,7 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_nr_p7_message_header_
|
||||
nfapi_nr_p7_update_checksum(buffer, len);
|
||||
}
|
||||
|
||||
nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->mu, p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
|
||||
// simple case that the message fits in a single segement
|
||||
send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &buffer[0], len);
|
||||
@@ -634,7 +632,7 @@ int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* hea
|
||||
nfapi_p7_update_checksum(tx_buffer, segment_size);
|
||||
}
|
||||
|
||||
nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->mu, p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
|
||||
send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &tx_buffer[0], segment_size);
|
||||
}
|
||||
@@ -646,7 +644,7 @@ int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* hea
|
||||
nfapi_p7_update_checksum(buffer, len);
|
||||
}
|
||||
|
||||
nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->mu, p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr));
|
||||
|
||||
// simple case that the message fits in a single segement
|
||||
send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &buffer[0], len);
|
||||
@@ -683,7 +681,7 @@ int vnf_nr_build_send_dl_node_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_inf
|
||||
dl_node_sync.header.phy_id = p7_info->phy_id;
|
||||
dl_node_sync.header.message_id = NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC;
|
||||
//dl_node_sync.t1 = calculate_t1(p7_info->sfn_sf, vnf_p7->sf_start_time_hr);
|
||||
dl_node_sync.t1 = calculate_nr_t1(p7_info->sfn,p7_info->slot, vnf_p7->slot_start_time_hr);
|
||||
dl_node_sync.t1 = calculate_nr_t1(p7_info->mu, p7_info->sfn,p7_info->slot, vnf_p7->slot_start_time_hr);
|
||||
dl_node_sync.delta_sfn_slot = 0;
|
||||
|
||||
return vnf_nr_p7_pack_and_send_p7_msg(vnf_p7, &dl_node_sync.header);
|
||||
@@ -695,11 +693,9 @@ int vnf_nr_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info)
|
||||
if(p7_info->in_sync == 1)
|
||||
{
|
||||
uint16_t dl_sync_period_mask = p7_info->dl_in_sync_period-1;
|
||||
// uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf);
|
||||
uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->sfn,p7_info->slot);
|
||||
uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->mu, p7_info->sfn,p7_info->slot);
|
||||
|
||||
//if ((((sfn_sf_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0)
|
||||
if ((((sfn_slot_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSLOTDEC) & dl_sync_period_mask) == 0)
|
||||
if ((((sfn_slot_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSLOTDEC(p7_info->mu)) & dl_sync_period_mask) == 0)
|
||||
{
|
||||
vnf_nr_build_send_dl_node_sync(vnf_p7, p7_info);
|
||||
}
|
||||
@@ -708,10 +704,9 @@ int vnf_nr_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info)
|
||||
{
|
||||
uint16_t dl_sync_period_mask = p7_info->dl_out_sync_period-1;
|
||||
//uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf);
|
||||
uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->sfn, p7_info->slot);
|
||||
uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->mu, p7_info->sfn, p7_info->slot);
|
||||
|
||||
//if ((((sfn_sf_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0)
|
||||
if ((((sfn_slot_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSLOTDEC) & dl_sync_period_mask) == 0)
|
||||
if ((((sfn_slot_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSLOTDEC(p7_info->mu)) & dl_sync_period_mask) == 0)
|
||||
{
|
||||
vnf_nr_build_send_dl_node_sync(vnf_p7, p7_info);
|
||||
}
|
||||
@@ -1499,7 +1494,7 @@ void vnf_handle_nr_slot_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf
|
||||
}
|
||||
else
|
||||
{
|
||||
nfapi_nr_slot_indication_scf_t ind;
|
||||
nfapi_nr_slot_indication_scf_t ind = {0};
|
||||
|
||||
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
@@ -1534,7 +1529,7 @@ void vnf_handle_nr_rx_data_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t*
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling RX Indication\n", __FUNCTION__);
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "%s: Handling RX Indication\n", __FUNCTION__);
|
||||
if(vnf_p7->_public.nr_rx_data_indication)
|
||||
{
|
||||
(vnf_p7->_public.nr_rx_data_indication)(&ind);
|
||||
@@ -1561,7 +1556,7 @@ void vnf_handle_nr_crc_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling CRC Indication\n", __FUNCTION__);
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "%s: Handling CRC Indication\n", __FUNCTION__);
|
||||
if(vnf_p7->_public.nr_crc_indication)
|
||||
{
|
||||
(vnf_p7->_public.nr_crc_indication)(&ind);
|
||||
@@ -1614,7 +1609,7 @@ void vnf_handle_nr_uci_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling UCI Indication\n", __FUNCTION__);
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "%s: Handling UCI Indication\n", __FUNCTION__);
|
||||
if(vnf_p7->_public.nr_uci_indication)
|
||||
{
|
||||
(vnf_p7->_public.nr_uci_indication)(&ind);
|
||||
@@ -1673,9 +1668,9 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Received UL_NODE_SYNC phy_id:%d t1:%d t2:%d t3:%d\n", ind.header.phy_id, ind.t1, ind.t2, ind.t3);
|
||||
|
||||
nfapi_vnf_p7_connection_info_t* phy = vnf_p7_connection_info_list_find(vnf_p7, ind.header.phy_id);
|
||||
uint32_t t4 = calculate_nr_t4(now_time_hr, phy->sfn, phy->slot, vnf_p7->slot_start_time_hr);
|
||||
uint32_t t4 = calculate_nr_t4(now_time_hr, phy->mu, phy->sfn, phy->slot, vnf_p7->slot_start_time_hr);
|
||||
|
||||
uint32_t tx_2_rx = t4>ind.t1 ? t4 - ind.t1 : t4 + NFAPI_MAX_SFNSLOTDEC - ind.t1 ; //time taken to receive ul node sync - time taken to send dl node sync
|
||||
uint32_t tx_2_rx = t4>ind.t1 ? t4 - ind.t1 : t4 + NFAPI_MAX_SFNSLOTDEC(phy->mu) - ind.t1 ; //time taken to receive ul node sync - time taken to send dl node sync
|
||||
uint32_t pnf_proc_time = ind.t3 - ind.t2;
|
||||
|
||||
// divide by 2 using shift operator
|
||||
@@ -1700,12 +1695,12 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
if (ind.t2 < phy->previous_t2 && ind.t1 > phy->previous_t1)
|
||||
{
|
||||
// Only t2 wrap has occurred!!!
|
||||
phy->slot_offset = (NFAPI_MAX_SFNSLOTDEC + ind.t2) - ind.t1 - latency;
|
||||
phy->slot_offset = (NFAPI_MAX_SFNSLOTDEC(phy->mu) + ind.t2) - ind.t1 - latency;
|
||||
}
|
||||
else if (ind.t2 > phy->previous_t2 && ind.t1 < phy->previous_t1)
|
||||
{
|
||||
// Only t1 wrap has occurred
|
||||
phy->slot_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSLOTDEC) - latency;
|
||||
phy->slot_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSLOTDEC(phy->mu)) - latency;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1757,7 +1752,7 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
{
|
||||
uint32_t curr_sfn = phy->sfn;
|
||||
uint32_t curr_slot = phy->slot;
|
||||
int32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(phy->sfn,phy->slot);
|
||||
int32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(phy->mu, phy->sfn,phy->slot);
|
||||
|
||||
if(!phy->filtered_adjust)
|
||||
{
|
||||
@@ -1774,7 +1769,7 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
|
||||
sfn_slot_dec += (phy->slot_offset / 500);
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF slot offset:%d sfn :%d slot:%d \n",phy->slot_offset,NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec),NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec) );
|
||||
NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF slot offset:%d sfn :%d slot:%d \n",phy->slot_offset,NFAPI_SFNSLOTDEC2SFN(phy->mu, sfn_slot_dec),NFAPI_SFNSLOTDEC2SLOT(phy->mu, sfn_slot_dec) );
|
||||
|
||||
|
||||
}
|
||||
@@ -1786,19 +1781,19 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
|
||||
if(sfn_slot_dec < 0)
|
||||
{
|
||||
sfn_slot_dec += NFAPI_MAX_SFNSLOTDEC;
|
||||
sfn_slot_dec += NFAPI_MAX_SFNSLOTDEC(phy->mu);
|
||||
}
|
||||
else if( sfn_slot_dec >= NFAPI_MAX_SFNSLOTDEC)
|
||||
else if( sfn_slot_dec >= NFAPI_MAX_SFNSLOTDEC(phy->mu))
|
||||
{
|
||||
sfn_slot_dec -= NFAPI_MAX_SFNSLOTDEC;
|
||||
sfn_slot_dec -= NFAPI_MAX_SFNSLOTDEC(phy->mu);
|
||||
}
|
||||
|
||||
|
||||
uint16_t new_sfn = NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec);
|
||||
uint16_t new_slot = NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec);
|
||||
uint16_t new_sfn = NFAPI_SFNSLOTDEC2SFN(phy->mu, sfn_slot_dec);
|
||||
uint16_t new_slot = NFAPI_SFNSLOTDEC2SLOT(phy->mu, sfn_slot_dec);
|
||||
|
||||
{
|
||||
phy->adjustment = NFAPI_SFNSLOT2DEC(new_sfn, new_slot) - NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot);
|
||||
phy->adjustment = NFAPI_SFNSLOT2DEC(phy->mu, new_sfn, new_slot) - NFAPI_SFNSLOT2DEC(phy->mu, curr_sfn, curr_slot);
|
||||
|
||||
//NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF phy_id:%d adjustment%d phy->previous_slot_offset_filtered:%d phy->previous_slot_offset_filtered:%d phy->slot_offset_trend:%d\n", ind.header.phy_id, phy->adjustment, phy->previous_slot_offset_filtered, phy->previous_slot_offset_filtered, phy->slot_offset_trend);
|
||||
|
||||
@@ -1906,15 +1901,24 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
|
||||
if(phy->insync_minor_adjustment != 0)
|
||||
{
|
||||
// NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (slot_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adjustment:%d\n",
|
||||
// phy->sfn, phy->slot, ind.header.phy_id,
|
||||
// phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration,
|
||||
// phy->slot_offset_filtered,
|
||||
// insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend,
|
||||
// NFAPI_SFNSLOT2DEC(new_sfn, new_slot),
|
||||
// NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot),
|
||||
// phy->adjustment);
|
||||
}
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG,
|
||||
"(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (slot_offset_filtered:%d) %d %d "
|
||||
"%d NEW:%d.%d CURR:%d.%d adjustment:%d\n",
|
||||
phy->sfn,
|
||||
phy->slot,
|
||||
ind.header.phy_id,
|
||||
phy->insync_minor_adjustment,
|
||||
phy->insync_minor_adjustment_duration,
|
||||
phy->slot_offset_filtered,
|
||||
insync_minor_adjustment_1,
|
||||
insync_minor_adjustment_2,
|
||||
phy->slot_offset_trend,
|
||||
new_sfn,
|
||||
new_slot,
|
||||
curr_sfn,
|
||||
curr_slot,
|
||||
phy->adjustment);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1948,16 +1952,27 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7
|
||||
{
|
||||
// out of sync?
|
||||
}
|
||||
|
||||
// NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (adjustment:%d slot_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adj:%d\n",
|
||||
// phy->sfn, phy->slot, ind.header.phy_id,
|
||||
// phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->slot_offset_filtered,
|
||||
// insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend,
|
||||
// NFAPI_SFNSLOT2DEC(new_sfn, new_slot),
|
||||
// NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot),
|
||||
// phy->adjustment);
|
||||
|
||||
}
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG,
|
||||
"(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (adjustment:%d "
|
||||
"slot_offset_filtered:%d) %d %d %d NEW:%d.%d CURR:%d.%d adj:%d\n",
|
||||
phy->sfn,
|
||||
phy->slot,
|
||||
ind.header.phy_id,
|
||||
phy->insync_minor_adjustment,
|
||||
phy->insync_minor_adjustment_duration,
|
||||
phy->adjustment,
|
||||
phy->slot_offset_filtered,
|
||||
insync_minor_adjustment_1,
|
||||
insync_minor_adjustment_2,
|
||||
phy->slot_offset_trend,
|
||||
new_sfn,
|
||||
new_slot,
|
||||
curr_sfn,
|
||||
curr_slot,
|
||||
phy->adjustment);
|
||||
|
||||
}
|
||||
else if(phy->adjustment < 0)
|
||||
{
|
||||
// VNF is fast
|
||||
@@ -2088,15 +2103,16 @@ void vnf_nr_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
if (vnf_p7 && vnf_p7->p7_connections)
|
||||
{
|
||||
//int16_t vnf_pnf_sfnsf_delta = NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf) - NFAPI_SFNSF2DEC(ind.last_sfn_sf);
|
||||
vnf_pnf_sfnslot_delta = NFAPI_SFNSLOT2DEC(vnf_p7->p7_connections[0].sfn,vnf_p7->p7_connections[0].slot) - NFAPI_SFNSLOT2DEC(ind.last_sfn,ind.last_slot);
|
||||
nfapi_vnf_p7_connection_info_t *p7_con = &vnf_p7->p7_connections[0];
|
||||
vnf_pnf_sfnslot_delta = NFAPI_SFNSLOT2DEC(p7_con->mu, p7_con->sfn,p7_con->slot) - NFAPI_SFNSLOT2DEC(p7_con->mu, ind.last_sfn,ind.last_slot);
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PNF:SFN/SF:%d VNF:SFN/SF:%d deltaSFNSF:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind.last_sfn_sf), NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), vnf_pnf_sfnsf_delta);
|
||||
|
||||
// Panos: Careful here!!! Modification of the original nfapi-code
|
||||
//if (vnf_pnf_sfnsf_delta>1 || vnf_pnf_sfnsf_delta < -1)
|
||||
//printf("VNF-PNF delta - %d", vnf_pnf_sfnslot_delta);
|
||||
if (vnf_pnf_sfnslot_delta != 0)
|
||||
if (vnf_pnf_sfnslot_delta > 1) // we need to have a small delta, otherwise it would mean we don't advance
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() LARGE SFN/SLOT DELTA between PNF and VNF. Delta %d. PNF:%d.%d VNF:%d.%d\n\n\n\n\n\n\n\n\n",
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "%s() LARGE SFN/SLOT DELTA between PNF and VNF. Delta %d slots. PNF:%d.%d VNF:%d.%d\n",
|
||||
__FUNCTION__, vnf_pnf_sfnslot_delta,
|
||||
ind.last_sfn, ind.last_slot,
|
||||
vnf_p7->p7_connections[0].sfn, vnf_p7->p7_connections[0].slot);
|
||||
@@ -2507,7 +2523,8 @@ void vnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7)
|
||||
vnf_p7_rx_reassembly_queue_remove_msg(vnf_p7, &(phy->reassembly_queue), rx_msg);
|
||||
}
|
||||
|
||||
vnf_p7_rx_reassembly_queue_remove_old_msgs(vnf_p7, &(phy->reassembly_queue), 1000);
|
||||
// see corresponding comment in pnf_nr_handle_p7_message() [same commit]
|
||||
vnf_p7_rx_reassembly_queue_remove_old_msgs(vnf_p7, &(phy->reassembly_queue), 10000);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ nfapi_vnf_p7_config_t* nfapi_vnf_p7_config_create()
|
||||
return 0;
|
||||
|
||||
// todo : initialize
|
||||
_this->_public.segment_size = 1400;
|
||||
_this->_public.segment_size = 65000; // UDP max packet size is 65535
|
||||
_this->_public.max_num_segments = 8;
|
||||
_this->_public.checksum_enabled = 1;
|
||||
|
||||
@@ -98,8 +98,6 @@ struct timespec timespec_sub(struct timespec lhs, struct timespec rhs)
|
||||
// send indications to mac
|
||||
int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config)
|
||||
{
|
||||
struct PHY_VARS_gNB_s *gNB = RC.gNB[0];
|
||||
uint8_t prev_slot = 0;
|
||||
if(config == 0)
|
||||
return -1;
|
||||
|
||||
@@ -157,7 +155,6 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config)
|
||||
|
||||
struct timespec ref_time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ref_time);
|
||||
uint8_t setup_done;
|
||||
while(vnf_p7->terminate == 0)
|
||||
{
|
||||
fd_set rfds;
|
||||
@@ -169,39 +166,6 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config)
|
||||
FD_SET(vnf_p7->socket, &rfds);
|
||||
maxSock = vnf_p7->socket;
|
||||
|
||||
if (setup_done == 0) {
|
||||
struct timespec curr_time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &curr_time);
|
||||
uint8_t setup_time = curr_time.tv_sec - ref_time.tv_sec;
|
||||
if (setup_time > 3) {
|
||||
setup_done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
nfapi_nr_slot_indication_scf_t *slot_ind = get_queue(&gnb_slot_ind_queue);
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "This is the slot_ind queue size %ld in %s():%d\n",
|
||||
gnb_slot_ind_queue.num_items, __FUNCTION__, __LINE__);
|
||||
if (slot_ind) {
|
||||
NR_UL_IND_t UL_INFO = {.frame = slot_ind->sfn, .slot = slot_ind->slot};
|
||||
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "UL_INFO.frame = %d and slot %d, prev_slot = %d\n", UL_INFO.frame, UL_INFO.slot, prev_slot);
|
||||
if (setup_done && prev_slot != UL_INFO.slot) { // Give the VNF sufficient time to setup before starting scheduling &&
|
||||
// prev_slot != UL_INFO.slot
|
||||
|
||||
// Call the scheduler
|
||||
UL_INFO.module_id = gNB->Mod_id;
|
||||
UL_INFO.CC_id = gNB->CC_id;
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG,
|
||||
"Calling NR_UL_indication for UL_INFO.frame = %d and slot %d\n",
|
||||
UL_INFO.frame,
|
||||
UL_INFO.slot);
|
||||
gNB->if_inst->NR_UL_indication(&UL_INFO);
|
||||
prev_slot = UL_INFO.slot;
|
||||
}
|
||||
free(slot_ind);
|
||||
slot_ind = NULL;
|
||||
}
|
||||
|
||||
selectRetval = pselect(maxSock+1, &rfds, NULL, NULL, &pselect_timeout, NULL);
|
||||
|
||||
if(selectRetval == 0)
|
||||
@@ -570,7 +534,7 @@ int nfapi_vnf_p7_stop(nfapi_vnf_p7_config_t* config)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr, int pnf_p7_port, int phy_id)
|
||||
int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr, int pnf_p7_port, int phy_id, int mu)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s(config:%p phy_id:%d pnf_addr:%s pnf_p7_port:%d)\n", __FUNCTION__, config, phy_id, pnf_p7_addr, pnf_p7_port);
|
||||
|
||||
@@ -594,6 +558,7 @@ int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr,
|
||||
node->sfn = 0;
|
||||
node->slot = 0;
|
||||
node->min_sync_cycle_count = 8;
|
||||
node->mu = mu;
|
||||
|
||||
// save the remote endpoint information
|
||||
node->remote_addr.sin_family = AF_INET;
|
||||
|
||||
@@ -769,7 +769,7 @@ int start_response(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_
|
||||
|
||||
vnf_test_config_vnf_t* vnf = &(vnf_test_config[0].vnfs[phy->vnf_idx]);
|
||||
|
||||
nfapi_vnf_p7_add_pnf(vnf->config, addr, port, response->header.phy_id);
|
||||
nfapi_vnf_p7_add_pnf(vnf->config, addr, port, response->header.phy_id, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user