From dd73b2df87a56663ea3bc6ac4acd1b048f40550f Mon Sep 17 00:00:00 2001 From: David Kim Date: Fri, 30 Jul 2021 08:35:57 -0700 Subject: [PATCH] Updated AssertFatal conditions and LOG level from I to D Regarding dl_hard, some AssertFatal commented out. Regarding to memory allocation error, AssertFatal was used. --- executables/nr-ue.c | 2 +- nfapi/oai_integration/nfapi_vnf.c | 60 ++++--------------- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 6 ++ .../NR_MAC_gNB/gNB_scheduler_primitives.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 1 + .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 5 +- openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 15 +++-- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 4 +- openair2/PHY_INTERFACE/queue.c | 2 +- 11 files changed, 34 insertions(+), 67 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index eebe7e9182..12b28d7cdf 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -357,7 +357,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) }; for (int j = 0; j < crc_ind->number_crcs; j++) { - LOG_I(NR_PHY, "Sending crc_ind.harq_id = %d for %d index SFN SLot %u %u with rnti %x\n", + LOG_D(NR_PHY, "Sending crc_ind.harq_id = %d for %d index SFN SLot %u %u with rnti %x\n", crc_ind->crc_list[j].harq_id, j, crc_ind->sfn, crc_ind->slot, crc_ind->crc_list[j].rnti); } send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id); diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 4141ce4b20..6eb650939f 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -713,27 +713,20 @@ int phy_nr_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_nr_rach_ind { if(NFAPI_MODE == NFAPI_MODE_VNF) { - //UL_INFO.rach_ind = *ind; nfapi_nr_rach_indication_t *rach_ind = CALLOC(1, sizeof(*rach_ind)); rach_ind->header.message_id = ind->header.message_id; rach_ind->number_of_pdus = ind->number_of_pdus; rach_ind->sfn = ind->sfn; rach_ind->slot = ind->slot; - rach_ind->pdu_list = CALLOC(1, sizeof(*rach_ind->pdu_list)); - if (rach_ind->pdu_list == NULL) { - LOG_I(NR_MAC, "Memory not allocated for rach_ind->pdu_list of phy_nr_rach_indication in nfapi_vnf.c.\n"); - exit(0); - } + rach_ind->pdu_list = CALLOC(rach_ind->number_of_pdus, sizeof(*rach_ind->pdu_list)); + AssertFatal(rach_ind->pdu_list != NULL, "Memory not allocated for rach_ind->pdu_list in phy_nr_rach_indication."); for (int i = 0; i < ind->number_of_pdus; i++) { rach_ind->pdu_list[i].num_preamble = ind->pdu_list[i].num_preamble; rach_ind->pdu_list[i].freq_index = ind->pdu_list[i].freq_index; rach_ind->pdu_list[i].symbol_index = ind->pdu_list[i].symbol_index; rach_ind->pdu_list[i].preamble_list = CALLOC(ind->pdu_list[i].num_preamble, sizeof(nfapi_nr_prach_indication_preamble_t)); - if (rach_ind->pdu_list[i].preamble_list == NULL) { - LOG_I(NR_MAC, "Memory not allocated for rach_ind->pdu_list[i].preamble_list of phy_nr_rach_indication in nfapi_vnf.c.\n"); - exit(0); - } + AssertFatal(rach_ind->pdu_list[i].preamble_list != NULL, "Memory not allocated for rach_ind->pdu_list[i].preamble_list in phy_nr_rach_indication."); for (int j = 0; j < ind->number_of_pdus; j++) { rach_ind->pdu_list[i].preamble_list[j].preamble_index = ind->pdu_list[i].preamble_list[j].preamble_index; @@ -765,19 +758,11 @@ int phy_nr_uci_indication(struct nfapi_vnf_p7_config *config, nfapi_nr_uci_indic if(NFAPI_MODE == NFAPI_MODE_VNF) { nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind)); - if (uci_ind == NULL) { - LOG_E(NR_MAC,"Memory not allocated for uci_ind of phy_nr_uci_indication in nfapi_vnf.c.\n"); - exit(0); - } - + AssertFatal(uci_ind != NULL, "Memory not allocated for uci_ind in phy_nr_uci_indication."); *uci_ind = *ind; uci_ind->uci_list = CALLOC(NFAPI_NR_UCI_IND_MAX_PDU, sizeof(nfapi_nr_uci_t)); - if (uci_ind->uci_list == NULL) { - LOG_E(NR_MAC,"Memory not allocated for uci_ind->uci_list of phy_nr_uci_indication in nfapi_vnf.c.\n"); - exit(0); - } - + AssertFatal(uci_ind->uci_list != NULL, "Memory not allocated for uci_ind->uci_list in phy_nr_uci_indication."); for (int i = 0; i < ind->num_ucis; i++) { uci_ind->uci_list[i] = ind->uci_list[i]; @@ -792,18 +777,12 @@ int phy_nr_uci_indication(struct nfapi_vnf_p7_config *config, nfapi_nr_uci_indic nfapi_nr_uci_pucch_pdu_format_0_1_t *ind_pdu = &ind->uci_list[i].pucch_pdu_format_0_1; uci_ind_pdu->harq = CALLOC(1, sizeof(*uci_ind_pdu->harq)); - if (uci_ind_pdu->harq == NULL) { - LOG_E(NR_MAC,"Memory not allocated for uci_ind_pdu->harq of phy_nr_uci_indication in nfapi_vnf.c.\n"); - exit(0); - } + AssertFatal(uci_ind_pdu->harq != NULL, "Memory not allocated for uci_ind_pdu->harq in phy_nr_uci_indication."); *uci_ind_pdu->harq = *ind_pdu->harq; uci_ind_pdu->harq->harq_list = CALLOC(uci_ind_pdu->harq->num_harq, sizeof(*uci_ind_pdu->harq->harq_list)); - if (uci_ind_pdu->harq->harq_list == NULL) { - LOG_E(NR_MAC,"Memory not allocated for uci_ind_pdu->harq->harq_list of phy_nr_uci_indication in nfapi_vnf.c.\n"); - exit(0); - } + AssertFatal(uci_ind_pdu->harq->harq_list != NULL, "Memory not allocated for uci_ind_pdu->harq->harq_list in phy_nr_uci_indication."); for (int j = 0; j < uci_ind_pdu->harq->num_harq; j++) uci_ind_pdu->harq->harq_list[j].harq_value = ind_pdu->harq->harq_list[j].harq_value; @@ -815,26 +794,17 @@ int phy_nr_uci_indication(struct nfapi_vnf_p7_config *config, nfapi_nr_uci_indic nfapi_nr_uci_pucch_pdu_format_2_3_4_t *ind_pdu = &ind->uci_list[i].pucch_pdu_format_2_3_4; uci_ind_pdu->harq.harq_payload = CALLOC(1, sizeof(*uci_ind_pdu->harq.harq_payload)); - if (uci_ind_pdu->harq.harq_payload == NULL) { - LOG_E(NR_MAC,"Memory not allocated for uci_ind_pdu->harq.harq_payload of phy_nr_uci_indication in nfapi_vnf.c.\n"); - exit(0); - } + AssertFatal(uci_ind_pdu->harq.harq_payload != NULL, "Memory not allocated for uci_ind_pdu->harq.harq_payload in phy_nr_uci_indication."); *uci_ind_pdu->harq.harq_payload = *ind_pdu->harq.harq_payload; uci_ind_pdu->csi_part1.csi_part1_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part1.csi_part1_payload)); - if (uci_ind_pdu->csi_part1.csi_part1_payload == NULL) { - LOG_E(NR_MAC,"Memory not allocated for uci_ind_pdu->csi_part1->csi_part1_payload of phy_nr_uci_indication in nfapi_vnf.c.\n"); - exit(0); - } + 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; uci_ind_pdu->csi_part2.csi_part2_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part2.csi_part2_payload)); - if (uci_ind_pdu->csi_part2.csi_part2_payload == NULL) { - LOG_E(NR_MAC,"Memory not allocated for uci_ind_pdu->csi_part2->csi_part2_payload of phy_nr_uci_indication in nfapi_vnf.c.\n"); - exit(0); - } + 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; break; @@ -968,10 +938,7 @@ int phy_nr_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_nr_crc_indic crc_ind->slot = ind->slot; if (ind->number_crcs > 0) { crc_ind->crc_list = CALLOC(NFAPI_NR_CRC_IND_MAX_PDU, sizeof(nfapi_nr_crc_t)); - if (crc_ind->crc_list == NULL) { - LOG_I(NR_MAC, "Memory not allocated for crc_ind->crc_list of phy_nr_crc_indication in nfapi_vnf.c.\n"); - exit(0); - } + AssertFatal(crc_ind->crc_list != NULL, "Memory not allocated for crc_ind->crc_list in phy_nr_crc_indication."); } for (int j = 0; j < ind->number_crcs; j++) { @@ -1091,10 +1058,7 @@ int phy_nr_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_nr_rx_data_in if (ind->number_of_pdus > 0) { rx_ind->pdu_list = CALLOC(NFAPI_NR_RX_DATA_IND_MAX_PDU, sizeof(nfapi_nr_rx_data_pdu_t)); - if (rx_ind->pdu_list == NULL) { - LOG_I(NR_MAC,"Memory not allocated for rx_ind->pdu_list of phy_nr_rx_indication in nfapi_vnf.c.\n"); - exit(0); - } + AssertFatal(rx_ind->pdu_list != NULL, "Memory not allocated for rx_ind->pdu_list in phy_nr_rx_indication."); } for (int j = 0; j < ind->number_of_pdus; j++) { diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 68d522e30b..9f0a2cffbe 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -60,7 +60,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response "Too many ul_config pdus %d", ul_config->number_pdus); for (int i = 0; i < ul_config->number_pdus; ++i) { - LOG_D(PHY, "In %s: processing type-%d PDU of %d total UL PDUs (ul_config %p) \n", + LOG_D(PHY, "In %s: processing type %d PDU of %d total UL PDUs (ul_config %p) \n", __FUNCTION__, ul_config->ul_config_list[i].pdu_type, ul_config->number_pdus, ul_config); uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index ae1ae3abe4..1e9b634cb7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -488,7 +488,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { NR_RA_t *ra = &cc->ra[i]; - LOG_I(MAC, + LOG_D(MAC, "[gNB %d][RAPROC] CC_id %d Frame %d, Slot %d Checking all rnti : preamble index %d, rnti %x\n", module_idP, CC_id, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 28998dbf66..51e4c1e56e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -721,6 +721,12 @@ void nr_schedule_ue_spec(module_id_t module_id, if (current_harq_pid < 0) { /* PP has not selected a specific HARQ Process, get a new one */ current_harq_pid = sched_ctrl->available_dl_harq.head; + //TODO:: Need to remove this if condition after debug. + if (current_harq_pid < 0) + { + LOG_D(MAC,"no free dl HARQ process available for UE %d\n",UE_id); + return; + } AssertFatal(current_harq_pid >= 0, "no free HARQ process available for UE %d\n", UE_id); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index d28420ebc7..5517bebf77 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1452,7 +1452,7 @@ int extract_length(int startSymbolAndLength) { void dump_nr_list(NR_list_t *listP) { for (int j = listP->head; j >= 0; j = listP->next[j]) - LOG_T(MAC, "NR list node %d => %d\n", j, listP->next[j]); + LOG_I(MAC, "NR list node %d => %d\n", j, listP->next[j]); } /* diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 4c3f676704..cd01bc3bcf 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -525,6 +525,7 @@ int nr_acknack_scheduling(int mod_id, if (pucch->dai_c > 0 && pucch->frame == frame) { /* this UE already has a PUCCH occasion */ DevAssert(pucch->frame == frame); + // Find the right timing_indicator value. int i = 0; while (i < 8) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index ab586c7458..48ada17796 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -298,9 +298,6 @@ void nr_process_mac_pdu( if (pdu_len < 0) { LOG_E(MAC, "%s() residual mac pdu length < 0!, pdu_len: %d\n", __func__, pdu_len); LOG_E(MAC, "MAC PDU "); - //for (int i = 0; i < 20; i++) // Only printf 1st - 20nd bytes - // printf("%02x ", pdu_ptr[i]); - //printf("\n"); return; } } @@ -487,7 +484,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[i]; if (ra->state != WAIT_Msg3 || ra->rnti == 0) { - LOG_I(NR_MAC, "Notice ra->state = %d (if it is 2, it is WAIT_Msg3. Else we continue), ra->rnti %x\n", ra->state, ra->rnti); + LOG_D(NR_MAC, "Notice ra->state = %d (if it is 2, it is WAIT_Msg3. Else we continue), ra->rnti %x\n", ra->state, ra->rnti); continue; } diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 89083e0013..bf1b575f79 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -185,13 +185,12 @@ static bool crc_sfn_slot_matcher(void *wanted, void *candidate) void handle_nr_ulsch(NR_UL_IND_t *UL_info) { - if (gnb_rx_ind_queue.num_items == 0 || gnb_crc_ind_queue.num_items == 0) - return; - LOG_I(NR_MAC, "gnb_rx_ind_queue size and gnb_crc_ind_queue size = %zu and %zu\n", - gnb_rx_ind_queue.num_items, - gnb_crc_ind_queue.num_items - ); nfapi_nr_rx_data_indication_t *rx_ind = get_queue(&gnb_rx_ind_queue); + if (!rx_ind) + { + LOG_D(NR_PHY, "No rx data indication (empty gnb_rx_ind_queue)\n"); + return; + } int sfn_slot = NFAPI_SFNSLOT2HEX(rx_ind->sfn, rx_ind->slot); nfapi_nr_crc_indication_t *crc_ind = unqueue_matching(&gnb_crc_ind_queue, @@ -200,7 +199,7 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) &sfn_slot); if (!crc_ind) { - LOG_I(NR_PHY, "No crc indication with the same SFN SLOT of rx indication %u %u\n", rx_ind->sfn, rx_ind->slot); + LOG_D(NR_PHY, "No crc indication with the same SFN SLOT of rx indication %u %u\n", rx_ind->sfn, rx_ind->slot); requeue(&gnb_rx_ind_queue, rx_ind); return; } @@ -234,7 +233,7 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) if (crc->rnti != rx->rnti) { - LOG_I(NR_MAC, "mis-match between CRC rnti %04x and RX rnit %04x\n", crc->rnti, rx->rnti); + LOG_D(NR_MAC, "mis-match between CRC rnti %04x and RX rnit %04x\n", crc->rnti, rx->rnti); continue; } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index c24fabb0db..41b521d642 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -287,7 +287,7 @@ static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi if (tx_data_request->Slot == 7) { //Melissa this means we have an RAR, sorta hacky though if( get_mac_inst(dl_info->module_id)->crnti == get_mac_inst(dl_info->module_id)->ra.t_crnti ) - { LOG_I(MAC, "Discarding tx_data_requested since it includes useless RAR.\n"); + { LOG_D(MAC, "Discarding tx_data_requested since it includes useless RAR.\n"); continue; } dl_info->rx_ind->rx_indication_body[i].pdu_type = FAPI_NR_RX_PDU_TYPE_RAR; @@ -590,7 +590,7 @@ void *nrue_standalone_pnf_task(void *context) if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id])) { - LOG_I(NR_MAC, "put_queue failed for sfn slot.\n"); + LOG_D(NR_MAC, "put_queue failed for sfn slot.\n"); } LOG_D(NR_MAC, "We have successfully queued snf slot %d.%d, with id %u, qsize %zu\n", sfn_slot_pool[sfn_slot_id]>> 6, sfn_slot_pool[sfn_slot_id] & 0x3F, diff --git a/openair2/PHY_INTERFACE/queue.c b/openair2/PHY_INTERFACE/queue.c index c6e1fb6d2f..8e263dcdca 100644 --- a/openair2/PHY_INTERFACE/queue.c +++ b/openair2/PHY_INTERFACE/queue.c @@ -165,4 +165,4 @@ void *unqueue_matching(queue_t *q, size_t max_depth, queue_matcher_t *matcher, v pthread_mutex_unlock(&q->mutex); return item; -} +} \ No newline at end of file