Commit bfc41d10 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/Fix_Aerial_Memory_Leak' into integration_2024_w21c

parents 1127a985 dd931819
......@@ -116,15 +116,15 @@ static int ipc_handle_rx_msg(nv_ipc_t *ipc, nv_ipc_msg_t *msg)
// unpack FAPI messages and handle them
if (vnf_config != 0) {
// first, unpack the header
fapi_phy_api_msg *fapi_msg = calloc(1, sizeof(fapi_phy_api_msg));
if (!(pull8(&pReadPackedMessage, &fapi_msg->num_msg, end) && pull8(&pReadPackedMessage, &fapi_msg->opaque_handle, end)
&& pull16(&pReadPackedMessage, &fapi_msg->message_id, end)
&& pull32(&pReadPackedMessage, &fapi_msg->message_length, end))) {
fapi_phy_api_msg fapi_msg;
if (!(pull8(&pReadPackedMessage, &fapi_msg.num_msg, end) && pull8(&pReadPackedMessage, &fapi_msg.opaque_handle, end)
&& pull16(&pReadPackedMessage, &fapi_msg.message_id, end)
&& pull32(&pReadPackedMessage, &fapi_msg.message_length, end))) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "FAPI message header unpack failed\n");
return -1;
}
switch (fapi_msg->message_id) {
switch (fapi_msg.message_id) {
case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE:
if (vnf_config->nr_param_resp) {
......@@ -210,8 +210,8 @@ static int ipc_handle_rx_msg(nv_ipc_t *ipc, nv_ipc_msg_t *msg)
case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: {
nfapi_nr_rx_data_indication_t ind;
ind.header.message_id = fapi_msg->message_id;
ind.header.message_length = fapi_msg->message_length;
ind.header.message_id = fapi_msg.message_id;
ind.header.message_length = fapi_msg.message_length;
aerial_unpack_nr_rx_data_indication(
&pReadPackedMessage,
end,
......@@ -222,20 +222,25 @@ static int ipc_handle_rx_msg(nv_ipc_t *ipc, nv_ipc_msg_t *msg)
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling RX Indication\n", __FUNCTION__);
if (((vnf_info *)vnf_config->user_data)->p7_vnfs->config->nr_rx_data_indication) {
(((vnf_info *)vnf_config->user_data)->p7_vnfs->config->nr_rx_data_indication)(&ind);
for (int i = 0; i < ind.number_of_pdus; ++i) {
free(ind.pdu_list[i].pdu);
}
free(ind.pdu_list);
}
break;
}
case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: {
nfapi_nr_crc_indication_t crc_ind;
crc_ind.header.message_id = fapi_msg->message_id;
crc_ind.header.message_length = fapi_msg->message_length;
crc_ind.header.message_id = fapi_msg.message_id;
crc_ind.header.message_length = fapi_msg.message_length;
aerial_unpack_nr_crc_indication(&pReadPackedMessage,
end,
&crc_ind,
&((vnf_p7_t *)((vnf_info *)vnf_config->user_data)->p7_vnfs->config)->_public.codec_config);
if (((vnf_info *)vnf_config->user_data)->p7_vnfs->config->nr_crc_indication) {
(((vnf_info *)vnf_config->user_data)->p7_vnfs->config->nr_crc_indication)(&crc_ind);
free(crc_ind.crc_list);
}
break;
}
......@@ -249,6 +254,24 @@ static int ipc_handle_rx_msg(nv_ipc_t *ipc, nv_ipc_msg_t *msg)
if (((vnf_info *)vnf_config->user_data)->p7_vnfs->config->nr_uci_indication) {
(((vnf_info *)vnf_config->user_data)->p7_vnfs->config->nr_uci_indication)(&ind);
for (int i = 0; i < ind.num_ucis; i++) {
if (ind.uci_list[i].pdu_type == NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE) {
if (ind.uci_list[i].pucch_pdu_format_2_3_4.sr.sr_payload) {
free(ind.uci_list[i].pucch_pdu_format_2_3_4.sr.sr_payload);
}
if(ind.uci_list[i].pucch_pdu_format_2_3_4.harq.harq_payload){
free(ind.uci_list[i].pucch_pdu_format_2_3_4.harq.harq_payload);
}
if(ind.uci_list[i].pucch_pdu_format_2_3_4.csi_part1.csi_part1_payload){
free(ind.uci_list[i].pucch_pdu_format_2_3_4.csi_part1.csi_part1_payload);
}
if(ind.uci_list[i].pucch_pdu_format_2_3_4.csi_part2.csi_part2_payload){
free(ind.uci_list[i].pucch_pdu_format_2_3_4.csi_part2.csi_part2_payload);
}
}
}
free(ind.uci_list);
ind.uci_list = NULL;
}
break;
......@@ -274,12 +297,13 @@ static int ipc_handle_rx_msg(nv_ipc_t *ipc, nv_ipc_msg_t *msg)
&((vnf_p7_t *)((vnf_info *)vnf_config->user_data)->p7_vnfs->config)->_public.codec_config);
if (((vnf_info *)vnf_config->user_data)->p7_vnfs->config->nr_rach_indication) {
(((vnf_info *)vnf_config->user_data)->p7_vnfs->config->nr_rach_indication)(&ind);
free(ind.pdu_list);
}
break;
}
default: {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P5 Unknown message ID %d\n", __FUNCTION__, fapi_msg->message_id);
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P5 Unknown message ID %d\n", __FUNCTION__, fapi_msg.message_id);
break;
}
......
......@@ -351,12 +351,10 @@ int aerial_nr_send_config_request(nfapi_vnf_config_t *config, int p5_idx)
nfapi_p4_p5_message_header_t *msg = &req->header;
uint16_t msg_len = sizeof(nfapi_nr_config_request_scf_t);
nfapi_p4_p5_message_header_t *msgFAPI = calloc(1, msg_len);
memcpy(msgFAPI, &req->header, msg_len);
uint8_t tx_messagebufferFAPI[sizeof(_this->tx_message_buffer)];
int packedMessageLengthFAPI = -1;
packedMessageLengthFAPI =
fapi_nr_p5_message_pack(msgFAPI, msg_len, tx_messagebufferFAPI, sizeof(tx_messagebufferFAPI), &_this->_public.codec_config);
fapi_nr_p5_message_pack(msg, msg_len, tx_messagebufferFAPI, sizeof(tx_messagebufferFAPI), &_this->_public.codec_config);
aerial_send_P5_msg(tx_messagebufferFAPI, packedMessageLengthFAPI, msg);
......@@ -752,11 +750,8 @@ int oai_fapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req)
int oai_fapi_send_end_request(int cell, uint32_t frame, uint32_t slot){
nfapi_vnf_p7_config_t *p7_config = aerial_vnf.p7_vnfs[0].config;
nfapi_nr_slot_indication_scf_t *nr_slot_resp = CALLOC(1, sizeof(*nr_slot_resp));
nr_slot_resp->header.message_id = 0x8F;
nr_slot_resp->sfn = frame;
nr_slot_resp->slot = slot;
int retval = fapi_nr_pack_and_send_p7_message((vnf_p7_t *)p7_config, &nr_slot_resp->header);
nfapi_nr_slot_indication_scf_t nr_slot_resp = {.header.message_id = 0x8F, .sfn = frame, .slot = slot};
int retval = fapi_nr_pack_and_send_p7_message((vnf_p7_t *)p7_config, &nr_slot_resp.header);
if (retval != 0) {
LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval);
}
......
......@@ -358,7 +358,8 @@ int aerial_phy_nr_rx_data_indication(nfapi_nr_rx_data_indication_t *ind)
rx_ind->pdu_list[j].ul_cqi = ind->pdu_list[j].ul_cqi;
rx_ind->pdu_list[j].timing_advance = ind->pdu_list[j].timing_advance;
rx_ind->pdu_list[j].rssi = ind->pdu_list[j].rssi;
rx_ind->pdu_list[j].pdu = ind->pdu_list[j].pdu;
rx_ind->pdu_list[j].pdu = calloc(rx_ind->pdu_list[j].pdu_length, sizeof(uint8_t));
memcpy(rx_ind->pdu_list[j].pdu,ind->pdu_list[j].pdu,ind->pdu_list[j].pdu_length);
LOG_D(NR_MAC,
"(%d.%d) Handle %d for index %d, RNTI, %04x, HARQID %d\n",
ind->sfn,
......@@ -472,19 +473,22 @@ int aerial_phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind)
uci_ind_pdu->sr.sr_payload = CALLOC(1, sizeof(*uci_ind_pdu->sr.sr_payload));
AssertFatal(uci_ind_pdu->sr.sr_payload != NULL,
"Memory not allocated for uci_ind_pdu->sr.sr_payload in phy_nr_uci_indication.");
*uci_ind_pdu->sr.sr_payload = *ind_pdu->sr.sr_payload;
//SCF222.10.02 sr_bit_len values from 1 to 8, payload always just one byte
uci_ind_pdu->sr.sr_payload[0] = ind_pdu->sr.sr_payload[0];
}
if (ind_pdu->csi_part1.csi_part1_payload) {
uci_ind_pdu->csi_part1.csi_part1_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part1.csi_part1_payload));
uint8_t byte_len = (ind_pdu->csi_part1.csi_part1_bit_len / 8) + 1;
uci_ind_pdu->csi_part1.csi_part1_payload = calloc(byte_len, sizeof(uint8_t));
AssertFatal(uci_ind_pdu->csi_part1.csi_part1_payload != NULL,
"Memory not allocated for uci_ind_pdu->csi_part1.csi_part1_payload in phy_nr_uci_indication.");
*uci_ind_pdu->csi_part1.csi_part1_payload = *ind_pdu->csi_part1.csi_part1_payload;
memcpy(uci_ind_pdu->csi_part1.csi_part1_payload,ind_pdu->csi_part1.csi_part1_payload,byte_len);
}
if (ind_pdu->csi_part2.csi_part2_payload) {
uci_ind_pdu->csi_part2.csi_part2_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part2.csi_part2_payload));
uint8_t byte_len = (ind_pdu->csi_part2.csi_part2_bit_len / 8) + 1;
uci_ind_pdu->csi_part2.csi_part2_payload = calloc(byte_len, sizeof(uint8_t));
AssertFatal(uci_ind_pdu->csi_part2.csi_part2_payload != NULL,
"Memory not allocated for uci_ind_pdu->csi_part2.csi_part2_payload in phy_nr_uci_indication.");
*uci_ind_pdu->csi_part2.csi_part2_payload = *ind_pdu->csi_part2.csi_part2_payload;
memcpy(uci_ind_pdu->csi_part2.csi_part2_payload,ind_pdu->csi_part2.csi_part2_payload,byte_len);
}
break;
}
......@@ -920,8 +924,7 @@ static uint8_t aerial_unpack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t *
}
// Allocate space for the pdu to be unpacked later
uint32_t length = value->pdu_length;
value->pdu = nfapi_p7_allocate(sizeof(*value->pdu) * length, config);
value->pdu = nfapi_p7_allocate(sizeof(*value->pdu) * value->pdu_length, config);
return 1;
}
......
......@@ -1529,13 +1529,11 @@ int vnf_nr_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_mes
#ifdef ENABLE_AERIAL
// In case it is a FAPI message, create 2 messages, one with nFAPI header for OAI PNF and one with no nFAPI header for Aerial
// L1
nfapi_p4_p5_message_header_t *msgFAPI = calloc(1, msg_len);
memcpy(msgFAPI, msg, msg_len);
// create FAPI tx_buffer
uint8_t tx_messagebufferFAPI[sizeof(vnf->tx_message_buffer)];
int packedMessageLengthFAPI = -1;
packedMessageLengthFAPI =
fapi_nr_p5_message_pack(msgFAPI, msg_len, tx_messagebufferFAPI, sizeof(tx_messagebufferFAPI), &vnf->_public.codec_config);
fapi_nr_p5_message_pack(msg, msg_len, tx_messagebufferFAPI, sizeof(tx_messagebufferFAPI), &vnf->_public.codec_config);
return aerial_send_P5_msg(tx_messagebufferFAPI, packedMessageLengthFAPI, msg);
#else
return 0;
......
......@@ -267,6 +267,9 @@ static void free_unqueued_nfapi_indications(nfapi_nr_rach_indication_t *rach_ind
}
if (rx_ind && rx_ind->number_of_pdus > 0)
{
for (int i = 0; i < rx_ind->number_of_pdus; ++i) {
free_and_zero(rx_ind->pdu_list[i].pdu);
}
free_and_zero(rx_ind->pdu_list);
free_and_zero(rx_ind);
}
......
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