From 7ca130832b2cdf08416290ffad41590d6cc5005f Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 20 Dec 2023 12:35:17 +0100 Subject: [PATCH 01/13] move computation of base graph for LDPC at MAC in the UE --- nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h | 2 ++ openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 3 +-- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 6 +----- openair1/SIMULATION/NR_PHY/dlschsim.c | 1 + openair1/SIMULATION/NR_PHY/ulschsim.c | 1 + openair1/SIMULATION/NR_PHY/ulsim.c | 1 + openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 4 ++-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 4 ++++ openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 1 + 9 files changed, 14 insertions(+), 9 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 67dd5d19b7..594a1db499 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -348,6 +348,7 @@ typedef struct uint8_t start_symbol_index; uint8_t nr_of_symbols; uint32_t tbslbrm; + uint8_t ldpcBaseGraph; //Optional Data only included if indicated in pduBitmap nfapi_nr_ue_pusch_data_t pusch_data; nfapi_nr_ue_pusch_uci_t pusch_uci; @@ -491,6 +492,7 @@ typedef struct { uint16_t dlDmrsScramblingId; uint16_t pduBitmap; uint32_t k1_feedback; + uint8_t ldpcBaseGraph; } fapi_nr_dl_config_dlsch_pdu_rel15_t; typedef struct { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index a0a90e8d42..fcce1d7cf7 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -44,7 +44,6 @@ #include "executables/nr-uesoftmodem.h" #include "PHY/CODING/nrLDPC_extern.h" #include "common/utils/nr/nr_common.h" -#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" #include "openair1/PHY/TOOLS/phy_scope_interface.h" //#define ENABLE_PHY_PAYLOAD_DEBUG 1 @@ -348,7 +347,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, LOG_D(PHY,"%d.%d DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d Qm %d Coderate %f\n", frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, dlsch->dlsch_config.mcs, dlsch->Nl, nb_symb_sch, nb_rb, dlsch->dlsch_config.qamModOrder, Coderate); - decParams.BG = get_BG(A, dlsch->dlsch_config.targetCodeRate); + decParams.BG = dlsch->dlsch_config.ldpcBaseGraph; unsigned int kc = decParams.BG == 2 ? 52 : 68; if (harq_process->first_rx == 1) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 95aa63d3bd..fadd7d6ac6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -122,11 +122,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, ///////////////////////// b---->| block segmentation |---->c ///////////////////////// /////////// - if ((A <= 292) || ((A <= NR_MAX_PDSCH_TBS) && (Coderate <= 0.6667)) || Coderate <= 0.25) { - harq_process->BG = 2; - } else { - harq_process->BG = 1; - } + harq_process->BG = ulsch->pusch_pdu.ldpcBaseGraph; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_SEGMENTATION, VCD_FUNCTION_IN); start_meas(&ue->ulsch_segmentation_stats); diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 57b62058ae..2199c43251 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -483,6 +483,7 @@ int main(int argc, char **argv) dlsch0_ue->dlsch_config.rv = rvidx; dlsch0_ue->dlsch_config.targetCodeRate = rate; dlsch0_ue->dlsch_config.TBS = TBS; + dlsch0_ue->dlsch_config.ldpcBaseGraph = get_BG(TBS, rate); dlsch0_ue->dlsch_config.dmrsConfigType = NFAPI_NR_DMRS_TYPE1; dlsch0_ue->dlsch_config.dlDmrsSymbPos = 4; dlsch0_ue->dlsch_config.n_dmrs_cdm_groups = 1; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 8ef9a039e4..966971ee73 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -506,6 +506,7 @@ int main(int argc, char **argv) ulsch_ue->pusch_pdu.pusch_data.tb_size = TBS>>3; ulsch_ue->pusch_pdu.target_code_rate = code_rate; ulsch_ue->pusch_pdu.qam_mod_order = mod_order; + ulsch_ue->pusch_pdu.ldpcBaseGraph = get_BG(TBS, code_rate); unsigned char *test_input = harq_process_ul_ue->a; /////////// diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index d3ecbdccdb..684a8385d1 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -1116,6 +1116,7 @@ int main(int argc, char *argv[]) pusch_config_pdu->absolute_delta_PUSCH = 0; pusch_config_pdu->target_code_rate = code_rate; pusch_config_pdu->tbslbrm = tbslbrm; + pusch_config_pdu->ldpcBaseGraph = get_BG(TBS, code_rate); pusch_config_pdu->pusch_data.tb_size = TBS / 8; pusch_config_pdu->pusch_data.new_data_indicator = round == 0 ? true : false; pusch_config_pdu->pusch_data.rv_index = rv_index; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index e0bc7ccb2a..6f222210dc 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -4075,8 +4075,8 @@ void csi_period_offset(NR_CSI_ReportConfig_t *csirep, } } -uint8_t get_BG(uint32_t A, uint16_t R) { - +uint8_t get_BG(uint32_t A, uint16_t R) +{ float code_rate = (float) R / 10240.0f; if ((A <= 292) || ((A <= NR_MAX_PDSCH_TBS) && (code_rate <= 0.6667)) || code_rate <= 0.25) return 2; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c5e8b9d95a..0b0e069bed 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -736,6 +736,8 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id, dlsch_pdu->TBS = current_harq->TBS; } + dlsch_pdu->ldpcBaseGraph = get_BG(dlsch_pdu->TBS, dlsch_pdu->targetCodeRate); + int bw_tbslbrm = current_DL_BWP ? mac->sc_info.dl_bw_tbslbrm : dlsch_pdu->BWPSize; dlsch_pdu->tbslbrm = nr_compute_tbslbrm(dlsch_pdu->mcs_table, bw_tbslbrm, 1); @@ -1163,6 +1165,8 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id, dlsch_pdu->TBS = current_harq->TBS; } + dlsch_pdu->ldpcBaseGraph = get_BG(dlsch_pdu->TBS, dlsch_pdu->targetCodeRate); + // TBS_LBRM according to section 5.4.2.1 of 38.212 AssertFatal(sc_info->maxMIMO_Layers_PDSCH != NULL, "Option with max MIMO layers not configured is not supported\n"); int nl_tbslbrm = *sc_info->maxMIMO_Layers_PDSCH < 4 ? *sc_info->maxMIMO_Layers_PDSCH : 4; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 5874f8fec9..9d56417335 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -739,6 +739,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->target_code_rate = mac->ul_harq_info[pid].R; pusch_config_pdu->pusch_data.tb_size = mac->ul_harq_info[pid].TBS; } + pusch_config_pdu->ldpcBaseGraph = get_BG(pusch_config_pdu->pusch_data.tb_size << 3, pusch_config_pdu->target_code_rate); return 0; } From 74832b4837f2d48fe21ea0439e70c329f5e41ee1 Mon Sep 17 00:00:00 2001 From: Alexis Falempin Date: Wed, 3 Jan 2024 10:45:20 +0000 Subject: [PATCH 02/13] NAS : Wrong security header type for PDU Session Establishment Request While testing the OAI 5G RAN in SA mode, it appears that the PDU session establishment request is using the wrong security header type. The current used header is: "Integrity protected and ciphered with new 5G NAS security context". However, according to TS 24.501, Table 9.3.1, this header can only be used by the "Security mode complete" procedure. Changes: - Hence, the new security header has been changed to "Integrity protected and ciphered", which will use the security context generated during the "Security mode complete". - Sequences numbers and NAS counters have been updated to reflect that change. --- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 4b7c4cc45c..5975aede08 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -741,7 +741,7 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi sp_msg->header.protocol_discriminator = FGS_MOBILITY_MANAGEMENT_MESSAGE; sp_msg->header.security_header_type = INTEGRITY_PROTECTED_AND_CIPHERED; sp_msg->header.message_authentication_code = 0; - sp_msg->header.sequence_number = 2; + sp_msg->header.sequence_number = 3; int size = sizeof(fgs_nas_message_security_header_t); fgs_deregistration_request_ue_originating_msg *dereg_req = &sp_msg->plain.mm_msg.fgs_deregistration_request_ue_originating; @@ -805,7 +805,9 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t * nas_stream_cipher_t stream_cipher; uint8_t mac[4]; nas_msg.header.protocol_discriminator = FGS_MOBILITY_MANAGEMENT_MESSAGE; - nas_msg.header.security_header_type = INTEGRITY_PROTECTED_AND_CIPHERED_WITH_NEW_SECU_CTX; + nas_msg.header.security_header_type = INTEGRITY_PROTECTED_AND_CIPHERED; + nas_msg.header.sequence_number = 2; + size += 7; mm_msg = &nas_msg.security_protected.plain.mm_msg; @@ -858,7 +860,7 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t * stream_cipher.key = nas->security.knas_int; stream_cipher.key_length = 16; - stream_cipher.count = nas->security.sm_counter++; + stream_cipher.count = nas->security.mm_counter++; stream_cipher.bearer = 1; stream_cipher.direction = 0; stream_cipher.message = (unsigned char *)(initialNasMsg->data + 6); From fb166fb1073a5837c67ebb0b3f1652a334f6840a Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 27 Dec 2023 19:08:24 +0100 Subject: [PATCH 03/13] avoid global prach_assoc_pattern --- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 1 + openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 129 ++++++++++---------- 2 files changed, 64 insertions(+), 66 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 4c010304b7..c42b22364d 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -462,6 +462,7 @@ typedef struct { struct NR_SI_SchedulingInfo *si_SchedulingInfo; int si_window_start; ssb_list_info_t ssb_list; + prach_association_pattern_t prach_assoc_pattern; NR_UE_ServingCell_Info_t sc_info; A_SEQUENCE_OF(NR_UE_DL_BWP_t) dl_BWPs; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 75e959f6cc..9d97cbe31a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -57,7 +57,6 @@ //#define SRS_DEBUG -static prach_association_pattern_t prach_assoc_pattern; static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP); void fill_ul_config(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx, uint8_t pdu_type) @@ -1492,8 +1491,8 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t is_Msg3, frame_t curren } // Build the list of all the valid RACH occasions in the maximum association pattern period according to the PRACH config -static void build_ro_list(NR_UE_MAC_INST_t *mac) { - +static void build_ro_list(NR_UE_MAC_INST_t *mac) +{ int x,y; // PRACH Configuration Index table variables used to compute the valid frame numbers int y2; // PRACH Configuration Index table additional variable used to compute the valid frame numbers uint8_t slot_shift_for_map; @@ -1504,7 +1503,6 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) { uint8_t N_t_slot; // Number of PRACH occasions in a 14-symbols PRACH slot uint8_t N_dur; // Duration of a PRACH occasion (nb of symbols) uint8_t frame; // Maximum is NB_FRAMES_IN_MAX_ASSOCIATION_PATTERN_PERIOD - uint8_t slot; // Maximum is the number of slots in a frame @ SCS 240kHz uint16_t format = 0xffff; uint8_t format2 = 0xff; int nb_fdm; @@ -1512,9 +1510,7 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) { uint8_t config_index; int msg1_FDM; - uint8_t prach_conf_period_idx; uint8_t nb_of_frames_per_prach_conf_period; - uint8_t prach_conf_period_frame_idx; NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP->rach_ConfigCommon; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; @@ -1595,71 +1591,71 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) { even_slot_invalid = false; } // FR2 / FR1 - prach_assoc_pattern.nb_of_prach_conf_period_in_max_period = MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD / x; + prach_association_pattern_t *prach_assoc_pattern = &mac->prach_assoc_pattern; + prach_assoc_pattern->nb_of_prach_conf_period_in_max_period = MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD / x; nb_of_frames_per_prach_conf_period = x; - LOG_D(NR_MAC,"nb_of_prach_conf_period_in_max_period %d\n", prach_assoc_pattern.nb_of_prach_conf_period_in_max_period); + LOG_D(NR_MAC,"nb_of_prach_conf_period_in_max_period %d\n", prach_assoc_pattern->nb_of_prach_conf_period_in_max_period); // Fill in the PRACH occasions table for every slot in every frame in every PRACH configuration periods in the maximum association pattern period // ---------------------------------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------------------------------- // For every PRACH configuration periods // ------------------------------------- - for (prach_conf_period_idx=0; prach_conf_period_idxnb_of_prach_conf_period_in_max_period; period_idx++) { + prach_conf_period_t *prach_conf_period_list = &prach_assoc_pattern->prach_conf_period_list[period_idx]; + prach_conf_period_list->nb_of_prach_occasion = 0; + prach_conf_period_list->nb_of_frame = nb_of_frames_per_prach_conf_period; + prach_conf_period_list->nb_of_slot = nr_slots_per_frame[mu]; - LOG_D(NR_MAC,"PRACH Conf Period Idx %d\n", prach_conf_period_idx); + LOG_D(NR_MAC,"PRACH Conf Period Idx %d\n", period_idx); // For every frames in a PRACH configuration period // ------------------------------------------------ - for (prach_conf_period_frame_idx=0; prach_conf_period_frame_idx> slot_shift_for_map; // in PRACH configuration index table slots are numbered wrt 60kHz - if ( (s_map>>map_shift)&0x01 ) { + if ((s_map>>map_shift) & 0x01) { // Valid slot // Additionally, for 30kHz/120kHz, we must check for the n_RA_Slot param also - if ( even_slot_invalid && (slot%2 == 0) ) - continue; // no prach in even slots @ 30kHz/120kHz for 1 prach per 60khz slot/subframe + if (even_slot_invalid && (slot%2 == 0)) + continue; // no prach in even slots @ 30kHz/120kHz for 1 prach per 60khz slot/subframe // We're good: valid frame and valid slot // Compute all the PRACH occasions in the slot - uint8_t n_prach_occ_in_time; - uint8_t n_prach_occ_in_freq; + prach_occasion_slot_t *slot_map = &prach_conf_period_list->prach_occasion_slot_map[frame_idx][slot]; + slot_map->nb_of_prach_occasion_in_time = N_t_slot; + slot_map->nb_of_prach_occasion_in_freq = nb_fdm; - prach_assoc_pattern.prach_conf_period_list[prach_conf_period_idx].prach_occasion_slot_map[prach_conf_period_frame_idx][slot].nb_of_prach_occasion_in_time = N_t_slot; - prach_assoc_pattern.prach_conf_period_list[prach_conf_period_idx].prach_occasion_slot_map[prach_conf_period_frame_idx][slot].nb_of_prach_occasion_in_freq = nb_fdm; - - for (n_prach_occ_in_time=0; n_prach_occ_in_timeprach_occasion[n_prach_occ_in_time][n_prach_occ_in_freq]; prach_occasion_p->start_symbol = start_symbol; prach_occasion_p->fdm = n_prach_occ_in_freq; prach_occasion_p->frame = frame; prach_occasion_p->slot = slot; prach_occasion_p->format = format; - prach_assoc_pattern.prach_conf_period_list[prach_conf_period_idx].nb_of_prach_occasion++; + prach_assoc_pattern->prach_conf_period_list[period_idx].nb_of_prach_occasion++; LOG_D(NR_MAC,"Adding a PRACH occasion: frame %u, slot-symbol %d-%d, occ_in_time-occ_in-freq %d-%d, nb ROs in conf period %d, for this slot: RO# in time %d, RO# in freq %d\n", - frame, slot, start_symbol, n_prach_occ_in_time, n_prach_occ_in_freq, prach_assoc_pattern.prach_conf_period_list[prach_conf_period_idx].nb_of_prach_occasion, - prach_assoc_pattern.prach_conf_period_list[prach_conf_period_idx].prach_occasion_slot_map[prach_conf_period_frame_idx][slot].nb_of_prach_occasion_in_time, - prach_assoc_pattern.prach_conf_period_list[prach_conf_period_idx].prach_occasion_slot_map[prach_conf_period_frame_idx][slot].nb_of_prach_occasion_in_freq); + frame, slot, start_symbol, n_prach_occ_in_time, n_prach_occ_in_freq, prach_conf_period_list->nb_of_prach_occasion, + slot_map->nb_of_prach_occasion_in_time, + slot_map->nb_of_prach_occasion_in_freq); } // For every freq in the slot } // For every time occasions in the slot } // Valid slot? @@ -1759,50 +1755,50 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) required_nb_of_prach_occasion = mac->ssb_list.nb_tx_ssb * ssb_rach_ratio; } - AssertFatal(prach_assoc_pattern.prach_conf_period_list[0].nb_of_prach_occasion>0, + prach_association_pattern_t *prach_assoc_pattern = &mac->prach_assoc_pattern; + prach_association_period_t *prach_association_period_list = &prach_assoc_pattern->prach_association_period_list[0]; + AssertFatal(prach_assoc_pattern->prach_conf_period_list[0].nb_of_prach_occasion > 0, "prach_assoc_pattern.prach_conf_period_list[0].nb_of_prach_occasion shouldn't be 0 (ssb_list.nb_tx_ssb %d, ssb_rach_ratio %d\n", mac->ssb_list.nb_tx_ssb,ssb_rach_ratio); - required_nb_of_prach_conf_period = ((required_nb_of_prach_occasion-1) + prach_assoc_pattern.prach_conf_period_list[0].nb_of_prach_occasion) / - prach_assoc_pattern.prach_conf_period_list[0].nb_of_prach_occasion; + required_nb_of_prach_conf_period = ((required_nb_of_prach_occasion-1) + prach_assoc_pattern->prach_conf_period_list[0].nb_of_prach_occasion) / + prach_assoc_pattern->prach_conf_period_list[0].nb_of_prach_occasion; if (required_nb_of_prach_conf_period == 1) { - prach_assoc_pattern.prach_association_period_list[0].nb_of_prach_conf_period = 1; + prach_association_period_list->nb_of_prach_conf_period = 1; } else if (required_nb_of_prach_conf_period == 2) { - prach_assoc_pattern.prach_association_period_list[0].nb_of_prach_conf_period = 2; + prach_association_period_list->nb_of_prach_conf_period = 2; } else if (required_nb_of_prach_conf_period <= 4) { - prach_assoc_pattern.prach_association_period_list[0].nb_of_prach_conf_period = 4; + prach_association_period_list->nb_of_prach_conf_period = 4; } else if (required_nb_of_prach_conf_period <= 8) { - prach_assoc_pattern.prach_association_period_list[0].nb_of_prach_conf_period = 8; + prach_association_period_list->nb_of_prach_conf_period = 8; } else if (required_nb_of_prach_conf_period <= 16) { - prach_assoc_pattern.prach_association_period_list[0].nb_of_prach_conf_period = 16; + prach_association_period_list->nb_of_prach_conf_period = 16; } else { AssertFatal(1 == 0, "Invalid number of PRACH config periods within an association period %d\n", required_nb_of_prach_conf_period); } - prach_assoc_pattern.nb_of_assoc_period = 1; // WIP: only one possible association period - prach_assoc_pattern.prach_association_period_list[0].nb_of_frame = prach_assoc_pattern.prach_association_period_list[0].nb_of_prach_conf_period * prach_assoc_pattern.prach_conf_period_list[0].nb_of_frame; - prach_assoc_pattern.nb_of_frame = prach_assoc_pattern.prach_association_period_list[0].nb_of_frame; + prach_assoc_pattern->nb_of_assoc_period = 1; // WIP: only one possible association period + prach_association_period_list->nb_of_frame = prach_association_period_list->nb_of_prach_conf_period * prach_assoc_pattern->prach_conf_period_list[0].nb_of_frame;; + prach_assoc_pattern->nb_of_frame = prach_association_period_list->nb_of_frame; LOG_D(NR_MAC,"Assoc period %d, Nb of frames in assoc period %d\n", - prach_assoc_pattern.prach_association_period_list[0].nb_of_prach_conf_period, - prach_assoc_pattern.prach_association_period_list[0].nb_of_frame); + prach_association_period_list->nb_of_prach_conf_period, + prach_association_period_list->nb_of_frame); // Proceed to the SSB to RO mapping // ================================ - uint8_t association_period_idx; // Association period index within the association pattern uint8_t ssb_idx = 0; uint8_t prach_configuration_period_idx; // PRACH Configuration period index within the association pattern prach_conf_period_t *prach_conf_period_p; // Map all the association periods within the association pattern period LOG_D(NR_MAC,"Proceed to the SSB to RO mapping\n"); - for (association_period_idx=0; association_period_idxnb_of_assoc_period; association_period_idx++) { uint8_t frame=0; uint8_t slot=0; uint8_t ro_in_time=0; @@ -1824,10 +1820,11 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) ssb_idx = 0; // Go through the list of PRACH config periods within this association period - for (n_prach_conf=0; n_prach_confprach_association_period_list[association_period_idx]; + for (int n_prach_conf=0; n_prach_conf < prach_association_period_list->nb_of_prach_conf_period; n_prach_conf++, prach_configuration_period_idx++) { // Build the association period with its association PRACH Configuration indexes - prach_conf_period_p = &prach_assoc_pattern.prach_conf_period_list[prach_configuration_period_idx]; - prach_assoc_pattern.prach_association_period_list[association_period_idx].prach_conf_period_list[n_prach_conf] = prach_conf_period_p; + prach_conf_period_p = &prach_assoc_pattern->prach_conf_period_list[prach_configuration_period_idx]; + prach_association_period_list->prach_conf_period_list[n_prach_conf] = prach_conf_period_p; // Go through all the ROs within the PRACH config period for (frame=0; framenb_of_frame; frame++) { @@ -1895,8 +1892,6 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) // -------------------- // -------------------- - n_prach_conf = 0; - // Go through the list of transmitted SSBs for (ssb_idx=0; ssb_idxprach_association_period_list[association_period_idx].nb_of_prach_conf_period; n_prach_conf++, prach_configuration_period_idx++) { // Build the association period with its association PRACH Configuration indexes - prach_conf_period_p = &prach_assoc_pattern.prach_conf_period_list[prach_configuration_period_idx]; - prach_assoc_pattern.prach_association_period_list[association_period_idx].prach_conf_period_list[n_prach_conf] = prach_conf_period_p; + prach_conf_period_p = &prach_assoc_pattern->prach_conf_period_list[prach_configuration_period_idx]; + prach_assoc_pattern->prach_association_period_list[association_period_idx].prach_conf_period_list[n_prach_conf] = prach_conf_period_p; for (; framenb_of_frame; frame++) { for (; slotnb_of_slot; slot++) { @@ -1980,7 +1975,8 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) } // Returns a RACH occasion if any matches the SSB idx, the frame and the slot -static int get_nr_prach_info_from_ssb_index(uint8_t ssb_idx, +static int get_nr_prach_info_from_ssb_index(prach_association_pattern_t *prach_assoc_pattern, + uint8_t ssb_idx, int frame, int slot, ssb_list_info_t *ssb_list, @@ -1999,14 +1995,14 @@ static int get_nr_prach_info_from_ssb_index(uint8_t ssb_idx, ssb_info_p = &ssb_list->tx_ssb[ssb_idx]; LOG_D(NR_MAC, "checking for prach : ssb_info_p->nb_mapped_ro %d\n", ssb_info_p->nb_mapped_ro); for (uint8_t n_mapped_ro=0; n_mapped_ronb_mapped_ro; n_mapped_ro++) { - LOG_D(NR_MAC,"%d.%d: mapped_ro[%d]->frame.slot %d.%d, prach_assoc_pattern.nb_of_frame %d\n", - frame,slot,n_mapped_ro,ssb_info_p->mapped_ro[n_mapped_ro]->frame,ssb_info_p->mapped_ro[n_mapped_ro]->slot,prach_assoc_pattern.nb_of_frame); + LOG_D(NR_MAC,"%d.%d: mapped_ro[%d]->frame.slot %d.%d, prach_assoc_pattern->nb_of_frame %d\n", + frame,slot,n_mapped_ro,ssb_info_p->mapped_ro[n_mapped_ro]->frame,ssb_info_p->mapped_ro[n_mapped_ro]->slot,prach_assoc_pattern->nb_of_frame); if ((slot == ssb_info_p->mapped_ro[n_mapped_ro]->slot) && - (ssb_info_p->mapped_ro[n_mapped_ro]->frame == (frame % prach_assoc_pattern.nb_of_frame))) { + (ssb_info_p->mapped_ro[n_mapped_ro]->frame == (frame % prach_assoc_pattern->nb_of_frame))) { - uint8_t prach_config_period_nb = ssb_info_p->mapped_ro[n_mapped_ro]->frame / prach_assoc_pattern.prach_conf_period_list[0].nb_of_frame; - uint8_t frame_nb_in_prach_config_period = ssb_info_p->mapped_ro[n_mapped_ro]->frame % prach_assoc_pattern.prach_conf_period_list[0].nb_of_frame; - prach_occasion_slot_p = &prach_assoc_pattern.prach_conf_period_list[prach_config_period_nb].prach_occasion_slot_map[frame_nb_in_prach_config_period][slot]; + uint8_t prach_config_period_nb = ssb_info_p->mapped_ro[n_mapped_ro]->frame / prach_assoc_pattern->prach_conf_period_list[0].nb_of_frame; + uint8_t frame_nb_in_prach_config_period = ssb_info_p->mapped_ro[n_mapped_ro]->frame % prach_assoc_pattern->prach_conf_period_list[0].nb_of_frame; + prach_occasion_slot_p = &prach_assoc_pattern->prach_conf_period_list[prach_config_period_nb].prach_occasion_slot_map[frame_nb_in_prach_config_period][slot]; } } @@ -2062,7 +2058,7 @@ static int get_nr_prach_info_from_ssb_index(uint8_t ssb_idx, void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac) { // Clear all the lists and maps - memset(&prach_assoc_pattern, 0, sizeof(prach_association_pattern_t)); + memset(&mac->prach_assoc_pattern, 0, sizeof(prach_association_pattern_t)); memset(&mac->ssb_list, 0, sizeof(ssb_list_info_t)); // Build the list of all the valid RACH occasions in the maximum association pattern period according to the PRACH config @@ -2472,7 +2468,8 @@ static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_fr // Get any valid PRACH occasion in the current slot for the selected SSB index prach_occasion_info_t *prach_occasion_info_p; - int is_nr_prach_slot = get_nr_prach_info_from_ssb_index(selected_gnb_ssb_idx, + int is_nr_prach_slot = get_nr_prach_info_from_ssb_index(&mac->prach_assoc_pattern, + selected_gnb_ssb_idx, (int)frameP, (int)slotP, &mac->ssb_list, From 6302169d427f61e979e3b08d63ad36a1cfbf5987 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 27 Dec 2023 19:09:07 +0100 Subject: [PATCH 04/13] don't configure rach occasions for bwp without rach config --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 7e7da9c4f8..718dec51bb 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1913,7 +1913,7 @@ static void configure_BWPs(NR_UE_MAC_INST_t *mac, NR_ServingCellConfig_t *scd) } if (scd->uplinkConfig->firstActiveUplinkBWP_Id) { mac->current_UL_BWP = get_ul_bwp_structure(mac, *scd->uplinkConfig->firstActiveUplinkBWP_Id, false); - AssertFatal(mac->current_UL_BWP, "Couldn't find DL-BWP %ld\n", *scd->uplinkConfig->firstActiveUplinkBWP_Id); + AssertFatal(mac->current_UL_BWP, "Couldn't find UL-BWP %ld\n", *scd->uplinkConfig->firstActiveUplinkBWP_Id); } } } @@ -1947,7 +1947,9 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, } // Setup the SSB to Rach Occasions mapping according to the config - build_ssb_to_ro_map(mac); + // Only if RACH is configured for current BWP + if (mac->current_UL_BWP->rach_ConfigCommon) + build_ssb_to_ro_map(mac); if (!mac->dl_config_request || !mac->ul_config_request) ue_init_config_request(mac, mac->current_DL_BWP->scs); From 3bb6457fc69829a1425c82543d080dc053f4fa24 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 28 Dec 2023 15:12:53 +0100 Subject: [PATCH 05/13] RO MAC fields depending on bwp-id --- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 10 +-- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 10 ++- .../NR_MAC_UE/nr_ue_dci_configuration.c | 5 +- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 61 ++++++++++--------- 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index c42b22364d..43125659a9 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -69,8 +69,8 @@ // ========== #define NB_NR_UE_MAC_INST 1 -#define MAX_NUM_BWP_UE 4 -#define NUM_SLOT_FRAME 10 +#define MAX_NUM_BWP_UE 5 +#define NUM_SLOT_FRAME 10 /*!\brief value for indicating BSR Timer is not running */ #define NR_MAC_UE_BSR_TIMER_NOT_RUNNING (0xFFFF) @@ -461,13 +461,13 @@ typedef struct { NR_MIB_t *mib; struct NR_SI_SchedulingInfo *si_SchedulingInfo; int si_window_start; - ssb_list_info_t ssb_list; - prach_association_pattern_t prach_assoc_pattern; + ssb_list_info_t ssb_list[MAX_NUM_BWP_UE]; + prach_association_pattern_t prach_assoc_pattern[MAX_NUM_BWP_UE]; NR_UE_ServingCell_Info_t sc_info; A_SEQUENCE_OF(NR_UE_DL_BWP_t) dl_BWPs; A_SEQUENCE_OF(NR_UE_UL_BWP_t) ul_BWPs; - NR_BWP_PDCCH_t config_BWP_PDCCH[5]; + NR_BWP_PDCCH_t config_BWP_PDCCH[MAX_NUM_BWP_UE]; NR_UE_DL_BWP_t *current_DL_BWP; NR_UE_UL_BWP_t *current_UL_BWP; diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 6ae2df12eb..83b5d7867b 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -74,6 +74,13 @@ void nr_ue_init_mac(module_id_t module_idP) mac->servCellIndex = 0; mac->harq_ACK_SpatialBundlingPUCCH = false; mac->harq_ACK_SpatialBundlingPUSCH = false; + + memset(&mac->ssb_measurements, 0, sizeof(mac->ssb_measurements)); + memset(&mac->ul_time_alignment, 0, sizeof(mac->ul_time_alignment)); + for (int i = 0; i < MAX_NUM_BWP_UE; i++) { + memset(&mac->ssb_list[i], 0, sizeof(mac->ssb_list[i])); + memset(&mac->prach_assoc_pattern[i], 0, sizeof(mac->prach_assoc_pattern[i])); + } } void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) @@ -103,9 +110,6 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) mac->UL_ndi[k] = -1; // initialize to invalid value } - - memset(&mac->ssb_measurements, 0, sizeof(mac->ssb_measurements)); - memset(&mac->ul_time_alignment, 0, sizeof(mac->ul_time_alignment)); } NR_UE_MAC_INST_t *nr_l2_init_ue() diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 1bd991f7c5..b507a0f2f1 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -412,6 +412,7 @@ bool monitior_dci_for_other_SI(NR_UE_MAC_INST_t *mac, return false; const int si_window_slots = 5 << si_SchedulingInfo->si_WindowLength; const int abs_slot = frame * slots_per_frame + slot; + const int bwp_id = mac->current_DL_BWP->bwp_id; for (int n = 0; n < si_SchedulingInfo->schedulingInfoList.list.count; n++) { struct NR_SchedulingInfo *sched_Info = si_SchedulingInfo->schedulingInfoList.list.array[n]; if(mac->si_window_start == -1) { @@ -436,10 +437,10 @@ bool monitior_dci_for_other_SI(NR_UE_MAC_INST_t *mac, get_monitoring_period_offset(ss, &period, &offset); for (int i = 0; i < duration; i++) { if (((frame * slots_per_frame + slot - offset - i) % period) == 0) { - int N = mac->ssb_list.nb_tx_ssb; + int N = mac->ssb_list[bwp_id].nb_tx_ssb; int K = 0; // k_th transmitted SSB for (int i = 0; i < mac->mib_ssb; i++) { - if(mac->ssb_list.tx_ssb[i].transmitted) + if(mac->ssb_list[bwp_id].tx_ssb[i].transmitted) K++; } // numbering current frame and slot in terms of monitoring occasions in window diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 9d97cbe31a..f799783f58 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1591,7 +1591,8 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) even_slot_invalid = false; } // FR2 / FR1 - prach_association_pattern_t *prach_assoc_pattern = &mac->prach_assoc_pattern; + const int bwp_id = mac->current_UL_BWP->bwp_id; + prach_association_pattern_t *prach_assoc_pattern = &mac->prach_assoc_pattern[bwp_id]; prach_assoc_pattern->nb_of_prach_conf_period_in_max_period = MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD / x; nb_of_frames_per_prach_conf_period = x; @@ -1666,11 +1667,11 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) } // Build the list of all the valid/transmitted SSBs according to the config -static void build_ssb_list(NR_UE_MAC_INST_t *mac) { - +static void build_ssb_list(NR_UE_MAC_INST_t *mac) +{ // Create the list of transmitted SSBs - // =================================== - ssb_list_info_t *ssb_list = &mac->ssb_list; + const int bwp_id = mac->current_UL_BWP->bwp_id; + ssb_list_info_t *ssb_list = &mac->ssb_list[bwp_id]; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; ssb_list->nb_tx_ssb = 0; @@ -1742,6 +1743,9 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) } LOG_D(NR_MAC,"SSB rach ratio %d, Multiple SSB per RO %d\n", ssb_rach_ratio, multiple_ssb_per_ro); + const int bwp_id = mac->current_UL_BWP->bwp_id; + ssb_list_info_t *ssb_list = &mac->ssb_list[bwp_id]; + // Evaluate the number of PRACH configuration periods required to map all the SSBs and set the association period // ============================================================================================================== // WIP: Assumption for now is that all the PRACH configuration periods within a maximum association pattern period have the same number of PRACH occasions @@ -1749,17 +1753,17 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) // There is only one possible association period which can contain up to 16 PRACH configuration periods LOG_D(NR_MAC,"Evaluate the number of PRACH configuration periods required to map all the SSBs and set the association period\n"); if (true == multiple_ssb_per_ro) { - required_nb_of_prach_occasion = ((mac->ssb_list.nb_tx_ssb-1) + ssb_rach_ratio) / ssb_rach_ratio; + required_nb_of_prach_occasion = ((ssb_list->nb_tx_ssb - 1) + ssb_rach_ratio) / ssb_rach_ratio; } else { - required_nb_of_prach_occasion = mac->ssb_list.nb_tx_ssb * ssb_rach_ratio; + required_nb_of_prach_occasion = ssb_list->nb_tx_ssb * ssb_rach_ratio; } - prach_association_pattern_t *prach_assoc_pattern = &mac->prach_assoc_pattern; + prach_association_pattern_t *prach_assoc_pattern = &mac->prach_assoc_pattern[bwp_id]; prach_association_period_t *prach_association_period_list = &prach_assoc_pattern->prach_association_period_list[0]; AssertFatal(prach_assoc_pattern->prach_conf_period_list[0].nb_of_prach_occasion > 0, - "prach_assoc_pattern.prach_conf_period_list[0].nb_of_prach_occasion shouldn't be 0 (ssb_list.nb_tx_ssb %d, ssb_rach_ratio %d\n", - mac->ssb_list.nb_tx_ssb,ssb_rach_ratio); + "prach_assoc_pattern.prach_conf_period_list[0].nb_of_prach_occasion shouldn't be 0 (nb_tx_ssb %d, ssb_rach_ratio %d)\n", + ssb_list->nb_tx_ssb, ssb_rach_ratio); required_nb_of_prach_conf_period = ((required_nb_of_prach_occasion-1) + prach_assoc_pattern->prach_conf_period_list[0].nb_of_prach_occasion) / prach_assoc_pattern->prach_conf_period_list[0].nb_of_prach_occasion; @@ -1838,20 +1842,20 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) // this is true if no PRACH occasions are conflicting with SSBs nor TDD_UL_DL_ConfigurationCommon schedule for (; ssb_idxssb_list.tx_ssb[ssb_idx].transmitted) { + if (true == ssb_list->tx_ssb[ssb_idx].transmitted) { ro_p->mapped_ssb_idx[ro_p->nb_mapped_ssb] = ssb_idx; ro_p->nb_mapped_ssb++; - mac->ssb_list.tx_ssb[ssb_idx].mapped_ro[mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro] = ro_p; - mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro++; - AssertFatal(MAX_NB_RO_PER_SSB_IN_ASSOCIATION_PATTERN > mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro, + ssb_list->tx_ssb[ssb_idx].mapped_ro[ssb_list->tx_ssb[ssb_idx].nb_mapped_ro] = ro_p; + ssb_list->tx_ssb[ssb_idx].nb_mapped_ro++; + AssertFatal(MAX_NB_RO_PER_SSB_IN_ASSOCIATION_PATTERN > ssb_list->tx_ssb[ssb_idx].nb_mapped_ro, "Too many mapped ROs (%d) to a single SSB\n", - mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro); + ssb_list->tx_ssb[ssb_idx].nb_mapped_ro); LOG_D(NR_MAC, "Mapped ssb_idx %u to RO slot-symbol %u-%u, %u-%u-%u/%u\n", ssb_idx, ro_p->slot, ro_p->start_symbol, slot, ro_in_time, ro_in_freq, prach_conf_period_p->prach_occasion_slot_map[frame][slot].nb_of_prach_occasion_in_freq); LOG_D(NR_MAC, "Nb mapped ROs for this ssb idx: in the association period only %u\n", - mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro); + ssb_list->tx_ssb[ssb_idx].nb_mapped_ro); // If all the required SSBs are mapped to this RO, exit the loop of SSBs if (ro_p->nb_mapped_ssb == ssb_rach_ratio) { @@ -1896,10 +1900,10 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) for (ssb_idx=0; ssb_idx %d\n", - ssb_idx, mac->ssb_list.tx_ssb[ssb_idx].transmitted); + ssb_idx, ssb_list->tx_ssb[ssb_idx].transmitted); // Map only the transmitted ssb_idx - if (true == mac->ssb_list.tx_ssb[ssb_idx].transmitted) { + if (true == ssb_list->tx_ssb[ssb_idx].transmitted) { // Map all the required ROs to this SSB // Go through the list of PRACH config periods within this association period @@ -1917,18 +1921,18 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) ro_p->mapped_ssb_idx[0] = ssb_idx; ro_p->nb_mapped_ssb = 1; - mac->ssb_list.tx_ssb[ssb_idx].mapped_ro[mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro] = ro_p; - mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro++; - AssertFatal(MAX_NB_RO_PER_SSB_IN_ASSOCIATION_PATTERN > mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro, + ssb_list->tx_ssb[ssb_idx].mapped_ro[ssb_list->tx_ssb[ssb_idx].nb_mapped_ro] = ro_p; + ssb_list->tx_ssb[ssb_idx].nb_mapped_ro++; + AssertFatal(MAX_NB_RO_PER_SSB_IN_ASSOCIATION_PATTERN > ssb_list->tx_ssb[ssb_idx].nb_mapped_ro, "Too many mapped ROs (%d) to a single SSB\n", - mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro); + ssb_list->tx_ssb[ssb_idx].nb_mapped_ro); nb_mapped_ro_in_association_period++; LOG_D(NR_MAC,"Mapped ssb_idx %u to RO slot-symbol %u-%u, %u-%u-%u/%u\n", ssb_idx, ro_p->slot, ro_p->start_symbol, slot, ro_in_time, ro_in_freq, prach_conf_period_p->prach_occasion_slot_map[frame][slot].nb_of_prach_occasion_in_freq); LOG_D(NR_MAC, "Nb mapped ROs for this ssb idx: in the association period only %u / total %u\n", - mac->ssb_list.tx_ssb[ssb_idx].nb_mapped_ro, nb_mapped_ro_in_association_period); + ssb_list->tx_ssb[ssb_idx].nb_mapped_ro, nb_mapped_ro_in_association_period); // Exit the loop if this SSB has been mapped to all the required ROs // WIP: Assuming that ssb_rach_ratio equals the maximum nb of times a given ssb_idx is mapped within an association period: @@ -2058,8 +2062,9 @@ static int get_nr_prach_info_from_ssb_index(prach_association_pattern_t *prach_a void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac) { // Clear all the lists and maps - memset(&mac->prach_assoc_pattern, 0, sizeof(prach_association_pattern_t)); - memset(&mac->ssb_list, 0, sizeof(ssb_list_info_t)); + const int bwp_id = mac->current_UL_BWP->bwp_id; + memset(&mac->ssb_list[bwp_id], 0, sizeof(ssb_list_info_t)); + memset(&mac->prach_assoc_pattern[bwp_id], 0, sizeof(prach_association_pattern_t)); // Build the list of all the valid RACH occasions in the maximum association pattern period according to the PRACH config LOG_D(NR_MAC,"Build RO list\n"); @@ -2457,7 +2462,7 @@ static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_fr NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP->rach_ConfigCommon; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; - + const int bwp_id = mac->current_UL_BWP->bwp_id; NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->tdd_UL_DL_ConfigurationCommon; if (is_nr_UL_slot(tdd_config, slotP, mac->frame_type)) { @@ -2468,11 +2473,11 @@ static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_fr // Get any valid PRACH occasion in the current slot for the selected SSB index prach_occasion_info_t *prach_occasion_info_p; - int is_nr_prach_slot = get_nr_prach_info_from_ssb_index(&mac->prach_assoc_pattern, + int is_nr_prach_slot = get_nr_prach_info_from_ssb_index(&mac->prach_assoc_pattern[bwp_id], selected_gnb_ssb_idx, (int)frameP, (int)slotP, - &mac->ssb_list, + &mac->ssb_list[bwp_id], &prach_occasion_info_p); if (is_nr_prach_slot) { From 4c7b185d92a4f34631c79dce176a31845759fe55 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Mon, 8 Jan 2024 14:08:55 +0100 Subject: [PATCH 06/13] merge two reduntant and incoherent enums for rnti_type_t, make a macro to stringify properly instead of hardcoded side strings array --- common/utils/nr/nr_common.h | 31 + executables/nr-ue.c | 2 +- .../nfapi/public_inc/nfapi_nr_interface.h | 16 - .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 2 +- .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 3 +- openair1/PHY/defs_nr_UE.h | 48 +- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 6 +- openair1/SCHED_NR_UE/harq_nr.c | 6 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 7 +- openair1/SIMULATION/NR_PHY/dlsim.c | 10 +- .../NR_UE_PHY/unit_tests/src/harq_test.c | 2 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 17 - openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 76 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 26 +- openair2/LAYER2/NR_MAC_UE/mac_extern.h | 25 +- openair2/LAYER2/NR_MAC_UE/mac_vars.c | 4 - .../NR_MAC_UE/nr_ue_dci_configuration.c | 38 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 205 ++--- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 5 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 36 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 25 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 21 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 844 +++++++++--------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c | 5 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 27 +- 26 files changed, 775 insertions(+), 714 deletions(-) diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index ea6c8b860e..7764b0ee8f 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -44,6 +44,37 @@ #define NR_NB_SC_PER_RB 12 #define NR_MAX_NUM_LCID 32 #define NR_MAX_NUM_QFI 64 +#define RNTI_NAMES /* see 38.321 Table 7.1-2 RNTI usage */ \ + R(TYPE_C_RNTI_) /* Cell RNTI */ \ + R(TYPE_CS_RNTI_) /* Configured Scheduling RNTI */ \ + R(TYPE_TC_RNTI_) /* Temporary C-RNTI */ \ + R(TYPE_P_RNTI_) /* Paging RNTI */ \ + R(TYPE_SI_RNTI_) /* System information RNTI */ \ + R(TYPE_RA_RNTI_) /* Random Access RNTI */ \ + R(TYPE_SP_CSI_RNTI_) /* Semipersistent CSI reporting on PUSCH */ \ + R(TYPE_SFI_RNTI_) /* Slot Format Indication on the given cell */ \ + R(TYPE_INT_RNTI_) /* Indication pre-emption in DL */ \ + R(TYPE_TPC_PUSCH_RNTI_) /* PUSCH power control */ \ + R(TYPE_TPC_PUCCH_RNTI_) /* PUCCH power control */ \ + R(TYPE_TPC_SRS_RNTI_) \ + R(TYPE_MCS_C_RNTI_) + +#define R(k) k , +typedef enum { RNTI_NAMES } nr_rnti_type_t; +#undef R + +#define R(k) \ + case k: \ + return #k; +static inline const char *rnti_types(nr_rnti_type_t rr) +{ + switch (rr) { + RNTI_NAMES + default: + return "Not existing RNTI type"; + } +} +#undef R typedef enum { nr_FR1 = 0, diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 9f1400ae47..f9eecf9076 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -613,7 +613,7 @@ nr_phy_data_t UE_dl_preprocessing(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) uint64_t a=rdtsc_oai(); pbch_pdcch_processing(UE, proc, &phy_data); - if (phy_data.dlsch[0].active) { + if (phy_data.dlsch[0].active && phy_data.dlsch[0].rnti_type == TYPE_C_RNTI_) { // indicate to tx thread to wait for DLSCH decoding const int ack_nack_slot = (proc->nr_slot_rx + phy_data.dlsch[0].dlsch_config.k1_feedback) % UE->frame_parms.slots_per_frame; UE->tx_wait_for_dlsch[ack_nack_slot]++; diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h index 20c1e890bc..ad6a325848 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -239,22 +239,6 @@ typedef struct { nfapi_vendor_extension_tlv_t vendor_extension; } nfapi_nr_config_request_t; -typedef enum { - NFAPI_NR_RNTI_new = 0, - NFAPI_NR_RNTI_C, - NFAPI_NR_RNTI_RA, - NFAPI_NR_RNTI_P, - NFAPI_NR_RNTI_CS, - NFAPI_NR_RNTI_TC, - NFAPI_NR_RNTI_SP_CSI, - NFAPI_NR_RNTI_SI, - NFAPI_NR_RNTI_SFI, - NFAPI_NR_RNTI_INT, - NFAPI_NR_RNTI_TPC_PUSCH, - NFAPI_NR_RNTI_TPC_PUCCH, - NFAPI_NR_RNTI_TPC_SRS -} nfapi_nr_rnti_type_e; - typedef enum { NFAPI_NR_USS_FORMAT_0_0_AND_1_0, NFAPI_NR_USS_FORMAT_0_1_AND_1_1, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 0f4bb266a7..390917885c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -597,7 +597,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } /* Check for PTRS bitmap and process it respectively */ - if((pduBitmap & 0x1) && (dlsch[0].rnti_type == _C_RNTI_)) { + if((pduBitmap & 0x1) && (dlsch[0].rnti_type == TYPE_C_RNTI_)) { nr_pdsch_ptrs_processing( ue, nbRx, ptrs_phase_per_slot, ptrs_re_per_slot, rx_size_symbol, rxdataF_comp, frame_parms, dlsch0_harq, dlsch1_harq, gNB_id, nr_slot_rx, symbol, (nb_rb_pdsch * 12), dlsch[0].rnti, dlsch); dl_valid_re[symbol-1] -= ptrs_re_per_slot[0][symbol]; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index b03764696f..0b2f7ba888 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -38,7 +38,6 @@ #include "nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h" #include "../NR_TRANSPORT/nr_transport_common_proto.h" - typedef enum { NEW_TRANSMISSION_HARQ, RETRANSMISSION_HARQ @@ -95,7 +94,7 @@ typedef struct { // UL number of harq processes uint8_t number_harq_processes_for_pusch; /// RNTI type - uint8_t rnti_type; + nr_rnti_type_t rnti_type; /// Cell ID int Nid_cell; /// bit mask of PT-RS ofdm symbol indicies diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 0eb824406b..2aef2782ae 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -254,48 +254,16 @@ typedef struct { #define MAX_NR_DCI_DECODED_SLOT 10 // This value is not specified - - typedef enum { - _format_0_0_found=0, - _format_0_1_found=1, - _format_1_0_found=2, - _format_1_1_found=3, - _format_2_0_found=4, - _format_2_1_found=5, - _format_2_2_found=6, - _format_2_3_found=7 + _format_0_0_found = 0, + _format_0_1_found = 1, + _format_1_0_found = 2, + _format_1_1_found = 3, + _format_2_0_found = 4, + _format_2_1_found = 5, + _format_2_2_found = 6, + _format_2_3_found = 7 } format_found_t; -#define TOTAL_NBR_SCRAMBLED_VALUES 13 -#define _C_RNTI_ 0 -#define _CS_RNTI_ 1 -#define _NEW_RNTI_ 2 -#define _TC_RNTI_ 3 -#define _P_RNTI_ 4 -#define _SI_RNTI_ 5 -#define _RA_RNTI_ 6 -#define _SP_CSI_RNTI_ 7 -#define _SFI_RNTI_ 8 -#define _INT_RNTI_ 9 -#define _TPC_PUSCH_RNTI_ 10 -#define _TPC_PUCCH_RNTI_ 11 -#define _TPC_SRS_RNTI_ 12 -typedef enum { /* see 38.321 Table 7.1-2 RNTI usage */ - _c_rnti = _C_RNTI_, /* Cell RNTI */ - _cs_rnti = _CS_RNTI_, /* Configured Scheduling RNTI */ - _new_rnti = _NEW_RNTI_, /* ? */ - _tc_rnti = _TC_RNTI_, /* Temporary C-RNTI */ - _p_rnti = _P_RNTI_, /* Paging RNTI */ - _si_rnti = _SI_RNTI_, /* System information RNTI */ - _ra_rnti = _RA_RNTI_, /* Random Access RNTI */ - _sp_csi_rnti = _SP_CSI_RNTI_, /* Semipersistent CSI reporting on PUSCH */ - _sfi_rnti = _SFI_RNTI_, /* Slot Format Indication on the given cell */ - _int_rnti = _INT_RNTI_, /* Indication pre-emption in DL */ - _tpc_pusch_rnti = _TPC_PUSCH_RNTI_, /* PUSCH power control */ - _tpc_pucch_rnti = _TPC_PUCCH_RNTI_, /* PUCCH power control */ - _tpc_srs_rnti = _TPC_SRS_RNTI_ -} crc_scrambled_t; - #endif typedef struct { diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 2e4cef8cb9..4272485c4b 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -429,7 +429,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ case FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH: { dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; NR_UE_DLSCH_t *dlsch0 = &((nr_phy_data_t *)scheduled_response->phy_data)->dlsch[0]; - dlsch0->rnti_type = _RA_RNTI_; + dlsch0->rnti_type = TYPE_RA_RNTI_; dlsch0->dlsch_config = *dlsch_config_pdu; configure_dlsch(dlsch0, PHY_vars_UE_g[module_id][cc_id]->dl_harq_processes[0], dlsch_config_pdu, module_id, dl_config->dl_config_list[i].dlsch_config_pdu.rnti); @@ -437,7 +437,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ case FAPI_NR_DL_CONFIG_TYPE_SI_DLSCH: { dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; NR_UE_DLSCH_t *dlsch0 = &((nr_phy_data_t *)scheduled_response->phy_data)->dlsch[0]; - dlsch0->rnti_type = _SI_RNTI_; + dlsch0->rnti_type = TYPE_SI_RNTI_; dlsch0->dlsch_config = *dlsch_config_pdu; configure_dlsch(dlsch0, PHY_vars_UE_g[module_id][cc_id]->dl_harq_processes[0], dlsch_config_pdu, module_id, dl_config->dl_config_list[i].dlsch_config_pdu.rnti); @@ -445,7 +445,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ case FAPI_NR_DL_CONFIG_TYPE_DLSCH: { dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; NR_UE_DLSCH_t *dlsch0 = &((nr_phy_data_t *)scheduled_response->phy_data)->dlsch[0]; - dlsch0->rnti_type = _C_RNTI_; + dlsch0->rnti_type = TYPE_C_RNTI_; dlsch0->dlsch_config = *dlsch_config_pdu; configure_dlsch(dlsch0, PHY_vars_UE_g[module_id][cc_id]->dl_harq_processes[0], dlsch_config_pdu, module_id, dl_config->dl_config_list[i].dlsch_config_pdu.rnti); diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index caf6898f88..f9c6440067 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -138,9 +138,9 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int dci_ndi, int rv, uint8_t rnti_type) { - if (rnti_type == _SI_RNTI_ || - rnti_type == _P_RNTI_ || - rnti_type == _RA_RNTI_) { + if (rnti_type == TYPE_SI_RNTI_ || + rnti_type == TYPE_P_RNTI_ || + rnti_type == TYPE_RA_RNTI_) { dl_harq->DLround = 0; dl_harq->status = ACTIVE; dl_harq->first_rx = 1; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 266a72b0fe..f8547ed5b6 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -737,15 +737,15 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, int ind_type = -1; switch(dlsch[0].rnti_type) { - case _RA_RNTI_: + case TYPE_RA_RNTI_: ind_type = FAPI_NR_RX_PDU_TYPE_RAR; break; - case _SI_RNTI_: + case TYPE_SI_RNTI_: ind_type = FAPI_NR_RX_PDU_TYPE_SIB; break; - case _C_RNTI_: + case TYPE_C_RNTI_: ind_type = FAPI_NR_RX_PDU_TYPE_DLSCH; break; @@ -829,7 +829,6 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, ue->if_inst->dl_indication(&dl_indication); } - // DLSCH decoding finished! don't wait anymore const int ack_nack_slot = (proc->nr_slot_rx + dlsch[0].dlsch_config.k1_feedback) % ue->frame_parms.slots_per_frame; send_slot_ind(ue->tx_resume_ind_fifo[ack_nack_slot], proc->nr_slot_rx); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 812a2a59fb..30e84a8837 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -170,8 +170,14 @@ void nr_dlsim_preprocessor(module_id_t module_id, sched_pdsch->time_domain_allocation = get_dl_tda(RC.nrmac[module_id], scc, slot); AssertFatal(sched_pdsch->time_domain_allocation >= 0,"Unable to find PDSCH time domain allocation in list\n"); - sched_pdsch->tda_info = get_dl_tda_info(current_BWP, sched_ctrl->search_space->searchSpaceType->present, sched_pdsch->time_domain_allocation, - NR_MIB__dmrs_TypeA_Position_pos2, 1, NR_RNTI_C, sched_ctrl->coreset->controlResourceSetId, false); + sched_pdsch->tda_info = get_dl_tda_info(current_BWP, + sched_ctrl->search_space->searchSpaceType->present, + sched_pdsch->time_domain_allocation, + NR_MIB__dmrs_TypeA_Position_pos2, + 1, + TYPE_C_RNTI_, + sched_ctrl->coreset->controlResourceSetId, + false); sched_pdsch->dmrs_parms = get_dl_dmrs_params(scc, current_BWP, diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c index dc182b2106..3099adb11a 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c @@ -56,7 +56,7 @@ int test_harq_downlink(PHY_VARS_NR_UE *phy_vars_ue) int gNB_id = 0; int harq_pid = 0; int ndi = 1; - uint8_t rnti_type = _C_RNTI_; + uint8_t rnti_type = TYPE_C_RNTI_; int number_steps = 5; int thread_number = 0; int TB_identifier = 0; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 0df63710b2..a86835448d 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -451,23 +451,6 @@ typedef enum { NR_DCI_NONE } nr_dci_format_t; -typedef enum { - NR_RNTI_new = 0, - NR_RNTI_C, - NR_RNTI_RA, - NR_RNTI_P, - NR_RNTI_CS, - NR_RNTI_TC, - NR_RNTI_SP_CSI, - NR_RNTI_SI, - NR_RNTI_SFI, - NR_RNTI_INT, - NR_RNTI_TPC_PUSCH, - NR_RNTI_TPC_PUCCH, - NR_RNTI_TPC_SRS, - NR_RNTI_MCS_C, -} nr_rnti_type_t; - typedef enum channel_bandwidth_e { bw_5MHz = 0x1, bw_10MHz = 0x2, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 1080ee7faa..132bba2d0c 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -466,7 +466,11 @@ const uint8_t table_6_1_2_1_1_3[16][4] = { {0, 3, 0, 10} // row index 16 }; -NR_tda_info_t get_ul_tda_info(const NR_UE_UL_BWP_t *ul_bwp, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type, int tda_index) +NR_tda_info_t get_ul_tda_info(const NR_UE_UL_BWP_t *ul_bwp, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type, + int tda_index) { NR_tda_info_t tda_info = {0}; NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist = get_ul_tdalist(ul_bwp, controlResourceSetId, ss_type, rnti_type); @@ -604,8 +608,14 @@ NR_tda_info_t set_tda_info_from_list(NR_PDSCH_TimeDomainResourceAllocationList_t return tda_info; } -NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda_index, int dmrs_typeA_pos, - int mux_pattern, nr_rnti_type_t rnti_type, int coresetid, bool sib1) +NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, + int ss_type, + int tda_index, + int dmrs_typeA_pos, + int mux_pattern, + nr_rnti_type_t rnti_type, + int coresetid, + bool sib1) { NR_tda_info_t tda_info; bool normal_CP = true; @@ -614,7 +624,7 @@ NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda // implements Table 5.1.2.1.1-1 of 38.214 NR_PDSCH_TimeDomainResourceAllocationList_t *tdalist = get_dl_tdalist(dl_BWP, coresetid, ss_type, rnti_type); switch (rnti_type) { - case NR_RNTI_SI: + case TYPE_SI_RNTI_: if(sib1) { default_table_type_t table_type = get_default_table_type(mux_pattern); tda_info = get_info_from_tda_tables(table_type, tda_index, dmrs_typeA_pos, normal_CP); @@ -628,7 +638,7 @@ NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda } } break; - case NR_RNTI_P: + case TYPE_P_RNTI_: if(tdalist) tda_info = set_tda_info_from_list(tdalist, tda_index); else { @@ -636,11 +646,11 @@ NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda tda_info = get_info_from_tda_tables(table_type, tda_index, dmrs_typeA_pos, normal_CP); } break; - case NR_RNTI_C: - case NR_RNTI_CS: - case NR_RNTI_MCS_C: - case NR_RNTI_RA: - case NR_RNTI_TC: + case TYPE_C_RNTI_: + case TYPE_CS_RNTI_: + case TYPE_MCS_C_RNTI_: + case TYPE_RA_RNTI_: + case TYPE_TC_RNTI_: if(tdalist) tda_info = set_tda_info_from_list(tdalist, tda_index); else @@ -3227,21 +3237,29 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, return nbits; } -NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type) +NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type) { if (!DL_BWP) return NULL; // see table 5.1.2.1.1-1 in 38.214 - if ((rnti_type == NR_RNTI_CS || rnti_type == NR_RNTI_C || rnti_type == NR_RNTI_MCS_C) && !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) + if ((rnti_type == TYPE_CS_RNTI_ || rnti_type == TYPE_C_RNTI_ || rnti_type == TYPE_MCS_C_RNTI_) + && !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) && (DL_BWP->pdsch_Config && DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList)) return DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; else return DL_BWP->tdaList_Common; } -NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type) +NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type) { - if ((rnti_type == NR_RNTI_CS || rnti_type == NR_RNTI_C || rnti_type == NR_RNTI_MCS_C) && !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) + if ((rnti_type == TYPE_CS_RNTI_ || rnti_type == TYPE_C_RNTI_ || rnti_type == TYPE_MCS_C_RNTI_) + && !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) && (UL_BWP->pusch_Config && UL_BWP->pusch_Config->pusch_TimeDomainAllocationList)) return UL_BWP->pusch_Config->pusch_TimeDomainAllocationList->choice.setup; else @@ -3795,17 +3813,12 @@ uint8_t get_pdsch_mcs_table(long *mcs_Table, int dci_format, int rnti_type, int // Set downlink MCS table (Semi-persistent scheduling ignored for now) uint8_t mcsTableIdx = 0; // default value - if (mcs_Table && - *mcs_Table == NR_PDSCH_Config__mcs_Table_qam256 && - dci_format == NR_DL_DCI_FORMAT_1_1 && - rnti_type == NR_RNTI_C) + if (mcs_Table && *mcs_Table == NR_PDSCH_Config__mcs_Table_qam256 && dci_format == NR_DL_DCI_FORMAT_1_1 && rnti_type == TYPE_C_RNTI_) mcsTableIdx = 1; - else if (rnti_type != NR_RNTI_MCS_C && - mcs_Table && - *mcs_Table == NR_PDSCH_Config__mcs_Table_qam64LowSE && - ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific) + else if (rnti_type != TYPE_MCS_C_RNTI_ && mcs_Table && *mcs_Table == NR_PDSCH_Config__mcs_Table_qam64LowSE + && ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific) mcsTableIdx = 2; - else if (rnti_type == NR_RNTI_MCS_C) + else if (rnti_type == TYPE_MCS_C_RNTI_) mcsTableIdx = 2; LOG_D(NR_MAC,"DL MCS Table Index: %d\n", mcsTableIdx); @@ -3823,23 +3836,20 @@ uint8_t get_pusch_mcs_table(long *mcs_Table, // implementing 6.1.4.1 in 38.214 if (mcs_Table != NULL) { - if (config_grant || (rnti_type == NR_RNTI_CS)) { + if (config_grant || (rnti_type == TYPE_CS_RNTI_)) { if (*mcs_Table == NR_PUSCH_Config__mcs_Table_qam256) return 1; else return (2 + (is_tp << 1)); - } - else { - if ((*mcs_Table == NR_PUSCH_Config__mcs_Table_qam256) && - (dci_format == NR_UL_DCI_FORMAT_0_1) && - ((rnti_type == NR_RNTI_C ) || (rnti_type == NR_RNTI_SP_CSI))) + } else { + if ((*mcs_Table == NR_PUSCH_Config__mcs_Table_qam256) && (dci_format == NR_UL_DCI_FORMAT_0_1) + && ((rnti_type == TYPE_C_RNTI_) || (rnti_type == TYPE_SP_CSI_RNTI_))) return 1; // TODO take into account UE configuration - if ((*mcs_Table == NR_PUSCH_Config__mcs_Table_qam64LowSE) && - (target_ss == NR_SearchSpace__searchSpaceType_PR_ue_Specific) && - ((rnti_type == NR_RNTI_C ) || (rnti_type == NR_RNTI_SP_CSI))) + if ((*mcs_Table == NR_PUSCH_Config__mcs_Table_qam64LowSE) && (target_ss == NR_SearchSpace__searchSpaceType_PR_ue_Specific) + && ((rnti_type == TYPE_C_RNTI_) || (rnti_type == TYPE_SP_CSI_RNTI_))) return (2 + (is_tp << 1)); - if (rnti_type == NR_RNTI_MCS_C) + if (rnti_type == TYPE_MCS_C_RNTI_) return (2 + (is_tp << 1)); } } diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 315cc9837b..e84a3bb468 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -84,14 +84,30 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, const uint8_t *nrOfLayers, uint32_t *val); -NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type); +NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type); -NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type); +NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type); -NR_tda_info_t get_ul_tda_info(const NR_UE_UL_BWP_t *ul_bwp, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type, int tda_index); +NR_tda_info_t get_ul_tda_info(const NR_UE_UL_BWP_t *ul_bwp, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type, + int tda_index); -NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda_index, int dmrs_typeA_pos, - int mux_pattern, nr_rnti_type_t rnti_type, int coresetid, bool sib1); +NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, + int ss_type, + int tda_index, + int dmrs_typeA_pos, + int mux_pattern, + nr_rnti_type_t rnti_type, + int coresetid, + bool sib1); uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_extern.h b/openair2/LAYER2/NR_MAC_UE/mac_extern.h index 132e08c7f1..3019ba5219 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_extern.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_extern.h @@ -68,17 +68,14 @@ extern const uint16_t table_7_2_1[16]; extern dci_pdu_rel15_t *def_dci_pdu_rel15; -extern void mac_rlc_data_ind(const module_id_t module_idP, - const rnti_t rntiP, - const eNB_index_t eNB_index, - const frame_t frameP, - const eNB_flag_t enb_flagP, - const MBMS_flag_t MBMS_flagP, - const logical_chan_id_t channel_idP, - char *buffer_pP, - const tb_size_t tb_sizeP, - num_tb_t num_tbP, - crc_t *crcs_pP); - -extern const char *const rnti_types[]; -extern const char *const dci_formats[]; +extern void mac_rlc_data_ind(const module_id_t module_idP, + const rnti_t rntiP, + const eNB_index_t eNB_index, + const frame_t frameP, + const eNB_flag_t enb_flagP, + const MBMS_flag_t MBMS_flagP, + const logical_chan_id_t channel_idP, + char *buffer_pP, + const tb_size_t tb_sizeP, + num_tb_t num_tbP, + crc_t *crcs_pP); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_vars.c b/openair2/LAYER2/NR_MAC_UE/mac_vars.c index 43a3acf9eb..20abda978d 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_vars.c +++ b/openair2/LAYER2/NR_MAC_UE/mac_vars.c @@ -32,10 +32,6 @@ #include -const char* const rnti_types[] = - {"RNTI_new", "RNTI_C", "RNTI_RA", "NR_RNTI_P", "NR_RNTI_CS", "NR_RNTI_TC", "NR_RNTI_SP_CSI", "NR_RNTI_SI"}; -const char* const dci_formats[] = {"1_0", "1_1", "2_0", "2_1", "2_2", "2_3", "0_0", "0_1"}; - // table_7_3_1_1_2_2_3_4_5 contains values for number of layers and precoding information for tables 7.3.1.1.2-2/3/4/5 from TS 38.212 subclause 7.3.1.1.2 // the first 6 columns contain table 7.3.1.1.2-2: Precoding information and number of layers, for 4 antenna ports, if transformPrecoder=disabled and maxRank = 2 or 3 or 4 // next six columns contain table 7.3.1.1.2-3: Precoding information and number of layers for 4 antenna ports, if transformPrecoder= enabled, or if transformPrecoder=disabled and maxRank = 1 diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 1bd991f7c5..6a29028618 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -154,9 +154,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, rel15->coreset.pdcch_dmrs_scrambling_id = mac->physCellId; } - rel15->num_dci_options = (mac->ra.ra_state == WAIT_RAR || - rnti_type == NR_RNTI_SI) ? - 1 : 2; + rel15->num_dci_options = (mac->ra.ra_state == WAIT_RAR || rnti_type == TYPE_SI_RNTI_) ? 1 : 2; if (ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { if (ss->searchSpaceType->choice.ue_Specific->dci_Formats == @@ -234,7 +232,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, int sps = 0; switch(rnti_type) { - case NR_RNTI_C: + case TYPE_C_RNTI_: // we use DL BWP dedicated sps = current_DL_BWP->cyclicprefix ? 12 : 14; // for SPS=14 8 MSBs in positions 13 down to 6 @@ -242,27 +240,27 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, rel15->rnti = mac->crnti; rel15->SubcarrierSpacing = current_DL_BWP->scs; break; - case NR_RNTI_RA: + case TYPE_RA_RNTI_: // we use the initial DL BWP sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->ra.ra_rnti; rel15->SubcarrierSpacing = current_DL_BWP->scs; break; - case NR_RNTI_P: + case TYPE_P_RNTI_: break; - case NR_RNTI_CS: + case TYPE_CS_RNTI_: break; - case NR_RNTI_TC: + case TYPE_TC_RNTI_: // we use the initial DL BWP sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->ra.t_crnti; rel15->SubcarrierSpacing = current_DL_BWP->scs; break; - case NR_RNTI_SP_CSI: + case TYPE_SP_CSI_RNTI_: break; - case NR_RNTI_SI: + case TYPE_SI_RNTI_: sps = 14; // for SPS=14 8 MSBs in positions 13 down to 6 monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); @@ -271,15 +269,15 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, if(mac->frequency_range == FR2) rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; break; - case NR_RNTI_SFI: + case TYPE_SFI_RNTI_: break; - case NR_RNTI_INT: + case TYPE_INT_RNTI_: break; - case NR_RNTI_TPC_PUSCH: + case TYPE_TPC_PUSCH_RNTI_: break; - case NR_RNTI_TPC_PUCCH: + case TYPE_TPC_PUCCH_RNTI_: break; - case NR_RNTI_TPC_SRS: + case TYPE_TPC_SRS_RNTI_: break; default: break; @@ -492,7 +490,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl fill_searchSpaceZero(pdcch_config->search_space_zero, slots_per_frame, &mac->type0_PDCCH_CSS_config); if (is_ss_monitor_occasion(frame, slot, slots_per_frame, pdcch_config->search_space_zero)) { LOG_D(NR_MAC, "Monitoring DCI for SIB1 in frame %d slot %d\n", frame, slot); - config_dci_pdu(mac, dl_config, NR_RNTI_SI, slot, pdcch_config->search_space_zero); + config_dci_pdu(mac, dl_config, TYPE_SI_RNTI_, slot, pdcch_config->search_space_zero); } } if (mac->get_otherSI) { @@ -503,14 +501,14 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl // TODO configure SI-window if (monitior_dci_for_other_SI(mac, ss, slots_per_frame, frame, slot)) { LOG_D(NR_MAC, "Monitoring DCI for other SIs in frame %d slot %d\n", frame, slot); - config_dci_pdu(mac, dl_config, NR_RNTI_SI, slot, ss); + config_dci_pdu(mac, dl_config, TYPE_SI_RNTI_, slot, ss); } } if (mac->state == UE_PERFORMING_RA && mac->ra.ra_state >= WAIT_RAR) { // if RA is ongoing use RA search space if (is_ss_monitor_occasion(frame, slot, slots_per_frame, pdcch_config->ra_SS)) { - int rnti_type = mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC; + int rnti_type = mac->ra.ra_state == WAIT_RAR ? TYPE_RA_RNTI_ : TYPE_TC_RNTI_; config_dci_pdu(mac, dl_config, rnti_type, slot, pdcch_config->ra_SS); } } @@ -518,7 +516,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl for (int i = 0; i < pdcch_config->list_SS.count; i++) { NR_SearchSpace_t *ss = pdcch_config->list_SS.array[i]; if (is_ss_monitor_occasion(frame, slot, slots_per_frame, ss)) - config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, ss); + config_dci_pdu(mac, dl_config, TYPE_C_RNTI_, slot, ss); } if (pdcch_config->list_SS.count == 0 && pdcch_config->ra_SS) { // If the UE has not been provided a Type3-PDCCH CSS set or a USS set and @@ -526,7 +524,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl // the UE monitors PDCCH candidates for DCI format 0_0 and DCI format 1_0 // with CRC scrambled by the C-RNTI in the Type1-PDCCH CSS set if (is_ss_monitor_occasion(frame, slot, slots_per_frame, pdcch_config->ra_SS)) - config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, pdcch_config->ra_SS); + config_dci_pdu(mac, dl_config, TYPE_C_RNTI_, slot, pdcch_config->ra_SS); } } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 9118fce36a..c29d17d287 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -162,23 +162,23 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti) { RA_config_t *ra = &mac->ra; - int rnti_type; + nr_rnti_type_t rnti_type; if (rnti == ra->ra_rnti) { - rnti_type = NR_RNTI_RA; + rnti_type = TYPE_RA_RNTI_; } else if (rnti == ra->t_crnti && (ra->ra_state == WAIT_RAR || ra->ra_state == WAIT_CONTENTION_RESOLUTION) ) { - rnti_type = NR_RNTI_TC; + rnti_type = TYPE_TC_RNTI_; } else if (rnti == mac->crnti) { - rnti_type = NR_RNTI_C; + rnti_type = TYPE_C_RNTI_; } else if (rnti == 0xFFFE) { - rnti_type = NR_RNTI_P; + rnti_type = TYPE_P_RNTI_; } else if (rnti == 0xFFFF) { - rnti_type = NR_RNTI_SI; + rnti_type = TYPE_SI_RNTI_; } else { AssertFatal(1 == 0, "In %s: Not identified/handled rnti %d \n", __FUNCTION__, rnti); } - LOG_D(MAC, "In %s: returning rnti_type %s \n", __FUNCTION__, rnti_types[rnti_type]); + LOG_D(MAC, "Returning rnti_type %s \n", rnti_types(rnti_type)); return rnti_type; } @@ -1153,6 +1153,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, dci_pdu_rel15_t *dci, fapi_nr_dci_indication_pdu_t *dci_ind) { + const char *dci_formats[] = {"1_0", "1_1", "2_0", "2_1", "2_2", "2_3", "0_0", "0_1"}; LOG_D(MAC, "Processing received DCI format %s\n", dci_formats[dci_ind->dci_format]); switch (dci_ind->dci_format) { @@ -2851,11 +2852,11 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, case NR_DL_DCI_FORMAT_1_0: switch(rnti_type) { - case NR_RNTI_RA: - // Freq domain assignment - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - pos=fsize; - dci_pdu_rel15->frequency_domain_assignment.val = *dci_pdu>>(dci_size-pos)&((1<> 1)); + pos = fsize; + dci_pdu_rel15->frequency_domain_assignment.val = *dci_pdu >> (dci_size - pos) & ((1 << fsize) - 1); #ifdef DEBUG_EXTRACT_DCI LOG_D(MAC,"frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment.val,fsize,N_RB,dci_size-pos,*dci_pdu); #endif @@ -2886,17 +2887,17 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, #endif break; - case NR_RNTI_C: + case TYPE_C_RNTI_: - //Identifier for DCI formats - pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; + // Identifier for DCI formats + pos++; + dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; - //switch to DCI_0_0 - if (dci_pdu_rel15->format_indicator == 0) { - dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_UL_DCI_FORMAT_0_0]; - return 2 + nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); - } + // switch to DCI_0_0 + if (dci_pdu_rel15->format_indicator == 0) { + dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_UL_DCI_FORMAT_0_0]; + return 2 + nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); + } #ifdef DEBUG_EXTRACT_DCI LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu); #endif @@ -3011,83 +3012,83 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, } //end else break; - case NR_RNTI_P: - /* - // Short Messages Indicator  E2 bits - for (int i=0; i<2; i++) - dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages_indicator>>(1-i))&1)<<(dci_size-pos++); - // Short Messages  E8 bits - for (int i=0; i<8; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages>>(7-i))&1)<<(dci_size-pos++); - // Freq domain assignment 0-16 bit - fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); - for (int i=0; ifrequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++); - // Time domain assignment 4 bit - for (int i=0; i<4; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_size-pos++); - // VRB to PRB mapping 1 bit - *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val&1)<<(dci_size-pos++); - // MCS 5 bit - for (int i=0; i<5; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs>>(4-i))&1)<<(dci_size-pos++); - - // TB scaling 2 bit - for (int i=0; i<2; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->tb_scaling>>(1-i))&1)<<(dci_size-pos++); - */ - - break; - - case NR_RNTI_SI: - // Freq domain assignment 0-16 bit - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - pos+=fsize; - dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<short_messages_indicator>>(1-i))&1)<<(dci_size-pos++); + // Short Messages  E8 bits + for (int i=0; i<8; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages>>(7-i))&1)<<(dci_size-pos++); + // Freq domain assignment 0-16 bit + fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + for (int i=0; ifrequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++); + // Time domain assignment 4 bit + for (int i=0; i<4; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_size-pos++); + // VRB to PRB mapping 1 bit + *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val&1)<<(dci_size-pos++); + // MCS 5 bit + for (int i=0; i<5; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs>>(4-i))&1)<<(dci_size-pos++); - // Time domain assignment 4 bit - pos+=4; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0xf; + // TB scaling 2 bit + for (int i=0; i<2; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->tb_scaling>>(1-i))&1)<<(dci_size-pos++); + */ - // VRB to PRB mapping 1 bit - pos++; - dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&0x1; + break; - // MCS 5bit //bit over 32, so dci_pdu ++ - pos+=5; - dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f; + case TYPE_SI_RNTI_: + // Freq domain assignment 0-16 bit + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); + pos += fsize; + dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu >> (dci_size - pos)) & ((1 << fsize) - 1); - // Redundancy version 2 bit - pos+=2; - dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&3; + // Time domain assignment 4 bit + pos += 4; + dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu >> (dci_size - pos)) & 0xf; - // System information indicator 1 bit - pos++; - dci_pdu_rel15->system_info_indicator = (*dci_pdu>>(dci_size-pos))&0x1; + // VRB to PRB mapping 1 bit + pos++; + dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu >> (dci_size - pos)) & 0x1; - LOG_D(MAC,"N_RB = %i\n", N_RB); - LOG_D(MAC,"dci_size = %i\n", dci_size); - LOG_D(MAC,"fsize = %i\n", fsize); - LOG_D(MAC,"dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); - LOG_D(MAC,"dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); - LOG_D(MAC,"dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); - LOG_D(MAC,"dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); - LOG_D(MAC,"dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); - LOG_D(MAC,"dci_pdu_rel15->system_info_indicator = %i\n", dci_pdu_rel15->system_info_indicator); + // MCS 5bit //bit over 32, so dci_pdu ++ + pos += 5; + dci_pdu_rel15->mcs = (*dci_pdu >> (dci_size - pos)) & 0x1f; - break; - - case NR_RNTI_TC: + // Redundancy version 2 bit + pos += 2; + dci_pdu_rel15->rv = (*dci_pdu >> (dci_size - pos)) & 3; - // indicating a DL DCI format 1bit - pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; + // System information indicator 1 bit + pos++; + dci_pdu_rel15->system_info_indicator = (*dci_pdu >> (dci_size - pos)) & 0x1; - //switch to DCI_0_0 - if (dci_pdu_rel15->format_indicator == 0) { - dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_UL_DCI_FORMAT_0_0]; - return 2 + nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); - } + LOG_D(MAC, "N_RB = %i\n", N_RB); + LOG_D(MAC, "dci_size = %i\n", dci_size); + LOG_D(MAC, "fsize = %i\n", fsize); + LOG_D(MAC, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); + LOG_D(MAC, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); + LOG_D(MAC, "dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); + LOG_D(MAC, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); + LOG_D(MAC, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); + LOG_D(MAC, "dci_pdu_rel15->system_info_indicator = %i\n", dci_pdu_rel15->system_info_indicator); + + break; + + case TYPE_TC_RNTI_: + + // indicating a DL DCI format 1bit + pos++; + dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; + + // switch to DCI_0_0 + if (dci_pdu_rel15->format_indicator == 0) { + dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_UL_DCI_FORMAT_0_0]; + return 2 + nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); + } // Freq domain assignment 0-16 bit fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); @@ -3156,10 +3157,10 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, case NR_UL_DCI_FORMAT_0_0: switch(rnti_type) { - case NR_RNTI_C: - //Identifier for DCI formats + case TYPE_C_RNTI_: + // Identifier for DCI formats pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; + dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; #ifdef DEBUG_EXTRACT_DCI LOG_D(MAC,"Format indicator %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,dci_size-pos,*dci_pdu); #endif @@ -3219,11 +3220,11 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)ul_sul_indicator&1)<<(dci_size-pos++); */ break; - - case NR_RNTI_TC: - //Identifier for DCI formats + + case TYPE_TC_RNTI_: + // Identifier for DCI formats pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; + dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; #ifdef DEBUG_EXTRACT_DCI LOG_I(MAC,"Format indicator %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,dci_size-pos,*dci_pdu); #endif @@ -3290,10 +3291,10 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, case NR_DL_DCI_FORMAT_1_1: switch(rnti_type) { - case NR_RNTI_C: - //Identifier for DCI formats + case TYPE_C_RNTI_: + // Identifier for DCI formats pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; + dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; if (dci_pdu_rel15->format_indicator == 0) return 1; // discard dci, format indicator not corresponding to dci_format // Carrier indicator @@ -3380,7 +3381,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, case NR_UL_DCI_FORMAT_0_1: switch(rnti_type) { - case NR_RNTI_C: + case TYPE_C_RNTI_: //Identifier for DCI formats pos++; dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; @@ -4074,6 +4075,8 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) case 7: ra->Msg3_TPC = 8; break; + default: + LOG_E(NR_PHY, "RAR impossible msg3 TPC\n"); } // MCS rar_grant.mcs = (unsigned char) (rar->UL_GRANT_4 >> 4); @@ -4122,7 +4125,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) NR_tda_info_t tda_info = get_ul_tda_info(current_UL_BWP, *pdcch_config->ra_SS->controlResourceSetId, pdcch_config->ra_SS->searchSpaceType->present, - NR_RNTI_RA, + TYPE_RA_RNTI_, rar_grant.Msg3_t_alloc); if (tda_info.nrOfSymbols == 0) { LOG_E(MAC, "Cannot schedule Msg3. Something wrong in TDA information\n"); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 75e959f6cc..bf7703fa6d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -695,12 +695,13 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } } - LOG_D(NR_MAC, "Received UL grant (rb_start %d, rb_size %d, start_symbol_index %d, nr_of_symbols %d) for RNTI type %s \n", + LOG_D(NR_MAC, + "Received UL grant (rb_start %d, rb_size %d, start_symbol_index %d, nr_of_symbols %d) for RNTI type %s \n", pusch_config_pdu->rb_start, pusch_config_pdu->rb_size, pusch_config_pdu->start_symbol_index, pusch_config_pdu->nr_of_symbols, - rnti_types[rnti_type]); + rnti_types(rnti_type)); pusch_config_pdu->ul_dmrs_symb_pos = l_prime_mask; pusch_config_pdu->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 425782cddc..f20d97258e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -857,7 +857,7 @@ static void nr_generate_Msg3_retransmission(module_id_t module_idP, dci_pdu, &uldci_payload, NR_UL_DCI_FORMAT_0_0, - NR_RNTI_TC, + TYPE_TC_RNTI_, ul_bwp->bwp_id, ss, coreset, @@ -1215,8 +1215,14 @@ static void nr_generate_Msg2(module_id_t module_idP, // Calculate number of symbols int time_domain_assignment = get_dl_tda(nr_mac, scc, slotP); int mux_pattern = type0_PDCCH_CSS_config ? type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern : 1; - NR_tda_info_t tda_info = get_dl_tda_info(dl_bwp, ss->searchSpaceType->present, time_domain_assignment, - scc->dmrs_TypeA_Position, mux_pattern, NR_RNTI_RA, coresetid, false); + NR_tda_info_t tda_info = get_dl_tda_info(dl_bwp, + ss->searchSpaceType->present, + time_domain_assignment, + scc->dmrs_TypeA_Position, + mux_pattern, + TYPE_RA_RNTI_, + coresetid, + false); uint16_t *vrb_map = cc[CC_id].vrb_map; for (int i = 0; (i < rbSize) && (rbStart <= (BWPSize - rbSize)); i++) { @@ -1378,9 +1384,10 @@ static void nr_generate_Msg2(module_id_t module_idP, dci_payload.tb_scaling); LOG_D(NR_MAC, - "[RAPROC] DCI params: rnti 0x%x, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n", + "[RAPROC] DCI params: rnti 0x%x, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d " + "n_symb %d\n", pdcch_pdu_rel15->dci_pdu[0].RNTI, - NR_RNTI_RA, + TYPE_RA_RNTI_, NR_DL_DCI_FORMAT_1_0, *(unsigned long long *)pdcch_pdu_rel15->FreqDomainResource, pdcch_pdu_rel15->StartSymbolIndex, @@ -1392,7 +1399,7 @@ static void nr_generate_Msg2(module_id_t module_idP, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, NR_DL_DCI_FORMAT_1_0, - NR_RNTI_RA, + TYPE_RA_RNTI_, dl_bwp->bwp_id, ss, coreset, @@ -1605,9 +1612,10 @@ static void prepare_dl_pdus(gNB_MAC_INST *nr_mac, dci_payload.pdsch_to_harq_feedback_timing_indicator.val); LOG_D(NR_MAC, - "[RAPROC] DCI params: rnti 0x%x, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d, BWPsize %d\n", + "[RAPROC] DCI params: rnti 0x%x, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d " + "n_symb %d, BWPsize %d\n", pdcch_pdu_rel15->dci_pdu[0].RNTI, - NR_RNTI_TC, + TYPE_TC_RNTI_, NR_DL_DCI_FORMAT_1_0, (unsigned long long)pdcch_pdu_rel15->FreqDomainResource, pdcch_pdu_rel15->StartSymbolIndex, @@ -1620,7 +1628,7 @@ static void prepare_dl_pdus(gNB_MAC_INST *nr_mac, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, NR_DL_DCI_FORMAT_1_0, - NR_RNTI_TC, + TYPE_TC_RNTI_, dl_bwp->bwp_id, ss, coreset, @@ -1731,8 +1739,14 @@ static void nr_generate_Msg4(module_id_t module_idP, uint8_t time_domain_assignment = get_dl_tda(nr_mac, scc, slotP); int mux_pattern = type0_PDCCH_CSS_config ? type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern : 1; - NR_tda_info_t msg4_tda = get_dl_tda_info(dl_bwp, ss->searchSpaceType->present, time_domain_assignment, - scc->dmrs_TypeA_Position, mux_pattern, NR_RNTI_TC, coreset->controlResourceSetId, false); + NR_tda_info_t msg4_tda = get_dl_tda_info(dl_bwp, + ss->searchSpaceType->present, + time_domain_assignment, + scc->dmrs_TypeA_Position, + mux_pattern, + TYPE_TC_RNTI_, + coreset->controlResourceSetId, + false); NR_pdsch_dmrs_t dmrs_info = get_dl_dmrs_params(scc, dl_bwp, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 8227a78e01..624ee6d243 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -492,7 +492,7 @@ static void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, dci_payload.dmrs_sequence_initialization.val = pdsch_pdu_rel15->SCID; int dci_format = NR_DL_DCI_FORMAT_1_0; - int rnti_type = NR_RNTI_SI; + int rnti_type = TYPE_SI_RNTI_; fill_dci_pdu_rel15(NULL, NULL, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 7d525e3894..b3a4396410 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -443,8 +443,14 @@ static bool allocate_dl_retransmission(module_id_t module_id, /* Check first whether the old TDA can be reused * this helps allocate retransmission when TDA changes (e.g. new nrOfSymbols > old nrOfSymbols) */ - NR_tda_info_t temp_tda = get_dl_tda_info(dl_bwp, sched_ctrl->search_space->searchSpaceType->present, tda, - scc->dmrs_TypeA_Position, 1, NR_RNTI_C, coresetid, false); + NR_tda_info_t temp_tda = get_dl_tda_info(dl_bwp, + sched_ctrl->search_space->searchSpaceType->present, + tda, + scc->dmrs_TypeA_Position, + 1, + TYPE_C_RNTI_, + coresetid, + false); bool reuse_old_tda = (retInfo->tda_info.startSymbolIndex == temp_tda.startSymbolIndex) && (retInfo->tda_info.nrOfSymbols <= temp_tda.nrOfSymbols); LOG_D(NR_MAC, "[UE %x] %s old TDA, %s number of layers\n", @@ -757,8 +763,14 @@ static void pf_dl(module_id_t module_id, AssertFatal(sched_pdsch->time_domain_allocation>=0,"Unable to find PDSCH time domain allocation in list\n"); const int coresetid = sched_ctrl->coreset->controlResourceSetId; - sched_pdsch->tda_info = get_dl_tda_info(dl_bwp, sched_ctrl->search_space->searchSpaceType->present, sched_pdsch->time_domain_allocation, - scc->dmrs_TypeA_Position, 1, NR_RNTI_C, coresetid, false); + sched_pdsch->tda_info = get_dl_tda_info(dl_bwp, + sched_ctrl->search_space->searchSpaceType->present, + sched_pdsch->time_domain_allocation, + scc->dmrs_TypeA_Position, + 1, + TYPE_C_RNTI_, + coresetid, + false); NR_tda_info_t *tda_info = &sched_pdsch->tda_info; @@ -833,7 +845,8 @@ static void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_ const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; const int coresetid = sched_ctrl->coreset->controlResourceSetId; - const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = get_dl_tdalist(current_BWP, coresetid, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = + get_dl_tdalist(current_BWP, coresetid, sched_ctrl->search_space->searchSpaceType->present, TYPE_C_RNTI_); AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); @@ -1185,7 +1198,7 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.tpc, pucch->timing_indicator); - const int rnti_type = NR_RNTI_C; + const int rnti_type = TYPE_C_RNTI_; fill_dci_pdu_rel15(&UE->sc_info, current_BWP, &UE->current_UL_BWP, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 34b9911847..a604e13c25 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -61,8 +61,14 @@ void nr_preprocessor_phytest(module_id_t module_id, const int CC_id = 0; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); - NR_tda_info_t tda_info = get_dl_tda_info(dl_bwp, sched_ctrl->search_space->searchSpaceType->present, tda, - scc->dmrs_TypeA_Position, 1, NR_RNTI_C, sched_ctrl->coreset->controlResourceSetId, false); + NR_tda_info_t tda_info = get_dl_tda_info(dl_bwp, + sched_ctrl->search_space->searchSpaceType->present, + tda, + scc->dmrs_TypeA_Position, + 1, + TYPE_C_RNTI_, + sched_ctrl->coreset->controlResourceSetId, + false); sched_ctrl->sched_pdsch.tda_info = tda_info; sched_ctrl->sched_pdsch.time_domain_allocation = tda; @@ -210,7 +216,10 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; const int mu = ul_bwp->scs; - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = get_ul_tdalist(ul_bwp, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = get_ul_tdalist(ul_bwp, + sched_ctrl->coreset->controlResourceSetId, + sched_ctrl->search_space->searchSpaceType->present, + TYPE_C_RNTI_); const int temp_tda = get_ul_tda(nr_mac, scc, frame, slot); if (temp_tda < 0) return false; @@ -245,7 +254,11 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ else rbSize = target_ul_bw; - NR_tda_info_t tda_info = get_ul_tda_info(ul_bwp, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C, tda); + NR_tda_info_t tda_info = get_ul_tda_info(ul_bwp, + sched_ctrl->coreset->controlResourceSetId, + sched_ctrl->search_space->searchSpaceType->present, + TYPE_C_RNTI_, + tda); sched_ctrl->sched_pusch.tda_info = tda_info; const int buffer_index = ul_buffer_index(sched_frame, sched_slot, mu, nr_mac->vrb_map_UL_size); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index d2526c6c60..89ac444e63 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1206,441 +1206,461 @@ void fill_dci_pdu_rel15(const NR_UE_ServingCell_Info_t *servingCellInfo, switch (dci_format) { case NR_DL_DCI_FORMAT_1_0: switch (rnti_type) { - case NR_RNTI_RA: - // Freq domain assignment - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - pos = fsize; - *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << fsize) - 1)) << (dci_size - pos)); - LOG_D(NR_MAC, - "RA_RNTI, size %d frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n", - dci_size,dci_pdu_rel15->frequency_domain_assignment.val, - fsize, - N_RB, - dci_size - pos, - *dci_pdu); - // Time domain assignment - pos += 4; - *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val & 0xf) << (dci_size - pos)); - LOG_D(NR_MAC, - "time-domain assignment %d (4 bits)=> %d (0x%lx)\n", - dci_pdu_rel15->time_domain_assignment.val, - dci_size - pos, - *dci_pdu); - // VRB to PRB mapping - pos++; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 0x1) << (dci_size - pos); - LOG_D(NR_MAC, - "vrb to prb mapping %d (1 bits)=> %d (0x%lx)\n", - dci_pdu_rel15->vrb_to_prb_mapping.val, - dci_size - pos, - *dci_pdu); - // MCS - pos += 5; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); - LOG_D(NR_MAC, "mcs %d (5 bits)=> %d (0x%lx)\n", dci_pdu_rel15->mcs, dci_size - pos, *dci_pdu); - // TB scaling - pos += 2; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->tb_scaling & 0x3) << (dci_size - pos); - LOG_D(NR_MAC, "tb_scaling %d (2 bits)=> %d (0x%lx)\n", dci_pdu_rel15->tb_scaling, dci_size - pos, *dci_pdu); - break; - - case NR_RNTI_C: - // indicating a DL DCI format 1bit - pos++; - *dci_pdu |= ((uint64_t)1) << (dci_size - pos); - LOG_D(NR_MAC, - "DCI1_0 (size %d): Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n", - dci_size, - dci_pdu_rel15->format_indicator, - 1, - N_RB, - dci_size - pos, - *dci_pdu); - // Freq domain assignment (275rb >> fsize = 16) - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - pos += fsize; - *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << fsize) - 1)) << (dci_size - pos)); - LOG_D(NR_MAC, - "Freq domain assignment %d (%d bits)=> %d (0x%lx)\n", - dci_pdu_rel15->frequency_domain_assignment.val, - fsize, - dci_size - pos, - *dci_pdu); - uint16_t is_ra = 1; - for (int i = 0; i < fsize; i++) { - if (!((dci_pdu_rel15->frequency_domain_assignment.val >> i) & 1)) { - is_ra = 0; - break; - } - } - if (is_ra) { // fsize are all 1 38.212 p86 - // ra_preamble_index 6 bits - pos += 6; - *dci_pdu |= ((dci_pdu_rel15->ra_preamble_index & 0x3f) << (dci_size - pos)); - // UL/SUL indicator 1 bit - pos++; - *dci_pdu |= (dci_pdu_rel15->ul_sul_indicator.val & 1) << (dci_size - pos); - // SS/PBCH index 6 bits - pos += 6; - *dci_pdu |= ((dci_pdu_rel15->ss_pbch_index & 0x3f) << (dci_size - pos)); - // prach_mask_index 4 bits - pos += 4; - *dci_pdu |= ((dci_pdu_rel15->prach_mask_index & 0xf) << (dci_size - pos)); - } else { - // Time domain assignment 4bit - pos += 4; - *dci_pdu |= ((dci_pdu_rel15->time_domain_assignment.val & 0xf) << (dci_size - pos)); + case TYPE_RA_RNTI_: + // Freq domain assignment + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); + pos = fsize; + *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << fsize) - 1)) << (dci_size - pos)); LOG_D(NR_MAC, - "Time domain assignment %d (%d bits)=> %d (0x%lx)\n", + "RA_RNTI, size %d frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n", + dci_size, + dci_pdu_rel15->frequency_domain_assignment.val, + fsize, + N_RB, + dci_size - pos, + *dci_pdu); + // Time domain assignment + pos += 4; + *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val & 0xf) << (dci_size - pos)); + LOG_D(NR_MAC, + "time-domain assignment %d (4 bits)=> %d (0x%lx)\n", dci_pdu_rel15->time_domain_assignment.val, - 4, dci_size - pos, *dci_pdu); - // VRB to PRB mapping 1bit + // VRB to PRB mapping pos++; - *dci_pdu |= (dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos); + *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 0x1) << (dci_size - pos); LOG_D(NR_MAC, - "VRB to PRB %d (%d bits)=> %d (0x%lx)\n", + "vrb to prb mapping %d (1 bits)=> %d (0x%lx)\n", dci_pdu_rel15->vrb_to_prb_mapping.val, - 1, dci_size - pos, *dci_pdu); - // MCS 5bit //bit over 32, so dci_pdu ++ + // MCS pos += 5; - *dci_pdu |= (dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); - LOG_D(NR_MAC, "MCS %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->mcs, 5, dci_size - pos, *dci_pdu); - // New data indicator 1bit + *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); + LOG_D(NR_MAC, "mcs %d (5 bits)=> %d (0x%lx)\n", dci_pdu_rel15->mcs, dci_size - pos, *dci_pdu); + // TB scaling + pos += 2; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->tb_scaling & 0x3) << (dci_size - pos); + LOG_D(NR_MAC, "tb_scaling %d (2 bits)=> %d (0x%lx)\n", dci_pdu_rel15->tb_scaling, dci_size - pos, *dci_pdu); + break; + + case TYPE_C_RNTI_: + // indicating a DL DCI format 1bit pos++; - *dci_pdu |= (dci_pdu_rel15->ndi & 1) << (dci_size - pos); - LOG_D(NR_MAC, "NDI %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->ndi, 1, dci_size - pos, *dci_pdu); + *dci_pdu |= ((uint64_t)1) << (dci_size - pos); + LOG_D(NR_MAC, + "DCI1_0 (size %d): Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n", + dci_size, + dci_pdu_rel15->format_indicator, + 1, + N_RB, + dci_size - pos, + *dci_pdu); + // Freq domain assignment (275rb >> fsize = 16) + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); + pos += fsize; + *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << fsize) - 1)) << (dci_size - pos)); + LOG_D(NR_MAC, + "Freq domain assignment %d (%d bits)=> %d (0x%lx)\n", + dci_pdu_rel15->frequency_domain_assignment.val, + fsize, + dci_size - pos, + *dci_pdu); + uint16_t is_ra = 1; + for (int i = 0; i < fsize; i++) { + if (!((dci_pdu_rel15->frequency_domain_assignment.val >> i) & 1)) { + is_ra = 0; + break; + } + } + if (is_ra) { // fsize are all 1 38.212 p86 + // ra_preamble_index 6 bits + pos += 6; + *dci_pdu |= ((dci_pdu_rel15->ra_preamble_index & 0x3f) << (dci_size - pos)); + // UL/SUL indicator 1 bit + pos++; + *dci_pdu |= (dci_pdu_rel15->ul_sul_indicator.val & 1) << (dci_size - pos); + // SS/PBCH index 6 bits + pos += 6; + *dci_pdu |= ((dci_pdu_rel15->ss_pbch_index & 0x3f) << (dci_size - pos)); + // prach_mask_index 4 bits + pos += 4; + *dci_pdu |= ((dci_pdu_rel15->prach_mask_index & 0xf) << (dci_size - pos)); + } else { + // Time domain assignment 4bit + pos += 4; + *dci_pdu |= ((dci_pdu_rel15->time_domain_assignment.val & 0xf) << (dci_size - pos)); + LOG_D(NR_MAC, + "Time domain assignment %d (%d bits)=> %d (0x%lx)\n", + dci_pdu_rel15->time_domain_assignment.val, + 4, + dci_size - pos, + *dci_pdu); + // VRB to PRB mapping 1bit + pos++; + *dci_pdu |= (dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos); + LOG_D(NR_MAC, + "VRB to PRB %d (%d bits)=> %d (0x%lx)\n", + dci_pdu_rel15->vrb_to_prb_mapping.val, + 1, + dci_size - pos, + *dci_pdu); + // MCS 5bit //bit over 32, so dci_pdu ++ + pos += 5; + *dci_pdu |= (dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); + LOG_D(NR_MAC, "MCS %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->mcs, 5, dci_size - pos, *dci_pdu); + // New data indicator 1bit + pos++; + *dci_pdu |= (dci_pdu_rel15->ndi & 1) << (dci_size - pos); + LOG_D(NR_MAC, "NDI %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->ndi, 1, dci_size - pos, *dci_pdu); + // Redundancy version 2bit + pos += 2; + *dci_pdu |= (dci_pdu_rel15->rv & 0x3) << (dci_size - pos); + LOG_D(NR_MAC, "RV %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->rv, 2, dci_size - pos, *dci_pdu); + // HARQ process number 4bit + pos += 4; + *dci_pdu |= ((dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos)); + LOG_D(NR_MAC, "HARQ_PID %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->harq_pid, 4, dci_size - pos, *dci_pdu); + // Downlink assignment index 2bit + pos += 2; + *dci_pdu |= ((dci_pdu_rel15->dai[0].val & 3) << (dci_size - pos)); + LOG_D(NR_MAC, "DAI %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->dai[0].val, 2, dci_size - pos, *dci_pdu); + // TPC command for scheduled PUCCH 2bit + pos += 2; + *dci_pdu |= ((dci_pdu_rel15->tpc & 3) << (dci_size - pos)); + LOG_D(NR_MAC, "TPC %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->tpc, 2, dci_size - pos, *dci_pdu); + // PUCCH resource indicator 3bit + pos += 3; + *dci_pdu |= ((dci_pdu_rel15->pucch_resource_indicator & 0x7) << (dci_size - pos)); + LOG_D(NR_MAC, + "PUCCH RI %d (%d bits)=> %d (0x%lx)\n", + dci_pdu_rel15->pucch_resource_indicator, + 3, + dci_size - pos, + *dci_pdu); + // PDSCH-to-HARQ_feedback timing indicator 3bit + pos += 3; + *dci_pdu |= ((dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val & 0x7) << (dci_size - pos)); + LOG_D(NR_MAC, + "PDSCH to HARQ TI %d (%d bits)=> %d (0x%lx)\n", + dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val, + 3, + dci_size - pos, + *dci_pdu); + } // end else + break; + + case TYPE_P_RNTI_: + // Short Messages Indicator – 2 bits + for (int i = 0; i < 2; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages_indicator >> (1 - i)) & 1) << (dci_size - pos++); + // Short Messages – 8 bits + for (int i = 0; i < 8; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages >> (7 - i)) & 1) << (dci_size - pos++); + // Freq domain assignment 0-16 bit + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); + for (int i = 0; i < fsize; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val >> (fsize - i - 1)) & 1) << (dci_size - pos++); + // Time domain assignment 4 bit + for (int i = 0; i < 4; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val >> (3 - i)) & 1) << (dci_size - pos++); + // VRB to PRB mapping 1 bit + *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos++); + // MCS 5 bit + for (int i = 0; i < 5; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs >> (4 - i)) & 1) << (dci_size - pos++); + // TB scaling 2 bit + for (int i = 0; i < 2; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->tb_scaling >> (1 - i)) & 1) << (dci_size - pos++); + break; + + case TYPE_SI_RNTI_: + pos = 1; + // Freq domain assignment 0-16 bit + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); + LOG_D(NR_MAC, "fsize = %i\n", fsize); + for (int i = 0; i < fsize; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val >> (fsize - i - 1)) & 1) << (dci_size - pos++); + LOG_D(NR_MAC, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); + // Time domain assignment 4 bit + for (int i = 0; i < 4; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val >> (3 - i)) & 1) << (dci_size - pos++); + LOG_D(NR_MAC, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); + // VRB to PRB mapping 1 bit + *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos++); + LOG_D(NR_MAC, "dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); + // MCS 5bit //bit over 32, so dci_pdu ++ + for (int i = 0; i < 5; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs >> (4 - i)) & 1) << (dci_size - pos++); + LOG_D(NR_MAC, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); // Redundancy version 2bit - pos += 2; - *dci_pdu |= (dci_pdu_rel15->rv & 0x3) << (dci_size - pos); - LOG_D(NR_MAC, "RV %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->rv, 2, dci_size - pos, *dci_pdu); + for (int i = 0; i < 2; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv >> (1 - i)) & 1) << (dci_size - pos++); + LOG_D(NR_MAC, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); + // System information indicator 1bit + *dci_pdu |= ((uint64_t)dci_pdu_rel15->system_info_indicator & 1) << (dci_size - pos++); + LOG_D(NR_MAC, "dci_pdu_rel15->system_info_indicator = %i\n", dci_pdu_rel15->system_info_indicator); + break; + + case TYPE_TC_RNTI_: + pos = 1; + // indicating a DL DCI format 1bit + *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos++); + // Freq domain assignment 0-16 bit + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); + for (int i = 0; i < fsize; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val >> (fsize - i - 1)) & 1) << (dci_size - pos++); + // Time domain assignment 4 bit + for (int i = 0; i < 4; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val >> (3 - i)) & 1) << (dci_size - pos++); + // VRB to PRB mapping 1 bit + *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos++); + // MCS 5bit //bit over 32, so dci_pdu ++ + for (int i = 0; i < 5; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs >> (4 - i)) & 1) << (dci_size - pos++); + // New data indicator 1bit + *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi & 1) << (dci_size - pos++); + // Redundancy version 2bit + for (int i = 0; i < 2; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv >> (1 - i)) & 1) << (dci_size - pos++); // HARQ process number 4bit - pos += 4; - *dci_pdu |= ((dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos)); - LOG_D(NR_MAC, "HARQ_PID %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->harq_pid, 4, dci_size - pos, *dci_pdu); - // Downlink assignment index 2bit - pos += 2; - *dci_pdu |= ((dci_pdu_rel15->dai[0].val & 3) << (dci_size - pos)); - LOG_D(NR_MAC, "DAI %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->dai[0].val, 2, dci_size - pos, *dci_pdu); - // TPC command for scheduled PUCCH 2bit - pos += 2; - *dci_pdu |= ((dci_pdu_rel15->tpc & 3) << (dci_size - pos)); - LOG_D(NR_MAC, "TPC %d (%d bits)=> %d (0x%lx)\n", dci_pdu_rel15->tpc, 2, dci_size - pos, *dci_pdu); - // PUCCH resource indicator 3bit - pos += 3; - *dci_pdu |= ((dci_pdu_rel15->pucch_resource_indicator & 0x7) << (dci_size - pos)); + for (int i = 0; i < 4; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->harq_pid >> (3 - i)) & 1) << (dci_size - pos++); + // Downlink assignment index – 2 bits + for (int i = 0; i < 2; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->dai[0].val >> (1 - i)) & 1) << (dci_size - pos++); + // TPC command for scheduled PUCCH – 2 bits + for (int i = 0; i < 2; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->tpc >> (1 - i)) & 1) << (dci_size - pos++); + // PUCCH resource indicator – 3 bits + for (int i = 0; i < 3; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->pucch_resource_indicator >> (2 - i)) & 1) << (dci_size - pos++); + // PDSCH-to-HARQ_feedback timing indicator – 3 bits + for (int i = 0; i < 3; i++) + *dci_pdu |= (((uint64_t)dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val >> (2 - i)) & 1) << (dci_size - pos++); + + LOG_D(NR_MAC, "N_RB = %i\n", N_RB); + LOG_D(NR_MAC, "dci_size = %i\n", dci_size); + LOG_D(NR_MAC, "fsize = %i\n", fsize); + LOG_D(NR_MAC, "dci_pdu_rel15->format_indicator = %i\n", dci_pdu_rel15->format_indicator); + LOG_D(NR_MAC, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); + LOG_D(NR_MAC, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); + LOG_D(NR_MAC, "dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); + LOG_D(NR_MAC, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); + LOG_D(NR_MAC, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); + LOG_D(NR_MAC, "dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid); + LOG_D(NR_MAC, "dci_pdu_rel15->dai[0].val = %i\n", dci_pdu_rel15->dai[0].val); + LOG_D(NR_MAC, "dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc); LOG_D(NR_MAC, - "PUCCH RI %d (%d bits)=> %d (0x%lx)\n", - dci_pdu_rel15->pucch_resource_indicator, - 3, - dci_size - pos, - *dci_pdu); - // PDSCH-to-HARQ_feedback timing indicator 3bit - pos += 3; - *dci_pdu |= ((dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val & 0x7) << (dci_size - pos)); - LOG_D(NR_MAC, - "PDSCH to HARQ TI %d (%d bits)=> %d (0x%lx)\n", - dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val, - 3, - dci_size - pos, - *dci_pdu); - } // end else - break; + "dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = %i\n", + dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val); - case NR_RNTI_P: - // Short Messages Indicator – 2 bits - for (int i = 0; i < 2; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages_indicator >> (1 - i)) & 1) << (dci_size - pos++); - // Short Messages – 8 bits - for (int i = 0; i < 8; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages >> (7 - i)) & 1) << (dci_size - pos++); - // Freq domain assignment 0-16 bit - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - for (int i = 0; i < fsize; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val >> (fsize - i - 1)) & 1) << (dci_size - pos++); - // Time domain assignment 4 bit - for (int i = 0; i < 4; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val >> (3 - i)) & 1) << (dci_size - pos++); - // VRB to PRB mapping 1 bit - *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos++); - // MCS 5 bit - for (int i = 0; i < 5; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs >> (4 - i)) & 1) << (dci_size - pos++); - // TB scaling 2 bit - for (int i = 0; i < 2; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->tb_scaling >> (1 - i)) & 1) << (dci_size - pos++); - break; - - case NR_RNTI_SI: - pos = 1; - // Freq domain assignment 0-16 bit - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - LOG_D(NR_MAC, "fsize = %i\n", fsize); - for (int i = 0; i < fsize; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val >> (fsize - i - 1)) & 1) << (dci_size - pos++); - LOG_D(NR_MAC, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); - // Time domain assignment 4 bit - for (int i = 0; i < 4; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val >> (3 - i)) & 1) << (dci_size - pos++); - LOG_D(NR_MAC, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); - // VRB to PRB mapping 1 bit - *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos++); - LOG_D(NR_MAC, "dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); - // MCS 5bit //bit over 32, so dci_pdu ++ - for (int i = 0; i < 5; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs >> (4 - i)) & 1) << (dci_size - pos++); - LOG_D(NR_MAC, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); - // Redundancy version 2bit - for (int i = 0; i < 2; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv >> (1 - i)) & 1) << (dci_size - pos++); - LOG_D(NR_MAC, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); - // System information indicator 1bit - *dci_pdu |= ((uint64_t)dci_pdu_rel15->system_info_indicator&1)<<(dci_size-pos++); - LOG_D(NR_MAC, "dci_pdu_rel15->system_info_indicator = %i\n", dci_pdu_rel15->system_info_indicator); - break; - - case NR_RNTI_TC: - pos = 1; - // indicating a DL DCI format 1bit - *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos++); - // Freq domain assignment 0-16 bit - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - for (int i = 0; i < fsize; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val >> (fsize - i - 1)) & 1) << (dci_size - pos++); - // Time domain assignment 4 bit - for (int i = 0; i < 4; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val >> (3 - i)) & 1) << (dci_size - pos++); - // VRB to PRB mapping 1 bit - *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos++); - // MCS 5bit //bit over 32, so dci_pdu ++ - for (int i = 0; i < 5; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs >> (4 - i)) & 1) << (dci_size - pos++); - // New data indicator 1bit - *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi & 1) << (dci_size - pos++); - // Redundancy version 2bit - for (int i = 0; i < 2; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv >> (1 - i)) & 1) << (dci_size - pos++); - // HARQ process number 4bit - for (int i = 0; i < 4; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->harq_pid >> (3 - i)) & 1) << (dci_size - pos++); - // Downlink assignment index – 2 bits - for (int i = 0; i < 2; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->dai[0].val >> (1 - i)) & 1) << (dci_size - pos++); - // TPC command for scheduled PUCCH – 2 bits - for (int i = 0; i < 2; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->tpc >> (1 - i)) & 1) << (dci_size - pos++); - // PUCCH resource indicator – 3 bits - for (int i = 0; i < 3; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->pucch_resource_indicator >> (2 - i)) & 1) << (dci_size - pos++); - // PDSCH-to-HARQ_feedback timing indicator – 3 bits - for (int i = 0; i < 3; i++) - *dci_pdu |= (((uint64_t)dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val >> (2 - i)) & 1) << (dci_size - pos++); - - LOG_D(NR_MAC,"N_RB = %i\n", N_RB); - LOG_D(NR_MAC,"dci_size = %i\n", dci_size); - LOG_D(NR_MAC,"fsize = %i\n", fsize); - LOG_D(NR_MAC,"dci_pdu_rel15->format_indicator = %i\n", dci_pdu_rel15->format_indicator); - LOG_D(NR_MAC,"dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); - LOG_D(NR_MAC,"dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); - LOG_D(NR_MAC,"dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); - LOG_D(NR_MAC,"dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); - LOG_D(NR_MAC,"dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); - LOG_D(NR_MAC,"dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid); - LOG_D(NR_MAC,"dci_pdu_rel15->dai[0].val = %i\n", dci_pdu_rel15->dai[0].val); - LOG_D(NR_MAC,"dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc); - LOG_D(NR_MAC,"dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = %i\n", dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val); - - break; + break; } break; case NR_UL_DCI_FORMAT_0_0: switch (rnti_type) { - case NR_RNTI_C: - LOG_D(NR_MAC,"Filling format 0_0 DCI for CRNTI (size %d bits, format ind %d)\n",dci_size,dci_pdu_rel15->format_indicator); - // indicating a UL DCI format 1bit - pos=1; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos); - // Freq domain assignment max 16 bit - fsize = dci_pdu_rel15->frequency_domain_assignment.nbits; - pos+=fsize; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << fsize) - 1)) << (dci_size - pos); - // Time domain assignment 4bit - pos += 4; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->time_domain_assignment.val & ((1 << 4) - 1)) << (dci_size - pos); - // Frequency hopping flag – 1 bit - pos++; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag.val & 1) << (dci_size - pos); - // MCS 5 bit - pos+=5; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); - // New data indicator 1bit - pos++; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi & 1) << (dci_size - pos); - // Redundancy version 2bit - pos+=2; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->rv & 0x3) << (dci_size - pos); - // HARQ process number 4bit - pos+=4; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos); - // TPC command for scheduled PUSCH – 2 bits - pos+=2; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->tpc & 0x3) << (dci_size - pos); - // Padding bits - for (int a = pos; a < dci_size; a++) - *dci_pdu |= ((uint64_t)dci_pdu_rel15->padding & 1) << (dci_size - pos++); - // UL/SUL indicator – 1 bit - /* commented for now (RK): need to get this from BWP descriptor - if (cfg->pucch_config.pucch_GroupHopping.value) - *dci_pdu |= - ((uint64_t)dci_pdu_rel15->ul_sul_indicator.val&1)<<(dci_size-pos++); - */ + case TYPE_C_RNTI_: + LOG_D(NR_MAC, + "Filling format 0_0 DCI for CRNTI (size %d bits, format ind %d)\n", + dci_size, + dci_pdu_rel15->format_indicator); + // indicating a UL DCI format 1bit + pos = 1; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos); + // Freq domain assignment max 16 bit + fsize = dci_pdu_rel15->frequency_domain_assignment.nbits; + pos += fsize; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << fsize) - 1)) << (dci_size - pos); + // Time domain assignment 4bit + pos += 4; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->time_domain_assignment.val & ((1 << 4) - 1)) << (dci_size - pos); + // Frequency hopping flag – 1 bit + pos++; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag.val & 1) << (dci_size - pos); + // MCS 5 bit + pos += 5; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); + // New data indicator 1bit + pos++; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi & 1) << (dci_size - pos); + // Redundancy version 2bit + pos += 2; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->rv & 0x3) << (dci_size - pos); + // HARQ process number 4bit + pos += 4; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos); + // TPC command for scheduled PUSCH – 2 bits + pos += 2; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->tpc & 0x3) << (dci_size - pos); + // Padding bits + for (int a = pos; a < dci_size; a++) + *dci_pdu |= ((uint64_t)dci_pdu_rel15->padding & 1) << (dci_size - pos++); + // UL/SUL indicator – 1 bit + /* commented for now (RK): need to get this from BWP descriptor + if (cfg->pucch_config.pucch_GroupHopping.value) + *dci_pdu |= + ((uint64_t)dci_pdu_rel15->ul_sul_indicator.val&1)<<(dci_size-pos++); + */ - LOG_D(NR_MAC,"N_RB = %i\n", N_RB); - LOG_D(NR_MAC,"dci_size = %i\n", dci_size); - LOG_D(NR_MAC,"fsize = %i\n", fsize); - LOG_D(NR_MAC,"dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); - LOG_D(NR_MAC,"dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); - LOG_D(NR_MAC,"dci_pdu_rel15->frequency_hopping_flag.val = %i\n", dci_pdu_rel15->frequency_hopping_flag.val); - LOG_D(NR_MAC,"dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); - LOG_D(NR_MAC,"dci_pdu_rel15->ndi = %i\n", dci_pdu_rel15->ndi); - LOG_D(NR_MAC,"dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); - LOG_D(NR_MAC,"dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid); - LOG_D(NR_MAC,"dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc); - LOG_D(NR_MAC,"dci_pdu_rel15->padding = %i\n", dci_pdu_rel15->padding); - break; + LOG_D(NR_MAC, "N_RB = %i\n", N_RB); + LOG_D(NR_MAC, "dci_size = %i\n", dci_size); + LOG_D(NR_MAC, "fsize = %i\n", fsize); + LOG_D(NR_MAC, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); + LOG_D(NR_MAC, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); + LOG_D(NR_MAC, "dci_pdu_rel15->frequency_hopping_flag.val = %i\n", dci_pdu_rel15->frequency_hopping_flag.val); + LOG_D(NR_MAC, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); + LOG_D(NR_MAC, "dci_pdu_rel15->ndi = %i\n", dci_pdu_rel15->ndi); + LOG_D(NR_MAC, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); + LOG_D(NR_MAC, "dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid); + LOG_D(NR_MAC, "dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc); + LOG_D(NR_MAC, "dci_pdu_rel15->padding = %i\n", dci_pdu_rel15->padding); + break; - case NFAPI_NR_RNTI_TC: - // indicating a UL DCI format 1bit - pos=1; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos); - // Freq domain assignment max 16 bit - fsize = dci_pdu_rel15->frequency_domain_assignment.nbits; - pos+=fsize; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << fsize) - 1)) << (dci_size - pos); - // Time domain assignment 4bit - pos += 4; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->time_domain_assignment.val & ((1 << 4) - 1)) << (dci_size - pos); - // Frequency hopping flag – 1 bit - pos++; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag.val & 1) << (dci_size - pos); - // MCS 5 bit - pos+=5; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); - // New data indicator 1bit - pos++; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi & 1) << (dci_size - pos); - // Redundancy version 2bit - pos+=2; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->rv & 0x3) << (dci_size - pos); - // HARQ process number 4bit - pos+=4; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos); - // Padding bits - for (int a = pos; a < dci_size; a++) - *dci_pdu |= ((uint64_t)dci_pdu_rel15->padding & 1) << (dci_size - pos++); - // UL/SUL indicator – 1 bit - /* commented for now (RK): need to get this from BWP descriptor - if (cfg->pucch_config.pucch_GroupHopping.value) - *dci_pdu |= - ((uint64_t)dci_pdu_rel15->ul_sul_indicator.val&1)<<(dci_size-pos++); - */ - LOG_D(NR_MAC,"N_RB = %i\n", N_RB); - LOG_D(NR_MAC,"dci_size = %i\n", dci_size); - LOG_D(NR_MAC,"fsize = %i\n", fsize); - LOG_D(NR_MAC,"dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); - LOG_D(NR_MAC,"dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); - LOG_D(NR_MAC,"dci_pdu_rel15->frequency_hopping_flag.val = %i\n", dci_pdu_rel15->frequency_hopping_flag.val); - LOG_D(NR_MAC,"dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); - LOG_D(NR_MAC,"dci_pdu_rel15->ndi = %i\n", dci_pdu_rel15->ndi); - LOG_D(NR_MAC,"dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); - LOG_D(NR_MAC,"dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid); - LOG_D(NR_MAC,"dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc); - LOG_D(NR_MAC,"dci_pdu_rel15->padding = %i\n", dci_pdu_rel15->padding); + case TYPE_TC_RNTI_: + // indicating a UL DCI format 1bit + pos = 1; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos); + // Freq domain assignment max 16 bit + fsize = dci_pdu_rel15->frequency_domain_assignment.nbits; + pos += fsize; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << fsize) - 1)) << (dci_size - pos); + // Time domain assignment 4bit + pos += 4; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->time_domain_assignment.val & ((1 << 4) - 1)) << (dci_size - pos); + // Frequency hopping flag – 1 bit + pos++; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag.val & 1) << (dci_size - pos); + // MCS 5 bit + pos += 5; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); + // New data indicator 1bit + pos++; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi & 1) << (dci_size - pos); + // Redundancy version 2bit + pos += 2; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->rv & 0x3) << (dci_size - pos); + // HARQ process number 4bit + pos += 4; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos); + // Padding bits + for (int a = pos; a < dci_size; a++) + *dci_pdu |= ((uint64_t)dci_pdu_rel15->padding & 1) << (dci_size - pos++); + // UL/SUL indicator – 1 bit + /* commented for now (RK): need to get this from BWP descriptor + if (cfg->pucch_config.pucch_GroupHopping.value) + *dci_pdu |= + ((uint64_t)dci_pdu_rel15->ul_sul_indicator.val&1)<<(dci_size-pos++); + */ + LOG_D(NR_MAC, "N_RB = %i\n", N_RB); + LOG_D(NR_MAC, "dci_size = %i\n", dci_size); + LOG_D(NR_MAC, "fsize = %i\n", fsize); + LOG_D(NR_MAC, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); + LOG_D(NR_MAC, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); + LOG_D(NR_MAC, "dci_pdu_rel15->frequency_hopping_flag.val = %i\n", dci_pdu_rel15->frequency_hopping_flag.val); + LOG_D(NR_MAC, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); + LOG_D(NR_MAC, "dci_pdu_rel15->ndi = %i\n", dci_pdu_rel15->ndi); + LOG_D(NR_MAC, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); + LOG_D(NR_MAC, "dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid); + LOG_D(NR_MAC, "dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc); + LOG_D(NR_MAC, "dci_pdu_rel15->padding = %i\n", dci_pdu_rel15->padding); - break; + break; } break; case NR_UL_DCI_FORMAT_0_1: switch (rnti_type) { - case NR_RNTI_C: - LOG_D(NR_MAC,"Filling NR_UL_DCI_FORMAT_0_1 size %d format indicator %d\n",dci_size,dci_pdu_rel15->format_indicator); - // Indicating a DL DCI format 1bit - pos = 1; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 0x1) << (dci_size - pos); - // Carrier indicator - pos += dci_pdu_rel15->carrier_indicator.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->carrier_indicator.val & ((1 << dci_pdu_rel15->carrier_indicator.nbits) - 1)) << (dci_size - pos); - // UL/SUL Indicator - pos += dci_pdu_rel15->ul_sul_indicator.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->ul_sul_indicator.val & ((1 << dci_pdu_rel15->ul_sul_indicator.nbits) - 1)) << (dci_size - pos); - // BWP indicator - pos += dci_pdu_rel15->bwp_indicator.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->bwp_indicator.val & ((1 << dci_pdu_rel15->bwp_indicator.nbits) - 1)) << (dci_size - pos); - // Frequency domain resource assignment - pos += dci_pdu_rel15->frequency_domain_assignment.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val & ((1 << dci_pdu_rel15->frequency_domain_assignment.nbits) - 1)) << (dci_size - pos); - // Time domain resource assignment - pos += dci_pdu_rel15->time_domain_assignment.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->time_domain_assignment.val & ((1 << dci_pdu_rel15->time_domain_assignment.nbits) - 1)) << (dci_size - pos); - // Frequency hopping - pos += dci_pdu_rel15->frequency_hopping_flag.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag.val & ((1 << dci_pdu_rel15->frequency_hopping_flag.nbits) - 1)) << (dci_size - pos); - // MCS 5bit - pos += 5; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); - // New data indicator 1bit - pos += 1; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi & 0x1) << (dci_size - pos); - // Redundancy version 2bit - pos += 2; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->rv & 0x3) << (dci_size - pos); - // HARQ process number 4bit - pos += 4; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos); - // 1st Downlink assignment index - pos += dci_pdu_rel15->dai[0].nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->dai[0].val & ((1 << dci_pdu_rel15->dai[0].nbits) - 1)) << (dci_size - pos); - // 2nd Downlink assignment index - pos += dci_pdu_rel15->dai[1].nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->dai[1].val & ((1 << dci_pdu_rel15->dai[1].nbits) - 1)) << (dci_size - pos); - // TPC command for scheduled PUSCH 2bit - pos += 2; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->tpc & 0x3) << (dci_size - pos); - // SRS resource indicator - pos += dci_pdu_rel15->srs_resource_indicator.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->srs_resource_indicator.val & ((1 << dci_pdu_rel15->srs_resource_indicator.nbits) - 1)) << (dci_size - pos); - // Precoding info and n. of layers - pos += dci_pdu_rel15->precoding_information.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->precoding_information.val & ((1 << dci_pdu_rel15->precoding_information.nbits) - 1)) << (dci_size - pos); - // Antenna ports - pos += dci_pdu_rel15->antenna_ports.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->antenna_ports.val & ((1 << dci_pdu_rel15->antenna_ports.nbits) - 1)) << (dci_size - pos); - // SRS request - pos += dci_pdu_rel15->srs_request.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->srs_request.val & ((1 << dci_pdu_rel15->srs_request.nbits) - 1)) << (dci_size - pos); - // CSI request - pos += dci_pdu_rel15->csi_request.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->csi_request.val & ((1 << dci_pdu_rel15->csi_request.nbits) - 1)) << (dci_size - pos); - // CBG transmission information - pos += dci_pdu_rel15->cbgti.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->cbgti.val & ((1 << dci_pdu_rel15->cbgti.nbits) - 1)) << (dci_size - pos); - // PTRS DMRS association - pos += dci_pdu_rel15->ptrs_dmrs_association.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->ptrs_dmrs_association.val & ((1 << dci_pdu_rel15->ptrs_dmrs_association.nbits) - 1)) << (dci_size - pos); - // Beta offset indicator - pos += dci_pdu_rel15->beta_offset_indicator.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->beta_offset_indicator.val & ((1 << dci_pdu_rel15->beta_offset_indicator.nbits) - 1)) << (dci_size - pos); - // DMRS sequence initialization - pos += dci_pdu_rel15->dmrs_sequence_initialization.nbits; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->dmrs_sequence_initialization.val & ((1 << dci_pdu_rel15->dmrs_sequence_initialization.nbits) - 1)) << (dci_size - pos); - // UL-SCH indicator - pos += 1; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->ulsch_indicator & 0x1) << (dci_size - pos); + case TYPE_C_RNTI_: + LOG_D(NR_MAC, "Filling NR_UL_DCI_FORMAT_0_1 size %d format indicator %d\n", dci_size, dci_pdu_rel15->format_indicator); + // Indicating a DL DCI format 1bit + pos = 1; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 0x1) << (dci_size - pos); + // Carrier indicator + pos += dci_pdu_rel15->carrier_indicator.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->carrier_indicator.val & ((1 << dci_pdu_rel15->carrier_indicator.nbits) - 1)) + << (dci_size - pos); + // UL/SUL Indicator + pos += dci_pdu_rel15->ul_sul_indicator.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->ul_sul_indicator.val & ((1 << dci_pdu_rel15->ul_sul_indicator.nbits) - 1)) + << (dci_size - pos); + // BWP indicator + pos += dci_pdu_rel15->bwp_indicator.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->bwp_indicator.val & ((1 << dci_pdu_rel15->bwp_indicator.nbits) - 1)) + << (dci_size - pos); + // Frequency domain resource assignment + pos += dci_pdu_rel15->frequency_domain_assignment.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val + & ((1 << dci_pdu_rel15->frequency_domain_assignment.nbits) - 1)) + << (dci_size - pos); + // Time domain resource assignment + pos += dci_pdu_rel15->time_domain_assignment.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->time_domain_assignment.val & ((1 << dci_pdu_rel15->time_domain_assignment.nbits) - 1)) + << (dci_size - pos); + // Frequency hopping + pos += dci_pdu_rel15->frequency_hopping_flag.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag.val & ((1 << dci_pdu_rel15->frequency_hopping_flag.nbits) - 1)) + << (dci_size - pos); + // MCS 5bit + pos += 5; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs & 0x1f) << (dci_size - pos); + // New data indicator 1bit + pos += 1; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi & 0x1) << (dci_size - pos); + // Redundancy version 2bit + pos += 2; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->rv & 0x3) << (dci_size - pos); + // HARQ process number 4bit + pos += 4; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos); + // 1st Downlink assignment index + pos += dci_pdu_rel15->dai[0].nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->dai[0].val & ((1 << dci_pdu_rel15->dai[0].nbits) - 1)) << (dci_size - pos); + // 2nd Downlink assignment index + pos += dci_pdu_rel15->dai[1].nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->dai[1].val & ((1 << dci_pdu_rel15->dai[1].nbits) - 1)) << (dci_size - pos); + // TPC command for scheduled PUSCH 2bit + pos += 2; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->tpc & 0x3) << (dci_size - pos); + // SRS resource indicator + pos += dci_pdu_rel15->srs_resource_indicator.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->srs_resource_indicator.val & ((1 << dci_pdu_rel15->srs_resource_indicator.nbits) - 1)) + << (dci_size - pos); + // Precoding info and n. of layers + pos += dci_pdu_rel15->precoding_information.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->precoding_information.val & ((1 << dci_pdu_rel15->precoding_information.nbits) - 1)) + << (dci_size - pos); + // Antenna ports + pos += dci_pdu_rel15->antenna_ports.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->antenna_ports.val & ((1 << dci_pdu_rel15->antenna_ports.nbits) - 1)) + << (dci_size - pos); + // SRS request + pos += dci_pdu_rel15->srs_request.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->srs_request.val & ((1 << dci_pdu_rel15->srs_request.nbits) - 1)) << (dci_size - pos); + // CSI request + pos += dci_pdu_rel15->csi_request.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->csi_request.val & ((1 << dci_pdu_rel15->csi_request.nbits) - 1)) << (dci_size - pos); + // CBG transmission information + pos += dci_pdu_rel15->cbgti.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->cbgti.val & ((1 << dci_pdu_rel15->cbgti.nbits) - 1)) << (dci_size - pos); + // PTRS DMRS association + pos += dci_pdu_rel15->ptrs_dmrs_association.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->ptrs_dmrs_association.val & ((1 << dci_pdu_rel15->ptrs_dmrs_association.nbits) - 1)) + << (dci_size - pos); + // Beta offset indicator + pos += dci_pdu_rel15->beta_offset_indicator.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->beta_offset_indicator.val & ((1 << dci_pdu_rel15->beta_offset_indicator.nbits) - 1)) + << (dci_size - pos); + // DMRS sequence initialization + pos += dci_pdu_rel15->dmrs_sequence_initialization.nbits; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->dmrs_sequence_initialization.val + & ((1 << dci_pdu_rel15->dmrs_sequence_initialization.nbits) - 1)) + << (dci_size - pos); + // UL-SCH indicator + pos += 1; + *dci_pdu |= ((uint64_t)dci_pdu_rel15->ulsch_indicator & 0x1) << (dci_size - pos); #ifdef DEBUG_DCI LOG_I(NR_MAC,"============= NR_UL_DCI_FORMAT_0_1 =============\n"); @@ -2324,7 +2344,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, // Set MCS tables long *dl_mcs_Table = DL_BWP->pdsch_Config ? DL_BWP->pdsch_Config->mcs_Table : NULL; - DL_BWP->mcsTableIdx = get_pdsch_mcs_table(dl_mcs_Table, DL_BWP->dci_format, NR_RNTI_C, target_ss); + DL_BWP->mcsTableIdx = get_pdsch_mcs_table(dl_mcs_Table, DL_BWP->dci_format, TYPE_C_RNTI_, target_ss); // 0 precoding enabled 1 precoding disabled UL_BWP->transform_precoding = get_transformPrecoding(UL_BWP, UL_BWP->dci_format, 0); @@ -2335,13 +2355,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, UL_BWP->pusch_Config->mcs_Table : UL_BWP->pusch_Config->mcs_TableTransformPrecoder; - UL_BWP->mcs_table = get_pusch_mcs_table(mcs_Table, - !UL_BWP->transform_precoding, - UL_BWP->dci_format, - NR_RNTI_C, - target_ss, - false); - + UL_BWP->mcs_table = get_pusch_mcs_table(mcs_Table, !UL_BWP->transform_precoding, UL_BWP->dci_format, TYPE_C_RNTI_, target_ss, false); } void reset_srs_stats(NR_UE_info_t *UE) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index 6664cc761b..521616f82d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -562,7 +562,10 @@ void nr_schedule_srs(int module_id, frame_t frame, int slot) continue; } - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = get_ul_tdalist(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = get_ul_tdalist(current_BWP, + sched_ctrl->coreset->controlResourceSetId, + sched_ctrl->search_space->searchSpaceType->present, + TYPE_C_RNTI_); const int num_tda = tdaList->list.count; int max_k2 = 0; // avoid last one in the list (for msg3) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index da4a2b3f8c..f1a3e34c85 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1502,7 +1502,11 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, const uint8_t nrOfLayers = retInfo->nrOfLayers; LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); LOG_D(NR_MAC,"tbs %d\n",retInfo->tb_size); - NR_tda_info_t tda_info = get_ul_tda_info(ul_bwp, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C, tda); + NR_tda_info_t tda_info = get_ul_tda_info(ul_bwp, + sched_ctrl->coreset->controlResourceSetId, + sched_ctrl->search_space->searchSpaceType->present, + TYPE_C_RNTI_, + tda); bool reuse_old_tda = (retInfo->tda_info.startSymbolIndex == tda_info.startSymbolIndex) && (retInfo->tda_info.nrOfSymbols <= tda_info.nrOfSymbols); if (reuse_old_tda && nrOfLayers == retInfo->nrOfLayers) { /* Check the resource is enough for retransmission */ @@ -1740,7 +1744,11 @@ static void pf_ul(module_id_t module_id, sched_pusch->nrOfLayers = sched_ctrl->srs_feedback.ul_ri + 1; sched_pusch->time_domain_allocation = get_ul_tda(nrmac, scc, sched_pusch->frame, sched_pusch->slot); - sched_pusch->tda_info = get_ul_tda_info(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C, sched_pusch->time_domain_allocation); + sched_pusch->tda_info = get_ul_tda_info(current_BWP, + sched_ctrl->coreset->controlResourceSetId, + sched_ctrl->search_space->searchSpaceType->present, + TYPE_C_RNTI_, + sched_pusch->time_domain_allocation); sched_pusch->dmrs_info = get_ul_dmrs_params(scc, current_BWP, &sched_pusch->tda_info, @@ -1840,7 +1848,11 @@ static void pf_ul(module_id_t module_id, sched_pusch->nrOfLayers = sched_ctrl->srs_feedback.ul_ri + 1; sched_pusch->time_domain_allocation = get_ul_tda(nrmac, scc, sched_pusch->frame, sched_pusch->slot); - sched_pusch->tda_info = get_ul_tda_info(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C, sched_pusch->time_domain_allocation); + sched_pusch->tda_info = get_ul_tda_info(current_BWP, + sched_ctrl->coreset->controlResourceSetId, + sched_ctrl->search_space->searchSpaceType->present, + TYPE_C_RNTI_, + sched_pusch->time_domain_allocation); sched_pusch->dmrs_info = get_ul_dmrs_params(scc, current_BWP, &sched_pusch->tda_info, @@ -1943,7 +1955,10 @@ static bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_ NR_UE_UL_BWP_t *current_BWP = &nr_mac->UE_info.list[0]->current_UL_BWP; int mu = current_BWP->scs; const int temp_tda = get_ul_tda(nr_mac, scc, frame, slot); - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = get_ul_tdalist(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = get_ul_tdalist(current_BWP, + sched_ctrl->coreset->controlResourceSetId, + sched_ctrl->search_space->searchSpaceType->present, + TYPE_C_RNTI_); int K2 = get_K2(tdaList, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; @@ -2119,8 +2134,6 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n cur_harq->feedback_slot = sched_pusch->slot; cur_harq->is_waiting = true; - int rnti_types[2] = { NR_RNTI_C, 0 }; - /* Statistics */ AssertFatal(cur_harq->round < nr_mac->ul_bler.harq_round_max, "Indexing ulsch_rounds[%d] is out of bounds\n", cur_harq->round); UE->mac_stats.ul.rounds[cur_harq->round]++; @@ -2385,7 +2398,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n dci_pdu, &uldci_payload, current_BWP->dci_format, - rnti_types[0], + TYPE_C_RNTI_, current_BWP->bwp_id, ss, coreset, From b5e169ec079106cf514390eca61fbd1b3a2d3903 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Tue, 9 Jan 2024 10:13:56 +0100 Subject: [PATCH 07/13] add const or other simple C code improvement --- openair1/PHY/MODULATION/modulation_UE.h | 4 +- openair1/PHY/MODULATION/slot_fep_nr.c | 4 +- openair1/PHY/NR_REFSIG/sss_nr.h | 2 +- .../nr_dl_channel_estimation.c | 10 +- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 18 ++-- .../PHY/NR_UE_ESTIMATION/nr_ue_measurements.c | 29 ++--- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 10 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 16 ++- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 6 +- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 101 +++++++----------- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 10 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 4 +- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 52 ++++----- openair1/PHY/NR_UE_TRANSPORT/sss_nr.c | 6 +- openair1/SCHED_NR_UE/defs.h | 37 ++----- openair1/SCHED_NR_UE/harq_nr.c | 10 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 28 +++-- openair1/SIMULATION/NR_PHY/pbchsim.c | 40 +++---- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 +- 19 files changed, 170 insertions(+), 219 deletions(-) diff --git a/openair1/PHY/MODULATION/modulation_UE.h b/openair1/PHY/MODULATION/modulation_UE.h index 99986725c0..07d7625770 100644 --- a/openair1/PHY/MODULATION/modulation_UE.h +++ b/openair1/PHY/MODULATION/modulation_UE.h @@ -49,12 +49,12 @@ int slot_fep(PHY_VARS_UE *phy_vars_ue, int reset_freq_est); int nr_slot_fep(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, int sample_offset, bool pbch_decoded, diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 43b83223f6..a645d9ded1 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -35,7 +35,7 @@ #endif*/ int nr_slot_fep(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { @@ -114,7 +114,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, } int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, int sample_offset, bool pbch_decoded, diff --git a/openair1/PHY/NR_REFSIG/sss_nr.h b/openair1/PHY/NR_REFSIG/sss_nr.h index 7292cc0f02..129c5a5917 100644 --- a/openair1/PHY/NR_REFSIG/sss_nr.h +++ b/openair1/PHY/NR_REFSIG/sss_nr.h @@ -76,7 +76,7 @@ void insert_sss_nr(int16_t *sss_time, NR_DL_FRAME_PARMS *frame_parms); bool rx_sss_nr(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int32_t *tot_metric, uint8_t *phase_max, int *freq_offset_sss, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index d658f012ad..a310e7d127 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -74,7 +74,7 @@ int nr_prs_channel_estimation(uint8_t gNB_id, uint8_t rsc_id, uint8_t rep_num, PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, NR_DL_FRAME_PARMS *frame_params, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { @@ -628,7 +628,7 @@ int nr_prs_channel_estimation(uint8_t gNB_id, } int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, int dmrss, NR_UE_SSB *current_ssb, @@ -782,7 +782,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], struct complex16 dl_ch_estimates_time[][ue->frame_parms.ofdm_symbol_size], - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, int dmrss, uint8_t ssb_index, @@ -1054,7 +1054,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, fapi_nr_coreset_t *coreset, uint16_t first_carrier_offset, @@ -1606,7 +1606,7 @@ void NFAPI_NR_DMRS_TYPE2_average_prb(NR_DL_FRAME_PARMS *frame_parms, #endif } int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned short p, unsigned char symbol, unsigned char nscid, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index 65591293a8..a313a3a759 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -37,7 +37,7 @@ int nr_prs_channel_estimation(uint8_t gNB_id, uint8_t rsc_id, uint8_t rep_num, PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, NR_DL_FRAME_PARMS *frame_params, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); @@ -48,7 +48,7 @@ void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t \brief This function performs channel estimation including frequency and temporal interpolation */ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, fapi_nr_coreset_t *coreset, uint16_t first_carrier_offset, @@ -58,7 +58,7 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, int dmrss, NR_UE_SSB *current_ssb, @@ -68,7 +68,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], struct complex16 dl_ch_estimates_time[][ue->frame_parms.ofdm_symbol_size], - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned char symbol, int dmrss, uint8_t ssb_index, @@ -76,7 +76,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, unsigned short p, unsigned char symbol, unsigned char nscid, @@ -100,20 +100,20 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, uint8_t subframe, unsigned char clear, short coef); - + void nr_ue_measurements(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, NR_UE_DLSCH_t *dlsch, uint32_t pdsch_est_size, int32_t dl_ch_estimates[][pdsch_est_size]); void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, uint8_t gNB_index, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); void phy_adjust_gain_nr(PHY_VARS_NR_UE *ue, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index a6aa2ba22f..840577d296 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -75,7 +75,7 @@ float_t get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index) } void nr_ue_measurements(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, NR_UE_DLSCH_t *dlsch, uint32_t pdsch_est_size, int32_t dl_ch_estimates[][pdsch_est_size]) @@ -180,9 +180,9 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, // - RX Gain dB void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, int ssb_index, - UE_nr_rxtx_proc_t *proc, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { - + const UE_nr_rxtx_proc_t *proc, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +{ int k_start = 56; int k_end = 183; int slot = proc->nr_slot_rx; @@ -235,9 +235,9 @@ void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, // Measurement units: // - psd_awgn (AWGN power spectral density): dBm/Hz void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]){ - + const UE_nr_rxtx_proc_t *proc, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +{ uint8_t k; int slot = proc->nr_slot_rx; int aarx; @@ -300,11 +300,12 @@ void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, LOG_D(PHY, "In [%s][slot:%d] NF USRP %d dB\n", __FUNCTION__, slot, nf_usrp); #endif - LOG_D(PHY, "In [%s][slot:%d] Noise Level %d (digital level %d dB, noise power spectral density %f dBm/RE)\n", - __FUNCTION__, - slot, - ue->measurements.n0_power_tot, - ue->measurements.n0_power_tot_dB, - ue->measurements.n0_power_tot_dB + 30 - 10*log10(pow(2, 30)) - dB_fixed(ue->frame_parms.ofdm_symbol_size) - ((int)rx_gain - (int)rx_gain_offset)); - + LOG_D(PHY, + "In [%s][slot:%d] Noise Level %d (digital level %d dB, noise power spectral density %f dBm/RE)\n", + __FUNCTION__, + slot, + ue->measurements.n0_power_tot, + ue->measurements.n0_power_tot_dB, + ue->measurements.n0_power_tot_dB + 30 - 10 * log10(pow(2, 30)) - dB_fixed(ue->frame_parms.ofdm_symbol_size) + - ((int)rx_gain - (int)rx_gain_offset)); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index f11042f9b2..7e80721524 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -807,8 +807,10 @@ int nr_csi_im_power_estimation(const PHY_VARS_NR_UE *ue, return 0; } -int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { - +int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +{ int gNB_id = proc->gNB_id; if(!ue->csiim_vars[gNB_id]->active) { return -1; @@ -852,7 +854,9 @@ static nfapi_nr_dl_tti_csi_rs_pdu_rel15_t convert_csirs_pdu(const fapi_nr_dl_con return dl_tti_csi_rs_pdu; } -void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { int gNB_id = proc->gNB_id; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index c979926c92..b95193e5e9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -609,13 +609,13 @@ void nr_pdcch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, } int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], int16_t *pdcch_e_rx, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { - + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +{ NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; uint8_t log2_maxh, aarx; @@ -739,8 +739,6 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, return (0); } - - void nr_pdcch_unscrambling(int16_t *e_rx, uint16_t scrambling_RNTI, uint32_t length, @@ -805,11 +803,11 @@ static uint16_t nr_dci_false_detection(uint64_t *dci, } uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int16_t *pdcch_e_rx, fapi_nr_dci_indication_t *dci_ind, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { - + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) +{ //int gNB_id = 0; int16_t tmp_e[16*108]; rnti_t n_rnti; @@ -892,5 +890,3 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, } return(dci_ind->number_of_dcis); } - - diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index a0a90e8d42..1af7e8852f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -74,11 +74,11 @@ void nr_dlsch_unscrambling(int16_t *llr, uint32_t size, uint8_t q, uint32_t Nid, static bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, notifiedFIFO_t *nf_p, - bool last, + const bool last, int b_size, uint8_t b[b_size], int *num_seg_ok, - UE_nr_rxtx_proc_t *proc) + const UE_nr_rxtx_proc_t *proc) { ldpcDecode_ue_t *rdata = (ldpcDecode_ue_t*) NotifiedFifoData(req); NR_DL_UE_HARQ_t *harq_process = rdata->harq_process; @@ -265,7 +265,7 @@ static void nr_processDLSegment(void *arg) } uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int eNB_id, short *dlsch_llr, NR_DL_FRAME_PARMS *frame_parms, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 390917885c..608db26921 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -49,8 +49,8 @@ int32_t nr_dlsch_demod_shift = 0; //int16_t interf_unaw_shift = 13; -//#define DEBUG_HARQ -//#define DEBUG_PHY +// #define DEBUG_HARQ(a...) printf(a) +#define DEBUG_HARQ(...) //#define DEBUG_DLSCH_DEMOD //#define DEBUG_PDSCH_RX @@ -233,7 +233,7 @@ void nr_dlsch_detection_mrc(uint32_t rx_size_symbol, /* Main Function */ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, NR_UE_DLSCH_t dlsch[2], unsigned char symbol, unsigned char first_symbol_flag, @@ -267,36 +267,19 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, NR_UE_COMMON *common_vars = &ue->common_vars; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; PHY_NR_MEASUREMENTS *measurements = &ue->measurements; - int frame = proc->frame_rx; - int nr_slot_rx = proc->nr_slot_rx; - int gNB_id = proc->gNB_id; + const int frame = proc->frame_rx; + const int nr_slot_rx = proc->nr_slot_rx; + const int gNB_id = proc->gNB_id; int avg[16]; -// int avg_0[2]; -// int avg_1[2]; - uint8_t slot = 0; - unsigned char aatx=0,aarx=0; - - int avgs = 0;// rb; - NR_DL_UE_HARQ_t *dlsch0_harq, *dlsch1_harq = NULL; - int32_t codeword_TB0 = -1; int32_t codeword_TB1 = -1; - //to be updated higher layer - unsigned short start_rb = 0; - unsigned short nb_rb_pdsch = 50; - //int16_t *pllr_symbol_cw0_deint; - //int16_t *pllr_symbol_cw1_deint; - //uint16_t bundle_L = 2; - int32_t median[16]; - uint32_t nb_re_pdsch; - uint16_t startSymbIdx=0; - uint16_t nbSymb=0; - uint16_t pduBitmap=0x0; + uint32_t nb_re_pdsch = -1; + NR_DL_UE_HARQ_t *dlsch0_harq, *dlsch1_harq = NULL; dlsch0_harq = &ue->dl_harq_processes[0][harq_pid]; if (NR_MAX_NB_LAYERS>4) dlsch1_harq = &ue->dl_harq_processes[1][harq_pid]; @@ -311,75 +294,61 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, dlsch0_harq = &ue->dl_harq_processes[codeword_TB0][harq_pid]; dlsch1_harq = &ue->dl_harq_processes[codeword_TB1][harq_pid]; - #ifdef DEBUG_HARQ - printf("[DEMOD] I am assuming both TBs are active, in cw0 %d and cw1 %d \n", codeword_TB0, codeword_TB1); - #endif + DEBUG_HARQ("[DEMOD] I am assuming both TBs are active, in cw0 %d and cw1 %d \n", codeword_TB0, codeword_TB1); } else if ((dlsch0_harq->status == ACTIVE) && (dlsch1_harq->status != ACTIVE) ) { codeword_TB0 = dlsch0_harq->codeword; dlsch0_harq = &ue->dl_harq_processes[codeword_TB0][harq_pid]; dlsch1_harq = NULL; - #ifdef DEBUG_HARQ - printf("[DEMOD] I am assuming only TB0 is active, in cw %d \n", codeword_TB0); - #endif + DEBUG_HARQ("[DEMOD] I am assuming only TB0 is active, in cw %d \n", codeword_TB0); } else if ((dlsch0_harq->status != ACTIVE) && (dlsch1_harq->status == ACTIVE)){ codeword_TB1 = dlsch1_harq->codeword; dlsch0_harq = NULL; dlsch1_harq = &ue->dl_harq_processes[codeword_TB1][harq_pid]; - #ifdef DEBUG_HARQ - printf("[DEMOD] I am assuming only TB1 is active, it is in cw %d\n", codeword_TB1); - #endif - - LOG_E(PHY, "[UE][FATAL] DLSCH: TB0 not active and TB1 active case is not supported\n"); + DEBUG_HARQ("[DEMOD] I am assuming only TB1 is active, it is in cw %d\n", codeword_TB1); + LOG_E(PHY, "[DEMOD] slot %d TB0 not active and TB1 active case is not supported\n", nr_slot_rx); return -1; } else { - LOG_E(PHY,"[UE][FATAL] nr_slot_rx %d: no active DLSCH\n", nr_slot_rx); - return(-1); + LOG_E(PHY, "[DEMOD] slot %d: no active DLSCH (2 layers case)\n", nr_slot_rx); + return (-1); } } else if (dlsch0_harq) { if (dlsch0_harq->status == ACTIVE) { codeword_TB0 = dlsch0_harq->codeword; dlsch0_harq = &ue->dl_harq_processes[0][harq_pid]; - - #ifdef DEBUG_HARQ - printf("[DEMOD] I am assuming only TB0 is active\n"); - #endif + DEBUG_HARQ("[DEMOD] I am assuming only TB0 is active\n"); } else { - LOG_E(PHY,"[UE][FATAL] nr_slot_rx %d: no active DLSCH\n", nr_slot_rx); + LOG_E(PHY, "[DEMOD] slot %d nr_rx_pdsch no active DLSCH (one layer case)\n", nr_slot_rx); return (-1); } } else { - LOG_E(PHY, "Done\n"); + LOG_E(PHY, "[DEMOD] slot %d Inconsistent call to nr_rx_pdsch (no layer 0)\n", nr_slot_rx); return -1; } - #ifdef DEBUG_HARQ - printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode); - printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1); - #endif + DEBUG_HARQ("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1); - start_rb = dlsch[0].dlsch_config.start_rb; - nb_rb_pdsch = dlsch[0].dlsch_config.number_rbs; + int start_rb = dlsch[0].dlsch_config.start_rb; + int nb_rb_pdsch = dlsch[0].dlsch_config.number_rbs; DevAssert(dlsch0_harq); - if (gNB_id > 2) { - LOG_W(PHY, "In %s: Illegal gNB_id %d\n", __FUNCTION__, gNB_id); + LOG_E(PHY, "In %s: Illegal gNB_id %d\n", __FUNCTION__, gNB_id); return(-1); } if (!common_vars) { - LOG_W(PHY,"dlsch_demodulation.c: Null common_vars\n"); + LOG_E(PHY, "dlsch_demodulation.c: Null common_vars\n"); return(-1); } if (!frame_parms) { - LOG_W(PHY,"dlsch_demodulation.c: Null frame_parms\n"); + LOG_E(PHY, "dlsch_demodulation.c: Null frame_parms\n"); return(-1); } @@ -463,18 +432,19 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, start_meas(&meas); if (first_symbol_flag == 1) { nr_dlsch_channel_level(rx_size_symbol, dl_ch_estimates_ext, frame_parms, nl, avg, symbol, nb_re_pdsch, nb_rb_pdsch); - avgs = 0; - for (aatx=0;aatx 1) { nr_dlsch_channel_level_median(rx_size_symbol, dl_ch_estimates_ext, median, nl, n_rx, nb_re_pdsch); - for (aatx = 0; aatx < nl; aatx++) { - for (aarx = 0; aarx < n_rx; aarx++) { + for (int aatx = 0; aatx < nl; aatx++) { + for (int aarx = 0; aarx < n_rx; aarx++) { avgs = cmax(avgs, median[aatx*n_rx + aarx]); } } @@ -589,6 +559,9 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, start_meas(&meas); /* Store the valid DL RE's */ dl_valid_re[symbol-1] = nb_re_pdsch; + int startSymbIdx = 0; + int nbSymb = 0; + int pduBitmap = 0; if(dlsch0_harq->status == ACTIVE) { startSymbIdx = dlsch[0].dlsch_config.start_symbol; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index a0230ac8cb..56631c75ea 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -100,8 +100,10 @@ void free_list(NR_UE_SSB *node) { free(node); } - -int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc, + PHY_VARS_NR_UE *ue, + int pbch_initial_symbol, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int ret =-1; @@ -196,9 +198,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini } -int nr_initial_sync(UE_nr_rxtx_proc_t *proc, - PHY_VARS_NR_UE *ue, - int n_frames, int sa) +int nr_initial_sync(const UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, int n_frames, int sa) { int32_t sync_pos, sync_pos_frame; // k_ssb, N_ssb_crb, sync_pos2, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index c7d10b69f4..ed30c95fe0 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -356,9 +356,9 @@ const uint8_t pbch_deinterleaving_pattern[32] = {28, 0, 31, 30, 7, 29, 25, 27, 1, 4, 3, 14, 15, 16, 17, 2, 26, 18, 19, 20, 21, 22, 6, 23}; int nr_rx_pbch(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int estimateSz, - struct complex16 dl_ch_estimates [][estimateSz], + struct complex16 dl_ch_estimates[][estimateSz], NR_DL_FRAME_PARMS *frame_parms, uint8_t i_ssb, MIMO_mode_t mimo_mode, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 4047abe164..d673baadda 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -198,19 +198,19 @@ void nr_conjch0_mult_ch1(int *ch0, @returns 0 on success, 1 on unsuccessful decoding */ -uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, - UE_nr_rxtx_proc_t *proc, - int eNB_id, - short *dlsch_llr, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_DLSCH_t *dlsch, - NR_DL_UE_HARQ_t *harq_process, - uint32_t frame, - uint16_t nb_symb_sch, - uint8_t nr_slot_rx, - uint8_t harq_pid, - int b_size, - uint8_t b[b_size]); +uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, + const UE_nr_rxtx_proc_t *proc, + int eNB_id, + short *dlsch_llr, + NR_DL_FRAME_PARMS *frame_parms, + NR_UE_DLSCH_t *dlsch, + NR_DL_UE_HARQ_t *harq_process, + uint32_t frame, + uint16_t nb_symb_sch, + uint8_t nr_slot_rx, + uint8_t harq_pid, + int b_size, + uint8_t b[b_size]); int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, NR_UE_ULSCH_t *ulsch, @@ -267,14 +267,13 @@ void nr_dlsch_unscrambling(int16_t* llr, uint32_t n_RNTI); int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], int16_t *pdcch_e_rx, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); - /*! \brief Performs detection of SSS to find cell ID and other framing parameters (FDD/TDD, normal/extended prefix) @param phy_vars_ue Pointer to UE variables @param tot_metric Pointer to variable containing maximum metric under framing hypothesis (to be compared to other hypotheses @@ -289,26 +288,30 @@ int rx_sss(PHY_VARS_NR_UE *phy_vars_ue,int32_t *tot_metric,uint8_t *flip_max,uin \returns number of tx antennas or -1 if error */ int nr_rx_pbch(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, const int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], NR_DL_FRAME_PARMS *frame_parms, uint8_t i_ssb, MIMO_mode_t mimo_mode, - fapiPbch_t* result, + fapiPbch_t *result, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); -int nr_pbch_detection(UE_nr_rxtx_proc_t *proc, +int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); - #ifndef modOrder #define modOrder(I_MCS,I_TBS) ((I_MCS-I_TBS)*2+2) // Find modulation order from I_TBS and I_MCS #endif -int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, char* buffer, int length, runmode_t mode, int input_level_dBm); +int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue, + const UE_nr_rxtx_proc_t *proc, + char *buffer, + int length, + runmode_t mode, + int input_level_dBm); /*! \brief This function performs the initial cell search procedure - PSS detection, SSS detection and PBCH detection. At the @@ -320,10 +323,7 @@ int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, char* bu @param n_frames @param sa current running mode */ -int nr_initial_sync(UE_nr_rxtx_proc_t *proc, - PHY_VARS_NR_UE *phy_vars_ue, - int n_frames, - int sa); +int nr_initial_sync(const UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *phy_vars_ue, int n_frames, int sa); /*! \brief This function gets the carrier frequencies either from FP or command-line-set global variables, depending on the @@ -368,7 +368,7 @@ void nr_pdcch_unscrambling(int16_t *z, int16_t *z2); uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int16_t *pdcch_e_rx, fapi_nr_dci_indication_t *dci_ind, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); @@ -401,7 +401,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, @param ptrs_re_per_slot */ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, NR_UE_DLSCH_t dlsch[2], unsigned char symbol, unsigned char first_symbol_flag, diff --git a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c index 6df24949a9..76196febcd 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c @@ -258,7 +258,7 @@ static int pss_ch_est_nr(PHY_VARS_NR_UE *ue, static int do_pss_sss_extract_nr( PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, c16_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR], c16_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR], uint8_t doPss, @@ -340,7 +340,7 @@ static int do_pss_sss_extract_nr( *********************************************************************/ static int pss_sss_extract_nr(PHY_VARS_NR_UE *phy_vars_ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, c16_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR], c16_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR], uint8_t subframe, @@ -362,7 +362,7 @@ static int pss_sss_extract_nr(PHY_VARS_NR_UE *phy_vars_ue, * *********************************************************************/ bool rx_sss_nr(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int32_t *tot_metric, uint8_t *phase_max, int *freq_offset_sss, diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index e999626bfd..2ff16ed18d 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -98,17 +98,9 @@ typedef struct { */ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_data_tx_t *phy_data); -void send_slot_ind(notifiedFIFO_t *nf, int slot); +void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_data_t *phy_data); -void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - nr_phy_data_t *phy_data); - -void pdsch_processing(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - nr_phy_data_t *phy_data); - -int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t abstraction_flag, uint8_t do_pdcch_flag, relaying_type_t r_type); +void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_data_t *phy_data); void processSlotTX(void *arg); @@ -139,7 +131,7 @@ bool is_csi_rs_in_symbol(fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, i void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, fapi_nr_dci_indication_t *dci_ind, fapi_nr_rx_indication_t *rx_ind, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, void *phy_data); @@ -153,32 +145,25 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, uint16_t n_pdus, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, void *typeSpecific, uint8_t *b); -bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - NR_UE_DLSCH_t dlsch[2], - int16_t* llr[2]); - -int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - NR_UE_DLSCH_t dlsch[2], - int16_t *llr[2], - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); - int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], nr_phy_data_t *phy_data, int n_ss, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); -int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); +int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); -void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); +void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); #endif /** @}*/ diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index f9c6440067..b7b542bf54 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -145,8 +145,14 @@ void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int dci_ndi, dl_harq->status = ACTIVE; dl_harq->first_rx = 1; } else { - LOG_D(PHY,"receive harq process: %p harqPid=%d, rv=%d, ndi=%d, rntiType=%d new transmission= %s\n", - dl_harq, harq_pid, rv, dci_ndi, rnti_type, dl_harq->Ndi != dci_ndi ? "yes":"no"); + LOG_D(PHY, + "receive harq process: %p harqPid=%d, rv=%d, ndi=%d, rntiType=%d new transmission= %s\n", + dl_harq, + harq_pid, + rv, + dci_ndi, + rnti_type, + dl_harq->Ndi != dci_ndi ? "yes" : "no"); AssertFatal(rv<4 && rv>=0, "invalid redondancy version %d\n", rv); if (dci_ndi!=dl_harq->Ndi) { if (dl_harq->ack == DL_NACK) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index f8547ed5b6..f4aec4b8dc 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -82,7 +82,7 @@ static const unsigned int gain_table[31] = {100, 112, 126, 141, 158, 178, void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, fapi_nr_dci_indication_t *dci_ind, fapi_nr_rx_indication_t *rx_ind, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, void *phy_data) { @@ -114,7 +114,7 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, uint16_t n_pdus, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, void *typeSpecific, uint8_t *b) { @@ -306,11 +306,11 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, n void nr_ue_measurement_procedures(uint16_t l, PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, NR_UE_DLSCH_t *dlsch, uint32_t pdsch_est_size, - int32_t dl_ch_estimates[][pdsch_est_size]) { - + int32_t dl_ch_estimates[][pdsch_est_size]) +{ NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int nr_slot_rx = proc->nr_slot_rx; int gNB_id = proc->gNB_id; @@ -361,11 +361,11 @@ void nr_ue_measurement_procedures(uint16_t l, } static int nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { - + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +{ int ret = 0; DevAssert(ue); @@ -424,7 +424,7 @@ unsigned int nr_get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb } int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], nr_phy_data_t *phy_data, @@ -838,10 +838,8 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, return dec; } -void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - nr_phy_data_t *phy_data) { - +void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_data_t *phy_data) +{ int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; int gNB_id = proc->gNB_id; @@ -1016,9 +1014,7 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDCCH, VCD_FUNCTION_OUT); } -void pdsch_processing(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - nr_phy_data_t *phy_data) +void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_data_t *phy_data) { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index a624b79e55..662a59992b 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -97,44 +97,34 @@ nfapi_mode_t nfapi_getmode(void) { return NFAPI_MODE_UNKNOWN; } void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, fapi_nr_dci_indication_t *dci_ind, fapi_nr_rx_indication_t *rx_ind, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, - void *phy_data) {} + void *phy_data) +{ +} void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, uint8_t pdu_type, PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, uint16_t n_pdus, - UE_nr_rxtx_proc_t *proc, + const UE_nr_rxtx_proc_t *proc, void *typeSpecific, - uint8_t *b) {} + uint8_t *b) +{ +} int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size], - nr_phy_data_t *phy_data, - int n_ss, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { + const UE_nr_rxtx_proc_t *proc, + int32_t pdcch_est_size, + int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + nr_phy_data_t *phy_data, + int n_ss, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +{ return 0; } -int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - NR_UE_DLSCH_t dlsch[2], - int16_t *llr[2], - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { - return 0; -} - -bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - NR_UE_DLSCH_t dlsch[2], - int16_t *llr[2]) { - return false; -} - void nr_phy_config_request_sim_pbchsim(PHY_VARS_gNB *gNB, int N_RB_DL, int N_RB_UL, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index b8ccdf3d8d..036ca54285 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1071,7 +1071,7 @@ void handle_ssb_meas(NR_UE_MAC_INST_t *mac, uint8_t ssb_index, int16_t rsrp_dbm) // L2 Abstraction Layer // Note: sdu should always be processed because data and timing advance updates are transmitted by the UE -int8_t handle_dlsch(nr_downlink_indication_t *dl_info, int pdu_id) +static int8_t handle_dlsch(nr_downlink_indication_t *dl_info, int pdu_id) { /* L1 assigns harq_pid, but in emulated L1 mode we need to assign the harq_pid based on the saved global g_harq_pid. Because we are From 9d98693bec584d1d4a4f6ad6452e71dae92c1e30 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 9 Jan 2024 10:10:16 +0100 Subject: [PATCH 08/13] Make nr_ue_process_rar() static --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 14 -------------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index f762665711..90d3ae5580 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -427,20 +427,6 @@ void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac, sub_frame_t current_slot, uint8_t Msg3_tda_id); -/* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI. -@param Mod_id Index of UE instance -@param CC_id Index to a component carrier -@param frame Frame index -@param ra_rnti RA_RNTI value -@param dlsch_buffer Pointer to dlsch_buffer containing RAR PDU -@param t_crnti Pointer to PHY variable containing the T_CRNTI -@param preamble_index Preamble Index used by PHY to transmit the PRACH. This should match the received RAR to trigger the rest of -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 -*/ -int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id); - void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame, int slot, NR_PRACH_RESOURCES_t *prach_resources); void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_resources, frame_t frame, int slot); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c29d17d287..1474894639 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -89,6 +89,21 @@ static const int sequence_cyclic_shift_2_harq_ack_bits[4] /* HARQ-ACK Value (0,0) (0,1) (1,0) (1,1) */ /* Sequence cyclic shift */ = { 0, 3, 9, 6 }; +/* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It +provides the timing advance and t-CRNTI. +@param Mod_id Index of UE instance +@param CC_id Index to a component carrier +@param frame Frame index +@param ra_rnti RA_RNTI value +@param dlsch_buffer Pointer to dlsch_buffer containing RAR PDU +@param t_crnti Pointer to PHY variable containing the T_CRNTI +@param preamble_index Preamble Index used by PHY to transmit the PRACH. This should match the received RAR to trigger the rest of +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); + int get_pucch0_mcs(const int O_ACK, const int O_SR, const int ack_payload, const int sr_payload) { int mcs = 0; @@ -3951,7 +3966,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 -int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) +static int 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; From 4a12bdc305e1e2ddbe3fabcbbbe8e9b87a28e2c1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 9 Jan 2024 16:09:14 +0100 Subject: [PATCH 09/13] fix tx_resume_ind_fifo messages sending bugs, rename associated function send_slot_ind() to what it actually does send_dl_done_to_tx_thread() --- executables/nr-ue.c | 93 +++++++++++++------ .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 2 +- openair1/PHY/defs_nr_UE.h | 6 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 50 +++++----- 4 files changed, 94 insertions(+), 57 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index f9eecf9076..a9f8364a66 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -494,7 +494,7 @@ static void UE_synch(void *arg) { static void RU_write(nr_rxtx_thread_data_t *rxtxD) { PHY_VARS_NR_UE *UE = rxtxD->UE; - UE_nr_rxtx_proc_t *proc = &rxtxD->proc; + const UE_nr_rxtx_proc_t *proc = &rxtxD->proc; void *txp[NB_ANTENNAS_TX]; int slot = proc->nr_slot_tx; @@ -541,19 +541,48 @@ static void RU_write(nr_rxtx_thread_data_t *rxtxD) { void processSlotTX(void *arg) { nr_rxtx_thread_data_t *rxtxD = (nr_rxtx_thread_data_t *) arg; - UE_nr_rxtx_proc_t *proc = &rxtxD->proc; + const UE_nr_rxtx_proc_t *proc = &rxtxD->proc; 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); 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); // wait for rx slots to send indication (if any) that DLSCH decoding is finished for(int i=0; i < rxtxD->tx_wait_for_dlsch; i++) { - notifiedFIFO_elt_t *res = pullNotifiedFIFO(UE->tx_resume_ind_fifo[proc->nr_slot_tx]); + notifiedFIFO_elt_t *res = pullNotifiedFIFO(UE->tx_resume_ind_fifo + proc->nr_slot_tx); delNotifiedFIFO_elt(res); } + LOG_D(PHY, "completed wait for tx, slot %d\n", proc->nr_slot_tx); + /* + This herafter code is costing some perfomance for a check that should be useless + But, we face today several bugs arround the matching between events in UE->tx_resume_ind_fifo[slot] + and the corresponding tx_wait_for_dlsch[slot] + The algorithm is we accumlate the actions that should end before processing a tx slot in tx_wait_for_dlsch[slot] + later, other threads push events in UE->tx_resume_ind_fifo[slot] + so, the tx encoding starts only when related actions are done (mainly DLSCH ACK/NACK to encode PUCCH) + if there is a bug that misses to send a event in UE->tx_resume_ind_fifo[slot], the process hangs, we detect the issue + if there is a bug that makes a extra event in UE->tx_resume_ind_fifo[slot], and if we drop the hereafter check + the system runs with random race conditions, very hard to debug + + Likely we should later remove completly UE->tx_resume_ind_fifo with notifications, + instead, + we may run in place the processSlotTX() when the conditions are met (when a decreasing tx_wait_for_dlsch[slot] will become 0) + It will remove the condition signals (for a thread safe semaphore or counter) and make the system simpler + This require also other modifications to + remove txFifo that is also a big issue + add out of order RF board sending, because, + if we encode and send tx slot as soon as we can, + it will be thrown out of order, especially in TDD mode + */ + notifiedFIFO_elt_t *res = pollNotifiedFIFO(UE->tx_resume_ind_fifo + proc->nr_slot_tx); + if (res) + LOG_E(NR_PHY, + "Internal error: extra event on Tx waiting queue for slot %d, event comes from rx slot %d\n", + proc->nr_slot_tx, + *(int *)NotifiedFifoData(res)); // trigger L2 to run ue_scheduler thru IF module // [TODO] mapping right after NR initial sync if(UE->if_inst != NULL && UE->if_inst->ul_indication != NULL) { @@ -580,10 +609,8 @@ void processSlotTX(void *arg) { RU_write(rxtxD); } -nr_phy_data_t UE_dl_preprocessing(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) +static void UE_dl_preprocessing(PHY_VARS_NR_UE *UE, const UE_nr_rxtx_proc_t *proc, int *tx_wait_for_dlsch, nr_phy_data_t *phy_data) { - nr_phy_data_t phy_data = {0}; - if (IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) { // Start synchronization with a target gNB @@ -607,23 +634,24 @@ nr_phy_data_t UE_dl_preprocessing(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) if(UE->if_inst != NULL && UE->if_inst->dl_indication != NULL) { nr_downlink_indication_t dl_indication; - nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, &phy_data); + nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, phy_data); UE->if_inst->dl_indication(&dl_indication); } uint64_t a=rdtsc_oai(); - pbch_pdcch_processing(UE, proc, &phy_data); - if (phy_data.dlsch[0].active && phy_data.dlsch[0].rnti_type == TYPE_C_RNTI_) { + pbch_pdcch_processing(UE, proc, phy_data); + if (phy_data->dlsch[0].active && phy_data->dlsch[0].rnti_type == TYPE_C_RNTI_) { // indicate to tx thread to wait for DLSCH decoding - const int ack_nack_slot = (proc->nr_slot_rx + phy_data.dlsch[0].dlsch_config.k1_feedback) % UE->frame_parms.slots_per_frame; - UE->tx_wait_for_dlsch[ack_nack_slot]++; + const int ack_nack_slot = (proc->nr_slot_rx + phy_data->dlsch[0].dlsch_config.k1_feedback) % UE->frame_parms.slots_per_frame; + LOG_D(NR_PHY, "Adding one event to wait after decoding slot %d, for futre tx slot %d\n", proc->nr_slot_rx, ack_nack_slot); + tx_wait_for_dlsch[ack_nack_slot]++; } LOG_D(PHY, "In %s: slot %d, time %llu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc_oai()-a)/3500); } ue_ta_procedures(UE, proc->nr_slot_tx, proc->frame_tx); - return phy_data; + return; } void UE_dl_processing(void *arg) { @@ -764,12 +792,11 @@ void *UE_thread(void *arg) const int nb_slot_frame = UE->frame_parms.slots_per_frame; int absolute_slot=0, decoded_frame_rx=INT_MAX, trashed_frames=0; initNotifiedFIFO(&UE->phy_config_ind); + int tx_wait_for_dlsch[NR_MAX_SLOTS_PER_FRAME]; int num_ind_fifo = nb_slot_frame; for(int i=0; i < num_ind_fifo; i++) { - UE->tx_wait_for_dlsch[num_ind_fifo] = 0; - UE->tx_resume_ind_fifo[i] = malloc(sizeof(*UE->tx_resume_ind_fifo[i])); - initNotifiedFIFO(UE->tx_resume_ind_fifo[i]); + initNotifiedFIFO(UE->tx_resume_ind_fifo + i); } while (!oai_exit) { @@ -836,6 +863,13 @@ void *UE_thread(void *arg) decoded_frame_rx++; // we do ++ first in the regular processing, so it will be begin of frame; absolute_slot = decoded_frame_rx * nb_slot_frame - 1; + // We have resynchronized, maybe after RF loss so we need to purge any existing context + memset(tx_wait_for_dlsch, 0, sizeof(tx_wait_for_dlsch)); + for (int i = 0; i < num_ind_fifo; i++) { + notifiedFIFO_elt_t *res; + while ((res = pollNotifiedFIFO(UE->tx_resume_ind_fifo + i))) + delNotifiedFIFO_elt(res); + } continue; } @@ -913,26 +947,27 @@ void *UE_thread(void *arg) if (curMsg.proc.nr_slot_tx == 0) nr_ue_rrc_timer_trigger(UE->Mod_id, curMsg.proc.frame_tx, curMsg.proc.gNB_id); + // RX slot processing. We launch and forget. + notifiedFIFO_elt_t *newRx = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), curMsg.proc.nr_slot_rx, NULL, UE_dl_processing); + nr_rxtx_thread_data_t *curMsgRx = (nr_rxtx_thread_data_t *)NotifiedFifoData(newRx); + *curMsgRx = (nr_rxtx_thread_data_t){.proc = curMsg.proc, .UE = UE}; + UE_dl_preprocessing(UE, &curMsgRx->proc, tx_wait_for_dlsch, &curMsgRx->phy_data); + pushTpool(&(get_nrUE_params()->Tpool), newRx); + // Start TX slot processing here. It runs in parallel with RX slot processing - notifiedFIFO_elt_t *newElt = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), curMsg.proc.nr_slot_tx, &txFifo, processSlotTX); - nr_rxtx_thread_data_t *curMsgTx = (nr_rxtx_thread_data_t *) NotifiedFifoData(newElt); + // in current code, DURATION_RX_TO_TX constant is the limit to get UL data to encode from a RX slot + notifiedFIFO_elt_t *newTx = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), curMsg.proc.nr_slot_tx, &txFifo, processSlotTX); + nr_rxtx_thread_data_t *curMsgTx = (nr_rxtx_thread_data_t *)NotifiedFifoData(newTx); curMsgTx->proc = curMsg.proc; curMsgTx->writeBlockSize = writeBlockSize; curMsgTx->proc.timestamp_tx = writeTimestamp; curMsgTx->UE = UE; - curMsgTx->tx_wait_for_dlsch = UE->tx_wait_for_dlsch[curMsgTx->proc.nr_slot_tx]; - UE->tx_wait_for_dlsch[curMsgTx->proc.nr_slot_tx] = 0; - pushTpool(&(get_nrUE_params()->Tpool), newElt); - - // RX slot processing. We launch and forget. - newElt = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), curMsg.proc.nr_slot_rx, NULL, UE_dl_processing); - nr_rxtx_thread_data_t *curMsgRx = (nr_rxtx_thread_data_t *) NotifiedFifoData(newElt); - curMsgRx->proc = curMsg.proc; - curMsgRx->UE = UE; - curMsgRx->phy_data = UE_dl_preprocessing(UE, &curMsg.proc); - pushTpool(&(get_nrUE_params()->Tpool), newElt); + curMsgTx->tx_wait_for_dlsch = tx_wait_for_dlsch[curMsgTx->proc.nr_slot_tx]; + tx_wait_for_dlsch[curMsgTx->proc.nr_slot_tx] = 0; + pushTpool(&(get_nrUE_params()->Tpool), newTx); // Wait for TX slot processing to finish + // Should be removed when bugs, race conditions, will be fixed notifiedFIFO_elt_t *res; res = pullTpool(&txFifo, &(get_nrUE_params()->Tpool)); if (res == NULL) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 1af7e8852f..a2734496ca 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -426,7 +426,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, rdata->offset = offset; rdata->dlsch = dlsch; rdata->dlsch_id = 0; - rdata->proc = proc; + rdata->proc = *proc; reset_meas(&rdata->ts_deinterleave); reset_meas(&rdata->ts_rate_unmatch); reset_meas(&rdata->ts_ldpc_decode); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 2aef2782ae..f57d3f8479 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -613,8 +613,7 @@ typedef struct { void *phy_sim_pdsch_dl_ch_estimates_ext; uint8_t *phy_sim_dlsch_b; notifiedFIFO_t phy_config_ind; - notifiedFIFO_t *tx_resume_ind_fifo[NR_MAX_SLOTS_PER_FRAME]; - int tx_wait_for_dlsch[NR_MAX_SLOTS_PER_FRAME]; + notifiedFIFO_t tx_resume_ind_fifo[NR_MAX_SLOTS_PER_FRAME]; } PHY_VARS_NR_UE; typedef struct { @@ -649,7 +648,6 @@ typedef struct nr_rxtx_thread_data_s { UE_nr_rxtx_proc_t proc; PHY_VARS_NR_UE *UE; int writeBlockSize; - notifiedFIFO_t txFifo; nr_phy_data_t phy_data; int tx_wait_for_dlsch; } nr_rxtx_thread_data_t; @@ -677,7 +675,7 @@ typedef struct LDPCDecode_ue_s { time_stats_t ts_deinterleave; time_stats_t ts_rate_unmatch; time_stats_t ts_ldpc_decode; - UE_nr_rxtx_proc_t *proc; + UE_nr_rxtx_proc_t proc; } ldpcDecode_ue_t; #include "SIMULATION/ETH_TRANSPORT/defs.h" diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index f4aec4b8dc..14091975f3 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -488,20 +488,17 @@ int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, return(dci_cnt); } -int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - NR_UE_DLSCH_t dlsch[2], - int16_t *llr[2], - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + NR_UE_DLSCH_t dlsch[2], + int16_t *llr[2], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; int m; int first_symbol_flag=0; - if (!dlsch[0].active) - return 0; - // We handle only one CW now if (!(NR_MAX_NB_LAYERS>4)) { NR_UE_DLSCH_t *dlsch0 = &dlsch[0]; @@ -637,23 +634,23 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, return 0; } -void send_slot_ind(notifiedFIFO_t *nf, int slot) { +// This function release the Tx working thread for one pending information, like dlsch ACK/NACK +static void send_dl_done_to_tx_thread(notifiedFIFO_t *nf, int rx_slot) +{ if (nf) { notifiedFIFO_elt_t *newElt = newNotifiedFIFO_elt(sizeof(int), 0, NULL, NULL); + // We put rx slot only for tracing purpose int *msgData = (int *) NotifiedFifoData(newElt); - *msgData = slot; + *msgData = rx_slot; pushNotifiedFIFO(nf, newElt); } } -bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - NR_UE_DLSCH_t dlsch[2], - int16_t* llr[2]) { - +static bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, NR_UE_DLSCH_t dlsch[2], int16_t *llr[2]) +{ if (dlsch[0].active == false) { LOG_E(PHY, "DLSCH should be active when calling this function\n"); - return 1; + return true; } int gNB_id = proc->gNB_id; @@ -688,8 +685,9 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, // exit dlsch procedures as there are no active dlsch if (is_cw0_active != ACTIVE && is_cw1_active != ACTIVE) { // don't wait anymore + LOG_E(NR_PHY, "Internal error nr_ue_dlsch_procedure() called but no active cw on slot %d, harq %d\n", nr_slot_rx, harq_pid); const int ack_nack_slot = (proc->nr_slot_rx + dlsch[0].dlsch_config.k1_feedback) % ue->frame_parms.slots_per_frame; - send_slot_ind(ue->tx_resume_ind_fifo[ack_nack_slot], proc->nr_slot_rx); + send_dl_done_to_tx_thread(ue->tx_resume_ind_fifo + ack_nack_slot, proc->nr_slot_rx); return false; } @@ -821,7 +819,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, LOG_D(PHY, "AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats.p_time)/(cpuf*1000.0)); } - LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch[1].dlsch_config.TBS); + LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch[1].dlsch_config.TBS); } // send to mac @@ -829,8 +827,11 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, ue->if_inst->dl_indication(&dl_indication); } - const int ack_nack_slot = (proc->nr_slot_rx + dlsch[0].dlsch_config.k1_feedback) % ue->frame_parms.slots_per_frame; - send_slot_ind(ue->tx_resume_ind_fifo[ack_nack_slot], proc->nr_slot_rx); + // DLSCH decoding finished! don't wait anymore in Tx process, we know if we should answer ACK/NACK PUCCH + if (dlsch[0].rnti_type == TYPE_C_RNTI_) { + const int ack_nack_slot = (proc->nr_slot_rx + dlsch[0].dlsch_config.k1_feedback) % ue->frame_parms.slots_per_frame; + send_dl_done_to_tx_thread(ue->tx_resume_ind_fifo + ack_nack_slot, proc->nr_slot_rx); + } if (ue->phy_sim_dlsch_b) memcpy(ue->phy_sim_dlsch_b, p_b, dlsch_bytes); @@ -1097,9 +1098,12 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ if (ret_pdsch >= 0) nr_ue_dlsch_procedures(ue, proc, dlsch, llr); - else - // don't wait anymore - send_slot_ind(ue->tx_resume_ind_fifo[(proc->nr_slot_rx + dlsch_config->k1_feedback) % ue->frame_parms.slots_per_frame], proc->nr_slot_rx); + else { + LOG_E(NR_PHY, "Demodulation impossible, internal error\n"); + 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); + } stop_meas(&ue->dlsch_procedures_stat); if (cpumeas(CPUMEAS_GETSTATE)) { From 4f5a5c461faea8b5056a2053832e573aa6f6356b Mon Sep 17 00:00:00 2001 From: Duncan Joly Date: Wed, 10 Jan 2024 09:22:59 +0000 Subject: [PATCH 10/13] Fixed typo --- openair1/PHY/INIT/lte_init_ru.c | 2 +- openair1/PHY/INIT/nr_init_ru.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/lte_init_ru.c b/openair1/PHY/INIT/lte_init_ru.c index c07c9230d8..62e8c1d5d3 100644 --- a/openair1/PHY/INIT/lte_init_ru.c +++ b/openair1/PHY/INIT/lte_init_ru.c @@ -186,7 +186,7 @@ int phy_init_RU(RU_t *ru) { void phy_free_RU(RU_t *ru) { int i,j,p; RU_CALIBRATION *calibration = &ru->calibration; - LOG_I(PHY, "Feeing RU signal buffers (if_south %s) nb_tx %d\n", ru_if_types[ru->if_south], ru->nb_tx); + LOG_I(PHY, "Freeing RU signal buffers (if_south %s) nb_tx %d\n", ru_if_types[ru->if_south], ru->nb_tx); if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so free memory for time-domain signals for (i = 0; i < ru->nb_tx; i++) free_and_zero(ru->common.txdata[i]); diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index 6b433f17d1..0a1a0322c5 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -168,7 +168,7 @@ void nr_phy_free_RU(RU_t *ru) int i,j; int p; - LOG_I(PHY, "Feeing RU signal buffers (if_south %s) nb_tx %d\n", ru_if_types[ru->if_south], ru->nb_tx); + LOG_I(PHY, "Freeing RU signal buffers (if_south %s) nb_tx %d\n", ru_if_types[ru->if_south], ru->nb_tx); if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so free memory for time-domain signals // Hack: undo what is done at allocation From 4226daee7f795ccf2a131cfe96e3540a054b9b4c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 8 Jan 2024 16:29:58 +0100 Subject: [PATCH 11/13] USRP doc: Include b205-mini, improve markup --- radio/USRP/README.md | 50 ++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/radio/USRP/README.md b/radio/USRP/README.md index c1c555828c..cd3f5f10ba 100644 --- a/radio/USRP/README.md +++ b/radio/USRP/README.md @@ -1,14 +1,29 @@ -USRP device documentation +[[_TOC_]] -OAI works with the most common USRP models like, B200, B200mini, B210, X310, N300, N310, N320, X410. This is achieved by using the Ettus Universal Hardware Driver (UHD) (https://github.com/EttusResearch/uhd). The file usrp_lib.cpp provides an abstraction layer of UHD to OAI. +# USRP device documentation -The USRP can be configured in the RU section of the config file. The field "sdr_addrs" uses the same syntax as the USRP device identification string (https://files.ettus.com/manual/page_identification.html). Here are a few examples +## General + +OAI works with most common USRP models, like B200, B200mini/B205mini, B210, +X310, N300, N310, N320, X410. This is achieved by using the Ettus Universal +Hardware Driver (UHD) (https://github.com/EttusResearch/uhd). The file +[`usrp_lib.cpp`](./usrp_lib.cpp) provides an abstraction layer of UHD to OAI. + +Example files can be found in the `ci-scripts/conf_files/` directory with a +`usrp` in the name, for instance +[`gnb.sa.band78.106prb.usrpn310.ddsuu-2x2.conf`](../../ci-scripts/conf_files/gnb.sa.band78.106prb.usrpn310.ddsuu-2x2.conf). + +## Configuration + +The USRP can be configured in the RU section of the config file. The field +`sdr_addrs` uses the [USRP device identification +string](https://files.ettus.com/manual/page_identification.html). Here are a +few examples ```bash sdr_addrs = "addr=192.168.10.2" # uses a single 10Gb Ethernet interface on an N3x0 or X3x0 or X4x0 - - sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2" # uses 2 10Gb Ethernet interfaces on a N3x0 or X3x0 or X4x0 (requires that you flashed the FPGA wth the XG image) +sdr_addrs = "serial=ABC1234" # globally unique identifier of this device ``` you can also use the multi USRP feature and specify multiple USRPs, in which case you will get the aggregated number of channels on all the devices @@ -17,7 +32,9 @@ you can also use the multi USRP feature and specify multiple USRPs, in which cas sdr_addrs = "addr0=192.168.10.2,addr1=192.168.30.2" ``` -You can specify if you want to use external or interal clock or time source either by adding the parameters in the sdr_addrs field or by using the fields clock_src or time_src +You can specify to use external or interal clock or time source either by +adding the parameters in the `sdr_addrs` field or by using the fields +`clock_src` or `time_src` ```bash sdr_addrs = "addr=192.168.10.2,clock_source=external,time_source=external" @@ -31,15 +48,23 @@ clock_src = "external" time_src = "external" ``` -Valid choices for clock and time source are "internal", "external", and "gpsdo". +Valid choices for clock and time source are `internal`, `external`, and `gpsdo`. -Note 1: the USRP remembers the choice of the clock source. If you want to make sure it uses always the same, always specify the clock_source and time_source. +Note 1: the USRP remembers the choice of the clock source. If you want to make +sure it uses always the same, always specify the `clock_source` and +`time_source`. -Note 2: when using multiple USRPs they always have to be synchronized using "external" or "gpsdo" +Note 2: when using multiple USRPs they always have to be synchronized using +`external` or `gpsdo` -Last but not least you may specify that only a specfic subdevice of the USRP is used. See also https://files.ettus.com/manual/page_configuration.html#config_subdev +Last but not least you may specify that only a specfic subdevice of the USRP is +used. See also the section [Specifying the +Subdevice](https://files.ettus.com/manual/page_configuration.html#config_subdev) +in the UHD manual. -For example on a USRP N310 the following fields will specify that you use channel 0 of subdevice A. You can enter this information after providing the ip addresses of the USRPs in sdr_addrs. +For example, on a USRP N310, the following fields will specify that you use +channel 0 of subdevice A. You can enter this information after providing the ip +addresses of the USRPs in `sdr_addrs`. ```bash tx_subdev = "A:0" @@ -67,9 +92,8 @@ RUs = ( } ); ``` -Hint: -You cannot see TX/RX spread over multiple USRPs, if you use "internal" as a refrence of the clock and time source. +Hint: You cannot see TX/RX spread over multiple USRPs, if you use `internal` as a refrence of the clock and time source. Furthur information about synchronization on the USRP N3xx devices can be found here: https://kb.ettus.com/Using_Ethernet-Based_Synchronization_on_the_USRP%E2%84%A2_N3xx_Devices From 4958f8b6d7816b2ad7f180aef8abbf96d91a4760 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Thu, 11 Jan 2024 15:09:24 +0100 Subject: [PATCH 12/13] segv on null pointer --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 425782cddc..e49c0b3730 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -839,10 +839,9 @@ static void nr_generate_Msg3_retransmission(module_id_t module_idP, dci_pdu->beta_PDCCH_1_0 = 0; dci_pdu->powerControlOffsetSS = 1; - dci_pdu_rel15_t uldci_payload; - memset(&uldci_payload, 0, sizeof(uldci_payload)); + dci_pdu_rel15_t uldci_payload={0}; - config_uldci(NULL, + config_uldci(sc_info, pusch_pdu, &uldci_payload, NULL, From f24cff929e45d1cdee2c56e10eb0d423339afcda Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Thu, 11 Jan 2024 15:04:56 +0100 Subject: [PATCH 13/13] make better version of nr_get_msg3_payload() --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 40 ++++++++------------ openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 3 +- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 54a10bfab6..ab5cae1a63 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -502,7 +502,7 @@ void set_ra_rnti(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_prach_pdu *prach_pdu); void nr_Msg1_transmitted(module_id_t mod_id); void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id); -void nr_get_msg3_payload(module_id_t mod_id); +void nr_get_msg3_payload(module_id_t mod_id, uint8_t *buf, int TBS_max); void send_msg3_rrc_request(module_id_t mod_id, int rnti); void nr_ue_msg2_scheduler(module_id_t mod_id, uint16_t rach_frame, uint16_t rach_slot, uint16_t *msg2_frame, uint16_t *msg2_slot); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index b9d9f7a8fc..5a80122d67 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -608,23 +608,25 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot ra->ra_state = WAIT_CONTENTION_RESOLUTION; } -void nr_get_msg3_payload(module_id_t mod_id) +void nr_get_msg3_payload(module_id_t mod_id, uint8_t *buf, int TBS_max) { NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); RA_config_t *ra = &mac->ra; - uint8_t *pdu = mac->CCCH_pdu.payload; - const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_FIXED); - NR_MAC_SUBHEADER_FIXED *header = (NR_MAC_SUBHEADER_FIXED *) pdu; - pdu += sh_size; - int lcid = 0; // SRB0 for messages sent in MSG3 + uint8_t *pdu = buf; + *(NR_MAC_SUBHEADER_FIXED *)pdu = (NR_MAC_SUBHEADER_FIXED){.LCID = UL_SCH_LCID_CCCH}; + pdu += sizeof(NR_MAC_SUBHEADER_FIXED); + // here a big race condition: nothing ensure RRC thread has already pushed data to rlc + // there is no issue inside RLC, + // if RRC has called nr_rlc_srb_recv_sdu(), + // we are good even if the name is misleading (we send a ssrb msg, not receive if) tbs_size_t len = mac_rlc_data_req(mod_id, ra->t_crnti, 0, 0, ENB_FLAG_NO, MBMS_FLAG_NO, - lcid, - 16, /* size of mac_ce above */ + 0, // SRB0 for messages sent in MSG3 + TBS_max - sizeof(NR_MAC_SUBHEADER_FIXED), /* size of mac_ce above */ (char *)pdu, 0, 0); @@ -632,26 +634,16 @@ void nr_get_msg3_payload(module_id_t mod_id) // UE Contention Resolution Identity // Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to determine whether or not the // Random Access Procedure has been successful after reception of Msg4 + // We copy from persisted memory to another persisted memory memcpy(ra->cont_res_id, pdu, sizeof(uint8_t) * 6); pdu += len; - int Msg3_size = len + sh_size; - // Build header - header->R = 0; - header->LCID = UL_SCH_LCID_CCCH; - const uint8_t TBS_max = 8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); // Note: unclear the reason behind the selection of such TBS_max + AssertFatal(TBS_max >= pdu - buf, "Allocated resources are not enough for Msg3!\n"); // Padding: fill remainder with 0 - if (TBS_max - Msg3_size > 0) { - AssertFatal(TBS_max > Msg3_size, "Allocated resources are not enough for Msg3!\n"); - LOG_D(NR_MAC, "Remaining %d bytes, filling with padding\n",TBS_max - Msg3_size); - ((NR_MAC_SUBHEADER_FIXED *) pdu)->R = 0; - ((NR_MAC_SUBHEADER_FIXED *) pdu)->LCID = UL_SCH_LCID_PADDING; + LOG_D(NR_MAC, "Remaining %ld bytes, filling with padding\n", pdu - buf); + while (pdu < buf + TBS_max - sizeof(NR_MAC_SUBHEADER_FIXED)) { + *(NR_MAC_SUBHEADER_FIXED *)pdu = (NR_MAC_SUBHEADER_FIXED){.LCID = UL_SCH_LCID_PADDING}; pdu += sizeof(NR_MAC_SUBHEADER_FIXED); - memset(pdu, 0, TBS_max - Msg3_size - sizeof(NR_MAC_SUBHEADER_FIXED)); } - // Dumping ULSCH payload - LOG_D(NR_MAC, "Dumping UL Msg3 MAC PDU with length %d: \n", TBS_max); - for(int k = 0; k < TBS_max; k++) - LOG_D(NR_MAC,"(%i): %i\n", k, pdu[k]); } /** @@ -710,7 +702,7 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, int size_sdu = 0; uint8_t mac_ce[16] = {0}; uint8_t *pdu = get_softmodem_params()->sa ? mac->CCCH_pdu.payload : mac_ce; - uint8_t *payload = pdu; + const uint8_t *payload = pdu; // Concerning the C-RNTI MAC CE, it has to be included if the UL transmission (Msg3) is not being made for the CCCH logical channel. // Therefore it has been assumed that this event only occurs only when RA is done and it is not SA mode. diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 75e959f6cc..51cb1a0bbb 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1036,8 +1036,7 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator, TBS_bytes,ra->ra_state); if (ra->ra_state == WAIT_RAR && !ra->cfra) { - nr_get_msg3_payload(mod_id); - memcpy(ulsch_input_buffer, mac->CCCH_pdu.payload, TBS_bytes); + nr_get_msg3_payload(mod_id, ulsch_input_buffer, TBS_bytes); for (int k = 0; k < TBS_bytes; k++) { LOG_D(NR_MAC,"(%i): 0x%x\n", k, ulsch_input_buffer[k]); }