Commit e5489659 authored by Michael Cook's avatar Michael Cook

Sync more NFAPI changes from multi-ue-proxy.git

Most notably, nfapi_rx_indication_pdu_t.data type is changed from
`uint8_t*` to `uint8_t[]`.  Also, renamed from `data` to
`rx_ind_data` to make it easier to find.
parent 9a0926bd
...@@ -839,12 +839,9 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t ...@@ -839,12 +839,9 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t
nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i]; nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i];
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu)); memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
// DJP - TODO FIXME - intentional memory leak
if(dest_pdu->rx_indication_rel8.length > 0){ if(dest_pdu->rx_indication_rel8.length > 0){
dest_pdu->data = malloc(dest_pdu->rx_indication_rel8.length); assert(dest_pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX);
memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length); memcpy(dest_pdu->rx_ind_data, src_pdu->rx_ind_data, dest_pdu->rx_indication_rel8.length);
}else{
dest_pdu->data = NULL;
} }
LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%zu [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n", LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%zu [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n",
...@@ -856,7 +853,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t ...@@ -856,7 +853,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t
dest_pdu->rx_indication_rel8.offset, dest_pdu->rx_indication_rel8.offset,
dest_pdu->rx_indication_rel8.ul_cqi, dest_pdu->rx_indication_rel8.ul_cqi,
dest_pdu->rx_indication_rel8.timing_advance, dest_pdu->rx_indication_rel8.timing_advance,
dest_pdu->data dest_pdu->rx_ind_data
); );
} }
}else{ }else{
...@@ -870,9 +867,10 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t ...@@ -870,9 +867,10 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t
nfapi_rx_indication_pdu_t *dest_pdu = &dest_ind->rx_indication_body.rx_pdu_list[i]; nfapi_rx_indication_pdu_t *dest_pdu = &dest_ind->rx_indication_body.rx_pdu_list[i];
nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i]; nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i];
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu)); memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
// DJP - TODO FIXME - intentional memory leak
dest_pdu->data = malloc(dest_pdu->rx_indication_rel8.length); assert(dest_pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX);
memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length); memcpy(dest_pdu->rx_ind_data, src_pdu->rx_ind_data, dest_pdu->rx_indication_rel8.length);
LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n", LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n",
__FUNCTION__, __FUNCTION__,
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i,
...@@ -882,7 +880,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t ...@@ -882,7 +880,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t
dest_pdu->rx_indication_rel8.offset, dest_pdu->rx_indication_rel8.offset,
dest_pdu->rx_indication_rel8.ul_cqi, dest_pdu->rx_indication_rel8.ul_cqi,
dest_pdu->rx_indication_rel8.timing_advance, dest_pdu->rx_indication_rel8.timing_advance,
dest_pdu->data dest_pdu->rx_ind_data
); );
} }
} }
......
...@@ -130,6 +130,7 @@ typedef struct { ...@@ -130,6 +130,7 @@ typedef struct {
#define NFAPI_SFNSLOT2SLOT(_sfnslot) ((_sfnslot) & 0x3F) #define NFAPI_SFNSLOT2SLOT(_sfnslot) ((_sfnslot) & 0x3F)
#define NFAPI_SFNSLOTDEC2SFN(_sfnslot_dec) ((_sfnslot_dec) / 20) #define NFAPI_SFNSLOTDEC2SFN(_sfnslot_dec) ((_sfnslot_dec) / 20)
#define NFAPI_SFNSLOTDEC2SLOT(_sfnslot_dec) ((_sfnslot_dec) % 20) #define NFAPI_SFNSLOTDEC2SLOT(_sfnslot_dec) ((_sfnslot_dec) % 20)
#define NFAPI_SFNSLOT2HEX(_sfn,_slot) ((_sfn << 6) | (_slot & 0x3F))
#define NFAPI_MAX_SFNSLOTDEC 1024*20 // 20 is for numerology 1 #define NFAPI_MAX_SFNSLOTDEC 1024*20 // 20 is for numerology 1
...@@ -708,7 +709,6 @@ typedef struct { ...@@ -708,7 +709,6 @@ typedef struct {
#define NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG 0x0015 #define NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG 0x0015
#define NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG 0x0016 #define NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG 0x0016
typedef struct { typedef struct {
nfapi_uint16_tlv_t primary_synchronization_signal_epre_eprers; nfapi_uint16_tlv_t primary_synchronization_signal_epre_eprers;
nfapi_uint16_tlv_t secondary_synchronization_signal_epre_eprers; nfapi_uint16_tlv_t secondary_synchronization_signal_epre_eprers;
...@@ -2874,11 +2874,12 @@ typedef struct { ...@@ -2874,11 +2874,12 @@ typedef struct {
} nfapi_rx_indication_rel9_t; } nfapi_rx_indication_rel9_t;
#define NFAPI_RX_INDICATION_REL9_TAG 0x2025 #define NFAPI_RX_INDICATION_REL9_TAG 0x2025
#define NFAPI_RX_IND_DATA_MAX 8192
typedef struct { typedef struct {
nfapi_rx_ue_information rx_ue_information; nfapi_rx_ue_information rx_ue_information;
nfapi_rx_indication_rel8_t rx_indication_rel8; nfapi_rx_indication_rel8_t rx_indication_rel8;
nfapi_rx_indication_rel9_t rx_indication_rel9; nfapi_rx_indication_rel9_t rx_indication_rel9;
uint8_t* data; uint8_t rx_ind_data[NFAPI_RX_IND_DATA_MAX];
} nfapi_rx_indication_pdu_t; } nfapi_rx_indication_pdu_t;
#define NFAPI_RX_IND_MAX_PDU 100 #define NFAPI_RX_IND_MAX_PDU 100
......
...@@ -300,6 +300,10 @@ static uint8_t pack_pnf_config_request(void *msg, uint8_t **ppWritePackedMsg, ui ...@@ -300,6 +300,10 @@ static uint8_t pack_pnf_config_request(void *msg, uint8_t **ppWritePackedMsg, ui
{ {
nfapi_pnf_config_request_t *pNfapiMsg = (nfapi_pnf_config_request_t*)msg; nfapi_pnf_config_request_t *pNfapiMsg = (nfapi_pnf_config_request_t*)msg;
return (pack_tlv(NFAPI_PNF_PHY_RF_TAG, &pNfapiMsg->pnf_phy_rf_config, ppWritePackedMsg, end, &pack_pnf_phy_rf_config_value) && return (pack_tlv(NFAPI_PNF_PHY_RF_TAG, &pNfapiMsg->pnf_phy_rf_config, ppWritePackedMsg, end, &pack_pnf_phy_rf_config_value) &&
// xxx - This next line (push8) was previously commented out and then was uncommented here:
// commit e6bf90e2ddc96a6c0af620c80acc3c286a8c81c7
// Author: Mahesh <maheshaithal@iisc.ac.in>
// Date: Wed Nov 11 15:10:32 2020 +0530
push8(pNfapiMsg->num_tlvs,ppWritePackedMsg,end) && push8(pNfapiMsg->num_tlvs,ppWritePackedMsg,end) &&
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end , config)); pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end , config));
} }
...@@ -909,7 +913,25 @@ static uint8_t pack_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8 ...@@ -909,7 +913,25 @@ static uint8_t pack_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8
{ {
nfapi_config_response_t *pNfapiMsg = (nfapi_config_response_t*)msg; nfapi_config_response_t *pNfapiMsg = (nfapi_config_response_t*)msg;
return ( push8(pNfapiMsg->error_code, ppWritePackedMsg, end) && // xxx - This function was added here:
// commit e6bf90e2ddc96a6c0af620c80acc3c286a8c81c7
// Author: Mahesh <maheshaithal@iisc.ac.in>
// Date: Wed Nov 11 15:10:32 2020 +0530
//
// The first expression was push8 in that commit.
// But unpack_config_response did pull32.
// So, the push8 seems to be wrong.
//
// In emane.git, this same function was added but with push32:
// commit 045261031bac557e4cf28c41afb09e9204d0ce22
// Author: RS <rsachdeva@episci.com>
// Date: Sat Feb 15 10:39:31 2020 -0800
//
// Adding open-nFAPI source code
//
// From: https://gitlab.eurecom.fr/oai/openairinterface5g/tree/master/nfapi/open-nFAPI
// Commit: 0f0b44373d1a5be572daa0dba261420a82fae9f7
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) );
} }
......
...@@ -2647,7 +2647,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP ...@@ -2647,7 +2647,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP
length = pdu->rx_indication_rel8.length; length = pdu->rx_indication_rel8.length;
} }
if( pusharray8(value->rx_pdu_list[i].data, length, length, ppWritePackedMsg, end) == 0) if( pusharray8(value->rx_pdu_list[i].rx_ind_data, NFAPI_RX_IND_DATA_MAX, length, ppWritePackedMsg, end) == 0)
return 0; return 0;
} }
return 1; return 1;
...@@ -7185,9 +7185,7 @@ static uint8_t unpack_rx_indication_body_value(void *tlv, uint8_t **ppReadPacked ...@@ -7185,9 +7185,7 @@ static uint8_t unpack_rx_indication_body_value(void *tlv, uint8_t **ppReadPacked
if (pdu->rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG) if (pdu->rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG)
{ {
uint32_t length = pdu->rx_indication_rel8.length; uint32_t length = pdu->rx_indication_rel8.length;
value->rx_pdu_list[i].data = nfapi_p7_allocate(length, config); if (pullarray8(ppReadPackedMsg, pdu->rx_ind_data, NFAPI_RX_IND_DATA_MAX, length, end) == 0)
if (pullarray8(ppReadPackedMsg, pdu->data, length, length, end) == 0)
{ {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s pullarray8 failure\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s pullarray8 failure\n", __FUNCTION__);
return 0; return 0;
......
...@@ -827,7 +827,7 @@ void vnf_handle_rx_ulsch_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vn ...@@ -827,7 +827,7 @@ void vnf_handle_rx_ulsch_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vn
uint16_t i = 0; uint16_t i = 0;
for(i = 0; i < ind.rx_indication_body.number_of_pdus; ++i) for(i = 0; i < ind.rx_indication_body.number_of_pdus; ++i)
{ {
vnf_p7_codec_free(vnf_p7, ind.rx_indication_body.rx_pdu_list[i].data); vnf_p7_codec_free(vnf_p7, ind.rx_indication_body.rx_pdu_list[i].rx_ind_data);
} }
vnf_p7_codec_free(vnf_p7, ind.rx_indication_body.rx_pdu_list); vnf_p7_codec_free(vnf_p7, ind.rx_indication_body.rx_pdu_list);
vnf_p7_codec_free(vnf_p7, ind.vendor_extension); vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
...@@ -2609,7 +2609,7 @@ void vnf_p7_release_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header) ...@@ -2609,7 +2609,7 @@ void vnf_p7_release_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header)
assert(number_of_pdus <= NFAPI_RX_IND_MAX_PDU); assert(number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
for(size_t i = 0; i < number_of_pdus; ++i) for(size_t i = 0; i < number_of_pdus; ++i)
{ {
vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list[i].data); vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list[i].rx_ind_data);
} }
vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list); vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list);
......
...@@ -1563,7 +1563,11 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, ...@@ -1563,7 +1563,11 @@ void fill_rx_indication(PHY_VARS_eNB *eNB,
pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG;
pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3; pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3;
pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation
pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->decodedBytes; assert(pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX);
memcpy(pdu->rx_ind_data,
eNB->ulsch[UE_id]->harq_processes[harq_pid]->decodedBytes,
pdu->rx_indication_rel8.length);
// estimate timing advance for MAC // estimate timing advance for MAC
sync_pos = lte_est_timing_advance_pusch(&eNB->frame_parms, eNB->pusch_vars[UE_id]->drs_ch_estimates_time); sync_pos = lte_est_timing_advance_pusch(&eNB->frame_parms, eNB->pusch_vars[UE_id]->drs_ch_estimates_time);
timing_advance_update = sync_pos; // - eNB->frame_parms.nb_prefix_samples/4; //to check timing_advance_update = sync_pos; // - eNB->frame_parms.nb_prefix_samples/4; //to check
......
...@@ -263,16 +263,12 @@ void handle_ulsch(UL_IND_t *UL_info) { ...@@ -263,16 +263,12 @@ void handle_ulsch(UL_IND_t *UL_info) {
NFAPI_SFNSF2SFN(UL_RCC_INFO.rx_ind[k].sfn_sf), //UL_info->frame, NFAPI_SFNSF2SFN(UL_RCC_INFO.rx_ind[k].sfn_sf), //UL_info->frame,
NFAPI_SFNSF2SF(UL_RCC_INFO.rx_ind[k].sfn_sf), //UL_info->subframe, NFAPI_SFNSF2SF(UL_RCC_INFO.rx_ind[k].sfn_sf), //UL_info->subframe,
UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].data, UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_ind_data,
UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
} }
if(UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].data != NULL) {
free(UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].data);
}
break; break;
} //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti == UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti) } //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti == UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti)
} // for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++) } // for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++)
...@@ -318,7 +314,7 @@ void handle_ulsch(UL_IND_t *UL_info) { ...@@ -318,7 +314,7 @@ void handle_ulsch(UL_IND_t *UL_info) {
NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe,
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ind_data,
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
......
...@@ -112,8 +112,8 @@ void fill_rx_indication_UE_MAC(module_id_t Mod_id, ...@@ -112,8 +112,8 @@ void fill_rx_indication_UE_MAC(module_id_t Mod_id,
pdu->rx_indication_rel9.timing_advance_r9 = 0; pdu->rx_indication_rel9.timing_advance_r9 = 0;
// ulsch_buffer is necessary to keep its value. // ulsch_buffer is necessary to keep its value.
pdu->data = malloc(buflen); assert(buflen <= NFAPI_RX_IND_DATA_MAX);
memcpy(pdu->data, ulsch_buffer, buflen); memcpy(pdu->rx_ind_data, ulsch_buffer, buflen);
LOG_I(MAC, "buflen of rx_ind pdu_data = %u SFN.SF: %d.%d\n", buflen, LOG_I(MAC, "buflen of rx_ind pdu_data = %u SFN.SF: %d.%d\n", buflen,
frame, subframe); frame, subframe);
// estimate timing advance for MAC // estimate timing advance for MAC
......
...@@ -1273,11 +1273,6 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) ...@@ -1273,11 +1273,6 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id); send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id);
sent_any = true; sent_any = true;
assert(UL_INFO->rx_ind.rx_indication_body.number_of_pdus <= NFAPI_RX_IND_MAX_PDU);
for (size_t num_pdu = 0; num_pdu < UL_INFO->rx_ind.rx_indication_body.number_of_pdus; num_pdu++) {
free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[num_pdu].data);
}
//LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n"); //LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n");
UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 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