From 2715c7efdd4563fe6c20bd1dd01650e6106665ba Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 24 Oct 2023 12:29:57 +0200 Subject: [PATCH] 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 {