From 8013d5d8ccb8f5e4a9bb9a6b89258a9d0e917500 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 20 Oct 2023 11:36:35 +0200 Subject: [PATCH 1/8] removing CellGroup dependance from MAC common functions --- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 3 ++ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 26 +++++------ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 6 +-- openair2/LAYER2/NR_MAC_UE/config_ue.c | 10 ++++- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 5 +-- .../NR_MAC_UE/nr_ue_dci_configuration.c | 26 +++++++++-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 11 ++--- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 3 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 6 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 4 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 45 ++++++++++++++++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 4 +- 12 files changed, 99 insertions(+), 50 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index affac3fbd4..d33390d75a 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -573,6 +573,7 @@ typedef struct NR_UE_DL_BWP { long *pdsch_HARQ_ACK_Codebook; uint8_t mcsTableIdx; nr_dci_format_t dci_format; + int bw_tbslbrm; } NR_UE_DL_BWP_t; typedef struct NR_UE_UL_BWP { @@ -591,6 +592,7 @@ typedef struct NR_UE_UL_BWP { NR_PUSCH_Config_t *pusch_Config; NR_PUCCH_Config_t *pucch_Config; NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; + NR_UplinkConfig_t *supplementaryUplink; long *harq_ACK_SpatialBundlingPUCCH; NR_CSI_MeasConfig_t *csi_MeasConfig; NR_SRS_Config_t *srs_Config; @@ -598,6 +600,7 @@ typedef struct NR_UE_UL_BWP { long transform_precoding; uint8_t mcs_table; nr_dci_format_t dci_format; + int bw_tbslbrm; int max_fb_time; } NR_UE_UL_BWP_t; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 14bce7f816..5498a2c9ae 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3278,7 +3278,7 @@ uint16_t get_rb_bwp_dci(nr_dci_format_t format, uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, - const NR_CellGroupConfig_t *cg, + NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, @@ -3328,12 +3328,12 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, /// fixed: Format identifier 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2, ULSCH indicator 1 --16 size += 16; // Carrier indicator - if (cg->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig != NULL) { + if (crossCarrierSchedulingConfig != NULL) { dci_pdu->carrier_indicator.nbits=3; size += dci_pdu->carrier_indicator.nbits; } // UL/SUL indicator - if (cg->spCellConfig->spCellConfigDedicated->supplementaryUplink != NULL) { + if (UL_BWP->supplementaryUplink != NULL) { dci_pdu->carrier_indicator.nbits=1; size += dci_pdu->ul_sul_indicator.nbits; } @@ -3416,7 +3416,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, size += dci_pdu->antenna_ports.nbits; LOG_D(NR_MAC,"dci_pdu->antenna_ports.nbits = %d\n",dci_pdu->antenna_ports.nbits); // SRS request - if (cg->spCellConfig->spCellConfigDedicated->supplementaryUplink==NULL) + if (UL_BWP->supplementaryUplink == NULL) dci_pdu->srs_request.nbits = 2; else dci_pdu->srs_request.nbits = 3; @@ -3481,7 +3481,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, // Format identifier size = 1; // Carrier indicator - if (cg->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig != NULL) { + if (crossCarrierSchedulingConfig != NULL) { dci_pdu->carrier_indicator.nbits=3; size += dci_pdu->carrier_indicator.nbits; } @@ -3575,7 +3575,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, size += dci_pdu->transmission_configuration_indication.nbits; } // SRS request - if (cg->spCellConfig->spCellConfigDedicated->supplementaryUplink==NULL) + if (UL_BWP->supplementaryUplink == NULL) dci_pdu->srs_request.nbits = 2; else dci_pdu->srs_request.nbits = 3; @@ -4734,11 +4734,10 @@ uint16_t compute_pucch_prb_size(uint8_t format, } int get_dlbw_tbslbrm(int scc_bwpsize, - NR_CellGroupConfig_t *cg) { - + NR_ServingCellConfig_t *servingCellConfig) +{ int bw = scc_bwpsize; - if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated) { - const NR_ServingCellConfig_t *servingCellConfig = cg->spCellConfig->spCellConfigDedicated; + if (servingCellConfig) { if(servingCellConfig->downlinkBWP_ToAddModList) { const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = servingCellConfig->downlinkBWP_ToAddModList; for (int i=0; ilist.count; i++) { @@ -4753,11 +4752,10 @@ int get_dlbw_tbslbrm(int scc_bwpsize, } int get_ulbw_tbslbrm(int scc_bwpsize, - NR_CellGroupConfig_t *cg) { - + NR_ServingCellConfig_t *servingCellConfig) +{ int bw = scc_bwpsize; - if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated) { - const NR_ServingCellConfig_t *servingCellConfig = cg->spCellConfig->spCellConfigDedicated; + if (servingCellConfig) { if (servingCellConfig->uplinkConfig && servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList) { const struct NR_UplinkConfig__uplinkBWP_ToAddModList *BWP_list = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index d21e441978..059dc31acd 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -95,7 +95,7 @@ NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, - const NR_CellGroupConfig_t *cg, + NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, @@ -196,10 +196,10 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset); int get_dlbw_tbslbrm(int scc_bwpsize, - NR_CellGroupConfig_t *cg); + NR_ServingCellConfig_t *servingCellConfig); int get_ulbw_tbslbrm(int scc_bwpsize, - NR_CellGroupConfig_t *cg); + NR_ServingCellConfig_t *servingCellConfig); uint32_t nr_compute_tbslbrm(uint16_t table, uint16_t nb_rb, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index b1624126bb..e6c494aa27 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -570,6 +570,8 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, configure_ss_coreset(mac, mac->bwp_dlcommon->pdcch_ConfigCommon->choice.setup, NULL); } + NR_ServingCellConfig_t *spCellConfigDedicated = NULL; + if(cell_group_config) { if (cell_group_config->physicalCellGroupConfig) { DL_BWP->pdsch_HARQ_ACK_Codebook = &cell_group_config->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook; @@ -577,7 +579,8 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->spCellConfigDedicated) { - struct NR_ServingCellConfig *spCellConfigDedicated = cell_group_config->spCellConfig->spCellConfigDedicated; + spCellConfigDedicated = cell_group_config->spCellConfig->spCellConfigDedicated; + UL_BWP->supplementaryUplink = spCellConfigDedicated->supplementaryUplink; UL_BWP->csi_MeasConfig = spCellConfigDedicated->csi_MeasConfig ? spCellConfigDedicated->csi_MeasConfig->choice.setup : NULL; UL_BWP->pusch_servingcellconfig = spCellConfigDedicated->uplinkConfig && spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig ? spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; @@ -673,6 +676,8 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, DL_BWP->initial_BWPStart = NRRIV2PRBOFFSET(mac->bwp_dlcommon->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); UL_BWP->initial_BWPStart = NRRIV2PRBOFFSET(mac->bwp_ulcommon->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + DL_BWP->bw_tbslbrm = get_dlbw_tbslbrm(DL_BWP->initial_BWPSize, spCellConfigDedicated); + UL_BWP->bw_tbslbrm = get_ulbw_tbslbrm(UL_BWP->initial_BWPSize, spCellConfigDedicated); } void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs) @@ -762,7 +767,7 @@ void nr_rrc_mac_config_req_mcg(module_id_t module_id, mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; else mac->servCellIndex = 0; - + mac->crossCarrierSchedulingConfig = cell_group_config->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig; mac->scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; mac->scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE; @@ -803,6 +808,7 @@ void nr_rrc_mac_config_req_scg(module_id_t module_id, mac->cg = scell_group_config; mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex; + mac->crossCarrierSchedulingConfig = scell_group_config->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig; if (scell_group_config->spCellConfig->reconfigurationWithSync) handle_reconfiguration_with_sync(mac, module_id, cc_idP, scell_group_config->spCellConfig->reconfigurationWithSync); configure_current_BWP(mac, NULL, scell_group_config); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 068890f620..cb91486b97 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -429,7 +429,6 @@ typedef struct { NR_UE_L2_STATE_t state; NR_CellGroupConfig_t *cg; int servCellIndex; - NR_CSI_ReportConfig_t *csirc; long physCellId; //// MAC config int first_sync_frame; @@ -437,9 +436,6 @@ typedef struct { bool get_otherSI; NR_DRX_Config_t *drx_Config; NR_SchedulingRequestConfig_t *schedulingRequestConfig; - NR_BSR_Config_t *bsr_Config; - NR_TAG_Config_t *tag_Config; - NR_PHR_Config_t *phr_Config; NR_RNTI_Value_t *cs_RNTI; NR_MIB_t *mib; struct NR_SI_SchedulingInfo *si_SchedulingInfo; @@ -462,6 +458,7 @@ typedef struct { NR_SearchSpace_t *search_space_zero; NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon; + NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig; bool phy_config_request_sent; frame_type_t frame_type; 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 d89dc44ef3..4c281239ec 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -186,15 +186,35 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, dci_pdu_rel15_t temp_pdu; if(dci_format == NR_DL_DCI_FORMAT_1_0) alt_size = - nr_dci_size(current_DL_BWP, current_UL_BWP, mac->cg, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); + nr_dci_size(current_DL_BWP, + current_UL_BWP, + mac->crossCarrierSchedulingConfig, + &temp_pdu, + NR_UL_DCI_FORMAT_0_0, + rnti_type, + coreset, + dl_bwp_id, + ss->searchSpaceType->present, + mac->type0_PDCCH_CSS_config.num_rbs, + 0); if(dci_format == NR_UL_DCI_FORMAT_0_0) alt_size = - nr_dci_size(current_DL_BWP, current_UL_BWP, mac->cg, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); + nr_dci_size(current_DL_BWP, + current_UL_BWP, + mac->crossCarrierSchedulingConfig, + &temp_pdu, + NR_DL_DCI_FORMAT_1_0, + rnti_type, + coreset, + dl_bwp_id, + ss->searchSpaceType->present, + mac->type0_PDCCH_CSS_config.num_rbs, + 0); } rel15->dci_length_options[i] = nr_dci_size(current_DL_BWP, current_UL_BWP, - mac->cg, + mac->crossCarrierSchedulingConfig, &mac->def_dci_pdu_rel15[dl_config->slot][dci_format], dci_format, rnti_type, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index f5902bed27..9251b9b38a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -735,11 +735,9 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id, dlsch_pdu->TBS = current_harq->TBS; } - int bw_tbslbrm; - if (current_DL_BWP->initial_BWPSize > 0) - bw_tbslbrm = get_dlbw_tbslbrm(current_DL_BWP->initial_BWPSize, mac->cg); - else - bw_tbslbrm = dlsch_pdu->BWPSize; + int bw_tbslbrm = current_DL_BWP->initial_BWPSize > 0 ? + current_DL_BWP->bw_tbslbrm : + dlsch_pdu->BWPSize; dlsch_pdu->tbslbrm = nr_compute_tbslbrm(dlsch_pdu->mcs_table, bw_tbslbrm, 1); /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ @@ -1164,8 +1162,7 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id, long *maxMIMO_Layers = current_DL_BWP->pdsch_servingcellconfig->ext1->maxMIMO_Layers; AssertFatal(maxMIMO_Layers != NULL, "Option with max MIMO layers not configured is not supported\n"); int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; - int bw_tbslbrm = get_dlbw_tbslbrm(current_DL_BWP->initial_BWPSize, mac->cg); - dlsch_pdu->tbslbrm = nr_compute_tbslbrm(dlsch_pdu->mcs_table, bw_tbslbrm, nl_tbslbrm); + dlsch_pdu->tbslbrm = nr_compute_tbslbrm(dlsch_pdu->mcs_table, current_DL_BWP->bw_tbslbrm, nl_tbslbrm); /*PTRS configuration */ dlsch_pdu->pduBitmap = 0; if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index e5ecba5efc..2cf83fc4dc 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -667,9 +667,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, if (!maxMIMO_Layers) maxMIMO_Layers = pusch_Config ? pusch_Config->maxRank : NULL; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); - int bw_tbslbrm = get_ulbw_tbslbrm(current_UL_BWP->initial_BWPSize, mac->cg); pusch_config_pdu->tbslbrm = nr_compute_tbslbrm(pusch_config_pdu->mcs_table, - bw_tbslbrm, + current_UL_BWP->bw_tbslbrm, *maxMIMO_Layers); } else pusch_config_pdu->tbslbrm = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index d7a36ec131..ec4ade5563 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1312,9 +1312,8 @@ static void nr_generate_Msg2(module_id_t module_idP, pdsch_pdu_rel15->TBSize[0] = TBS; } - int bw_tbslbrm = get_dlbw_tbslbrm(dl_bwp->initial_BWPSize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, - bw_tbslbrm, + dl_bwp->bw_tbslbrm, 1); pdsch_pdu_rel15->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS<<3,R); @@ -1522,9 +1521,8 @@ static void prepare_dl_pdus(gNB_MAC_INST *nr_mac, int x_Overhead = 0; nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, tb_scaling); - int bw_tbslbrm = get_dlbw_tbslbrm(dl_bwp->initial_BWPSize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, - bw_tbslbrm, + dl_bwp->bw_tbslbrm, 1); pdsch_pdu_rel15->maintenance_parms_v3.ldpcBaseGraph = get_BG(tb_size<<3,R); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 4675403834..90233cab82 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1086,10 +1086,8 @@ void nr_schedule_ue_spec(module_id_t module_id, long maxMIMO_Layers = current_BWP->pdsch_servingcellconfig ? *current_BWP->pdsch_servingcellconfig->ext1->maxMIMO_Layers : 1; const int nl_tbslbrm = min(maxMIMO_Layers, 4); // Maximum number of PRBs across all configured DL BWPs - int scc_bwpsize = current_BWP->initial_BWPSize; - int bw_tbslbrm = get_dlbw_tbslbrm(scc_bwpsize, cg); pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(current_BWP->mcsTableIdx, - bw_tbslbrm, + current_BWP->bw_tbslbrm, nl_tbslbrm); pdsch_pdu->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS<<3,R); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index fdc3e79b6e..5697107c0b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1140,7 +1140,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, NR_ControlResourceSet_t *coreset, uint16_t cset0_bwp_size) { - + NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig = NULL; // TODO configure uint8_t fsize = 0, pos = 0; uint64_t *dci_pdu = (uint64_t *)pdcch_dci_pdu->Payload; *dci_pdu = 0; @@ -1158,16 +1158,46 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, // computing alternative size for padding dci_pdu_rel15_t temp_pdu; if(dci_format == NR_DL_DCI_FORMAT_1_0) - alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, CellGroup, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); + alt_size = nr_dci_size(current_DL_BWP, + current_UL_BWP, + crossCarrierSchedulingConfig, + &temp_pdu, + NR_UL_DCI_FORMAT_0_0, + rnti_type, + coreset, + bwp_id, + ss->searchSpaceType->present, + cset0_bwp_size, + 0); if(dci_format == NR_UL_DCI_FORMAT_0_0) - alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, CellGroup, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); + alt_size = nr_dci_size(current_DL_BWP, + current_UL_BWP, + crossCarrierSchedulingConfig, + &temp_pdu, + NR_DL_DCI_FORMAT_1_0, + rnti_type, + coreset, + bwp_id, + ss->searchSpaceType->present, + cset0_bwp_size, + 0); } else N_RB = cset0_bwp_size; - int dci_size = nr_dci_size(current_DL_BWP, current_UL_BWP, CellGroup, dci_pdu_rel15, dci_format, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, alt_size); + int dci_size = nr_dci_size(current_DL_BWP, + current_UL_BWP, + crossCarrierSchedulingConfig, + dci_pdu_rel15, + dci_format, + rnti_type, + coreset, + bwp_id, + ss->searchSpaceType->present, + cset0_bwp_size, + alt_size); pdcch_dci_pdu->PayloadSizeBits = dci_size; AssertFatal(dci_size <= 64, "DCI sizes above 64 bits not yet supported"); if (dci_format == NR_DL_DCI_FORMAT_1_1 || dci_format == NR_UL_DCI_FORMAT_0_1) @@ -2027,11 +2057,13 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, if (CellGroup && CellGroup->physicalCellGroupConfig) DL_BWP->pdsch_HARQ_ACK_Codebook = &CellGroup->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook; + NR_ServingCellConfig_t *servingCellConfig = NULL; if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { - const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; + servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; + UL_BWP->supplementaryUplink = servingCellConfig->supplementaryUplink; DL_BWP->pdsch_servingcellconfig = servingCellConfig->pdsch_ServingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; UL_BWP->pusch_servingcellconfig = servingCellConfig->uplinkConfig && servingCellConfig->uplinkConfig->pusch_ServingCellConfig ? servingCellConfig->uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; @@ -2144,6 +2176,9 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, UL_BWP->initial_BWPSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); UL_BWP->initial_BWPStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + DL_BWP->bw_tbslbrm = get_dlbw_tbslbrm(DL_BWP->initial_BWPSize, servingCellConfig); + UL_BWP->bw_tbslbrm = get_ulbw_tbslbrm(UL_BWP->initial_BWPSize, servingCellConfig); + if (UL_BWP->bwp_id > 0) { UL_BWP->pucch_ConfigCommon = ul_bwp->bwp_Common->pucch_ConfigCommon ? ul_bwp->bwp_Common->pucch_ConfigCommon->choice.setup : NULL; UL_BWP->rach_ConfigCommon = ul_bwp->bwp_Common->rach_ConfigCommon ? ul_bwp->bwp_Common->rach_ConfigCommon->choice.setup : NULL; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 761bbf6535..cc9a6c9f84 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -2288,10 +2288,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n if (!maxMIMO_Layers) maxMIMO_Layers = current_BWP->pusch_Config->maxRank; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); - const int scc_bwpsize = current_BWP->initial_BWPSize; - int bw_tbslbrm = get_ulbw_tbslbrm(scc_bwpsize, cg); pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(current_BWP->mcs_table, - bw_tbslbrm, + current_BWP->bw_tbslbrm, *maxMIMO_Layers); } else From 5661b20e9e5c17deb54ace8fb3ab0fc906b08d1d Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 20 Oct 2023 15:07:31 +0200 Subject: [PATCH 2/8] improving init for dora and phytest --- executables/nr-ue.c | 7 ++--- openair1/SIMULATION/NR_PHY/ulsim.c | 2 ++ openair2/LAYER2/NR_MAC_UE/config_ue.c | 2 ++ openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 18 ++++--------- openair2/RRC/NR_UE/main_ue.c | 37 +++++++++++++++++++++++--- openair2/RRC/NR_UE/rrc_UE.c | 37 ++++---------------------- openair2/RRC/NR_UE/rrc_proto.h | 7 +++-- 7 files changed, 57 insertions(+), 53 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index e7fcdcfa0f..071d36087c 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -944,14 +944,15 @@ void *UE_thread(void *arg) void init_NR_UE(int nb_inst, char *uecap_file, char *reconfig_file, char *rbconfig_file) { - int inst; NR_UE_MAC_INST_t *mac_inst; NR_UE_RRC_INST_t* rrc_inst; - for (inst=0; inst < nb_inst; inst++) { - AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file, reconfig_file, rbconfig_file)) != NULL, "can not initialize RRC module\n"); + for (int inst = 0; inst < nb_inst; inst++) { + AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file)) != NULL, "can not initialize RRC module\n"); AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n"); AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n"); + if (!get_softmodem_params()->sa) + init_nsa_message(rrc_inst, reconfig_file, rbconfig_file); } } diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index e08a8cfb3a..54d69c9611 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -695,6 +695,8 @@ int main(int argc, char *argv[]) nr_l2_init_ue(&rrcue); NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0); + + ue_init_config_request(UE_mac, mu); UE->if_inst = nr_ue_if_module_init(0); UE->if_inst->scheduled_response = nr_ue_scheduled_response; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index e6c494aa27..8b9d3f38ca 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -812,6 +812,8 @@ void nr_rrc_mac_config_req_scg(module_id_t module_id, if (scell_group_config->spCellConfig->reconfigurationWithSync) handle_reconfiguration_with_sync(mac, module_id, cc_idP, scell_group_config->spCellConfig->reconfigurationWithSync); configure_current_BWP(mac, NULL, scell_group_config); + if (!mac->dl_config_request || !mac->ul_config_request) + ue_init_config_request(mac, mac->current_DL_BWP.scs); // Setup the SSB to Rach Occasions mapping according to the config build_ssb_to_ro_map(mac); } diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 77c6fd6c8d..8cd5a05ee1 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -63,11 +63,9 @@ void send_msg3_rrc_request(module_id_t mod_id, int rnti) nr_mac_rrc_msg3_ind(mod_id, rnti); } -NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { - - //LOG_I(MAC, "[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n"); - - //LOG_I(MAC, "[MAIN] init UE MAC functions \n"); +NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) +{ + LOG_I(NR_MAC, "MAIN: init UE MAC functions \n"); //init mac here nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(NB_NR_UE_MAC_INST, sizeof(NR_UE_MAC_INST_t)); @@ -75,17 +73,11 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { for (int j = 0; j < NB_NR_UE_MAC_INST; j++) nr_ue_init_mac(j); - int scs = get_softmodem_params()->sa ? - get_softmodem_params()->numerology : - rrc_inst ? - *rrc_inst->scell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon->ssbSubcarrierSpacing : - - 1; - if (scs > -1) - ue_init_config_request(nr_ue_mac_inst, scs); + if (get_softmodem_params()->sa) + ue_init_config_request(nr_ue_mac_inst, get_softmodem_params()->numerology); if (rrc_inst && rrc_inst->scell_group_config) { - nr_rrc_mac_config_req_scg(0, 0, rrc_inst->scell_group_config); int rc = rlc_module_init(0); AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); nr_rlc_activate_srb0(nr_ue_mac_inst->crnti, NULL, send_srb0_rrc); diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c index 72853cd278..b558744e9e 100644 --- a/openair2/RRC/NR_UE/main_ue.c +++ b/openair2/RRC/NR_UE/main_ue.c @@ -33,10 +33,41 @@ #include "defs.h" #include "rrc_proto.h" #include "common/utils/LOG/log.h" +#include "executables/softmodem-common.h" -NR_UE_RRC_INST_t* nr_l3_init_ue(char* uecap, char* reconfig_file, char* rbconfig_file) +NR_UE_RRC_INST_t* nr_l3_init_ue(char* uecap) { - // LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n"); + return openair_rrc_top_init_ue_nr(uecap); +} - return openair_rrc_top_init_ue_nr(uecap, reconfig_file, rbconfig_file); +void init_nsa_message(NR_UE_RRC_INST_t *rrc, char* reconfig_file, char* rbconfig_file) +{ + if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1) { + // read in files for RRCReconfiguration and RBconfig + + LOG_I(NR_RRC, "using %s for rrc init[1/2]\n", reconfig_file); + FILE *fd = fopen(reconfig_file, "r"); + AssertFatal(fd, + "cannot read file %s: errno %d, %s\n", + reconfig_file, + errno, + strerror(errno)); + char buffer[1024]; + int msg_len = fread(buffer, 1, 1024, fd); + fclose(fd); + process_nsa_message(rrc, nr_SecondaryCellGroupConfig_r15, buffer, msg_len); + + LOG_I(NR_RRC, "using %s for rrc init[2/2]\n", rbconfig_file); + fd = fopen(rbconfig_file, "r"); + AssertFatal(fd, + "cannot read file %s: errno %d, %s\n", + rbconfig_file, + errno, + strerror(errno)); + msg_len = fread(buffer, 1, 1024, fd); + fclose(fd); + process_nsa_message(rrc, nr_RadioBearerConfigX_r15, buffer,msg_len); + } + else + LOG_D(NR_RRC, "In NSA mode \n"); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index e6712676e0..75f58af872 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -257,8 +257,10 @@ static void nr_rrc_ue_process_rrcReconfiguration(const instance_t instance, if (get_softmodem_params()->nsa) { nr_rrc_mac_config_req_scg(0, 0, secondCellGroupConfig); } - } else + } else { + nr_rrc_mac_config_req_scg(0, 0, secondCellGroupConfig); nr_rrc_ue_decode_secondary_cellgroup_config(rrc, secondCellGroupConfig); + } } if (ie->measConfig != NULL) { LOG_I(NR_RRC, "Measurement Configuration is present\n"); @@ -283,7 +285,7 @@ static void nr_rrc_ue_process_rrcReconfiguration(const instance_t instance, return; } -static void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message, int msg_len) +void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message, int msg_len) { switch (nsa_message_type) { case nr_SecondaryCellGroupConfig_r15: @@ -341,7 +343,7 @@ static void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message } } -NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* reconfig_file, char* rbconfig_file) +NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file) { if(NB_NR_UE_INST > 0) { NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)calloc(NB_NR_UE_INST , sizeof(NR_UE_RRC_INST_t)); @@ -368,35 +370,6 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* reconfig_fi NR_UE_rrc_inst->uecap_file = uecap_file; - if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1) { - // read in files for RRCReconfiguration and RBconfig - - LOG_I(NR_RRC, "using %s for rrc init[1/2]\n", reconfig_file); - FILE *fd = fopen(reconfig_file,"r"); - AssertFatal(fd, - "cannot read file %s: errno %d, %s\n", - reconfig_file, - errno, - strerror(errno)); - char buffer[1024]; - int msg_len=fread(buffer,1,1024,fd); - fclose(fd); - process_nsa_message(NR_UE_rrc_inst, nr_SecondaryCellGroupConfig_r15, buffer,msg_len); - - LOG_I(NR_RRC, "using %s for rrc init[2/2]\n", rbconfig_file); - fd = fopen(rbconfig_file,"r"); - AssertFatal(fd, - "cannot read file %s: errno %d, %s\n", - rbconfig_file, - errno, - strerror(errno)); - msg_len=fread(buffer,1,1024,fd); - fclose(fd); - process_nsa_message(NR_UE_rrc_inst, nr_RadioBearerConfigX_r15, buffer,msg_len); - } else if (get_softmodem_params()->nsa) { - LOG_D(NR_RRC, "In NSA mode \n"); - } - if (get_softmodem_params()->sl_mode) { configure_NR_SL_Preconfig(get_softmodem_params()->sync_ref); } diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 95330eabd2..565b9e813e 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -56,14 +56,17 @@ extern queue_t nr_ul_tti_req_queue; // main_rrc.c // /**\brief Layer 3 initialization*/ -NR_UE_RRC_INST_t *nr_l3_init_ue(char *, char *, char *); +NR_UE_RRC_INST_t *nr_l3_init_ue(char *); // // UE_rrc.c // /**\brief Initial the top level RRC structure instance*/ -NR_UE_RRC_INST_t *openair_rrc_top_init_ue_nr(char *, char *, char *); +NR_UE_RRC_INST_t *openair_rrc_top_init_ue_nr(char *); +void init_nsa_message (NR_UE_RRC_INST_t *rrc, char* reconfig_file, char* rbconfig_file); + +void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message, int msg_len); /**\brief interface between MAC and RRC thru SRB0 (RLC TM/no PDCP) \param module_id module id From 4d8bb4ef25404c08df942a0958237fb955d834d3 Mon Sep 17 00:00:00 2001 From: francescomani Date: Sat, 21 Oct 2023 18:25:53 +0200 Subject: [PATCH 3/8] unify handling of reconfiguration with sync --- executables/nr-uesoftmodem.c | 16 ++++++++------- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 2 +- openair1/SIMULATION/NR_PHY/dlsim.c | 4 +++- openair2/LAYER2/NR_MAC_UE/config_ue.c | 29 ++++++++++++--------------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 35bc218ac2..8e5751a190 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -437,8 +437,6 @@ int main( int argc, char **argv ) { if (set_exe_prio) set_priority(79); - //uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; - PHY_VARS_NR_UE *UE[MAX_NUM_CCs]; start_background_system(); if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL) { @@ -478,6 +476,13 @@ int main( int argc, char **argv ) { #endif LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); + PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE **)); + PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE *) * MAX_NUM_CCs); + for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[0][CC_id] = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE)); + memset(PHY_vars_UE_g[0][CC_id], 0, sizeof(PHY_VARS_NR_UE)); + } + init_NR_UE(1, uecap_file, reconfig_file, rbconfig_file); int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1; @@ -493,8 +498,6 @@ int main( int argc, char **argv ) { } } - PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE **)); - PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE *)*MAX_NUM_CCs); if (get_softmodem_params()->emulate_l1) { RCconfig_nr_ue_macrlc(); get_channel_model_mode(uniqCfg); @@ -510,10 +513,9 @@ int main( int argc, char **argv ) { start_oai_nrue_threads(); if (!get_softmodem_params()->emulate_l1) { - for (int CC_id=0; CC_idMod_id][phy_config->CC_id]->nrUE_config; if(phy_config != NULL) { - memcpy(nrUE_config,&phy_config->config_req,sizeof(fapi_nr_config_request_t)); + memcpy(nrUE_config, &phy_config->config_req, sizeof(fapi_nr_config_request_t)); pushNotifiedFIFO(&PHY_vars_UE_g[phy_config->Mod_id][phy_config->CC_id]->phy_config_ind, newNotifiedFIFO_elt(1,0,NULL,NULL)); } return 0; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 3b99bedbe9..fd68a3b9c3 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -835,7 +835,6 @@ int main(int argc, char **argv) UE->chest_time = chest_type[1]; UE_mac->if_module = nr_ue_if_module_init(0); - UE_mac->state = UE_CONNECTED; unsigned int available_bits=0; unsigned char *estimated_output_bit; @@ -855,6 +854,9 @@ int main(int argc, char **argv) nr_rrc_mac_config_req_mib(0, 0, mib->message.choice.mib, false); nr_rrc_mac_config_req_scg(0, 0, secondaryCellGroup); + UE_mac->state = UE_CONNECTED; + UE_mac->ra.ra_state = RA_SUCCEEDED; + nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; nr_phy_data_t phy_data = {0}; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 8b9d3f38ca..c93b607f9e 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -753,6 +753,19 @@ void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, mac->crnti = reconfigurationWithSync->newUE_Identity; LOG_I(NR_MAC, "Configuring CRNTI %x\n", mac->crnti); config_common_ue(mac, scc, module_id, cc_idP); + + mac->state = UE_NOT_SYNC; + ra->ra_state = RA_UE_IDLE; + nr_ue_mac_default_configs(mac); + + if (!get_softmodem_params()->emulate_l1) { + mac->synch_request.Mod_id = module_id; + mac->synch_request.CC_id = cc_idP; + mac->synch_request.synch_req.target_Nid_cell = mac->physCellId; + mac->if_module->synch_request(&mac->synch_request); + mac->if_module->phy_config_request(&mac->phy_config); + mac->phy_config_request_sent = true; + } } void nr_rrc_mac_config_req_mcg(module_id_t module_id, @@ -778,23 +791,7 @@ void nr_rrc_mac_config_req_mcg(module_id_t module_id, if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) { LOG_A(NR_MAC, "Received the reconfigurationWithSync in %s\n", __FUNCTION__); - handle_reconfiguration_with_sync(mac, module_id, cc_idP, cell_group_config->spCellConfig->reconfigurationWithSync); - - mac->state = UE_NOT_SYNC; - mac->ra.ra_state = RA_UE_IDLE; - nr_ue_mac_default_configs(mac); - - if (!get_softmodem_params()->emulate_l1) { - mac->synch_request.Mod_id = module_id; - mac->synch_request.CC_id = cc_idP; - mac->synch_request.synch_req.target_Nid_cell = mac->physCellId; - mac->if_module->synch_request(&mac->synch_request); - mac->if_module->phy_config_request(&mac->phy_config); - mac->phy_config_request_sent = true; - } - // Setup the SSB to Rach Occasions mapping according to the config - build_ssb_to_ro_map(mac); } configure_current_BWP(mac, NULL, cell_group_config); } From df917624db53800173c6976724d2f80c233601e2 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 23 Oct 2023 12:21:38 +0200 Subject: [PATCH 4/8] function to configure cellgroup at RRC --- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 251 +++++++++---------------- openair2/RRC/NR_UE/rrc_defs.h | 8 +- openair2/RRC/NR_UE/rrc_proto.h | 4 + 4 files changed, 100 insertions(+), 165 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 8cd5a05ee1..bbc3da1739 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -76,7 +76,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) if (get_softmodem_params()->sa) ue_init_config_request(nr_ue_mac_inst, get_softmodem_params()->numerology); - if (rrc_inst && rrc_inst->scell_group_config) { + if (get_softmodem_params()->do_ra || get_softmodem_params()->phy_test) { int rc = rlc_module_init(0); AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 75f58af872..53abface41 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -162,20 +162,6 @@ static void nr_rrc_ue_process_masterCellGroup(instance_t instance, void nr_rrc_ue_process_measConfig(rrcPerNB_t *rrc, NR_MeasConfig_t *const measConfig); -// from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded) -static int8_t nr_rrc_ue_decode_secondary_cellgroup_config(NR_UE_RRC_INST_t *rrc, NR_CellGroupConfig_t *cell_group_config) -{ - if (rrc->scell_group_config == NULL) - rrc->scell_group_config = cell_group_config; - else - SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)cell_group_config, 0); - - if(cell_group_config->spCellConfig != NULL) - configure_spcell(rrc, cell_group_config->spCellConfig); - - return 0; -} - static void nr_rrc_ue_process_rrcReconfiguration(const instance_t instance, int gNB_index, rnti_t rnti, @@ -217,10 +203,10 @@ static void nr_rrc_ue_process_rrcReconfiguration(const instance_t instance, } if (ie->secondaryCellGroup != NULL) { - NR_CellGroupConfig_t *secondCellGroupConfig = NULL; + NR_CellGroupConfig_t *cellGroupConfig = NULL; asn_dec_rval_t dec_rval = uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, // might be added prefix later - (void **)&secondCellGroupConfig, + (void **)&cellGroupConfig, (uint8_t *)ie->secondaryCellGroup->buf, ie->secondaryCellGroup->size, 0, @@ -232,35 +218,18 @@ static void nr_rrc_ue_process_rrcReconfiguration(const instance_t instance, LOG_E(NR_RRC, "%02x ", buffer[i]); LOG_E(NR_RRC, "\n"); // free the memory - SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)secondCellGroupConfig, 1); - return; + SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)cellGroupConfig, 1); } + if (LOG_DEBUGFLAG(DEBUG_ASN1)) - xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *)secondCellGroupConfig); + xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *) cellGroupConfig); - if (get_softmodem_params()->sa || get_softmodem_params()->nsa) { - // remote NB index lost ???? - nr_rrc_manage_rlc_bearers(instance, secondCellGroupConfig, rrc->perNB + 0, rrc->rnti); - if (rrc->cell_group_config == NULL) { - // first time receive the configuration, just use the memory allocated from uper_decoder. TODO this is not good - // implementation, need to maintain RRC_INST own structure every time. - rrc->cell_group_config = secondCellGroupConfig; - } else { - // after first time, update it and free the memory after. - SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)rrc->cell_group_config, 0); - rrc->cell_group_config = secondCellGroupConfig; - } + nr_rrc_cellgroup_configuration(rrcNB, + instance, + cellGroupConfig); - if (secondCellGroupConfig->spCellConfig != NULL) - configure_spcell(rrc, secondCellGroupConfig->spCellConfig); - - if (get_softmodem_params()->nsa) { - nr_rrc_mac_config_req_scg(0, 0, secondCellGroupConfig); - } - } else { - nr_rrc_mac_config_req_scg(0, 0, secondCellGroupConfig); - nr_rrc_ue_decode_secondary_cellgroup_config(rrc, secondCellGroupConfig); - } + if (!get_softmodem_params()->sa) + nr_rrc_mac_config_req_scg(0, 0, cellGroupConfig); } if (ie->measConfig != NULL) { LOG_I(NR_RRC, "Measurement Configuration is present\n"); @@ -281,7 +250,6 @@ static void nr_rrc_ue_process_rrcReconfiguration(const instance_t instance, default: break; } - return; } @@ -352,8 +320,8 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file) // fill UE-NR-Capability @ UE-CapabilityRAT-Container here. rrc->selected_plmn_identity = 1; - rrc->bwpd = NULL; - rrc->ubwpd = NULL; + rrc->dl_bwp_id = 0; + rrc->ul_bwp_id = 0; rrc->as_security_activated = false; for (int i = 0; i < NB_CNX_UE; i++) { @@ -362,7 +330,7 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file) for (int j = 0; j < NR_NUM_SRB; j++) ptr->Srb[j] = (NR_UE_RRC_SRB_INFO_t){0}; for (int j = 0; j < MAX_DRBS_PER_UE; j++) - ptr->active_DRBs[j] = false; + ptr->status_DRBs[j] = RB_NOT_PRESENT; // SRB0 activated by default ptr->Srb[0].status = RB_ESTABLISHED; } @@ -800,13 +768,82 @@ static void nr_rrc_manage_rlc_bearers(const instance_t instance, cellGroupConfig->rlc_BearerToReleaseList); } +void nr_rrc_cellgroup_configuration(rrcPerNB_t *rrcNB, + instance_t instance, + NR_CellGroupConfig_t *cellGroupConfig) +{ + NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[instance]; + if(rrc->cell_group_config == NULL) + rrc->cell_group_config = cellGroupConfig; + else { + ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, rrc->cell_group_config); + rrc->cell_group_config = cellGroupConfig; + } + + NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants; + + NR_SpCellConfig_t *spCellConfig = cellGroupConfig->spCellConfig; + if(spCellConfig != NULL) { + if (spCellConfig->reconfigurationWithSync != NULL) { + NR_ReconfigurationWithSync_t *reconfigurationWithSync = spCellConfig->reconfigurationWithSync; + // perform Reconfiguration with sync according to 5.3.5.5.2 + if (!rrc->as_security_activated && rrc->nrRrcState != RRC_STATE_IDLE_NR) { + // perform the actions upon going to RRC_IDLE as specified in 5.3.11 + // with the release cause 'other' upon which the procedure ends + // TODO + } + if (tac->T310_active) { + tac->T310_active = false; + tac->T310_cnt = 0; + } + nr_rrc_set_T304(&rrc->timers_and_constants, reconfigurationWithSync); + tac->T304_active = true; + tac->T304_cnt = 0; + rrc->rnti = reconfigurationWithSync->newUE_Identity; + // resume suspended radio bearers + for (int i = 0; i < NR_NUM_SRB; i++) { + if (rrcNB->Srb[i].status == RB_SUSPENDED) + rrcNB->Srb[i].status = RB_ESTABLISHED; + } + for (int i = 0; i < MAX_DRBS_PER_UE; i++) { + if (rrcNB->status_DRBs[i] == RB_SUSPENDED) + rrcNB->status_DRBs[i] = RB_ESTABLISHED; + } + // TODO reset MAC + } + nr_rrc_handle_SetupRelease_RLF_TimersAndConstants(rrc, spCellConfig->rlf_TimersAndConstants); + if (spCellConfig->spCellConfigDedicated) { + if (spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id) + rrc->dl_bwp_id = *spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id; + if (spCellConfig->spCellConfigDedicated->uplinkConfig && + spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) + rrc->dl_bwp_id = *spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id; + } + } + + if(cellGroupConfig->mac_CellGroupConfig != NULL) { + // TODO handle MAC CellGroupConfig + } + + // TODO verify why we need this limitation + if (get_softmodem_params()->sa || get_softmodem_params()->nsa) + nr_rrc_manage_rlc_bearers(instance, cellGroupConfig, rrcNB, rrc->rnti); + + AssertFatal(cellGroupConfig->sCellToReleaseList == NULL, + "Secondary serving cell release not implemented\n"); + + AssertFatal(cellGroupConfig->sCellToAddModList == NULL, + "Secondary serving cell addition not implemented\n"); +} + + static void nr_rrc_ue_process_masterCellGroup(instance_t instance, rnti_t rnti, rrcPerNB_t *rrcNB, OCTET_STRING_t *masterCellGroup, long *fullConfig) { - NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[instance]; + AssertFatal(!fullConfig, "fullConfig not supported yet\n"); NR_CellGroupConfig_t *cellGroupConfig = NULL; uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, //might be added prefix later @@ -818,116 +855,12 @@ static void nr_rrc_ue_process_masterCellGroup(instance_t instance, xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *) cellGroupConfig); } - if(rrc->cell_group_config == NULL){ - rrc->cell_group_config = calloc(1,sizeof(NR_CellGroupConfig_t)); - } - nr_rrc_manage_rlc_bearers(instance, cellGroupConfig, rrcNB, rnti); + nr_rrc_cellgroup_configuration(rrcNB, + instance, + cellGroupConfig); - if(cellGroupConfig->mac_CellGroupConfig != NULL){ - //TODO (configure the MAC entity of this cell group as specified in 5.3.5.5.5) - LOG_I(RRC, "Received mac_CellGroupConfig from gNB\n"); - if(rrc->cell_group_config->mac_CellGroupConfig != NULL){ - LOG_E(RRC, "UE RRC instance already contains mac CellGroupConfig which will be overwritten\n"); - // Laurent: there are cases where the not NULL value is also not coming from a previous malloc - // so it is better to let the potential memory leak than corrupting the heap - //free(rrc->cell_group_config->mac_CellGroupConfig); - } - rrc->cell_group_config->mac_CellGroupConfig = malloc(sizeof(struct NR_MAC_CellGroupConfig)); - memcpy(rrc->cell_group_config->mac_CellGroupConfig,cellGroupConfig->mac_CellGroupConfig, - sizeof(struct NR_MAC_CellGroupConfig)); - } - - if(cellGroupConfig->sCellToReleaseList != NULL) { - //TODO (perform SCell release as specified in 5.3.5.5.8) - } - - if(cellGroupConfig->spCellConfig != NULL) { - configure_spcell(rrc, cellGroupConfig->spCellConfig); - // TS 38.331 - Section 5.3.5.5.2 Reconfiguration with sync - if (cellGroupConfig->spCellConfig->reconfigurationWithSync != NULL) { - if(fullConfig) - set_default_timers_and_constants(&rrc->timers_and_constants); - LOG_A(NR_RRC, "Received the reconfigurationWithSync in %s\n", __FUNCTION__); - NR_ReconfigurationWithSync_t *reconfigurationWithSync = cellGroupConfig->spCellConfig->reconfigurationWithSync; - rrc->timers_and_constants.T304_active = true; - nr_rrc_set_T304(&rrc->timers_and_constants, reconfigurationWithSync); - // TODO: Implementation of the remaining procedures regarding the reception of the reconfigurationWithSync, TS 38.331 - Section 5.3.5.5.2 - } - - if (rrc->cell_group_config && - rrc->cell_group_config->spCellConfig) { - memcpy(rrc->cell_group_config->spCellConfig,cellGroupConfig->spCellConfig, - sizeof(struct NR_SpCellConfig)); - } else { - if (rrc->cell_group_config) - rrc->cell_group_config->spCellConfig = cellGroupConfig->spCellConfig; - else - rrc->cell_group_config = cellGroupConfig; - } - LOG_D(RRC,"Sending CellGroupConfig to MAC\n"); - nr_rrc_mac_config_req_mcg(instance, 0, cellGroupConfig); - } - - if(fullConfig) - // full configuration after re-establishment or during RRC resume - nr_rrc_set_sib1_timers_and_constants(&rrc->timers_and_constants, rrcNB->SInfo.sib1); - - if( cellGroupConfig->sCellToAddModList != NULL){ - //TODO (perform SCell addition/modification as specified in 5.3.5.5.9) - } - - if(cellGroupConfig->ext2 != NULL && cellGroupConfig->ext2->bh_RLC_ChannelToReleaseList_r16 != NULL){ - //TODO (perform the BH RLC channel addition/modification as specified in 5.3.5.5.11) - } - - if(cellGroupConfig->ext2 != NULL && cellGroupConfig->ext2->bh_RLC_ChannelToAddModList_r16 != NULL){ - //TODO (perform the BH RLC channel addition/modification as specified in 5.3.5.5.11) - } -} - -static void configure_spcell(NR_UE_RRC_INST_t *rrc, NR_SpCellConfig_t *spcell_config) -{ - nr_rrc_handle_SetupRelease_RLF_TimersAndConstants(rrc, spcell_config->rlf_TimersAndConstants); - - if(spcell_config->spCellConfigDedicated) { - NR_ServingCellConfig_t *scd = spcell_config->spCellConfigDedicated; - if(scd->firstActiveDownlinkBWP_Id) { - if(*scd->firstActiveDownlinkBWP_Id == 0) - rrc->bwpd = scd->initialDownlinkBWP; - else { - AssertFatal(scd->downlinkBWP_ToAddModList, "No DL BWP list configured\n"); - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = scd->downlinkBWP_ToAddModList; - NR_BWP_Downlink_t *dl_bwp = NULL; - for (int i = 0; i < bwpList->list.count; i++) { - dl_bwp = bwpList->list.array[i]; - if(dl_bwp->bwp_Id == *scd->firstActiveDownlinkBWP_Id) - break; - } - AssertFatal(dl_bwp != NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n", *scd->firstActiveDownlinkBWP_Id); - rrc->bwpd = dl_bwp->bwp_Dedicated; - } - // if any of the reference signal(s) that are used for radio link monitoring are reconfigured by the received spCellConfigDedicated - // reset RLF timers and constants - if (rrc->bwpd->radioLinkMonitoringConfig) - reset_rlf_timers_and_constants(&rrc->timers_and_constants); - } - if(scd->uplinkConfig && scd->uplinkConfig->firstActiveUplinkBWP_Id) { - if(*scd->uplinkConfig->firstActiveUplinkBWP_Id == 0) - rrc->ubwpd = scd->uplinkConfig->initialUplinkBWP; - else { - AssertFatal(scd->uplinkConfig->uplinkBWP_ToAddModList, "No UL BWP list configured\n"); - const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = scd->uplinkConfig->uplinkBWP_ToAddModList; - NR_BWP_Uplink_t *ul_bwp = NULL; - for (int i = 0; i < ubwpList->list.count; i++) { - ul_bwp = ubwpList->list.array[i]; - if(ul_bwp->bwp_Id == *scd->uplinkConfig->firstActiveUplinkBWP_Id) - break; - } - AssertFatal(ul_bwp != NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n", *scd->uplinkConfig->firstActiveUplinkBWP_Id); - rrc->ubwpd = ul_bwp->bwp_Dedicated; - } - } - } + LOG_D(RRC,"Sending CellGroupConfig to MAC\n"); + nr_rrc_mac_config_req_mcg(instance, 0, cellGroupConfig); } static void rrc_ue_generate_RRCSetupComplete(instance_t instance, rnti_t rnti, const uint8_t Transaction_id, uint8_t sel_plmn_id) @@ -998,7 +931,7 @@ static int8_t nr_rrc_ue_decode_ccch(const instance_t instance, // Get configuration // Release T300 timer rrc->timers_and_constants.T300_active = 0; - + rrc->rnti = rnti; nr_rrc_ue_process_masterCellGroup( instance, rnti, @@ -1011,7 +944,7 @@ static int8_t nr_rrc_ue_decode_ccch(const instance_t instance, rrc->perNB + gNB_index, &dl_ccch_msg->message.choice.c1->choice.rrcSetup->criticalExtensions.choice.rrcSetup->radioBearerConfig); rrc->nrRrcState = RRC_STATE_CONNECTED_NR; - rrc->rnti = rnti; + rrc_ue_generate_RRCSetupComplete(instance, rnti, dl_ccch_msg->message.choice.c1->choice.rrcSetup->rrc_TransactionIdentifier, @@ -1330,7 +1263,7 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, for (int cnt = 0; cnt < radioBearerConfig->drb_ToAddModList->list.count; cnt++) { struct NR_DRB_ToAddMod *drb = radioBearerConfig->drb_ToAddModList->list.array[cnt]; int DRB_id = drb->drb_Identity; - if (rrcNB->active_DRBs[DRB_id]) { + if (rrcNB->status_DRBs[DRB_id] == RB_ESTABLISHED) { AssertFatal(drb->reestablishPDCP == NULL, "reestablishPDCP not yet implemented\n"); AssertFatal(drb->recoverPDCP == NULL, "recoverPDCP not yet implemented\n"); if (drb->pdcp_Config && drb->pdcp_Config->t_Reordering) @@ -1338,7 +1271,7 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, if (drb->cnAssociation) AssertFatal(drb->cnAssociation->choice.sdap_Config == NULL, "SDAP reconfiguration not yet implemented\n"); } else { - rrcNB->active_DRBs[DRB_id] = true; + rrcNB->status_DRBs[DRB_id] = RB_ESTABLISHED; add_drb(false, rnti, radioBearerConfig->drb_ToAddModList->list.array[cnt], diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index 5e04b6ce4a..c702105a4c 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -191,7 +191,7 @@ typedef struct rrcPerNB { NR_MeasIdToAddMod_t *MeasId[MAX_MEAS_ID]; NR_MeasGapConfig_t *measGapConfig; NR_UE_RRC_SRB_INFO_t Srb[NR_NUM_SRB]; - bool active_DRBs[MAX_DRBS_PER_UE]; + NR_RB_status_t status_DRBs[MAX_DRBS_PER_UE]; bool active_RLC_entity[NR_MAX_NUM_LCID]; NR_UE_RRC_SI_INFO SInfo; NR_RSRP_Range_t s_measure; @@ -201,7 +201,6 @@ typedef struct NR_UE_RRC_INST_s { NR_MeasConfig_t *meas_config; NR_CellGroupConfig_t *cell_group_config; NR_ServingCellConfigCommonSIB_t *servingCellConfigCommonSIB; - NR_CellGroupConfig_t *scell_group_config; NR_RadioBearerConfig_t *radio_bearer_config; rrcPerNB_t perNB[NB_CNX_UE]; @@ -215,9 +214,8 @@ typedef struct NR_UE_RRC_INST_s { // NR_MIB_t *mib; - // active BWPs - NR_BWP_DownlinkDedicated_t *bwpd; - NR_BWP_UplinkDedicated_t *ubwpd; + NR_BWP_Id_t dl_bwp_id; + NR_BWP_Id_t ul_bwp_id; /* KeNB as computed from parameters within USIM card */ uint8_t kgnb[32]; diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 565b9e813e..2d9d19423c 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -68,6 +68,10 @@ void init_nsa_message (NR_UE_RRC_INST_t *rrc, char* reconfig_file, char* rbconfi void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message, int msg_len); +void nr_rrc_cellgroup_configuration(rrcPerNB_t *rrcNB, + instance_t instance, + NR_CellGroupConfig_t *cellGroupConfig); + /**\brief interface between MAC and RRC thru SRB0 (RLC TM/no PDCP) \param module_id module id \param CC_id component carrier id From 848f5767d79908801871ac1dda9c74c08e06aee8 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 23 Oct 2023 17:30:14 +0200 Subject: [PATCH 5/8] unified handling of cellgroup config at MAC --- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulsim.c | 1 - openair2/LAYER2/NR_MAC_UE/config_ue.c | 43 ++++++++------------------- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 10 ++----- openair2/RRC/NR_UE/rrc_UE.c | 12 ++------ openair2/RRC/NR_UE/rrc_defs.h | 2 -- 6 files changed, 18 insertions(+), 52 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index fd68a3b9c3..fcc7bcc067 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -852,7 +852,7 @@ int main(int argc, char **argv) //Configure UE NR_BCCH_BCH_Message_t *mib = get_new_MIB_NR(scc); nr_rrc_mac_config_req_mib(0, 0, mib->message.choice.mib, false); - nr_rrc_mac_config_req_scg(0, 0, secondaryCellGroup); + nr_rrc_mac_config_req_cg(0, 0, secondaryCellGroup); UE_mac->state = UE_CONNECTED; UE_mac->ra.ra_state = RA_SUCCEEDED; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 54d69c9611..ba7e09d9f9 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -691,7 +691,6 @@ int main(int argc, char *argv[]) //Configure UE NR_UE_RRC_INST_t rrcue = {0}; - rrcue.scell_group_config = secondaryCellGroup; nr_l2_init_ue(&rrcue); NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index c93b607f9e..dd9fc930a7 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -564,8 +564,11 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } if (mac->bwp_ulcommon->pucch_ConfigCommon) UL_BWP->pucch_ConfigCommon = mac->bwp_ulcommon->pucch_ConfigCommon->choice.setup; - if (mac->bwp_ulcommon->rach_ConfigCommon) + if (mac->bwp_ulcommon->rach_ConfigCommon) { UL_BWP->rach_ConfigCommon = mac->bwp_ulcommon->rach_ConfigCommon->choice.setup; + // Setup the SSB to Rach Occasions mapping according to the config + build_ssb_to_ro_map(mac); + } if (mac->bwp_dlcommon->pdcch_ConfigCommon) configure_ss_coreset(mac, mac->bwp_dlcommon->pdcch_ConfigCommon->choice.setup, NULL); } @@ -641,8 +644,11 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, UL_BWP->configuredGrantConfig = bwp_uplink->bwp_Dedicated->configuredGrantConfig ? bwp_uplink->bwp_Dedicated->configuredGrantConfig->choice.setup : NULL; if (bwp_uplink->bwp_Common->pucch_ConfigCommon) UL_BWP->pucch_ConfigCommon = bwp_uplink->bwp_Common->pucch_ConfigCommon->choice.setup; - if (bwp_uplink->bwp_Common->rach_ConfigCommon) + if (bwp_uplink->bwp_Common->rach_ConfigCommon) { UL_BWP->rach_ConfigCommon = bwp_uplink->bwp_Common->rach_ConfigCommon->choice.setup; + // Setup the SSB to Rach Occasions mapping according to the config + build_ssb_to_ro_map(mac); + } } else { UL_BWP->tdaList_Common = mac->bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; @@ -726,8 +732,6 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, if(mac->state < UE_CONNECTED) configure_current_BWP(mac, scc, NULL); - // Setup the SSB to Rach Occasionsif (cell_group_config->spCellConfig) { mapping according to the config - build_ssb_to_ro_map(mac); if (!get_softmodem_params()->emulate_l1) mac->if_module->phy_config_request(&mac->phy_config); mac->phy_config_request_sent = true; @@ -768,49 +772,26 @@ void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, } } -void nr_rrc_mac_config_req_mcg(module_id_t module_id, - int cc_idP, - NR_CellGroupConfig_t *cell_group_config) +void nr_rrc_mac_config_req_cg(module_id_t module_id, + int cc_idP, + NR_CellGroupConfig_t *cell_group_config) { LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); AssertFatal(cell_group_config, "CellGroupConfig should not be NULL\n"); NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); mac->cg = cell_group_config; + if (cell_group_config->spCellConfig) mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; else mac->servCellIndex = 0; mac->crossCarrierSchedulingConfig = cell_group_config->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig; - mac->scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; - mac->scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; - mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE; - LOG_D(MAC, "[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", - module_id, - mac->scheduling_info.periodicBSR_SF, - mac->scheduling_info.retxBSR_SF); if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) { LOG_A(NR_MAC, "Received the reconfigurationWithSync in %s\n", __FUNCTION__); handle_reconfiguration_with_sync(mac, module_id, cc_idP, cell_group_config->spCellConfig->reconfigurationWithSync); } configure_current_BWP(mac, NULL, cell_group_config); -} - -void nr_rrc_mac_config_req_scg(module_id_t module_id, - int cc_idP, - NR_CellGroupConfig_t *scell_group_config) -{ - NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - AssertFatal(scell_group_config, "scell_group_config cannot be NULL\n"); - - mac->cg = scell_group_config; - mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex; - mac->crossCarrierSchedulingConfig = scell_group_config->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig; - if (scell_group_config->spCellConfig->reconfigurationWithSync) - handle_reconfiguration_with_sync(mac, module_id, cc_idP, scell_group_config->spCellConfig->reconfigurationWithSync); - configure_current_BWP(mac, NULL, scell_group_config); if (!mac->dl_config_request || !mac->ul_config_request) ue_init_config_request(mac, mac->current_DL_BWP.scs); - // Setup the SSB to Rach Occasions mapping according to the config - build_ssb_to_ro_map(mac); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 60c64ead12..03e2177edd 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -67,13 +67,9 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_toadd_list, struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_torelease_list); -void nr_rrc_mac_config_req_scg(module_id_t module_id, - int cc_idP, - NR_CellGroupConfig_t *scell_group_config); - -void nr_rrc_mac_config_req_mcg(module_id_t module_id, - int cc_idP, - NR_CellGroupConfig_t *scell_group_config); +void nr_rrc_mac_config_req_cg(module_id_t module_id, + int cc_idP, + NR_CellGroupConfig_t *cell_group_config); void nr_rrc_mac_config_req_mib(module_id_t module_id, int cc_idP, diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 53abface41..ccd92df77a 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -229,7 +229,7 @@ static void nr_rrc_ue_process_rrcReconfiguration(const instance_t instance, cellGroupConfig); if (!get_softmodem_params()->sa) - nr_rrc_mac_config_req_scg(0, 0, cellGroupConfig); + nr_rrc_mac_config_req_cg(0, 0, cellGroupConfig); } if (ie->measConfig != NULL) { LOG_I(NR_RRC, "Measurement Configuration is present\n"); @@ -709,7 +709,6 @@ static int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(instance_t instance, // configure timers and constant nr_rrc_set_sib1_timers_and_constants(&rrc->timers_and_constants, sib1); // take ServingCellConfigCommon and configure L1/L2 - rrc->servingCellConfigCommonSIB = sib1->servingCellConfigCommon; nr_rrc_mac_config_req_sib1(instance, 0, sib1->si_SchedulingInfo, sib1->servingCellConfigCommon); break; case NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformation: @@ -773,13 +772,6 @@ void nr_rrc_cellgroup_configuration(rrcPerNB_t *rrcNB, NR_CellGroupConfig_t *cellGroupConfig) { NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[instance]; - if(rrc->cell_group_config == NULL) - rrc->cell_group_config = cellGroupConfig; - else { - ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, rrc->cell_group_config); - rrc->cell_group_config = cellGroupConfig; - } - NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants; NR_SpCellConfig_t *spCellConfig = cellGroupConfig->spCellConfig; @@ -860,7 +852,7 @@ static void nr_rrc_ue_process_masterCellGroup(instance_t instance, cellGroupConfig); LOG_D(RRC,"Sending CellGroupConfig to MAC\n"); - nr_rrc_mac_config_req_mcg(instance, 0, cellGroupConfig); + nr_rrc_mac_config_req_cg(instance, 0, cellGroupConfig); } static void rrc_ue_generate_RRCSetupComplete(instance_t instance, rnti_t rnti, const uint8_t Transaction_id, uint8_t sel_plmn_id) diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index c702105a4c..7160ff19c7 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -199,8 +199,6 @@ typedef struct rrcPerNB { typedef struct NR_UE_RRC_INST_s { NR_MeasConfig_t *meas_config; - NR_CellGroupConfig_t *cell_group_config; - NR_ServingCellConfigCommonSIB_t *servingCellConfigCommonSIB; NR_RadioBearerConfig_t *radio_bearer_config; rrcPerNB_t perNB[NB_CNX_UE]; From 2715c7efdd4563fe6c20bd1dd01650e6106665ba Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 24 Oct 2023 12:29:57 +0200 Subject: [PATCH 6/8] improve MAC configuration from RRC --- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 2 - openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 9 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 5 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 272 ++++++++++-------- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 8 +- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 5 +- .../NR_MAC_UE/nr_ue_dci_configuration.c | 3 + .../LAYER2/NR_MAC_UE/nr_ue_power_procedures.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 11 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 3 + .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 1 + .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 1 + .../NR_MAC_gNB/gNB_scheduler_primitives.c | 10 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 1 + openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 1 + openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 + 16 files changed, 198 insertions(+), 137 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index d33390d75a..e5c7e7e04b 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -570,7 +570,6 @@ typedef struct NR_UE_DL_BWP { NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList_Common; NR_PDSCH_Config_t *pdsch_Config; NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig; - long *pdsch_HARQ_ACK_Codebook; uint8_t mcsTableIdx; nr_dci_format_t dci_format; int bw_tbslbrm; @@ -593,7 +592,6 @@ typedef struct NR_UE_UL_BWP { NR_PUCCH_Config_t *pucch_Config; NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; NR_UplinkConfig_t *supplementaryUplink; - long *harq_ACK_SpatialBundlingPUCCH; NR_CSI_MeasConfig_t *csi_MeasConfig; NR_SRS_Config_t *srs_Config; long *msg3_DeltaPreamble; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 5498a2c9ae..867ec10b05 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3279,6 +3279,7 @@ uint16_t get_rb_bwp_dci(nr_dci_format_t format, uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig, + long pdsch_HARQ_ACK_Codebook, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, @@ -3376,7 +3377,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, size += 1; } // 1st DAI - if (DL_BWP->pdsch_HARQ_ACK_Codebook && *DL_BWP->pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) + if (pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) dci_pdu->dai[0].nbits = 2; else dci_pdu->dai[0].nbits = 1; @@ -3548,7 +3549,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, // HARQ PID size += 4; // DAI - if (DL_BWP->pdsch_HARQ_ACK_Codebook && *DL_BWP->pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) { // FIXME in case of more than one serving cell + if (pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) { // FIXME in case of more than one serving cell dci_pdu->dai[0].nbits = 2; size += dci_pdu->dai[0].nbits; } @@ -4734,7 +4735,7 @@ uint16_t compute_pucch_prb_size(uint8_t format, } int get_dlbw_tbslbrm(int scc_bwpsize, - NR_ServingCellConfig_t *servingCellConfig) + const NR_ServingCellConfig_t *servingCellConfig) { int bw = scc_bwpsize; if (servingCellConfig) { @@ -4752,7 +4753,7 @@ int get_dlbw_tbslbrm(int scc_bwpsize, } int get_ulbw_tbslbrm(int scc_bwpsize, - NR_ServingCellConfig_t *servingCellConfig) + const NR_ServingCellConfig_t *servingCellConfig) { int bw = scc_bwpsize; if (servingCellConfig) { diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 059dc31acd..c460119612 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -96,6 +96,7 @@ NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig, + long pdsch_HARQ_ACK_Codebook, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, @@ -196,10 +197,10 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset); int get_dlbw_tbslbrm(int scc_bwpsize, - NR_ServingCellConfig_t *servingCellConfig); + const NR_ServingCellConfig_t *servingCellConfig); int get_ulbw_tbslbrm(int scc_bwpsize, - NR_ServingCellConfig_t *servingCellConfig); + const NR_ServingCellConfig_t *servingCellConfig); uint32_t nr_compute_tbslbrm(uint16_t table, uint16_t nb_rb, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index dd9fc930a7..6cb0ef23ef 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -533,29 +533,52 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, } } +void configure_scc(NR_UE_MAC_INST_t *mac, + NR_ServingCellConfigCommonSIB_t *scc_sib, + NR_ServingCellConfigCommon_t *scc) +{ + // SCC is provided when receiving reconfigurationWithSync + // SCC_SIB is provided when receiving SIB1 + // So never at the same time + if (scc) { + if (scc->physCellId) + mac->physCellId = *scc->physCellId; + mac->bwp_dlcommon = scc->downlinkConfigCommon->initialDownlinkBWP; + mac->bwp_ulcommon = scc->uplinkConfigCommon->initialUplinkBWP; + mac->dmrs_TypeA_Position = scc->dmrs_TypeA_Position; + mac->tdd_UL_DL_ConfigurationCommon = scc->tdd_UL_DL_ConfigurationCommon; + mac->p_Max = scc->uplinkConfigCommon->frequencyInfoUL->p_Max ? + *scc->uplinkConfigCommon->frequencyInfoUL->p_Max : + INT_MIN; + mac->nr_band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + } + if (scc_sib) { + mac->bwp_dlcommon = &scc_sib->downlinkConfigCommon.initialDownlinkBWP; + mac->bwp_ulcommon = &scc_sib->uplinkConfigCommon->initialUplinkBWP; + mac->tdd_UL_DL_ConfigurationCommon = scc_sib->tdd_UL_DL_ConfigurationCommon; + mac->p_Max = scc_sib->uplinkConfigCommon->frequencyInfoUL.p_Max ? + *scc_sib->uplinkConfigCommon->frequencyInfoUL.p_Max : + INT_MIN; + mac->nr_band = *scc_sib->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list.array[0]->freqBandIndicatorNR; + } +} + void configure_current_BWP(NR_UE_MAC_INST_t *mac, NR_ServingCellConfigCommonSIB_t *scc, - NR_CellGroupConfig_t *cell_group_config) + const NR_ServingCellConfig_t *spCellConfigDedicated) { NR_UE_DL_BWP_t *DL_BWP = &mac->current_DL_BWP; NR_UE_UL_BWP_t *UL_BWP = &mac->current_UL_BWP; NR_BWP_t dl_genericParameters = {0}; NR_BWP_t ul_genericParameters = {0}; - DL_BWP->n_dl_bwp = 0; - UL_BWP->n_ul_bwp = 0; if(scc) { - DL_BWP->bwp_id = 0; - UL_BWP->bwp_id = 0; - mac->bwp_dlcommon = &scc->downlinkConfigCommon.initialDownlinkBWP; - mac->bwp_ulcommon = &scc->uplinkConfigCommon->initialUplinkBWP; dl_genericParameters = mac->bwp_dlcommon->genericParameters; - if(scc->uplinkConfigCommon) - ul_genericParameters = scc->uplinkConfigCommon->initialUplinkBWP.genericParameters; + if(mac->bwp_ulcommon) + ul_genericParameters = mac->bwp_ulcommon->genericParameters; else ul_genericParameters = mac->bwp_dlcommon->genericParameters; - DL_BWP->pdsch_Config = NULL; if (mac->bwp_dlcommon->pdsch_ConfigCommon) DL_BWP->tdaList_Common = mac->bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; if (mac->bwp_ulcommon->pusch_ConfigCommon) { @@ -573,99 +596,86 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, configure_ss_coreset(mac, mac->bwp_dlcommon->pdcch_ConfigCommon->choice.setup, NULL); } - NR_ServingCellConfig_t *spCellConfigDedicated = NULL; + if(spCellConfigDedicated) { + UL_BWP->supplementaryUplink = spCellConfigDedicated->supplementaryUplink; + UL_BWP->csi_MeasConfig = spCellConfigDedicated->csi_MeasConfig ? spCellConfigDedicated->csi_MeasConfig->choice.setup : NULL; + UL_BWP->pusch_servingcellconfig = + spCellConfigDedicated->uplinkConfig && spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig ? spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; + DL_BWP->pdsch_servingcellconfig = spCellConfigDedicated->pdsch_ServingCellConfig ? spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup : NULL; + + if (spCellConfigDedicated->firstActiveDownlinkBWP_Id) + DL_BWP->bwp_id = *spCellConfigDedicated->firstActiveDownlinkBWP_Id; + if (spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) + UL_BWP->bwp_id = *spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id; + + NR_BWP_Downlink_t *bwp_downlink = NULL; + const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = spCellConfigDedicated->downlinkBWP_ToAddModList; + if (bwpList) + DL_BWP->n_dl_bwp = bwpList->list.count; + if (bwpList && DL_BWP->bwp_id > 0) { + for (int i = 0; i < bwpList->list.count; i++) { + bwp_downlink = bwpList->list.array[i]; + if(bwp_downlink->bwp_Id == DL_BWP->bwp_id) + break; + } + AssertFatal(bwp_downlink != NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n", DL_BWP->bwp_id); + dl_genericParameters = bwp_downlink->bwp_Common->genericParameters; + DL_BWP->pdsch_Config = bwp_downlink->bwp_Dedicated->pdsch_Config->choice.setup; + DL_BWP->tdaList_Common = bwp_downlink->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + configure_ss_coreset(mac, + bwp_downlink->bwp_Common->pdcch_ConfigCommon ? bwp_downlink->bwp_Common->pdcch_ConfigCommon->choice.setup : NULL, + bwp_downlink->bwp_Dedicated->pdcch_Config ? bwp_downlink->bwp_Dedicated->pdcch_Config->choice.setup : NULL); - if(cell_group_config) { - if (cell_group_config->physicalCellGroupConfig) { - DL_BWP->pdsch_HARQ_ACK_Codebook = &cell_group_config->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook; - UL_BWP->harq_ACK_SpatialBundlingPUCCH = cell_group_config->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH; } - if (cell_group_config->spCellConfig && - cell_group_config->spCellConfig->spCellConfigDedicated) { - spCellConfigDedicated = cell_group_config->spCellConfig->spCellConfigDedicated; - UL_BWP->supplementaryUplink = spCellConfigDedicated->supplementaryUplink; - UL_BWP->csi_MeasConfig = spCellConfigDedicated->csi_MeasConfig ? spCellConfigDedicated->csi_MeasConfig->choice.setup : NULL; - UL_BWP->pusch_servingcellconfig = - spCellConfigDedicated->uplinkConfig && spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig ? spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; - DL_BWP->pdsch_servingcellconfig = spCellConfigDedicated->pdsch_ServingCellConfig ? spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup : NULL; + else { + dl_genericParameters = mac->bwp_dlcommon->genericParameters; + DL_BWP->pdsch_Config = spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup; + DL_BWP->tdaList_Common = mac->bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + configure_ss_coreset(mac, + mac->bwp_dlcommon->pdcch_ConfigCommon ? mac->bwp_dlcommon->pdcch_ConfigCommon->choice.setup : NULL, + spCellConfigDedicated->initialDownlinkBWP->pdcch_Config ? spCellConfigDedicated->initialDownlinkBWP->pdcch_Config->choice.setup : NULL); + } - if (spCellConfigDedicated->firstActiveDownlinkBWP_Id) - DL_BWP->bwp_id = *spCellConfigDedicated->firstActiveDownlinkBWP_Id; - if (spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) - UL_BWP->bwp_id = *spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id; - - NR_BWP_Downlink_t *bwp_downlink = NULL; - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = spCellConfigDedicated->downlinkBWP_ToAddModList; - if (bwpList) - DL_BWP->n_dl_bwp = bwpList->list.count; - if (bwpList && DL_BWP->bwp_id > 0) { - for (int i = 0; i < bwpList->list.count; i++) { - bwp_downlink = bwpList->list.array[i]; - if(bwp_downlink->bwp_Id == DL_BWP->bwp_id) - break; - } - AssertFatal(bwp_downlink != NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n", DL_BWP->bwp_id); - dl_genericParameters = bwp_downlink->bwp_Common->genericParameters; - DL_BWP->pdsch_Config = bwp_downlink->bwp_Dedicated->pdsch_Config->choice.setup; - DL_BWP->tdaList_Common = bwp_downlink->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - configure_ss_coreset(mac, - bwp_downlink->bwp_Common->pdcch_ConfigCommon ? bwp_downlink->bwp_Common->pdcch_ConfigCommon->choice.setup : NULL, - bwp_downlink->bwp_Dedicated->pdcch_Config ? bwp_downlink->bwp_Dedicated->pdcch_Config->choice.setup : NULL); + UL_BWP->msg3_DeltaPreamble = mac->bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; + NR_BWP_Uplink_t *bwp_uplink = NULL; + const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList; + if (ubwpList) + UL_BWP->n_ul_bwp = ubwpList->list.count; + if (ubwpList && UL_BWP->bwp_id > 0) { + for (int i = 0; i < ubwpList->list.count; i++) { + bwp_uplink = ubwpList->list.array[i]; + if(bwp_uplink->bwp_Id == UL_BWP->bwp_id) + break; } - else { - dl_genericParameters = mac->bwp_dlcommon->genericParameters; - DL_BWP->pdsch_Config = spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup; - DL_BWP->tdaList_Common = mac->bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - configure_ss_coreset(mac, - mac->bwp_dlcommon->pdcch_ConfigCommon ? mac->bwp_dlcommon->pdcch_ConfigCommon->choice.setup : NULL, - spCellConfigDedicated->initialDownlinkBWP->pdcch_Config ? spCellConfigDedicated->initialDownlinkBWP->pdcch_Config->choice.setup : NULL); - - } - - UL_BWP->msg3_DeltaPreamble = mac->bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; - - NR_BWP_Uplink_t *bwp_uplink = NULL; - const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList; - if (ubwpList) - UL_BWP->n_ul_bwp = ubwpList->list.count; - if (ubwpList && UL_BWP->bwp_id > 0) { - for (int i = 0; i < ubwpList->list.count; i++) { - bwp_uplink = ubwpList->list.array[i]; - if(bwp_uplink->bwp_Id == UL_BWP->bwp_id) - break; - } - AssertFatal(bwp_uplink != NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); - ul_genericParameters = bwp_uplink->bwp_Common->genericParameters; - UL_BWP->tdaList_Common = bwp_uplink->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - UL_BWP->pusch_Config = bwp_uplink->bwp_Dedicated->pusch_Config->choice.setup; - UL_BWP->pucch_Config = bwp_uplink->bwp_Dedicated->pucch_Config->choice.setup; - UL_BWP->srs_Config = bwp_uplink->bwp_Dedicated->srs_Config->choice.setup; - UL_BWP->configuredGrantConfig = bwp_uplink->bwp_Dedicated->configuredGrantConfig ? bwp_uplink->bwp_Dedicated->configuredGrantConfig->choice.setup : NULL; - if (bwp_uplink->bwp_Common->pucch_ConfigCommon) - UL_BWP->pucch_ConfigCommon = bwp_uplink->bwp_Common->pucch_ConfigCommon->choice.setup; - if (bwp_uplink->bwp_Common->rach_ConfigCommon) { - UL_BWP->rach_ConfigCommon = bwp_uplink->bwp_Common->rach_ConfigCommon->choice.setup; - // Setup the SSB to Rach Occasions mapping according to the config - build_ssb_to_ro_map(mac); - } - } - else { - UL_BWP->tdaList_Common = mac->bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - UL_BWP->pusch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup; - UL_BWP->pucch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - UL_BWP->srs_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; - UL_BWP->configuredGrantConfig = - spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig ? spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig->choice.setup : NULL; - ul_genericParameters = mac->bwp_ulcommon->genericParameters; - if (mac->bwp_ulcommon->pucch_ConfigCommon) - UL_BWP->pucch_ConfigCommon = mac->bwp_ulcommon->pucch_ConfigCommon->choice.setup; - if (mac->bwp_ulcommon->rach_ConfigCommon) - UL_BWP->rach_ConfigCommon = mac->bwp_ulcommon->rach_ConfigCommon->choice.setup; + AssertFatal(bwp_uplink != NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); + ul_genericParameters = bwp_uplink->bwp_Common->genericParameters; + UL_BWP->tdaList_Common = bwp_uplink->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->pusch_Config = bwp_uplink->bwp_Dedicated->pusch_Config->choice.setup; + UL_BWP->pucch_Config = bwp_uplink->bwp_Dedicated->pucch_Config->choice.setup; + UL_BWP->srs_Config = bwp_uplink->bwp_Dedicated->srs_Config->choice.setup; + UL_BWP->configuredGrantConfig = bwp_uplink->bwp_Dedicated->configuredGrantConfig ? bwp_uplink->bwp_Dedicated->configuredGrantConfig->choice.setup : NULL; + if (bwp_uplink->bwp_Common->pucch_ConfigCommon) + UL_BWP->pucch_ConfigCommon = bwp_uplink->bwp_Common->pucch_ConfigCommon->choice.setup; + if (bwp_uplink->bwp_Common->rach_ConfigCommon) { + UL_BWP->rach_ConfigCommon = bwp_uplink->bwp_Common->rach_ConfigCommon->choice.setup; + // Setup the SSB to Rach Occasions mapping according to the config + build_ssb_to_ro_map(mac); } } - else - AssertFatal(1==0,"We shouldn't end here in configuring BWP\n"); + else { + UL_BWP->tdaList_Common = mac->bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->pusch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup; + UL_BWP->pucch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + UL_BWP->srs_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; + UL_BWP->configuredGrantConfig = + spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig ? spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig->choice.setup : NULL; + ul_genericParameters = mac->bwp_ulcommon->genericParameters; + if (mac->bwp_ulcommon->pucch_ConfigCommon) + UL_BWP->pucch_ConfigCommon = mac->bwp_ulcommon->pucch_ConfigCommon->choice.setup; + if (mac->bwp_ulcommon->rach_ConfigCommon) + UL_BWP->rach_ConfigCommon = mac->bwp_ulcommon->rach_ConfigCommon->choice.setup; + } } DL_BWP->scs = dl_genericParameters.subcarrierSpacing; @@ -717,15 +727,15 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, - struct NR_SI_SchedulingInfo *si_SchedulingInfo, + NR_SI_SchedulingInfo_t *si_SchedulingInfo, NR_ServingCellConfigCommonSIB_t *scc) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); AssertFatal(scc, "SIB1 SCC should not be NULL\n"); - mac->tdd_UL_DL_ConfigurationCommon = scc->tdd_UL_DL_ConfigurationCommon; - mac->p_Max = scc->uplinkConfigCommon->frequencyInfoUL.p_Max; + + configure_scc(mac, scc, NULL); + mac->si_SchedulingInfo = si_SchedulingInfo; - mac->nr_band = *scc->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list.array[0]->freqBandIndicatorNR; config_common_ue_sa(mac, scc, module_id, cc_idP); // configure BWP only if it is a SIB1 detection in non connected state (after sync) // not if it is a periodical update of SIB1 (no change of BWP in that case) @@ -740,23 +750,17 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, module_id_t module_id, int cc_idP, - struct NR_ReconfigurationWithSync *reconfigurationWithSync) + const NR_ReconfigurationWithSync_t *reconfigurationWithSync) { RA_config_t *ra = &mac->ra; if (reconfigurationWithSync->rach_ConfigDedicated) { ra->rach_ConfigDedicated = reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; } - NR_ServingCellConfigCommon_t *scc = reconfigurationWithSync->spCellConfigCommon; - mac->bwp_dlcommon = scc->downlinkConfigCommon->initialDownlinkBWP; - mac->bwp_ulcommon = scc->uplinkConfigCommon->initialUplinkBWP; - mac->dmrs_TypeA_Position = scc->dmrs_TypeA_Position; - mac->tdd_UL_DL_ConfigurationCommon = scc->tdd_UL_DL_ConfigurationCommon; - mac->p_Max = scc->uplinkConfigCommon->frequencyInfoUL->p_Max; - mac->nr_band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; - mac->physCellId = *scc->physCellId; + + configure_scc(mac, NULL, reconfigurationWithSync->spCellConfigCommon); mac->crnti = reconfigurationWithSync->newUE_Identity; LOG_I(NR_MAC, "Configuring CRNTI %x\n", mac->crnti); - config_common_ue(mac, scc, module_id, cc_idP); + config_common_ue(mac, reconfigurationWithSync->spCellConfigCommon, module_id, cc_idP); mac->state = UE_NOT_SYNC; ra->ra_state = RA_UE_IDLE; @@ -772,6 +776,25 @@ void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, } } +void configure_physicalcellgroup(NR_UE_MAC_INST_t *mac, + const NR_PhysicalCellGroupConfig_t *phyConfig) +{ + mac->pdsch_HARQ_ACK_Codebook = phyConfig->pdsch_HARQ_ACK_Codebook; + mac->harq_ACK_SpatialBundlingPUCCH = phyConfig->harq_ACK_SpatialBundlingPUCCH ? true : false; + mac->harq_ACK_SpatialBundlingPUSCH = phyConfig->harq_ACK_SpatialBundlingPUSCH ? true : false; + + NR_P_Max_t *p_NR_FR1 = phyConfig->p_NR_FR1; + NR_P_Max_t *p_UE_FR1 = phyConfig->ext1 ? + phyConfig->ext1->p_UE_FR1 : + NULL; + if (p_NR_FR1 == NULL) + mac->p_Max_alt = p_UE_FR1 == NULL ? INT_MIN : *p_UE_FR1; + else + mac->p_Max_alt = p_UE_FR1 == NULL ? *p_NR_FR1 : + (*p_UE_FR1 < *p_NR_FR1 ? + *p_UE_FR1 : *p_NR_FR1); +} + void nr_rrc_mac_config_req_cg(module_id_t module_id, int cc_idP, NR_CellGroupConfig_t *cell_group_config) @@ -781,17 +804,26 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); mac->cg = cell_group_config; - if (cell_group_config->spCellConfig) - mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; - else - mac->servCellIndex = 0; - mac->crossCarrierSchedulingConfig = cell_group_config->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig; - - if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) { - LOG_A(NR_MAC, "Received the reconfigurationWithSync in %s\n", __FUNCTION__); - handle_reconfiguration_with_sync(mac, module_id, cc_idP, cell_group_config->spCellConfig->reconfigurationWithSync); + if (cell_group_config->mac_CellGroupConfig) { + // TODO handle MAC-CellGroupConfig } - configure_current_BWP(mac, NULL, cell_group_config); + + if (cell_group_config->physicalCellGroupConfig) + configure_physicalcellgroup(mac, cell_group_config->physicalCellGroupConfig); + + if (cell_group_config->spCellConfig) { + NR_SpCellConfig_t *spCellConfig = cell_group_config->spCellConfig; + mac->servCellIndex = spCellConfig->servCellIndex ? *spCellConfig->servCellIndex : 0; + if (spCellConfig->reconfigurationWithSync) { + LOG_A(NR_MAC, "Received reconfigurationWithSync\n"); + handle_reconfiguration_with_sync(mac, module_id, cc_idP, spCellConfig->reconfigurationWithSync); + } + if (spCellConfig->spCellConfigDedicated) { + mac->crossCarrierSchedulingConfig = spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig; + configure_current_BWP(mac, NULL, spCellConfig->spCellConfigDedicated); + } + } + if (!mac->dl_config_request || !mac->ul_config_request) ue_init_config_request(mac, mac->current_DL_BWP.scs); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index cb91486b97..6182a0bf72 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -447,6 +447,9 @@ typedef struct { NR_BWP_DownlinkCommon_t *bwp_dlcommon; NR_BWP_UplinkCommon_t *bwp_ulcommon; + bool harq_ACK_SpatialBundlingPUCCH; + bool harq_ACK_SpatialBundlingPUSCH; + NR_UL_TIME_ALIGNMENT_t ul_time_alignment; NR_SearchSpace_t *otherSI_SS; @@ -513,7 +516,10 @@ typedef struct { uint8_t PHR_reporting_active; int dmrs_TypeA_Position; - NR_P_Max_t *p_Max; + int p_Max; + int p_Max_alt; + + long pdsch_HARQ_ACK_Codebook; NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config; frequency_range_t frequency_range; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 03e2177edd..8b5c4b47d5 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -78,7 +78,7 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, - struct NR_SI_SchedulingInfo *si_SchedulingInfo, + NR_SI_SchedulingInfo_t *si_SchedulingInfo, NR_ServingCellConfigCommonSIB_t *scc); /**\brief initialization NR UE MAC instance(s), total number of MAC instance based on NB_NR_UE_MAC_INST*/ @@ -86,8 +86,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst); /**\brief fetch MAC instance by module_id, within 0 - (NB_NR_UE_MAC_INST-1) \param module_id index of MAC instance(s)*/ -NR_UE_MAC_INST_t *get_mac_inst( - module_id_t module_id); +NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id); /**\brief called at each slot, slot length based on numerology. now use u=0, scs=15kHz, slot=1ms performs BSR/SR/PHR procedures, random access procedure handler and DLSCH/ULSCH procedures. 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 4c281239ec..17ccd6517e 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -189,6 +189,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, nr_dci_size(current_DL_BWP, current_UL_BWP, mac->crossCarrierSchedulingConfig, + mac->pdsch_HARQ_ACK_Codebook, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, @@ -202,6 +203,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, nr_dci_size(current_DL_BWP, current_UL_BWP, mac->crossCarrierSchedulingConfig, + mac->pdsch_HARQ_ACK_Codebook, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, @@ -215,6 +217,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, rel15->dci_length_options[i] = nr_dci_size(current_DL_BWP, current_UL_BWP, mac->crossCarrierSchedulingConfig, + mac->pdsch_HARQ_ACK_Codebook, &mac->def_dci_pdu_rel15[dl_config->slot][dci_format], dci_format, rnti_type, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c index 02c4881898..1c3f1b7b0b 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c @@ -58,7 +58,7 @@ int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs, //TODO configure P-MAX from the upper layers according to 38.331 int p_powerclass = 23; // dBm assuming poweclass 3 UE - int p_emax = mac->p_Max ? *mac->p_Max : 0; + int p_emax = mac->p_Max != INT_MIN ? mac->p_Max : p_powerclass; int delta_P_powerclass = 0; // for powerclass 2 needs to be changed if(mac->p_Max && Qm == 1 && powerBoostPi2BPSK && (nr_band == 40 || nr_band == 41 || nr_band == 77 || nr_band == 78 || nr_band == 79)) { p_emax += 3; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 9251b9b38a..a96860a236 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -169,6 +169,9 @@ void nr_ue_init_mac(module_id_t module_idP) mac->phy_config_request_sent = false; mac->state = UE_NOT_SYNC; mac->si_window_start = -1; + mac->servCellIndex = 0; + memset(&mac->current_DL_BWP, 0, sizeof(mac->current_DL_BWP)); + memset(&mac->current_UL_BWP, 0, sizeof(mac->current_UL_BWP)); } void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) @@ -1361,7 +1364,8 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, NR_PUCCH_Resource_t *pucchres = pucch->pucch_resource; - if (current_UL_BWP->harq_ACK_SpatialBundlingPUCCH != NULL || *current_DL_BWP->pdsch_HARQ_ACK_Codebook != 1) { + if (mac->harq_ACK_SpatialBundlingPUCCH || + mac->pdsch_HARQ_ACK_Codebook != NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) { LOG_E(MAC,"PUCCH Unsupported cell group configuration\n"); return; } else if (current_DL_BWP && current_DL_BWP->pdsch_servingcellconfig && current_DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { @@ -2876,6 +2880,11 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, else N_RB = mac->type0_PDCCH_CSS_config.num_rbs; + if (N_RB == 0) { + LOG_E(MAC, "DCI configuration error! N_RB = 0\n"); + return 1; + } + switch(dci_format) { case NR_DL_DCI_FORMAT_1_0: diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index ec4ade5563..04a374a4f6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -847,6 +847,7 @@ static void nr_generate_Msg3_retransmission(module_id_t module_idP, ul_bwp->bwp_id, ss, coreset, + 0, // parameter not needed for DCI 0_0 nr_mac->cset0_bwp_size); // Mark the corresponding RBs as used @@ -1373,6 +1374,7 @@ static void nr_generate_Msg2(module_id_t module_idP, dl_bwp->bwp_id, ss, coreset, + 0, // parameter not needed for DCI 1_0 nr_mac->cset0_bwp_size); // DL TX request @@ -1595,6 +1597,7 @@ static void prepare_dl_pdus(gNB_MAC_INST *nr_mac, dl_bwp->bwp_id, ss, coreset, + 0, // parameter not needed for DCI 1_0 nr_mac->cset0_bwp_size); LOG_D(NR_MAC,"BWPSize: %i\n", pdcch_pdu_rel15->BWPSize); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 332e5a3fd9..47b714fbd0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -506,6 +506,7 @@ static void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, 0, gNB_mac->sched_ctrlCommon->search_space, gNB_mac->sched_ctrlCommon->coreset, + 0, // parameter not needed for DCI 1_0 gNB_mac->cset0_bwp_size); LOG_D(MAC,"BWPSize: %i\n", pdcch_pdu_rel15->BWPSize); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 90233cab82..230ac310e5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1198,6 +1198,7 @@ void nr_schedule_ue_spec(module_id_t module_id, bwp_id, sched_ctrl->search_space, sched_ctrl->coreset, + UE->pdsch_HARQ_ACK_Codebook, gNB_mac->cset0_bwp_size); LOG_D(NR_MAC, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 5697107c0b..d72339c11f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1138,6 +1138,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, int bwp_id, NR_SearchSpace_t *ss, NR_ControlResourceSet_t *coreset, + long pdsch_HARQ_ACK_Codebook, uint16_t cset0_bwp_size) { NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig = NULL; // TODO configure @@ -1161,6 +1162,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, crossCarrierSchedulingConfig, + pdsch_HARQ_ACK_Codebook, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, @@ -1174,6 +1176,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, crossCarrierSchedulingConfig, + pdsch_HARQ_ACK_Codebook, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, @@ -1190,6 +1193,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, int dci_size = nr_dci_size(current_DL_BWP, current_UL_BWP, crossCarrierSchedulingConfig, + pdsch_HARQ_ACK_Codebook, dci_pdu_rel15, dci_format, rnti_type, @@ -2054,9 +2058,6 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, int target_ss; - if (CellGroup && CellGroup->physicalCellGroupConfig) - DL_BWP->pdsch_HARQ_ACK_Codebook = &CellGroup->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook; - NR_ServingCellConfig_t *servingCellConfig = NULL; if (CellGroup && CellGroup->spCellConfig && @@ -2189,6 +2190,9 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, if(UE) { + if (CellGroup && CellGroup->physicalCellGroupConfig) + UE->pdsch_HARQ_ACK_Codebook = CellGroup->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook; + // Reset required fields in sched_ctrl (e.g. ul_ri and tpmi) reset_sched_ctrl(sched_ctrl); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index cc9a6c9f84..448c4e94f0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -2394,6 +2394,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n current_BWP->bwp_id, ss, coreset, + UE->pdsch_HARQ_ACK_Codebook, nr_mac->cset0_bwp_size); memset(sched_pusch, 0, sizeof(*sched_pusch)); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 2397de0fb7..9e8d9c396b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -236,6 +236,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, int bwp_id, NR_SearchSpace_t *ss, NR_ControlResourceSet_t *coreset, + long pdsch_HARQ_ACK_Codebook, uint16_t cset0_bwp_size); void prepare_dci(const NR_CellGroupConfig_t *CellGroup, const NR_UE_DL_BWP_t *current_BWP, const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 3ff713cbdb..b205abafd0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -705,6 +705,7 @@ typedef struct { uint32_t ra_timer; float ul_thr_ue; float dl_thr_ue; + long pdsch_HARQ_ACK_Codebook; } NR_UE_info_t; typedef struct { From 273562f345ffdf2d737fc451c7d21fa5ea10781d Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 25 Oct 2023 09:28:16 +0200 Subject: [PATCH 7/8] fix for do-ra and phy-test mode --- executables/nr-ue.c | 29 ++++++++++++++++-- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulsim.c | 3 +- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 4 ++- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 42 +++----------------------- 5 files changed, 36 insertions(+), 44 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 071d36087c..aaeda3df9a 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -34,6 +34,8 @@ #include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "radio/COMMON/common_lib.h" #include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h" +#include "LAYER2/nr_rlc/nr_rlc_oai_api.h" +#include "RRC/NR/MESSAGES/asn1_msg.h" /* * NR SLOT PROCESSING SEQUENCE @@ -949,10 +951,33 @@ void init_NR_UE(int nb_inst, char *uecap_file, char *reconfig_file, char *rbconf for (int inst = 0; inst < nb_inst; inst++) { AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file)) != NULL, "can not initialize RRC module\n"); - AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n"); + AssertFatal((mac_inst = nr_l2_init_ue()) != NULL, "can not initialize L2 module\n"); AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n"); - if (!get_softmodem_params()->sa) + if (!get_softmodem_params()->sa) { init_nsa_message(rrc_inst, reconfig_file, rbconfig_file); + // TODO why do we need noS1 configuration? + // temporarily moved here to understand why not using the one provided by gNB + nr_rlc_activate_srb0(mac_inst->crnti, NULL, send_srb0_rrc); + if (IS_SOFTMODEM_NOS1) { + // get default noS1 configuration + NR_RadioBearerConfig_t *rbconfig = NULL; + NR_RLC_BearerConfig_t *rlc_rbconfig = NULL; + fill_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig); + + // set up PDCP, RLC, MAC + nr_pdcp_layer_init(false); + nr_pdcp_add_drbs(ENB_FLAG_NO, mac_inst->crnti, rbconfig->drb_ToAddModList, 0, NULL, NULL); + nr_rlc_add_drb(mac_inst->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig); + struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_toadd_list; + rlc_toadd_list.list.count = 1; + rlc_toadd_list.list.array = calloc(1, sizeof(NR_RLC_BearerConfig_t)); + rlc_toadd_list.list.array[0] = rlc_rbconfig; + nr_rrc_mac_config_req_ue_logicalChannelBearer(0, &rlc_toadd_list, NULL); + + // free memory + free_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig); + } + } } } diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index fcc7bcc067..540fef1b38 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -822,7 +822,7 @@ int main(int argc, char **argv) nr_gold_pdsch(UE, i, UE->scramblingID_dlsch[i]); } - nr_l2_init_ue(NULL); + nr_l2_init_ue(); UE_mac = get_mac_inst(0); ue_init_config_request(UE_mac, mu); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index ba7e09d9f9..25e6d84430 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -690,8 +690,7 @@ int main(int argc, char *argv[]) } //Configure UE - NR_UE_RRC_INST_t rrcue = {0}; - nr_l2_init_ue(&rrcue); + nr_l2_init_ue(); NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 8b5c4b47d5..7789d4c0c4 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -43,6 +43,8 @@ \param module_id module id */ void nr_ue_init_mac(module_id_t module_idP); +void send_srb0_rrc(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *data); + /**\brief apply default configuration values in nr_mac instance \param mac mac instance */ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac); @@ -82,7 +84,7 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, NR_ServingCellConfigCommonSIB_t *scc); /**\brief initialization NR UE MAC instance(s), total number of MAC instance based on NB_NR_UE_MAC_INST*/ -NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst); +NR_UE_MAC_INST_t * nr_l2_init_ue(); /**\brief fetch MAC instance by module_id, within 0 - (NB_NR_UE_MAC_INST-1) \param module_id index of MAC instance(s)*/ diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index bbc3da1739..9371c8c7df 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -36,16 +36,13 @@ //#undef MALLOC #include "assertions.h" #include "executables/softmodem-common.h" -#include "openair2/LAYER2/nr_pdcp/nr_pdcp.h" -#include "openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h" #include "nr_rlc/nr_rlc_oai_api.h" -#include "RRC/NR/MESSAGES/asn1_msg.h" #include "RRC/NR_UE/rrc_proto.h" #include static NR_UE_MAC_INST_t *nr_ue_mac_inst; -static void send_srb0_rrc(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *data) +void send_srb0_rrc(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *data) { AssertFatal(sdu_len > 0 && sdu_len < CCCH_SDU_SIZE, "invalid CCCH SDU size %d\n", sdu_len); @@ -63,10 +60,9 @@ void send_msg3_rrc_request(module_id_t mod_id, int rnti) nr_mac_rrc_msg3_ind(mod_id, rnti); } -NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) +NR_UE_MAC_INST_t * nr_l2_init_ue() { LOG_I(NR_MAC, "MAIN: init UE MAC functions \n"); - //init mac here nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(NB_NR_UE_MAC_INST, sizeof(NR_UE_MAC_INST_t)); @@ -76,38 +72,8 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) if (get_softmodem_params()->sa) ue_init_config_request(nr_ue_mac_inst, get_softmodem_params()->numerology); - if (get_softmodem_params()->do_ra || get_softmodem_params()->phy_test) { - - int rc = rlc_module_init(0); - AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); - nr_rlc_activate_srb0(nr_ue_mac_inst->crnti, NULL, send_srb0_rrc); - if (IS_SOFTMODEM_NOS1){ - // get default noS1 configuration - NR_RadioBearerConfig_t *rbconfig = NULL; - NR_RLC_BearerConfig_t *rlc_rbconfig = NULL; - fill_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig); - - // set up PDCP, RLC, MAC - nr_pdcp_layer_init(false); - nr_pdcp_add_drbs(ENB_FLAG_NO, nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList, 0, NULL, NULL); - nr_rlc_add_drb(nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig); - struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_toadd_list; - rlc_toadd_list.list.count = 1; - rlc_toadd_list.list.array = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_toadd_list.list.array[0] = rlc_rbconfig; - nr_rrc_mac_config_req_ue_logicalChannelBearer(0, &rlc_toadd_list, NULL); - - // free memory - free_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig); - } - } - else { - LOG_I(MAC,"Running without CellGroupConfig\n"); - if(get_softmodem_params()->sa == 1) { - int rc = rlc_module_init(0); - AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); - } - } + int rc = rlc_module_init(0); + AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); return (nr_ue_mac_inst); } From c6e5ead2a94d250d566b1d36a5f5b546b62df177 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 26 Oct 2023 10:56:39 +0200 Subject: [PATCH 8/8] some more RRC cleanup --- executables/nr-uesoftmodem.c | 8 +++--- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 2 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 2 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 1 - openair2/LAYER2/NR_MAC_UE/mac_defs.h | 4 --- openair2/RRC/NR_UE/rrc_UE.c | 26 +++++++++---------- openair2/RRC/NR_UE/rrc_defs.h | 7 +---- 7 files changed, 19 insertions(+), 31 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 8e5751a190..12362105bd 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -476,11 +476,11 @@ int main( int argc, char **argv ) { #endif LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); - PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE **)); - PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE *) * MAX_NUM_CCs); + PHY_vars_UE_g = malloc(sizeof(*PHY_vars_UE_g)); + PHY_vars_UE_g[0] = malloc(sizeof(*PHY_vars_UE_g[0]) * MAX_NUM_CCs); for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - PHY_vars_UE_g[0][CC_id] = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE)); - memset(PHY_vars_UE_g[0][CC_id], 0, sizeof(PHY_VARS_NR_UE)); + PHY_vars_UE_g[0][CC_id] = malloc(sizeof(*PHY_vars_UE_g[0][CC_id])); + memset(PHY_vars_UE_g[0][CC_id], 0, sizeof(*PHY_vars_UE_g[0][CC_id])); } init_NR_UE(1, uecap_file, reconfig_file, rbconfig_file); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 867ec10b05..aceec80613 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3278,7 +3278,7 @@ uint16_t get_rb_bwp_dci(nr_dci_format_t format, uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, - NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig, + const NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig, long pdsch_HARQ_ACK_Codebook, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index c460119612..fab681d8f0 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -95,7 +95,7 @@ NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, - NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig, + const NR_CrossCarrierSchedulingConfig_t *crossCarrierSchedulingConfig, long pdsch_HARQ_ACK_Codebook, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 6cb0ef23ef..8de21221f1 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -802,7 +802,6 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); AssertFatal(cell_group_config, "CellGroupConfig should not be NULL\n"); NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - mac->cg = cell_group_config; if (cell_group_config->mac_CellGroupConfig) { // TODO handle MAC-CellGroupConfig diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 6182a0bf72..bec654260c 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -427,16 +427,12 @@ typedef struct ssb_list_info { /*!\brief Top level UE MAC structure */ typedef struct { NR_UE_L2_STATE_t state; - NR_CellGroupConfig_t *cg; int servCellIndex; long physCellId; //// MAC config int first_sync_frame; bool get_sib1; bool get_otherSI; - NR_DRX_Config_t *drx_Config; - NR_SchedulingRequestConfig_t *schedulingRequestConfig; - NR_RNTI_Value_t *cs_RNTI; NR_MIB_t *mib; struct NR_SI_SchedulingInfo *si_SchedulingInfo; int si_window_start; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index ccd92df77a..d77cfd6a47 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -147,7 +147,6 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, static void nr_rrc_ue_generate_RRCSetupRequest(rnti_t rnti); static void nr_rrc_ue_generate_rrcReestablishmentComplete(NR_RRCReestablishment_t *rrcReestablishment); static void process_lte_nsa_msg(NR_UE_RRC_INST_t *rrc, nsa_msg_t *msg, int msg_len); -static void configure_spcell(NR_UE_RRC_INST_t *rrc, NR_SpCellConfig_t *spcell_config); static void nr_rrc_ue_process_rrcReconfiguration(const instance_t instance, int gNB_index, rnti_t rnti, @@ -175,8 +174,6 @@ static void nr_rrc_ue_process_rrcReconfiguration(const instance_t instance, NR_RRCReconfiguration_IEs_t *ie = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration; if (ie->radioBearerConfig != NULL) { - if (rrc->radio_bearer_config == NULL) - rrc->radio_bearer_config = ie->radioBearerConfig; LOG_I(NR_RRC, "radio Bearer Configuration is present\n"); nr_rrc_ue_process_RadioBearerConfig(rrc, rnti, rrcNB, ie->radioBearerConfig); if (LOG_DEBUGFLAG(DEBUG_ASN1)) @@ -328,11 +325,11 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file) rrcPerNB_t *ptr = &rrc->perNB[i]; ptr->SInfo = (NR_UE_RRC_SI_INFO){0}; for (int j = 0; j < NR_NUM_SRB; j++) - ptr->Srb[j] = (NR_UE_RRC_SRB_INFO_t){0}; + ptr->Srb[j] = RB_NOT_PRESENT; for (int j = 0; j < MAX_DRBS_PER_UE; j++) ptr->status_DRBs[j] = RB_NOT_PRESENT; // SRB0 activated by default - ptr->Srb[0].status = RB_ESTABLISHED; + ptr->Srb[0] = RB_ESTABLISHED; } } @@ -695,7 +692,9 @@ static int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(instance_t instance, if(SI_info->sib1) ASN_STRUCT_FREE(asn_DEF_NR_SIB1, SI_info->sib1); NR_SIB1_t *sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1; - SI_info->sib1 = sib1; + if(!SI_info->sib1) + SI_info->sib1 = calloc(1, sizeof(*SI_info->sib1)); + memcpy(SI_info->sib1, sib1, sizeof(NR_SIB1_t)); if(g_log->log_component[NR_RRC].level >= OAILOG_DEBUG) xer_fprint(stdout, &asn_DEF_NR_SIB1, (const void *) SI_info->sib1); LOG_A(NR_RRC, "SIB1 decoded\n"); @@ -794,8 +793,8 @@ void nr_rrc_cellgroup_configuration(rrcPerNB_t *rrcNB, rrc->rnti = reconfigurationWithSync->newUE_Identity; // resume suspended radio bearers for (int i = 0; i < NR_NUM_SRB; i++) { - if (rrcNB->Srb[i].status == RB_SUSPENDED) - rrcNB->Srb[i].status = RB_ESTABLISHED; + if (rrcNB->Srb[i] == RB_SUSPENDED) + rrcNB->Srb[i] = RB_ESTABLISHED; } for (int i = 0; i < MAX_DRBS_PER_UE; i++) { if (rrcNB->status_DRBs[i] == RB_SUSPENDED) @@ -1030,7 +1029,7 @@ static void nr_rrc_ue_process_securityModeCommand(NR_UE_RRC_INST_t *ue_rrc, uint8_t security_mode = ue_rrc->cipheringAlgorithm | (ue_rrc->integrityProtAlgorithm << 4); // configure lower layers to apply SRB integrity protection and ciphering for (int i = 1; i < NR_NUM_SRB; i++) { - if (ue_rrc->perNB[gNB_index].Srb[i].status == RB_ESTABLISHED) + if (ue_rrc->perNB[gNB_index].Srb[i] == RB_ESTABLISHED) nr_pdcp_config_set_security(rnti, i, security_mode, kRRCenc, kRRCint, kUPenc); } } else { @@ -1223,8 +1222,7 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, if (radioBearerConfig->srb_ToAddModList != NULL) { for (int cnt = 0; cnt < radioBearerConfig->srb_ToAddModList->list.count; cnt++) { struct NR_SRB_ToAddMod *srb = radioBearerConfig->srb_ToAddModList->list.array[cnt]; - NR_UE_RRC_SRB_INFO_t *Srb_info = &rrcNB->Srb[srb->srb_Identity]; - if (Srb_info->status == RB_NOT_PRESENT) + if (rrcNB->Srb[srb->srb_Identity] == RB_NOT_PRESENT) add_srb(false, rnti, radioBearerConfig->srb_ToAddModList->list.array[cnt], @@ -1238,7 +1236,7 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, if (srb->pdcp_Config && srb->pdcp_Config->t_Reordering) nr_pdcp_reconfigure_srb(rnti, srb->srb_Identity, *srb->pdcp_Config->t_Reordering); } - Srb_info->status = RB_ESTABLISHED; + rrcNB->Srb[srb->srb_Identity] = RB_ESTABLISHED; } } @@ -1413,10 +1411,10 @@ void nr_rrc_handle_ra_indication(NR_UE_RRC_INST_t *rrc, bool ra_succeeded) // reconfigurationWithSync is included in spCellConfig } } + void *rrc_nrue_task(void *args_p) { itti_mark_task_ready(TASK_RRC_NRUE); - while (1) { rrc_nrue(NULL); } @@ -1506,7 +1504,7 @@ void *rrc_nrue(void *notUsed) /* Transfer data to PDCP */ // check if SRB2 is created, if yes request data_req on SRB2 // error: the remote gNB is hardcoded here - rb_id_t srb_id = rrc->perNB[0].Srb[2].status == RB_ESTABLISHED ? 2 : 1; + rb_id_t srb_id = rrc->perNB[0].Srb[2] == RB_ESTABLISHED ? 2 : 1; nr_pdcp_data_req_srb(rrc->rnti, srb_id, 0, length, buffer, deliver_pdu_srb_rlc, NULL); break; } diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index 7160ff19c7..998f83e75c 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -180,17 +180,13 @@ typedef enum { typedef enum { RB_NOT_PRESENT, RB_ESTABLISHED, RB_SUSPENDED } NR_RB_status_t; -typedef struct NR_UE_RRC_SRB_INFO_s { - NR_RB_status_t status; -} NR_UE_RRC_SRB_INFO_t; - typedef struct rrcPerNB { NR_MeasObjectToAddMod_t *MeasObj[MAX_MEAS_OBJ]; NR_ReportConfigToAddMod_t *ReportConfig[MAX_MEAS_CONFIG]; NR_QuantityConfig_t *QuantityConfig; NR_MeasIdToAddMod_t *MeasId[MAX_MEAS_ID]; NR_MeasGapConfig_t *measGapConfig; - NR_UE_RRC_SRB_INFO_t Srb[NR_NUM_SRB]; + NR_RB_status_t Srb[NR_NUM_SRB]; NR_RB_status_t status_DRBs[MAX_DRBS_PER_UE]; bool active_RLC_entity[NR_MAX_NUM_LCID]; NR_UE_RRC_SI_INFO SInfo; @@ -199,7 +195,6 @@ typedef struct rrcPerNB { typedef struct NR_UE_RRC_INST_s { NR_MeasConfig_t *meas_config; - NR_RadioBearerConfig_t *radio_bearer_config; rrcPerNB_t perNB[NB_CNX_UE];