From 43d8ed216e71d3c600351cedc6cc009f06f0cc41 Mon Sep 17 00:00:00 2001 From: "Deokseong \"David\" Kim" Date: Wed, 25 Aug 2021 22:52:58 +0000 Subject: [PATCH] Update on scheduler to relax AssertFatal. --- executables/nr-ue.c | 16 ++++++++++++ openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 6 +++++ openair2/LAYER2/NR_MAC_UE/mac_defs.h | 2 ++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 4 +-- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 25 ++++++++++++++++--- openair2/RRC/NR_UE/rrc_UE.c | 2 +- 7 files changed, 50 insertions(+), 7 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index a475b81346..d6c8c65299 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -141,6 +141,9 @@ void init_nrUE_standalone_thread(int ue_idx) int standalone_rx_port = 3612 + ue_idx * 2; nrue_init_standalone_socket(standalone_addr, standalone_tx_port, standalone_rx_port); + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + pthread_mutex_init(&mac->mutex_dl_info, NULL); + pthread_t thread; if (pthread_create(&thread, NULL, nrue_standalone_pnf_task, NULL) != 0) { LOG_E(NR_MAC, "pthread_create failed for calling nrue_standalone_pnf_task"); @@ -179,7 +182,12 @@ static void L1_nsa_prach_procedures(frame_t frame, int slot, fapi_nr_ul_config_p if (!put_queue(&nr_rach_ind_queue, rach_ind)) { + for (int pdu_index = 0; pdu_index < rach_ind->number_of_pdus; pdu_index++) + { + free(rach_ind->pdu_list[pdu_index].preamble_list); + } free(rach_ind->pdu_list); + free(rach_ind); } LOG_I(NR_MAC, "Melissa, We have successfully filled the rach_ind queue with the recently filled rach ind\n"); } @@ -287,6 +295,8 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ul_info.frame_tx = (ul_info.slot_rx + slot_ahead >= slots_per_frame) ? ul_info.frame_rx + 1 : ul_info.frame_rx; ul_info.ue_sched_mode = SCHED_ALL; + if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); + memset(&mac->dl_info, 0, sizeof(mac->dl_info)); mac->dl_info.cc_id = CC_id; mac->dl_info.gNB_index = gNB_id; @@ -301,6 +311,9 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) { nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); } + + if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); + if (is_nr_UL_slot(mac->scc->tdd_UL_DL_ConfigurationCommon, ul_info.slot_tx, mac->frame_type)) { LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", ul_info.slot_tx, __FUNCTION__); @@ -350,6 +363,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) free(rach_ind->pdu_list[i].preamble_list); } free(rach_ind->pdu_list); + free(rach_ind); nr_Msg1_transmitted(mod_id, CC_id, frame, gNB_id); } if (rx_ind && rx_ind->number_of_pdus > 0) @@ -359,6 +373,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) }; send_nsa_standalone_msg(&UL_INFO, rx_ind->header.message_id); free(rx_ind->pdu_list); + free(rx_ind); } if (crc_ind && crc_ind->number_crcs > 0) { @@ -367,6 +382,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) }; send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id); free(crc_ind->crc_list); + free(crc_ind); } } return NULL; diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 2da8c6f201..cb3df9e325 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -197,6 +197,12 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response LOG_E(NR_MAC, "Put_queue failed for uci_ind\n"); //free(uci_ind->uci_list[0].pucch_pdu_format_0_1.harq->harq_list); //free(uci_ind->uci_list[0].pucch_pdu_format_0_1.harq); + for (int j = 0; j < uci_ind->num_ucis; j++) + { + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1; + free(pdu_0_1->harq->harq_list); + free(pdu_0_1->harq); + } free(uci_ind->uci_list); free(uci_ind); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index a62a6756c2..666950a0cf 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -425,6 +425,8 @@ typedef struct { nr_downlink_indication_t dl_info; NR_UE_HARQ_STATUS_t dl_harq_info[16]; + pthread_mutex_t mutex_dl_info; + } NR_UE_MAC_INST_t; typedef enum seach_space_mask_e { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 32a80f00ea..ed4530b34b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1521,7 +1521,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra LOG_D(NR_MAC,"numDlDci: %i\n", pdcch_pdu_rel15->numDlDci); ra->state = WAIT_Msg4_ACK; - LOG_I(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); + LOG_I(NR_MAC,"[gNB %d][RAPROC] Frame %d, Slot %d: RA state %d\n", module_idP, frameP, slotP, ra->state); } } diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index a7b153400a..b10dae6e87 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -300,7 +300,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { NR_Sched_Rsp_t *sched_info = &NR_Sched_INFO[module_id][CC_id]; NR_IF_Module_t *ifi = nr_if_inst[module_id]; gNB_MAC_INST *mac = RC.nrmac[module_id]; - LOG_D(PHY,"SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rach_pdus:%d rx_ind:%d crcs:%d]\n", + LOG_D(NR_PHY,"SFN/SLOT:%d.%d module_id:%d CC_id:%d UL_info[rach_pdus:%d rx_ind:%d crcs:%d]\n", UL_info->frame,UL_info->slot, module_id,CC_id, UL_info->rach_ind.number_of_pdus, UL_info->rx_ind.number_of_pdus, UL_info->crc_ind.number_crcs); @@ -360,7 +360,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { ifi->NR_Schedule_response(sched_info); } - LOG_D(PHY,"NR_Schedule_response: SFN SLOT:%d %d dl_pdus:%d\n", + LOG_D(NR_PHY,"NR_Schedule_response: SFN SLOT:%d %d dl_pdus:%d\n", sched_info->frame, sched_info->slot, sched_info->DL_req->dl_tti_request_body.nPDUs); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 2ca9423c43..0f98ecbbd5 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -274,6 +274,7 @@ static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi } dl_info->rx_ind = CALLOC(1, sizeof(fapi_nr_rx_indication_t)); + AssertFatal(dl_info->rx_ind != NULL, "%s: Out of memory in calloc", __FUNCTION__); dl_info->rx_ind->sfn = tx_data_request->SFN; dl_info->rx_ind->slot = tx_data_request->Slot; dl_info->rx_ind->number_pdus = num_pdus; @@ -290,6 +291,7 @@ static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi LOG_I(NR_PHY, "%s: num_tlv %d and length %d, pdu index %d\n", __FUNCTION__, pdu_list->num_TLV, length, i); uint8_t *pdu = malloc(length); + AssertFatal(pdu != NULL, "%s: Out of memory in malloc", __FUNCTION__); dl_info->rx_ind->rx_indication_body[i].pdsch_pdu.pdu = pdu; for (int j = 0; j < pdu_list->num_TLV; j++) { @@ -332,6 +334,7 @@ static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n if (num_dci > 0) { dl_info->dci_ind = CALLOC(1, sizeof(fapi_nr_dci_indication_t)); + AssertFatal(dl_info->dci_ind != NULL, "%s: Out of memory in calloc", __FUNCTION__); dl_info->dci_ind->number_of_dcis = num_dci; dl_info->dci_ind->SFN = ul_dci_req->SFN; dl_info->dci_ind->slot = ul_dci_req->Slot; @@ -396,6 +399,12 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n }; send_nsa_standalone_msg(&UL_INFO, uci_ind->header.message_id); } + for (int j = 0; j < uci_ind->num_ucis; j++) + { + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1; + free(pdu_0_1->harq->harq_list); + free(pdu_0_1->harq); + } free(uci_ind->uci_list); free(uci_ind); } @@ -466,6 +475,8 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, return; } + if (pthread_mutex_lock(&mac->mutex_dl_info)) abort(); + if (dl_tti_request) { frame = dl_tti_request->SFN; @@ -496,6 +507,7 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, } else { + if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); return; } @@ -505,6 +517,8 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, fill_dci_from_dl_config(&mac->dl_info, &mac->dl_config_request); nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); + if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); + // If we filled dl_info AFTER we got the slot indication, we want to check if we should fill tx_req: nr_uplink_indication_t ul_info; memset(&ul_info, 0, sizeof(ul_info)); @@ -880,9 +894,14 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ } //clean up nr_downlink_indication_t *dl_info - dl_info->rx_ind = NULL; - dl_info->dci_ind = NULL; - + if(dl_info->dci_ind != NULL){ + free(dl_info->dci_ind); + dl_info->dci_ind = NULL; + } + if(dl_info->rx_ind != NULL){ + free(dl_info->rx_ind); + dl_info->rx_ind = NULL; + } } return 0; } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 9e873054e4..f1c059aaae 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -2992,7 +2992,7 @@ void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len) LOG_I(NR_RRC, "We got an RRC_CONFIG_COMPLETE_REQ\n"); uint32_t nr_RadioBearer_size = hdr.RadioBearer_size; uint32_t nr_SecondaryCellGroup_size = hdr.SecondaryCellGroup_size; - AssertFatal(sizeof(hdr) + nr_RadioBearer_size + nr_SecondaryCellGroup_size == msg_len, + AssertFatal(sizeof(hdr) + nr_RadioBearer_size + nr_SecondaryCellGroup_size <= msg_len, "nr_RadioBearerConfig1_r15 size %d nr_SecondaryCellGroupConfig_r15 size %d sizeof(hdr) %zu, msg_len = %d\n", nr_RadioBearer_size, nr_SecondaryCellGroup_size,