diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 60cc6ef8aa..4e66322c41 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -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]; memcpy(dest_pdu, src_pdu, sizeof(*src_pdu)); - // DJP - TODO FIXME - intentional memory leak if(dest_pdu->rx_indication_rel8.length > 0){ - dest_pdu->data = malloc(dest_pdu->rx_indication_rel8.length); - memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length); - }else{ - dest_pdu->data = NULL; + assert(dest_pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX); + 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:%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 dest_pdu->rx_indication_rel8.offset, dest_pdu->rx_indication_rel8.ul_cqi, dest_pdu->rx_indication_rel8.timing_advance, - dest_pdu->data + dest_pdu->rx_ind_data ); } }else{ @@ -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 *src_pdu = &ind->rx_indication_body.rx_pdu_list[i]; memcpy(dest_pdu, src_pdu, sizeof(*src_pdu)); - // DJP - TODO FIXME - intentional memory leak - dest_pdu->data = malloc(dest_pdu->rx_indication_rel8.length); - memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length); + + assert(dest_pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX); + 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", __FUNCTION__, 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 dest_pdu->rx_indication_rel8.offset, dest_pdu->rx_indication_rel8.ul_cqi, dest_pdu->rx_indication_rel8.timing_advance, - dest_pdu->data + dest_pdu->rx_ind_data ); } } diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h index 96da8c9bc2..4dca519cf3 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h @@ -130,6 +130,7 @@ typedef struct { #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_MAX_SFNSLOTDEC 1024*20 // 20 is for numerology 1 @@ -708,7 +709,6 @@ typedef struct { #define NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG 0x0015 #define NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG 0x0016 - typedef struct { nfapi_uint16_tlv_t primary_synchronization_signal_epre_eprers; nfapi_uint16_tlv_t secondary_synchronization_signal_epre_eprers; @@ -2499,7 +2499,7 @@ typedef struct { typedef struct { nfapi_p7_message_header_t header; uint32_t t1; - int32_t delta_sfn_sf; + int32_t delta_sfn_sf; nfapi_vendor_extension_tlv_t vendor_extension; } nfapi_dl_node_sync_t; @@ -2874,11 +2874,12 @@ typedef struct { } nfapi_rx_indication_rel9_t; #define NFAPI_RX_INDICATION_REL9_TAG 0x2025 +#define NFAPI_RX_IND_DATA_MAX 8192 typedef struct { nfapi_rx_ue_information rx_ue_information; nfapi_rx_indication_rel8_t rx_indication_rel8; 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; #define NFAPI_RX_IND_MAX_PDU 100 diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c index 4189d0f687..24bc5add21 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c @@ -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; 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 +// Date: Wed Nov 11 15:10:32 2020 +0530 push8(pNfapiMsg->num_tlvs,ppWritePackedMsg,end) && 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 { 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 +// 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 +// 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) ); } diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c index e8d15730f2..336a4f4384 100755 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -2647,7 +2647,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP 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 1; @@ -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) { uint32_t length = pdu->rx_indication_rel8.length; - value->rx_pdu_list[i].data = nfapi_p7_allocate(length, config); - - if (pullarray8(ppReadPackedMsg, pdu->data, length, length, end) == 0) + if (pullarray8(ppReadPackedMsg, pdu->rx_ind_data, NFAPI_RX_IND_DATA_MAX, length, end) == 0) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s pullarray8 failure\n", __FUNCTION__); return 0; diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c index 58ed60121e..e367b8f537 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c @@ -827,7 +827,7 @@ void vnf_handle_rx_ulsch_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vn uint16_t i = 0; 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.vendor_extension); @@ -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); 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); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index eff7ccb282..addac15d47 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -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.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->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 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 diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index 5f7d8ebeb6..6a75f0f980 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -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_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].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.timing_advance, 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; } //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;jcrc_ind.crc_indication_body.number_of_crcs;j++) @@ -318,7 +314,7 @@ void handle_ulsch(UL_IND_t *UL_info) { NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, 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].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.timing_advance, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 48e302d335..bc875c6850 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -112,8 +112,8 @@ void fill_rx_indication_UE_MAC(module_id_t Mod_id, pdu->rx_indication_rel9.timing_advance_r9 = 0; // ulsch_buffer is necessary to keep its value. - pdu->data = malloc(buflen); - memcpy(pdu->data, ulsch_buffer, buflen); + assert(buflen <= NFAPI_RX_IND_DATA_MAX); + memcpy(pdu->rx_ind_data, ulsch_buffer, buflen); LOG_I(MAC, "buflen of rx_ind pdu_data = %u SFN.SF: %d.%d\n", buflen, frame, subframe); // estimate timing advance for MAC diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 0ae03ee537..faa2e72738 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -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); 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"); UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; }