From e678676a3d768bc8d2186711664e92aa3548a47a Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 19 May 2023 18:07:05 +0200 Subject: [PATCH 1/7] remove old BWP structures at UE MAC --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 21 +------- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 4 -- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 1 - openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 39 ++++---------- .../NR_MAC_UE/nr_ue_dci_configuration.c | 5 +- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 53 ++++++------------- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 1 - 7 files changed, 31 insertions(+), 93 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index a3bb33868e..4ac46f7962 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -439,28 +439,11 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, @param NR_UE_MAC_INST_t mac: pointer to local MAC instance @returns void */ -void config_control_ue(NR_UE_MAC_INST_t *mac){ - - int bwp_id; +void config_control_ue(NR_UE_MAC_INST_t *mac) +{ NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; - // configure DLbwp - if (scd->downlinkBWP_ToAddModList) { - for (int i = 0; i < scd->downlinkBWP_ToAddModList->list.count; i++) { - bwp_id = scd->downlinkBWP_ToAddModList->list.array[i]->bwp_Id; - mac->DLbwp[bwp_id-1] = scd->downlinkBWP_ToAddModList->list.array[i]; - } - } - - // configure ULbwp - if (scd->uplinkConfig->uplinkBWP_ToAddModList) { - for (int i = 0; i < scd->uplinkConfig->uplinkBWP_ToAddModList->list.count; i++) { - bwp_id = scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[i]->bwp_Id; - mac->ULbwp[bwp_id-1] = scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[i]; - } - } - configure_ss_coreset(mac, scd, dl_bwp_id); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index cc2f90280e..14ff5d886e 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -412,8 +412,6 @@ typedef struct { NR_UE_UL_BWP_t current_UL_BWP; NR_UL_TIME_ALIGNMENT_t ul_time_alignment; - NR_BWP_Downlink_t *DLbwp[MAX_NUM_BWP_UE]; - NR_BWP_Uplink_t *ULbwp[MAX_NUM_BWP_UE]; NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP]; NR_SearchSpace_t *SSpace[MAX_NUM_BWP_UE][FAPI_NR_MAX_SS]; @@ -527,7 +525,5 @@ typedef struct ssb_list_info { uint8_t nb_tx_ssb; } ssb_list_info_t; -void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); - /*@}*/ #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 53888c0f1d..573430878e 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -420,7 +420,6 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p uint16_t n_RB_DLBWP, uint16_t riv); -void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, int slot, int rnti); void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 65ea5e2a79..155ea5cc19 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -85,40 +85,19 @@ void init_RA(module_id_t mod_id, prach_resources->POWER_OFFSET_2STEP_RA = 0; prach_resources->RA_SCALING_FACTOR_BI = 1; - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList; - NR_SearchSpaceId_t *ra_ss; - NR_SearchSpaceId_t ss_id = -1; - NR_SearchSpace_t *ss = NULL; + NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; + NR_BWP_DownlinkCommon_t *bwp_Common = get_bwp_downlink_common(mac, dl_bwp_id); + AssertFatal(bwp_Common != NULL, "bwp_Common is null\n"); + NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; + NR_SearchSpaceId_t *ss_id = pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - if (mac->scc) { - NR_SearchSpaceId_t *ra_ss = mac->scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - if (ra_ss) { - commonSearchSpaceList = mac->scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ss_id = *ra_ss; - } - } else if (mac->scc_SIB) { - NR_SearchSpaceId_t *ra_ss = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - if (ra_ss) { - commonSearchSpaceList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ss_id = *ra_ss; - } - } - if (ss_id < 0) { - if (mac->current_DL_BWP.bwp_id>0) { - ra_ss = mac->DLbwp[mac->current_DL_BWP.bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - if (ra_ss) { - commonSearchSpaceList = mac->DLbwp[mac->current_DL_BWP.bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ss_id = *ra_ss; - } - } - } - - AssertFatal(ss_id>-1,"Didn't find ra-SearchSpace\n"); + AssertFatal(ss_id, "Didn't find ra-SearchSpace\n"); AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); // Common searchspace list for (int i = 0; i < commonSearchSpaceList->list.count; i++) { - ss = commonSearchSpaceList->list.array[i]; - if (ss->searchSpaceId == ss_id) + NR_SearchSpace_t *ss = commonSearchSpaceList->list.array[i]; + if (ss->searchSpaceId == *ss_id) ra->ss = ss; } 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 69cdfde879..333bb21725 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -266,8 +266,9 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl int ss_id; uint8_t bwp_id = mac->current_DL_BWP.bwp_id; - //NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated; - NR_BWP_DownlinkDedicated_t *bwpd = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Dedicated : (mac->cg ? mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL); + NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; + NR_BWP_DownlinkDedicated_t *bwpd = bwp_id > 0 ? scd->downlinkBWP_ToAddModList->list.array[bwp_id - 1]->bwp_Dedicated: + scd->initialDownlinkBWP; NR_BWP_DownlinkCommon_t *bwp_Common = get_bwp_downlink_common(mac, bwp_id); LOG_D(NR_MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 49eb8416f1..a8535e185b 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -526,11 +526,6 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->tbslbrm = 0; } else if (dci) { - NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; - - int target_ss; - bool valid_ptrs_setup = 0; - pusch_config_pdu->bwp_start = current_UL_BWP->BWPStart; pusch_config_pdu->bwp_size = current_UL_BWP->BWPSize; @@ -544,21 +539,21 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->transform_precoding = get_transformPrecoding(current_UL_BWP, *dci_format, 0); /*DCI format-related configuration*/ + int target_ss; if (*dci_format == NR_UL_DCI_FORMAT_0_0) { - target_ss = NR_SearchSpace__searchSpaceType_PR_common; - + if ((pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled) && + pusch_config_pdu->nr_of_symbols < 3) + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 1; + else + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; } else if (*dci_format == NR_UL_DCI_FORMAT_0_1) { - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; ul_layers_config(mac, pusch_config_pdu, dci, *dci_format); ul_ports_config(mac, &dmrslength, pusch_config_pdu, dci, *dci_format); - } else { - LOG_E(NR_MAC, "In %s: UL grant from DCI format %d is not handled...\n", __FUNCTION__, *dci_format); return -1; - } int mappingtype = tda_info->mapping_type; @@ -577,8 +572,6 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, /* TRANSFORM PRECODING ------------------------------------------------------------------------------------------*/ if (pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled) { - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; - uint32_t n_RS_Id = 0; if (NR_DMRS_ulconfig->transformPrecodingEnabled && NR_DMRS_ulconfig->transformPrecodingEnabled->nPUSCH_Identity != NULL) @@ -664,18 +657,6 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->start_symbol_index, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); - if (ul_bwp_id > 0 && - mac->ULbwp[ul_bwp_id - 1] && - pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled && - *dci_format != NR_UL_DCI_FORMAT_0_1) { - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 1; - } else if (*dci_format == NR_UL_DCI_FORMAT_0_0 || - (ul_bwp_id > 0 && - mac->ULbwp[ul_bwp_id-1] && - pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled)) { - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; - } - // Num PRB Overhead from PUSCH-ServingCellConfig if (current_UL_BWP->pusch_servingcellconfig && current_UL_BWP->pusch_servingcellconfig->xOverhead) N_PRB_oh = *current_UL_BWP->pusch_servingcellconfig->xOverhead; @@ -699,17 +680,17 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, if (pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled) { nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; pusch_config_pdu->pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; - valid_ptrs_setup = set_ul_ptrs_values(pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup, - pusch_config_pdu->rb_size, - pusch_config_pdu->mcs_index, - pusch_config_pdu->mcs_table, - &pusch_config_pdu->pusch_ptrs.ptrs_freq_density, - &pusch_config_pdu->pusch_ptrs.ptrs_time_density, - &pusch_config_pdu->pusch_ptrs.ptrs_ports_list->ptrs_re_offset, - &pusch_config_pdu->pusch_ptrs.num_ptrs_ports, - &pusch_config_pdu->pusch_ptrs.ul_ptrs_power, - pusch_config_pdu->nr_of_symbols); - if(valid_ptrs_setup==true) { + bool valid_ptrs_setup = set_ul_ptrs_values(pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup, + pusch_config_pdu->rb_size, + pusch_config_pdu->mcs_index, + pusch_config_pdu->mcs_table, + &pusch_config_pdu->pusch_ptrs.ptrs_freq_density, + &pusch_config_pdu->pusch_ptrs.ptrs_time_density, + &pusch_config_pdu->pusch_ptrs.ptrs_ports_list->ptrs_re_offset, + &pusch_config_pdu->pusch_ptrs.num_ptrs_ports, + &pusch_config_pdu->pusch_ptrs.ul_ptrs_power, + pusch_config_pdu->nr_of_symbols); + if(valid_ptrs_setup == true) { pusch_config_pdu->pdu_bit_map |= PUSCH_PDU_BITMAP_PUSCH_PTRS; } LOG_D(NR_MAC, "UL PTRS values: PTRS time den: %d, PTRS freq den: %d\n", pusch_config_pdu->pusch_ptrs.ptrs_time_density, pusch_config_pdu->pusch_ptrs.ptrs_freq_density); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 33bd6831d1..5ceaed1f56 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2897,7 +2897,6 @@ void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCom void send_initial_ul_rrc_message(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *rawUE) { - LOG_W(MAC, "[RAPROC] Received SDU for CCCH length %d for UE %04x\n", sdu_len, rnti); NR_UE_info_t *UE = (NR_UE_info_t *)rawUE; NR_SCHED_ENSURE_LOCKED(&mac->sched_lock); From d9dfd732f504e8a1de630f6b9064ecdb9b72d495 Mon Sep 17 00:00:00 2001 From: francescomani Date: Sat, 20 May 2023 17:42:56 +0200 Subject: [PATCH 2/7] store common searchspaces (for RA, SI, P) --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 47 ++++++++++++++++++- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 6 +-- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 16 ------- .../NR_MAC_UE/nr_ue_dci_configuration.c | 7 +-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 4 +- 6 files changed, 55 insertions(+), 27 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 4ac46f7962..94259fed2e 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -447,11 +447,48 @@ void config_control_ue(NR_UE_MAC_INST_t *mac) configure_ss_coreset(mac, scd, dl_bwp_id); } +NR_SearchSpace_t *get_common_search_space(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList, + NR_UE_MAC_INST_t *mac, + NR_SearchSpaceId_t ss_id) +{ + if (ss_id == 0) + return mac->search_space_zero; + + NR_SearchSpace_t *css = NULL; + for (int i = 0; i < commonSearchSpaceList->list.count; i++) { + if (commonSearchSpaceList->list.array[i]->searchSpaceId == ss_id) { + css = commonSearchSpaceList->list.array[i]; + break; + } + } + AssertFatal(css, "Couldn't find CSS with Id %ld\n", ss_id); + return css; +} + +void configure_common_ss(NR_UE_MAC_INST_t *mac, + NR_PDCCH_ConfigCommon_t *pdcch_ConfigCommon) +{ + if (pdcch_ConfigCommon) { + mac->otherSI_SS = pdcch_ConfigCommon->searchSpaceOtherSystemInformation ? + get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, mac, + *pdcch_ConfigCommon->searchSpaceOtherSystemInformation) : + NULL; + mac->ra_SS = pdcch_ConfigCommon->ra_SearchSpace ? + get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, mac, + *pdcch_ConfigCommon->ra_SearchSpace) : + NULL; + mac->paging_SS = pdcch_ConfigCommon->pagingSearchSpace ? + get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, mac, + *pdcch_ConfigCommon->pagingSearchSpace) : + NULL; + } +} + void configure_ss_coreset(NR_UE_MAC_INST_t *mac, NR_ServingCellConfig_t *scd, - NR_BWP_Id_t dl_bwp_id) { - + NR_BWP_Id_t dl_bwp_id) +{ NR_BWP_DownlinkCommon_t *bwp_Common = get_bwp_downlink_common(mac, dl_bwp_id); AssertFatal(bwp_Common != NULL, "bwp_Common is null\n"); @@ -564,6 +601,8 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, UL_BWP->pucch_ConfigCommon = bwp_ulcommon->pucch_ConfigCommon->choice.setup; if (bwp_ulcommon->rach_ConfigCommon) UL_BWP->rach_ConfigCommon = bwp_ulcommon->rach_ConfigCommon->choice.setup; + if (bwp_dlcommon->pdcch_ConfigCommon) + configure_common_ss(mac, bwp_dlcommon->pdcch_ConfigCommon->choice.setup); } if(cell_group_config) { @@ -609,11 +648,15 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, 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; + if (bwp_downlink->bwp_Common->pdcch_ConfigCommon) + configure_common_ss(mac, bwp_downlink->bwp_Common->pdcch_ConfigCommon->choice.setup); } else { dl_genericParameters = bwp_dlcommon->genericParameters; DL_BWP->pdsch_Config = spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup; DL_BWP->tdaList_Common = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + if (bwp_dlcommon->pdcch_ConfigCommon) + configure_common_ss(mac, bwp_dlcommon->pdcch_ConfigCommon->choice.setup); } UL_BWP->msg3_DeltaPreamble = bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 14ff5d886e..b9c0f9eab0 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -325,9 +325,6 @@ typedef struct { /// BeamfailurerecoveryConfig NR_BeamFailureRecoveryConfig_t RA_BeamFailureRecoveryConfig; - /// RA SearchSpace - NR_SearchSpace_t *ss; - NR_PRACH_RESOURCES_t prach_resources; } RA_config_t; @@ -414,6 +411,9 @@ typedef struct { NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP]; NR_SearchSpace_t *SSpace[MAX_NUM_BWP_UE][FAPI_NR_MAX_SS]; + NR_SearchSpace_t *otherSI_SS; + NR_SearchSpace_t *ra_SS; + NR_SearchSpace_t *paging_SS; bool phy_config_request_sent; frame_type_t frame_type; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 155ea5cc19..130b46143b 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -85,22 +85,6 @@ void init_RA(module_id_t mod_id, prach_resources->POWER_OFFSET_2STEP_RA = 0; prach_resources->RA_SCALING_FACTOR_BI = 1; - NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; - NR_BWP_DownlinkCommon_t *bwp_Common = get_bwp_downlink_common(mac, dl_bwp_id); - AssertFatal(bwp_Common != NULL, "bwp_Common is null\n"); - NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; - NR_SearchSpaceId_t *ss_id = pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - - AssertFatal(ss_id, "Didn't find ra-SearchSpace\n"); - AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); - // Common searchspace list - for (int i = 0; i < commonSearchSpaceList->list.count; i++) { - NR_SearchSpace_t *ss = commonSearchSpaceList->list.array[i]; - if (ss->searchSpaceId == *ss_id) - ra->ss = ss; - } - if (rach_ConfigDedicated) { if (rach_ConfigDedicated->cfra){ LOG_I(MAC, "Initialization of 2-step contention-free random access procedure\n"); 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 333bb21725..6d5739d647 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -101,9 +101,10 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t NR_ControlResourceSet_t *coreset; if(ss_id>=0) { if (rnti_type == NR_RNTI_TC || rnti_type == NR_RNTI_RA) { - ss = mac->ra.ss; - AssertFatal(mac->ra.ss->searchSpaceId == ss_id,"Search Space id %d does not correspond to the one in ra->ss %ld for RA procedures\n", - ss_id,mac->ra.ss->searchSpaceId); + ss = mac->ra_SS; + AssertFatal(mac->ra_SS->searchSpaceId == ss_id, + "Search Space id %d does not correspond to the one in ra_ss %ld for RA procedures\n", + ss_id, mac->ra_SS->searchSpaceId); } else ss = mac->SSpace[dl_bwp_id][ss_id-1]; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 7326d187a4..4fe0492854 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -4119,7 +4119,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) // Schedule Msg3 NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_tda_info_t tda_info = get_ul_tda_info(current_UL_BWP, *ra->ss->controlResourceSetId, ra->ss->searchSpaceType->present, NR_RNTI_RA, rar_grant.Msg3_t_alloc); + NR_tda_info_t tda_info = get_ul_tda_info(current_UL_BWP, *mac->ra_SS->controlResourceSetId, mac->ra_SS->searchSpaceType->present, NR_RNTI_RA, rar_grant.Msg3_t_alloc); if (tda_info.nrOfSymbols == 0) { LOG_E(MAC, "Cannot schedule Msg3. Something wrong in TDA information\n"); return -1; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index a8535e185b..b428996110 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -983,8 +983,8 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info) rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; if (mac->ra.ra_state == WAIT_CONTENTION_RESOLUTION) rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_0; // msg3 retransmission - config_dci_pdu(mac, rel15, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , mac->ra.ss->searchSpaceId); - fill_dci_search_candidates(mac->ra.ss, rel15, -1 , -1); + config_dci_pdu(mac, rel15, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , mac->ra_SS->searchSpaceId); + fill_dci_search_candidates(mac->ra_SS, rel15, -1 , -1); dl_config->number_pdus = 1; LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response rnti %x, type0_pdcch, num_pdus %d\n",mac->cg,rel15->rnti,dl_config->number_pdus); fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->phy_data); From 4af3d76d0e3bff8650c219db70956043f52d9903 Mon Sep 17 00:00:00 2001 From: francescomani Date: Sun, 21 May 2023 11:26:26 +0200 Subject: [PATCH 3/7] dci options inside config_dci_pdu function --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 9 ++- .../NR_MAC_UE/nr_ue_dci_configuration.c | 67 ++++++++++++------- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 13 +--- 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 573430878e..0f1d62ba34 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -249,7 +249,12 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, NR_BSR_SHORT *short_bsr, NR_BSR_LONG *long_bsr); -void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); +void config_dci_pdu(NR_UE_MAC_INST_t *mac, + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + fapi_nr_dl_config_request_t *dl_config, + int rnti_type, + int slot, + int ss_id); void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot); @@ -420,8 +425,6 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p uint16_t n_RB_DLBWP, uint16_t riv); -void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, int slot, int rnti); - void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs); 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 6d5739d647..bc8b03d5e0 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -51,23 +51,19 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, - int slot, int rnti) + uint32_t Y) { LOG_D(NR_MAC,"Filling search candidates for DCI\n"); - uint8_t aggregation; - uint8_t number_of_candidates = 0; rel15->number_of_candidates = 0; - uint32_t Y = 0; int i = 0; - if (slot >= 0) - Y = get_Y(ss, slot, rnti); for (int maxL = 16; maxL > 0; maxL >>= 1) { + uint8_t aggregation, number_of_candidates; find_aggregation_candidates(&aggregation, &number_of_candidates, - ss,maxL); - - if (number_of_candidates>0) { + ss, + maxL); + if (number_of_candidates > 0) { LOG_D(NR_MAC,"L %d, number of candidates %d, aggregation %d\n", maxL, number_of_candidates, aggregation); rel15->number_of_candidates += number_of_candidates; int N_cce_sym = 0; // nb of rbs of coreset per symbol @@ -87,7 +83,12 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss, } } -void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id) +void config_dci_pdu(NR_UE_MAC_INST_t *mac, + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + fapi_nr_dl_config_request_t *dl_config, + int rnti_type, + int slot, + int ss_id) { uint16_t monitoringSymbolsWithinSlot = 0; @@ -153,6 +154,29 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->coreset.pdcch_dmrs_scrambling_id = mac->physCellId; rel15->coreset.scrambling_rnti = 0; } + + rel15->num_dci_options = (mac->ra.ra_state == WAIT_RAR || + rnti_type == NR_RNTI_SI) ? + 1 : 2; + + if (ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { + if (ss->searchSpaceType->choice.ue_Specific->dci_Formats == + NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0) { + rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; + rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_0; + } + else { + rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1; + rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1; + } + } + else { // common + AssertFatal(ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0, + "Only supporting format 10 and 00 for common SS\n"); + rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; + rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_0; + } + // loop over RNTI type and configure resource allocation for DCI for (int i = 0; i < rel15->num_dci_options; i++) { rel15->dci_type_options[i] = ss->searchSpaceType->present; @@ -245,6 +269,11 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t break; } } + uint32_t Y = 0; + if (ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) + Y = get_Y(ss, slot, rel15->rnti); + fill_dci_search_candidates(ss, rel15, Y); + #ifdef DEBUG_DCI LOG_D(MAC, "[DCI_CONFIG] Configure DCI PDU: rnti_type %d BWPSize %d BWPStart %d rel15->SubcarrierSpacing %d rel15->dci_format %d rel15->dci_length %d sps %d monitoringSymbolsWithinSlot %d \n", rnti_type, @@ -299,21 +328,15 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl switch(ra->ra_state){ case WAIT_RAR: LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg2)\n"); - rel15->num_dci_options = 1; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; if (get_softmodem_params()->sa) { - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, -1); + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, slot, -1); } else { - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, ss_id); + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, slot, ss_id); } - fill_dci_search_candidates(ss, rel15, -1, -1); break; case WAIT_CONTENTION_RESOLUTION: LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg4)\n"); - rel15->num_dci_options = 1; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_TC, -1); - fill_dci_search_candidates(ss, rel15, -1, -1); + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_TC, slot, -1); break; default: break; @@ -381,11 +404,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl mac->crnti > 0) { // Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n"); - rel15->num_dci_options = 2; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1; - rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1; - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id); - fill_dci_search_candidates(ss, rel15, slot, mac->crnti); + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, slot, ss_id); //#ifdef DEBUG_DCI LOG_D(NR_MAC, "[DCI_CONFIG] ss %d ue_Specific %p searchSpaceType->present %d dci_Formats %d\n", diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index b428996110..7b39a32408 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -979,13 +979,7 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info) if(mac->ul_time_alignment.ta_apply) schedule_ta_command(dl_config, &mac->ul_time_alignment); fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - rel15->num_dci_options = mac->ra.ra_state == WAIT_RAR ? 1 : 2; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; - if (mac->ra.ra_state == WAIT_CONTENTION_RESOLUTION) - rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_0; // msg3 retransmission - config_dci_pdu(mac, rel15, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , mac->ra_SS->searchSpaceId); - fill_dci_search_candidates(mac->ra_SS, rel15, -1 , -1); - dl_config->number_pdus = 1; + config_dci_pdu(mac, rel15, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , rx_slot, mac->ra_SS->searchSpaceId); LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response rnti %x, type0_pdcch, num_pdus %d\n",mac->cg,rel15->rnti,dl_config->number_pdus); fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->phy_data); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) @@ -2637,10 +2631,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, fill_coresetZero(mac->coreset0, &mac->type0_PDCCH_CSS_config); fill_searchSpaceZero(mac->search_space_zero, &mac->type0_PDCCH_CSS_config); rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - rel15->num_dci_options = 1; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, -1); - fill_dci_search_candidates(mac->search_space_zero, rel15, -1, -1); + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, slot_s, -1); LOG_D(MAC,"Calling fill_scheduled_response, type0_pdcch, num_pdus %d\n",dl_config->number_pdus); fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, module_idP, cc_id, frame_s, slot_s, phy_data); From 4183e5846e849e72d482a789cda63ca7d004d09b Mon Sep 17 00:00:00 2001 From: francescomani Date: Sun, 21 May 2023 18:14:30 +0200 Subject: [PATCH 4/7] use BWP specific SS and coreset structures --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 137 +++++++----------- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 8 +- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 7 +- .../NR_MAC_UE/nr_ue_dci_configuration.c | 64 ++++---- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 21 ++- 5 files changed, 95 insertions(+), 142 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 94259fed2e..b66600aa22 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -434,18 +434,6 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, cfg->prach_config.ssb_per_rach = rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present-1; } -/** \brief This function is relavant for the UE procedures for control. It loads the search spaces, the BWPs and the CORESETs into the MAC instance and - \brief performs assert checks on the relevant RRC configuration. - @param NR_UE_MAC_INST_t mac: pointer to local MAC instance - @returns void - */ -void config_control_ue(NR_UE_MAC_INST_t *mac) -{ - NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; - NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; - - configure_ss_coreset(mac, scd, dl_bwp_id); -} NR_SearchSpace_t *get_common_search_space(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList, NR_UE_MAC_INST_t *mac, @@ -465,9 +453,12 @@ NR_SearchSpace_t *get_common_search_space(struct NR_PDCCH_ConfigCommon__commonSe return css; } -void configure_common_ss(NR_UE_MAC_INST_t *mac, - NR_PDCCH_ConfigCommon_t *pdcch_ConfigCommon) +void configure_ss_coreset(NR_UE_MAC_INST_t *mac, + NR_PDCCH_ConfigCommon_t *pdcch_ConfigCommon, + NR_PDCCH_Config_t *pdcch_Config) { + + // configuration of search spaces if (pdcch_ConfigCommon) { mac->otherSI_SS = pdcch_ConfigCommon->searchSpaceOtherSystemInformation ? get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, mac, @@ -482,75 +473,47 @@ void configure_common_ss(NR_UE_MAC_INST_t *mac, *pdcch_ConfigCommon->pagingSearchSpace) : NULL; } -} - - -void configure_ss_coreset(NR_UE_MAC_INST_t *mac, - NR_ServingCellConfig_t *scd, - NR_BWP_Id_t dl_bwp_id) -{ - NR_BWP_DownlinkCommon_t *bwp_Common = get_bwp_downlink_common(mac, dl_bwp_id); - AssertFatal(bwp_Common != NULL, "bwp_Common is null\n"); - - NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; - AssertFatal(pdcch_ConfigCommon != NULL, "pdcch_ConfigCommon is null\n"); - - // configuring eventual common coreset - NR_ControlResourceSet_t *coreset = pdcch_ConfigCommon->choice.setup->commonControlResourceSet; - if (coreset) - mac->coreset[dl_bwp_id][coreset->controlResourceSetId - 1] = coreset; - - NR_BWP_DownlinkDedicated_t *dl_bwp_Dedicated = dl_bwp_id>0 ? scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]->bwp_Dedicated: - scd->initialDownlinkBWP; - - AssertFatal(dl_bwp_Dedicated != NULL, "dl_bwp_Dedicated is null\n"); - - NR_SetupRelease_PDCCH_Config_t *pdcch_Config = dl_bwp_Dedicated->pdcch_Config; - AssertFatal(pdcch_Config != NULL, "pdcch_Config is null\n"); - - struct NR_PDCCH_Config__controlResourceSetToAddModList *controlResourceSetToAddModList = pdcch_Config->choice.setup->controlResourceSetToAddModList; - AssertFatal(controlResourceSetToAddModList != NULL, "controlResourceSetToAddModList is null\n"); - - // configuring dedicated coreset - // In case network reconfigures control resource set with the same ControlResourceSetId as used for commonControlResourceSet configured via PDCCH-ConfigCommon, - // the configuration from PDCCH-Config always takes precedence - for (int i=0; ilist.count; i++) { - coreset = controlResourceSetToAddModList->list.array[i]; - mac->coreset[dl_bwp_id][coreset->controlResourceSetId - 1] = coreset; + if(pdcch_Config && + pdcch_Config->searchSpacesToAddModList) { + int ss_configured = 0; + struct NR_PDCCH_Config__searchSpacesToAddModList *searchSpacesToAddModList = pdcch_Config->searchSpacesToAddModList; + for (int i = 0; i < searchSpacesToAddModList->list.count; i++) { + AssertFatal(ss_configured < FAPI_NR_MAX_SS, "Attempting to configure %d SS but only %d per BWP are allowed", + ss_configured + 1, FAPI_NR_MAX_SS); + mac->BWP_searchspaces[ss_configured] = searchSpacesToAddModList->list.array[i]; + ss_configured++; + } + for (int i = ss_configured; i < FAPI_NR_MAX_SS; i++) + mac->BWP_searchspaces[i] = NULL; } - struct NR_PDCCH_Config__searchSpacesToAddModList *searchSpacesToAddModList = pdcch_Config->choice.setup->searchSpacesToAddModList; - AssertFatal(searchSpacesToAddModList != NULL, "searchSpacesToAddModList is null\n"); - AssertFatal(searchSpacesToAddModList->list.count > 0, "list of UE specifically configured Search Spaces is empty\n"); - AssertFatal(searchSpacesToAddModList->list.count < FAPI_NR_MAX_SS_PER_BWP, "too many searchpaces per coreset %d\n", searchSpacesToAddModList->list.count); - - // check available Search Spaces in the searchSpacesToAddModList and pass to MAC - // note: the network configures at most 10 Search Spaces per BWP per cell (including UE-specific and common Search Spaces). - for (int ss_id = 0; ss_id < searchSpacesToAddModList->list.count; ss_id++) { - NR_SearchSpace_t *ss = searchSpacesToAddModList->list.array[ss_id]; - AssertFatal(ss->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); - AssertFatal(ss->searchSpaceType != NULL, "ss->searchSpaceType is null\n"); - AssertFatal(ss->monitoringSymbolsWithinSlot != NULL, "NR_SearchSpace->monitoringSymbolsWithinSlot is null\n"); - AssertFatal(ss->monitoringSymbolsWithinSlot->buf != NULL, "NR_SearchSpace->monitoringSymbolsWithinSlot->buf is null\n"); - AssertFatal(ss->searchSpaceId <= FAPI_NR_MAX_SS, "Invalid searchSpaceId\n"); - mac->SSpace[dl_bwp_id][ss->searchSpaceId - 1] = ss; + // configuration of coresets + int cset_configured = 0; + int common_cset_id = -1; + if (pdcch_ConfigCommon && + pdcch_ConfigCommon->commonControlResourceSet) { + mac->BWP_coresets[cset_configured] = pdcch_ConfigCommon->commonControlResourceSet; + common_cset_id = pdcch_ConfigCommon->commonControlResourceSet->controlResourceSetId; + cset_configured++; } - - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - AssertFatal(commonSearchSpaceList != NULL, "commonSearchSpaceList is null\n"); - AssertFatal(commonSearchSpaceList->list.count > 0, "PDCCH CSS list has 0 elements\n"); - - // Check available CSSs in the commonSearchSpaceList (list of additional common search spaces) - // note: commonSearchSpaceList SIZE(1..4) - for (int css_id = 0; css_id < commonSearchSpaceList->list.count; css_id++) { - NR_SearchSpace_t *css = commonSearchSpaceList->list.array[css_id]; - AssertFatal(css->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); - AssertFatal(css->searchSpaceType != NULL, "css->searchSpaceType is null\n"); - AssertFatal(css->monitoringSymbolsWithinSlot != NULL, "css->monitoringSymbolsWithinSlot is null\n"); - AssertFatal(css->monitoringSymbolsWithinSlot->buf != NULL, "css->monitoringSymbolsWithinSlot->buf is null\n"); - AssertFatal(css->searchSpaceId <= FAPI_NR_MAX_SS, "Invalid searchSpaceId\n"); - mac->SSpace[dl_bwp_id][css->searchSpaceId - 1] = css; + if(pdcch_Config && + pdcch_Config->controlResourceSetToAddModList) { + struct NR_PDCCH_Config__controlResourceSetToAddModList *controlResourceSetToAddModList = pdcch_Config->controlResourceSetToAddModList; + for (int i = 0; i < controlResourceSetToAddModList->list.count; i++) { + AssertFatal(cset_configured < FAPI_NR_MAX_CORESET_PER_BWP, "Attempting to configure %d CORESET but only %d per BWP are allowed", + cset_configured + 1, FAPI_NR_MAX_CORESET_PER_BWP); + // In case network reconfigures control resource set with the same ControlResourceSetId as used for commonControlResourceSet + // configured via PDCCH-ConfigCommon, the configuration from PDCCH-Config always takes precedence + if (controlResourceSetToAddModList->list.array[i]->controlResourceSetId == common_cset_id) + mac->BWP_coresets[0] = controlResourceSetToAddModList->list.array[i]; + else { + mac->BWP_coresets[cset_configured] = controlResourceSetToAddModList->list.array[i]; + cset_configured++; + } + } } + for (int i = cset_configured; i < FAPI_NR_MAX_CORESET_PER_BWP; i++) + mac->BWP_coresets[i] = NULL; } // todo handle mac_LogicalChannelConfig @@ -602,7 +565,7 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, if (bwp_ulcommon->rach_ConfigCommon) UL_BWP->rach_ConfigCommon = bwp_ulcommon->rach_ConfigCommon->choice.setup; if (bwp_dlcommon->pdcch_ConfigCommon) - configure_common_ss(mac, bwp_dlcommon->pdcch_ConfigCommon->choice.setup); + configure_ss_coreset(mac, bwp_dlcommon->pdcch_ConfigCommon->choice.setup, NULL); } if(cell_group_config) { @@ -648,15 +611,19 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, 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; - if (bwp_downlink->bwp_Common->pdcch_ConfigCommon) - configure_common_ss(mac, bwp_downlink->bwp_Common->pdcch_ConfigCommon->choice.setup); + 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); + } else { dl_genericParameters = bwp_dlcommon->genericParameters; DL_BWP->pdsch_Config = spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup; DL_BWP->tdaList_Common = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - if (bwp_dlcommon->pdcch_ConfigCommon) - configure_common_ss(mac, bwp_dlcommon->pdcch_ConfigCommon->choice.setup); + configure_ss_coreset(mac, + bwp_dlcommon->pdcch_ConfigCommon ? bwp_dlcommon->pdcch_ConfigCommon->choice.setup : NULL, + spCellConfigDedicated->initialDownlinkBWP->pdcch_Config ? spCellConfigDedicated->initialDownlinkBWP->pdcch_Config->choice.setup : NULL); + } UL_BWP->msg3_DeltaPreamble = bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; @@ -783,7 +750,6 @@ void nr_rrc_mac_config_req_mcg(module_id_t module_id, mac->scheduling_info.retxBSR_SF); configure_current_BWP(mac, NULL, cell_group_config); - config_control_ue(mac); RA_config_t *ra = &mac->ra; if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) { @@ -845,7 +811,6 @@ void nr_rrc_mac_config_req_scg(module_id_t module_id, LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); } configure_current_BWP(mac, NULL, scell_group_config); - config_control_ue(mac); // 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_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index b9c0f9eab0..77a0fc8e58 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -409,11 +409,13 @@ typedef struct { NR_UE_UL_BWP_t current_UL_BWP; NR_UL_TIME_ALIGNMENT_t ul_time_alignment; - NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP]; - NR_SearchSpace_t *SSpace[MAX_NUM_BWP_UE][FAPI_NR_MAX_SS]; NR_SearchSpace_t *otherSI_SS; NR_SearchSpace_t *ra_SS; NR_SearchSpace_t *paging_SS; + NR_ControlResourceSet_t *BWP_coresets[FAPI_NR_MAX_CORESET_PER_BWP]; + NR_ControlResourceSet_t *coreset0; + NR_SearchSpace_t *BWP_searchspaces[FAPI_NR_MAX_SS]; + NR_SearchSpace_t *search_space_zero; bool phy_config_request_sent; frame_type_t frame_type; @@ -467,8 +469,6 @@ typedef struct { uint8_t PHR_reporting_active; NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config; - NR_SearchSpace_t *search_space_zero; - NR_ControlResourceSet_t *coreset0; frequency_range_t frequency_range; uint16_t nr_band; uint8_t ssb_subcarrier_offset; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 0f1d62ba34..bd1ef3574e 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -250,11 +250,10 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, NR_BSR_LONG *long_bsr); void config_dci_pdu(NR_UE_MAC_INST_t *mac, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int slot, - int ss_id); + NR_SearchSpace_t *ss); void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot); @@ -429,10 +428,6 @@ void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs); -void configure_ss_coreset(NR_UE_MAC_INST_t *mac, - NR_ServingCellConfig_t *scd, - NR_BWP_Id_t dl_bwp_id); - static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, nr_dci_format_t dci_format, uint8_t dci_size, 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 bc8b03d5e0..3a1d3eedae 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -83,12 +83,26 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss, } } +NR_ControlResourceSet_t *ue_get_coreset(NR_UE_MAC_INST_t *mac, int coreset_id) +{ + NR_ControlResourceSet_t *coreset = NULL; + for (int i = 0; i < FAPI_NR_MAX_CORESET_PER_BWP; i++) { + if (mac->BWP_coresets[i] != NULL && + mac->BWP_coresets[i]->controlResourceSetId == coreset_id) { + coreset = mac->BWP_coresets[i]; + break; + } + } + AssertFatal(coreset, "Couldn't find coreset with id %d\n", coreset_id); + return coreset; +} + + void config_dci_pdu(NR_UE_MAC_INST_t *mac, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int slot, - int ss_id) + NR_SearchSpace_t *ss) { uint16_t monitoringSymbolsWithinSlot = 0; @@ -98,33 +112,16 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; NR_BWP_Id_t dl_bwp_id = current_DL_BWP ? current_DL_BWP->bwp_id : 0; - NR_SearchSpace_t *ss; + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; + + int coreset_id = *ss->controlResourceSetId; NR_ControlResourceSet_t *coreset; - if(ss_id>=0) { - if (rnti_type == NR_RNTI_TC || rnti_type == NR_RNTI_RA) { - ss = mac->ra_SS; - AssertFatal(mac->ra_SS->searchSpaceId == ss_id, - "Search Space id %d does not correspond to the one in ra_ss %ld for RA procedures\n", - ss_id, mac->ra_SS->searchSpaceId); - } - else - ss = mac->SSpace[dl_bwp_id][ss_id-1]; - } - else - ss = mac->search_space_zero; - - uint8_t coreset_id = *ss->controlResourceSetId; - if(coreset_id > 0) { - coreset = mac->coreset[dl_bwp_id][coreset_id - 1]; + coreset = ue_get_coreset(mac, coreset_id); rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; } else { coreset = mac->coreset0; - if(rnti_type == NR_RNTI_SI) { - rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_MIB_SIB1; - } else { - rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG_CSET_0; - } + rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_MIB_SIB1; } rel15->coreset.duration = coreset->duration; @@ -293,9 +290,8 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) { RA_config_t *ra = &mac->ra; - int ss_id; - uint8_t bwp_id = mac->current_DL_BWP.bwp_id; + NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; NR_BWP_DownlinkDedicated_t *bwpd = bwp_id > 0 ? scd->downlinkBWP_ToAddModList->list.array[bwp_id - 1]->bwp_Dedicated: scd->initialDownlinkBWP; @@ -305,16 +301,14 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl // loop over all available SS for bwp_id if (bwpd) { - for (ss_id = 1; ss_id <= FAPI_NR_MAX_SS; ss_id++){ + for (int ss_id = 0; ss_id < FAPI_NR_MAX_SS; ss_id++){ - if(mac->SSpace[bwp_id][ss_id-1]==NULL) { + if(mac->BWP_searchspaces[ss_id]==NULL) { continue; } LOG_D(NR_MAC, "[DCI_CONFIG] ss_id %d\n",ss_id); - NR_SearchSpace_t *ss = mac->SSpace[bwp_id][ss_id-1]; - AssertFatal(ss_id == ss->searchSpaceId,"SS IDs don't correspond\n"); - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; + NR_SearchSpace_t *ss = mac->BWP_searchspaces[ss_id]; NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; struct NR_PhysicalCellGroupConfig *phy_cgc = mac->cg->physicalCellGroupConfig; switch (ss->searchSpaceType->present){ @@ -329,14 +323,14 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl case WAIT_RAR: LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg2)\n"); if (get_softmodem_params()->sa) { - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, slot, -1); + config_dci_pdu(mac, dl_config, NR_RNTI_RA, slot, mac->ra_SS); } else { - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, slot, ss_id); + config_dci_pdu(mac, dl_config, NR_RNTI_RA, slot, ss); } break; case WAIT_CONTENTION_RESOLUTION: LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg4)\n"); - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_TC, slot, -1); + config_dci_pdu(mac, dl_config, NR_RNTI_TC, slot, mac->ra_SS); break; default: break; @@ -404,7 +398,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl mac->crnti > 0) { // Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n"); - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, slot, ss_id); + config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, ss); //#ifdef DEBUG_DCI LOG_D(NR_MAC, "[DCI_CONFIG] ss %d ue_Specific %p searchSpaceType->present %d dci_Formats %d\n", diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 7b39a32408..7404b18e91 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -978,9 +978,8 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info) if (mac->ra.ra_state >= WAIT_RAR) { if(mac->ul_time_alignment.ta_apply) schedule_ta_command(dl_config, &mac->ul_time_alignment); - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - config_dci_pdu(mac, rel15, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , rx_slot, mac->ra_SS->searchSpaceId); - LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response rnti %x, type0_pdcch, num_pdus %d\n",mac->cg,rel15->rnti,dl_config->number_pdus); + config_dci_pdu(mac, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , rx_slot, mac->ra_SS); + LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response for type0_pdcch, num_pdus %d\n", mac->cg, dl_config->number_pdus); fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->phy_data); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) mac->if_module->scheduled_response(&scheduled_response); @@ -2622,18 +2621,18 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, frame_s = 0; // same frame as ssb slot_s = mac->type0_PDCCH_CSS_config.n_c; } - fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request[0]; // Take the first dl_config_request for SIB1 - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15; - - if(mac->search_space_zero == NULL) mac->search_space_zero=calloc(1,sizeof(*mac->search_space_zero)); - if(mac->coreset0 == NULL) mac->coreset0 = calloc(1,sizeof(*mac->coreset0)); + if(mac->search_space_zero == NULL) + mac->search_space_zero=calloc(1,sizeof(*mac->search_space_zero)); + if(mac->coreset0 == NULL) + mac->coreset0 = calloc(1,sizeof(*mac->coreset0)); fill_coresetZero(mac->coreset0, &mac->type0_PDCCH_CSS_config); fill_searchSpaceZero(mac->search_space_zero, &mac->type0_PDCCH_CSS_config); - rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, slot_s, -1); - LOG_D(MAC,"Calling fill_scheduled_response, type0_pdcch, num_pdus %d\n",dl_config->number_pdus); + fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request[0]; // Take the first dl_config_request for SIB1 + config_dci_pdu(mac, dl_config, NR_RNTI_SI, slot_s, mac->search_space_zero); + + LOG_D(MAC,"Calling fill_scheduled_response, type0_pdcch, num_pdus %d\n", dl_config->number_pdus); fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, module_idP, cc_id, frame_s, slot_s, phy_data); if (dl_config->number_pdus) { From 215392318d36c0ad862428dbbf6fbe5a0bc9ac4b Mon Sep 17 00:00:00 2001 From: francescomani Date: Sun, 21 May 2023 19:16:00 +0200 Subject: [PATCH 5/7] reworking dci configuration --- .../NR_MAC_UE/nr_ue_dci_configuration.c | 253 ++++++++---------- 1 file changed, 112 insertions(+), 141 deletions(-) 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 3a1d3eedae..24d1dbe199 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -287,150 +287,121 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, dl_config->number_pdus += 1; } -void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) { - RA_config_t *ra = &mac->ra; - uint8_t bwp_id = mac->current_DL_BWP.bwp_id; +void get_monitoring_period_offset(NR_SearchSpace_t *ss, int *period, int *offset) +{ + switch(ss->monitoringSlotPeriodicityAndOffset->present) { + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1: + *period = 1; + *offset = 0; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2: + *period = 2; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl2; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4: + *period = 4; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl4; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5: + *period = 5; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl5; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8: + *period = 8; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl8; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10: + *period = 10; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl10; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16: + *period = 16; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl16; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20: + *period = 20; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl20; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40: + *period = 40; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl40; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80: + *period = 80; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl80; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160: + *period = 160; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl160; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320: + *period = 320; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl320; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640: + *period = 640; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl640; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280: + *period = 1280; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl1280; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560: + *period = 2560; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl2560; + break; + default: + AssertFatal(1==0,"Invalid monitoring slot periodicity value\n"); + break; + } +} - NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; - NR_BWP_DownlinkDedicated_t *bwpd = bwp_id > 0 ? scd->downlinkBWP_ToAddModList->list.array[bwp_id - 1]->bwp_Dedicated: - scd->initialDownlinkBWP; - NR_BWP_DownlinkCommon_t *bwp_Common = get_bwp_downlink_common(mac, bwp_id); - - LOG_D(NR_MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti); - - // loop over all available SS for bwp_id - if (bwpd) { - for (int ss_id = 0; ss_id < FAPI_NR_MAX_SS; ss_id++){ - - if(mac->BWP_searchspaces[ss_id]==NULL) { - continue; - } - - LOG_D(NR_MAC, "[DCI_CONFIG] ss_id %d\n",ss_id); - NR_SearchSpace_t *ss = mac->BWP_searchspaces[ss_id]; - NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; - struct NR_PhysicalCellGroupConfig *phy_cgc = mac->cg->physicalCellGroupConfig; - switch (ss->searchSpaceType->present){ - case NR_SearchSpace__searchSpaceType_PR_common: - // this is for CSSs, we use BWP common and pdcch_ConfigCommon - - if (ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0){ - // check available SS IDs - if (pdcch_ConfigCommon->choice.setup->ra_SearchSpace){ - if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->ra_SearchSpace){ - switch(ra->ra_state){ - case WAIT_RAR: - LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg2)\n"); - if (get_softmodem_params()->sa) { - config_dci_pdu(mac, dl_config, NR_RNTI_RA, slot, mac->ra_SS); - } else { - config_dci_pdu(mac, dl_config, NR_RNTI_RA, slot, ss); - } - break; - case WAIT_CONTENTION_RESOLUTION: - LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg4)\n"); - config_dci_pdu(mac, dl_config, NR_RNTI_TC, slot, mac->ra_SS); - break; - default: - break; - } - } - } - if (pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){ - if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){ - // Configure monitoring of PDCCH candidates in Type0-PDCCH common search space on the MCG - //LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet..."); - } - } - if (pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation){ - if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation){ - // Configure monitoring of PDCCH candidates in Type0-PDCCH common search space on the MCG - //LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet..."); - } - } - if (pdcch_ConfigCommon->choice.setup->pagingSearchSpace){ - if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->pagingSearchSpace){ - // Configure monitoring of PDCCH candidates in Type2-PDCCH common search space on the MCG - //LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet..."); - } - } - if (phy_cgc){ - if (phy_cgc->cs_RNTI){ - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by CS-RNTI...\n"); - LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet...\n"); - } - if (phy_cgc->ext1){ - if (phy_cgc->ext1->mcs_C_RNTI){ - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by MCS-C-RNTI...\n"); - LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet...\n"); - } - } - } - } // end DCI 00 and 01 - // DCI 2_0 - if (ss->searchSpaceType->choice.common->dci_Format2_0){ - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_0 with CRC scrambled by SFI-RNTI \n"); - LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n"); - } - // DCI 2_1 - if (ss->searchSpaceType->choice.common->dci_Format2_1){ - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_1 with CRC scrambled by INT-RNTI \n"); - LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n"); - } - // DCI 2_2 - if (ss->searchSpaceType->choice.common->dci_Format2_2){ - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_2 with CRC scrambled by TPC-RNTI \n"); - LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n"); - } - // DCI 2_3 - if (ss->searchSpaceType->choice.common->dci_Format2_3){ - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_3 with CRC scrambled by TPC-SRS-RNTI \n"); - LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n"); - } - - break; - case NR_SearchSpace__searchSpaceType_PR_ue_Specific: - // this is an USS - if (ss->searchSpaceType->choice.ue_Specific && - ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1 && - mac->state == UE_CONNECTED && - mac->crnti > 0) { - // Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI - LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n"); - config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, ss); +bool is_ss_monitor_occasion(int frame, int slot, int slots_per_frame, NR_SearchSpace_t *ss) +{ + int duration = ss->duration ? *ss->duration : 1; + bool monitor = false; + int period, offset; + get_monitoring_period_offset(ss, &period, &offset); + // The UE monitors PDCCH candidates for search space set ss for 'duration' consecutive slots + for (int i = 0; i < duration; i++) { + if (((frame * slots_per_frame + slot - offset - i) % period) == 0) { + monitor = true; + break; + } + } + return monitor; +} -//#ifdef DEBUG_DCI - LOG_D(NR_MAC, "[DCI_CONFIG] ss %d ue_Specific %p searchSpaceType->present %d dci_Formats %d\n", - ss_id, - ss->searchSpaceType->choice.ue_Specific, - (int)ss->searchSpaceType->present, - (int)ss->searchSpaceType->choice.ue_Specific->dci_Formats); -//#endif - } - if (phy_cgc){ - if (phy_cgc->cs_RNTI){ - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by CS-RNTI...\n"); - LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet..."); - } - if (phy_cgc->sp_CSI_RNTI){ - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by SP-CSI-RNTI...\n"); - LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet..."); - } - if (phy_cgc->ext1 && - phy_cgc->ext1->mcs_C_RNTI){ - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by MCS-C-RNTI...\n"); - LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet..."); - } - } - break; - default: - AssertFatal(1 == 0, "[DCI_CONFIG] Unrecognized search space type..."); - break; - } // switch searchspace - } // for ss_id +void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) +{ + NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + int slots_per_frame = nr_slots_per_frame[current_DL_BWP->scs]; + if (mac->state == UE_PERFORMING_RA && + mac->ra.ra_state >= WAIT_RAR) { + // if RA is ongoing use RA search space + if (is_ss_monitor_occasion(frame, slot, slots_per_frame, mac->ra_SS)) { + int rnti_type = mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC; + config_dci_pdu(mac, dl_config, rnti_type, slot, mac->ra_SS); + } } - else { - LOG_E(MAC,"Cannot handle DCI without dedicated BWP\n"); + else if (mac->state == UE_CONNECTED) { + bool found = false; + for (int i = 0; i < FAPI_NR_MAX_SS; i++) { + if (mac->BWP_searchspaces[i] != NULL) { + found = true; + NR_SearchSpace_t *ss = mac->BWP_searchspaces[i]; + if (is_ss_monitor_occasion(frame, slot, slots_per_frame, ss)) + config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, ss); + } + } + if (!found && mac->ra_SS) { + // If the UE has not been provided a Type3-PDCCH CSS set or a USS set and + // the UE has received a C-RNTI and has been provided a Type1-PDCCH CSS set, + // the UE monitors PDCCH candidates for DCI format 0_0 and DCI format 1_0 + // with CRC scrambled by the C-RNTI in the Type1-PDCCH CSS set + if (is_ss_monitor_occasion(frame, slot, slots_per_frame, mac->ra_SS)) + config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, mac->ra_SS); + } } } From bc1b4d862e8dab9422ee7f3b341de7487ef87cae Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 29 May 2023 16:36:01 +0200 Subject: [PATCH 6/7] workaround to avoid L2 simulator to fail --- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 7404b18e91..07253e6ed9 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -979,6 +979,7 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info) if(mac->ul_time_alignment.ta_apply) schedule_ta_command(dl_config, &mac->ul_time_alignment); config_dci_pdu(mac, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , rx_slot, mac->ra_SS); + dl_config->number_pdus = 1; LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response for type0_pdcch, num_pdus %d\n", mac->cg, dl_config->number_pdus); fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->phy_data); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) From 227d21ee5cad45417d35fed6e0498898ab792750 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Tue, 30 May 2023 16:30:35 +0000 Subject: [PATCH 7/7] code review --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 10 +++---- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 8 ++--- .../NR_MAC_UE/nr_ue_dci_configuration.c | 30 +++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index b66600aa22..39408f150c 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -435,9 +435,9 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, } -NR_SearchSpace_t *get_common_search_space(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList, - NR_UE_MAC_INST_t *mac, - NR_SearchSpaceId_t ss_id) +NR_SearchSpace_t *get_common_search_space(const struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList, + const NR_UE_MAC_INST_t *mac, + const NR_SearchSpaceId_t ss_id) { if (ss_id == 0) return mac->search_space_zero; @@ -454,8 +454,8 @@ NR_SearchSpace_t *get_common_search_space(struct NR_PDCCH_ConfigCommon__commonSe } void configure_ss_coreset(NR_UE_MAC_INST_t *mac, - NR_PDCCH_ConfigCommon_t *pdcch_ConfigCommon, - NR_PDCCH_Config_t *pdcch_Config) + const NR_PDCCH_ConfigCommon_t *pdcch_ConfigCommon, + const NR_PDCCH_Config_t *pdcch_Config) { // configuration of search spaces diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index bd1ef3574e..253ad00d43 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -251,11 +251,11 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, - int rnti_type, - int slot, - NR_SearchSpace_t *ss); + const int rnti_type, + const int slot, + const NR_SearchSpace_t *ss); -void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot); +void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, const frame_t frame, const int slot); NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id); 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 24d1dbe199..a4a41839c3 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -49,9 +49,9 @@ //#define DEBUG_DCI -void fill_dci_search_candidates(NR_SearchSpace_t *ss, +void fill_dci_search_candidates(const NR_SearchSpace_t *ss, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, - uint32_t Y) + const uint32_t Y) { LOG_D(NR_MAC,"Filling search candidates for DCI\n"); @@ -83,7 +83,7 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss, } } -NR_ControlResourceSet_t *ue_get_coreset(NR_UE_MAC_INST_t *mac, int coreset_id) +NR_ControlResourceSet_t *ue_get_coreset(const NR_UE_MAC_INST_t *mac, const int coreset_id) { NR_ControlResourceSet_t *coreset = NULL; for (int i = 0; i < FAPI_NR_MAX_CORESET_PER_BWP; i++) { @@ -100,21 +100,21 @@ NR_ControlResourceSet_t *ue_get_coreset(NR_UE_MAC_INST_t *mac, int coreset_id) void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, - int rnti_type, - int slot, - NR_SearchSpace_t *ss) + const int rnti_type, + const int slot, + const NR_SearchSpace_t *ss) { uint16_t monitoringSymbolsWithinSlot = 0; int sps = 0; - NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + const NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + const NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; NR_BWP_Id_t dl_bwp_id = current_DL_BWP ? current_DL_BWP->bwp_id : 0; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - int coreset_id = *ss->controlResourceSetId; + const int coreset_id = *ss->controlResourceSetId; NR_ControlResourceSet_t *coreset; if(coreset_id > 0) { coreset = ue_get_coreset(mac, coreset_id); @@ -288,7 +288,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, } -void get_monitoring_period_offset(NR_SearchSpace_t *ss, int *period, int *offset) +void get_monitoring_period_offset(const NR_SearchSpace_t *ss, int *period, int *offset) { switch(ss->monitoringSlotPeriodicityAndOffset->present) { case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1: @@ -357,9 +357,9 @@ void get_monitoring_period_offset(NR_SearchSpace_t *ss, int *period, int *offset } } -bool is_ss_monitor_occasion(int frame, int slot, int slots_per_frame, NR_SearchSpace_t *ss) +bool is_ss_monitor_occasion(const int frame, const int slot, const int slots_per_frame, const NR_SearchSpace_t *ss) { - int duration = ss->duration ? *ss->duration : 1; + const int duration = ss->duration ? *ss->duration : 1; bool monitor = false; int period, offset; get_monitoring_period_offset(ss, &period, &offset); @@ -373,10 +373,10 @@ bool is_ss_monitor_occasion(int frame, int slot, int slots_per_frame, NR_SearchS return monitor; } -void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) +void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, const frame_t frame, const int slot) { - NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; - int slots_per_frame = nr_slots_per_frame[current_DL_BWP->scs]; + const NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + const int slots_per_frame = nr_slots_per_frame[current_DL_BWP->scs]; if (mac->state == UE_PERFORMING_RA && mac->ra.ra_state >= WAIT_RAR) { // if RA is ongoing use RA search space