From 7e244b3da32e0294cbe8c9a5142c8a513edb97a4 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Tue, 23 Jan 2024 18:52:34 +0100 Subject: [PATCH] make return in ul_config case correct, replace asserts by LOG_E()and return error --- executables/nr-ue.c | 7 ++- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 4 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 9 ++-- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 10 ++++- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 45 ++++++++++--------- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 10 ++++- 6 files changed, 50 insertions(+), 35 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 431794abe2..ec5f325807 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -540,7 +540,12 @@ void processSlotTX(void *arg) { PHY_VARS_NR_UE *UE = rxtxD->UE; nr_phy_data_tx_t phy_data = {0}; - LOG_D(PHY,"%d.%d => slot type %d\n", proc->frame_tx, proc->nr_slot_tx, proc->tx_slot_type); + LOG_D(PHY, + "SlotTx %d.%d => slot type %d, wait: %d \n", + proc->frame_tx, + proc->nr_slot_tx, + proc->tx_slot_type, + rxtxD->tx_wait_for_dlsch); if (proc->tx_slot_type == NR_UPLINK_SLOT || proc->tx_slot_type == NR_MIXED_SLOT){ if (rxtxD->tx_wait_for_dlsch) LOG_D(PHY, "enter wait for tx, slot %d, nb events to wait %d; ", proc->nr_slot_tx, rxtxD->tx_wait_for_dlsch); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 70ccdd8a9c..e04d8fc41a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -372,9 +372,7 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, } LOG_D(PHY, - "ULSCH Decoding, ulsch_id %d, harq_pid %d rnti %x TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d new " - "RX %d\n", - ULSCH_id, + "ULSCH Decoding, harq_pid %d rnti %x TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d new RX %d\n", harq_pid, ulsch->rnti, A, diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 14091975f3..f71d7b5f61 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1025,7 +1025,6 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ time_stats_t meas = {0}; start_meas(&meas); // do procedures for C-RNTI - int ret_pdsch = 0; const uint32_t rxdataF_sz = ue->frame_parms.samples_per_slot_wCP; __attribute__ ((aligned(32))) c16_t rxdataF[ue->frame_parms.nb_antennas_rx][rxdataF_sz]; @@ -1081,11 +1080,8 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ llr[i] = (int16_t *)malloc16_clear(rx_llr_buf_sz * sizeof(int16_t)); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_C, VCD_FUNCTION_IN); - ret_pdsch = nr_ue_pdsch_procedures(ue, - proc, - dlsch, - llr, - rxdataF); + // it returns -1 in case of internal failure, or 0 in case of normal result + int ret_pdsch = nr_ue_pdsch_procedures(ue, proc, dlsch, llr, rxdataF); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_C, VCD_FUNCTION_OUT); @@ -1103,6 +1099,7 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ send_dl_done_to_tx_thread( ue->tx_resume_ind_fifo + (proc->nr_slot_rx + dlsch_config->k1_feedback) % ue->frame_parms.slots_per_frame, proc->nr_slot_rx); + LOG_W(NR_PHY, "nr_ue_pdsch_procedures failed in slot %d\n", proc->nr_slot_rx); } stop_meas(&ue->dlsch_procedures_stat); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 70ba74158e..6240508c55 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -382,7 +382,7 @@ int get_deltatf(uint16_t nb_of_prbs, int N_sc_ctrl_RB, int O_UCI); -void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, +int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, int slot, uint16_t rnti, PUCCH_sched_t *pucch, @@ -496,7 +496,13 @@ int16_t compute_nr_SSB_PL(NR_UE_MAC_INST_t *mac, short ssb_rsrp_dBm); // - in which ULSCH should be scheduled. K2 is configured in RRC configuration. // PUSCH Msg3 scheduler: // - scheduled by RAR UL grant according to 8.3 of TS 38.213 -int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t is_Msg3, frame_t current_frame, int current_slot, frame_t *frame_tx, int *slot_tx, long k2); +int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac, + const uint8_t is_Msg3, + const frame_t current_frame, + const int current_slot, + frame_t *frame_tx, + int *slot_tx, + const long k2); int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 1f76ef2825..bbc85753bb 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -102,7 +102,7 @@ random-access procedure @param selected_rar_buffer the output buffer for storing the selected RAR header and RAR payload @returns timing advance or 0xffff if preamble doesn't match */ -static int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id); +static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id); int get_pucch0_mcs(const int O_ACK, const int O_SR, const int ack_payload, const int sr_payload) { @@ -190,7 +190,7 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti) } else if (rnti == 0xFFFF) { rnti_type = TYPE_SI_RNTI_; } else { - AssertFatal(1 == 0, "In %s: Not identified/handled rnti %d \n", __FUNCTION__, rnti); + AssertFatal(1 == 0, "Not identified/handled rnti %d \n", rnti); } LOG_D(MAC, "Returning rnti_type %s \n", rnti_types(rnti_type)); @@ -1279,7 +1279,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, harq_id, frame, slot, current_harq->ul_frame, current_harq->ul_slot, data_toul_fb); } -void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, +int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, int slot, uint16_t rnti, PUCCH_sched_t *pucch, @@ -1341,11 +1341,11 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, if (mac->harq_ACK_SpatialBundlingPUCCH || mac->pdsch_HARQ_ACK_Codebook != NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) { - LOG_E(MAC,"PUCCH Unsupported cell group configuration\n"); - return; + LOG_E(NR_MAC, "PUCCH Unsupported cell group configuration\n"); + return -1; } else if (sc_info->pdsch_CGB_Transmission) { - LOG_E(MAC,"PUCCH Unsupported code block group for serving cell config\n"); - return; + LOG_E(NR_MAC, "PUCCH Unsupported code block group for serving cell config\n"); + return -1; } NR_PUSCH_Config_t *pusch_Config = current_UL_BWP ? current_UL_BWP->pusch_Config : NULL; @@ -1371,8 +1371,8 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, int n_uci = pucch->n_sr + pucch->n_harq + pucch->n_csi; if (n_uci > (sizeof(uint64_t) * 8)) { - LOG_E(MAC,"PUCCH number of UCI bits exceeds payload size\n"); - return; + LOG_E(NR_MAC, "PUCCH number of UCI bits exceeds payload size\n"); + return -1; } switch(pucchres->format.present) { @@ -1470,7 +1470,8 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->payload = (pucch->csi_part1_payload << (pucch->n_harq + pucch->n_sr)) | (pucch->sr_payload << pucch->n_harq) | pucch->ack_payload; break; default : - AssertFatal(1==0,"Undefined PUCCH format \n"); + LOG_E(NR_MAC, "Undefined PUCCH format \n"); + return -1; } pucch_pdu->pucch_tx_power = get_pucch_tx_power_ue(mac, @@ -1484,8 +1485,10 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->nr_of_symbols, subframe_number, n_uci); - } else - AssertFatal(1 == 0, "problem with pucch configuration\n"); + } else { + LOG_E(NR_MAC, "problem with pucch configuration\n"); + return -1; + } NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = current_UL_BWP->pucch_ConfigCommon; @@ -1511,8 +1514,10 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->sequence_hop_flag = 1; break; default: - AssertFatal(1==0,"Group hopping flag undefined (0,1,2) \n"); + LOG_E(NR_MAC, "Group hopping flag undefined (0,1,2) \n"); + return -1; } + return 0; } int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, @@ -1696,7 +1701,7 @@ NR_PUCCH_Resource_t *find_pucch_resource_from_list(struct NR_PUCCH_Config__resou return pucch_resource; } -bool check_mux_acknack_csi(NR_PUCCH_Resource_t *csi_res, NR_PUCCH_Config_t *pucch_Config) +static bool check_mux_acknack_csi(NR_PUCCH_Resource_t *csi_res, NR_PUCCH_Config_t *pucch_Config) { bool ret; switch (csi_res->format.present) { @@ -2823,7 +2828,7 @@ void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, int pdu_id) nr_ue_process_mac_pdu(dl_info, pdu_id); break; case FAPI_NR_RX_PDU_TYPE_RAR: - nr_ue_process_rar(dl_info, pdu_id); + nr_ue_process_rar(dl_info, pdu_id); break; default: break; @@ -3969,7 +3974,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, // - b buffer // - ulsch power offset // - optimize: mu_pusch, j and table_6_1_2_1_1_2_time_dom_res_alloc_A are already defined in nr_ue_procedures -static int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) +static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) { module_id_t mod_id = dl_info->module_id; frame_t frame = dl_info->frame; @@ -3977,7 +3982,7 @@ static int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) if(dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack == 0) { LOG_W(NR_MAC,"[UE %d][RAPROC][%d.%d] CRC check failed on RAR (NAK)\n", mod_id, frame, slot); - return 0; + return; } NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); @@ -4046,7 +4051,6 @@ static int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) #endif if (ra->RA_RAPID_found) { - RAR_grant_t rar_grant; unsigned char tpc_command; @@ -4147,7 +4151,7 @@ static int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) rar_grant.Msg3_t_alloc); if (tda_info.nrOfSymbols == 0) { LOG_E(MAC, "Cannot schedule Msg3. Something wrong in TDA information\n"); - return -1; + return; } ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2); @@ -4158,7 +4162,6 @@ static int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) if (!ul_config) { LOG_W(MAC, "In %s: ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n", __FUNCTION__, frame, slot); - return -1; } AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]), "Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus); @@ -4185,7 +4188,7 @@ static int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) ra->t_crnti = 0; } - return ret; + return; } // Returns the pathloss in dB for the active UL BWP on the selected carrier based on the DL RS associated with the PRACH transmission diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index cd96a389b7..d5d0af8b7d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1420,7 +1420,13 @@ int nr_get_sf_retxBSRTimer(uint8_t sf_offset) { // PUSCH Msg3 scheduler: // - scheduled by RAR UL grant according to 8.3 of TS 38.213 // Note: Msg3 tx in the uplink symbols of mixed slot -int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t is_Msg3, frame_t current_frame, int current_slot, frame_t *frame_tx, int *slot_tx, long k2) +int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac, + const uint8_t is_Msg3, + const frame_t current_frame, + const int current_slot, + frame_t *frame_tx, + int *slot_tx, + const long k2) { AssertFatal(k2 > DURATION_RX_TO_TX, "Slot offset K2 (%ld) needs to be higher than DURATION_RX_TO_TX (%d). Please set min_rxtxtime at least to %d in gNB config file or gNBs.[0].min_rxtxtime=%d via command line.\n", @@ -1430,7 +1436,7 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t is_Msg3, frame_t curren DURATION_RX_TO_TX); int delta = 0; - NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; + const NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; // Get the numerology to calculate the Tx frame and slot int mu = current_UL_BWP->scs;