From 7f7bda5421c8d2ce33aca359883dbcf4c9eb4f2d Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Fri, 19 Nov 2021 11:22:37 -0800 Subject: [PATCH] The number of active harqs is included in the UL_TTI_REQ Also, we had two heap-buffer-overflow crashes while filling the CRC_IND and RX_IND. The corrected CALLOC command is included in this commit as well. Lastly, we included a better fix for handling late DL_TTI_REQs. If the number of active harqs is larger than the number of UCIs we have built, this is a good indicator that the DL_TTI_REQ is late. To mitigate problems, we will requeue the UL_TTI_REQ to when the late DL_TTI_REQ comes in, we can handle the late UCI that is built from it. --- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 5 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 60 +++++++++++---------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index c2ae84963b..d3c8b43ddd 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -80,7 +80,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response rx_ind->sfn = scheduled_response->ul_config->sfn; rx_ind->slot = scheduled_response->ul_config->slot; rx_ind->number_of_pdus = scheduled_response->tx_request->number_of_pdus; - rx_ind->pdu_list = CALLOC(1, sizeof(*rx_ind->pdu_list)); + rx_ind->pdu_list = CALLOC(rx_ind->number_of_pdus, sizeof(*rx_ind->pdu_list)); for (int j = 0; j < rx_ind->number_of_pdus; j++) { fapi_nr_tx_request_body_t *tx_req_body = &scheduled_response->tx_request->tx_request_body[j]; @@ -102,7 +102,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response crc_ind->number_crcs = scheduled_response->ul_config->number_pdus; crc_ind->sfn = scheduled_response->ul_config->sfn; crc_ind->slot = scheduled_response->ul_config->slot; - crc_ind->crc_list = CALLOC(1, sizeof(*crc_ind->crc_list)); + crc_ind->crc_list = CALLOC(crc_ind->number_crcs, sizeof(*crc_ind->crc_list)); for (int j = 0; j < crc_ind->number_crcs; j++) { crc_ind->crc_list[j].handle = pusch_config_pdu->handle; @@ -204,6 +204,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response } } } + dl_config->number_pdus = 0; } } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index c3230ff37e..d07171c352 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -511,7 +511,7 @@ static void copy_uci_inds_to_single_uci_ind(NR_UE_MAC_INST_t *mac, } nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &new_uci->uci_list[index].pucch_pdu_format_0_1; memset(pdu_0_1, 0, sizeof(*pdu_0_1)); - AssertFatal(index <= new_uci->num_ucis, + AssertFatal(index <= new_uci->num_ucis || uci_from_queue->num_ucis == 1, "Attempting to index past end of uci_list array. Index = %d\n", index); new_uci->uci_list[index].pdu_type = uci_from_queue->uci_list[0].pdu_type; @@ -527,34 +527,19 @@ static void copy_uci_inds_to_single_uci_ind(NR_UE_MAC_INST_t *mac, return; } -nfapi_nr_uci_indication_t *multiplex_uci_ind(NR_UE_MAC_INST_t *mac) +static nfapi_nr_uci_indication_t *multiplex_uci_ind(NR_UE_MAC_INST_t *mac, int num_active_harqs) { - int num_active_harqs = 0; - for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) - { - int harq_slot = mac->dl_harq_info[i].dl_slot + mac->dl_harq_info[i].feedback_to_ul; - frame_t harq_sfn = mac->dl_harq_info[i].dl_frame; - int harq_sfn_slot = NFAPI_SFNSLOT2HEX(harq_sfn, harq_slot); - if (harq_sfn_slot == mac->nr_ue_emul_l1.active_harq_sfn_slot) - { - LOG_D(NR_MAC, "The sfn_slot stored in the current harq UE mac " - "instance matches the active_harq_sfn_slot we have." - " mac->harq_info[%d].sfn_slot = %d %d and active = %d %d\n", - i, harq_sfn, harq_slot, - NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot), - NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot)); - num_active_harqs++; - } - } nfapi_nr_uci_indication_t *uci_ind = MALLOC(sizeof(*uci_ind)); uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; uci_ind->sfn = NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot); uci_ind->slot = NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot); uci_ind->num_ucis = num_active_harqs; uci_ind->uci_list = MALLOC(uci_ind->num_ucis * sizeof(*uci_ind->uci_list)); - AssertFatal(num_active_harqs == nr_uci_ind_queue.num_items, - "The number of active harqs %d should match the number of UCIs in the queue %lu\n", - num_active_harqs, nr_uci_ind_queue.num_items); + if (num_active_harqs != nr_uci_ind_queue.num_items) + { + LOG_I(NR_MAC, "The number of active harqs %d doesn't match the number of UCIs in the queue %lu\n", + num_active_harqs, nr_uci_ind_queue.num_items); + } for (int j = 0; j < num_active_harqs; j++) { @@ -587,7 +572,11 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n { return; } - nfapi_nr_uci_indication_t *uci_ind = multiplex_uci_ind(mac); + + int num_active_harqs = pdu_list->pucch_pdu.bit_len_harq; + LOG_I(NR_MAC, "The number of active harqs %d from ul_tti_req\n", num_active_harqs); + nfapi_nr_uci_indication_t *uci_ind = multiplex_uci_ind(mac, num_active_harqs); + if (uci_ind && uci_ind->num_ucis > 0) { LOG_D(NR_MAC, "This is the SFN/SF [%d, %d] and RNTI %x of the UCI ind. ul_tti_req.pdu[%d]->rnti = %x \n", @@ -642,14 +631,27 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n pdu_0_1->harq = NULL; } } - free(uci_ind->uci_list); - uci_ind->uci_list = NULL; - free(uci_ind); - uci_ind = NULL; } - + LOG_D(NR_MAC, "The num_active_harqs %d and uci_ind->num_ucis %d\n", + num_active_harqs, uci_ind->num_ucis); + if (num_active_harqs > uci_ind->num_ucis) + { + LOG_E(NR_MAC, "The num_active_harqs %d > uci_ind->num_ucis %d" + "Which means that the incoming dl_tti_req to build the UCI is late. " + "So we will requeue the ul_tti_req to capture the upcoming UCI\n", + num_active_harqs, uci_ind->num_ucis); + if (!put_queue(&nr_ul_tti_req_queue, ul_tti_req)) + { + LOG_E(NR_PHY, "put_queue failed for ul_tti_req.\n"); + free(ul_tti_req); + ul_tti_req = NULL; + } + } + free(uci_ind->uci_list); + uci_ind->uci_list = NULL; + free(uci_ind); + uci_ind = NULL; } - } }