From b6246f771719193e54141b9c263e418c48a6deda Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 21 Nov 2019 20:43:00 +0100 Subject: [PATCH] debugged DCI and PDSCH interfaces based on full RRC configuration Still need to update PDCCH configuration with NR FAPI specifications --- .../nfapi/public_inc/nfapi_nr_interface.h | 1 + .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 21 +-- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 132 +++++++++++++++--- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 6 +- 4 files changed, 133 insertions(+), 27 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h index 374da0e9c2..2b5886c86b 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -568,6 +568,7 @@ typedef struct { uint16_t rnti; uint8_t rnti_type; uint8_t dci_format; + uint16_t cce_index; /// Number of CRB in BWP that this DCI configures uint16_t n_RB_BWP; uint8_t config_type; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 1e9b3215a3..9002d57a22 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -336,9 +336,12 @@ int configure_fapi_dl_Tx(int Mod_idP, dlsch_pdu_rel15->TBSize[0]=0; dlsch_pdu_rel15->nrOfLayers =1; + nr_configure_dci_from_pdcch_config(params_rel15, - coreset, - search_space, + 1, // ue specific, + 4, + 0, + scc, bwp); pdu_rel15->frequency_domain_assignment = PRBalloc_to_locationandbandwidth0(dlsch_pdu_rel15->rbStart, dlsch_pdu_rel15->rbSize, cfg->rf_config.dl_carrier_bandwidth.value); @@ -357,21 +360,21 @@ int configure_fapi_dl_Tx(int Mod_idP, pdu_rel15->pucch_resource_indicator = 7; pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7; - LOG_D(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", + LOG_I(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", pdu_rel15->frequency_domain_assignment, pdu_rel15->time_domain_assignment, pdu_rel15->vrb_to_prb_mapping, pdu_rel15->mcs, pdu_rel15->tb_scaling, - pdu_rel15->ndi, + pdu_rel15->ndi, pdu_rel15->rv); - params_rel15->rnti = UE_list->rnti[UE_id]; - params_rel15->rnti_type = NFAPI_NR_RNTI_C; - params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; - + params_rel15->rnti = UE_list->rnti[UE_id]; + params_rel15->rnti_type = NFAPI_NR_RNTI_C; + params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; + //params_rel15->aggregation_level = 1; - LOG_D(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d, config type %d\n \ + LOG_I(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d, config type %d\n \ coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ ss params : first symb %d, ss type %d\n", params_rel15->rnti, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 722b21026e..bfe6ac98f8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -59,6 +59,8 @@ #include "NR_ControlResourceSet.h" #include "NR_SearchSpace.h" +#include "nfapi_nr_interface.h" + #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_gNB_SCHEDULER 1 @@ -348,8 +350,10 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p } void nr_configure_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params, - nfapi_nr_coreset_t* coreset, - nfapi_nr_search_space_t* search_space, + int ss_type, + int target_aggregation_level, + int cce_index, + NR_ServingCellConfigCommon_t *scc, NR_BWP_Downlink_t *bwp) { uint16_t N_RB=NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); @@ -358,10 +362,22 @@ void nr_configure_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel1 //ControlResourceSetId pdcch_params->config_type = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList!=NULL, + "controlResourceSetToAddModList is null\n"); + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count>0, + "controlResourceSetToAddModList is empty\n"); + NR_ControlResourceSet_t *coreset0 = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[0]; //frequencyDomainResources uint8_t count=0, start=0, start_set=0; - uint64_t bitmap = coreset->frequency_domain_resources; + // find coreset descriptor + + uint64_t bitmap = (((uint64_t)coreset0->frequencyDomainResources.buf[0])<<37)| + (((uint64_t)coreset0->frequencyDomainResources.buf[1])<<29)| + (((uint64_t)coreset0->frequencyDomainResources.buf[2])<<21)| + (((uint64_t)coreset0->frequencyDomainResources.buf[3])<<13)| + (((uint64_t)coreset0->frequencyDomainResources.buf[4])<<5)| + (((uint64_t)coreset0->frequencyDomainResources.buf[5])>>3); for (int i=0; i<45; i++) if ((bitmap>>(44-i))&1) { @@ -375,30 +391,40 @@ void nr_configure_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel1 pdcch_params->n_rb = 6*count; //duration - pdcch_params->n_symb = coreset->duration; + pdcch_params->n_symb = coreset0->duration; //cce-REG-MappingType - pdcch_params->cr_mapping_type = coreset->cce_reg_mapping_type; + pdcch_params->cr_mapping_type = coreset0->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved? + NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED : NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED; if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - pdcch_params->reg_bundle_size = coreset->reg_bundle_size; - pdcch_params->interleaver_size = coreset->interleaver_size; + pdcch_params->reg_bundle_size = (coreset0->cce_REG_MappingType.choice.interleaved->reg_BundleSize == NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) ? 6 : (2+coreset0->cce_REG_MappingType.choice.interleaved->reg_BundleSize); + pdcch_params->interleaver_size = (coreset0->cce_REG_MappingType.choice.interleaved->interleaverSize==NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) ? 6 : (2+coreset0->cce_REG_MappingType.choice.interleaved->interleaverSize); + AssertFatal(scc->physCellId != NULL,"scc->physCellId is null\n"); + pdcch_params->shift_index = coreset0->cce_REG_MappingType.choice.interleaved->shiftIndex != NULL ? *coreset0->cce_REG_MappingType.choice.interleaved->shiftIndex : *scc->physCellId; } else { pdcch_params->reg_bundle_size = 0; pdcch_params->interleaver_size = 0; + pdcch_params->shift_index = 0; } - //shift index - pdcch_params->shift_index = coreset->shift_index; - //precoderGranularity - pdcch_params->precoder_granularity = coreset->precoder_granularity; + pdcch_params->precoder_granularity = coreset0->precoderGranularity; //TCI states - // PDCCH params does not yet include information about TCI and QCL (needed for DCI 1.1 and 0.1) + // + /* + //TCI present + if (coreset0->tci_PresentInDCI != NULL) { + AssertFatal(coreset0->tci_StatesPDCCH_ToAddList != NULL,"tci_StatesPDCCH_ToAddList is null\n"); + AssertFatal(coreset0->tci_StatesPDCCH_ToAddList->list.count>0,"TCI state list is empty\n"); + for (int i=0;itci_StatesPDCCH_ToAddList->list.count;i++) { + + } + */ //pdcch-DMRS-ScramblingID - pdcch_params->scrambling_id = coreset->dmrs_scrambling_id; + pdcch_params->scrambling_id = coreset0->pdcch_DMRS_ScramblingID; /// SearchSpace @@ -407,16 +433,90 @@ void nr_configure_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel1 //AssertFatal(pdcch_scs==kHz15, "PDCCH SCS above 15kHz not allowed if a symbol above 2 is monitored"); int sps = bwp->bwp_Common->genericParameters.cyclicPrefix == NULL ? 14 : 12; + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n"); + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, + "searchPsacesToAddModList is empty\n"); + NR_SearchSpace_t *ss; + int found=0; + int target_ss = NR_SearchSpace__searchSpaceType_PR_common; + if (ss_type == 1) { + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + pdcch_params->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC; + } else pdcch_params->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_COMMON; + + for (int i=0;ibwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { + ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; + AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); + AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); + if (*ss->controlResourceSetId == coreset0->controlResourceSetId && + ss->searchSpaceType->present == target_ss) { + found=1; + break; + } + } + AssertFatal(found==1,"Couldn't find a searchspace corresponding to coreset0\n"); + AssertFatal(ss->monitoringSymbolsWithinSlot!=NULL,"ss->monitoringSymbolsWithinSlot is null\n"); + AssertFatal(ss->monitoringSymbolsWithinSlot->buf!=NULL,"ss->monitoringSymbolsWithinSlot->buf is null\n"); + + // for SPS=14 8 MSBs in positions 13 downto 6, + uint16_t monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | + (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); + for (int i=0; imonitoring_symbols_in_slot>>(sps-1-i))&1) { + if ((monitoringSymbolsWithinSlot>>(sps-1-i))&1) { pdcch_params->first_symbol=i; break; } - //searchSpaceType - pdcch_params->search_space_type = search_space->search_space_type; + // aggregation, find closest to target + AssertFatal(target_aggregation_level == 1 || target_aggregation_level == 2 || target_aggregation_level == 4 || target_aggregation_level == 8 || target_aggregation_level == 16,"illegal target aggregation level %d\n",target_aggregation_level); + AssertFatal(ss->nrofCandidates!=NULL,"ss->nrofCandidates is null\n"); + switch (target_aggregation_level) { + case 1: + if (ss->nrofCandidates->aggregationLevel1 > 0) pdcch_params->aggregation_level = 1; + else if (ss->nrofCandidates->aggregationLevel2 > 0) pdcch_params->aggregation_level = 2; + else if (ss->nrofCandidates->aggregationLevel4 > 0) pdcch_params->aggregation_level = 4; + else if (ss->nrofCandidates->aggregationLevel8 > 0) pdcch_params->aggregation_level = 8; + else if (ss->nrofCandidates->aggregationLevel16 > 0) pdcch_params->aggregation_level = 16; + else AssertFatal(1==0,"Couldn't find an aggregation level, shouldn't happen\n"); + break; + case 2: + if (ss->nrofCandidates->aggregationLevel2 > 0) pdcch_params->aggregation_level = 2; + else if (ss->nrofCandidates->aggregationLevel4 > 0) pdcch_params->aggregation_level = 4; + else if (ss->nrofCandidates->aggregationLevel1 > 0) pdcch_params->aggregation_level = 1; + else if (ss->nrofCandidates->aggregationLevel8 > 0) pdcch_params->aggregation_level = 8; + else if (ss->nrofCandidates->aggregationLevel16 > 0) pdcch_params->aggregation_level = 16; + else AssertFatal(1==0,"Couldn't find an aggregation level, shouldn't happen\n"); + break; + case 4: + if (ss->nrofCandidates->aggregationLevel4 > 0) pdcch_params->aggregation_level = 4; + else if (ss->nrofCandidates->aggregationLevel8 > 0) pdcch_params->aggregation_level = 8; + else if (ss->nrofCandidates->aggregationLevel2 > 0) pdcch_params->aggregation_level = 2; + else if (ss->nrofCandidates->aggregationLevel16 > 0) pdcch_params->aggregation_level = 16; + else if (ss->nrofCandidates->aggregationLevel1 > 0) pdcch_params->aggregation_level = 1; + else AssertFatal(1==0,"Couldn't find an aggregation level, shouldn't happen\n"); + break; + case 8: + if (ss->nrofCandidates->aggregationLevel8 > 0) pdcch_params->aggregation_level = 8; + else if (ss->nrofCandidates->aggregationLevel16 > 0) pdcch_params->aggregation_level = 16; + else if (ss->nrofCandidates->aggregationLevel4 > 0) pdcch_params->aggregation_level = 4; + else if (ss->nrofCandidates->aggregationLevel2 > 0) pdcch_params->aggregation_level = 2; + else if (ss->nrofCandidates->aggregationLevel1 > 0) pdcch_params->aggregation_level = 1; + else AssertFatal(1==0,"Couldn't find an aggregation level, shouldn't happen\n"); + break; + case 16: + if (ss->nrofCandidates->aggregationLevel16 > 0) pdcch_params->aggregation_level = 16; + else if (ss->nrofCandidates->aggregationLevel8 > 0) pdcch_params->aggregation_level = 8; + else if (ss->nrofCandidates->aggregationLevel4 > 0) pdcch_params->aggregation_level = 4; + else if (ss->nrofCandidates->aggregationLevel2 > 0) pdcch_params->aggregation_level = 2; + else if (ss->nrofCandidates->aggregationLevel1 > 0) pdcch_params->aggregation_level = 1; + else AssertFatal(1==0,"Couldn't find an aggregation level, shouldn't happen\n"); + break; + } + pdcch_params->n_RB_BWP = N_RB; + pdcch_params->cce_index = cce_index; } int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 076009c19d..eecc844241 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -96,8 +96,10 @@ int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space, nfapi_nr_config_request_t cfg); void nr_configure_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params, - nfapi_nr_coreset_t* coreset, - nfapi_nr_search_space_t* search_space, + int ss_type, + int target_aggregation_level, + int cce_index, + NR_ServingCellConfigCommon_t *scc, NR_BWP_Downlink_t *bwp); int get_dlscs(nfapi_nr_config_request_t *cfg);