From d820051397c829a15fb8589c7fb9352aed74e4c2 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 21 Feb 2022 17:46:02 +0000 Subject: [PATCH 001/105] Update config files --- .../CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf | 5 +++-- .../CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf | 4 +++- .../CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf | 4 +++- .../CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf | 7 +++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf index 2777035fdd..783e126972 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf @@ -35,9 +35,10 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; - min_rxtxtime = 6; + min_rxtxtime = 2; sib1_tda = 0; - do_SRS = 1; + do_CSIRS = 1; + do_SRS = 0; pdcch_ConfigSIB1 = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf index 27a1b6ad62..acdb28a47f 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf @@ -35,8 +35,10 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 2; + min_rxtxtime = 2; sib1_tda = 0; - do_SRS = 1; + do_CSIRS = 1; + do_SRS = 0; ul_prbblacklist = "51,52,53,54" pdcch_ConfigSIB1 = ( diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index f340d6116b..8e439e2897 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -35,8 +35,10 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; - min_rxtxtime = 6; + min_rxtxtime = 2; sib1_tda = 0; + do_CSIRS = 1; + do_SRS = 0; pdcch_ConfigSIB1 = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf index befceae695..c5ab7dfdd6 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf @@ -35,9 +35,12 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 2; -# do_CSIRS = 1; - min_rxtxtime_pdsch = 2; + min_rxtxtime = 2; + sib1_tda = 0; + do_CSIRS = 1; + do_SRS = 0; ul_prbblacklist = "79,80,81,82" + pdcch_ConfigSIB1 = ( { controlResourceSetZero = 11; From 777074ff7921b2e3dbf676ad2adffec81fe5112d Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 21 Feb 2022 20:23:27 +0000 Subject: [PATCH 002/105] Implementation of fill_default_csi_MeasConfig --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 326 ++++++++++++++++++++++++++++ openair2/RRC/NR/rrc_gNB_reconfig.c | 5 +- 2 files changed, 327 insertions(+), 4 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 7c8ecad91f..d0df9af4e2 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1004,6 +1004,322 @@ long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS) { return c_srs; } +// There are two types of signal which can used for CSI report: +// - SSB +// - CSI-RS. +// +// Two interference measurement methods for 5G NR are: +// - CSI-IM: +// Channel state information interference measurement; +// It can be used for measuring inter cell interference, in this case source cell does not transmit anything +// and measure interference from neighboring cells. +// - NZP CSI-RS: +// Non-zero-power channel state information reference signal; +// It can be used for measuring intra cell interference from other UEs of same cell. +// +// NZP-CSI-RS resource, ZP-CSI-RS resource, IM Resource: +// - These parameters define the location of physical resource element of the various CSI-RS. +// +// The RRC message information element for these resources is in: +// - PDSCH-Config: zp-CSI-RS-ResourceToAddModList -> ZP-CSI-RS-Resource -> CSI-RS-ResourceMapping +// - CSI-MeasConfig: nzp-CSI-RS-ResourceToAddModList -> NZP-CSI-RS-Resource -> CSI-RS-ResourceMapping +// csi-IM-ResourceToAddModList -> CSI-IM-Resource +// +// ResourceSet: Group where the individual resource belongs. The ResourceSet is configured in the following RRC. +// - nzp-CSI-RS-ResourceSetToAddModList->NZP-CSI-RS-ResourceSet->nzp-CSI-RS-Resources +// - csi-SSB-ResourceSetToAddModList -> CSI-SSB-ResourceSet -> SSB-Index + +void fill_default_csi_MeasConfig(int uid, + NR_CSI_MeasConfig_t *csi_MeasConfig, + NR_ServingCellConfigCommon_t *scc, + int dl_antenna_ports) { + + /// CSI-IM + if (dl_antenna_ports > 1) { + csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList)); + NR_CSI_IM_Resource_t *imres0 = calloc(1,sizeof(*imres0)); + imres0->csi_IM_ResourceId = 0; + imres0->csi_IM_ResourceElementPattern = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern)); + imres0->csi_IM_ResourceElementPattern->present = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern_PR_pattern1; + imres0->csi_IM_ResourceElementPattern->choice.pattern1 = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern->choice.pattern1)); + imres0->csi_IM_ResourceElementPattern->choice.pattern1->subcarrierLocation_p1 = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern__pattern1__subcarrierLocation_p1_s4; + imres0->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1 = 6; + imres0->freqBand = calloc(1,sizeof(*imres0->freqBand)); + imres0->freqBand->startingRB = 0; + imres0->freqBand->nrofRBs = 108; + imres0->periodicityAndOffset = calloc(1,sizeof(*imres0->periodicityAndOffset)); + imres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; + imres0->periodicityAndOffset->choice.slots320 = 0; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceToAddModList->list,imres0); + csi_MeasConfig->csi_IM_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceSetToAddModList)); + NR_CSI_IM_ResourceSet_t *imset0 = calloc(1,sizeof(*imset0)); + imset0->csi_IM_ResourceSetId = 0; + NR_CSI_IM_ResourceId_t *res0 = calloc(1,sizeof(*res0)); + *res0 = 0; + ASN_SEQUENCE_ADD(&imset0->csi_IM_Resources,res0); + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceSetToAddModList->list,imset0); + } else { + csi_MeasConfig->csi_IM_ResourceToAddModList = NULL; + csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL; + } + csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL; + csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL; + csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL; + + /// NZP CSI-RS + csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)); + NR_NZP_CSI_RS_ResourceSet_t *nzpcsirs0 = calloc(1,sizeof(*nzpcsirs0)); + nzpcsirs0->nzp_CSI_ResourceSetId = 0; + NR_NZP_CSI_RS_ResourceId_t *nzpid0 = calloc(1,sizeof(*nzpid0)); + *nzpid0 = 0; + ASN_SEQUENCE_ADD(&nzpcsirs0->nzp_CSI_RS_Resources,nzpid0); + nzpcsirs0->repetition = NULL; + nzpcsirs0->aperiodicTriggeringOffset = NULL; + nzpcsirs0->trs_Info = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpcsirs0); + csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL; + csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList)); + NR_NZP_CSI_RS_Resource_t *nzpcsi0 = calloc(1,sizeof(*nzpcsi0)); + nzpcsi0->nzp_CSI_RS_ResourceId = 0; + NR_CSI_RS_ResourceMapping_t resourceMapping; + switch (dl_antenna_ports) { + case 1: + resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2; + resourceMapping.frequencyDomainAllocation.choice.row2.buf = calloc(2, sizeof(uint8_t)); + resourceMapping.frequencyDomainAllocation.choice.row2.size = 2; + resourceMapping.frequencyDomainAllocation.choice.row2.bits_unused = 4; + resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]=0; + resourceMapping.frequencyDomainAllocation.choice.row2.buf[1]=16; + resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1; + resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM; + break; + case 2: + resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other; + resourceMapping.frequencyDomainAllocation.choice.row2.buf = calloc(2, sizeof(uint8_t)); + resourceMapping.frequencyDomainAllocation.choice.row2.size = 1; + resourceMapping.frequencyDomainAllocation.choice.row2.bits_unused = 2; + resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]=4; + resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p2; + resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_fd_CDM2; + break; + default: + AssertFatal(1==0,"Number of ports not yet supported\n"); + } + resourceMapping.firstOFDMSymbolInTimeDomain = 6; + resourceMapping.firstOFDMSymbolInTimeDomain2 = NULL; + resourceMapping.density.present = NR_CSI_RS_ResourceMapping__density_PR_one; + resourceMapping.density.choice.one = (NULL_t)0; + resourceMapping.freqBand.startingRB = 0; + resourceMapping.freqBand.nrofRBs = 108; + nzpcsi0->resourceMapping = resourceMapping; + nzpcsi0->powerControlOffset = 0; + nzpcsi0->powerControlOffsetSS=calloc(1,sizeof(*nzpcsi0->powerControlOffsetSS)); + *nzpcsi0->powerControlOffsetSS = NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0; + nzpcsi0->scramblingID = *scc->physCellId; + nzpcsi0->periodicityAndOffset = calloc(1,sizeof(*nzpcsi0->periodicityAndOffset)); + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; + nzpcsi0->periodicityAndOffset->choice.slots320 = 0; + nzpcsi0->qcl_InfoPeriodicCSI_RS = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpcsi0); + + /// SSB + csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); + csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; + NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); + ssbresset0->csi_SSB_ResourceSetId=0; + uint64_t bitmap=0; + switch (scc->ssb_PositionsInBurst->present) { + case 1 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; + break; + case 2 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; + break; + case 3 : + for (int i=0; i<8; i++) { + bitmap |= (((uint64_t) scc->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); + } + break; + default: + AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); + } + NR_SSB_Index_t *ssbresset[64]; + for (int i=0;i<64;i++) { + if ((bitmap>>(63-i))&0x01){ + ssbresset[i]=calloc(1,sizeof(*ssbresset[i])); + *ssbresset[i] = i; + ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset[i]); + } + } + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); + + // CSI ResourceConfig: specifies on what type of reference signal (nzp-CSI-RS-SSB, csi-IM-Resource) is to be transmitted. + // It also configures the types of the transmission (periodic, aperiodic, semipersistent). The Resource element and + // ResourceSet just defines the structure of the CSI resources. It is CSI ResourceConfig that triggers the transmission of the resources. + + csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); + csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; + NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); + csires0->csi_ResourceConfigId=0; + csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; + csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); + csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList)); + NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0)); + *nzp0 = 0; + ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); + csires0->bwp_Id = 1; + csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); + + NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); + csires1->csi_ResourceConfigId=1; + csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; + csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); + csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); + NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); + *ssbres00 = 0; + ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); + csires1->bwp_Id = 1; + csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); + + if (dl_antenna_ports > 1) { + NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); + csires2->csi_ResourceConfigId=2; + csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList; + csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList)); + NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00)); + *csiim00 = 0; + ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2); + } + + NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); + pucchcsires1->uplinkBandwidthPartId=1; + pucchcsires1->pucch_Resource=2; + + // ReportConfig: specifies which of CSI ResourceConfig to be used for the measurement. It has the mapping table + // between the measurement type and the corresponding CSI ResourceConfig. + + csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); + csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; + if (dl_antenna_ports > 1) { + NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); + csirep1->reportConfigId=0; + csirep1->carrier=NULL; + csirep1->resourcesForChannelMeasurement=0; + csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); + *csirep1->csi_IM_ResourcesForInterference=2; + csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; + + // reportConfigType: this parameter indicates the scheduling method of the report. It can be periodic, aperiodic and semiPersistent. + csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); + csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9 + (20 * uid) % 320; + ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + + // reportQuantity: this parameter indicates what to measure (CSI or L1-RSRP related quantities) + csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; + csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; + + // reportFreqConfiguration: this indicates the reporting granularity in frequency domain. It can be wideband or subband. + csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); + csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); + *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; + csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); + *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; + csirep1->reportFreqConfiguration->csi_ReportingBand = calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand)); + csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1); + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254; + + // timeRestrictionForChannelMeasurements: It indicates whether to put the restriction on channel measurement in time domain or not. + csirep1->timeRestrictionForChannelMeasurements = NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; + + // timeRestrictionForInterferenceMeasurements: It indicates whether to put the restriction on interference measurement in time domain or not. + csirep1->timeRestrictionForInterferenceMeasurements = NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; + + // codebookConfig: It configures the parameters for type 1 and type 2. + csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig)); + csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1; + csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); + csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= + calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; + + // dummy: This field is not used in the specification(38.331-v15.7). If received it shall be ignored by the UE. + csirep1->dummy = NULL; + + csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); + csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table)); + *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; + csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value2; + csirep1->non_PMI_PortIndication = NULL; + csirep1->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1); + } + + NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); + csirep2->reportConfigId=1; + csirep2->carrier=NULL; + csirep2->resourcesForChannelMeasurement=0; + csirep2->csi_IM_ResourcesForInterference=NULL; + csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; + + // reportConfigType: this parameter indicates the scheduling method of the report. It can be periodic, aperiodic and semiPersistent. + csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); + csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; + ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + + // reportQuantity: this parameter indicates what to measure (CSI or L1-RSRP related quantities) + csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; + csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; + + // reportFreqConfiguration: this indicates the reporting granularity in frequency domain. It can be wideband or subband. + csirep2->reportFreqConfiguration = NULL; + + // timeRestrictionForChannelMeasurements: It indicates whether to put the restriction on channel measurement in time domain or not. + csirep2->timeRestrictionForChannelMeasurements = NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; + + // timeRestrictionForInterferenceMeasurements: It indicates whether to put the restriction on interference measurement in time domain or not. + csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; + + // codebookConfig: It configures the parameters for type 1 and type 2. + csirep2->codebookConfig=NULL; + + // dummy: This field is not used in the specification(38.331-v15.7). If received it shall be ignored by the UE. + csirep2->dummy = NULL; + + csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); + csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep2->cqi_Table = NULL; + csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; + csirep2->non_PMI_PortIndication = NULL; + csirep2->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); +} + + void fill_initial_SpCellConfig(int uid, NR_SpCellConfig_t *SpCellConfig, NR_ServingCellConfigCommon_t *scc, @@ -1359,6 +1675,16 @@ void fill_initial_SpCellConfig(int uid, pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers)); *pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2; + if (carrier->do_CSIRS) { + SpCellConfig->spCellConfigDedicated->csi_MeasConfig = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup)); + fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, scc, carrier->pdsch_AntennaPorts); + } + + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_SpCellConfig, (const void*)SpCellConfig); + } } void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup) { diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 3a28409aea..f41bd26810 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -1285,10 +1285,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP; csirep2->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0; - csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); - csirep2->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; - csirep2->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; - csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; + csirep2->reportFreqConfiguration = NULL; csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; csirep2->codebookConfig= NULL; From 580f56c869ec38e30a558caa690375ec7b707584 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 10:08:39 +0000 Subject: [PATCH 003/105] Revert "Implementation of fill_default_csi_MeasConfig" This reverts commit 777074ff7921b2e3dbf676ad2adffec81fe5112d. --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 326 ---------------------------- openair2/RRC/NR/rrc_gNB_reconfig.c | 5 +- 2 files changed, 4 insertions(+), 327 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index d0df9af4e2..7c8ecad91f 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1004,322 +1004,6 @@ long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS) { return c_srs; } -// There are two types of signal which can used for CSI report: -// - SSB -// - CSI-RS. -// -// Two interference measurement methods for 5G NR are: -// - CSI-IM: -// Channel state information interference measurement; -// It can be used for measuring inter cell interference, in this case source cell does not transmit anything -// and measure interference from neighboring cells. -// - NZP CSI-RS: -// Non-zero-power channel state information reference signal; -// It can be used for measuring intra cell interference from other UEs of same cell. -// -// NZP-CSI-RS resource, ZP-CSI-RS resource, IM Resource: -// - These parameters define the location of physical resource element of the various CSI-RS. -// -// The RRC message information element for these resources is in: -// - PDSCH-Config: zp-CSI-RS-ResourceToAddModList -> ZP-CSI-RS-Resource -> CSI-RS-ResourceMapping -// - CSI-MeasConfig: nzp-CSI-RS-ResourceToAddModList -> NZP-CSI-RS-Resource -> CSI-RS-ResourceMapping -// csi-IM-ResourceToAddModList -> CSI-IM-Resource -// -// ResourceSet: Group where the individual resource belongs. The ResourceSet is configured in the following RRC. -// - nzp-CSI-RS-ResourceSetToAddModList->NZP-CSI-RS-ResourceSet->nzp-CSI-RS-Resources -// - csi-SSB-ResourceSetToAddModList -> CSI-SSB-ResourceSet -> SSB-Index - -void fill_default_csi_MeasConfig(int uid, - NR_CSI_MeasConfig_t *csi_MeasConfig, - NR_ServingCellConfigCommon_t *scc, - int dl_antenna_ports) { - - /// CSI-IM - if (dl_antenna_ports > 1) { - csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList)); - NR_CSI_IM_Resource_t *imres0 = calloc(1,sizeof(*imres0)); - imres0->csi_IM_ResourceId = 0; - imres0->csi_IM_ResourceElementPattern = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern)); - imres0->csi_IM_ResourceElementPattern->present = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern_PR_pattern1; - imres0->csi_IM_ResourceElementPattern->choice.pattern1 = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern->choice.pattern1)); - imres0->csi_IM_ResourceElementPattern->choice.pattern1->subcarrierLocation_p1 = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern__pattern1__subcarrierLocation_p1_s4; - imres0->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1 = 6; - imres0->freqBand = calloc(1,sizeof(*imres0->freqBand)); - imres0->freqBand->startingRB = 0; - imres0->freqBand->nrofRBs = 108; - imres0->periodicityAndOffset = calloc(1,sizeof(*imres0->periodicityAndOffset)); - imres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; - imres0->periodicityAndOffset->choice.slots320 = 0; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceToAddModList->list,imres0); - csi_MeasConfig->csi_IM_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceSetToAddModList)); - NR_CSI_IM_ResourceSet_t *imset0 = calloc(1,sizeof(*imset0)); - imset0->csi_IM_ResourceSetId = 0; - NR_CSI_IM_ResourceId_t *res0 = calloc(1,sizeof(*res0)); - *res0 = 0; - ASN_SEQUENCE_ADD(&imset0->csi_IM_Resources,res0); - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceSetToAddModList->list,imset0); - } else { - csi_MeasConfig->csi_IM_ResourceToAddModList = NULL; - csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL; - } - csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL; - csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL; - csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL; - - /// NZP CSI-RS - csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)); - NR_NZP_CSI_RS_ResourceSet_t *nzpcsirs0 = calloc(1,sizeof(*nzpcsirs0)); - nzpcsirs0->nzp_CSI_ResourceSetId = 0; - NR_NZP_CSI_RS_ResourceId_t *nzpid0 = calloc(1,sizeof(*nzpid0)); - *nzpid0 = 0; - ASN_SEQUENCE_ADD(&nzpcsirs0->nzp_CSI_RS_Resources,nzpid0); - nzpcsirs0->repetition = NULL; - nzpcsirs0->aperiodicTriggeringOffset = NULL; - nzpcsirs0->trs_Info = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpcsirs0); - csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL; - csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList)); - NR_NZP_CSI_RS_Resource_t *nzpcsi0 = calloc(1,sizeof(*nzpcsi0)); - nzpcsi0->nzp_CSI_RS_ResourceId = 0; - NR_CSI_RS_ResourceMapping_t resourceMapping; - switch (dl_antenna_ports) { - case 1: - resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2; - resourceMapping.frequencyDomainAllocation.choice.row2.buf = calloc(2, sizeof(uint8_t)); - resourceMapping.frequencyDomainAllocation.choice.row2.size = 2; - resourceMapping.frequencyDomainAllocation.choice.row2.bits_unused = 4; - resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]=0; - resourceMapping.frequencyDomainAllocation.choice.row2.buf[1]=16; - resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1; - resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM; - break; - case 2: - resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other; - resourceMapping.frequencyDomainAllocation.choice.row2.buf = calloc(2, sizeof(uint8_t)); - resourceMapping.frequencyDomainAllocation.choice.row2.size = 1; - resourceMapping.frequencyDomainAllocation.choice.row2.bits_unused = 2; - resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]=4; - resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p2; - resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_fd_CDM2; - break; - default: - AssertFatal(1==0,"Number of ports not yet supported\n"); - } - resourceMapping.firstOFDMSymbolInTimeDomain = 6; - resourceMapping.firstOFDMSymbolInTimeDomain2 = NULL; - resourceMapping.density.present = NR_CSI_RS_ResourceMapping__density_PR_one; - resourceMapping.density.choice.one = (NULL_t)0; - resourceMapping.freqBand.startingRB = 0; - resourceMapping.freqBand.nrofRBs = 108; - nzpcsi0->resourceMapping = resourceMapping; - nzpcsi0->powerControlOffset = 0; - nzpcsi0->powerControlOffsetSS=calloc(1,sizeof(*nzpcsi0->powerControlOffsetSS)); - *nzpcsi0->powerControlOffsetSS = NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0; - nzpcsi0->scramblingID = *scc->physCellId; - nzpcsi0->periodicityAndOffset = calloc(1,sizeof(*nzpcsi0->periodicityAndOffset)); - nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; - nzpcsi0->periodicityAndOffset->choice.slots320 = 0; - nzpcsi0->qcl_InfoPeriodicCSI_RS = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpcsi0); - - /// SSB - csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); - csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; - NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); - ssbresset0->csi_SSB_ResourceSetId=0; - uint64_t bitmap=0; - switch (scc->ssb_PositionsInBurst->present) { - case 1 : - bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; - break; - case 2 : - bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; - break; - case 3 : - for (int i=0; i<8; i++) { - bitmap |= (((uint64_t) scc->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); - } - break; - default: - AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); - } - NR_SSB_Index_t *ssbresset[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - ssbresset[i]=calloc(1,sizeof(*ssbresset[i])); - *ssbresset[i] = i; - ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset[i]); - } - } - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); - - // CSI ResourceConfig: specifies on what type of reference signal (nzp-CSI-RS-SSB, csi-IM-Resource) is to be transmitted. - // It also configures the types of the transmission (periodic, aperiodic, semipersistent). The Resource element and - // ResourceSet just defines the structure of the CSI resources. It is CSI ResourceConfig that triggers the transmission of the resources. - - csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); - csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; - NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); - csires0->csi_ResourceConfigId=0; - csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; - csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); - csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList)); - NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0)); - *nzp0 = 0; - ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); - csires0->bwp_Id = 1; - csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); - - NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); - csires1->csi_ResourceConfigId=1; - csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; - csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); - csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); - NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); - *ssbres00 = 0; - ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); - csires1->bwp_Id = 1; - csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); - - if (dl_antenna_ports > 1) { - NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); - csires2->csi_ResourceConfigId=2; - csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList; - csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList)); - NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00)); - *csiim00 = 0; - ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2); - } - - NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); - pucchcsires1->uplinkBandwidthPartId=1; - pucchcsires1->pucch_Resource=2; - - // ReportConfig: specifies which of CSI ResourceConfig to be used for the measurement. It has the mapping table - // between the measurement type and the corresponding CSI ResourceConfig. - - csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); - csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; - if (dl_antenna_ports > 1) { - NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); - csirep1->reportConfigId=0; - csirep1->carrier=NULL; - csirep1->resourcesForChannelMeasurement=0; - csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); - *csirep1->csi_IM_ResourcesForInterference=2; - csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; - - // reportConfigType: this parameter indicates the scheduling method of the report. It can be periodic, aperiodic and semiPersistent. - csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); - csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9 + (20 * uid) % 320; - ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - - // reportQuantity: this parameter indicates what to measure (CSI or L1-RSRP related quantities) - csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; - csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; - - // reportFreqConfiguration: this indicates the reporting granularity in frequency domain. It can be wideband or subband. - csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); - csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); - *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; - csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); - *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; - csirep1->reportFreqConfiguration->csi_ReportingBand = calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand)); - csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1); - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254; - - // timeRestrictionForChannelMeasurements: It indicates whether to put the restriction on channel measurement in time domain or not. - csirep1->timeRestrictionForChannelMeasurements = NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; - - // timeRestrictionForInterferenceMeasurements: It indicates whether to put the restriction on interference measurement in time domain or not. - csirep1->timeRestrictionForInterferenceMeasurements = NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; - - // codebookConfig: It configures the parameters for type 1 and type 2. - csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig)); - csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1; - csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); - csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= - calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; - csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; - - // dummy: This field is not used in the specification(38.331-v15.7). If received it shall be ignored by the UE. - csirep1->dummy = NULL; - - csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; - csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); - csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table)); - *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; - csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value2; - csirep1->non_PMI_PortIndication = NULL; - csirep1->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1); - } - - NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); - csirep2->reportConfigId=1; - csirep2->carrier=NULL; - csirep2->resourcesForChannelMeasurement=0; - csirep2->csi_IM_ResourcesForInterference=NULL; - csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; - - // reportConfigType: this parameter indicates the scheduling method of the report. It can be periodic, aperiodic and semiPersistent. - csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); - csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; - ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - - // reportQuantity: this parameter indicates what to measure (CSI or L1-RSRP related quantities) - csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; - csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; - - // reportFreqConfiguration: this indicates the reporting granularity in frequency domain. It can be wideband or subband. - csirep2->reportFreqConfiguration = NULL; - - // timeRestrictionForChannelMeasurements: It indicates whether to put the restriction on channel measurement in time domain or not. - csirep2->timeRestrictionForChannelMeasurements = NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; - - // timeRestrictionForInterferenceMeasurements: It indicates whether to put the restriction on interference measurement in time domain or not. - csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; - - // codebookConfig: It configures the parameters for type 1 and type 2. - csirep2->codebookConfig=NULL; - - // dummy: This field is not used in the specification(38.331-v15.7). If received it shall be ignored by the UE. - csirep2->dummy = NULL; - - csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; - csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); - csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); - *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; - csirep2->cqi_Table = NULL; - csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; - csirep2->non_PMI_PortIndication = NULL; - csirep2->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); -} - - void fill_initial_SpCellConfig(int uid, NR_SpCellConfig_t *SpCellConfig, NR_ServingCellConfigCommon_t *scc, @@ -1675,16 +1359,6 @@ void fill_initial_SpCellConfig(int uid, pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers)); *pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2; - if (carrier->do_CSIRS) { - SpCellConfig->spCellConfigDedicated->csi_MeasConfig = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); - SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; - SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup)); - fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, scc, carrier->pdsch_AntennaPorts); - } - - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_NR_SpCellConfig, (const void*)SpCellConfig); - } } void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup) { diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index f41bd26810..3a28409aea 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -1285,7 +1285,10 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP; csirep2->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0; - csirep2->reportFreqConfiguration = NULL; + csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); + csirep2->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; + csirep2->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; + csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; csirep2->codebookConfig= NULL; From 628726caae481303412f73219c523899bcd26c63 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 13:33:36 +0000 Subject: [PATCH 004/105] Fix build after merge --- cmake_targets/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index b7b365741c..a745f69647 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2038,6 +2038,7 @@ set(NR_L2_SRC_UE ${NR_UE_RRC_DIR}/main_ue.c ${NR_UE_RRC_DIR}/rrc_UE.c ${NR_UE_RRC_DIR}/rrc_nsa.c + ${NR_RRC_DIR}/nr_rrc_config.c ) set (MAC_SRC From cf284d76f090016f11a2284f66488a1367ab3e53 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 17:49:59 +0000 Subject: [PATCH 005/105] Fix build after merge --- common/utils/nr/nr_common.c | 1 - openair1/PHY/INIT/nr_init_ru.c | 7 +-- openair1/PHY/NR_TRANSPORT/nr_dlsch.c | 2 + openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c | 2 +- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 4 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 9 ++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 4 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 1 - .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 15 ++---- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 48 +++++++++---------- openair2/RRC/NR/MESSAGES/asn1_msg.c | 8 ++-- openair2/RRC/NR/nr_rrc_config.c | 3 +- openair2/RRC/NR/nr_rrc_defs.h | 8 ++-- openair2/RRC/NR/rrc_gNB.c | 1 - openair2/RRC/NR/rrc_gNB_reconfig.c | 4 +- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 3 +- 17 files changed, 56 insertions(+), 66 deletions(-) diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index b0a6266d34..f60760e115 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -482,7 +482,6 @@ int get_nr_table_idx(int nr_bandP, uint8_t scs_index) { return i; } - int get_subband_size(int NPRB,int size) { // implements table 5.2.1.4-2 from 36.214 // diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index d032746718..2b78c8f8c3 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -124,9 +124,10 @@ int nr_phy_init_RU(RU_t *ru) { ru->num_gNB,NUMBER_OF_gNB_MAX); LOG_I(PHY,"[INIT] %s() ru->num_gNB:%d \n", __FUNCTION__, ru->num_gNB); - if (ru->do_precoding == 1) { + + if (ru->do_precoding == 1) { int beam_count = 0; - if (ru->nb_tx>1) {//Enable beamforming when nb_tx > 1 + if (ru->nb_tx>1) { //Enable beamforming when nb_tx > 1 for (p=0;pnb_log_antennas;p++) { //if ((fp->L_ssb >> (63-p)) & 0x01)//64 bit-map with the MSB @2⁶³ corresponds to SSB ssb_index 0 @@ -149,7 +150,7 @@ int nr_phy_init_RU(RU_t *ru) { } // for j //} } // for p - } //for i + } // for i } ru->common.beam_id = (uint8_t**)malloc16_clear(ru->nb_tx*sizeof(uint8_t*)); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index 9ffbe90329..ecdc90fc7e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -211,6 +211,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, #endif stop_meas(&gNB->dlsch_layer_mapping_stats); + /// Resource mapping // Non interleaved VRB to PRB mapping @@ -228,6 +229,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, for (int nl=0; nlnrOfLayers; nl++) { int dmrs_port = get_dmrs_port(nl,rel15->dmrsPorts); + // DMRS params for this dmrs port get_Wt(Wt, dmrs_port, dmrs_Type); get_Wf(Wf, dmrs_port, dmrs_Type); diff --git a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c index 159f1172f8..256fb4f202 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c @@ -92,6 +92,6 @@ uint8_t get_l0(uint16_t dlDmrsSymbPos) { if ((mask&1) == 1) break; mask>>=1; } - AssertFatal(l0 < 4,"impossible l0 %d, dlDmrsSymbPos %x\n",l0,dlDmrsSymbPos); + AssertFatal(l0 < 4,"impossible l0 %d, dlDmrsSymbPos %x\n", l0, dlDmrsSymbPos); return (l0); } diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 5082084832..bd832d4174 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -1528,7 +1528,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, #ifdef DEBUG_NR_PUCCH_RX printf("cw_ML %d, metric %d dB\n",cw_ML,corr_dB); #endif - LOG_D(PHY,"slot %d PUCCH2 cw_ML %d, metric %d dB\n",slot,cw_ML,corr_dB); + LOG_D(PHY,"slot %d PUCCH2 cw_ML %d, metric %d dB\n", slot, cw_ML, corr_dB); decodedPayload[0]=(uint64_t)cw_ML; } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 17a6593998..809242f36f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -871,10 +871,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr (get_softmodem_params()->nsa) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position, dlsch_config_pdu_1_0->number_symbols, dlsch_config_pdu_1_0->start_symbol, - mappingtype, 1); + mappingtype, + 1); dlsch_config_pdu_1_0->dmrsConfigType = (mac->DLbwp[0] != NULL) ? (mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1) : 0; - /* number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214 version 15.9.0 Release 15 */ if (dlsch_config_pdu_1_0->number_symbols == 2) dlsch_config_pdu_1_0->n_dmrs_cdm_groups = 1; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index a20de3dd82..9d1078415c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -587,7 +587,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* check whether we need to switch the TDA allocation since the last * (re-)transmission */ if (ps->time_domain_allocation != tda) - nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, bwpd, tda, ps->nrOfLayers, sched_ctrl, ps); + nr_set_pdsch_semi_static(scc, cg, sched_ctrl->active_bwp, bwpd, tda, ps->nrOfLayers, sched_ctrl, ps); } else { /* the retransmission will use a different time domain allocation, check * that we have enough resources */ @@ -716,7 +716,7 @@ void pf_dl(module_id_t module_id, /* get the PID of a HARQ process awaiting retrnasmission, or -1 otherwise */ sched_pdsch->dl_harq_pid = sched_ctrl->retrans_dl_harq.head; - layers[UE_id] = ps->nrOfLayers; // initialization of layers to the previous value in the strcuture + layers[UE_id] = ps->nrOfLayers; // initialization of layers to the previous value in the structure /* Calculate Throughput */ const float a = 0.0005f; // corresponds to 200ms window @@ -744,6 +744,9 @@ void pf_dl(module_id_t module_id, set_dl_mcs(sched_pdsch,sched_ctrl,&mac->dl_max_mcs,ps->mcsTableIdx); sched_pdsch->mcs = get_mcs_from_bler(module_id, /* CC_id = */ 0, frame, slot, UE_id); layers[UE_id] = set_dl_nrOfLayers(sched_ctrl); + + // uint32_t tbs = pf_tbs[ps->mcsTableIdx][sched_pdsch->mcs]; // for nrOfLayers = 1 + const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); uint32_t tbs = nr_compute_tbs(Qm, @@ -754,6 +757,7 @@ void pf_dl(module_id_t module_id, 0 /* N_PRB_oh, 0 for initialBWP */, 0 /* tb_scaling */, layers[UE_id]) >> 3; + coeff_ue[UE_id] = (float) tbs / thr_ue[UE_id]; LOG_D(NR_MAC,"b %d, thr_ue[%d] %f, tbs %d, coeff_ue[%d] %f\n", b, UE_id, thr_ue[UE_id], tbs, UE_id, coeff_ue[UE_id]); @@ -856,7 +860,6 @@ void pf_dl(module_id_t module_id, AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - const long f = (sched_ctrl->active_bwp || bwpd) ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; if (ps->nrOfLayers != layers[UE_id] || ps->time_domain_allocation != tda) nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, bwpd, tda, layers[UE_id], sched_ctrl, ps); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 58620ce74a..162d108bb5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -279,12 +279,10 @@ void nr_preprocessor_phytest(module_id_t module_id, UE_id); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; - const long f = sched_ctrl->active_bwp ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = target_dl_Nl; if (ps->time_domain_allocation != tda) - nr_set_pdsch_semi_static( - scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, NULL, tda, f, ps); + nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, NULL, tda, ps->nrOfLayers, sched_ctrl, ps); /* find largest unallocated chunk */ const int bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 92942f8169..cb7a58c65a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2437,7 +2437,6 @@ void nr_csirs_scheduling(int Mod_idP, int period, offset; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - NR_BWP_Downlink_t *bwp=sched_ctrl->active_bwp; NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? &sched_ctrl->active_bwp->bwp_Common->genericParameters: &gNB_mac->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index f151402040..91eb7e2401 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -280,7 +280,6 @@ void compute_li_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, } } - void get_n1n2_o1o2_singlepanel(int *n1, int *n2, int *o1, int *o2, struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo *morethantwo) { @@ -547,7 +546,6 @@ void compute_cqi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, AssertFatal(1==0,"Sub-band CQI reporting not yet supported"); } - //!TODO : same function can be written to handle csi_resources void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_info, int UE_id, module_id_t Mod_idP){ uint8_t csi_report_id = 0; @@ -700,7 +698,7 @@ void nr_csi_meas_reporting(int Mod_idP, const NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; AssertFatal(csi_measconfig->csi_ReportConfigToAddModList->list.count > 0, "NO CSI report configuration available"); - NR_PUCCH_Config_t *pucch_Config; + NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; } else if (RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id] && @@ -712,7 +710,6 @@ void nr_csi_meas_reporting(int Mod_idP, pucch_Config = RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } - for (int csi_report_id = 0; csi_report_id < csi_measconfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ NR_CSI_ReportConfig_t *csirep = csi_measconfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; @@ -735,7 +732,7 @@ void nr_csi_meas_reporting(int Mod_idP, if (*pucchresset->resourceList.list.array[res_index] == pucchcsires->pucch_Resource) break; AssertFatal(res_index < n, - "CSI pucch resource %d not found among PUCCH resources\n",pucchcsires->pucch_Resource); + "CSI pucch resource %ld not found among PUCCH resources\n", pucchcsires->pucch_Resource); // find free PUCCH that is in order with possibly existing PUCCH // schedulings (other CSI, SR) @@ -924,13 +921,10 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { uint8_t idx = 0; NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - int bwp_id = sched_ctrl->active_bwp ? 1 : 0; + int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; - NR_BWP_Downlink_t *bwp = bwp_id>0 ? - sched_ctrl->active_bwp: - NULL; + NR_BWP_Downlink_t *bwp = bwp_id>0 ? sched_ctrl->active_bwp : NULL; - //bwp indicator int n_dl_bwp=0; if (CellGroup->spCellConfig->spCellConfigDedicated && @@ -942,7 +936,6 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { int better_rsrp_reported = -140-(-0); /*minimum_measured_RSRP_value - minimum_differntail_RSRP_value*///considering the minimum RSRP value as better RSRP initially uint8_t diff_rsrp_idx = 0; uint8_t i, j; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; if (n_dl_bwp < 4) pdsch_bwp_id = bwp_id; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 643e03f047..d03cc67e18 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1636,30 +1636,30 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) UE_info->mac_stats[UE_id].ulsch_current_bytes = sched_pusch->tb_size; sched_ctrl->last_ul_frame = sched_pusch->frame; sched_ctrl->last_ul_slot = sched_pusch->slot; - if (sched_pusch->rbSize > 5) - LOG_D(NR_MAC, - "ULSCH/PUSCH: %4d.%2d RNTI %04x UL sched %4d.%2d DCI L %d start %2d RBS %3d startSymbol %2d nb_symbol %2d dmrs_pos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d est %6d sched %6d est BSR %6d TPC %d\n", - frame, - slot, - rnti, - sched_pusch->frame, - sched_pusch->slot, - sched_ctrl->aggregation_level, - sched_pusch->rbStart, - sched_pusch->rbSize, - ps->startSymbolIndex, - ps->nrOfSymbols, - ps->ul_dmrs_symb_pos, - sched_pusch->mcs, - sched_pusch->tb_size, - harq_id, - cur_harq->round, - nr_rv_round_map[cur_harq->round], - cur_harq->ndi, - sched_ctrl->estimated_ul_buffer, - sched_ctrl->sched_ul_bytes, - sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, - sched_ctrl->tpc0); + + LOG_D(NR_MAC, + "ULSCH/PUSCH: %4d.%2d RNTI %04x UL sched %4d.%2d DCI L %d start %2d RBS %3d startSymbol %2d nb_symbol %2d dmrs_pos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d est %6d sched %6d est BSR %6d TPC %d\n", + frame, + slot, + rnti, + sched_pusch->frame, + sched_pusch->slot, + sched_ctrl->aggregation_level, + sched_pusch->rbStart, + sched_pusch->rbSize, + ps->startSymbolIndex, + ps->nrOfSymbols, + ps->ul_dmrs_symb_pos, + sched_pusch->mcs, + sched_pusch->tb_size, + harq_id, + cur_harq->round, + nr_rv_round_map[cur_harq->round], + cur_harq->ndi, + sched_ctrl->estimated_ul_buffer, + sched_ctrl->sched_ul_bytes, + sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, + sched_ctrl->tpc0); /* PUSCH in a later slot, but corresponding DCI now! */ diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index a0d3bc123e..f12ac03795 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -395,7 +395,6 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, initialDownlinkBWP->genericParameters= configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - for(int i = 0; i< configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count; i++) { asn1cSequenceAdd(ServCellCom->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list, struct NR_NR_MultiBandInfo, nrMultiBandInfo); @@ -510,7 +509,6 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss7->searchSpaceType->choice.common=calloc(1,sizeof(*ss7->searchSpaceType->choice.common)); ss7->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss7->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1, 0); asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation, 7); asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->pagingSearchSpace, 5); @@ -1301,8 +1299,8 @@ void fill_initial_SpCellConfig(int uid, // frequency domain resources depends on BWP size // options are 24, 48 or 96 coreset->frequencyDomainResources.buf = calloc(1,6); - int curr_bwp = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; if (0) { + int curr_bwp = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; if (curr_bwp < 48) coreset->frequencyDomainResources.buf[0] = 0xf0; else @@ -1455,7 +1453,7 @@ void fill_initial_SpCellConfig(int uid, csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL; - config_csirs(scc, csi_MeasConfig,carrier->pdsch_AntennaPorts,curr_bwp,carrier->do_CSIRS); + config_csirs(scc, csi_MeasConfig, uid, carrier->pdsch_AntennaPorts, curr_bwp, carrier->do_CSIRS); csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; @@ -1957,7 +1955,7 @@ int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, return -1; } - LOG_I(NR_RRC,"RRCSetup Encoded %zd bits (%zd bytes)\n", + LOG_D(NR_RRC,"RRCSetup Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index bea9afb739..520a6dc2ad 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -158,7 +158,8 @@ void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, *nzpcsi0->powerControlOffsetSS = NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0; nzpcsi0->scramblingID = *servingcellconfigcommon->physCellId; set_csirs_periodicity(nzpcsi0, uid, nb_slots_per_period); - nzpcsi0->qcl_InfoPeriodicCSI_RS = NULL; + nzpcsi0->qcl_InfoPeriodicCSI_RS = calloc(1,sizeof(*nzpcsi0->qcl_InfoPeriodicCSI_RS)); + *nzpcsi0->qcl_InfoPeriodicCSI_RS = 0; ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpcsi0); } else { diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 670eafc23a..f78d95effc 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -286,10 +286,10 @@ typedef struct gNB_RRC_UE_s { NR_DRB_ToReleaseList_t *DRB_Release_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; uint8_t DRB_active[8]; - NR_SRB_INFO SI; - NR_SRB_INFO Srb0; - NR_SRB_INFO_TABLE_ENTRY Srb1; - NR_SRB_INFO_TABLE_ENTRY Srb2; + NR_SRB_INFO SI; + NR_SRB_INFO Srb0; + NR_SRB_INFO_TABLE_ENTRY Srb1; + NR_SRB_INFO_TABLE_ENTRY Srb2; NR_MeasConfig_t *measConfig; HANDOVER_INFO *handover_info; NR_MeasResults_t *measResults; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 1fdaba690d..ead9184cb6 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3516,7 +3516,6 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { if (fd) fclose(fd); - /* send a tick to x2ap */ if (is_x2ap_enabled()){ msg = itti_alloc_new_message(TASK_RRC_ENB, 0, X2AP_SUBFRAME_PROCESS); diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 015ea9f65d..7451166358 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -562,9 +562,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco } bwp->bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; - if ((get_softmodem_params()->do_ra || - get_softmodem_params()->phy_test) && - dl_antenna_ports > 1) // for MIMO, we use DMRS Config Type 2 but only with OAI UE + if ((get_softmodem_params()->do_ra || get_softmodem_params()->phy_test) && dl_antenna_ports > 1) // for MIMO, we use DMRS Config Type 2 but only with OAI UE bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type)); else bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 5da5cd0b67..5794d9ac12 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -694,7 +694,6 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp ((int16x8_t *)buff[i])[j] = vshrq_n_s16(buff_tmp[i][j],rxshift); #endif } - } if (samples_received < nsamps) { LOG_E(HW,"[recv] received %d samples out of %d\n",samples_received,nsamps); @@ -1096,7 +1095,7 @@ extern "C" { if (device->type==USRP_X300_DEV) { openair0_cfg[0].rx_gain_calib_table = calib_table_x310; std::cerr << "-- Using calibration table: calib_table_x310" << std::endl; - // s->usrp->set_rx_dc_offset(true); + s->usrp->set_rx_dc_offset(true); } if (device->type==USRP_N300_DEV) { From bb82697819c30459e8e6053cc4be18d382ce89d7 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 19:14:17 +0000 Subject: [PATCH 006/105] Fix segmentation fault at UE in nr_schedule_csi_for_im and nr_schedule_csirs_reception --- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 44 ++++++++++++--------- openair2/RRC/NR_UE/rrc_UE.c | 6 --- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index a51dde9e75..1fc74bfaa5 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2357,20 +2357,25 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) { NR_CSI_IM_Resource_t *imcsi; int period, offset; NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - int mu = mac->DLbwp[dl_bwp_id-1] ? - mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing : - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.subcarrierSpacing; + + NR_BWP_t *genericParameters = NULL; + if(dl_bwp_id > 0 && mac->DLbwp[dl_bwp_id-1]) { + genericParameters = &mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters; + } else { + genericParameters = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + } + + int mu = genericParameters->subcarrierSpacing; + uint16_t bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + uint16_t bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); for (int id = 0; id < csi_measconfig->csi_IM_ResourceToAddModList->list.count; id++){ imcsi = csi_measconfig->csi_IM_ResourceToAddModList->list.array[id]; csi_period_offset(NULL,imcsi->periodicityAndOffset,&period,&offset); if((frame*nr_slots_per_frame[mu]+slot-offset)%period == 0) { fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].csiim_config_pdu.csiim_config_rel15; - const NR_BWP_Downlink_t *dlbwp = mac->DLbwp[dl_bwp_id-1]; - const int locationAndBandwidth = dlbwp != NULL ? dlbwp->bwp_Common->genericParameters.locationAndBandwidth: - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth; - csiim_config_pdu->bwp_size = NRRIV2BW(locationAndBandwidth, MAX_BWP_SIZE); - csiim_config_pdu->bwp_start = NRRIV2PRBOFFSET(locationAndBandwidth, MAX_BWP_SIZE); + csiim_config_pdu->bwp_size = bwp_size; + csiim_config_pdu->bwp_start = bwp_start; csiim_config_pdu->subcarrier_spacing = mu; csiim_config_pdu->start_rb = imcsi->freqBand->startingRB; csiim_config_pdu->nr_of_rbs = imcsi->freqBand->nrofRBs; @@ -2418,9 +2423,17 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { NR_NZP_CSI_RS_Resource_t *nzpcsi; int period, offset; NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - int mu = mac->DLbwp[dl_bwp_id-1] ? - mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing : - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.subcarrierSpacing; + + NR_BWP_t *genericParameters = NULL; + if(dl_bwp_id > 0 && mac->DLbwp[dl_bwp_id-1]) { + genericParameters = &mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters; + } else { + genericParameters = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + } + + int mu = genericParameters->subcarrierSpacing; + uint16_t bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + uint16_t bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); for (int id = 0; id < csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.count; id++){ nzpcsi = csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.array[id]; @@ -2428,14 +2441,9 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { if((frame*nr_slots_per_frame[mu]+slot-offset)%period == 0) { LOG_D(MAC,"Scheduling reception of CSI-RS in frame %d slot %d\n",frame,slot); fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].csirs_config_pdu.csirs_config_rel15; - NR_CSI_RS_ResourceMapping_t resourceMapping = nzpcsi->resourceMapping; - - const NR_BWP_Downlink_t *dlbwp = mac->DLbwp[dl_bwp_id-1]; - const int locationAndBandwidth = dlbwp != NULL ? dlbwp->bwp_Common->genericParameters.locationAndBandwidth: - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth; - csirs_config_pdu->bwp_size = NRRIV2BW(locationAndBandwidth, MAX_BWP_SIZE); - csirs_config_pdu->bwp_start = NRRIV2PRBOFFSET(locationAndBandwidth, MAX_BWP_SIZE); + csirs_config_pdu->bwp_size = bwp_size; + csirs_config_pdu->bwp_start = bwp_start; csirs_config_pdu->subcarrier_spacing = mu; csirs_config_pdu->start_rb = resourceMapping.freqBand.startingRB; csirs_config_pdu->nr_of_rbs = resourceMapping.freqBand.nrofRBs; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index f910ff68d4..fe3d7d51c4 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1360,12 +1360,6 @@ static void rrc_ue_generate_RRCSetupComplete( int nas_msg_length; NR_UE_MAC_INST_t *mac = get_mac_inst(0); - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig) - AssertFatal(1==0,"2 > csi_MeasConfig is not null\n"); - if (AMF_MODE_ENABLED) { #if defined(ITTI_SIM) as_nas_info_t initialNasMsg; From 0ced14a56d1e5a2eaeb4001d965e85066fb4c1e0 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 20:02:15 +0000 Subject: [PATCH 007/105] Fix in nr_set_pdsch_semi_static --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 1 - 1 file changed, 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index cb7a58c65a..5de596cdca 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -511,7 +511,6 @@ void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, NR_UE_sched_ctrl_t *sched_ctrl, NR_pdsch_semi_static_t *ps) { - ps->time_domain_allocation = tda; bool reset_dmrs = false; NR_BWP_DownlinkDedicated_t *bwpd; From ed6aa9f505e7ba65817acab7a58c12056ae27502 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 20:09:58 +0000 Subject: [PATCH 008/105] Replace AssertFatal with a LOG in nr_get_csi_payload at UE --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 3 ++- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 809242f36f..d15be1e547 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2428,7 +2428,8 @@ uint8_t nr_get_csi_payload(NR_UE_MAC_INST_t *mac, case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_i1_CQI: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_CQI: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_LI_PMI_CQI: - AssertFatal(1==0,"Measurement report based on CSI-RS not availalble\n"); + LOG_D(NR_MAC,"Measurement report based on CSI-RS not available\n"); + break; default: AssertFatal(1==0,"Invalid CSI report quantity type %d\n",csi_reportconfig->reportQuantity.present); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 5de596cdca..04167943a3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -513,8 +513,7 @@ void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, { bool reset_dmrs = false; - NR_BWP_DownlinkDedicated_t *bwpd; - + NR_BWP_DownlinkDedicated_t *bwpd = NULL; if (bwp && bwp->bwp_Dedicated) { bwpd = bwp->bwp_Dedicated; } else { From 4d1736414264dbe87bdd90b9ad83f37c9ff154ba Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 14:16:58 +0000 Subject: [PATCH 009/105] Fix build warnings --- openair2/RRC/NR/rrc_gNB.c | 21 +++++++++++++++++++++ openair2/RRC/NR_UE/rrc_UE.c | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index b992158aa3..6770c4ffe6 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -106,6 +106,27 @@ extern RAN_CONTEXT_t RC; +extern boolean_t nr_rrc_pdcp_config_asn1_req( + const protocol_ctxt_t *const ctxt_pP, + NR_SRB_ToAddModList_t *const srb2add_list, + NR_DRB_ToAddModList_t *const drb2add_list, + NR_DRB_ToReleaseList_t *const drb2release_list, + const uint8_t security_modeP, + uint8_t *const kRRCenc, + uint8_t *const kRRCint, + uint8_t *const kUPenc, + uint8_t *const kUPint, + LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9, + rb_id_t *const defaultDRB, + struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); + +extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP, + const NR_SRB_ToAddModList_t * const srb2add_listP, + const NR_DRB_ToAddModList_t * const drb2add_listP, + const NR_DRB_ToReleaseList_t * const drb2release_listP, + const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, + struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); + static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn); mui_t rrc_gNB_mui = 0; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 3e89693311..2bc4b45ead 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1358,7 +1358,6 @@ static void rrc_ue_generate_RRCSetupComplete( uint8_t size; const char *nas_msg; int nas_msg_length; - NR_UE_MAC_INST_t *mac = get_mac_inst(0); if (AMF_MODE_ENABLED) { #if defined(ITTI_SIM) From 3ae8f393f4e37a54f3287cc08b968149e5579ba3 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 15:05:02 +0000 Subject: [PATCH 010/105] Add logs in nr_generate_csi_rs --- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index 4f5baacc34..8e08edf60a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -33,6 +33,25 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, uint16_t cell_id, int slot){ +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "csi_params.bwp_size = %i\n", csi_params.bwp_size); + LOG_I(NR_PHY, "csi_params.bwp_start = %i\n", csi_params.bwp_start); + LOG_I(NR_PHY, "csi_params.subcarrier_spacing = %i\n", csi_params.subcarrier_spacing); + LOG_I(NR_PHY, "csi_params.cyclic_prefix = %i\n", csi_params.cyclic_prefix); + LOG_I(NR_PHY, "csi_params.start_rb = %i\n", csi_params.start_rb); + LOG_I(NR_PHY, "csi_params.nr_of_rbs = %i\n", csi_params.nr_of_rbs); + LOG_I(NR_PHY, "csi_params.csi_type = %i (0:TRS, 1:CSI-RS NZP, 2:CSI-RS ZP)\n", csi_params.csi_type); + LOG_I(NR_PHY, "csi_params.row = %i\n", csi_params.row); + LOG_I(NR_PHY, "csi_params.freq_domain = %i\n", csi_params.freq_domain); + LOG_I(NR_PHY, "csi_params.symb_l0 = %i\n", csi_params.symb_l0); + LOG_I(NR_PHY, "csi_params.symb_l1 = %i\n", csi_params.symb_l1); + LOG_I(NR_PHY, "csi_params.cdm_type = %i\n", csi_params.cdm_type); + LOG_I(NR_PHY, "csi_params.freq_density = %i (0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three)\n", csi_params.freq_density); + LOG_I(NR_PHY, "csi_params.scramb_id = %i\n", csi_params.scramb_id); + LOG_I(NR_PHY, "csi_params.power_control_offset = %i\n", csi_params.power_control_offset); + LOG_I(NR_PHY, "csi_params.power_control_offset_ss = %i\n", csi_params.power_control_offset_ss); +#endif + NR_DL_FRAME_PARMS frame_parms=gNB->frame_parms; int32_t **txdataF = gNB->common_vars.txdataF; int txdataF_offset = slot*frame_parms.samples_per_slot_wCP; From 5bae6dd6f3630e4205dc36e93b1b32d83b4f6e94 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 16:11:13 +0000 Subject: [PATCH 011/105] Add missing fiels in fapi_nr_dl_config_csirs_pdu_rel15_t --- nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h | 2 ++ openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 5 +++++ openair2/RRC/NR/MESSAGES/asn1_msg.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 284ef22fc4..d93072519b 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -489,6 +489,8 @@ typedef struct { uint8_t cdm_type; uint8_t freq_density;//The density field, p and comb offset (for dot5).0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three uint16_t scramb_id;//ScramblingID of the CSI-RS [TS38.214, sec 5.2.2.3.1] Value: 0->1023 + uint8_t power_control_offset;//Ratio of PDSCH EPRE to NZP CSI-RSEPRE Value :0->23 representing -8 to 15 dB in 1dB steps + uint8_t power_control_offset_ss;//Ratio of SSB/PBCH block EPRE to NZP CSI-RS EPRES 0: -3dB, 1: 0dB, 2: 3dB, 3: 6dB } fapi_nr_dl_config_csirs_pdu_rel15_t; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 1fc74bfaa5..d32aa7e22e 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2457,6 +2457,11 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { && (resourceMapping.density.choice.dot5 == NR_CSI_RS_ResourceMapping__density__dot5_evenPRBs)) csirs_config_pdu->freq_density--; csirs_config_pdu->scramb_id = nzpcsi->scramblingID; + csirs_config_pdu->power_control_offset = nzpcsi->powerControlOffset + 8; + if (nzpcsi->powerControlOffsetSS) + csirs_config_pdu->power_control_offset_ss = *nzpcsi->powerControlOffsetSS; + else + csirs_config_pdu->power_control_offset_ss = 1; // 0 dB switch(resourceMapping.frequencyDomainAllocation.present){ case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1: csirs_config_pdu->row = 1; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index f12ac03795..9c0cfe7bcd 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1510,7 +1510,7 @@ void fill_initial_SpCellConfig(int uid, csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); - *ssbres00 = 0; + *ssbres00 = 0; ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); csires1->bwp_Id = 0; csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; From fdce62f7995aae6dbc8ec91b881ae26c01d3d080 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 18:05:45 +0000 Subject: [PATCH 012/105] Add cyclic_prefix in csirs_config_pdu at UE --- 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 d32aa7e22e..09b38fbb62 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2445,6 +2445,7 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { csirs_config_pdu->bwp_size = bwp_size; csirs_config_pdu->bwp_start = bwp_start; csirs_config_pdu->subcarrier_spacing = mu; + csirs_config_pdu->cyclic_prefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0; csirs_config_pdu->start_rb = resourceMapping.freqBand.startingRB; csirs_config_pdu->nr_of_rbs = resourceMapping.freqBand.nrofRBs; csirs_config_pdu->csi_type = 1; // NZP-CSI-RS From 05a9c0e264d7f519c70e66bdad91cc9e21228a4a Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 18:12:36 +0000 Subject: [PATCH 013/105] Fix in nr_ue_scheduler for CSI --- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 74996f87e9..31003a1d05 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -43,7 +43,7 @@ extern PHY_VARS_NR_UE ***PHY_vars_UE_g; -const char *dl_pdu_type[]={"DCI", "DLSCH", "RA_DLSCH", "SI_DLSCH", "P_DLSCH"}; +const char *dl_pdu_type[]={"DCI", "DLSCH", "RA_DLSCH", "SI_DLSCH", "P_DLSCH", "CSI_RS", "CSI_IM"}; const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"}; queue_t nr_rx_ind_queue; queue_t nr_crc_ind_queue; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 09b38fbb62..29aae08351 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1047,9 +1047,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in if(mac->cg != NULL){ // we have a cg - nr_schedule_csirs_reception(mac, rx_frame, rx_slot); - nr_schedule_csi_for_im(mac, rx_frame, rx_slot); - dcireq.module_id = mod_id; dcireq.gNB_index = gNB_index; dcireq.cc_id = cc_id; @@ -1059,6 +1056,10 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in nr_ue_dcireq(&dcireq); //to be replaced with function pointer later mac->dl_config_request = dcireq.dl_config_req; + nr_schedule_csirs_reception(mac, rx_frame, rx_slot); + nr_schedule_csi_for_im(mac, rx_frame, rx_slot); + dcireq.dl_config_req = mac->dl_config_request; + fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) mac->if_module->scheduled_response(&scheduled_response); @@ -2397,7 +2398,7 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) { AssertFatal(1==0, "Invalid CSI-IM pattern\n"); } dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_CSI_IM; - dl_config->number_pdus = dl_config->number_pdus + 1; + dl_config->number_pdus += 1; } } } @@ -2543,7 +2544,7 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { AssertFatal(1==0,"Invalid freqency domain allocation in CSI-RS resource\n"); } dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_CSI_RS; - dl_config->number_pdus = dl_config->number_pdus + 1; + dl_config->number_pdus += 1; } } } From 853776ef2f46ee6669fab5ba3d424829cd3cc530 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 19:32:20 +0000 Subject: [PATCH 014/105] Implementation of FAPI procedures for CSI at UE --- openair1/PHY/INIT/nr_init_ue.c | 7 +++++++ openair1/PHY/defs_nr_UE.h | 12 ++++++++++++ openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index b09e8690f3..962da82282 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -128,6 +128,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, NR_UE_COMMON *const common_vars = &ue->common_vars; NR_UE_PBCH **const pbch_vars = ue->pbch_vars; NR_UE_PRACH **const prach_vars = ue->prach_vars; + NR_UE_CSI_IM **const csiim_vars = ue->csiim_vars; + NR_UE_CSI_RS **const csirs_vars = ue->csirs_vars; NR_UE_SRS **const srs_vars = ue->srs_vars; int i,j,k,l,slot,symb,q; @@ -311,9 +313,14 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, prach_vars[gNB_id] = (NR_UE_PRACH *)malloc16_clear(sizeof(NR_UE_PRACH)); pbch_vars[gNB_id] = (NR_UE_PBCH *)malloc16_clear(sizeof(NR_UE_PBCH)); + csiim_vars[gNB_id] = (NR_UE_CSI_IM *)malloc16_clear(sizeof(NR_UE_CSI_IM)); + csirs_vars[gNB_id] = (NR_UE_CSI_RS *)malloc16_clear(sizeof(NR_UE_CSI_RS)); srs_vars[gNB_id] = (NR_UE_SRS *)malloc16_clear(sizeof(NR_UE_SRS)); + csiim_vars[gNB_id]->active = false; + csirs_vars[gNB_id]->active = false; srs_vars[gNB_id]->active = false; + ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); ue->nr_srs_info->srs_generated_signal = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) ); ue->nr_srs_info->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 0fa839f104..1cd2a1c4ac 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -705,6 +705,16 @@ typedef struct { fapi_nr_ul_config_prach_pdu prach_pdu; } NR_UE_PRACH; +typedef struct { + bool active; + fapi_nr_dl_config_csiim_pdu_rel15_t csiim_config_pdu; +} NR_UE_CSI_IM; + +typedef struct { + bool active; + fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu; +} NR_UE_CSI_RS; + typedef struct { bool active; fapi_nr_ul_config_srs_pdu srs_config_pdu; @@ -819,6 +829,8 @@ typedef struct { NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_gNB_MAX]; + NR_UE_CSI_IM *csiim_vars[NUMBER_OF_CONNECTED_gNB_MAX]; + NR_UE_CSI_RS *csirs_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_SRS *srs_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PUSCH *pusch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PUCCH *pucch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 31003a1d05..766b53d9dd 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -278,11 +278,15 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ NR_UE_PDCCH *pdcch_vars = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0]; NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0][0]; NR_UE_PUCCH *pucch_vars = PHY_vars_UE_g[module_id][cc_id]->pucch_vars[thread_id][0]; + NR_UE_CSI_IM *csiim_vars = PHY_vars_UE_g[module_id][cc_id]->csiim_vars[0]; + NR_UE_CSI_RS *csirs_vars = PHY_vars_UE_g[module_id][cc_id]->csirs_vars[0]; if(scheduled_response->dl_config != NULL){ fapi_nr_dl_config_request_t *dl_config = scheduled_response->dl_config; fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu; fapi_nr_dl_config_dci_dl_pdu_rel15_t *pdcch_config; + fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu; + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu; pdcch_vars->nb_search_space = 0; for (int i = 0; i < dl_config->number_pdus; ++i){ @@ -302,9 +306,15 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ break; case FAPI_NR_DL_CONFIG_TYPE_CSI_IM: LOG_I(PHY,"Received CSI-IM PDU at FAPI\n"); + csiim_config_pdu = &dl_config->dl_config_list[i].csiim_config_pdu.csiim_config_rel15; + memcpy((void*)&(csiim_vars->csiim_config_pdu), (void*)csiim_config_pdu, sizeof(fapi_nr_dl_config_csiim_pdu_rel15_t)); + csirs_vars->active = true; break; case FAPI_NR_DL_CONFIG_TYPE_CSI_RS: LOG_I(PHY,"Received CSI-RS PDU at FAPI\n"); + csirs_config_pdu = &dl_config->dl_config_list[i].csirs_config_pdu.csirs_config_rel15; + memcpy((void*)&(csirs_vars->csirs_config_pdu), (void*)csirs_config_pdu, sizeof(fapi_nr_dl_config_csirs_pdu_rel15_t)); + csirs_vars->active = true; break; case FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH: dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; From 3eaebbca935d871dde073c94ef273e50a0b34143 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 20:23:34 +0000 Subject: [PATCH 015/105] CSI PDU received at PHY layer in new function nr_ue_csi_rs_procedures at UE --- cmake_targets/CMakeLists.txt | 1 + executables/main-ocp.c | 2 +- openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 75 +++++++++++++++++++++ openair1/SCHED_NR_UE/defs.h | 3 + openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 2 - openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 12 ++++ openair2/RRC/NR/MESSAGES/asn1_msg.c | 2 +- targets/RT/USER/lte-enb.c | 2 +- 9 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 openair1/PHY/NR_UE_TRANSPORT/csi_rx.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 1bd7591e58..40353813f0 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1759,6 +1759,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/dci_nr.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/dci_tools_nr.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/pucch_nr.c + ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/csi_rx.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_uci_tools_common.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/ul_ref_seq_nr.c diff --git a/executables/main-ocp.c b/executables/main-ocp.c index 04315a4d57..32e978043a 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -173,7 +173,7 @@ void init_transport(PHY_VARS_eNB *eNB) { } for (int i=0; iulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0)) != NULL, "Can't get eNB ulsch structures\n"); // this is the transmission mode for the signalling channels diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index e6b6c82834..2e5b96ea3c 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -573,7 +573,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { for (int i=0; inumber_of_nr_ulsch_max; i++) { - LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH %d/%d\n",i,gNB->number_of_nr_ulsch_max); + LOG_I(PHY,"Allocating Transport Channel Buffers for ULSCH %d/%d\n",i,gNB->number_of_nr_ulsch_max); for (int j=0; j<2; j++) { // ULSCH for data diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c new file mode 100644 index 0000000000..261672114b --- /dev/null +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -0,0 +1,75 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*********************************************************************** +* +* FILENAME : csi_rx.c +* +* MODULE : +* +* DESCRIPTION : function to receive the channel state information +* +************************************************************************/ + +#include +#include +#include + +#include "nr_transport_proto_ue.h" +#include "PHY/phy_extern_nr_ue.h" +#include "common/utils/nr/nr_common.h" + + +//#define NR_CSIRS_DEBUG + +int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { + return 0; +} + +int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { + + if(!ue->csirs_vars[gNB_id]->active) { + return -1; + } + + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = (fapi_nr_dl_config_csirs_pdu_rel15_t*)&ue->csirs_vars[gNB_id]->csirs_config_pdu; + +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "csirs_config_pdu->bwp_size = %i\n", csirs_config_pdu->bwp_size); + LOG_I(NR_PHY, "csirs_config_pdu->bwp_start = %i\n", csirs_config_pdu->bwp_start); + LOG_I(NR_PHY, "csirs_config_pdu->subcarrier_spacing = %i\n", csirs_config_pdu->subcarrier_spacing); + LOG_I(NR_PHY, "csirs_config_pdu->cyclic_prefix = %i\n", csirs_config_pdu->cyclic_prefix); + LOG_I(NR_PHY, "csirs_config_pdu->start_rb = %i\n", csirs_config_pdu->start_rb); + LOG_I(NR_PHY, "csirs_config_pdu->nr_of_rbs = %i\n", csirs_config_pdu->nr_of_rbs); + LOG_I(NR_PHY, "csirs_config_pdu->csi_type = %i (0:TRS, 1:CSI-RS NZP, 2:CSI-RS ZP)\n", csirs_config_pdu->csi_type); + LOG_I(NR_PHY, "csirs_config_pdu->row = %i\n", csirs_config_pdu->row); + LOG_I(NR_PHY, "csirs_config_pdu->freq_domain = %i\n", csirs_config_pdu->freq_domain); + LOG_I(NR_PHY, "csirs_config_pdu->symb_l0 = %i\n", csirs_config_pdu->symb_l0); + LOG_I(NR_PHY, "csirs_config_pdu->symb_l1 = %i\n", csirs_config_pdu->symb_l1); + LOG_I(NR_PHY, "csirs_config_pdu->cdm_type = %i\n", csirs_config_pdu->cdm_type); + LOG_I(NR_PHY, "csirs_config_pdu->freq_density = %i (0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three)\n", csirs_config_pdu->freq_density); + LOG_I(NR_PHY, "csirs_config_pdu->scramb_id = %i\n", csirs_config_pdu->scramb_id); + LOG_I(NR_PHY, "csirs_config_pdu->power_control_offset = %i\n", csirs_config_pdu->power_control_offset); + LOG_I(NR_PHY, "csirs_config_pdu->power_control_offset_ss = %i\n", csirs_config_pdu->power_control_offset_ss); +#endif + + return 0; +} diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index b85d4c1b50..1d7bbf4054 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -418,6 +418,9 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, UE_nr_rxtx_proc_t *proc, int n_ss); +int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); + +int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); #endif diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 766b53d9dd..924fd9fd51 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -305,13 +305,11 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ LOG_D(PHY,"Number of DCI SearchSpaces %d\n",pdcch_vars->nb_search_space); break; case FAPI_NR_DL_CONFIG_TYPE_CSI_IM: - LOG_I(PHY,"Received CSI-IM PDU at FAPI\n"); csiim_config_pdu = &dl_config->dl_config_list[i].csiim_config_pdu.csiim_config_rel15; memcpy((void*)&(csiim_vars->csiim_config_pdu), (void*)csiim_config_pdu, sizeof(fapi_nr_dl_config_csiim_pdu_rel15_t)); csirs_vars->active = true; break; case FAPI_NR_DL_CONFIG_TYPE_CSI_RS: - LOG_I(PHY,"Received CSI-RS PDU at FAPI\n"); csirs_config_pdu = &dl_config->dl_config_list[i].csirs_config_pdu.csirs_config_rel15; memcpy((void*)&(csirs_vars->csirs_config_pdu), (void*)csirs_config_pdu, sizeof(fapi_nr_dl_config_csirs_pdu_rel15_t)); csirs_vars->active = true; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index bb0c976cc3..b5f2341993 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1641,6 +1641,18 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, } + // do procedures for CSI-IM + if ((ue->csiim_vars[gNB_id]) && (ue->csiim_vars[gNB_id]->active == 1)) { + nr_ue_csi_im_procedures(ue, proc, gNB_id); + ue->csiim_vars[gNB_id]->active = 0; + } + + // do procedures for CSI-RS + if ((ue->csirs_vars[gNB_id]) && (ue->csirs_vars[gNB_id]->active == 1)) { + nr_ue_csi_rs_procedures(ue, proc, gNB_id); + ue->csirs_vars[gNB_id]->active = 0; + } + start_meas(&ue->generic_stat); if (nr_slot_rx==9) { diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 9c0cfe7bcd..5cb8a27da9 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1419,7 +1419,7 @@ void fill_initial_SpCellConfig(int uid, imres0->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1 = 6; imres0->freqBand = calloc(1,sizeof(*imres0->freqBand)); imres0->freqBand->startingRB = 0; - imres0->freqBand->nrofRBs = 108; + imres0->freqBand->nrofRBs = ((curr_bwp>>2)+(curr_bwp%4>0))<<2; imres0->periodicityAndOffset = calloc(1,sizeof(*imres0->periodicityAndOffset)); imres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; imres0->periodicityAndOffset->choice.slots320 = 0; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 0b6b0b3a75..dd6f74e6ea 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -1137,7 +1137,7 @@ void init_transport(PHY_VARS_eNB *eNB) { } for (int i=0;iulsch[i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0); if (!eNB->ulsch[i]) { From c272bb2f7cbe07caa14464e86e84a52a8cfcac80 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 2 Mar 2022 15:23:15 +0000 Subject: [PATCH 016/105] Generalization of the nr_generate_csi_rs function to be able to call it in gNB and UE --- cmake_targets/CMakeLists.txt | 4 ++-- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 21 +++++++++---------- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 4 +++- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 7ff30f077d..1fd0803b4b 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1584,9 +1584,10 @@ set(PHY_SRC_UE set(PHY_NR_SRC_COMMON ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_prach_common.c - ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c + ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_csi_rs.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_scrambling.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/scrambling_luts.c + ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c ) set(PHY_NR_SRC @@ -1610,7 +1611,6 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/ul_ref_seq_nr.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c - ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_csi_rs.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gen_mod_table.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/dmrs_nr.c diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index 8e08edf60a..3de697fdf3 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -27,8 +27,10 @@ //#define NR_CSIRS_DEBUG -void nr_generate_csi_rs(PHY_VARS_gNB *gNB, +void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, + int32_t **dataF, int16_t amp, + uint32_t **gold_csi_rs, nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params, uint16_t cell_id, int slot){ @@ -52,10 +54,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, LOG_I(NR_PHY, "csi_params.power_control_offset_ss = %i\n", csi_params.power_control_offset_ss); #endif - NR_DL_FRAME_PARMS frame_parms=gNB->frame_parms; - int32_t **txdataF = gNB->common_vars.txdataF; - int txdataF_offset = slot*frame_parms.samples_per_slot_wCP; - uint32_t **gold_csi_rs = gNB->nr_gold_csi_rs[slot]; + int dataF_offset = slot*frame_parms.samples_per_slot_wCP; int16_t mod_csi[frame_parms.symbols_per_slot][NR_MAX_CSI_RS_LENGTH>>1] __attribute__((aligned(16)));; uint16_t b = csi_params.freq_domain; uint16_t n, csi_bw, csi_start, p, k, l, mprime, na, kpn, csi_length; @@ -621,17 +620,17 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } // ZP CSI RS if (csi_params.csi_type == 2) { - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*txdataF_offset)] = 0; - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*txdataF_offset)] = 0; + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)] = 0; + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_offset)] = 0; } else { - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*txdataF_offset)] = (beta*wt*wf*mod_csi[l][mprime<<1]) >> 15; - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*txdataF_offset)] = (beta*wt*wf*mod_csi[l][(mprime<<1) + 1]) >> 15; + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)] = (beta*wt*wf*mod_csi[l][mprime<<1]) >> 15; + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_offset)] = (beta*wt*wf*mod_csi[l][(mprime<<1) + 1]) >> 15; } #ifdef NR_CSIRS_DEBUG printf("l,k (%d %d) seq. index %d \t port %d \t (%d,%d)\n",l,k,mprime,p+3000, - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*txdataF_offset)], - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*txdataF_offset)]); + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)], + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_offset)]); #endif } } diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index b62698c748..968744ef74 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -335,8 +335,10 @@ void init_prach_ru_list(RU_t *ru); void free_nr_ru_prach_entry(RU_t *ru, int prach_id); uint8_t get_nr_prach_duration(uint8_t prach_format); -void nr_generate_csi_rs(PHY_VARS_gNB *gNB, +void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, + int32_t **dataF, int16_t amp, + uint32_t **gold_csi_rs, nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params, uint16_t cell_id, int slot); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 41f395c090..09b70f5f22 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -180,7 +180,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, if (csirs->active == 1) { LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = csirs->csirs_pdu.csi_rs_pdu_rel15; - nr_generate_csi_rs(gNB, AMP, csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); + nr_generate_csi_rs(gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_gold_csi_rs[slot], csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); csirs->active = 0; } } From 6c27a40f0915cf63b7ef37318fc6d02ae555dfc2 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 2 Mar 2022 16:30:54 +0000 Subject: [PATCH 017/105] Creation of nr_csi_rs_info_t --- openair1/PHY/INIT/nr_init.c | 42 ++++++++++--------- openair1/PHY/NR_REFSIG/nr_gold.c | 9 +--- openair1/PHY/NR_REFSIG/nr_refsig.h | 2 +- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 13 +++--- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 2 +- openair1/PHY/defs_gNB.h | 6 +-- openair1/PHY/defs_nr_common.h | 6 +++ openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 8 files changed, 42 insertions(+), 40 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 6c0aaa1c42..c41af5fb22 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -177,23 +177,22 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, LOG_D(PHY,"Initializing PUSCH DMRS Gold sequence with (%x,%x)\n",Nid_pusch[0],Nid_pusch[1]); nr_gold_pusch(gNB, &Nid_pusch[0]); - //CSI RS init - gNB->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); - uint32_t ***csi_rs = gNB->nr_gold_csi_rs; - AssertFatal(csi_rs!=NULL, "NR init: csi reference signal malloc failed\n"); - - for (int slot=0; slotslots_per_frame; slot++) { - csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *)); - AssertFatal(csi_rs[slot]!=NULL, "NR init: csi reference signal for slot %d - malloc failed\n", slot); - - for (int symb=0; symbsymbols_per_slot; symb++) { - csi_rs[slot][symb] = (uint32_t *)malloc16(NR_MAX_CSI_RS_INIT_LENGTH_DWORD*sizeof(uint32_t)); - AssertFatal(csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); + // CSI RS init + for (int id=0; idnr_csi_rs_info[id] = (nr_csi_rs_info_t *)malloc16_clear(sizeof(nr_csi_rs_info_t)); + gNB->nr_csi_rs_info[id]->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); + AssertFatal(gNB->nr_csi_rs_info[id]->nr_gold_csi_rs!=NULL, "NR init: csi reference signal malloc failed\n"); + for (int slot=0; slotslots_per_frame; slot++) { + gNB->nr_csi_rs_info[id]->nr_gold_csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *)); + AssertFatal(gNB->nr_csi_rs_info[id]->nr_gold_csi_rs[slot]!=NULL, "NR init: csi reference signal for slot %d - malloc failed\n", slot); + for (int symb=0; symbsymbols_per_slot; symb++) { + gNB->nr_csi_rs_info[id]->nr_gold_csi_rs[slot][symb] = (uint32_t *)malloc16(NR_MAX_CSI_RS_INIT_LENGTH_DWORD*sizeof(uint32_t)); + AssertFatal(gNB->nr_csi_rs_info[id]->nr_gold_csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); + } } + nr_init_csi_rs(&gNB->frame_parms, gNB->nr_csi_rs_info[id]->nr_gold_csi_rs, cfg->cell_config.phy_cell_id.value); } - nr_init_csi_rs(gNB, cfg->cell_config.phy_cell_id.value); - for (int id=0; idnr_srs_info[id] = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); gNB->nr_srs_info[id]->srs_generated_signal = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); @@ -335,13 +334,16 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) } free_and_zero(pusch_dmrs); - uint32_t ***csi_rs = gNB->nr_gold_csi_rs; - for (int slot = 0; slot < fp->slots_per_frame; slot++) { - for (int symb = 0; symb < fp->symbols_per_slot; symb++) - free_and_zero(csi_rs[slot][symb]); - free_and_zero(csi_rs[slot]); + for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) { + uint32_t ***csi_rs = gNB->nr_csi_rs_info[id]->nr_gold_csi_rs; + for (int slot = 0; slot < fp->slots_per_frame; slot++) { + for (int symb = 0; symb < fp->symbols_per_slot; symb++) + free_and_zero(csi_rs[slot][symb]); + free_and_zero(csi_rs[slot]); + } + free_and_zero(csi_rs); + free_and_zero(gNB->nr_csi_rs_info[id]); } - free_and_zero(csi_rs); for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) { for (int i = 0; i < Prx; i++){ diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 7930839832..483f40973f 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -132,24 +132,17 @@ void nr_gold_pusch(PHY_VARS_gNB* gNB, uint32_t *Nid) { } -void nr_init_csi_rs(PHY_VARS_gNB* gNB, uint32_t Nid) -{ - NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; - uint32_t ***csi_rs = gNB->nr_gold_csi_rs; +void nr_init_csi_rs(NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Nid) { uint32_t x1, x2; uint8_t reset; - for (uint8_t slot=0; slotslots_per_frame; slot++) { for (uint8_t symb=0; symbsymbols_per_slot; symb++) { - reset = 1; x2 = ((1<<10) * (fp->symbols_per_slot*slot+symb+1) * ((Nid<<1)+1) + (Nid)); - for (uint32_t n=0; nnr_gold_csi_rs[slot]; int16_t mod_csi[frame_parms.symbols_per_slot][NR_MAX_CSI_RS_LENGTH>>1] __attribute__((aligned(16)));; uint16_t b = csi_params.freq_domain; uint16_t n, csi_bw, csi_start, p, k, l, mprime, na, kpn, csi_length; @@ -78,7 +79,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, reset = 1; x2 = ((1<<10) * (frame_parms.symbols_per_slot*slot+symb+1) * ((Nid<<1)+1) + (Nid)); for (uint32_t n=0; nactive == 1) { LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = csirs->csirs_pdu.csi_rs_pdu_rel15; - nr_generate_csi_rs(gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_gold_csi_rs[slot], csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); + nr_generate_csi_rs(gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info[i], csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); csirs->active = 0; } } From 35324cfa1259313aa83fc3b473318515bfb2d577 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 2 Mar 2022 18:30:02 +0000 Subject: [PATCH 018/105] Call nr_generate_csi_rs at UE side too --- openair1/PHY/INIT/nr_init_ue.c | 16 ++ openair1/PHY/NR_REFSIG/nr_gold.c | 16 -- openair1/PHY/NR_REFSIG/refsig_defs_ue.h | 2 + openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 143 ++++++++++-------- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 2 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 9 ++ .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 2 + openair1/PHY/defs_nr_UE.h | 3 + openair1/PHY/defs_nr_common.h | 1 + openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 10 files changed, 114 insertions(+), 82 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index ecc2395b1e..5d516c9248 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -353,6 +353,22 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) csirs_vars[gNB_id]->active = false; srs_vars[gNB_id]->active = false; + ue->nr_csi_rs_info = (nr_csi_rs_info_t *)malloc16_clear(sizeof(nr_csi_rs_info_t)); + ue->nr_csi_rs_info->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); + AssertFatal(ue->nr_csi_rs_info->nr_gold_csi_rs!=NULL, "NR init: csi reference signal malloc failed\n"); + for (int slot=0; slotslots_per_frame; slot++) { + ue->nr_csi_rs_info->nr_gold_csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *)); + AssertFatal(ue->nr_csi_rs_info->nr_gold_csi_rs[slot]!=NULL, "NR init: csi reference signal for slot %d - malloc failed\n", slot); + for (int symb=0; symbsymbols_per_slot; symb++) { + ue->nr_csi_rs_info->nr_gold_csi_rs[slot][symb] = (uint32_t *)malloc16(NR_MAX_CSI_RS_INIT_LENGTH_DWORD*sizeof(uint32_t)); + AssertFatal(ue->nr_csi_rs_info->nr_gold_csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); + } + } + ue->nr_csi_rs_info->csi_rs_received_signal = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + for (i=0; inb_antennas_rx; i++) { + ue->nr_csi_rs_info->csi_rs_received_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); + } + ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); ue->nr_srs_info->srs_generated_signal = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) ); ue->nr_srs_info->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 483f40973f..f059283440 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -130,19 +130,3 @@ void nr_gold_pusch(PHY_VARS_gNB* gNB, uint32_t *Nid) { } } } - - -void nr_init_csi_rs(NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Nid) { - uint32_t x1, x2; - uint8_t reset; - for (uint8_t slot=0; slotslots_per_frame; slot++) { - for (uint8_t symb=0; symbsymbols_per_slot; symb++) { - reset = 1; - x2 = ((1<<10) * (fp->symbols_per_slot*slot+symb+1) * ((Nid<<1)+1) + (Nid)); - for (uint32_t n=0; nslots_per_frame; slot++) { + for (uint8_t symb=0; symbsymbols_per_slot; symb++) { + reset = 1; + x2 = ((1<<10) * (fp->symbols_per_slot*slot+symb+1) * ((Nid<<1)+1) + (Nid)); + for (uint32_t n=0; nbwp_size = %i\n", csi_params->bwp_size); + LOG_I(NR_PHY, "csi_params->bwp_start = %i\n", csi_params->bwp_start); + LOG_I(NR_PHY, "csi_params->subcarrier_spacing = %i\n", csi_params->subcarrier_spacing); + LOG_I(NR_PHY, "csi_params->cyclic_prefix = %i\n", csi_params->cyclic_prefix); + LOG_I(NR_PHY, "csi_params->start_rb = %i\n", csi_params->start_rb); + LOG_I(NR_PHY, "csi_params->nr_of_rbs = %i\n", csi_params->nr_of_rbs); + LOG_I(NR_PHY, "csi_params->csi_type = %i (0:TRS, 1:CSI-RS NZP, 2:CSI-RS ZP)\n", csi_params->csi_type); + LOG_I(NR_PHY, "csi_params->row = %i\n", csi_params->row); + LOG_I(NR_PHY, "csi_params->freq_domain = %i\n", csi_params->freq_domain); + LOG_I(NR_PHY, "csi_params->symb_l0 = %i\n", csi_params->symb_l0); + LOG_I(NR_PHY, "csi_params->symb_l1 = %i\n", csi_params->symb_l1); + LOG_I(NR_PHY, "csi_params->cdm_type = %i\n", csi_params->cdm_type); + LOG_I(NR_PHY, "csi_params->freq_density = %i (0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three)\n", csi_params->freq_density); + LOG_I(NR_PHY, "csi_params->scramb_id = %i\n", csi_params->scramb_id); + LOG_I(NR_PHY, "csi_params->power_control_offset = %i\n", csi_params->power_control_offset); + LOG_I(NR_PHY, "csi_params->power_control_offset_ss = %i\n", csi_params->power_control_offset_ss); #endif int dataF_offset = slot*frame_parms.samples_per_slot_wCP; uint32_t **nr_gold_csi_rs = nr_csi_rs_info->nr_gold_csi_rs[slot]; int16_t mod_csi[frame_parms.symbols_per_slot][NR_MAX_CSI_RS_LENGTH>>1] __attribute__((aligned(16)));; - uint16_t b = csi_params.freq_domain; + uint16_t b = csi_params->freq_domain; uint16_t n, csi_bw, csi_start, p, k, l, mprime, na, kpn, csi_length; uint8_t size, ports, kprime, lprime, i, gs; uint8_t j[16], k_n[6], koverline[16], loverline[16]; @@ -71,10 +86,10 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, // pre-computed for scrambling id equel to cell id // if the scrambling id is not the cell id we need to re-initialize the rs - if (csi_params.scramb_id != cell_id) { + if (csi_params->scramb_id != cell_id) { uint8_t reset; uint32_t x1, x2; - uint32_t Nid = csi_params.scramb_id; + uint32_t Nid = csi_params->scramb_id; for (uint8_t symb=0; symbrow) { // implementation of table 7.4.1.5.3-1 of 38.211 // lprime and kprime are the max value of l' and k' case 1: @@ -103,7 +118,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[0] + (i<<2); } break; @@ -123,7 +138,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[0]; } break; @@ -143,7 +158,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[0]; } break; @@ -163,7 +178,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[0] + (i<<1); } break; @@ -183,7 +198,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0 + i; koverline[i] = k_n[0]; } break; @@ -202,7 +217,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -221,7 +236,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; i>1); + loverline[i] = csi_params->symb_l0 + (i>>1); koverline[i] = k_n[i%2]; } break; @@ -240,7 +255,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -259,7 +274,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -278,7 +293,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -297,7 +312,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; i>2); + loverline[i] = csi_params->symb_l0 + (i>>2); koverline[i] = k_n[i%4]; } break; @@ -316,7 +331,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -336,9 +351,9 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, for (i=0; isymb_l0 + i/3; else - loverline[i] = csi_params.symb_l1 + i/9; + loverline[i] = csi_params->symb_l1 + i/9; koverline[i] = k_n[i%3]; } break; @@ -358,9 +373,9 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, for (i=0; isymb_l0; else - loverline[i] = csi_params.symb_l1; + loverline[i] = csi_params->symb_l1; koverline[i] = k_n[i%3]; } break; @@ -379,7 +394,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -399,9 +414,9 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, for (i=0; i>2); + loverline[i] = csi_params->symb_l0 + (i>>2); else - loverline[i] = csi_params.symb_l1 + (i/12); + loverline[i] = csi_params->symb_l1 + (i/12); koverline[i] = k_n[i%4]; } break; @@ -421,9 +436,9 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, for (i=0; isymb_l0; else - loverline[i] = csi_params.symb_l1; + loverline[i] = csi_params->symb_l1; koverline[i] = k_n[i%4]; } break; @@ -442,17 +457,17 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; default: - AssertFatal(0==1, "Row %d is not valid for CSI Table 7.4.1.5.3-1\n", csi_params.row); + AssertFatal(0==1, "Row %d is not valid for CSI Table 7.4.1.5.3-1\n", csi_params->row); } #ifdef NR_CSIRS_DEBUG - printf(" row %d, n. of ports %d\n k' ",csi_params.row,ports); + printf(" row %d, n. of ports %d\n k' ",csi_params->row,ports); for (kp=0; kp<=kprime; kp++) printf("%d, ",kp); printf("l' "); @@ -469,7 +484,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, // setting the frequency density from its index - switch (csi_params.freq_density) { + switch (csi_params->freq_density) { case 0: rho = 0.5; @@ -501,7 +516,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, #endif // CDM group size from CDM type index - switch (csi_params.cdm_type) { + switch (csi_params->cdm_type) { case 0: gs = 1; @@ -524,17 +539,17 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } // according to 38.214 5.2.2.3.1 last paragraph - if (csi_params.start_rbstart_rbbwp_start) + csi_start = csi_params->bwp_start; else - csi_start = csi_params.start_rb; - if (csi_params.nr_of_rbs > (csi_params.bwp_start+csi_params.bwp_size-csi_start)) - csi_bw = csi_params.bwp_start+csi_params.bwp_size-csi_start; + csi_start = csi_params->start_rb; + if (csi_params->nr_of_rbs > (csi_params->bwp_start+csi_params->bwp_size-csi_start)) + csi_bw = csi_params->bwp_start+csi_params->bwp_size-csi_start; else - csi_bw = csi_params.nr_of_rbs; + csi_bw = csi_params->nr_of_rbs; if (rho < 1) { - if (csi_params.freq_density == 0) + if (csi_params->freq_density == 0) csi_length = (((csi_bw + csi_start)>>1)<>1)<csi_type == 0) { // ??? } // NZP CSI RS - if (csi_params.csi_type == 1) { + if (csi_params->csi_type == 1) { // assuming amp is the amplitude of SSB channels - switch (csi_params.power_control_offset_ss) { + switch (csi_params->power_control_offset_ss) { case 0: beta = (amp*ONE_OVER_SQRT2_Q15)>>15; break; @@ -573,14 +588,14 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } for (lp=0; lp<=lprime; lp++){ - symb = csi_params.symb_l0; + symb = csi_params->symb_l0; nr_modulation(nr_gold_csi_rs[symb+lp], csi_length, DMRS_MOD_ORDER, mod_csi[symb+lp]); - if ((csi_params.row == 5) || (csi_params.row == 7) || (csi_params.row == 11) || (csi_params.row == 13) || (csi_params.row == 16)) + if ((csi_params->row == 5) || (csi_params->row == 7) || (csi_params->row == 11) || (csi_params->row == 13) || (csi_params->row == 16)) nr_modulation(nr_gold_csi_rs[symb+1], csi_length, DMRS_MOD_ORDER, mod_csi[symb+1]); - if ((csi_params.row == 14) || (csi_params.row == 13) || (csi_params.row == 16) || (csi_params.row == 17)) { - symb = csi_params.symb_l1; + if ((csi_params->row == 14) || (csi_params->row == 13) || (csi_params->row == 16) || (csi_params->row == 17)) { + symb = csi_params->symb_l1; nr_modulation(nr_gold_csi_rs[symb+lp], csi_length, DMRS_MOD_ORDER, mod_csi[symb+lp]); - if ((csi_params.row == 13) || (csi_params.row == 16)) + if ((csi_params->row == 13) || (csi_params->row == 16)) nr_modulation(nr_gold_csi_rs[symb+1], csi_length, DMRS_MOD_ORDER, mod_csi[symb+1]); } } @@ -590,7 +605,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, // resource mapping according to 38.211 7.4.1.5.3 for (n=csi_start; n<(csi_start+csi_bw); n++) { - if ( (csi_params.freq_density > 1) || (csi_params.freq_density == (n%2))) { // for freq density 0.5 checks if even or odd RB + if ( (csi_params->freq_density > 1) || (csi_params->freq_density == (n%2))) { // for freq density 0.5 checks if even or odd RB for (int ji=0; jicsi_type == 2) { ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)] = 0; ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_offset)] = 0; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index aa84ba5e01..19e87604f2 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -339,7 +339,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, int32_t **dataF, int16_t amp, nr_csi_rs_info_t *nr_csi_rs_info, - nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params, + nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, uint16_t cell_id, int slot); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 261672114b..d8d01724c1 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -36,6 +36,7 @@ #include "nr_transport_proto_ue.h" #include "PHY/phy_extern_nr_ue.h" #include "common/utils/nr/nr_common.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" //#define NR_CSIRS_DEBUG @@ -71,5 +72,13 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t LOG_I(NR_PHY, "csirs_config_pdu->power_control_offset_ss = %i\n", csirs_config_pdu->power_control_offset_ss); #endif + nr_generate_csi_rs(ue->frame_parms, + ue->nr_csi_rs_info->csi_rs_received_signal, + AMP, + ue->nr_csi_rs_info, + (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *) csirs_config_pdu, + ue->frame_parms.first_carrier_offset, + proc->nr_slot_rx); + return 0; } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index d7b1a030c9..080b12af86 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -348,6 +348,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, nr_gold_pdsch(ue,ue->scramblingID); + nr_init_csi_rs(fp, ue->nr_csi_rs_info->nr_gold_csi_rs, fp->Nid_cell); + // initialize the pusch dmrs uint16_t N_n_scid[2] = {fp->Nid_cell,fp->Nid_cell}; int n_scid = 0; // This quantity is indicated by higher layer parameter dmrs-SeqInitialization diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 8d08d99162..9d95227215 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -986,6 +986,9 @@ typedef struct { /// SRS variables nr_srs_info_t *nr_srs_info; + /// CSI-RS variables + nr_csi_rs_info_t *nr_csi_rs_info; + //#if defined(UPGRADE_RAT_NR) #if 1 SystemInformationBlockType1_nr_t systemInformationBlockType1_nr; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index ba0b9a7984..0f3842824d 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -268,6 +268,7 @@ typedef struct { uint32_t ***nr_gold_csi_rs; uint16_t sc_list_length; uint16_t sc_list[6 * NR_MAX_NB_RB]; + int32_t **csi_rs_received_signal; } nr_csi_rs_info_t; typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 0b6c072da6..3cba346071 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -179,7 +179,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, NR_gNB_CSIRS_t *csirs = &msgTx->csirs_pdu[i]; if (csirs->active == 1) { LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); - nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = csirs->csirs_pdu.csi_rs_pdu_rel15; + nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params = &csirs->csirs_pdu.csi_rs_pdu_rel15; nr_generate_csi_rs(gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info[i], csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); csirs->active = 0; } From de8aa24de5474360f44b721e619821c6546b5e41 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Sat, 5 Mar 2022 01:37:38 +0000 Subject: [PATCH 019/105] Get CSI-RS symbols from received signal at UE --- openair1/PHY/INIT/nr_init_ue.c | 6 ++- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 5 +++ openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 41 +++++++++++++++++- openair1/PHY/defs_nr_common.h | 5 ++- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 46 +++++++++++++++++++++ 5 files changed, 98 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 5d516c9248..04c4b5a7ca 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -364,9 +364,11 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) AssertFatal(ue->nr_csi_rs_info->nr_gold_csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); } } - ue->nr_csi_rs_info->csi_rs_received_signal = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + ue->nr_csi_rs_info->csi_rs_generated_signal = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); + ue->nr_csi_rs_info->csi_rs_received_signal = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); for (i=0; inb_antennas_rx; i++) { - ue->nr_csi_rs_info->csi_rs_received_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_generated_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_received_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); } ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index b840fcea99..505494783e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -601,6 +601,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } } + bzero(nr_csi_rs_info->k_list_length,NR_SYMBOLS_PER_SLOT*sizeof(uint16_t)); uint16_t start_sc = frame_parms.first_carrier_offset; // resource mapping according to 38.211 7.4.1.5.3 @@ -634,6 +635,10 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, else wt = -1; } + + nr_csi_rs_info->map_list[l][nr_csi_rs_info->k_list_length[l]] = k; + nr_csi_rs_info->k_list_length[l]++; + // ZP CSI RS if (csi_params->csi_type == 2) { ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)] = 0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index d8d01724c1..0e96c556a2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -41,6 +41,43 @@ //#define NR_CSIRS_DEBUG +int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + nr_csi_rs_info_t *nr_csi_rs_info, + int32_t **csi_rs_received_signal) { + + int32_t **rxdataF = ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; + NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + + for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { + memset(csi_rs_received_signal[ant], 0, frame_parms->samples_per_frame_wCP*sizeof(int32_t)); + for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *rx_signal = (int16_t*)&rxdataF[ant][symbol_offset]; + int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant][symbol_offset]; + for(int k_id = 0; k_idk_list_length[symb]; k_id++) { + uint16_t k = nr_csi_rs_info->map_list[symb][k_id]; + rx_csi_rs_signal[k<<1] = rx_signal[k<<1]; + rx_csi_rs_signal[(k<<1)+1] = rx_signal[(k<<1)+1]; + +#ifdef NR_CSIRS_DEBUG + int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; + int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[ant][symbol_offset+dataF_offset]; + LOG_I(NR_PHY, "l,k (%d %d) \t tx (%d,%d) \t rx (%d,%d)\n", + symb, + nr_csi_rs_info->map_list[symb][k_id], + tx_csi_rs_signal[k<<1], + tx_csi_rs_signal[(k<<1)+1], + rx_csi_rs_signal[k<<1], + rx_csi_rs_signal[(k<<1)+1]); +#endif + } + } + } + + return 0; +} + int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { return 0; } @@ -73,12 +110,14 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t #endif nr_generate_csi_rs(ue->frame_parms, - ue->nr_csi_rs_info->csi_rs_received_signal, + ue->nr_csi_rs_info->csi_rs_generated_signal, AMP, ue->nr_csi_rs_info, (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *) csirs_config_pdu, ue->frame_parms.first_carrier_offset, proc->nr_slot_rx); + nr_get_csi_rs_signal(ue, proc, ue->nr_csi_rs_info, ue->nr_csi_rs_info->csi_rs_received_signal); + return 0; } diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 0f3842824d..1863aaa33a 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -266,8 +266,9 @@ typedef struct { typedef struct { uint32_t ***nr_gold_csi_rs; - uint16_t sc_list_length; - uint16_t sc_list[6 * NR_MAX_NB_RB]; + uint16_t k_list_length[NR_SYMBOLS_PER_SLOT]; + uint16_t map_list[NR_SYMBOLS_PER_SLOT][NR_MAX_CSI_RS_LENGTH]; + int32_t **csi_rs_generated_signal; int32_t **csi_rs_received_signal; } nr_csi_rs_info_t; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index b5f2341993..37890f9c7f 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1356,6 +1356,51 @@ int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL } } +void nr_slot_fep_csi_rs(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, + int slot) { + + // 38.211-Table 7.4.1.5.3-1: CSI-RS locations within a slot + switch(csirs_config_pdu.row){ + case 1: + case 2: + case 3: + case 4: + case 6: + case 9: + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0, slot); + break; + case 5: + case 7: + case 8: + case 10: + case 11: + case 12: + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0, slot); + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0+1, slot); + break; + case 13: + case 14: + case 16: + case 17: + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0, slot); + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0+1, slot); + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l1, slot); + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l1+1, slot); + break; + case 15: + case 18: + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0, slot); + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0+1, slot); + nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0+2, slot); + break; + default: + AssertFatal(0==1, "Row %d is not valid for CSI Table 7.4.1.5.3-1\n", csirs_config_pdu.row); + } + +} + int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, @@ -1649,6 +1694,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, // do procedures for CSI-RS if ((ue->csirs_vars[gNB_id]) && (ue->csirs_vars[gNB_id]->active == 1)) { + nr_slot_fep_csi_rs(ue, proc, ue->csirs_vars[gNB_id]->csirs_config_pdu, nr_slot_rx); nr_ue_csi_rs_procedures(ue, proc, gNB_id); ue->csirs_vars[gNB_id]->active = 0; } From bb89ae3aca13ed28d957c80a5c075c775f60667a Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Fri, 4 Mar 2022 14:34:26 +0000 Subject: [PATCH 020/105] Delete duplicated prototype function (update to develop implementation) --- openair2/RRC/NR/rrc_gNB.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 683a754feb..78576d8fa6 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -107,27 +107,6 @@ extern RAN_CONTEXT_t RC; -extern boolean_t nr_rrc_pdcp_config_asn1_req( - const protocol_ctxt_t *const ctxt_pP, - NR_SRB_ToAddModList_t *const srb2add_list, - NR_DRB_ToAddModList_t *const drb2add_list, - NR_DRB_ToReleaseList_t *const drb2release_list, - const uint8_t security_modeP, - uint8_t *const kRRCenc, - uint8_t *const kRRCint, - uint8_t *const kUPenc, - uint8_t *const kUPint, - LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9, - rb_id_t *const defaultDRB, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); - -extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP, - const NR_SRB_ToAddModList_t * const srb2add_listP, - const NR_DRB_ToAddModList_t * const drb2add_listP, - const NR_DRB_ToReleaseList_t * const drb2release_listP, - const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); - static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn); mui_t rrc_gNB_mui = 0; From a77769d45b9e4823e4a87bbd2515b121aef08c32 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Sat, 5 Mar 2022 02:32:34 +0000 Subject: [PATCH 021/105] Fix build after merge --- openair2/RRC/NR/rrc_gNB.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 9c8a2e061b..fd6f88dfb7 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1155,6 +1155,8 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( NULL, dedicatedNAS_MessageList, NULL, + NULL, + NULL, NULL); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)buffer, size, "[MSG] RRC Reconfiguration\n"); From db0ce84aa5bc57feb16fe711d1d155e7d396e9f5 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 8 Mar 2022 13:18:17 +0000 Subject: [PATCH 022/105] Fix FAPI for CSI-RS pdu and associated procedures --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 30 +++++------ .../nfapi/public_inc/nfapi_nr_interface_scf.h | 36 +++++-------- nfapi/open-nFAPI/nfapi/src/nfapi_p7.c | 4 -- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 32 ++++------- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 2 - openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 18 +++++-- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 53 +++++++++++-------- 7 files changed, 85 insertions(+), 90 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index d93072519b..a943a2462b 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -475,22 +475,20 @@ typedef struct { typedef struct { - uint16_t bwp_size;// - uint16_t bwp_start;// - uint8_t subcarrier_spacing;// - uint8_t cyclic_prefix;// - uint16_t start_rb; - uint16_t nr_of_rbs; - uint8_t csi_type;//Value: 0:TRS 1:CSI-RS NZP 2:CSI-RS ZP - uint8_t row;//Row entry into the CSI Resource location table. [TS38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1] Value: 1-18 - uint16_t freq_domain;//Value: Up to the 12 LSBs, actual size is determined by the Row parameter - uint8_t symb_l0;//The time domain location l0 and firstOFDMSymbolInTimeDomain Value: 0->13 - uint8_t symb_l1;// - uint8_t cdm_type; - uint8_t freq_density;//The density field, p and comb offset (for dot5).0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three - uint16_t scramb_id;//ScramblingID of the CSI-RS [TS38.214, sec 5.2.2.3.1] Value: 0->1023 - uint8_t power_control_offset;//Ratio of PDSCH EPRE to NZP CSI-RSEPRE Value :0->23 representing -8 to 15 dB in 1dB steps - uint8_t power_control_offset_ss;//Ratio of SSB/PBCH block EPRE to NZP CSI-RS EPRES 0: -3dB, 1: 0dB, 2: 3dB, 3: 6dB + uint8_t subcarrier_spacing; // subcarrierSpacing [3GPP TS 38.211, sec 4.2], Value:0->4 + uint8_t cyclic_prefix; // Cyclic prefix type [3GPP TS 38.211, sec 4.2], 0: Normal; 1: Extended + uint16_t start_rb; // PRB where this CSI resource starts related to common resource block #0 (CRB#0). Only multiples of 4 are allowed. [3GPP TS 38.331, sec 6.3.2 parameter CSIFrequencyOccupation], Value: 0 ->274 + uint16_t nr_of_rbs; // Number of PRBs across which this CSI resource spans. Only multiples of 4 are allowed. [3GPP TS 38.331, sec 6.3.2 parameter CSI-FrequencyOccupation], Value: 24 -> 276 + uint8_t csi_type; // CSI Type [3GPP TS 38.211, sec 7.4.1.5], Value: 0:TRS; 1:CSI-RS NZP; 2:CSI-RS ZP + uint8_t row; // Row entry into the CSI Resource location table. [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 1-18 + uint16_t freq_domain; // Bitmap defining the frequencyDomainAllocation [3GPP TS 38.211, sec 7.4.1.5.3] [3GPP TS 38.331 CSIResourceMapping], Value: Up to the 12 LSBs, actual size is determined by the Row parameter + uint8_t symb_l0; // The time domain location l0 and firstOFDMSymbolInTimeDomain [3GPP TS 38.211, sec 7.4.1.5.3], Value: 0->13 + uint8_t symb_l1; // The time domain location l1 and firstOFDMSymbolInTimeDomain2 [3GPP TS 38.211, sec 7.4.1.5.3], Value: 2->12 + uint8_t cdm_type; // The cdm-Type field [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 0: noCDM; 1: fd-CDM2; 2: cdm4-FD2-TD2; 3: cdm8-FD2-TD4 + uint8_t freq_density; // The density field, p and comb offset (for dot5). [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 0: dot5 (even RB); 1: dot5 (odd RB); 2: one; 3: three + uint16_t scramb_id; // ScramblingID of the CSI-RS [3GPP TS 38.214, sec 5.2.2.3.1], Value: 0->1023 + uint8_t power_control_offset; // Ratio of PDSCH EPRE to NZP CSI-RSEPRE [3GPP TS 38.214, sec 5.2.2.3.1], Value: 0->23 representing -8 to 15 dB in 1dB steps; 255: L1 is configured with ProfileSSS + uint8_t power_control_offset_ss; // Ratio of NZP CSI-RS EPRE to SSB/PBCH block EPRE [3GPP TS 38.214, sec 5.2.2.3.1], Values: 0: -3dB; 1: 0dB; 2: 3dB; 3: 6dB; 255: L1 is configured with ProfileSSS } fapi_nr_dl_config_csirs_pdu_rel15_t; diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index c3a173758c..f84ae5a37e 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -920,32 +920,24 @@ typedef struct } nfapi_nr_dlsch_pdu_t; */ -//for csi-rs_pdu: - -//table 3-39 typedef struct { - uint16_t bwp_size;// - uint16_t bwp_start;// - uint8_t subcarrier_spacing;// - uint8_t cyclic_prefix;// - uint16_t start_rb; - uint16_t nr_of_rbs; - uint8_t csi_type;//Value: 0:TRS 1:CSI-RS NZP 2:CSI-RS ZP - uint8_t row;//Row entry into the CSI Resource location table. [TS38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1] Value: 1-18 - uint16_t freq_domain;//Value: Up to the 12 LSBs, actual size is determined by the Row parameter - uint8_t symb_l0;//The time domain location l0 and firstOFDMSymbolInTimeDomain Value: 0->13 - uint8_t symb_l1;// - uint8_t cdm_type; - uint8_t freq_density;//The density field, p and comb offset (for dot5).0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three - uint16_t scramb_id;//ScramblingID of the CSI-RS [TS38.214, sec 5.2.2.3.1] Value: 0->1023 - //tx power info - uint8_t power_control_offset;//Ratio of PDSCH EPRE to NZP CSI-RSEPRE Value :0->23 representing -8 to 15 dB in 1dB steps - uint8_t power_control_offset_ss;//Ratio of SSB/PBCH block EPRE to NZP CSI-RS EPRES 0: -3dB, 1: 0dB, 2: 3dB, 3: 6dB - + uint8_t subcarrier_spacing; // subcarrierSpacing [3GPP TS 38.211, sec 4.2], Value:0->4 + uint8_t cyclic_prefix; // Cyclic prefix type [3GPP TS 38.211, sec 4.2], 0: Normal; 1: Extended + uint16_t start_rb; // PRB where this CSI resource starts related to common resource block #0 (CRB#0). Only multiples of 4 are allowed. [3GPP TS 38.331, sec 6.3.2 parameter CSIFrequencyOccupation], Value: 0 ->274 + uint16_t nr_of_rbs; // Number of PRBs across which this CSI resource spans. Only multiples of 4 are allowed. [3GPP TS 38.331, sec 6.3.2 parameter CSI-FrequencyOccupation], Value: 24 -> 276 + uint8_t csi_type; // CSI Type [3GPP TS 38.211, sec 7.4.1.5], Value: 0:TRS; 1:CSI-RS NZP; 2:CSI-RS ZP + uint8_t row; // Row entry into the CSI Resource location table. [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 1-18 + uint16_t freq_domain; // Bitmap defining the frequencyDomainAllocation [3GPP TS 38.211, sec 7.4.1.5.3] [3GPP TS 38.331 CSIResourceMapping], Value: Up to the 12 LSBs, actual size is determined by the Row parameter + uint8_t symb_l0; // The time domain location l0 and firstOFDMSymbolInTimeDomain [3GPP TS 38.211, sec 7.4.1.5.3], Value: 0->13 + uint8_t symb_l1; // The time domain location l1 and firstOFDMSymbolInTimeDomain2 [3GPP TS 38.211, sec 7.4.1.5.3], Value: 2->12 + uint8_t cdm_type; // The cdm-Type field [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 0: noCDM; 1: fd-CDM2; 2: cdm4-FD2-TD2; 3: cdm8-FD2-TD4 + uint8_t freq_density; // The density field, p and comb offset (for dot5). [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 0: dot5 (even RB); 1: dot5 (odd RB); 2: one; 3: three + uint16_t scramb_id; // ScramblingID of the CSI-RS [3GPP TS 38.214, sec 5.2.2.3.1], Value: 0->1023 + uint8_t power_control_offset; // Ratio of PDSCH EPRE to NZP CSI-RSEPRE [3GPP TS 38.214, sec 5.2.2.3.1], Value: 0->23 representing -8 to 15 dB in 1dB steps; 255: L1 is configured with ProfileSSS + uint8_t power_control_offset_ss; // Ratio of NZP CSI-RS EPRE to SSB/PBCH block EPRE [3GPP TS 38.214, sec 5.2.2.3.1], Values: 0: -3dB; 1: 0dB; 2: 3dB; 3: 6dB; 255: L1 is configured with ProfileSSS } nfapi_nr_dl_tti_csi_rs_pdu_rel15_t; -//for ssb_pdu: typedef struct { diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c index 0e43c803e7..bc529d3e43 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -200,8 +200,6 @@ static uint8_t pack_tpm_value(nfapi_dl_config_dci_dl_tpm_t *value, uint8_t **ppW static uint8_t pack_dl_tti_csi_rs_pdu_rel15_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *value = (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *)tlv; return( - push16(value->bwp_size, ppWritePackedMsg, end) && - push16(value->bwp_start, ppWritePackedMsg, end) && push8(value->subcarrier_spacing, ppWritePackedMsg, end) && push8(value->cyclic_prefix, ppWritePackedMsg, end) && push16(value->start_rb, ppWritePackedMsg, end) && @@ -3627,8 +3625,6 @@ int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBu static uint8_t unpack_dl_tti_csi_rs_pdu_rel15_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *value = (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *)tlv; return( - pull16(ppReadPackedMsg, &value->bwp_size, end) && - pull16(ppReadPackedMsg, &value->bwp_start, end) && pull8(ppReadPackedMsg, &value->subcarrier_spacing, end) && pull8(ppReadPackedMsg, &value->cyclic_prefix, end) && pull16(ppReadPackedMsg, &value->start_rb, end) && diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index 505494783e..2dc41aa015 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -51,8 +51,6 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, int slot){ #ifdef NR_CSIRS_DEBUG - LOG_I(NR_PHY, "csi_params->bwp_size = %i\n", csi_params->bwp_size); - LOG_I(NR_PHY, "csi_params->bwp_start = %i\n", csi_params->bwp_start); LOG_I(NR_PHY, "csi_params->subcarrier_spacing = %i\n", csi_params->subcarrier_spacing); LOG_I(NR_PHY, "csi_params->cyclic_prefix = %i\n", csi_params->cyclic_prefix); LOG_I(NR_PHY, "csi_params->start_rb = %i\n", csi_params->start_rb); @@ -73,7 +71,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, uint32_t **nr_gold_csi_rs = nr_csi_rs_info->nr_gold_csi_rs[slot]; int16_t mod_csi[frame_parms.symbols_per_slot][NR_MAX_CSI_RS_LENGTH>>1] __attribute__((aligned(16)));; uint16_t b = csi_params->freq_domain; - uint16_t n, csi_bw, csi_start, p, k, l, mprime, na, kpn, csi_length; + uint16_t n, p, k, l, mprime, na, kpn; uint8_t size, ports, kprime, lprime, i, gs; uint8_t j[16], k_n[6], koverline[16], loverline[16]; int found = 0; @@ -538,27 +536,19 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, AssertFatal(0==1, "Invalid cdm type index for CSI\n"); } - // according to 38.214 5.2.2.3.1 last paragraph - if (csi_params->start_rbbwp_start) - csi_start = csi_params->bwp_start; - else - csi_start = csi_params->start_rb; - if (csi_params->nr_of_rbs > (csi_params->bwp_start+csi_params->bwp_size-csi_start)) - csi_bw = csi_params->bwp_start+csi_params->bwp_size-csi_start; - else - csi_bw = csi_params->nr_of_rbs; - + uint16_t csi_length; if (rho < 1) { - if (csi_params->freq_density == 0) - csi_length = (((csi_bw + csi_start)>>1)<>1)<freq_density == 0) { + csi_length = (((csi_params->start_rb + csi_params->nr_of_rbs)>>1)<start_rb + csi_params->nr_of_rbs)>>1)<start_rb + csi_params->nr_of_rbs))<start_rb, csi_params->nr_of_rbs, csi_length); #endif @@ -605,7 +595,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, uint16_t start_sc = frame_parms.first_carrier_offset; // resource mapping according to 38.211 7.4.1.5.3 - for (n=csi_start; n<(csi_start+csi_bw); n++) { + for (n=csi_params->start_rb; n<(csi_params->start_rb+csi_params->nr_of_rbs); n++) { if ( (csi_params->freq_density > 1) || (csi_params->freq_density == (n%2))) { // for freq density 0.5 checks if even or odd RB for (int ji=0; jicsirs_vars[gNB_id]->csirs_config_pdu; #ifdef NR_CSIRS_DEBUG - LOG_I(NR_PHY, "csirs_config_pdu->bwp_size = %i\n", csirs_config_pdu->bwp_size); - LOG_I(NR_PHY, "csirs_config_pdu->bwp_start = %i\n", csirs_config_pdu->bwp_start); LOG_I(NR_PHY, "csirs_config_pdu->subcarrier_spacing = %i\n", csirs_config_pdu->subcarrier_spacing); LOG_I(NR_PHY, "csirs_config_pdu->cyclic_prefix = %i\n", csirs_config_pdu->cyclic_prefix); LOG_I(NR_PHY, "csirs_config_pdu->start_rb = %i\n", csirs_config_pdu->start_rb); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 1bdfce4b67..4024b94851 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2443,12 +2443,22 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { LOG_D(MAC,"Scheduling reception of CSI-RS in frame %d slot %d\n",frame,slot); fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].csirs_config_pdu.csirs_config_rel15; NR_CSI_RS_ResourceMapping_t resourceMapping = nzpcsi->resourceMapping; - csirs_config_pdu->bwp_size = bwp_size; - csirs_config_pdu->bwp_start = bwp_start; csirs_config_pdu->subcarrier_spacing = mu; csirs_config_pdu->cyclic_prefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0; - csirs_config_pdu->start_rb = resourceMapping.freqBand.startingRB; - csirs_config_pdu->nr_of_rbs = resourceMapping.freqBand.nrofRBs; + + // According to last paragraph of TS 38.214 5.2.2.3.1 + if (resourceMapping.freqBand.startingRB < bwp_start) { + csirs_config_pdu->start_rb = bwp_start; + } else { + csirs_config_pdu->start_rb = resourceMapping.freqBand.startingRB; + } + if (resourceMapping.freqBand.nrofRBs > (bwp_start + bwp_size - csirs_config_pdu->start_rb)) { + csirs_config_pdu->nr_of_rbs = bwp_start + bwp_size - csirs_config_pdu->start_rb; + } else { + csirs_config_pdu->nr_of_rbs = resourceMapping.freqBand.nrofRBs; + } + AssertFatal(csirs_config_pdu->nr_of_rbs >= 24, "CSI-RS has %d RBs, but the minimum is 24\n", csirs_config_pdu->nr_of_rbs); + csirs_config_pdu->csi_type = 1; // NZP-CSI-RS csirs_config_pdu->symb_l0 = resourceMapping.firstOFDMSymbolInTimeDomain; if (resourceMapping.firstOFDMSymbolInTimeDomain2) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 4ee2ea82b8..f00c2ed458 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2506,16 +2506,27 @@ void nr_csirs_scheduling(int Mod_idP, nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csirs_pdu_rel15 = &dl_tti_csirs_pdu->csi_rs_pdu.csi_rs_pdu_rel15; - csirs_pdu_rel15->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth,275); - csirs_pdu_rel15->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,275); csirs_pdu_rel15->subcarrier_spacing = genericParameters->subcarrierSpacing; if (genericParameters->cyclicPrefix) csirs_pdu_rel15->cyclic_prefix = *genericParameters->cyclicPrefix; else csirs_pdu_rel15->cyclic_prefix = 0; - csirs_pdu_rel15->start_rb = resourceMapping.freqBand.startingRB; - csirs_pdu_rel15->nr_of_rbs = resourceMapping.freqBand.nrofRBs; + // According to last paragraph of TS 38.214 5.2.2.3.1 + uint16_t BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + uint16_t BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + if (resourceMapping.freqBand.startingRB < BWPStart) { + csirs_pdu_rel15->start_rb = BWPStart; + } else { + csirs_pdu_rel15->start_rb = resourceMapping.freqBand.startingRB; + } + if (resourceMapping.freqBand.nrofRBs > (BWPStart + BWPSize - csirs_pdu_rel15->start_rb)) { + csirs_pdu_rel15->nr_of_rbs = BWPStart + BWPSize - csirs_pdu_rel15->start_rb; + } else { + csirs_pdu_rel15->nr_of_rbs = resourceMapping.freqBand.nrofRBs; + } + AssertFatal(csirs_pdu_rel15->nr_of_rbs >= 24, "CSI-RS has %d RBs, but the minimum is 24\n", csirs_pdu_rel15->nr_of_rbs); + csirs_pdu_rel15->csi_type = 1; // NZP-CSI-RS csirs_pdu_rel15->symb_l0 = resourceMapping.firstOFDMSymbolInTimeDomain; if (resourceMapping.firstOFDMSymbolInTimeDomain2) @@ -2536,20 +2547,20 @@ void nr_csirs_scheduling(int Mod_idP, csirs_pdu_rel15->row = 1; csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.row1.buf[0])>>4)&0x0f; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2: csirs_pdu_rel15->row = 2; csirs_pdu_rel15->freq_domain = (((resourceMapping.frequencyDomainAllocation.choice.row2.buf[1]>>4)&0x0f) | ((resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]<<4)&0xff0)); for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row4: csirs_pdu_rel15->row = 4; csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.row4.buf[0])>>5)&0x07; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other: csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.other.buf[0])>>2)&0x3f; @@ -2561,18 +2572,18 @@ void nr_csirs_scheduling(int Mod_idP, case NR_CSI_RS_ResourceMapping__nrofPorts_p2: csirs_pdu_rel15->row = 3; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p4: csirs_pdu_rel15->row = 5; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p8: if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 8; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); } else{ int num_k = 0; @@ -2581,12 +2592,12 @@ void nr_csirs_scheduling(int Mod_idP, if(num_k==4) { csirs_pdu_rel15->row = 6; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); } else { csirs_pdu_rel15->row = 7; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); } } break; @@ -2594,12 +2605,12 @@ void nr_csirs_scheduling(int Mod_idP, if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 10; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); } else { csirs_pdu_rel15->row = 9; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); } break; case NR_CSI_RS_ResourceMapping__nrofPorts_p16: @@ -2608,24 +2619,24 @@ void nr_csirs_scheduling(int Mod_idP, else csirs_pdu_rel15->row = 11; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p24: if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 14; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); + vrb_map[rb] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } else{ if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm8_FD2_TD4) { csirs_pdu_rel15->row = 15; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); } else { csirs_pdu_rel15->row = 13; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); + vrb_map[rb] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } } break; @@ -2633,18 +2644,18 @@ void nr_csirs_scheduling(int Mod_idP, if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 17; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); + vrb_map[rb] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } else{ if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm8_FD2_TD4) { csirs_pdu_rel15->row = 18; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); } else { csirs_pdu_rel15->row = 16; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); + vrb_map[rb] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } } break; From 51a72b847947e550adef85514e529247971848eb Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 9 Mar 2022 15:07:23 +0000 Subject: [PATCH 023/105] LS channel estimation at UE based on CSI-RS --- openair1/PHY/INIT/nr_init_ue.c | 25 +++++++++++++ openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 3 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 51 ++++++++++++++++++++++++++- openair1/PHY/defs_nr_common.h | 4 +++ 4 files changed, 81 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 04c4b5a7ca..fd9a021a80 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -364,11 +364,16 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) AssertFatal(ue->nr_csi_rs_info->nr_gold_csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); } } + ue->nr_csi_rs_info->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); ue->nr_csi_rs_info->csi_rs_generated_signal = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); ue->nr_csi_rs_info->csi_rs_received_signal = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); + ue->nr_csi_rs_info->csi_rs_ls_estimated_channel = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); for (i=0; inb_antennas_rx; i++) { ue->nr_csi_rs_info->csi_rs_generated_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); ue->nr_csi_rs_info->csi_rs_received_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); } ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); @@ -647,6 +652,26 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) free_and_zero(ue->pdcch_vars[th_id][gNB_id]); } + for (int i = 0; i < fp->nb_antennas_rx; i++) { + free_and_zero(ue->nr_csi_rs_info->csi_rs_generated_signal[i]); + free_and_zero(ue->nr_csi_rs_info->csi_rs_received_signal[i]); + free_and_zero(ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i]); + free_and_zero(ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i]); + } + for (int slot=0; slotslots_per_frame; slot++) { + for (int symb=0; symbsymbols_per_slot; symb++) { + free_and_zero(ue->nr_csi_rs_info->nr_gold_csi_rs[slot][symb]); + } + free_and_zero(ue->nr_csi_rs_info->nr_gold_csi_rs[slot]); + } + free_and_zero(ue->nr_csi_rs_info->noise_power); + free_and_zero(ue->nr_csi_rs_info->nr_gold_csi_rs); + free_and_zero(ue->nr_csi_rs_info->csi_rs_generated_signal); + free_and_zero(ue->nr_csi_rs_info->csi_rs_received_signal); + free_and_zero(ue->nr_csi_rs_info->csi_rs_ls_estimated_channel); + free_and_zero(ue->nr_csi_rs_info->csi_rs_estimated_channel_freq); + free_and_zero(ue->nr_csi_rs_info); + for (int i = 0; i < fp->nb_antennas_rx; i++) { free_and_zero(ue->nr_srs_info->srs_received_signal[i]); free_and_zero(ue->nr_srs_info->srs_ls_estimated_channel[i]); diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index 2dc41aa015..85c49b7eb2 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -79,6 +79,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, uint8_t fi = 0; double rho, alpha; uint32_t beta = amp; + nr_csi_rs_info->csi_rs_generated_signal_bits = log2_approx(amp); AssertFatal(b!=0, "Invalid CSI frequency domain mapping: no bit selected in bitmap\n"); @@ -639,7 +640,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_offset)] = (beta*wt*wf*mod_csi[l][(mprime<<1) + 1]) >> 15; } #ifdef NR_CSIRS_DEBUG - printf("l,k (%d %d) seq. index %d \t port %d \t (%d,%d)\n",l,k,mprime,p+3000, + printf("l,k (%d,%d) seq. index %d \t port %d \t (%d,%d)\n",l,k,mprime,p+3000, ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)], ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_offset)]); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index c0006beada..1f34bc75ee 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -63,7 +63,7 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, #ifdef NR_CSIRS_DEBUG int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[ant][symbol_offset+dataF_offset]; - LOG_I(NR_PHY, "l,k (%d %d) \t tx (%d,%d) \t rx (%d,%d)\n", + LOG_I(NR_PHY, "l,k (%2d,%3d) |\ttx (%4d,%4d)\trx (%4d,%4d)\n", symb, nr_csi_rs_info->map_list[symb][k_id], tx_csi_rs_signal[k<<1], @@ -78,6 +78,48 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, return 0; } +int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + nr_csi_rs_info_t *nr_csi_rs_info, + int32_t **csi_rs_generated_signal, + int32_t **csi_rs_received_signal, + int32_t **csi_rs_estimated_channel_freq, + uint32_t *noise_power) { + + NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; + int16_t ls_estimated[2]; + + for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { + for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { + + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[ant][symbol_offset+dataF_offset]; + int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant][symbol_offset]; + + for(int k_id = 0; k_idk_list_length[symb]; k_id++) { + uint16_t k = nr_csi_rs_info->map_list[symb][k_id]; + ls_estimated[0] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[k<<1] + (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[(k<<1)+1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + ls_estimated[1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[(k<<1)+1] - (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[k<<1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "l,k (%2d,%3d) |\ttx (%4d,%4d)\trx (%4d,%4d)\tls (%4d,%4d)\n", + symb, + nr_csi_rs_info->map_list[symb][k_id], + tx_csi_rs_signal[k<<1], + tx_csi_rs_signal[(k<<1)+1], + rx_csi_rs_signal[k<<1], + rx_csi_rs_signal[(k<<1)+1], + ls_estimated[0], + ls_estimated[1]); +#endif + } + } + } + + return 0; +} + int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { return 0; } @@ -117,5 +159,12 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t nr_get_csi_rs_signal(ue, proc, ue->nr_csi_rs_info, ue->nr_csi_rs_info->csi_rs_received_signal); + nr_csi_rs_channel_estimation(ue, + proc, + ue->nr_csi_rs_info, + ue->nr_csi_rs_info->csi_rs_generated_signal, + ue->nr_csi_rs_info->csi_rs_received_signal, + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + ue->nr_csi_rs_info->noise_power); return 0; } diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 1863aaa33a..de307dac32 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -268,8 +268,12 @@ typedef struct { uint32_t ***nr_gold_csi_rs; uint16_t k_list_length[NR_SYMBOLS_PER_SLOT]; uint16_t map_list[NR_SYMBOLS_PER_SLOT][NR_MAX_CSI_RS_LENGTH]; + uint8_t csi_rs_generated_signal_bits; int32_t **csi_rs_generated_signal; int32_t **csi_rs_received_signal; + int32_t **csi_rs_ls_estimated_channel; + int32_t **csi_rs_estimated_channel_freq; + uint32_t *noise_power; } nr_csi_rs_info_t; typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; From 19d8ea274257ee1afdf536554db11389bd0d8ba7 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 9 Mar 2022 17:59:32 +0000 Subject: [PATCH 024/105] Minor optimizations --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 77 +++++++++++++++++++-- openair1/SCHED_NR_UE/defs.h | 1 + openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 52 ++------------ 3 files changed, 76 insertions(+), 54 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 1f34bc75ee..5fa1508f23 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -41,8 +41,57 @@ //#define NR_CSIRS_DEBUG +bool is_csi_rs_in_symbol(fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, int symbol) { + + bool ret = false; + + // 38.211-Table 7.4.1.5.3-1: CSI-RS locations within a slot + switch(csirs_config_pdu.row){ + case 1: + case 2: + case 3: + case 4: + case 6: + case 9: + if(symbol == csirs_config_pdu.symb_l0) { + ret = true; + } + break; + case 5: + case 7: + case 8: + case 10: + case 11: + case 12: + if(symbol == csirs_config_pdu.symb_l0 || symbol == (csirs_config_pdu.symb_l0+1) ) { + ret = true; + } + break; + case 13: + case 14: + case 16: + case 17: + if(symbol == csirs_config_pdu.symb_l0 || symbol == (csirs_config_pdu.symb_l0+1) || + symbol == csirs_config_pdu.symb_l1 || symbol == (csirs_config_pdu.symb_l1+1)) { + ret = true; + } + break; + case 15: + case 18: + if(symbol == csirs_config_pdu.symb_l0 || symbol == (csirs_config_pdu.symb_l0+1) || symbol == (csirs_config_pdu.symb_l0+2) ) { + ret = true; + } + break; + default: + AssertFatal(0==1, "Row %d is not valid for CSI Table 7.4.1.5.3-1\n", csirs_config_pdu.row); + } + + return ret; +} + int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, nr_csi_rs_info_t *nr_csi_rs_info, int32_t **csi_rs_received_signal) { @@ -52,6 +101,9 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { memset(csi_rs_received_signal[ant], 0, frame_parms->samples_per_frame_wCP*sizeof(int32_t)); for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { + if(!is_csi_rs_in_symbol(*csirs_config_pdu, symb)) { + continue; + } uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; int16_t *rx_signal = (int16_t*)&rxdataF[ant][symbol_offset]; int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant][symbol_offset]; @@ -80,6 +132,7 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, nr_csi_rs_info_t *nr_csi_rs_info, int32_t **csi_rs_generated_signal, int32_t **csi_rs_received_signal, @@ -88,19 +141,24 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; - int16_t ls_estimated[2]; for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { - for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { + /// LS channel estimation + + for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { + if(!is_csi_rs_in_symbol(*csirs_config_pdu, symb)) { + continue; + } uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[ant][symbol_offset+dataF_offset]; int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant][symbol_offset]; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant][symbol_offset]; for(int k_id = 0; k_idk_list_length[symb]; k_id++) { uint16_t k = nr_csi_rs_info->map_list[symb][k_id]; - ls_estimated[0] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[k<<1] + (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[(k<<1)+1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); - ls_estimated[1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[(k<<1)+1] - (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[k<<1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + csi_rs_ls_estimated_channel[k<<1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[k<<1] + (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[(k<<1)+1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + csi_rs_ls_estimated_channel[(k<<1)+1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[(k<<1)+1] - (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[k<<1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); #ifdef NR_CSIRS_DEBUG LOG_I(NR_PHY, "l,k (%2d,%3d) |\ttx (%4d,%4d)\trx (%4d,%4d)\tls (%4d,%4d)\n", @@ -110,8 +168,8 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, tx_csi_rs_signal[(k<<1)+1], rx_csi_rs_signal[k<<1], rx_csi_rs_signal[(k<<1)+1], - ls_estimated[0], - ls_estimated[1]); + csi_rs_ls_estimated_channel[k<<1], + csi_rs_ls_estimated_channel[(k<<1)+1]); #endif } } @@ -157,10 +215,15 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->frame_parms.first_carrier_offset, proc->nr_slot_rx); - nr_get_csi_rs_signal(ue, proc, ue->nr_csi_rs_info, ue->nr_csi_rs_info->csi_rs_received_signal); + nr_get_csi_rs_signal(ue, + proc, + csirs_config_pdu, + ue->nr_csi_rs_info, + ue->nr_csi_rs_info->csi_rs_received_signal); nr_csi_rs_channel_estimation(ue, proc, + csirs_config_pdu, ue->nr_csi_rs_info, ue->nr_csi_rs_info->csi_rs_generated_signal, ue->nr_csi_rs_info->csi_rs_received_signal, diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 917d9fc342..244b79b1b4 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -366,6 +366,7 @@ int get_tx_harq_id(NR_UE_ULSCH_t *ulsch, int slot_tx); int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp); int is_ssb_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp); +bool is_csi_rs_in_symbol(fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, int symbol); /*! \brief This function prepares the dl indication to pass to the MAC @param diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index da31319934..06cf192270 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1356,52 +1356,6 @@ int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL } } -void nr_slot_fep_csi_rs(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, - int slot) { - - // 38.211-Table 7.4.1.5.3-1: CSI-RS locations within a slot - switch(csirs_config_pdu.row){ - case 1: - case 2: - case 3: - case 4: - case 6: - case 9: - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0, slot); - break; - case 5: - case 7: - case 8: - case 10: - case 11: - case 12: - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0, slot); - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0+1, slot); - break; - case 13: - case 14: - case 16: - case 17: - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0, slot); - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0+1, slot); - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l1, slot); - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l1+1, slot); - break; - case 15: - case 18: - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0, slot); - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0+1, slot); - nr_slot_fep(ue, proc, csirs_config_pdu.symb_l0+2, slot); - break; - default: - AssertFatal(0==1, "Row %d is not valid for CSI Table 7.4.1.5.3-1\n", csirs_config_pdu.row); - } - -} - - int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, @@ -1694,7 +1648,11 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, // do procedures for CSI-RS if ((ue->csirs_vars[gNB_id]) && (ue->csirs_vars[gNB_id]->active == 1)) { - nr_slot_fep_csi_rs(ue, proc, ue->csirs_vars[gNB_id]->csirs_config_pdu, nr_slot_rx); + for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { + if(is_csi_rs_in_symbol(ue->csirs_vars[gNB_id]->csirs_config_pdu,symb)) { + nr_slot_fep(ue, proc, symb, nr_slot_rx); + } + } nr_ue_csi_rs_procedures(ue, proc, gNB_id); ue->csirs_vars[gNB_id]->active = 0; } From 0126bd849b8935ed23a69ddd618c1b2de36604b1 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 9 Mar 2022 19:18:30 +0000 Subject: [PATCH 025/105] Remove redundant info from nr_csi_rs_info_t --- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 9 ++++----- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 12 ++++++------ openair1/PHY/defs_nr_common.h | 4 ++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index 85c49b7eb2..0f687d6878 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -592,7 +592,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } } - bzero(nr_csi_rs_info->k_list_length,NR_SYMBOLS_PER_SLOT*sizeof(uint16_t)); + nr_csi_rs_info->k_list_length = 0; uint16_t start_sc = frame_parms.first_carrier_offset; // resource mapping according to 38.211 7.4.1.5.3 @@ -603,7 +603,9 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, p = s+j[ji]*gs; // port index for (kp=0; kp<=kprime; kp++) { // loop over frequency resource elements within a group k = (start_sc+(n*NR_NB_SC_PER_RB)+koverline[ji]+kp)%(frame_parms.ofdm_symbol_size); // frequency index of current resource element - // wf according to tables 7.4.5.3-2 to 7.4.5.3-5 + nr_csi_rs_info->map_list[nr_csi_rs_info->k_list_length] = k; + nr_csi_rs_info->k_list_length++; + // wf according to tables 7.4.5.3-2 to 7.4.5.3-5 if (kp == 0) wf = 1; else @@ -627,9 +629,6 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, wt = -1; } - nr_csi_rs_info->map_list[l][nr_csi_rs_info->k_list_length[l]] = k; - nr_csi_rs_info->k_list_length[l]++; - // ZP CSI RS if (csi_params->csi_type == 2) { ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)] = 0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 5fa1508f23..2cfd43b5a0 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -107,8 +107,8 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; int16_t *rx_signal = (int16_t*)&rxdataF[ant][symbol_offset]; int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant][symbol_offset]; - for(int k_id = 0; k_idk_list_length[symb]; k_id++) { - uint16_t k = nr_csi_rs_info->map_list[symb][k_id]; + for(int k_id = 0; k_idk_list_length; k_id++) { + uint16_t k = nr_csi_rs_info->map_list[k_id]; rx_csi_rs_signal[k<<1] = rx_signal[k<<1]; rx_csi_rs_signal[(k<<1)+1] = rx_signal[(k<<1)+1]; @@ -117,7 +117,7 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[ant][symbol_offset+dataF_offset]; LOG_I(NR_PHY, "l,k (%2d,%3d) |\ttx (%4d,%4d)\trx (%4d,%4d)\n", symb, - nr_csi_rs_info->map_list[symb][k_id], + nr_csi_rs_info->map_list[k_id], tx_csi_rs_signal[k<<1], tx_csi_rs_signal[(k<<1)+1], rx_csi_rs_signal[k<<1], @@ -155,15 +155,15 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant][symbol_offset]; int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant][symbol_offset]; - for(int k_id = 0; k_idk_list_length[symb]; k_id++) { - uint16_t k = nr_csi_rs_info->map_list[symb][k_id]; + for(int k_id = 0; k_idk_list_length; k_id++) { + uint16_t k = nr_csi_rs_info->map_list[k_id]; csi_rs_ls_estimated_channel[k<<1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[k<<1] + (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[(k<<1)+1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); csi_rs_ls_estimated_channel[(k<<1)+1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[(k<<1)+1] - (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[k<<1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); #ifdef NR_CSIRS_DEBUG LOG_I(NR_PHY, "l,k (%2d,%3d) |\ttx (%4d,%4d)\trx (%4d,%4d)\tls (%4d,%4d)\n", symb, - nr_csi_rs_info->map_list[symb][k_id], + nr_csi_rs_info->map_list[k_id], tx_csi_rs_signal[k<<1], tx_csi_rs_signal[(k<<1)+1], rx_csi_rs_signal[k<<1], diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index de307dac32..cbc8bc8508 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -266,8 +266,8 @@ typedef struct { typedef struct { uint32_t ***nr_gold_csi_rs; - uint16_t k_list_length[NR_SYMBOLS_PER_SLOT]; - uint16_t map_list[NR_SYMBOLS_PER_SLOT][NR_MAX_CSI_RS_LENGTH]; + uint16_t k_list_length; + uint16_t map_list[NR_MAX_CSI_RS_LENGTH]; uint8_t csi_rs_generated_signal_bits; int32_t **csi_rs_generated_signal; int32_t **csi_rs_received_signal; From 670f979f977ad68612c56fc1ede58118166dd4ae Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 9 Mar 2022 20:00:41 +0000 Subject: [PATCH 026/105] Perform the average of LS estimates over time for CSI-RS at UE --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 2cfd43b5a0..8d339191bf 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -173,6 +173,36 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, #endif } } + + /// Channel interpolation + + int16_t ls_estimated[2]; + for (int k_id = 0; k_id < nr_csi_rs_info->k_list_length; k_id++) { + + uint16_t k = nr_csi_rs_info->map_list[k_id]; + + // There are many possibilities to allocate the CSI-RS in time, which would take the implementation of many filters. + // In this approach, the LS for each symbol would be different, and it would be necessary to interpolate each symbol + // on the frequency as well. To reduce this complexity, and lower the processing time, we will assume that the + // slot duration is less than the channel coherence time. Therefore, the LS of each symbol (for the same subcarrier) + // would be the same, and it will only be necessary to do the frequency interpolation for 1 symbol, as the result + // for the others would be the same. + int Nsymb = 0; + int32_t sum_csi_rs_ls_real = 0; + int32_t sum_csi_rs_ls_imag = 0; + for (int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { + if (!is_csi_rs_in_symbol(*csirs_config_pdu, symb)) { + continue; + } + Nsymb++; + uint64_t symbol_offset = symb * frame_parms->ofdm_symbol_size; + int16_t *csi_rs_ls_estimated_channel = (int16_t *) &nr_csi_rs_info->csi_rs_ls_estimated_channel[ant][symbol_offset]; + sum_csi_rs_ls_real += csi_rs_ls_estimated_channel[k << 1]; + sum_csi_rs_ls_imag += csi_rs_ls_estimated_channel[(k << 1) + 1]; + } + ls_estimated[0] = (int16_t) (sum_csi_rs_ls_real / Nsymb); + ls_estimated[1] = (int16_t) (sum_csi_rs_ls_imag / Nsymb); + } } return 0; From 7e17f8bd6a5a52596601605158c93fcf6d5cb2eb Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 18 Oct 2021 12:03:30 +0000 Subject: [PATCH 027/105] make nr_ulsim PASS condition depend on eff_tp_check, just as nr_dlsim already does --- openair1/SIMULATION/NR_PHY/dlsim.c | 4 ++-- openair1/SIMULATION/NR_PHY/ulsim.c | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index e797c01096..680858f821 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -653,7 +653,7 @@ int main(int argc, char **argv) default: case 'h': - printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", + printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); printf("-L \n"); @@ -662,7 +662,7 @@ int main(int argc, char **argv) printf("-n Number of frames to simulate\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); - printf("-t Delay spread for multipath channel\n"); + //printf("-t Delay spread for multipath channel\n"); printf("-g [A,B,C,D,E,F,G,R] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models or R for MIMO model (ignores delay spread and Ricean factor)\n"); printf("-y Number of TX antennas used in gNB\n"); printf("-z Number of RX antennas used in UE\n"); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 76d896a047..1443ebc24f 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -299,7 +299,6 @@ int main(int argc, char **argv) int32_t txlev=0; int start_rb = 0; int UE_id =0; // [hna] only works for UE_id = 0 because NUMBER_OF_NR_UE_MAX is set to 1 (phy_init_nr_gNB causes segmentation fault) - float target_error_rate = 0.01; int print_perf = 0; cpuf = get_cpu_freq_GHz(); int msg3_flag = 0; @@ -307,7 +306,7 @@ int main(int argc, char **argv) float roundStats[100]; double effRate[100]; double effTP[100]; - //float eff_tp_check = 0.7; + float eff_tp_check = 0.7; uint8_t snrRun; int prb_inter = 0; @@ -315,8 +314,8 @@ int main(int argc, char **argv) int modify_dmrs = 0; /* L_PTRS = ptrs_arg[0], K_PTRS = ptrs_arg[1] */ int ptrs_arg[2] = {-1,-1};// Invalid values - /* DMRS TYPE = dmrs_arg[0], Add Pos = dmrs_arg[1] */ - int dmrs_arg[2] = {-1,-1};// Invalid values + /* mapping type = dmrs_arg[0], Add Pos = dmrs_arg[1], dmrs config type = dmrs_arg[2] */ + int dmrs_arg[3] = {-1,-1,-1};// Invalid values uint16_t ptrsSymPos = 0; uint16_t ptrsSymbPerSlot = 0; uint16_t ptrsRePerSymb = 0; @@ -343,7 +342,7 @@ int main(int argc, char **argv) /* initialize the sin-cos table */ InitSinLUT(); - while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:ikl:m:n:p:r:s:u:w:y:z:F:G:H:M:N:PR:S:T:U:L:Z")) != -1) { + while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:ikl:m:n:p:r:s:t:u:w:y:z:F:G:H:M:N:PR:S:T:U:L:Z")) != -1) { printf("handling optarg %c\n",c); switch (c) { @@ -477,11 +476,10 @@ int main(int argc, char **argv) start_rb = atoi(optarg); break; -/* case 't': eff_tp_check = (float)atoi(optarg)/100; break; -*/ + /* case 'r': ricean_factor = pow(10,-.1*atof(optarg)); @@ -592,7 +590,7 @@ int main(int argc, char **argv) default: case 'h': - printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId -Z Enable SC-FDMA in Uplink \n", argv[0]); + printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId -Z Enable SC-FDMA in Uplink \n", argv[0]); //printf("-d Use TDD\n"); printf("-d Introduce delay in terms of number of samples\n"); printf("-f Number of frames to simulate\n"); @@ -604,7 +602,7 @@ int main(int argc, char **argv) printf("-m MCS value\n"); printf("-n Number of trials to simulate\n"); printf("-p Use extended prefix mode\n"); - printf("-t Delay spread for multipath channel\n"); + //printf("-t Delay spread for multipath channel\n"); printf("-u Set the numerology\n"); printf("-w Start PRB for PUSCH\n"); //printf("-x Transmission mode (1,2,6 for the moment)\n"); @@ -865,8 +863,15 @@ int main(int argc, char **argv) { add_pos = dmrs_arg[1]; } + /* DMRS Conf Type 1 or 2 */ + if(dmrs_arg[2] == 1) { + dmrs_config_type = pusch_dmrs_type1; + } else if(dmrs_arg[2] == 2) { + dmrs_config_type = pusch_dmrs_type2; + } + + printf("NOTE: DMRS config is modified with Mapping Type %d , Additional Position %d \n", mapping_type, add_pos ); } - printf("NOTE: DMRS config is modified with Mapping Type %d , Additional Position %d \n", mapping_type, add_pos ); uint8_t length_dmrs = pusch_len1; uint16_t l_prime_mask = get_l_prime(nb_symb_sch, mapping_type, add_pos, length_dmrs, start_symbol, NR_MIB__dmrs_TypeA_Position_pos2); @@ -883,6 +888,7 @@ int main(int argc, char **argv) AssertFatal(index >= 0, "Num RBs not configured according to 3GPP 38.211 section 6.3.1.4. For PUSCH with transform precoding, num RBs cannot be multiple of any other primenumber other than 2,3,5\n"); dmrs_config_type = pusch_dmrs_type1; + nb_re_dmrs = 6; printf("[ULSIM]: TRANSFORM PRECODING ENABLED. Num RBs: %d, index for DMRS_SEQ: %d\n", nb_rb, index); } @@ -1492,7 +1498,7 @@ int main(int argc, char **argv) if(n_trials==1) break; - if ((float)n_errors[0][snrRun]/(float)n_trials <= target_error_rate) { + if (effRate[snrRun] > (eff_tp_check*TBS)) { printf("*************\n"); printf("PUSCH test OK\n"); printf("*************\n"); From e56f28434712c4da0ac73f9b5dca9170ff8c513c Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 14 Mar 2022 15:29:10 +0000 Subject: [PATCH 028/105] Perform the channel interpolation for CSI-RS row 1 --- openair1/PHY/INIT/nr_init_ue.c | 2 +- openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c | 15 ++++++++++- openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h | 6 +++++ openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 31 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index fd9a021a80..a8db7203c7 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -373,7 +373,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) ue->nr_csi_rs_info->csi_rs_generated_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); ue->nr_csi_rs_info->csi_rs_received_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); - ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size * sizeof(int32_t)); } ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c index 0c520aabe7..5d3362a8c7 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c @@ -282,4 +282,17 @@ short filt16_middle4[16] = { 4096,8192,8192,8192,8192,8192,8192,8192,4096,0,0,0,0,0,0,0}; short filt16_end[16] = { - 4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0}; \ No newline at end of file + 4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0}; + +// CSI-RS +short filt24_start[24] = { + 12288,11605,10923,10240,9557,8875,8192,7509,6827,6144,5461,4779, + 4096,0,0,0,0,0,0,0,0,0,0,0}; + +short filt24_end[24] = { + 4096,4779,5461,6144,6827,7509,8192,8875,9557,10240,10923,11605, + 16384,16384,16384,16384,16384,16384,16384,16384,16384,16384,16384,16384}; + +short filt24_middle[24] = { + 4096,4779,5461,6144,6827,7509,8192,8875,9557,10240,10923,11605, + 12288,11605,10923,10240,9557,8875,8192,7509,6827,6144,5461,4779}; \ No newline at end of file diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h index 72d1318545..41109cb7bb 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h @@ -193,4 +193,10 @@ extern short filt8_end[8]; extern short filt16_start[16]; extern short filt16_middle4[16]; extern short filt16_end[16]; + +/*CSI-RS*/ +extern short filt24_start[24]; +extern short filt24_end[24]; +extern short filt24_middle[24]; + #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 8d339191bf..cc7906fabf 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -37,6 +37,7 @@ #include "PHY/phy_extern_nr_ue.h" #include "common/utils/nr/nr_common.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" +#include "PHY/NR_UE_ESTIMATION/filt16a_32.h" //#define NR_CSIRS_DEBUG @@ -177,9 +178,12 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, /// Channel interpolation int16_t ls_estimated[2]; + memset(csi_rs_estimated_channel_freq[ant], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); + for (int k_id = 0; k_id < nr_csi_rs_info->k_list_length; k_id++) { uint16_t k = nr_csi_rs_info->map_list[k_id]; + int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant][k]; // There are many possibilities to allocate the CSI-RS in time, which would take the implementation of many filters. // In this approach, the LS for each symbol would be different, and it would be necessary to interpolate each symbol @@ -202,7 +206,34 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, } ls_estimated[0] = (int16_t) (sum_csi_rs_ls_real / Nsymb); ls_estimated[1] = (int16_t) (sum_csi_rs_ls_imag / Nsymb); + + if( (k_id == 0) || (k_id > 0 && k < nr_csi_rs_info->map_list[k_id-1]) ) { // First occupied subcarrier case or Start of OFDM symbol case + multadd_real_vector_complex_scalar(filt24_start, ls_estimated, csi_rs_estimated_channel16, 24); + } else if( (k_id < nr_csi_rs_info->k_list_length-1 && nr_csi_rs_info->map_list[k_id+1] < k) || + (k_id == nr_csi_rs_info->k_list_length-1) ) { // End of OFDM symbol case or Last occupied subcarrier case + multadd_real_vector_complex_scalar(filt24_end, ls_estimated, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + } else { // Middle case + multadd_real_vector_complex_scalar(filt24_middle, ls_estimated, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + } } + +#ifdef NR_CSIRS_DEBUG + + uint64_t symbol_offset = csirs_config_pdu->symb_l0*frame_parms->ofdm_symbol_size; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant][symbol_offset]; + int16_t *csi_rs_estimated_channel16 = (int16_t*)&nr_csi_rs_info->csi_rs_estimated_channel_freq[ant][0]; + + for(int k = 0; kofdm_symbol_size; k++) { + LOG_I(NR_PHY, "(%4d) |\tls (%4d,%4d)\tint (%4d,%4d)\n", + k, + csi_rs_ls_estimated_channel[k<<1], + csi_rs_ls_estimated_channel[(k<<1)+1], + csi_rs_estimated_channel16[k<<1], + csi_rs_estimated_channel16[(k<<1)+1]); + } + +#endif + } return 0; From baa2e9256221367a84a5b5b239231b9df8e4d702 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Sat, 13 Nov 2021 15:44:49 +0100 Subject: [PATCH 029/105] add support for 5 MHz (15 kHz SCS) and 10 MHz (30 kHz SCS) to nr_dlsim and nr_ulsim --- openair1/PHY/INIT/nr_init.c | 7 +++++- openair1/SIMULATION/NR_PHY/dlsim.c | 13 +++++++--- openair1/SIMULATION/NR_PHY/ulsim.c | 40 ++++++++++++++++++++++-------- openair2/GNB_APP/gnb_config.c | 32 +++++++++++++++--------- openair2/RRC/NR/nr_rrc_config.c | 2 +- 5 files changed, 67 insertions(+), 27 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index bf360d347a..3507d9ab77 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -478,7 +478,12 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB, //gNB_config->subframe_config.dl_cyclic_prefix_type.value = (fp->Ncp == NORMAL) ? NFAPI_CP_NORMAL : NFAPI_CP_EXTENDED; gNB->mac_enabled = 1; - if (mu==1) { + if (mu==0) { + fp->dl_CarrierFreq = 2600000000;//from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); + fp->ul_CarrierFreq = 2600000000;//fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); + fp->nr_band = 38; + // fp->threequarter_fs= 0; + } else if (mu==1) { fp->dl_CarrierFreq = 3600000000;//from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); fp->ul_CarrierFreq = 3600000000;//fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); fp->nr_band = 78; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 680858f821..0c27ca5974 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -96,7 +96,6 @@ uint16_t sl_ahead=0; uint64_t downlink_frequency[MAX_NUM_CCs][4]; THREAD_STRUCT thread_struct; nfapi_ue_release_request_body_t release_rntis; -uint32_t N_RB_DL = 106; //Fixme: Uniq dirty DU instance, by global var, datamodel need better management instance_t DUuniqInstance=0; instance_t CUuniqInstance=0; @@ -832,10 +831,14 @@ int main(int argc, char **argv) double fs,bw; - if (mu == 1 && N_RB_DL == 217) { + if (mu == 0 && N_RB_DL == 25) { + fs = 7.68e6; + bw = 5e6; + } + else if (mu == 1 && N_RB_DL == 217) { fs = 122.88e6; bw = 80e6; - } + } else if (mu == 1 && N_RB_DL == 245) { fs = 122.88e6; bw = 90e6; @@ -856,6 +859,10 @@ int main(int argc, char **argv) fs = 61.44e6; bw = 60e6; } + else if (mu == 1 && N_RB_DL == 24) { + fs = 15.36e6; + bw = 10e6; + } else if (mu == 3 && N_RB_DL == 66) { fs = 122.88e6; bw = 100e6; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 1443ebc24f..16e406794a 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -91,7 +91,6 @@ double cpuf; uint64_t downlink_frequency[MAX_NUM_CCs][4]; THREAD_STRUCT thread_struct; nfapi_ue_release_request_body_t release_rntis; -uint32_t N_RB_DL = 106; //Fixme: Uniq dirty DU instance, by global var, datamodel need better management instance_t DUuniqInstance=0; @@ -644,16 +643,37 @@ int main(int argc, char **argv) double sampling_frequency; double bandwidth; - if (N_RB_UL >= 217) sampling_frequency = 122.88; - else if (N_RB_UL >= 106) sampling_frequency = 61.44; - else if (N_RB_UL >= 32) sampling_frequency = 32.72; - else { printf("Need at least 106 PRBs\b"); exit(-1); } - if (N_RB_UL == 273) bandwidth = 100; - else if (N_RB_UL == 217) bandwidth = 80; - else if (N_RB_UL == 106) bandwidth = 40; - else if (N_RB_UL == 32) bandwidth = 50; - else { printf("Add N_RB_UL %d\n",N_RB_UL); exit(-1); } + if (mu == 0 && N_RB_UL == 25 ) { + sampling_frequency = 7.68; + bandwidth = 5; + } + else if (mu == 1 && N_RB_UL == 273) { + sampling_frequency = 122.88; + bandwidth = 100; + } + else if (mu == 1 && N_RB_UL == 217) { + sampling_frequency = 122.88; + bandwidth = 80; + } + else if (mu == 1 && N_RB_UL == 106) { + sampling_frequency = 61.44; + bandwidth = 40; + } + else if (mu == 1 && N_RB_UL == 24) { + sampling_frequency = 15.36; + bandwidth = 10; + } + else if (mu == 3 && N_RB_UL == 32) { + sampling_frequency = 61.44; + bandwidth = 50; + } + else { + printf("Add N_RB_UL %d\n",N_RB_UL); + exit(-1); + } + LOG_I( PHY,"++++++++++++++++++++++++++++++++++++++++++++++%i+++++++++++++++++++++++++++++++++++++++++",loglvl); + if (openair0_cfg[0].threequarter_fs == 1) sampling_frequency*=.75; UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 2795c07ce7..f532f9e74a 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -213,15 +213,20 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R // *scc->n_TimingAdvanceOffset=NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n0; *scc->ssb_periodicityServingCell=NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms20; scc->dmrs_TypeA_Position=NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2; - *scc->ssbSubcarrierSpacing=NR_SubcarrierSpacing_kHz30; - *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB=641032; - *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]=78; - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA=640000; + *scc->ssbSubcarrierSpacing=mu_dl; + if (mu_dl == 0) { + *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB=520432; + *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]=38; + scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA=520000; + } else { + *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB=641032; + *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]=78; + scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA=640000; + } scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0; - scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30; - + scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=mu_dl; scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_DL; - scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth=13036; + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth=275*(N_RB_DL-1); scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing=mu_dl;//NR_SubcarrierSpacing_kHz30; *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=12; *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero=0; @@ -235,13 +240,13 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R timedomainresourceallocation1->startSymbolAndLength=57; ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, timedomainresourceallocation1); - *scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]=78; + *scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]=mu_ul?78:38; *scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA=-1; scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0; - scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30; + scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=mu_ul; scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_UL; *scc->uplinkConfigCommon->frequencyInfoUL->p_Max=20; - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth=13036; + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth=275*(N_RB_UL-1); scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing=mu_ul;//NR_SubcarrierSpacing_kHz30; scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex=98; scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM=NR_RACH_ConfigGeneric__msg1_FDM_one; @@ -277,8 +282,11 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal=-90; scc->ssb_PositionsInBurst->present=NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap; *ssb_bitmap=0xff; - scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing=NR_SubcarrierSpacing_kHz30; - scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity=NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5; + scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing=mu_dl; + if (mu_dl == 0) + scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity=NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms10; + else + scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity=NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5; scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots=7; scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols=6; scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots=2; diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index f8f05f2fe5..1e590a26b8 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -172,7 +172,7 @@ void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, } AssertFatal(bw_rb>0,"Could not find scs-SpecificCarrierList element for scs %d",scs); int bw = get_supported_band_index(scs, band, bw_rb); - AssertFatal(bw>0,"Supported band corresponding to %d RBs not found\n", bw_rb); + AssertFatal(bw>=0,"Supported band corresponding to %d RBs not found\n", bw_rb); bool supported = false; if (band>256) { From 4a9009109512688d86a705b7b5c921c670c55701 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Sat, 13 Nov 2021 15:53:27 +0100 Subject: [PATCH 030/105] fix init_timeshift_rotation() --- openair1/PHY/MODULATION/nr_modulation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c index c81a88ff30..fd3c1d394d 100644 --- a/openair1/PHY/MODULATION/nr_modulation.c +++ b/openair1/PHY/MODULATION/nr_modulation.c @@ -747,8 +747,9 @@ void init_symbol_rotation(NR_DL_FRAME_PARMS *fp) { void init_timeshift_rotation(NR_DL_FRAME_PARMS *fp) { + const int sample_offset = fp->nb_prefix_samples / fp->ofdm_offset_divisor; for (int i = 0; i < fp->ofdm_symbol_size; i++) { - double poff = -i * 2.0 * M_PI * 144.0 / 2048.0 / fp->ofdm_offset_divisor; + double poff = -i * 2.0 * M_PI * sample_offset / fp->ofdm_symbol_size; double exp_re = cos(poff); double exp_im = sin(-poff); fp->timeshift_symbol_rotation[i*2] = (int16_t)round(exp_re * 32767); From 47148e3f7d3b97c5b6f0488aabe17d62b654156a Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Sat, 13 Nov 2021 16:01:27 +0100 Subject: [PATCH 031/105] add NO_INTERP to nr_pdsch_channel_estimation() as it is in nr_pusch_channel_estimation() --- .../NR_ESTIMATION/nr_ul_channel_estimation.c | 15 ++++++++ .../nr_dl_channel_estimation.c | 34 ++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 9aaba7fb66..5fcb59c85b 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -803,6 +803,10 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; + ul_ch+=24; +#else multadd_real_vector_complex_scalar(filt8_avlip0, ch, ul_ch, @@ -820,6 +824,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ul_ch, 8); ul_ch -= 24; +#endif for (pilot_cnt=4; pilot_cnt<4*(nb_rb_pusch-1); pilot_cnt += 4) { @@ -854,6 +859,10 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; + ul_ch+=24; +#else ul_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 ul_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -875,6 +884,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ul_ch, 8); ul_ch -= 16; +#endif } // Last PRB ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; @@ -908,6 +918,10 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; + ul_ch+=24; +#else ul_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 ul_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -922,6 +936,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch, ul_ch, 8); +#endif } #ifdef DEBUG_PUSCH ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index d15a10a9d9..c1e7e7fea7 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -33,6 +33,7 @@ //#define DEBUG_PDSCH //#define DEBUG_PDCCH +#define NO_INTERP 1 int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, @@ -690,7 +691,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, k = bwp_start_subcarrier; int re_offset = k; -#ifdef DEBUG_CH +#ifdef DEBUG_PDSCH printf("PDSCH Channel Estimation : ThreadId %d, gNB_id %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",proc->thread_id, gNB_id,ch_offset,symbol_offset,ue->frame_parms.ofdm_symbol_size, ue->frame_parms.Ncp,Ns,k, symbol); #endif @@ -1243,6 +1244,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 6; ch[1] = ch_1 / 6; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else multadd_real_vector_complex_scalar(filt8_avlip0, ch, dl_ch, @@ -1260,6 +1265,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); dl_ch -= 24; +#endif for (pilot_cnt=6; pilot_cnt<6*(nb_rb_pdsch-1); pilot_cnt += 6) { @@ -1307,6 +1313,11 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 6; ch[1] = ch_1 / 6; + +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else dl_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 dl_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -1328,6 +1339,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); dl_ch -= 16; +#endif } ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; ch_1 = ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; @@ -1374,6 +1386,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 6; ch[1] = ch_1 / 6; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else dl_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 dl_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -1388,6 +1404,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch, dl_ch, 8); +#endif } else { // this is case without frequency-domain linear interpolation, just take average of LS channel estimates of 4 DMRS REs and use a common value for the whole PRB int32_t ch_0, ch_1; @@ -1423,6 +1440,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else multadd_real_vector_complex_scalar(filt8_avlip0, ch, dl_ch, @@ -1440,6 +1461,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); dl_ch -= 24; +#endif for (pilot_cnt=4; pilot_cnt<4*(nb_rb_pdsch-1); pilot_cnt += 4) { int32_t ch_0, ch_1; @@ -1475,6 +1497,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else dl_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 dl_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -1496,6 +1522,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); dl_ch -= 16; +#endif } ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; @@ -1529,6 +1556,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else dl_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 dl_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -1543,6 +1574,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch, dl_ch, 8); +#endif } #ifdef DEBUG_PDSCH dl_ch = (int16_t *)&dl_ch_estimates[p*ue->frame_parms.nb_antennas_rx+aarx][ch_offset]; From cbf57d7b3c48010854feb5d37b0a0508ee75d78b Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Thu, 18 Nov 2021 16:33:20 +0100 Subject: [PATCH 032/105] Add configuration file for 15 kHz SCS, 5 MHz BW, band 66, FDD --- .../CONF/gnb.band66.tm1.25PRB.usrpn300.conf | 266 ++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf new file mode 100644 index 0000000000..6af1356088 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf @@ -0,0 +1,266 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); + + tr_s_preference = "local_mac"; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + min_rxtxtime = 6; + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 2150 MHz + 12 PRBs@15kHz SCS (same as initial BWP), points to Subcarrier 0 of RB#10 of SSB block + absoluteFrequencySSB = 430432; + dl_frequencyBand = 66; + # this is 2150 MHz + dl_absoluteFrequencyPointA = 430000; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 0; + dl_carrierBandwidth = 25; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=25 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6600; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 0; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 0; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 66; + ul_absoluteFrequencyPointA = 350000; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 0; + ul_carrierBandwidth = 25; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 6600; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 0; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -118; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + msg1_SubcarrierSpacing = 0; +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 0x1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 0; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 0; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_INTERFACE_NAME_FOR_S1U = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 + } +); + +RUs = ( + { + local_rf = "yes"; + nb_tx = 1; + nb_rx = 1; + att_tx = 0; + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 50; + eNB_instances = [0]; + ## beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ## beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + #bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sdr_addrs = "addr=192.168.10.2,mgmt_addr=192.168.10.2,second_addr=192.168.20.2"; + clock_src = "external"; + # if_freq = 3700000000L; + # if_offset = 1000000; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_DISABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + }; + From 4fd78ce1e0e6baa76fa4747b00b3069bc1bf5197 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Thu, 18 Nov 2021 16:38:59 +0100 Subject: [PATCH 033/105] small fixes for 15 kHz SCS --- executables/nr-ru.c | 15 +++++++++++---- openair1/PHY/NR_TRANSPORT/nr_prach.c | 18 +++++++++++++----- openair1/PHY/NR_UE_TRANSPORT/nr_prach.c | 17 +++++++++++++---- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 08decf0f67..14cd9149bd 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -726,10 +726,17 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { AssertFatal(txsymb>0,"illegal txsymb %d\n",txsymb); - if(slot%(fp->slots_per_subframe/2)) - siglen = txsymb * (fp->ofdm_symbol_size + fp->nb_prefix_samples); - else - siglen = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples); + if (fp->slots_per_subframe == 1) { + if (txsymb <= 7) + siglen = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples); + else + siglen = 2 * (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 2) * (fp->ofdm_symbol_size + fp->nb_prefix_samples); + } else { + if (slot%(fp->slots_per_subframe/2)) + siglen = txsymb * (fp->ofdm_symbol_size + fp->nb_prefix_samples); + else + siglen = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples); + } //+ ru->end_of_burst_delay; flags = 3; // end of burst diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c index 4e2fbd4e71..ed8eba4940 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c @@ -175,11 +175,19 @@ void rx_nr_prach_ru(RU_t *ru, int msg1_frequencystart = ru->config.prach_config.num_prach_fd_occasions_list[numRA].k1.value; int sample_offset_slot; - if (!(slot%(fp->slots_per_subframe/2))) - sample_offset_slot = (prachStartSymbol==0?0:fp->ofdm_symbol_size*prachStartSymbol+fp->nb_prefix_samples0+fp->nb_prefix_samples*(prachStartSymbol-1)); - else - sample_offset_slot = (prachStartSymbol==0?0:prachStartSymbol*(fp->ofdm_symbol_size+fp->nb_prefix_samples)); - //to be checked for mu=0; + if (prachStartSymbol == 0) { + sample_offset_slot = 0; + } else if (fp->slots_per_subframe == 1) { + if (prachStartSymbol <= 7) + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 1) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0); + else + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 2) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0) * 2; + } else { + if (!(slot%(fp->slots_per_subframe/2))) + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 1) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0); + else + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * prachStartSymbol; + } LOG_D(PHY,"frame %d, slot %d: doing rx_nr_prach_ru for format %d, numRA %d, prachStartSymbol %d, prachOccasion %d\n",frame,slot,prachFormat,numRA,prachStartSymbol,prachOccasion); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index 24299fd788..70240b8468 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -102,10 +102,19 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ nrUE_config->prach_config.num_prach_fd_occasions_list[fd_occasion].prach_root_sequence_index, ue->X_u); - if (slot % (fp->slots_per_subframe / 2) == 0) - sample_offset_slot = (prachStartSymbol==0?0:fp->ofdm_symbol_size*prachStartSymbol+fp->nb_prefix_samples0+fp->nb_prefix_samples*(prachStartSymbol-1)); - else - sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * prachStartSymbol; + if (prachStartSymbol == 0) { + sample_offset_slot = 0; + } else if (fp->slots_per_subframe == 1) { + if (prachStartSymbol <= 7) + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 1) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0); + else + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 2) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0) * 2; + } else { + if (slot % (fp->slots_per_subframe / 2) == 0) + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 1) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0); + else + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * prachStartSymbol; + } prach_start = fp->get_samples_slot_timestamp(slot, fp, 0) + sample_offset_slot; From 9e90b8f22c32ebf635596473378af2f93cd9c7f5 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 13 Dec 2021 16:47:44 +0100 Subject: [PATCH 034/105] remove unneeded global arrays ul_ch_ptrs_estimates, ul_ch_ptrs_estimates_ext, dl_ch_ptrs_estimates and dl_ch_ptrs_estimates_ext --- openair1/PHY/INIT/nr_init.c | 8 -------- openair1/PHY/INIT/nr_init_ue.c | 4 ---- openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c | 1 - openair1/PHY/NR_REFSIG/ptrs_nr.c | 9 ++++----- openair1/PHY/NR_REFSIG/ptrs_nr.h | 1 - openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 1 - openair1/PHY/defs_gNB.h | 8 -------- openair1/PHY/defs_nr_UE.h | 4 ---- 8 files changed, 4 insertions(+), 32 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 3507d9ab77..3139da15cd 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -258,8 +258,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, pusch_vars[ULSCH_id]->rxdataF_ext2 = (int32_t **)malloc16(Prx*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_estimates = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_estimates_ext = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); - pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); - pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ptrs_phase_per_slot = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_estimates_time = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->rxdataF_comp = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); @@ -277,8 +275,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, pusch_vars[ULSCH_id]->ul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); pusch_vars[ULSCH_id]->ul_ch_estimates_time[i] = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size ); - pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); // max intensity in freq is 1 sc every 2 RBs - pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); pusch_vars[ULSCH_id]->ptrs_phase_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot); // symbols per slot pusch_vars[ULSCH_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); pusch_vars[ULSCH_id]->ul_ch_mag0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); @@ -399,8 +395,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates[i]); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i]); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time[i]); - free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates[i]); - free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i]); free_and_zero(pusch_vars[ULSCH_id]->ptrs_phase_per_slot[i]); free_and_zero(pusch_vars[ULSCH_id]->rxdataF_comp[i]); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag0[i]); @@ -413,8 +407,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext); - free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates); - free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext); free_and_zero(pusch_vars[ULSCH_id]->ptrs_phase_per_slot); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time); free_and_zero(pusch_vars[ULSCH_id]->ul_valid_re_per_slot); diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index a27c541c80..5c6780c67d 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -79,7 +79,6 @@ void phy_init_nr_ue__PDSCH(NR_UE_PDSCH *const pdsch, pdsch->dl_ch_magr0 = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); pdsch->ptrs_phase_per_slot = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); pdsch->ptrs_re_per_slot = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->dl_ch_ptrs_estimates_ext = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); // the allocated memory size is fixed: AssertFatal( fp->nb_antennas_rx <= 4, "nb_antennas_rx > 4" );//Extend the max number of UE Rx antennas to 4 @@ -89,7 +88,6 @@ void phy_init_nr_ue__PDSCH(NR_UE_PDSCH *const pdsch, pdsch->rxdataF_uespec_pilots[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * fp->N_RB_DL*12); pdsch->ptrs_phase_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * 14 ); pdsch->ptrs_re_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * 14); - pdsch->dl_ch_ptrs_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * num); pdsch->rho[i] = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*NR_MAX_NB_LAYERS*sizeof(int32_t *) ); for (int j=0; jrxdataF_uespec_pilots[i]); free_and_zero(pdsch->ptrs_phase_per_slot[i]); free_and_zero(pdsch->ptrs_re_per_slot[i]); - free_and_zero(pdsch->dl_ch_ptrs_estimates_ext[i]); free_and_zero(pdsch->rho[i]); } free_and_zero(pdsch->pmi_ext); @@ -151,7 +148,6 @@ void phy_term_nr_ue__PDSCH(NR_UE_PDSCH* pdsch, const NR_DL_FRAME_PARMS *const fp free_and_zero(pdsch->dl_ch_magr0); free_and_zero(pdsch->ptrs_phase_per_slot); free_and_zero(pdsch->ptrs_re_per_slot); - free_and_zero(pdsch->dl_ch_ptrs_estimates_ext); } void phy_init_nr_ue_PUSCH(NR_UE_PUSCH *const pusch, diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 5fcb59c85b..7fda99a2dd 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -1043,7 +1043,6 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, /*------------------------------------------------------------------------------------------------------- */ nr_ptrs_cpe_estimation(*K_ptrs,*ptrsReOffset,*dmrsConfigType,*nb_rb, rel15_ul->rnti, - (int16_t *)&gNB->pusch_vars[ulsch_id]->ul_ch_ptrs_estimates_ext[aarx][symbol*nb_re_pusch], nr_tti_rx, symbol,frame_parms->ofdm_symbol_size, (int16_t*)&gNB->pusch_vars[ulsch_id]->rxdataF_comp[aarx][(symbol * nb_re_pusch)], diff --git a/openair1/PHY/NR_REFSIG/ptrs_nr.c b/openair1/PHY/NR_REFSIG/ptrs_nr.c index 40a6a56611..e6db1783a4 100644 --- a/openair1/PHY/NR_REFSIG/ptrs_nr.c +++ b/openair1/PHY/NR_REFSIG/ptrs_nr.c @@ -230,7 +230,6 @@ int8_t get_next_estimate_in_slot(uint16_t ptrsSymbPos,uint16_t dmrsSymbPos, ui * dmrsConfigType: DMRS configuration type * nb_rb : No. of resource blocks * rnti : RNTI - * ptrs_ch_p : pointer to ptrs channel structure * Ns : * symbol : OFDM symbol * ofdm_symbol_size: OFDM Symbol Size @@ -249,7 +248,6 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, uint8_t dmrsConfigType, uint16_t nb_rb, uint16_t rnti, - int16_t *ptrs_ch_p, unsigned char Ns, unsigned char symbol, uint16_t ofdm_symbol_size, @@ -269,6 +267,7 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, } uint16_t sc_per_symbol = (nb_rb + K_ptrs - 1)/K_ptrs; struct complex16 ptrs_p[(1 + sc_per_symbol/4)*4]; + struct complex16 ptrs_ch_p[(1 + sc_per_symbol/4)*4]; struct complex16 dmrs_comp_p[(1 + sc_per_symbol/4)*4]; double abs = 0.0; double real = 0.0; @@ -306,13 +305,13 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, *ptrs_sc = re_cnt; /*Multiple compensated data with conj of PTRS */ - mult_cpx_vector((int16_t*)dmrs_comp_p, (int16_t*)ptrs_p, ptrs_ch_p,(1 + sc_per_symbol/4)*4,15); // 2^15 shifted + mult_cpx_vector((int16_t*)dmrs_comp_p, (int16_t*)ptrs_p, (int16_t*)ptrs_ch_p, (1 + sc_per_symbol/4)*4, 15); // 2^15 shifted /* loop over all ptrs sub carriers in a symbol */ /* sum the error vector */ for(int i = 0;i < sc_per_symbol; i++) { - real+= ptrs_ch_p[(2*i)]; - imag+= ptrs_ch_p[(2*i)+1]; + real += ptrs_ch_p[i].r; + imag += ptrs_ch_p[i].i; } #ifdef DEBUG_PTRS alpha = atan(imag/real); diff --git a/openair1/PHY/NR_REFSIG/ptrs_nr.h b/openair1/PHY/NR_REFSIG/ptrs_nr.h index 41acde0d06..f46c5c7aee 100644 --- a/openair1/PHY/NR_REFSIG/ptrs_nr.h +++ b/openair1/PHY/NR_REFSIG/ptrs_nr.h @@ -96,7 +96,6 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, uint8_t dmrsConfigType, uint16_t nb_rb, uint16_t rnti, - int16_t *ptrs_ch_p, unsigned char Ns, unsigned char symbol, uint16_t ofdm_symbol_size, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index c1e7e7fea7..8bc877239c 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -1704,7 +1704,6 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, /*------------------------------------------------------------------------------------------------------- */ nr_ptrs_cpe_estimation(*K_ptrs,*ptrsReOffset,*dmrsConfigType,*nb_rb, rnti, - (int16_t *)&pdsch_vars[gNB_id]->dl_ch_ptrs_estimates_ext[aarx][symbol*nb_re_pdsch], nr_slot_rx, symbol,frame_parms->ofdm_symbol_size, (int16_t*)&pdsch_vars[gNB_id]->rxdataF_comp0[aarx][(symbol * nb_re_pdsch)], diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index c24bd81549..db6b8b2b70 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -452,14 +452,6 @@ typedef struct { /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ int32_t **ul_ch_estimates_ext; - /// \brief Hold the PTRS phase estimates in frequency domain. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **ul_ch_ptrs_estimates; - /// \brief Uplink phase estimates extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **ul_ch_ptrs_estimates_ext; /// \brief Holds the compensated signal. /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index f4b49ececa..1cbe724f33 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -290,10 +290,6 @@ typedef struct { /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..168*N_RB_DL[ int32_t **dl_ch_estimates_ext; - /// \brief Downlink channel estimates extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_ptrs_estimates_ext; /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. For the SIC receiver we need to store the history of this for each harq process and round /// - first index: ? [0..7] (hard coded) accessed via \c harq_pid /// - second index: ? [0..7] (hard coded) accessed via \c round From d104ef73b71de449f45952604dab6bd96d238c13 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 13 Dec 2021 16:50:51 +0100 Subject: [PATCH 035/105] gNB: fix memory allocations for PUSCH in phy_init_nr_gNB() --- openair1/PHY/INIT/nr_init.c | 33 ++++++++++++++++++--------------- openair1/PHY/defs_gNB.h | 4 ---- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 3139da15cd..afb5614cbd 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -252,10 +252,16 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, int N_RB_UL = cfg->carrier_config.ul_grid_size[cfg->ssb_config.scs_common.value].value; int n_buf = Prx*max_ul_mimo_layers; + int nb_re_pusch = N_RB_UL * NR_NB_SC_PER_RB; +#ifdef __AVX2__ + int nb_re_pusch2 = nb_re_pusch + (nb_re_pusch&7); +#else + int nb_re_pusch2 = nb_re_pusch; +#endif + for (int ULSCH_id=0; ULSCH_idnumber_of_nr_ulsch_max; ULSCH_id++) { pusch_vars[ULSCH_id] = (NR_gNB_PUSCH *)malloc16_clear( sizeof(NR_gNB_PUSCH) ); pusch_vars[ULSCH_id]->rxdataF_ext = (int32_t **)malloc16(Prx*sizeof(int32_t *) ); - pusch_vars[ULSCH_id]->rxdataF_ext2 = (int32_t **)malloc16(Prx*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_estimates = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_estimates_ext = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ptrs_phase_per_slot = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); @@ -265,23 +271,22 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, pusch_vars[ULSCH_id]->ul_ch_magb0 = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_mag = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_magb = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); - pusch_vars[ULSCH_id]->rho = (int32_t **)malloc16_clear(n_buf*sizeof(int32_t*) ); + pusch_vars[ULSCH_id]->rho = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); for (i=0; irxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); - pusch_vars[ULSCH_id]->rxdataF_ext2[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); } for (i=0; iul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); - pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); - pusch_vars[ULSCH_id]->ul_ch_estimates_time[i] = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size ); + pusch_vars[ULSCH_id]->ul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_estimates_time[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size ); pusch_vars[ULSCH_id]->ptrs_phase_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot); // symbols per slot - pusch_vars[ULSCH_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); - pusch_vars[ULSCH_id]->ul_ch_mag0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); - pusch_vars[ULSCH_id]->ul_ch_magb0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); - pusch_vars[ULSCH_id]->ul_ch_mag[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); - pusch_vars[ULSCH_id]->ul_ch_magb[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); - pusch_vars[ULSCH_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->N_RB_UL*12*7*2) ); + pusch_vars[ULSCH_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_mag0[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_magb0[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_mag[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_magb[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); } pusch_vars[ULSCH_id]->llr = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); // [hna] 6144 is LTE and (8*((3*8*6144)+12)) is not clear pusch_vars[ULSCH_id]->ul_valid_re_per_slot = (int16_t *)malloc16_clear( sizeof(int16_t)*fp->symbols_per_slot); @@ -389,7 +394,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) for (int ULSCH_id=0; ULSCH_idnumber_of_nr_ulsch_max; ULSCH_id++) { for (int i = 0; i < Prx; i++) { free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext[i]); - free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2[i]); } for (int i = 0; i < n_buf; i++) { free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates[i]); @@ -404,7 +408,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(pusch_vars[ULSCH_id]->rho[i]); } free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext); - free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext); free_and_zero(pusch_vars[ULSCH_id]->ptrs_phase_per_slot); diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index db6b8b2b70..50b79289ed 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -436,10 +436,6 @@ typedef struct { /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..2*ofdm_symbol_size[ int32_t **rxdataF_ext; - /// \brief Holds the received data in the frequency domain for the allocated RBs in normal format. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index (definition from phy_init_lte_eNB()): ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **rxdataF_ext2; /// \brief Hold the channel estimates in time domain based on DRS. /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..4*ofdm_symbol_size[ From 31cd31826d7bcdbc1caee8db2533eb7a98a434e2 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 28 Feb 2022 11:17:11 +0100 Subject: [PATCH 036/105] move get_dft() and get_idft() from pss_nr.c to tools_defs.h --- openair1/PHY/MODULATION/slot_fep_nr.c | 47 +--------- openair1/PHY/NR_REFSIG/pss_nr.h | 2 - openair1/PHY/NR_UE_TRANSPORT/pss_nr.c | 118 ------------------------- openair1/PHY/TOOLS/tools_defs.h | 119 ++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 164 deletions(-) diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index eb26dfc02b..139b730ce1 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -34,47 +34,6 @@ #define LOG_I(A,B...) printf(A) #endif*/ -dft_size_idx_t get_dft_size_idx(uint16_t ofdm_symbol_size) -{ - switch (ofdm_symbol_size) { - case 128: - return DFT_128; - - case 256: - return DFT_256; - - case 512: - return DFT_512; - - case 1024: - return DFT_1024; - - case 1536: - return DFT_1536; - - case 2048: - return DFT_2048; - - case 3072: - return DFT_3072; - - case 4096: - return DFT_4096; - - case 6144: - return DFT_6144; - - case 8192: - return DFT_8192; - - default: - printf("unsupported ofdm symbol size \n"); - assert(0); - } - - return DFT_SIZE_IDXTABLESIZE; -} - int nr_slot_fep(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, unsigned char symbol, @@ -96,7 +55,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, nb_prefix_samples0 = frame_parms->nb_prefix_samples; } - dft_size_idx_t dftsize = get_dft_size_idx(frame_parms->ofdm_symbol_size); + dft_size_idx_t dftsize = get_dft(frame_parms->ofdm_symbol_size); // This is for misalignment issues int32_t tmp_dft_in[8192] __attribute__ ((aligned (32))); @@ -195,7 +154,7 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, } unsigned int frame_length_samples = frame_parms->samples_per_frame; - dft_size_idx_t dftsize = get_dft_size_idx(frame_parms->ofdm_symbol_size); + dft_size_idx_t dftsize = get_dft(frame_parms->ofdm_symbol_size); // This is for misalignment issues int32_t tmp_dft_in[8192] __attribute__ ((aligned (32))); @@ -289,7 +248,7 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, unsigned int nb_prefix_samples = frame_parms->nb_prefix_samples; unsigned int nb_prefix_samples0 = frame_parms->nb_prefix_samples0; - dft_size_idx_t dftsize = get_dft_size_idx(frame_parms->ofdm_symbol_size); + dft_size_idx_t dftsize = get_dft(frame_parms->ofdm_symbol_size); // This is for misalignment issues int32_t tmp_dft_in[8192] __attribute__ ((aligned (32))); diff --git a/openair1/PHY/NR_REFSIG/pss_nr.h b/openair1/PHY/NR_REFSIG/pss_nr.h index b32d48a2e9..1259cbe790 100644 --- a/openair1/PHY/NR_REFSIG/pss_nr.h +++ b/openair1/PHY/NR_REFSIG/pss_nr.h @@ -126,8 +126,6 @@ EXTERN time_stats_t generic_time[TIME_LAST]; /************** FUNCTION ******************************************/ -idft_size_idx_t get_idft(int ofdm_symbol_size); -dft_size_idx_t get_dft(int ofdm_symbol_size); void init_context_synchro_nr(NR_DL_FRAME_PARMS *frame_parms_ue); void free_context_synchro_nr(void); void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue); diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 88bdc3a9cd..158c82e585 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -48,126 +48,8 @@ #include "PHY/NR_REFSIG/sss_nr.h" #include "PHY/NR_UE_TRANSPORT/cic_filter_nr.h" -/******************************************************************* -* -* NAME : get_idft -* -* PARAMETERS : size of ofdm symbol -* -* RETURN : index pointing to the dft func in the dft library -* -* DESCRIPTION : get idft function depending of ofdm size -* -*********************************************************************/ - //#define DBG_PSS_NR -idft_size_idx_t get_idft(int ofdm_symbol_size) -{ - - - switch (ofdm_symbol_size) { - case 128: - return IDFT_128; - break; - - case 256: - return IDFT_256; - break; - - case 512: - return IDFT_512; - break; - - case 1024: - return IDFT_1024; - break; - - case 1536: - return IDFT_1536; - break; - - case 2048: - return IDFT_2048; - break; - - case 3072: - return IDFT_3072; - break; - - case 4096: - return IDFT_4096; - break; - - case 8192: - return IDFT_8192; - break; - - default: - printf("function get_idft : unsupported ofdm symbol size \n"); - assert(0); - break; - } - return IDFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function -} - -/******************************************************************* -* -* NAME : get_dft -* -* PARAMETERS : size of ofdm symbol -* -* RETURN : function for discrete fourier transform -* -* DESCRIPTION : get dft function depending of ofdm size -* -*********************************************************************/ - -dft_size_idx_t get_dft(int ofdm_symbol_size) -{ - - - switch (ofdm_symbol_size) { - case 128: - return DFT_128; - break; - - case 256: - return DFT_256; - break; - - case 512: - return DFT_512; - break; - - case 1024: - return DFT_1024; - break; - - case 1536: - return DFT_1536; - break; - - case 2048: - return DFT_2048; - break; - - case 4096: - return DFT_4096; - break; - - case 8192: - return DFT_8192; - break; - - default: - printf("function get_dft : unsupported ofdm symbol size \n"); - assert(0); - break; - } - return DFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function; -} - /******************************************************************* * * NAME : generate_pss_nr diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h index 966e93440e..55cbcf6645 100644 --- a/openair1/PHY/TOOLS/tools_defs.h +++ b/openair1/PHY/TOOLS/tools_defs.h @@ -33,7 +33,9 @@ extern "C" { #endif +#include #include +#include #include "PHY/sse_intrin.h" #define CEILIDIV(a,b) ((a+b-1)/b) @@ -322,6 +324,65 @@ adftfunc_t dft_ftab[]={ }; #endif +/******************************************************************* +* +* NAME : get_dft +* +* PARAMETERS : size of ofdm symbol +* +* RETURN : function for discrete fourier transform +* +* DESCRIPTION : get dft function depending of ofdm size +* +*********************************************************************/ +static inline +dft_size_idx_t get_dft(int ofdm_symbol_size) +{ + switch (ofdm_symbol_size) { + case 128: + return DFT_128; + case 256: + return DFT_256; + case 512: + return DFT_512; + case 1024: + return DFT_1024; + case 1536: + return DFT_1536; + case 2048: + return DFT_2048; + case 3072: + return DFT_3072; + case 4096: + return DFT_4096; + case 6144: + return DFT_6144; + case 8192: + return DFT_8192; + case 9216: + return DFT_9216; + case 12288: + return DFT_12288; + case 18432: + return DFT_18432; + case 24576: + return DFT_24576; + case 36864: + return DFT_36864; + case 49152: + return DFT_49152; + case 73728: + return DFT_73728; + case 98304: + return DFT_98304; + default: + printf("function get_dft : unsupported ofdm symbol size \n"); + assert(0); + break; + } + return DFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function; +} + typedef enum idft_size_idx { IDFT_128, IDFT_256, IDFT_512, IDFT_1024, IDFT_1536, IDFT_2048, IDFT_3072, IDFT_4096, IDFT_6144, IDFT_8192, IDFT_9216, IDFT_12288, IDFT_18432, IDFT_24576, IDFT_36864, IDFT_49152, @@ -336,6 +397,64 @@ aidftfunc_t idft_ftab[]={ }; #endif +/******************************************************************* +* +* NAME : get_idft +* +* PARAMETERS : size of ofdm symbol +* +* RETURN : index pointing to the dft func in the dft library +* +* DESCRIPTION : get idft function depending of ofdm size +* +*********************************************************************/ +static inline +idft_size_idx_t get_idft(int ofdm_symbol_size) +{ + switch (ofdm_symbol_size) { + case 128: + return IDFT_128; + case 256: + return IDFT_256; + case 512: + return IDFT_512; + case 1024: + return IDFT_1024; + case 1536: + return IDFT_1536; + case 2048: + return IDFT_2048; + case 3072: + return IDFT_3072; + case 4096: + return IDFT_4096; + case 6144: + return IDFT_6144; + case 8192: + return IDFT_8192; + case 9216: + return IDFT_9216; + case 12288: + return IDFT_12288; + case 18432: + return IDFT_18432; + case 24576: + return IDFT_24576; + case 36864: + return IDFT_36864; + case 49152: + return IDFT_49152; + case 73728: + return IDFT_73728; + case 98304: + return IDFT_98304; + default: + printf("function get_idft : unsupported ofdm symbol size \n"); + assert(0); + break; + } + return IDFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function +} /*!\fn int32_t rotate_cpx_vector(int16_t *x,int16_t *alpha,int16_t *y,uint32_t N,uint16_t output_shift) From 15e82e48114f787f2896002d4fe193cb1eee789e Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 28 Feb 2022 11:19:26 +0100 Subject: [PATCH 037/105] add support for mu==0 to nr_prachsim --- openair1/SIMULATION/NR_PHY/prachsim.c | 25 +++++++++---------- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index bc4f4a0b60..4ef32fc3f4 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -234,7 +234,7 @@ int main(int argc, char **argv){ int i, l, aa, aarx, **txdata, trial, n_frames = 1, prach_start, rx_prach_start; //, ntrials=1; int N_RB_UL = 106, delay = 0, NCS_config = 13, rootSequenceIndex = 1, threequarter_fs = 0, mu = 1, fd_occasion = 0, loglvl = OAILOG_INFO, numRA = 0, prachStartSymbol = 0; uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format=0; - uint8_t frame = 1, slot=19, slot_gNB=19, config_index = 98, prach_sequence_length = 1, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; + uint8_t config_index = 98, prach_sequence_length = 1, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; uint16_t Nid_cell = 0, preamble_tx = 0, preamble_delay, format, format0, format1; uint32_t tx_lev = 10000, prach_errors = 0; //,tx_lev_dB; uint64_t SSB_positions = 0x01; @@ -530,7 +530,7 @@ int main(int argc, char **argv){ frame_parms->N_RB_UL = N_RB_UL; frame_parms->threequarter_fs = threequarter_fs; frame_parms->frame_type = TDD; - frame_parms->freq_range = (mu==1 ? nr_FR1 : nr_FR2); + frame_parms->freq_range = (mu != 3 ? nr_FR1 : nr_FR2); frame_parms->numerology_index = mu; nr_phy_config_request_sim(gNB, N_RB_UL, N_RB_UL, mu, Nid_cell, SSB_positions); @@ -540,9 +540,11 @@ int main(int argc, char **argv){ frame_parms->numerology_index, frame_parms->N_RB_UL*(180e3)*(1 << frame_parms->numerology_index)); - uint8_t subframe = slot/frame_parms->slots_per_subframe; + uint8_t frame = 1; + uint8_t subframe = 9; + uint8_t slot = 10 * frame_parms->slots_per_subframe - 1; - if (config_index<67 && mu==1) { prach_sequence_length=0; slot = subframe*2; slot_gNB = 1+(subframe*2); } + if (config_index<67 && mu != 3) { prach_sequence_length=0; slot = subframe * frame_parms->slots_per_subframe; } uint16_t N_ZC = prach_sequence_length == 0 ? 839 : 139; printf("Config_index %d, prach_sequence_length %d\n",config_index,prach_sequence_length); @@ -563,9 +565,11 @@ int main(int argc, char **argv){ ru->gNB_list[0] = gNB; gNB->gNB_config.carrier_config.num_tx_ant.value = 1; gNB->gNB_config.carrier_config.num_rx_ant.value = 1; - if (mu==1) + if (mu == 0) + gNB->gNB_config.tdd_table.tdd_period.value = 7; + else if (mu == 1) gNB->gNB_config.tdd_table.tdd_period.value = 6; - else if (mu==3) + else if (mu == 3) gNB->gNB_config.tdd_table.tdd_period.value = 3; else { printf("unsupported numerology %d\n",mu); @@ -579,7 +583,7 @@ int main(int argc, char **argv){ int ret = get_nr_prach_info_from_index(config_index, (int)frame, - (int)slot_gNB, + (int)slot, absoluteFrequencyPointA, mu, frame_parms->frame_type, @@ -711,12 +715,7 @@ int main(int argc, char **argv){ bw = N_RB_UL*(180e3)*(1 << frame_parms->numerology_index); AssertFatal(bw<=122.88e6,"Illegal channel bandwidth %f (mu %d,N_RB_UL %d)\n", bw, frame_parms->numerology_index, N_RB_UL); - if (bw <= 30.72e6) - fs = 30.72e6; - else if (bw <= 61.44e6) - fs = 61.44e6; - else if (bw <= 122.88e6) - fs = 122.88e6; + fs = frame_parms->samples_per_subframe * 1e3; LOG_I(PHY,"Running with bandwidth %f Hz, fs %f samp/s, FRAME_LENGTH_COMPLEX_SAMPLES %d\n",bw,fs,FRAME_LENGTH_COMPLEX_SAMPLES); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 94b7ab18bf..340976e4bb 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1685,7 +1685,7 @@ int get_nr_prach_info_from_index(uint8_t index, } if ( (s_map>>subframe)&0x01 ) { *N_RA_slot = table_6_3_3_2_3_prachConfig_Index[index][6]; // Number of RACH slots within a subframe - if (mu == 1) { + if (mu == 1 && index >= 67) { if ( (*N_RA_slot <= 1) && (slot%2 == 0) ) return 0; // no prach in even slots @ 30kHz for 1 prach per subframe } From 8f632a7c69db971273fcf42d53f8b79e6f0210aa Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 28 Feb 2022 11:22:58 +0100 Subject: [PATCH 038/105] NR_UE: generalize generate_nr_prach() and add support for mu==0 --- openair1/PHY/NR_UE_TRANSPORT/nr_prach.c | 1063 +++++------------------ 1 file changed, 210 insertions(+), 853 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index 70240b8468..121a182061 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -67,7 +67,7 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ uint8_t Mod_id, fd_occasion, preamble_index, restricted_set, not_found; uint16_t rootSequenceIndex, prach_fmt_id, NCS, *prach_root_sequence_map, preamble_offset = 0; uint16_t preamble_shift = 0, preamble_index0, n_shift_ra, n_shift_ra_bar, d_start=INT16_MAX, numshift, N_ZC, u, offset, offset2, first_nonzero_root_idx; - int16_t prach_tmp[98304*2*4] __attribute__((aligned(32))); + int16_t prach_tmp[(4688+4*24576)*4*2] __attribute__((aligned(32))); int16_t Ncp = 0, amp, *prach, *prach2, *prachF, *Xu; int32_t Xu_re, Xu_im; @@ -238,10 +238,139 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ preamble_offset, first_nonzero_root_idx); - Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx]; + // Ncp and dftlen here is given in terms of T_s wich is 30.72MHz sampling + if (prach_sequence_length == 0) { + switch (prach_fmt_id) { + case 0: + Ncp = 3168; + dftlen = 24576; + break; - #if defined (PRACH_WRITE_OUTPUT_DEBUG) - LOG_M("X_u.m", "X_u", (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx], N_ZC, 1, 1); + case 1: + Ncp = 21024; + dftlen = 24576; + break; + + case 2: + Ncp = 4688; + dftlen = 24576; + break; + + case 3: + Ncp = 3168; + dftlen = 6144; + break; + + default: + AssertFatal(1==0, "Illegal PRACH format %d for sequence length 839\n", prach_fmt_id); + break; + } + } else { + switch (prach_fmt_id) { + case 4: //A1 + Ncp = 288 >> mu; + break; + + case 5: //A2 + Ncp = 576 >> mu; + break; + + case 6: //A3 + Ncp = 864 >> mu; + break; + + case 7: //B1 + Ncp = 216 >> mu; + break; + + /* + case 4: //B2 + Ncp = 360 >> mu; + break; + + case 5: //B3 + Ncp = 504 >> mu; + break; + */ + + case 8: //B4 + Ncp = 936 >> mu; + break; + + case 9: //C0 + Ncp = 1240 >> mu; + break; + + case 10: //C2 + Ncp = 2048 >> mu; + break; + + default: + AssertFatal(1==0,"Unknown PRACH format ID %d\n", prach_fmt_id); + break; + } + dftlen = 2048 >> mu; + } + + //actually what we should be checking here is how often the current prach crosses a 0.5ms boundary. I am not quite sure for which paramter set this would be the case, so I will ignore it for now and just check if the prach starts on a 0.5ms boundary + if(fp->numerology_index == 0) { + if (prachStartSymbol == 0 || prachStartSymbol == 7) + Ncp += 16; + } + else { + if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) + Ncp += 16; + } + + switch(fp->samples_per_subframe) { + case 7680: + // 5 MHz @ 7.68 Ms/s + Ncp >>= 2; + dftlen >>= 2; + break; + + case 15360: + // 10, 15 MHz @ 15.36 Ms/s + Ncp >>= 1; + dftlen >>= 1; + break; + + case 30720: + // 20, 25, 30 MHz @ 30.72 Ms/s + Ncp = Ncp; + dftlen = dftlen; + break; + + case 46080: + // 40 MHz @ 46.08 Ms/s + Ncp = (Ncp*3)/2; + dftlen = (dftlen*3)/2; + break; + + case 61440: + // 40, 50, 60 MHz @ 61.44 Ms/s + Ncp <<= 1; + dftlen <<= 1; + break; + + case 92160: + // 50, 60, 70, 80, 90 MHz @ 92.16 Ms/s + Ncp *= 3; + dftlen *= 3; + break; + + case 122880: + // 70, 80, 90, 100 MHz @ 122.88 Ms/s + Ncp <<= 2; + dftlen <<= 2; + break; + + default: + AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); + } + + #ifdef NR_PRACH_DEBUG + LOG_I(PHY, "PRACH [UE %d] Ncp %d, dftlen %d \n", Mod_id, Ncp, dftlen); #endif /******************************************************** @@ -258,99 +387,11 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ * *********************************************************/ - if (mu==1) { - switch(fp->samples_per_subframe) { - case 15360: - // 10, 15 MHz @ 15.36 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 12288; - if (prach_fmt_id == 3) - dftlen = 3072; - } else { // 839 sequence - dftlen = 512; - } - break; - - case 30720: - // 20, 25, 30 MHz @ 30.72 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 24576; - if (prach_fmt_id == 3) - dftlen = 6144; - } else { // 839 sequence - dftlen = 1024; - } - break; - - case 46080: - // 40 MHz @ 46.08 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 36864; - if (prach_fmt_id == 3) - dftlen = 9216; - } else { // 839 sequence - dftlen = 1536; - } - break; - - case 61440: - // 40, 50, 60 MHz @ 61.44 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 49152; - if (prach_fmt_id == 3) - dftlen = 12288; - } else { // 839 sequence - dftlen = 2048; - } - break; - - case 92160: - // 50, 60, 70, 80, 90 MHz @ 92.16 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 73728; - if (prach_fmt_id == 3) - dftlen = 18432; - } else { // 839 sequence - dftlen = 3072; - } - break; - - case 122880: - // 70, 80, 90, 100 MHz @ 122.88 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 98304; - if (prach_fmt_id == 3) - dftlen = 24576; - } else { // 839 sequence - dftlen = 4096; - } - break; - - default: - AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); - } - } - else if (mu==3) { - if (fp->threequarter_fs) - AssertFatal(1==0,"3/4 sampling not supported for numerology %d\n",mu); - - if (prach_sequence_length == 0) - AssertFatal(1==0,"long prach not supported for numerology %d\n",mu); - - if (fp->N_RB_UL == 32) - dftlen=512; - else if (fp->N_RB_UL == 66) - dftlen=1024; - else - AssertFatal(1==0,"N_RB_UL %d not support for numerology %d\n",fp->N_RB_UL,mu); - } + Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx]; + #if defined (PRACH_WRITE_OUTPUT_DEBUG) + LOG_M("X_u.m", "X_u", (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx], N_ZC, 1, 1); + #endif for (offset=0,offset2=0; offsetnumerology_index == 0) { - if (prachStartSymbol == 0 || prachStartSymbol == 7) - use_extended_prach_prefix = 1; - } - else { - if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) - use_extended_prach_prefix = 1; - } - - if (mu == 3) { - switch (fp->samples_per_subframe) { - case 61440: // 32 PRB case, 61.44 Msps - Ncp<<=1; //to account for 61.44Mbps - // This is after cyclic prefix - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0) - AssertFatal(1==0,"no long PRACH for this PRACH size %d\n",fp->N_RB_UL); - else { - if (use_extended_prach_prefix) - Ncp+=32; // 16*kappa, kappa=2 for 61.44Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_512,prachF,prach2,1); - // here we have |empty | Prach512 | - if (prach_fmt_id != 9) { - memmove(prach2+(512<<1),prach2,(512<<2)); - prach_len = (512*2)+Ncp; - } - else prach_len = (512*1)+Ncp; - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have |Prefix | Prach512 | Prach512 (if ! 0xc0) | - } else if (prach_fmt_id == 5) { // 6x512 - idft(IDFT_512,prachF,prach2,1); - // here we have |empty | Prach512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have |empty | Prach512 | Prach512| empty512 | empty512 | - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have |Prefix | Prach512 | - prach_len = (512*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x512 - idft(IDFT_512,prachF,prach2,1); - // here we have |empty | Prach512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have |empty | Prach512 | Prach512| empty512 | empty512 | empty512 | empty512 - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | empty512 | empty512 - memmove(prach2+(512<<3),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512 - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have |Prefix | Prach512 | - prach_len = (512*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x512 - idft(IDFT_512,prachF,prach2,1); - // here we have |empty | Prach512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have |empty | Prach512 | Prach512| empty512 | empty512 | empty512 | empty512 - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | empty512 | empty512 - memmove(prach2+(512<<3),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512 - memmove(prach2+(512<<1)*6,prach2,(512<<2)*6); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512| - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have |Prefix | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512| - prach_len = (512*12)+Ncp; - } - } - break; - - case 122880: // 66 PRB case, 122.88 Msps - Ncp<<=2; //to account for 122.88Mbps - // This is after cyclic prefix - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0) - AssertFatal(1==0,"no long PRACH for this PRACH size %d\n",fp->N_RB_UL); - else { - if (use_extended_prach_prefix) - Ncp+=64; // 16*kappa, kappa=4 for 122.88Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_1024,prachF,prach2,1); - // here we have |empty | Prach1024 | - if (prach_fmt_id != 9) { - memmove(prach2+(1024<<1),prach2,(1024<<2)); - prach_len = (1024*2)+Ncp; - } - else prach_len = (1024*1)+Ncp; - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have |Prefix | Prach1024 | Prach1024 (if ! 0xc0) | - } else if (prach_fmt_id == 5) { // 6x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have |empty | Prach1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have |empty | Prach1024 | Prach1024| empty1024 | empty1024 | - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have |Prefix | Prach1024 | - prach_len = (1024*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have |empty | Prach1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have |empty | Prach1024 | Prach1024| empty1024 | empty1024 | empty1024 | empty1024 - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | empty1024 | empty1024 - memmove(prach2+(1024<<3),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024 - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have |Prefix | Prach1024 | - prach_len = (1024*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have |empty | Prach1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have |empty | Prach1024 | Prach1024| empty1024 | empty1024 | empty1024 | empty1024 - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | empty1024 | empty1024 - memmove(prach2+(1024<<3),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024 - memmove(prach2+(1024<<1)*6,prach2,(1024<<2)*6); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024| - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have |Prefix | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024| - prach_len = (1024*12)+Ncp; - } - } - break; - - default: - AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); - } - } else if (mu == 1) { - switch (fp->samples_per_subframe) { - case 15360: // full sampling @ 15.36 Ms/s - Ncp = Ncp/2; // to account for 15.36 Ms/s - // This is after cyclic prefix - prach2 = prach+(2*Ncp); // times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { // 24576 samples @ 30.72 Ms/s, 12288 samples @ 15.36 Ms/s - idft(IDFT_12288,prachF,prach2,1); - // here we have | empty | Prach12288 | - memmove(prach,prach+(12288<<1),(Ncp<<2)); - // here we have | Prefix | Prach12288 | - prach_len = 12288+Ncp; - } else if (prach_fmt_id == 1) { // 24576 samples @ 30.72 Ms/s, 12288 samples @ 15.36 Ms/s - idft(IDFT_12288,prachF,prach2,1); - // here we have | empty | Prach12288 | empty12288 | - memmove(prach2+(12288<<1),prach2,(12288<<2)); - // here we have | empty | Prach12288 | Prach12288 | - memmove(prach,prach+(12288<<2),(Ncp<<2)); - // here we have | Prefix | Prach12288 | Prach12288 | - prach_len = (12288*2)+Ncp; - } else if (prach_fmt_id == 2) { // 24576 samples @ 30.72 Ms/s, 12288 samples @ 15.36 Ms/s - idft(IDFT_12288,prachF,prach2,1); - // here we have | empty | Prach12288 | empty12288 | empty12288 | empty12288 | - memmove(prach2+(12288<<1),prach2,(12288<<2)); - // here we have | empty | Prach12288 | Prach12288 | empty12288 | empty12288 | - memmove(prach2+(12288<<2),prach2,(12288<<3)); - // here we have | empty | Prach12288 | Prach12288 | Prach12288 | Prach12288 | - memmove(prach,prach+(12288<<3),(Ncp<<2)); - // here we have | Prefix | Prach12288 | Prach12288 | Prach12288 | Prach12288 | - prach_len = (12288*4)+Ncp; - } else if (prach_fmt_id == 3) { // 6144 samples @ 30.72 Ms/s, 3072 samples @ 15.36 Ms/s - idft(IDFT_3072,prachF,prach2,1); - // here we have | empty | Prach3072 | empty3072 | empty3072 | empty3072 | - memmove(prach2+(3072<<1),prach2,(3072<<2)); - // here we have | empty | Prach3072 | Prach3072 | empty3072 | empty3072 | - memmove(prach2+(3072<<2),prach2,(3072<<3)); - // here we have | empty | Prach3072 | Prach3072 | Prach3072 | Prach3072 | - memmove(prach,prach+(3072<<3),(Ncp<<2)); - // here we have | Prefix | Prach3072 | Prach3072 | Prach3072 | Prach3072 | - prach_len = (3072*4)+Ncp; - } - } else { // short PRACH sequence - if (use_extended_prach_prefix) - Ncp += 8; // 16*kappa, kappa=0.5 for 15.36 Ms/s - prach2 = prach+(2*Ncp); // times 2 for complex samples - if (prach_fmt_id == 9) { - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | - prach_len = (512*1)+Ncp; - } else if (prach_fmt_id == 4 || prach_fmt_id == 7) { - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | empty512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have | empty | Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | Prach512 | - prach_len = (512*2)+Ncp; - } else if (prach_fmt_id == 5) { // 4x512 - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have | empty | Prach512 | Prach512 | empty512 | empty512 | - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | Prach512 | Prach512 | Prach512 | - prach_len = (512*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x512 - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have | empty | Prach512 | Prach512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | empty512 | empty512 | - memmove(prach2+(512<<3),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | - prach_len = (512*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x512 - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have | empty | Prach512 | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<3),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<1)*6,prach2,(512<<2)*6); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | - prach_len = (512*12)+Ncp; - } - } - break; - - case 30720: // full sampling @ 30.72 Ms/s - Ncp = Ncp*1; // to account for 30.72 Ms/s - // This is after cyclic prefix - prach2 = prach+(2*Ncp); // times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { // 24576 samples @ 30.72 Ms/s - idft(IDFT_24576,prachF,prach2,1); - // here we have | empty | Prach24576 | - memmove(prach,prach+(24576<<1),(Ncp<<2)); - // here we have | Prefix | Prach24576 | - prach_len = 24576+Ncp; - } else if (prach_fmt_id == 1) { // 24576 samples @ 30.72 Ms/s - idft(IDFT_24576,prachF,prach2,1); - // here we have | empty | Prach24576 | empty24576 | - memmove(prach2+(24576<<1),prach2,(24576<<2)); - // here we have | empty | Prach24576 | Prach24576 | - memmove(prach,prach+(24576<<2),(Ncp<<2)); - // here we have | Prefix | Prach24576 | Prach24576 | - prach_len = (24576*2)+Ncp; - } else if (prach_fmt_id == 2) { // 24576 samples @ 30.72 Ms/s - idft(IDFT_24576,prachF,prach2,1); - // here we have | empty | Prach24576 | empty24576 | empty24576 | empty24576 | - memmove(prach2+(24576<<1),prach2,(24576<<2)); - // here we have | empty | Prach24576 | Prach24576 | empty24576 | empty24576 | - memmove(prach2+(24576<<2),prach2,(24576<<3)); - // here we have | empty | Prach24576 | Prach24576 | Prach24576 | Prach24576 | - memmove(prach,prach+(24576<<3),(Ncp<<2)); - // here we have | Prefix | Prach24576 | Prach24576 | Prach24576 | Prach24576 | - prach_len = (24576*4)+Ncp; - } else if (prach_fmt_id == 3) { // 6144 samples @ 30.72 Ms/s - idft(IDFT_6144,prachF,prach2,1); - // here we have | empty | Prach6144 | empty6144 | empty6144 | empty6144 | - memmove(prach2+(6144<<1),prach2,(6144<<2)); - // here we have | empty | Prach6144 | Prach6144 | empty6144 | empty6144 | - memmove(prach2+(6144<<2),prach2,(6144<<3)); - // here we have | empty | Prach6144 | Prach6144 | Prach6144 | Prach6144 | - memmove(prach,prach+(6144<<3),(Ncp<<2)); - // here we have | Prefix | Prach6144 | Prach6144 | Prach6144 | Prach6144 | - prach_len = (6144*4)+Ncp; - } - } else { // short PRACH sequence - if (use_extended_prach_prefix) - Ncp += 16; // 16*kappa, kappa=1 for 30.72Msps - prach2 = prach+(2*Ncp); // times 2 for complex samples - if (prach_fmt_id == 9) { - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | - prach_len = (1024*1)+Ncp; - } else if (prach_fmt_id == 4 || prach_fmt_id == 7) { - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | empty1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have | empty | Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | Prach1024 | - prach_len = (1024*2)+Ncp; - } else if (prach_fmt_id == 5) { // 4x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have | empty | Prach1024 | Prach1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - prach_len = (1024*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have | empty | Prach1024 | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<3),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - prach_len = (1024*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have | empty | Prach1024 | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<3),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<1)*6,prach2,(1024<<2)*6); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - prach_len = (1024*12)+Ncp; - } - } - break; - - case 61440: // full sampling @ 61.44 Ms/s - Ncp = Ncp*2; // to account for 61.44 Ms/s - // This is after cyclic prefix - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s - idft(IDFT_49152,prachF,prach2,1); - // here we have |empty | Prach49152| - memmove(prach,prach+(49152<<1),(Ncp<<2)); - // here we have |Prefix | Prach49152| - prach_len = 49152+Ncp; - } else if (prach_fmt_id == 1) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s - idft(IDFT_49152,prachF,prach2,1); - memmove(prach2+(49152<<1),prach2,(49152<<2)); - // here we have |empty | Prach49152 | Prach49152| - memmove(prach,prach+(49152<<2),(Ncp<<2)); - // here we have |Prefix | Prach49152 | Prach49152| - prach_len = (49152*2)+Ncp; - } else if (prach_fmt_id == 2) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s - idft(IDFT_49152,prachF,prach2,1); - memmove(prach2+(49152<<1),prach2,(49152<<2)); - // here we have |empty | Prach49152 | Prach49152| empty49152 | empty49152 - memmove(prach2+(49152<<2),prach2,(49152<<3)); - // here we have |empty | Prach49152 | Prach49152| Prach49152 | Prach49152 - memmove(prach,prach+(49152<<3),(Ncp<<2)); - // here we have |Prefix | Prach49152 | Prach49152| Prach49152 | Prach49152 - prach_len = (49152*4)+Ncp; - } else if (prach_fmt_id == 3) { // 6144 samples @ 30.72 Ms/s, 12288 samples @ 61.44 Ms/s - idft(IDFT_12288,prachF,prach2,1); - memmove(prach2+(12288<<1),prach2,(12288<<2)); - // here we have |empty | Prach12288 | Prach12288| empty12288 | empty12288 - memmove(prach2+(12288<<2),prach2,(12288<<3)); - // here we have |empty | Prach12288 | Prach12288| Prach12288 | Prach12288 - memmove(prach,prach+(12288<<3),(Ncp<<2)); - // here we have |Prefix | Prach12288 | Prach12288| Prach12288 | Prach12288 - prach_len = (12288*4)+Ncp; - } - } else { // short PRACH sequence - if (use_extended_prach_prefix) - Ncp+=32; // 16*kappa, kappa=2 for 61.44Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_2048,prachF,prach2,1); - // here we have |empty | Prach2048 | - if (prach_fmt_id != 9) { - memmove(prach2+(2048<<1),prach2,(2048<<2)); - prach_len = (2048*2)+Ncp; - } - else prach_len = (2048*1)+Ncp; - memmove(prach,prach+(2048<<1),(Ncp<<2)); - // here we have |Prefix | Prach2048 | Prach2048 (if ! 0xc0) | - } else if (prach_fmt_id == 5) { // 6x2048 - idft(IDFT_2048,prachF,prach2,1); - // here we have |empty | Prach2048 | - memmove(prach2+(2048<<1),prach2,(2048<<2)); - // here we have |empty | Prach2048 | Prach2048| empty2048 | empty2048 | - memmove(prach2+(2048<<2),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | - memmove(prach,prach+(2048<<1),(Ncp<<2)); - // here we have |Prefix | Prach2048 | - prach_len = (2048*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x2048 - idft(IDFT_2048,prachF,prach2,1); - // here we have |empty | Prach2048 | - memmove(prach2+(2048<<1),prach2,(2048<<2)); - // here we have |empty | Prach2048 | Prach2048| empty2048 | empty2048 | empty2048 | empty2048 - memmove(prach2+(2048<<2),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | empty2048 | empty2048 - memmove(prach2+(2048<<3),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 - memmove(prach,prach+(2048<<1),(Ncp<<2)); - // here we have |Prefix | Prach2048 | - prach_len = (2048*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x2048 - idft(IDFT_2048,prachF,prach2,1); - // here we have |empty | Prach2048 | - memmove(prach2+(2048<<1),prach2,(2048<<2)); - // here we have |empty | Prach2048 | Prach2048| empty2048 | empty2048 | empty2048 | empty2048 - memmove(prach2+(2048<<2),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | empty2048 | empty2048 - memmove(prach2+(2048<<3),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 - memmove(prach2+(2048<<1)*6,prach2,(2048<<2)*6); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048| - memmove(prach,prach+(2048<<1),(Ncp<<2)); - // here we have |Prefix | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048| - prach_len = (2048*12)+Ncp; - } - } - break; - - case 46080: // threequarter sampling @ 46.08 Ms/s - Ncp = (Ncp*3)/2; - prach2 = prach+(Ncp<<1); - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { - idft(IDFT_36864,prachF,prach2,1); - // here we have |empty | Prach73728| - memmove(prach,prach+(36864<<1),(Ncp<<2)); - // here we have |Prefix | Prach73728| - prach_len = (36864*1)+Ncp; - } else if (prach_fmt_id == 1) { - idft(IDFT_36864,prachF,prach2,1); - memmove(prach2+(36864<<1),prach2,(36864<<2)); - // here we have |empty | Prach73728 | Prach73728| - memmove(prach,prach+(36864<<2),(Ncp<<2)); - // here we have |Prefix | Prach73728 | Prach73728| - prach_len = (36864*2)+Ncp; - } else if (prach_fmt_id == 2) { - idft(IDFT_36864,prachF,prach2,1); - memmove(prach2+(36864<<1),prach2,(36864<<2)); - // here we have |empty | Prach73728 | Prach73728| empty73728 | empty73728 - memmove(prach2+(36864<<2),prach2,(36864<<3)); - // here we have |empty | Prach73728 | Prach73728| Prach73728 | Prach73728 - memmove(prach,prach+(36864<<3),(Ncp<<2)); - // here we have |Prefix | Prach73728 | Prach73728| Prach73728 | Prach73728 - prach_len = (36864*4)+Ncp; - } else if (prach_fmt_id == 3) { - idft(IDFT_9216,prachF,prach2,1); - memmove(prach2+(9216<<1),prach2,(9216<<2)); - // here we have |empty | Prach9216 | Prach9216| empty9216 | empty9216 - memmove(prach2+(9216<<2),prach2,(9216<<3)); - // here we have |empty | Prach9216 | Prach9216| Prach9216 | Prach9216 - memmove(prach,prach+(9216<<3),(Ncp<<2)); - // here we have |Prefix | Prach9216 | Prach9216| Prach9216 | Prach9216 - prach_len = (9216*4)+Ncp; - } - } else { // short sequence - if (use_extended_prach_prefix) - Ncp+=24; // 16*kappa, kappa=1.5 for 46.08Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_1536,prachF,prach2,1); - // here we have |empty | Prach1536 | - if (prach_fmt_id != 9) { - memmove(prach2+(1536<<1),prach2,(1536<<2)); - prach_len = (1536*2)+Ncp; - } else prach_len = (1536*1)+Ncp; - - memmove(prach,prach+(1536<<1),(Ncp<<2)); - // here we have |Prefix | Prach1536 | Prach1536 (if ! 0xc0) | - - } else if (prach_fmt_id == 5) { // 6x1536 - idft(IDFT_1536,prachF,prach2,1); - // here we have |empty | Prach1536 | - memmove(prach2+(1536<<1),prach2,(1536<<2)); - // here we have |empty | Prach1536 | Prach1536| empty1536 | empty1536 | - memmove(prach2+(1536<<2),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | - memmove(prach,prach+(1536<<1),(Ncp<<2)); - // here we have |Prefix | Prach1536 | - prach_len = (1536*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x1536 - idft(IDFT_1536,prachF,prach2,1); - // here we have |empty | Prach1536 | - memmove(prach2+(1536<<1),prach2,(1536<<2)); - // here we have |empty | Prach1536 | Prach1536| empty1536 | empty1536 | empty1536 | empty1536 - memmove(prach2+(1536<<2),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | empty1536 | empty1536 - memmove(prach2+(1536<<3),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 - memmove(prach,prach+(1536<<1),(Ncp<<2)); - // here we have |Prefix | Prach1536 | - prach_len = (1536*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x1536 - idft(IDFT_1536,prachF,prach2,1); - // here we have |empty | Prach1536 | - memmove(prach2+(1536<<1),prach2,(1536<<2)); - // here we have |empty | Prach1536 | Prach1536| empty1536 | empty1536 | empty1536 | empty1536 - memmove(prach2+(1536<<2),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | empty1536 | empty1536 - memmove(prach2+(1536<<3),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 - memmove(prach2+(1536<<1)*6,prach2,(1536<<2)*6); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536| - memmove(prach,prach+(1536<<1),(Ncp<<2)); - // here we have |Prefix | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536| - prach_len = (1536*12)+Ncp; - } - } - break; - - case 122880: // full sampling @ 122.88 Ms/s - Ncp<<=2; //to account for 122.88Mbps - // This is after cyclic prefix - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { //24576 samples @ 30.72 Ms/s, 98304 samples @ 122.88 Ms/s - idft(IDFT_98304,prachF,prach2,1); - // here we have |empty | Prach98304| - memmove(prach,prach+(98304<<1),(Ncp<<2)); - // here we have |Prefix | Prach98304| - prach_len = (98304*1)+Ncp; - } else if (prach_fmt_id == 1) { - idft(IDFT_98304,prachF,prach2,1); - memmove(prach2+(98304<<1),prach2,(98304<<2)); - // here we have |empty | Prach98304 | Prach98304| - memmove(prach,prach+(98304<<2),(Ncp<<2)); - // here we have |Prefix | Prach98304 | Prach98304| - prach_len = (98304*2)+Ncp; - } else if (prach_fmt_id == 2) { - idft(IDFT_98304,prachF,prach2,1); - memmove(prach2+(98304<<1),prach2,(98304<<2)); - // here we have |empty | Prach98304 | Prach98304| empty98304 | empty98304 - memmove(prach2+(98304<<2),prach2,(98304<<3)); - // here we have |empty | Prach98304 | Prach98304| Prach98304 | Prach98304 - memmove(prach,prach+(98304<<3),(Ncp<<2)); - // here we have |Prefix | Prach98304 | Prach98304| Prach98304 | Prach98304 - prach_len = (98304*4)+Ncp; - } else if (prach_fmt_id == 3) { // 4x6144, Ncp 3168 - idft(IDFT_24576,prachF,prach2,1); - memmove(prach2+(24576<<1),prach2,(24576<<2)); - // here we have |empty | Prach24576 | Prach24576| empty24576 | empty24576 - memmove(prach2+(24576<<2),prach2,(24576<<3)); - // here we have |empty | Prach24576 | Prach24576| Prach24576 | Prach24576 - memmove(prach,prach+(24576<<3),(Ncp<<2)); - // here we have |Prefix | Prach24576 | Prach24576| Prach24576 | Prach24576 - prach_len = (24576*4)+Ncp; - } - } else { // short sequence - if (use_extended_prach_prefix) - Ncp+=64; // 16*kappa, kappa=4 for 122.88Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_4096,prachF,prach2,1); - // here we have |empty | Prach4096 | - if (prach_fmt_id != 9) { - memmove(prach2+(4096<<1),prach2,(4096<<2)); - prach_len = (4096*2)+Ncp; - } else prach_len = (4096*1)+Ncp; - memmove(prach,prach+(4096<<1),(Ncp<<2)); - // here we have |Prefix | Prach4096 | Prach4096 (if ! 0xc0) | - } else if (prach_fmt_id == 5) { // 4x4096 - idft(IDFT_4096,prachF,prach2,1); - // here we have |empty | Prach4096 | - memmove(prach2+(4096<<1),prach2,(4096<<2)); - // here we have |empty | Prach4096 | Prach4096| empty4096 | empty4096 | - memmove(prach2+(4096<<2),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | - memmove(prach,prach+(4096<<1),(Ncp<<2)); - // here we have |Prefix | Prach4096 | - prach_len = (4096*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x4096 - idft(IDFT_4096,prachF,prach2,1); - // here we have |empty | Prach4096 | - memmove(prach2+(4096<<1),prach2,(4096<<2)); - // here we have |empty | Prach4096 | Prach4096| empty4096 | empty4096 | empty4096 | empty4096 - memmove(prach2+(4096<<2),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | empty4096 | empty4096 - memmove(prach2+(4096<<3),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 - memmove(prach,prach+(4096<<1),(Ncp<<2)); - // here we have |Prefix | Prach4096 | - prach_len = (4096*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x4096 - idft(IDFT_4096,prachF,prach2,1); - // here we have |empty | Prach4096 | - memmove(prach2+(4096<<1),prach2,(4096<<2)); - // here we have |empty | Prach4096 | Prach4096| empty4096 | empty4096 | empty4096 | empty4096 - memmove(prach2+(4096<<2),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | empty4096 | empty4096 - memmove(prach2+(4096<<3),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 - memmove(prach2+(4096<<1)*6,prach2,(4096<<2)*6); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096| - memmove(prach,prach+(4096<<1),(Ncp<<2)); - // here we have |Prefix | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096| - prach_len = (4096*12)+Ncp; - } - } - break; - - case 92160: // three quarter sampling @ 92.16 Ms/s - Ncp = (Ncp*3); //to account for 92.16 Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { - idft(IDFT_73728,prachF,prach2,1); - // here we have |empty | Prach73728| - memmove(prach,prach+(73728<<1),(Ncp<<2)); - // here we have |Prefix | Prach73728| - prach_len = (73728*1)+Ncp; - } else if (prach_fmt_id == 1) { - idft(IDFT_73728,prachF,prach2,1); - memmove(prach2+(73728<<1),prach2,(73728<<2)); - // here we have |empty | Prach73728 | Prach73728| - memmove(prach,prach+(73728<<2),(Ncp<<2)); - // here we have |Prefix | Prach73728 | Prach73728| - prach_len = (73728*2)+Ncp; - } if (prach_fmt_id == 2) { - idft(IDFT_73728,prachF,prach2,1); - memmove(prach2+(73728<<1),prach2,(73728<<2)); - // here we have |empty | Prach73728 | Prach73728| empty73728 | empty73728 - memmove(prach2+(73728<<2),prach2,(73728<<3)); - // here we have |empty | Prach73728 | Prach73728| Prach73728 | Prach73728 - memmove(prach,prach+(73728<<3),(Ncp<<2)); - // here we have |Prefix | Prach73728 | Prach73728| Prach73728 | Prach73728 - prach_len = (73728*4)+Ncp; - } else if (prach_fmt_id == 3) { - idft(IDFT_18432,prachF,prach2,1); - memmove(prach2+(18432<<1),prach2,(18432<<2)); - // here we have |empty | Prach18432 | Prach18432| empty18432 | empty18432 - memmove(prach2+(18432<<2),prach2,(18432<<3)); - // here we have |empty | Prach18432 | Prach18432| Prach18432 | Prach18432 - memmove(prach,prach+(18432<<3),(Ncp<<2)); - // here we have |Prefix | Prach18432 | Prach18432| Prach18432 | Prach18432 - prach_len = (18432*4)+Ncp; - } - } else { // short sequence - if (use_extended_prach_prefix) - Ncp+=48; // 16*kappa, kappa=3 for 92.16Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_3072,prachF,prach2,1); - // here we have |empty | Prach3072 | - if (prach_fmt_id != 9) { - memmove(prach2+(3072<<1),prach2,(3072<<2)); - prach_len = (3072*2)+Ncp; - } else prach_len = (3072*1)+Ncp; - memmove(prach,prach+(3072<<1),(Ncp<<2)); - // here we have |Prefix | Prach3072 | Prach3072 (if ! 0xc0) | - } else if (prach_fmt_id == 6) { // 6x3072 - idft(IDFT_3072,prachF,prach2,1); - // here we have |empty | Prach3072 | - memmove(prach2+(3072<<1),prach2,(3072<<2)); - // here we have |empty | Prach3072 | Prach3072| empty3072 | empty3072 | empty3072 | empty3072 - memmove(prach2+(3072<<2),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | empty3072 | empty3072 - memmove(prach2+(3072<<3),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 - memmove(prach,prach+(3072<<1),(Ncp<<2)); - // here we have |Prefix | Prach3072 | - prach_len = (3072*6)+Ncp; - } else if (prach_fmt_id == 5) { // 4x3072 - idft(IDFT_3072,prachF,prach2,1); - // here we have |empty | Prach3072 | - memmove(prach2+(3072<<1),prach2,(3072<<2)); - // here we have |empty | Prach3072 | Prach3072| empty3072 | empty3072 | - memmove(prach2+(3072<<2),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | - memmove(prach,prach+(3072<<1),(Ncp<<2)); - // here we have |Prefix | Prach3072 | - prach_len = (3072*4)+Ncp; - } else if (prach_fmt_id == 6) { // 12x3072 - idft(IDFT_3072,prachF,prach2,1); - // here we have |empty | Prach3072 | - memmove(prach2+(3072<<1),prach2,(3072<<2)); - // here we have |empty | Prach3072 | Prach3072| empty3072 | empty3072 | empty3072 | empty3072 - memmove(prach2+(3072<<2),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | empty3072 | empty3072 - memmove(prach2+(3072<<3),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 - memmove(prach2+(3072<<1)*6,prach2,(3072<<2)*6); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072| - memmove(prach,prach+(3072<<1),(Ncp<<2)); - // here we have |Prefix | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072| - prach_len = (3072*12)+Ncp; - } - } - break; - - default: - AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); + } else { // short PRACH sequence + if (prach_fmt_id == 9) { + // here we have | empty | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | + prach_len = (dftlen*1)+Ncp; + } else if (prach_fmt_id == 4 || prach_fmt_id == 7) { + // here we have | empty | Prach | empty | + memcpy(prach2+(dftlen<<1), prach2, (dftlen<<2)); + // here we have | empty | Prach | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | Prach | + prach_len = (dftlen*2)+Ncp; + } else if (prach_fmt_id == 5) { // 4xdftlen + // here we have | empty | Prach | empty | empty | empty | + memcpy(prach2+(dftlen<<1), prach2, (dftlen<<2)); + // here we have | empty | Prach | Prach | empty | empty | + memcpy(prach2+(dftlen<<2), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | Prach | Prach | Prach | + prach_len = (dftlen*4)+Ncp; + } else if (prach_fmt_id == 6) { // 6xdftlen + // here we have | empty | Prach | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<1), prach2, (dftlen<<2)); + // here we have | empty | Prach | Prach | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<2), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | empty | empty | + memcpy(prach2+(dftlen<<3), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | Prach | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | Prach | Prach | Prach | Prach | Prach | + prach_len = (dftlen*6)+Ncp; + } else if (prach_fmt_id == 8) { // 12xdftlen + // here we have | empty | Prach | empty | empty | empty | empty | empty | empty | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<1), prach2, (dftlen<<2)); + // here we have | empty | Prach | Prach | empty | empty | empty | empty | empty | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<2), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | empty | empty | empty | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<3), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | Prach | Prach | empty | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<1)*6, prach2, (dftlen<<2)*6); + // here we have | empty | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | + prach_len = (dftlen*12)+Ncp; } } From 1616ed7727d3dc1bea9eaf127cab4542c1088d5a Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 28 Feb 2022 11:24:37 +0100 Subject: [PATCH 039/105] gNB: generalize rx_nr_prach_ru() and add support for mu==0 --- openair1/PHY/NR_TRANSPORT/nr_prach.c | 488 ++++++--------------------- 1 file changed, 111 insertions(+), 377 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c index ed8eba4940..dce98b70f0 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c @@ -200,89 +200,167 @@ void rx_nr_prach_ru(RU_t *ru, prach[aa] = (int16_t*)&ru->common.rxdata[aa][fp->get_samples_slot_timestamp(slot2,fp,0)+sample_offset_slot-ru->N_TA_offset]; } - idft_size_idx_t dftsize; - int dftlen=0; + int reps; + int Ncp; + int dftlen; int mu = fp->numerology_index; - int Ncp = 0; - int16_t *prach2; if (prach_sequence_length == 0) { LOG_D(PHY,"PRACH (ru %d) in %d.%d, format %d, msg1_frequencyStart %d\n", ru->idx,frame,slot2,prachFormat,msg1_frequencystart); - AssertFatal(prachFormat<4,"Illegal prach format %d for length 839\n",prachFormat); switch (prachFormat) { case 0: + reps = 1; Ncp = 3168; + dftlen = 24576; break; - + case 1: + reps = 2; Ncp = 21024; + dftlen = 24576; break; - + case 2: + reps = 4; Ncp = 4688; + dftlen = 24576; break; - + case 3: + reps = 4; Ncp = 3168; + dftlen = 6144; + break; + + default: + AssertFatal(1==0, "Illegal prach format %d for length 839\n", prachFormat); break; - } } else { LOG_D(PHY,"PRACH (ru %d) in %d.%d, format %s, msg1_frequencyStart %d,startSymbol %d\n", ru->idx,frame,slot,prachfmt[prachFormat],msg1_frequencystart,prachStartSymbol); - switch (prachFormat) { case 4: //A1 - Ncp = 288/(1<> mu; break; - + case 5: //A2 - Ncp = 576/(1<> mu; break; - + case 6: //A3 - Ncp = 864/(1<> mu; break; - + case 7: //B1 - Ncp = 216/(1<> mu; + break; + /* // B2 and B3 do not exist in FAPI case 4: //B2 - Ncp = 360/(1<> mu; break; - + case 5: //B3 - Ncp = 504/(1<> mu; break; */ + case 8: //B4 - Ncp = 936/(1<> mu; break; - + case 9: //C0 - Ncp = 1240/(1<> mu; break; - + case 10: //C2 - Ncp = 2048/(1<> mu; break; - + default: AssertFatal(1==0,"unknown prach format %x\n",prachFormat); break; } + dftlen = 2048 >> mu; } + + //actually what we should be checking here is how often the current prach crosses a 0.5ms boundary. I am not quite sure for which paramter set this would be the case, so I will ignore it for now and just check if the prach starts on a 0.5ms boundary + if(fp->numerology_index == 0) { + if (prachStartSymbol == 0 || prachStartSymbol == 7) + Ncp += 16; + } + else { + if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) + Ncp += 16; + } + + switch(fp->samples_per_subframe) { + case 7680: + // 5 MHz @ 7.68 Ms/s + Ncp >>= 2; + dftlen >>= 2; + break; + + case 15360: + // 10, 15 MHz @ 15.36 Ms/s + Ncp >>= 1; + dftlen >>= 1; + break; + + case 30720: + // 20, 25, 30 MHz @ 30.72 Ms/s + Ncp = Ncp; + dftlen = dftlen; + break; + + case 46080: + // 40 MHz @ 46.08 Ms/s + Ncp = (Ncp*3)/2; + dftlen = (dftlen*3)/2; + break; + + case 61440: + // 40, 50, 60 MHz @ 61.44 Ms/s + Ncp <<= 1; + dftlen <<= 1; + break; + + case 92160: + // 50, 60, 70, 80, 90 MHz @ 92.16 Ms/s + Ncp *= 3; + dftlen *= 3; + break; + + case 122880: + // 70, 80, 90, 100 MHz @ 122.88 Ms/s + Ncp <<= 2; + dftlen <<= 2; + break; + + default: + AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); + } + + const idft_size_idx_t dftsize = get_dft(dftlen); + // Do forward transform if (LOG_DEBUGFLAG(PRACH)) { - LOG_D(PHY,"rx_prach: Doing PRACH FFT for nb_rx:%d Ncp:%d\n",ru->nb_rx, Ncp); + LOG_D(PHY, "rx_prach: Doing PRACH FFT for nb_rx:%d Ncp:%d dftlen:%d\n", ru->nb_rx, Ncp, dftlen); } - // Note: Assumes PUSCH SCS @ 30 kHz, take values for formats 0-2 and adjust for others below int kbar = 1; @@ -306,357 +384,13 @@ void rx_nr_prach_ru(RU_t *ru, k*=K; k+=kbar; - int reps=1; - for (int aa=0; aanb_rx; aa++) { AssertFatal(prach[aa]!=NULL,"prach[%d] is null\n",aa); // do DFT - if (mu==1) { - switch(fp->samples_per_subframe) { - case 15360: - // 10, 15 MHz @ 15.36 Ms/s - prach2 = prach[aa] + (1*Ncp); // Ncp is for 30.72 Ms/s, so divide by 2 to bring to 15.36 Ms/s and multiply by 2 for I/Q - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=12288; - dft(DFT_12288,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_12288,prach2+24576,rxsigF[aa]+24576,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_12288,prach2+(24576*2),rxsigF[aa]+(24576*2),1); - dft(DFT_12288,prach2+(24576*3),rxsigF[aa]+(24576*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=3072; - for (int i=0;i<4;i++) dft(DFT_3072,prach2+(i*3072*2),rxsigF[aa]+(i*3072*2),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=16; // 8 samples @ 15.36 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=512; - dft(DFT_512,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_512,prach2+1024,rxsigF[aa]+1024,1); - reps++; - } - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_512,prach2+1024*2,rxsigF[aa]+1024*2,1); - dft(DFT_512,prach2+1024*3,rxsigF[aa]+1024*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_512,prach2+1024*4,rxsigF[aa]+1024*4,1); - dft(DFT_512,prach2+1024*5,rxsigF[aa]+1024*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_512,prach2+(1024*i),rxsigF[aa]+(1024*i),1); - reps+=6; - } - } - break; - - case 30720: - // 20, 25, 30 MHz @ 30.72 Ms/s - prach2 = prach[aa] + (2*Ncp); // Ncp is for 30.72 Ms/s, so just multiply by 2 for I/Q - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=24576; - dft(DFT_24576,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_24576,prach2+49152,rxsigF[aa]+49152,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_24576,prach2+(49152*2),rxsigF[aa]+(49152*2),1); - dft(DFT_24576,prach2+(49152*3),rxsigF[aa]+(49152*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=6144; - for (int i=0;i<4;i++) dft(DFT_6144,prach2+(i*6144*2),rxsigF[aa]+(i*6144*2),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=32; // 16 samples @ 30.72 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=1024; - dft(DFT_1024,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_1024,prach2+2048,rxsigF[aa]+2048,1); - reps++; - } - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_1024,prach2+2048*2,rxsigF[aa]+2048*2,1); - dft(DFT_1024,prach2+2048*3,rxsigF[aa]+2048*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_1024,prach2+2048*4,rxsigF[aa]+2048*4,1); - dft(DFT_1024,prach2+2048*5,rxsigF[aa]+2048*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_1024,prach2+(2048*i),rxsigF[aa]+(2048*i),1); - reps+=6; - } - } - break; - - case 61440: - // 40, 50, 60 MHz @ 61.44 Ms/s - prach2 = prach[aa] + (4*Ncp); // Ncp is for 30.72 Ms/s, so multiply by 2 for I/Q, and 2 to bring to 61.44 Ms/s - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=49152; - dft(DFT_49152,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_49152,prach2+98304,rxsigF[aa]+98304,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_49152,prach2+(98304*2),rxsigF[aa]+(98304*2),1); - dft(DFT_49152,prach2+(98304*3),rxsigF[aa]+(98304*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=12288; - for (int i=0;i<4;i++) dft(DFT_12288,prach2+(i*12288*2),rxsigF[aa]+(i*12288*2),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=64; // 32 samples @ 61.44 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=2048; - dft(DFT_2048,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_2048,prach2+4096,rxsigF[aa]+4096,1); - reps++; - } - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_2048,prach2+4096*2,rxsigF[aa]+4096*2,1); - dft(DFT_2048,prach2+4096*3,rxsigF[aa]+4096*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_2048,prach2+4096*4,rxsigF[aa]+4096*4,1); - dft(DFT_2048,prach2+4096*5,rxsigF[aa]+4096*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_2048,prach2+(4096*i),rxsigF[aa]+(4096*i),1); - reps+=6; - } - } - break; - - case 46080: - // 40 MHz @ 46.08 Ms/s - prach2 = prach[aa] + (3*Ncp); // 46.08 is 1.5 * 30.72, times 2 for I/Q - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=36864; - dft(DFT_36864,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_36864,prach2+73728,rxsigF[aa]+73728,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_36864,prach2+(73728*2),rxsigF[aa]+(73728*2),1); - dft(DFT_36864,prach2+(73728*3),rxsigF[aa]+(73728*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=9216; - for (int i=0;i<4;i++) dft(DFT_9216,prach2+(i*9216*2),rxsigF[aa]+(i*9216*2),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=48; // 24 samples @ 46.08 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=1536; - dft(DFT_1536,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_1536,prach2+3072,rxsigF[aa]+3072,1); - reps++; - } - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_1536,prach2+3072*2,rxsigF[aa]+3072*2,1); - dft(DFT_1536,prach2+3072*3,rxsigF[aa]+3072*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_1536,prach2+3072*4,rxsigF[aa]+3072*4,1); - dft(DFT_1536,prach2+3072*5,rxsigF[aa]+3072*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_1536,prach2+(3072*i),rxsigF[aa]+(3072*i),1); - reps+=6; - } - } - break; - - case 122880: - // 70, 80, 90, 100 MHz @ 122.88 Ms/s - prach2 = prach[aa] + (8*Ncp); - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=98304; - dft(DFT_98304,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_98304,prach2+196608,rxsigF[aa]+196608,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_98304,prach2+(196608*2),rxsigF[aa]+(196608*2),1); - dft(DFT_98304,prach2+(196608*3),rxsigF[aa]+(196608*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=24576; - for (int i=0;i<4;i++) dft(DFT_24576,prach2+(i*2*24576),rxsigF[aa]+(i*2*24576),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=128; // 64 samples @ 122.88 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=4096; - dft(DFT_4096,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_4096,prach2+8192,rxsigF[aa]+8192,1); - reps++; - } - - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_4096,prach2+8192*2,rxsigF[aa]+8192*2,1); - dft(DFT_4096,prach2+8192*3,rxsigF[aa]+8192*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_4096,prach2+8192*4,rxsigF[aa]+8192*4,1); - dft(DFT_4096,prach2+8192*5,rxsigF[aa]+8192*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_4096,prach2+(8192*i),rxsigF[aa]+(8192*i),1); - reps+=6; - } - } - break; - - case 92160: - // 80, 90 MHz @ 92.16 Ms/s - prach2 = prach[aa] + (6*Ncp); - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=73728; - dft(DFT_73728,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_73728,prach2+147456,rxsigF[aa]+147456,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_73728,prach2+(147456*2),rxsigF[aa]+(147456*2),1); - dft(DFT_73728,prach2+(147456*3),rxsigF[aa]+(147456*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=18432; - for (int i=0;i<4;i++) dft(DFT_18432,prach2+(i*2*18432),rxsigF[aa]+(i*2*18432),1); - reps=4; - } - } else { - if (prachStartSymbol == 0) prach2+=96; // 64 samples @ 122.88 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=3072; - dft(DFT_3072,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_3072,prach2+6144,rxsigF[aa]+6144,1); - reps++; - } - - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_3072,prach2+6144*2,rxsigF[aa]+6144*2,1); - dft(DFT_3072,prach2+6144*3,rxsigF[aa]+6144*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_3072,prach2+6144*4,rxsigF[aa]+6144*4,1); - dft(DFT_3072,prach2+6144*5,rxsigF[aa]+6144*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_3072,prach2+(6144*i),rxsigF[aa]+(6144*i),1); - reps+=6; - } - } - break; - default: - AssertFatal(1==0,"sample_rate %f MHz not support for NR PRACH yet\n", fp->samples_per_subframe / 1000.0); - } - } - else if (mu==3) { - if (fp->threequarter_fs) { - AssertFatal(1==0,"3/4 sampling not supported for numerology %d\n",mu); - } - if (prach_sequence_length == 0) { - AssertFatal(1==0,"long prach not supported for numerology %d\n",mu); - } - if (fp->N_RB_UL == 32) { - prach2 = prach[aa] + (Ncp<<2); // Ncp is for 30.72 Ms/s, so multiply by 2 for I/Q, and 2 for 61.44Msps - if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) - prach2+=64; // 32 samples @ 61.44 Ms/s in first symbol of each half subframe - dftlen=512; - dftsize = DFT_512; - } - else if (fp->N_RB_UL == 66) { - prach2 = prach[aa] + (Ncp<<3); // Ncp is for 30.72 Ms/s, so multiply by 4 for I/Q, and 2 for 122.88Msps - if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) - prach2+=128; // 64 samples @ 122.88 Ms/s in first symbol of each half subframe - dftlen=1024; - dftsize = DFT_1024; - } - else { - AssertFatal(1==0,"N_RB_UL %d not support for numerology %d\n",fp->N_RB_UL,mu); - } - - dft(dftsize,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(dftsize,prach2+dftlen*2,rxsigF[aa]+dftlen*2,1); - reps++; - } - - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(dftsize,prach2+dftlen*4,rxsigF[aa]+dftlen*4,1); - dft(dftsize,prach2+dftlen*6,rxsigF[aa]+dftlen*6,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(dftsize,prach2+dftlen*8,rxsigF[aa]+dftlen*8,1); - dft(dftsize,prach2+dftlen*10,rxsigF[aa]+dftlen*10,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) - dft(dftsize,prach2+(dftlen*2*i),rxsigF[aa]+(dftlen*2*i),1); - reps+=6; - } - } - else { - AssertFatal(1==0,"Numerology not supported\n"); - } + int16_t *prach2 = prach[aa] + (2*Ncp); // times 2 for complex samples + for (int i = 0; i < reps; i++) + dft(dftsize, prach2 + 2*dftlen*i, rxsigF[aa] + 2*dftlen*i, 1); //LOG_M("ru_rxsigF_tmp.m","rxsFtmp", rxsigF[aa], dftlen*2*reps, 1, 1); From 6569ea1a20a83b0a8792fe9bff5f3f2b4000c7a2 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 14 Mar 2022 16:38:02 +0100 Subject: [PATCH 040/105] fix use of uninitialized memory found by valdgrind in nr_dlsim --- common/utils/threadPool/thread-pool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index d06f2195ee..e448117385 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -80,7 +80,7 @@ static inline notifiedFIFO_elt_t *newNotifiedFIFO_elt(int size, notifiedFIFO_t *reponseFifo, void (*processingFunc)(void *)) { notifiedFIFO_elt_t *ret; - AssertFatal( NULL != (ret=(notifiedFIFO_elt_t *) malloc(sizeof(notifiedFIFO_elt_t)+size+32)), ""); + AssertFatal( NULL != (ret=(notifiedFIFO_elt_t *) calloc(1, sizeof(notifiedFIFO_elt_t)+size+32)), ""); ret->next=NULL; ret->key=key; ret->reponseFifo=reponseFifo; From 9ef3fdbc49d968820d3f8b85993328ff69dc25f3 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 14 Mar 2022 17:07:16 +0100 Subject: [PATCH 041/105] add autotests for nr_dlsim and nr_ulsim with 15 kHz SCS and 5 MHz BW --- cmake_targets/autotests/test_case_list.xml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 7497fb419c..acbbcfd1a9 100755 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1104,7 +1104,8 @@ (Test19: Mapping type A, 3 DMRS Symbols), (Test20: Mapping type B, 4 DMRS Symbols), (Test21: 4x4 MIMO, 1 Layer), - (Test22: 4x4 MIMO, 2 Layers) + (Test22: 4x4 MIMO, 2 Layers), + (Test23: 25 PRBs, 15 kHz SCS) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1132,8 +1133,9 @@ -n100 -s2 -U 2 0 2 -n100 -s2 -U 2 1 3 -n10 -s20 -U 3 0 0 2 -gR -x1 -y4 -z4 - -n10 -s20 -U 3 0 0 2 -gR -x2 -y4 -z4 - nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 nr_dlsim.test11 nr_dlsim.test12 nr_dlsim.test13 nr_dlsim.test14 nr_dlsim.test15 nr_dlsim.test16 nr_dlsim.test17 nr_dlsim.test18 nr_dlsim.test19 nr_dlsim.test20 nr_dlsim.test21 nr_dlsim.test22 + -n10 -s20 -U 3 0 0 2 -gR -x2 -y4 -z4 + -n100 -m0 -e0 -R25 -b25 -i + nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 nr_dlsim.test11 nr_dlsim.test12 nr_dlsim.test13 nr_dlsim.test14 nr_dlsim.test15 nr_dlsim.test16 nr_dlsim.test17 nr_dlsim.test18 nr_dlsim.test19 nr_dlsim.test20 nr_dlsim.test21 nr_dlsim.test22 nr_dlsim.test23 PDSCH test OK segmentation fault|assertion|exiting|fatal 3 @@ -1304,7 +1306,8 @@ (Test12: SC-FDMA, 216 PRBs), (Test13: SC-FDMA, 273 PRBs), (Test14: SC-FDMA, 3 DMRS), - (Test15: MCS 16 50 PRBs 2 RX_Antenna) + (Test15: MCS 16 50 PRBs 2 RX_Antenna), + (Test16: 25 PRBs, 15 kHz SCS) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1325,9 +1328,9 @@ -n50 -s5 -Z -r216 -R217 -n50 -s5 -Z -r270 -R273 -n100 -s5 -Z -U 2 0 2 - -n100 -m16 -s10 -z2 - - nr_ulsim.test1 nr_ulsim.test2 nr_ulsim.test3 nr_ulsim.test4 nr_ulsim.test5 nr_ulsim.test6 nr_ulsim.test7 nr_ulsim.test8 nr_ulsim.test9 nr_ulsim.test10 nr_ulsim.test11 nr_ulsim.test12 nr_ulsim.test13 nr_ulsim.test14 nr_ulsim.test15 + -n100 -m16 -s10 -z2 + -n100 -u0 -m0 -R25 -r25 -i + nr_ulsim.test1 nr_ulsim.test2 nr_ulsim.test3 nr_ulsim.test4 nr_ulsim.test5 nr_ulsim.test6 nr_ulsim.test7 nr_ulsim.test8 nr_ulsim.test9 nr_ulsim.test10 nr_ulsim.test11 nr_ulsim.test12 nr_ulsim.test13 nr_ulsim.test14 nr_ulsim.test15 nr_ulsim.test16 PUSCH test OK segmentation fault|assertion|exiting|fatal 3 From ce1613ad7c73faf60500980f3c212dd4e748eced Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 15 Mar 2022 18:55:50 +0000 Subject: [PATCH 042/105] Improvement in nr_get_csi_rs_signal() and nr_csi_rs_channel_estimation() to later be easier to extend to multiple ports --- openair1/PHY/INIT/nr_init_ue.c | 16 +- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 29 +++- openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 192 +++++++++++++-------- openair1/PHY/defs_nr_common.h | 15 +- 5 files changed, 169 insertions(+), 85 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index a8db7203c7..f4d958dae9 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -367,13 +367,17 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) ue->nr_csi_rs_info->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); ue->nr_csi_rs_info->csi_rs_generated_signal = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); ue->nr_csi_rs_info->csi_rs_received_signal = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); - ue->nr_csi_rs_info->csi_rs_ls_estimated_channel = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); - ue->nr_csi_rs_info->csi_rs_estimated_channel_freq = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); + ue->nr_csi_rs_info->csi_rs_ls_estimated_channel = (int32_t ***)malloc16(fp->nb_antennas_rx * sizeof(int32_t **) ); + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq = (int32_t ***)malloc16(fp->nb_antennas_rx * sizeof(int32_t **) ); for (i=0; inb_antennas_rx; i++) { ue->nr_csi_rs_info->csi_rs_generated_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); ue->nr_csi_rs_info->csi_rs_received_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); - ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); - ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size * sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i] = (int32_t **) malloc16_clear(NR_MAX_NB_PORTS * sizeof(int32_t *)); + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i] = (int32_t **) malloc16_clear(NR_MAX_NB_PORTS * sizeof(int32_t *)); + for (j=0; jnr_csi_rs_info->csi_rs_ls_estimated_channel[i][j] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i][j] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size * sizeof(int32_t)); + } } ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); @@ -655,6 +659,10 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) for (int i = 0; i < fp->nb_antennas_rx; i++) { free_and_zero(ue->nr_csi_rs_info->csi_rs_generated_signal[i]); free_and_zero(ue->nr_csi_rs_info->csi_rs_received_signal[i]); + for (int j=0; jnr_csi_rs_info->csi_rs_ls_estimated_channel[i][j]); + free_and_zero(ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i][j]); + } free_and_zero(ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i]); free_and_zero(ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i]); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index 0f687d6878..64198e1318 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -592,7 +592,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } } - nr_csi_rs_info->k_list_length = 0; + nr_csi_rs_info->N_ports = 0; uint16_t start_sc = frame_parms.first_carrier_offset; // resource mapping according to 38.211 7.4.1.5.3 @@ -600,11 +600,14 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, if ( (csi_params->freq_density > 1) || (csi_params->freq_density == (n%2))) { // for freq density 0.5 checks if even or odd RB for (int ji=0; jiN_ports<(p+1)) { + nr_csi_rs_info->N_ports = p+1; + } + for (kp=0; kp<=kprime; kp++) { // loop over frequency resource elements within a group k = (start_sc+(n*NR_NB_SC_PER_RB)+koverline[ji]+kp)%(frame_parms.ofdm_symbol_size); // frequency index of current resource element - nr_csi_rs_info->map_list[nr_csi_rs_info->k_list_length] = k; - nr_csi_rs_info->k_list_length++; // wf according to tables 7.4.5.3-2 to 7.4.5.3-5 if (kp == 0) wf = 1; @@ -648,5 +651,23 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } } } - } + } + nr_csi_rs_info->N_cdm_groups = size; + nr_csi_rs_info->CDM_group_size = gs; + nr_csi_rs_info->kprime = kprime; + nr_csi_rs_info->lprime = lprime; + memcpy(nr_csi_rs_info->j,j,16*sizeof(uint8_t)); + memcpy(nr_csi_rs_info->koverline,koverline,16*sizeof(uint8_t)); + memcpy(nr_csi_rs_info->loverline,loverline,16*sizeof(uint8_t)); + +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "nr_csi_rs_info->N_ports = %d\n", nr_csi_rs_info->N_ports); + LOG_I(NR_PHY, "nr_csi_rs_info->N_cdm_groups = %d\n", nr_csi_rs_info->N_cdm_groups); + LOG_I(NR_PHY, "nr_csi_rs_info->CDM_group_size = %d\n", nr_csi_rs_info->CDM_group_size); + LOG_I(NR_PHY, "nr_csi_rs_info->kprime = %d\n", nr_csi_rs_info->kprime); + LOG_I(NR_PHY, "nr_csi_rs_info->lprime = %d\n", nr_csi_rs_info->lprime); + for(int ji=0; jiN_cdm_groups; ji++) { + LOG_I(NR_PHY, "(CDM group %d) j = %d, koverline = %d, loverline = %d\n", ji, nr_csi_rs_info->j[ji], nr_csi_rs_info->koverline[ji], nr_csi_rs_info->loverline[ji]); + } +#endif } diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c index 5d3362a8c7..85084deae5 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c @@ -287,7 +287,7 @@ short filt16_end[16] = { // CSI-RS short filt24_start[24] = { 12288,11605,10923,10240,9557,8875,8192,7509,6827,6144,5461,4779, - 4096,0,0,0,0,0,0,0,0,0,0,0}; + 0,0,0,0,0,0,0,0,0,0,0,0}; short filt24_end[24] = { 4096,4779,5461,6144,6827,7509,8192,8875,9557,10240,10923,11605, diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index cc7906fabf..0ae52ec62d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -99,31 +99,50 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, int32_t **rxdataF = ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { - memset(csi_rs_received_signal[ant], 0, frame_parms->samples_per_frame_wCP*sizeof(int32_t)); - for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { - if(!is_csi_rs_in_symbol(*csirs_config_pdu, symb)) { + for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { + memset(csi_rs_received_signal[ant_rx], 0, frame_parms->samples_per_frame_wCP*sizeof(int32_t)); + + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { + + // for freq density 0.5 checks if even or odd RB + if(csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { continue; } - uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; - int16_t *rx_signal = (int16_t*)&rxdataF[ant][symbol_offset]; - int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant][symbol_offset]; - for(int k_id = 0; k_idk_list_length; k_id++) { - uint16_t k = nr_csi_rs_info->map_list[k_id]; - rx_csi_rs_signal[k<<1] = rx_signal[k<<1]; - rx_csi_rs_signal[(k<<1)+1] = rx_signal[(k<<1)+1]; + + for (int cdm_id = 0; cdm_id < nr_csi_rs_info->N_cdm_groups; cdm_id++) { + for (int s = 0; s < nr_csi_rs_info->CDM_group_size; s++) { + + // loop over frequency resource elements within a group + for (int kp = 0; kp <= nr_csi_rs_info->kprime; kp++) { + + uint16_t k = (frame_parms->first_carrier_offset + (rb*NR_NB_SC_PER_RB)+nr_csi_rs_info->koverline[cdm_id] + kp) % frame_parms->ofdm_symbol_size; + + // loop over time resource elements within a group + for (int lp = 0; lp <= nr_csi_rs_info->lprime; lp++) { + uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *rx_signal = (int16_t*)&rxdataF[ant_rx][symbol_offset]; + int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; + rx_csi_rs_signal[k<<1] = rx_signal[k<<1]; + rx_csi_rs_signal[(k<<1)+1] = rx_signal[(k<<1)+1]; #ifdef NR_CSIRS_DEBUG - int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; - int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[ant][symbol_offset+dataF_offset]; - LOG_I(NR_PHY, "l,k (%2d,%3d) |\ttx (%4d,%4d)\trx (%4d,%4d)\n", - symb, - nr_csi_rs_info->map_list[k_id], - tx_csi_rs_signal[k<<1], - tx_csi_rs_signal[(k<<1)+1], - rx_csi_rs_signal[k<<1], - rx_csi_rs_signal[(k<<1)+1]); + int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; + uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; + int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + LOG_I(NR_PHY, "l,k (%2d,%3d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\n", + symb, + k, + port_tx+3000, + tx_csi_rs_signal[k<<1], + tx_csi_rs_signal[(k<<1)+1], + ant_rx, + rx_csi_rs_signal[k<<1], + rx_csi_rs_signal[(k<<1)+1]); #endif + } + } + } } } } @@ -137,80 +156,104 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, nr_csi_rs_info_t *nr_csi_rs_info, int32_t **csi_rs_generated_signal, int32_t **csi_rs_received_signal, - int32_t **csi_rs_estimated_channel_freq, + int32_t ***csi_rs_estimated_channel_freq, uint32_t *noise_power) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; - for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { + for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { /// LS channel estimation - for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { - if(!is_csi_rs_in_symbol(*csirs_config_pdu, symb)) { + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + memset(nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx], 0, frame_parms->samples_per_frame_wCP*sizeof(int32_t)); + } + + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { + + // for freq density 0.5 checks if even or odd RB + if(csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { continue; } - uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; - int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[ant][symbol_offset+dataF_offset]; - int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant][symbol_offset]; - int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant][symbol_offset]; - for(int k_id = 0; k_idk_list_length; k_id++) { - uint16_t k = nr_csi_rs_info->map_list[k_id]; - csi_rs_ls_estimated_channel[k<<1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[k<<1] + (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[(k<<1)+1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); - csi_rs_ls_estimated_channel[(k<<1)+1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[(k<<1)+1] - (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[k<<1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + for (int cdm_id = 0; cdm_id < nr_csi_rs_info->N_cdm_groups; cdm_id++) { + for (int s = 0; s < nr_csi_rs_info->CDM_group_size; s++) { + + uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; + + // loop over frequency resource elements within a group + for (int kp = 0; kp <= nr_csi_rs_info->kprime; kp++) { + + uint16_t k = (frame_parms->first_carrier_offset + (rb*NR_NB_SC_PER_RB)+nr_csi_rs_info->koverline[cdm_id] + kp) % frame_parms->ofdm_symbol_size; + + // loop over time resource elements within a group + for (int lp = 0; lp <= nr_csi_rs_info->lprime; lp++) { + uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; + + csi_rs_ls_estimated_channel[k<<1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[k<<1] + (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[(k<<1)+1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + csi_rs_ls_estimated_channel[(k<<1)+1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[(k<<1)+1] - (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[k<<1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); #ifdef NR_CSIRS_DEBUG - LOG_I(NR_PHY, "l,k (%2d,%3d) |\ttx (%4d,%4d)\trx (%4d,%4d)\tls (%4d,%4d)\n", - symb, - nr_csi_rs_info->map_list[k_id], - tx_csi_rs_signal[k<<1], - tx_csi_rs_signal[(k<<1)+1], - rx_csi_rs_signal[k<<1], - rx_csi_rs_signal[(k<<1)+1], - csi_rs_ls_estimated_channel[k<<1], - csi_rs_ls_estimated_channel[(k<<1)+1]); + LOG_I(NR_PHY, "l,k (%2d,%4d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\tls (%4d,%4d)\n", + symb, + k, + port_tx+3000, + tx_csi_rs_signal[k<<1], + tx_csi_rs_signal[(k<<1)+1], + ant_rx, + rx_csi_rs_signal[k<<1], + rx_csi_rs_signal[(k<<1)+1], + csi_rs_ls_estimated_channel[k<<1], + csi_rs_ls_estimated_channel[(k<<1)+1]); #endif + } + } + } } } /// Channel interpolation + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + memset(csi_rs_estimated_channel_freq[ant_rx][port_tx], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); + } + int16_t ls_estimated[2]; - memset(csi_rs_estimated_channel_freq[ant], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); - for (int k_id = 0; k_id < nr_csi_rs_info->k_list_length; k_id++) { + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { - uint16_t k = nr_csi_rs_info->map_list[k_id]; - int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant][k]; - - // There are many possibilities to allocate the CSI-RS in time, which would take the implementation of many filters. - // In this approach, the LS for each symbol would be different, and it would be necessary to interpolate each symbol - // on the frequency as well. To reduce this complexity, and lower the processing time, we will assume that the - // slot duration is less than the channel coherence time. Therefore, the LS of each symbol (for the same subcarrier) - // would be the same, and it will only be necessary to do the frequency interpolation for 1 symbol, as the result - // for the others would be the same. - int Nsymb = 0; - int32_t sum_csi_rs_ls_real = 0; - int32_t sum_csi_rs_ls_imag = 0; - for (int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { - if (!is_csi_rs_in_symbol(*csirs_config_pdu, symb)) { - continue; - } - Nsymb++; - uint64_t symbol_offset = symb * frame_parms->ofdm_symbol_size; - int16_t *csi_rs_ls_estimated_channel = (int16_t *) &nr_csi_rs_info->csi_rs_ls_estimated_channel[ant][symbol_offset]; - sum_csi_rs_ls_real += csi_rs_ls_estimated_channel[k << 1]; - sum_csi_rs_ls_imag += csi_rs_ls_estimated_channel[(k << 1) + 1]; + // for freq density 0.5 checks if even or odd RB + if(csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { + continue; } - ls_estimated[0] = (int16_t) (sum_csi_rs_ls_real / Nsymb); - ls_estimated[1] = (int16_t) (sum_csi_rs_ls_imag / Nsymb); - if( (k_id == 0) || (k_id > 0 && k < nr_csi_rs_info->map_list[k_id-1]) ) { // First occupied subcarrier case or Start of OFDM symbol case + // TODO: Extend this to multiple antenna ports + int cdm_id = 0; + int s = 0; + int kp = 0; + int lp = 0; + + uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; + + uint16_t k = (frame_parms->first_carrier_offset + (rb*NR_NB_SC_PER_RB)+nr_csi_rs_info->koverline[cdm_id] + kp) % frame_parms->ofdm_symbol_size; + uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; + int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k]; + + ls_estimated[0] = (int16_t) csi_rs_ls_estimated_channel[k<<1]; + ls_estimated[1] = (int16_t) csi_rs_ls_estimated_channel[(k<<1)+1]; + + if( (k == 0) || (k == frame_parms->first_carrier_offset) ) { // Start of OFDM symbol case or first occupied subcarrier case multadd_real_vector_complex_scalar(filt24_start, ls_estimated, csi_rs_estimated_channel16, 24); - } else if( (k_id < nr_csi_rs_info->k_list_length-1 && nr_csi_rs_info->map_list[k_id+1] < k) || - (k_id == nr_csi_rs_info->k_list_length-1) ) { // End of OFDM symbol case or Last occupied subcarrier case + } else if( ( (k + NR_NB_SC_PER_RB) >= frame_parms->ofdm_symbol_size) || + (rb == (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs-1)) ) { // End of OFDM symbol case or Last occupied subcarrier case multadd_real_vector_complex_scalar(filt24_end, ls_estimated, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); } else { // Middle case multadd_real_vector_complex_scalar(filt24_middle, ls_estimated, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); @@ -219,9 +262,14 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, #ifdef NR_CSIRS_DEBUG - uint64_t symbol_offset = csirs_config_pdu->symb_l0*frame_parms->ofdm_symbol_size; - int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant][symbol_offset]; - int16_t *csi_rs_estimated_channel16 = (int16_t*)&nr_csi_rs_info->csi_rs_estimated_channel_freq[ant][0]; + int cdm_id = 0; + int s = 0; + int lp = 0; + uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; + uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; + int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][0]; for(int k = 0; kofdm_symbol_size; k++) { LOG_I(NR_PHY, "(%4d) |\tls (%4d,%4d)\tint (%4d,%4d)\n", diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index cbc8bc8508..cfe5e8b9df 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -94,6 +94,7 @@ #define NR_MAX_NB_RBG 18 #define NR_MAX_NB_LAYERS 2 // 8 // SU-MIMO (3GPP TS 38.211 V15.4.0 section 7.3.1.3) +#define NR_MAX_NB_PORTS 32 #define NR_MAX_NB_CODEWORDS 2 #define NR_MAX_NB_HARQ_PROCESSES 16 #define NR_MAX_PDSCH_ENCODED_LENGTH (NR_MAX_NB_RB*NR_SYMBOLS_PER_SLOT*NR_NB_SC_PER_RB*8*NR_MAX_NB_LAYERS) // 8 is the maximum modulation order (it was 950984 before !!) @@ -265,14 +266,20 @@ typedef struct { } nr_srs_info_t; typedef struct { + uint8_t N_cdm_groups; + uint8_t CDM_group_size; + uint8_t kprime; + uint8_t lprime; + uint8_t N_ports; + uint8_t j[16]; + uint8_t koverline[16]; + uint8_t loverline[16]; uint32_t ***nr_gold_csi_rs; - uint16_t k_list_length; - uint16_t map_list[NR_MAX_CSI_RS_LENGTH]; uint8_t csi_rs_generated_signal_bits; int32_t **csi_rs_generated_signal; int32_t **csi_rs_received_signal; - int32_t **csi_rs_ls_estimated_channel; - int32_t **csi_rs_estimated_channel_freq; + int32_t ***csi_rs_ls_estimated_channel; + int32_t ***csi_rs_estimated_channel_freq; uint32_t *noise_power; } nr_csi_rs_info_t; From 8b0409d349390cc19a5cf0e076fd7e044d5ad09a Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 16 Mar 2022 01:34:23 +0000 Subject: [PATCH 043/105] Channel estimation based on CSI-RS and interpolation working for a gNB with 2 antenna ports --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 109 ++++++++++++++++---------- 1 file changed, 69 insertions(+), 40 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 0ae52ec62d..da86260d5b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -130,7 +130,7 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; - LOG_I(NR_PHY, "l,k (%2d,%3d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\n", + LOG_I(NR_PHY, "l,k (%2d,%4d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\n", symb, k, port_tx+3000, @@ -150,6 +150,34 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, return 0; } +int get_wf(int kp, int s) { + int wf = 0; + if (kp == 0) { + wf = 1; + } else { + wf = -2*(s%2)+1; + } + return wf; +} + +int get_wt(int lp, int s) { + int wt = 0; + if (s < 2) { + wt = 1; + } else if (s < 4) { + wt = -2*(lp%2)+1; + } else if (s < 6) { + wt = -2*(lp/2)+1; + } else { + if ((lp == 0) || (lp == 3)) { + wt = 1; + } else { + wt = -1; + } + } + return wt; +} + int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, @@ -223,8 +251,6 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, memset(csi_rs_estimated_channel_freq[ant_rx][port_tx], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); } - int16_t ls_estimated[2]; - for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { // for freq density 0.5 checks if even or odd RB @@ -232,52 +258,55 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, continue; } - // TODO: Extend this to multiple antenna ports - int cdm_id = 0; - int s = 0; - int kp = 0; - int lp = 0; + int16_t ls_estimated[nr_csi_rs_info->N_ports][2]; + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + memset(ls_estimated[port_tx], 0, 2*sizeof(int16_t)); + } - uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; + for (int cdm_id = 0; cdm_id < nr_csi_rs_info->N_cdm_groups; cdm_id++) { + for (int s = 0; s < nr_csi_rs_info->CDM_group_size; s++) { + uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; + for (int kp = 0; kp <= nr_csi_rs_info->kprime; kp++) { + uint16_t k = (frame_parms->first_carrier_offset + (rb*NR_NB_SC_PER_RB)+nr_csi_rs_info->koverline[cdm_id] + kp) % frame_parms->ofdm_symbol_size; + for (int lp = 0; lp <= nr_csi_rs_info->lprime; lp++) { + uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; + int w = get_wf(kp,s)*get_wt(lp,s); + ls_estimated[port_tx][0] += (int16_t) w*csi_rs_ls_estimated_channel[k<<1]; + ls_estimated[port_tx][1] += (int16_t) w*csi_rs_ls_estimated_channel[(k<<1)+1]; + } + } + } + } - uint16_t k = (frame_parms->first_carrier_offset + (rb*NR_NB_SC_PER_RB)+nr_csi_rs_info->koverline[cdm_id] + kp) % frame_parms->ofdm_symbol_size; - uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; - uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; - - int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; - int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k]; - - ls_estimated[0] = (int16_t) csi_rs_ls_estimated_channel[k<<1]; - ls_estimated[1] = (int16_t) csi_rs_ls_estimated_channel[(k<<1)+1]; - - if( (k == 0) || (k == frame_parms->first_carrier_offset) ) { // Start of OFDM symbol case or first occupied subcarrier case - multadd_real_vector_complex_scalar(filt24_start, ls_estimated, csi_rs_estimated_channel16, 24); - } else if( ( (k + NR_NB_SC_PER_RB) >= frame_parms->ofdm_symbol_size) || + uint16_t k = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k]; + if( (k == 0) || (k == frame_parms->first_carrier_offset) ) { // Start of OFDM symbol case or first occupied subcarrier case + multadd_real_vector_complex_scalar(filt24_start, ls_estimated[port_tx], csi_rs_estimated_channel16, 24); + } else if( ( (k + NR_NB_SC_PER_RB) >= frame_parms->ofdm_symbol_size) || (rb == (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs-1)) ) { // End of OFDM symbol case or Last occupied subcarrier case - multadd_real_vector_complex_scalar(filt24_end, ls_estimated, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); - } else { // Middle case - multadd_real_vector_complex_scalar(filt24_middle, ls_estimated, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + multadd_real_vector_complex_scalar(filt24_end, ls_estimated[port_tx], csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + } else { // Middle case + multadd_real_vector_complex_scalar(filt24_middle, ls_estimated[port_tx], csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + } } } #ifdef NR_CSIRS_DEBUG - int cdm_id = 0; - int s = 0; - int lp = 0; - uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; - uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; - uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; - int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; - int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][0]; - + uint64_t symbol_offset = csirs_config_pdu->symb_l0*frame_parms->ofdm_symbol_size; for(int k = 0; kofdm_symbol_size; k++) { - LOG_I(NR_PHY, "(%4d) |\tls (%4d,%4d)\tint (%4d,%4d)\n", - k, - csi_rs_ls_estimated_channel[k<<1], - csi_rs_ls_estimated_channel[(k<<1)+1], - csi_rs_estimated_channel16[k<<1], - csi_rs_estimated_channel16[(k<<1)+1]); + LOG_I(NR_PHY, "(k = %4d) |\t", k); + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + printf("Channel port_tx %d --> ant_rx %d : ", port_tx+3000, ant_rx); + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; + printf("ls (%4d,%4d), ", csi_rs_ls_estimated_channel[k<<1], csi_rs_ls_estimated_channel[(k<<1)+1]); + int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][0]; + printf("int (%4d,%4d) | ", csi_rs_estimated_channel16[k<<1], csi_rs_estimated_channel16[(k<<1)+1]); + } + printf("\n"); } #endif From f1eb2e15d4402b5a2abe415af1d98449f0ae590c Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 16 Mar 2022 13:03:31 +0000 Subject: [PATCH 044/105] Channel estimation based on CSI-RS and interpolation at UE working for a gNB with 4 antenna ports --- openair1/PHY/INIT/nr_init_ue.c | 6 ++++-- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 7 +------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index f4d958dae9..97efd4e342 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -365,12 +365,14 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) } } ue->nr_csi_rs_info->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); - ue->nr_csi_rs_info->csi_rs_generated_signal = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); + ue->nr_csi_rs_info->csi_rs_generated_signal = (int32_t **)malloc16(NR_MAX_NB_PORTS * sizeof(int32_t *) ); + for (i=0; inr_csi_rs_info->csi_rs_generated_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); + } ue->nr_csi_rs_info->csi_rs_received_signal = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); ue->nr_csi_rs_info->csi_rs_ls_estimated_channel = (int32_t ***)malloc16(fp->nb_antennas_rx * sizeof(int32_t **) ); ue->nr_csi_rs_info->csi_rs_estimated_channel_freq = (int32_t ***)malloc16(fp->nb_antennas_rx * sizeof(int32_t **) ); for (i=0; inb_antennas_rx; i++) { - ue->nr_csi_rs_info->csi_rs_generated_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); ue->nr_csi_rs_info->csi_rs_received_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i] = (int32_t **) malloc16_clear(NR_MAX_NB_PORTS * sizeof(int32_t *)); ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i] = (int32_t **) malloc16_clear(NR_MAX_NB_PORTS * sizeof(int32_t *)); diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index 64198e1318..b1688e25ec 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -592,7 +592,6 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } } - nr_csi_rs_info->N_ports = 0; uint16_t start_sc = frame_parms.first_carrier_offset; // resource mapping according to 38.211 7.4.1.5.3 @@ -600,12 +599,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, if ( (csi_params->freq_density > 1) || (csi_params->freq_density == (n%2))) { // for freq density 0.5 checks if even or odd RB for (int ji=0; jiN_ports<(p+1)) { - nr_csi_rs_info->N_ports = p+1; - } - for (kp=0; kp<=kprime; kp++) { // loop over frequency resource elements within a group k = (start_sc+(n*NR_NB_SC_PER_RB)+koverline[ji]+kp)%(frame_parms.ofdm_symbol_size); // frequency index of current resource element // wf according to tables 7.4.5.3-2 to 7.4.5.3-5 @@ -656,6 +650,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, nr_csi_rs_info->CDM_group_size = gs; nr_csi_rs_info->kprime = kprime; nr_csi_rs_info->lprime = lprime; + nr_csi_rs_info->N_ports = ports; memcpy(nr_csi_rs_info->j,j,16*sizeof(uint8_t)); memcpy(nr_csi_rs_info->koverline,koverline,16*sizeof(uint8_t)); memcpy(nr_csi_rs_info->loverline,loverline,16*sizeof(uint8_t)); From 2f9d8e759dc534aa8ca09bb0ccc2804604c4a58f Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 16 Mar 2022 15:21:55 +0000 Subject: [PATCH 045/105] Memory optimization for procedures related to CSI-RS channel estimation --- openair1/PHY/INIT/nr_init_ue.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 88 ++++++++++++--------------- 2 files changed, 41 insertions(+), 49 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 97efd4e342..b6a1f9dceb 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -377,7 +377,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i] = (int32_t **) malloc16_clear(NR_MAX_NB_PORTS * sizeof(int32_t *)); ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i] = (int32_t **) malloc16_clear(NR_MAX_NB_PORTS * sizeof(int32_t *)); for (j=0; jnr_csi_rs_info->csi_rs_ls_estimated_channel[i][j] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i][j] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size * sizeof(int32_t)); ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i][j] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size * sizeof(int32_t)); } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index da86260d5b..b324aa6d0b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -195,7 +195,7 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, /// LS channel estimation for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { - memset(nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx], 0, frame_parms->samples_per_frame_wCP*sizeof(int32_t)); + memset(nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); } for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { @@ -213,38 +213,54 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, // loop over frequency resource elements within a group for (int kp = 0; kp <= nr_csi_rs_info->kprime; kp++) { - uint16_t k = (frame_parms->first_carrier_offset + (rb*NR_NB_SC_PER_RB)+nr_csi_rs_info->koverline[cdm_id] + kp) % frame_parms->ofdm_symbol_size; + uint16_t kinit = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; + uint16_t k = kinit + nr_csi_rs_info->koverline[cdm_id] + kp; // loop over time resource elements within a group for (int lp = 0; lp <= nr_csi_rs_info->lprime; lp++) { uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; - int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + int16_t *tx_csi_rs_signal = (int16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; - int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; - csi_rs_ls_estimated_channel[k<<1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[k<<1] + (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[(k<<1)+1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); - csi_rs_ls_estimated_channel[(k<<1)+1] = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[(k<<1)+1] - (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[k<<1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + int16_t csi_rs_ls_estimated_channel_re = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[k<<1] + (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[(k<<1)+1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + int16_t csi_rs_ls_estimated_channel_im = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[(k<<1)+1] - (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[k<<1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); -#ifdef NR_CSIRS_DEBUG - LOG_I(NR_PHY, "l,k (%2d,%4d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\tls (%4d,%4d)\n", - symb, - k, - port_tx+3000, - tx_csi_rs_signal[k<<1], - tx_csi_rs_signal[(k<<1)+1], - ant_rx, - rx_csi_rs_signal[k<<1], - rx_csi_rs_signal[(k<<1)+1], - csi_rs_ls_estimated_channel[k<<1], - csi_rs_ls_estimated_channel[(k<<1)+1]); -#endif + // This is not just the LS estimation for each (k,l), but also the sum of the different contributions + // for the sake of optimizing the memory used. + int w = get_wf(kp,s)*get_wt(lp,s); + csi_rs_ls_estimated_channel[kinit<<1] += w*csi_rs_ls_estimated_channel_re; + csi_rs_ls_estimated_channel[(kinit<<1)+1] += w*csi_rs_ls_estimated_channel_im; } } } } } +#ifdef NR_CSIRS_DEBUG + for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { + if(!is_csi_rs_in_symbol(*csirs_config_pdu,symb)) { + continue; + } + for(int k = 0; kofdm_symbol_size; k++) { + LOG_I(NR_PHY, "l,k (%2d,%4d) | ", symb, k); + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *tx_csi_rs_signal = (int16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; + printf("port_tx %d --> ant_rx %d, tx (%4d,%4d), rx (%4d,%4d), ls (%4d,%4d) | ", + port_tx+3000, ant_rx, + tx_csi_rs_signal[k<<1], tx_csi_rs_signal[(k<<1)+1], + rx_csi_rs_signal[k<<1], rx_csi_rs_signal[(k<<1)+1], + csi_rs_ls_estimated_channel[k<<1], csi_rs_ls_estimated_channel[(k<<1)+1]); + } + printf("\n"); + } + } +#endif + /// Channel interpolation for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { @@ -258,57 +274,33 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, continue; } - int16_t ls_estimated[nr_csi_rs_info->N_ports][2]; - for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { - memset(ls_estimated[port_tx], 0, 2*sizeof(int16_t)); - } - - for (int cdm_id = 0; cdm_id < nr_csi_rs_info->N_cdm_groups; cdm_id++) { - for (int s = 0; s < nr_csi_rs_info->CDM_group_size; s++) { - uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; - for (int kp = 0; kp <= nr_csi_rs_info->kprime; kp++) { - uint16_t k = (frame_parms->first_carrier_offset + (rb*NR_NB_SC_PER_RB)+nr_csi_rs_info->koverline[cdm_id] + kp) % frame_parms->ofdm_symbol_size; - for (int lp = 0; lp <= nr_csi_rs_info->lprime; lp++) { - uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; - uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; - int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; - int w = get_wf(kp,s)*get_wt(lp,s); - ls_estimated[port_tx][0] += (int16_t) w*csi_rs_ls_estimated_channel[k<<1]; - ls_estimated[port_tx][1] += (int16_t) w*csi_rs_ls_estimated_channel[(k<<1)+1]; - } - } - } - } - uint16_t k = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][k]; int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k]; if( (k == 0) || (k == frame_parms->first_carrier_offset) ) { // Start of OFDM symbol case or first occupied subcarrier case - multadd_real_vector_complex_scalar(filt24_start, ls_estimated[port_tx], csi_rs_estimated_channel16, 24); + multadd_real_vector_complex_scalar(filt24_start, csi_rs_ls_estimated_channel, csi_rs_estimated_channel16, 24); } else if( ( (k + NR_NB_SC_PER_RB) >= frame_parms->ofdm_symbol_size) || (rb == (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs-1)) ) { // End of OFDM symbol case or Last occupied subcarrier case - multadd_real_vector_complex_scalar(filt24_end, ls_estimated[port_tx], csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + multadd_real_vector_complex_scalar(filt24_end, csi_rs_ls_estimated_channel, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); } else { // Middle case - multadd_real_vector_complex_scalar(filt24_middle, ls_estimated[port_tx], csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + multadd_real_vector_complex_scalar(filt24_middle, csi_rs_ls_estimated_channel, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); } } } #ifdef NR_CSIRS_DEBUG - - uint64_t symbol_offset = csirs_config_pdu->symb_l0*frame_parms->ofdm_symbol_size; for(int k = 0; kofdm_symbol_size; k++) { LOG_I(NR_PHY, "(k = %4d) |\t", k); for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { printf("Channel port_tx %d --> ant_rx %d : ", port_tx+3000, ant_rx); - int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][symbol_offset]; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; printf("ls (%4d,%4d), ", csi_rs_ls_estimated_channel[k<<1], csi_rs_ls_estimated_channel[(k<<1)+1]); int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][0]; printf("int (%4d,%4d) | ", csi_rs_estimated_channel16[k<<1], csi_rs_estimated_channel16[(k<<1)+1]); } printf("\n"); } - #endif } From 3f88cc1fb109de78cd154b9da1ea159691c8b6b3 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 16 Mar 2022 17:19:36 +0000 Subject: [PATCH 046/105] Intermediate commit: move CSI configuration to a separate function --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 458 ++++++++++++++-------------- 1 file changed, 233 insertions(+), 225 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index b8195d21d9..d3c86d62a0 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1001,6 +1001,237 @@ long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS) { return c_srs; } +void fill_default_csi_MeasConfig(int uid, + NR_SetupRelease_CSI_MeasConfig_t *setupRelease_csi_MeasConfig, + NR_ServingCellConfigCommon_t *scc, + rrc_gNB_carrier_data_t *carrier) { + + int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + + setupRelease_csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; + NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); + setupRelease_csi_MeasConfig->choice.setup = csi_MeasConfig; + + if (carrier->pdsch_AntennaPorts > 1) { + csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList)); + NR_CSI_IM_Resource_t *imres0 = calloc(1,sizeof(*imres0)); + imres0->csi_IM_ResourceId = 0; + imres0->csi_IM_ResourceElementPattern = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern)); + imres0->csi_IM_ResourceElementPattern->present = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern_PR_pattern1; + imres0->csi_IM_ResourceElementPattern->choice.pattern1 = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern->choice.pattern1)); + imres0->csi_IM_ResourceElementPattern->choice.pattern1->subcarrierLocation_p1 = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern__pattern1__subcarrierLocation_p1_s4; + imres0->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1 = 6; + imres0->freqBand = calloc(1,sizeof(*imres0->freqBand)); + imres0->freqBand->startingRB = 0; + imres0->freqBand->nrofRBs = ((curr_bwp>>2)+(curr_bwp%4>0))<<2; + imres0->periodicityAndOffset = calloc(1,sizeof(*imres0->periodicityAndOffset)); + imres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; + imres0->periodicityAndOffset->choice.slots320 = 0; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceToAddModList->list,imres0); + csi_MeasConfig->csi_IM_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceSetToAddModList)); + NR_CSI_IM_ResourceSet_t *imset0 = calloc(1,sizeof(*imset0)); + imset0->csi_IM_ResourceSetId = 0; + NR_CSI_IM_ResourceId_t *res0 = calloc(1,sizeof(*res0)); + *res0 = 0; + ASN_SEQUENCE_ADD(&imset0->csi_IM_Resources,res0); + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceSetToAddModList->list,imset0); + } + else { + csi_MeasConfig->csi_IM_ResourceToAddModList = NULL; + csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL; + } + + csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL; + csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL; + + csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)); + NR_NZP_CSI_RS_ResourceSet_t *nzpcsirs0 = calloc(1,sizeof(*nzpcsirs0)); + nzpcsirs0->nzp_CSI_ResourceSetId = 0; + NR_NZP_CSI_RS_ResourceId_t *nzpid0 = calloc(1,sizeof(*nzpid0)); + *nzpid0 = 0; + ASN_SEQUENCE_ADD(&nzpcsirs0->nzp_CSI_RS_Resources,nzpid0); + nzpcsirs0->repetition = NULL; + nzpcsirs0->aperiodicTriggeringOffset = NULL; + nzpcsirs0->trs_Info = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpcsirs0); + + csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL; + + config_csirs(scc, csi_MeasConfig, uid, carrier->pdsch_AntennaPorts, curr_bwp, carrier->do_CSIRS); + + csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); + csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; + + NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); + ssbresset0->csi_SSB_ResourceSetId=0; + + uint64_t bitmap=0; + switch (scc->ssb_PositionsInBurst->present) { + case 1 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; + break; + case 2 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; + break; + case 3 : + for (int i=0; i<8; i++) { + bitmap |= (((uint64_t) scc->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); + } + break; + default: + AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); + } + + NR_SSB_Index_t *ssbresset[64]; + for (int i=0;i<64;i++) { + if ((bitmap>>(63-i))&0x01){ + ssbresset[i]=calloc(1,sizeof(*ssbresset[i])); + *ssbresset[i] = i; + ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset[i]); + } + } + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); + + csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); + + csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; + NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); + csires0->csi_ResourceConfigId=0; + csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; + csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); + csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList)); + NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0)); + *nzp0 = 0; + ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); + csires0->bwp_Id = 0; + csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); + + + NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); + csires1->csi_ResourceConfigId=1; + csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; + csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); + csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); + NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); + *ssbres00 = 0; + ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); + csires1->bwp_Id = 0; + csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); + + if (carrier->pdsch_AntennaPorts > 1) { + NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); + csires2->csi_ResourceConfigId=2; + csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList; + csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList)); + NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00)); + *csiim00 = 0; + ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); + csires2->bwp_Id=0; + csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2); + } + + NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); + pucchcsires1->uplinkBandwidthPartId=0; + pucchcsires1->pucch_Resource=1; + csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); + csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; + if (carrier->pdsch_AntennaPorts > 1) { + LOG_I(NR_RRC,"Filling CSI Report Config for RI_PMI_CQI\n"); + NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); + csirep1->reportConfigId=0; + csirep1->carrier=NULL; + csirep1->resourcesForChannelMeasurement=0; + csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); + *csirep1->csi_IM_ResourcesForInterference=2; + csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); + csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9 + (20 * uid) % 320; + ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; + csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; + csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); + csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); + *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; + csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); + *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; + csirep1->reportFreqConfiguration->csi_ReportingBand = NULL; +/*calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand)); + csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1); + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254;*/ + csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_notConfigured; + csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_notConfigured; + csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig)); + csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1; + csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); + csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= + calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; + csirep1->dummy = NULL; + csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); + //csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + //*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table)); + *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; + csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value2; + csirep1->non_PMI_PortIndication = NULL; + csirep1->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1); + } + + LOG_I(NR_RRC,"Filling CSI Report Config for CRI_RSRP\n"); + NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); + csirep2->reportConfigId=1; + csirep2->carrier=NULL; + csirep2->resourcesForChannelMeasurement=0; + csirep2->csi_IM_ResourcesForInterference=NULL; + csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); + csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; + ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; + csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; + csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); + csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL; + csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL; + csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; + csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; + csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; + csirep2->codebookConfig=NULL; + csirep2->dummy = NULL; + csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); + csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep2->cqi_Table = NULL; + csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; + csirep2->non_PMI_PortIndication = NULL; + csirep2->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); +} + void fill_initial_SpCellConfig(int uid, NR_SpCellConfig_t *SpCellConfig, NR_ServingCellConfigCommon_t *scc, @@ -1101,7 +1332,6 @@ void fill_initial_SpCellConfig(int uid, pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); - initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config)); initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; NR_PUSCH_Config_t *pusch_Config = calloc(1,sizeof(*pusch_Config)); @@ -1401,232 +1631,10 @@ void fill_initial_SpCellConfig(int uid, SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig; if (carrier->do_CSIRS) { - SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); - SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; - - NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); - SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig; - - if (carrier->pdsch_AntennaPorts > 1) { - csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList)); - NR_CSI_IM_Resource_t *imres0 = calloc(1,sizeof(*imres0)); - imres0->csi_IM_ResourceId = 0; - imres0->csi_IM_ResourceElementPattern = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern)); - imres0->csi_IM_ResourceElementPattern->present = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern_PR_pattern1; - imres0->csi_IM_ResourceElementPattern->choice.pattern1 = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern->choice.pattern1)); - imres0->csi_IM_ResourceElementPattern->choice.pattern1->subcarrierLocation_p1 = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern__pattern1__subcarrierLocation_p1_s4; - imres0->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1 = 6; - imres0->freqBand = calloc(1,sizeof(*imres0->freqBand)); - imres0->freqBand->startingRB = 0; - imres0->freqBand->nrofRBs = ((curr_bwp>>2)+(curr_bwp%4>0))<<2; - imres0->periodicityAndOffset = calloc(1,sizeof(*imres0->periodicityAndOffset)); - imres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; - imres0->periodicityAndOffset->choice.slots320 = 0; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceToAddModList->list,imres0); - csi_MeasConfig->csi_IM_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceSetToAddModList)); - NR_CSI_IM_ResourceSet_t *imset0 = calloc(1,sizeof(*imset0)); - imset0->csi_IM_ResourceSetId = 0; - NR_CSI_IM_ResourceId_t *res0 = calloc(1,sizeof(*res0)); - *res0 = 0; - ASN_SEQUENCE_ADD(&imset0->csi_IM_Resources,res0); - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceSetToAddModList->list,imset0); - } - else { - csi_MeasConfig->csi_IM_ResourceToAddModList = NULL; - csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL; - } - - csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL; - csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL; - - csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)); - NR_NZP_CSI_RS_ResourceSet_t *nzpcsirs0 = calloc(1,sizeof(*nzpcsirs0)); - nzpcsirs0->nzp_CSI_ResourceSetId = 0; - NR_NZP_CSI_RS_ResourceId_t *nzpid0 = calloc(1,sizeof(*nzpid0)); - *nzpid0 = 0; - ASN_SEQUENCE_ADD(&nzpcsirs0->nzp_CSI_RS_Resources,nzpid0); - nzpcsirs0->repetition = NULL; - nzpcsirs0->aperiodicTriggeringOffset = NULL; - nzpcsirs0->trs_Info = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpcsirs0); - - csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL; - - config_csirs(scc, csi_MeasConfig, uid, carrier->pdsch_AntennaPorts, curr_bwp, carrier->do_CSIRS); - - csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); - csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; - - NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); - ssbresset0->csi_SSB_ResourceSetId=0; - - uint64_t bitmap=0; - switch (scc->ssb_PositionsInBurst->present) { - case 1 : - bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; - break; - case 2 : - bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; - break; - case 3 : - for (int i=0; i<8; i++) { - bitmap |= (((uint64_t) scc->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); - } - break; - default: - AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); - } - - NR_SSB_Index_t *ssbresset[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - ssbresset[i]=calloc(1,sizeof(*ssbresset[i])); - *ssbresset[i] = i; - ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset[i]); - } - } - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); - - csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); - - csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; - NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); - csires0->csi_ResourceConfigId=0; - csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; - csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); - csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList)); - NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0)); - *nzp0 = 0; - ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); - csires0->bwp_Id = 0; - csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); - - - NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); - csires1->csi_ResourceConfigId=1; - csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; - csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); - csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); - NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); - *ssbres00 = 0; - ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); - csires1->bwp_Id = 0; - csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); - - if (carrier->pdsch_AntennaPorts > 1) { - NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); - csires2->csi_ResourceConfigId=2; - csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList; - csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList)); - NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00)); - *csiim00 = 0; - ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); - csires2->bwp_Id=0; - csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2); - } - - NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); - pucchcsires1->uplinkBandwidthPartId=0; - pucchcsires1->pucch_Resource=1; - csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); - csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; - if (carrier->pdsch_AntennaPorts > 1) { - LOG_I(NR_RRC,"Filling CSI Report Config for RI_PMI_CQI\n"); - NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); - csirep1->reportConfigId=0; - csirep1->carrier=NULL; - csirep1->resourcesForChannelMeasurement=0; - csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); - *csirep1->csi_IM_ResourcesForInterference=2; - csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; - csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); - csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9 + (20 * uid) % 320; - ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; - csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; - csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); - csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); - *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; - csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); - *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; - csirep1->reportFreqConfiguration->csi_ReportingBand = NULL; -/*calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand)); - csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1); - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254;*/ - csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_notConfigured; - csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_notConfigured; - csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig)); - csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1; - csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); - csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= - calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; - csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; - csirep1->dummy = NULL; - csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; - csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); - //csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); - //*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; - csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table)); - *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; - csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value2; - csirep1->non_PMI_PortIndication = NULL; - csirep1->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1); - } - - LOG_I(NR_RRC,"Filling CSI Report Config for CRI_RSRP\n"); - NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); - csirep2->reportConfigId=1; - csirep2->carrier=NULL; - csirep2->resourcesForChannelMeasurement=0; - csirep2->csi_IM_ResourcesForInterference=NULL; - csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; - csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); - csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; - ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; - csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; - csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); - csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL; - csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL; - csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; - csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; - csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; - csirep2->codebookConfig=NULL; - csirep2->dummy = NULL; - csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; - csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); - csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); - *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; - csirep2->cqi_Table = NULL; - csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; - csirep2->non_PMI_PortIndication = NULL; - csirep2->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); + fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig, scc, carrier); } + pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; pdsch_servingcellconfig->xOverhead = NULL; pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH)); From ea22da6e7a71f58631c4b730a6208b519793710c Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 17 Mar 2022 00:50:35 +0000 Subject: [PATCH 047/105] Noise power estimation based on CSI-RS --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 53 +++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index b324aa6d0b..13c1c67c16 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -178,6 +178,21 @@ int get_wt(int lp, int s) { return wt; } +uint32_t calc_power_csirs(uint16_t *x, fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu) { + uint64_t sum_x = 0; + uint64_t sum_x2 = 0; + uint16_t size = 0; + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { + if (csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { + continue; + } + sum_x = sum_x + x[rb-csirs_config_pdu->start_rb]; + sum_x2 = sum_x2 + x[rb]*x[rb-csirs_config_pdu->start_rb]; + size++; + } + return sum_x2/size - (sum_x/size)*(sum_x/size); +} + int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, @@ -189,6 +204,7 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; + *noise_power = 0; for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { @@ -289,15 +305,40 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, } } + /// Power noise estimation + uint16_t noise_real[frame_parms->nb_antennas_rx][nr_csi_rs_info->N_ports][csirs_config_pdu->nr_of_rbs]; + uint16_t noise_imag[frame_parms->nb_antennas_rx][nr_csi_rs_info->N_ports][csirs_config_pdu->nr_of_rbs]; + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { + if (csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { + continue; + } + uint16_t k = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][k]; + int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k]; + noise_real[ant_rx][port_tx][rb-csirs_config_pdu->start_rb] = abs(csi_rs_ls_estimated_channel[0]-csi_rs_estimated_channel16[0]); + noise_imag[ant_rx][port_tx][rb-csirs_config_pdu->start_rb] = abs(csi_rs_ls_estimated_channel[1]-csi_rs_estimated_channel16[1]); + } + } + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + *noise_power += (calc_power_csirs(noise_real[ant_rx][port_tx], csirs_config_pdu) + calc_power_csirs(noise_imag[ant_rx][port_tx],csirs_config_pdu)); + } + #ifdef NR_CSIRS_DEBUG for(int k = 0; kofdm_symbol_size; k++) { + int rb = k >= frame_parms->first_carrier_offset ? + (k - frame_parms->first_carrier_offset)/NR_NB_SC_PER_RB : + (k + frame_parms->ofdm_symbol_size - frame_parms->first_carrier_offset)/NR_NB_SC_PER_RB; LOG_I(NR_PHY, "(k = %4d) |\t", k); for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { - printf("Channel port_tx %d --> ant_rx %d : ", port_tx+3000, ant_rx); int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; - printf("ls (%4d,%4d), ", csi_rs_ls_estimated_channel[k<<1], csi_rs_ls_estimated_channel[(k<<1)+1]); int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][0]; - printf("int (%4d,%4d) | ", csi_rs_estimated_channel16[k<<1], csi_rs_estimated_channel16[(k<<1)+1]); + printf("Channel port_tx %d --> ant_rx %d : ls (%4d,%4d), int (%4d,%4d), noise (%4d,%4d) |", + port_tx+3000, ant_rx, + csi_rs_ls_estimated_channel[k<<1], csi_rs_ls_estimated_channel[(k<<1)+1], + csi_rs_estimated_channel16[k<<1], csi_rs_estimated_channel16[(k<<1)+1], + rb >= csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs ? 0 : noise_real[ant_rx][port_tx][rb-csirs_config_pdu->start_rb], + rb >= csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs ? 0 : noise_imag[ant_rx][port_tx][rb-csirs_config_pdu->start_rb]); } printf("\n"); } @@ -305,6 +346,12 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, } + *noise_power /= (frame_parms->nb_antennas_rx*nr_csi_rs_info->N_ports); + +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "Noise power estimation based on CSI-RS: %i\n", *noise_power); +#endif + return 0; } From 8704f810256b6c9a7386643dd677169bb5617293 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 17 Mar 2022 16:35:06 +0000 Subject: [PATCH 048/105] Remove duplicated code --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 791c46f14d..c46fd13ca4 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1041,20 +1041,6 @@ void fill_default_csi_MeasConfig(int uid, csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL; } - csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL; - csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL; - - csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)); - NR_NZP_CSI_RS_ResourceSet_t *nzpcsirs0 = calloc(1,sizeof(*nzpcsirs0)); - nzpcsirs0->nzp_CSI_ResourceSetId = 0; - NR_NZP_CSI_RS_ResourceId_t *nzpid0 = calloc(1,sizeof(*nzpid0)); - *nzpid0 = 0; - ASN_SEQUENCE_ADD(&nzpcsirs0->nzp_CSI_RS_Resources,nzpid0); - nzpcsirs0->repetition = NULL; - nzpcsirs0->aperiodicTriggeringOffset = NULL; - nzpcsirs0->trs_Info = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpcsirs0); - csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL; config_csirs(scc, csi_MeasConfig, uid, carrier->pdsch_AntennaPorts, curr_bwp, carrier->do_CSIRS); From 190eaa1e4247a24e38cccce11f56275bf68cf744 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 17 Mar 2022 16:36:50 +0000 Subject: [PATCH 049/105] Move CSI-RS configuration from fill_initial_SpCellConfig() to update_cellGroupConfig() --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 41 +++++++++++++---------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index c46fd13ca4..224592c98a 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1305,14 +1305,8 @@ void fill_initial_SpCellConfig(int uid, NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); pucchspatial->pucch_SpatialRelationInfoId = 1; pucchspatial->servingCellId = NULL; - if(carrier->do_CSIRS) { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - pucchspatial->referenceSignal.choice.csi_RS_Index = 0; - } - else { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; - } + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; + pucchspatial->referenceSignal.choice.ssb_Index = 0; pucchspatial->pucch_PathlossReferenceRS_Id = 0; pucchspatial->p0_PUCCH_Id = 1; pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; @@ -1616,11 +1610,6 @@ void fill_initial_SpCellConfig(int uid, SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup; SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig; - if (carrier->do_CSIRS) { - SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); - fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig, scc, carrier); - } - pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; pdsch_servingcellconfig->xOverhead = NULL; pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH)); @@ -1733,16 +1722,23 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc = carrier->servingcellconfigcommon; // Config CSI-RS - NR_CSI_MeasConfig_t *csi_MeasConfig; - if(!SpCellConfig->spCellConfigDedicated->csi_MeasConfig) { - csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); - SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig; + if (carrier->do_CSIRS) { + struct NR_PUCCH_Config__spatialRelationInfoToAddModList *spatialRelationInfoToAddModList = calloc(1,sizeof(*spatialRelationInfoToAddModList)); + NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); + pucchspatial->pucch_SpatialRelationInfoId = 1; + pucchspatial->servingCellId = NULL; + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + pucchspatial->referenceSignal.choice.csi_RS_Index = 0; + pucchspatial->pucch_PathlossReferenceRS_Id = 0; + pucchspatial->p0_PUCCH_Id = 1; + pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; + ASN_SEQUENCE_ADD(&spatialRelationInfoToAddModList->list,pucchspatial); + SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->spatialRelationInfoToAddModList = spatialRelationInfoToAddModList; + if(!SpCellConfig->spCellConfigDedicated->csi_MeasConfig) { + SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); + } + fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig, scc, carrier); } - else - csi_MeasConfig = SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; - - int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); - config_csirs(scc, csi_MeasConfig, uid, carrier->pdsch_AntennaPorts, curr_bwp, carrier->do_CSIRS); // Set DL MCS table NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP; @@ -1758,7 +1754,6 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, } } - void fill_initial_cellGroupConfig(int uid, NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc, From f439095c6ee036ca46211352144b11f7a0af2495 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Thu, 17 Mar 2022 18:19:42 +0000 Subject: [PATCH 050/105] Fix bug after merge --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 2927317055..4ef05d660d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -598,9 +598,8 @@ bool allocate_dl_retransmission(module_id_t module_id, } else { /* the retransmission will use a different time domain allocation, check * that we have enough resources */ - NR_pdsch_semi_static_t temp_ps; - temp_ps.nrOfLayers = 1; - nr_set_pdsch_semi_static(scc, cg, sched_ctrl->active_bwp, bwpd,tda, ps->nrOfLayers, sched_ctrl, &temp_ps); + NR_pdsch_semi_static_t temp_ps = *ps; + nr_set_pdsch_semi_static(scc, cg, sched_ctrl->active_bwp, bwpd, tda, ps->nrOfLayers, sched_ctrl, &temp_ps); while (rbStart < bwpSize && !(rballoc_mask[rbStart]&SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) rbStart++; From 7ecd593f6b1972482c66261391f79e14af2c7e1a Mon Sep 17 00:00:00 2001 From: rmagueta Date: Fri, 18 Mar 2022 17:55:53 +0000 Subject: [PATCH 051/105] Fix memory leaks --- openair1/PHY/INIT/nr_init_ue.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 7f1c3544a6..1a4a6c4afc 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -639,8 +639,10 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) free_and_zero(ue->pdcch_vars[th_id][gNB_id]); } - for (int i = 0; i < fp->nb_antennas_rx; i++) { + for (int i=0; inr_csi_rs_info->csi_rs_generated_signal[i]); + } + for (int i = 0; i < fp->nb_antennas_rx; i++) { free_and_zero(ue->nr_csi_rs_info->csi_rs_received_signal[i]); for (int j=0; jnr_csi_rs_info->csi_rs_ls_estimated_channel[i][j]); @@ -679,6 +681,8 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) free_and_zero(ue->nr_srs_info->srs_estimated_channel_time_shifted); free_and_zero(ue->nr_srs_info); + free_and_zero(ue->csiim_vars[gNB_id]); + free_and_zero(ue->csirs_vars[gNB_id]); free_and_zero(ue->srs_vars[gNB_id]); free_and_zero(ue->pbch_vars[gNB_id]); From 199680d24df1bd0ea7529fafd8849e19b64779af Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 21 Mar 2022 17:37:29 +0000 Subject: [PATCH 052/105] Address reviewer comments --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 1 - openair2/LAYER2/NR_MAC_gNB/config.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 492f7c7399..35ca15aa31 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1154,7 +1154,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr (table_7_3_2_3_3_1[dci->antenna_ports.val][2]<<1) + (table_7_3_2_3_3_1[dci->antenna_ports.val][3]<<2) + (table_7_3_2_3_3_1[dci->antenna_ports.val][4]<<3)); - dlsch_config_pdu_1_1->n_front_load_symb = 1; } if ((dmrs_type == NULL) && (max_length != NULL)){ // Table 7.3.1.2.2-2: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=2 diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index b21ddc062c..0ced6725ea 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -433,9 +433,9 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, int minRXTXTIMEpdsch, NR_ServingCellConfigCommon_t *scc, NR_BCCH_BCH_Message_t *mib, - int add_ue, + int add_ue, uint32_t rnti, - NR_CellGroupConfig_t *CellGroup) { + NR_CellGroupConfig_t *CellGroup) { if (scc != NULL ) { AssertFatal((scc->ssb_PositionsInBurst->present > 0) && (scc->ssb_PositionsInBurst->present < 4), "SSB Bitmap type %d is not valid\n",scc->ssb_PositionsInBurst->present); From c6b4f97d19e4d1937174dc1d774520b8603f256c Mon Sep 17 00:00:00 2001 From: francescomani Date: Sat, 26 Mar 2022 13:37:34 +0100 Subject: [PATCH 053/105] coderate according to SCF and get tbs,qm,R only at MAC --- common/utils/nr/nr_common.c | 61 ------------------- common/utils/nr/nr_common.h | 6 -- .../nfapi/public_inc/fapi_nr_ue_interface.h | 3 + openair1/PHY/CODING/coding_defs.h | 12 ---- openair1/PHY/NR_TRANSPORT/nr_dlsch.h | 5 -- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 8 +-- .../NR_TRANSPORT/nr_transport_common_proto.h | 8 --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 11 +--- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 16 ++--- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 9 +-- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 3 +- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 16 ++--- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 3 + openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 6 +- openair1/SIMULATION/NR_PHY/dlschsim.c | 14 +++-- openair1/SIMULATION/NR_PHY/ulschsim.c | 9 ++- openair1/SIMULATION/NR_PHY/ulsim.c | 3 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 17 ++++++ openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 36 +++++++++++ openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 8 +-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 12 ++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 3 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 3 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 3 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 3 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 7 --- 26 files changed, 115 insertions(+), 170 deletions(-) diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index 49743b3bdc..691d6e0824 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -191,67 +191,6 @@ int PRBalloc_to_locationandbandwidth(int NPRB,int RBstart) { return(PRBalloc_to_locationandbandwidth0(NPRB,RBstart,275)); } -/// Target code rate tables indexed by Imcs -/* TS 38.214 table 5.1.3.1-1 - MCS index table 1 for PDSCH */ -uint16_t nr_target_code_rate_table1[29] = {120, 157, 193, 251, 308, 379, 449, 526, 602, 679, 340, 378, 434, 490, 553, \ - 616, 658, 438, 466, 517, 567, 616, 666, 719, 772, 822, 873, 910, 948}; - -/* TS 38.214 table 5.1.3.1-2 - MCS index table 2 for PDSCH */ -// Imcs values 20 and 26 have been multiplied by 2 to avoid the floating point -uint16_t nr_target_code_rate_table2[28] = {120, 193, 308, 449, 602, 378, 434, 490, 553, 616, 658, 466, 517, 567, \ - 616, 666, 719, 772, 822, 873, 1365, 711, 754, 797, 841, 885, 1833, 948}; - -/* TS 38.214 table 5.1.3.1-3 - MCS index table 3 for PDSCH */ -uint16_t nr_target_code_rate_table3[29] = {30, 40, 50, 64, 78, 99, 120, 157, 193, 251, 308, 379, 449, 526, 602, 340, \ - 378, 434, 490, 553, 616, 438, 466, 517, 567, 616, 666, 719, 772}; - -uint16_t nr_tbs_table[93] = {24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 208, 224, 240, 256, 272, 288, 304, 320, \ - 336, 352, 368, 384, 408, 432, 456, 480, 504, 528, 552, 576, 608, 640, 672, 704, 736, 768, 808, 848, 888, 928, 984, 1032, 1064, 1128, 1160, 1192, 1224, 1256, \ - 1288, 1320, 1352, 1416, 1480, 1544, 1608, 1672, 1736, 1800, 1864, 1928, 2024, 2088, 2152, 2216, 2280, 2408, 2472, 2536, 2600, 2664, 2728, 2792, 2856, 2976, \ - 3104, 3240, 3368, 3496, 3624, 3752, 3824}; - -uint8_t nr_get_Qm(uint8_t Imcs, uint8_t table_idx) { - switch(table_idx) { - case 1: - return (((Imcs<10)||(Imcs==29))?2:((Imcs<17)||(Imcs==30))?4:((Imcs<29)||(Imcs==31))?6:-1); - break; - - case 2: - return (((Imcs<5)||(Imcs==28))?2:((Imcs<11)||(Imcs==29))?4:((Imcs<20)||(Imcs==30))?6:((Imcs<28)||(Imcs==31))?8:-1); - break; - - case 3: - return (((Imcs<15)||(Imcs==29))?2:((Imcs<21)||(Imcs==30))?4:((Imcs<29)||(Imcs==31))?6:-1); - break; - - default: - AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx); - return(0); - break; - } -} - -uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx) { - switch(table_idx) { - case 1: - return (nr_target_code_rate_table1[Imcs]); - break; - - case 2: - return (nr_target_code_rate_table2[Imcs]); - break; - - case 3: - return (nr_target_code_rate_table3[Imcs]); - break; - - default: - AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx); - return(0); - break; - } -} - void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset) { uint8_t count=0, start=0, start_set=0; diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index 0150cf59f8..9b55a48b0b 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -69,12 +69,6 @@ int NRRIV2BW(int locationAndBandwidth,int N_RB); int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB); int PRBalloc_to_locationandbandwidth0(int NPRB,int RBstart,int BWPsize); int PRBalloc_to_locationandbandwidth(int NPRB,int RBstart); -extern uint16_t nr_target_code_rate_table1[29]; -extern uint16_t nr_target_code_rate_table2[28]; -extern uint16_t nr_target_code_rate_table3[29]; -extern uint16_t nr_tbs_table[93]; -uint8_t nr_get_Qm(uint8_t Imcs, uint8_t table_idx); -uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx); int get_subband_size(int NPRB,int size); void SLIV2SL(int SLIV,int *S,int *L); int get_dmrs_port(int nl, uint16_t dmrs_ports); diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 284ef22fc4..44a816f5c6 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -433,6 +433,9 @@ typedef struct { uint8_t mcs; uint8_t ndi; uint8_t rv; + uint16_t targetCodeRate; + uint8_t qamModOrder; + uint32_t TBS; uint8_t tb2_mcs; uint8_t tb2_ndi; uint8_t tb2_rv; diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 8fe31f208e..5f2ceeec15 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -469,18 +469,6 @@ int32_t nr_segmentation(unsigned char *input_buffer, unsigned int *F, uint8_t BG); -/*!\fn uint32_t nr_compute_tbs -\brief This function returns the TBS in bits as per 6.1.4.2 of TS 38.214 -*/ -uint32_t nr_compute_tbs(uint16_t Qm, - uint16_t R, - uint16_t nb_rb, - uint16_t nb_symb_sch, - uint16_t nb_dmrs_prb, - uint16_t nb_rb_oh, - uint8_t tb_scaling, - uint8_t Nl); - uint32_t nr_compute_tbslbrm(uint16_t table, uint16_t nb_rb, uint8_t Nl); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h index 28676b49f2..fe50370964 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h @@ -49,11 +49,6 @@ void nr_get_rbg_parms(NR_BWP_PARMS* bwp, uint8_t config_type); void nr_get_rbg_list(uint32_t bitmap, uint8_t n_rbg, uint8_t* rbg_list); - -uint8_t nr_get_Qm(uint8_t Imcs, uint8_t table_idx); - -uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx); - void nr_pdsch_codeword_scrambling(uint8_t *in, uint32_t size, uint8_t q, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 229f59032e..5447c2bd73 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -301,7 +301,6 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15; impp.Zc = &dlsch->harq_process.Z; - float Coderate = 0.0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN); uint32_t A = rel15->TBSize[0]<<3; @@ -364,10 +363,9 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, memcpy(harq->b, a, (A / 8) + 3); // using 3 bytes to mimic the case of 24 bit crc } - if (rel15->targetCodeRate[0]<1000) - Coderate = (float)rel15->targetCodeRate[0] /(float) 1024; - else // to scale for mcs 20 and 26 in table 5.1.3.1-2 which are decimal and input 2* in nr_tbs_tools - Coderate = (float)rel15->targetCodeRate[0] /(float) 2048; + // target_code_rate in terms of 0.1 bits + float Coderate = (float) rel15->targetCodeRate[0] / (float) 10240; + LOG_D(PHY,"DLSCH Coderate %f\n",Coderate); if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) impp.BG = 2; diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index 2daf2af1fb..74d19bf6f6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -60,14 +60,6 @@ uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch, uint8_t nb_re_dmrs, uint uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r); -uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx); - -uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx); - -uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); - -uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); - void compute_nr_prach_seq(uint8_t short_sequence, uint8_t num_sequences, uint8_t rootSequenceIndex, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 49c1b898cc..90a5c7270a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -423,13 +423,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, phy_vars_gNB->nbDecode = 0; harq_process->processedSegments = 0; - - double Coderate = 0.0; // ------------------------------------------------------------------ uint16_t nb_rb = pusch_pdu->rb_size; uint8_t Qm = pusch_pdu->qam_mod_order; - uint16_t R = pusch_pdu->target_code_rate; uint8_t mcs = pusch_pdu->mcs_index; uint8_t n_layers = pusch_pdu->nrOfLayers; // ------------------------------------------------------------------ @@ -458,12 +455,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, A = (harq_process->TBS)<<3; - LOG_D(NR_PHY, "ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d, Coderate %d\n", harq_pid, A, G, mcs, n_layers, nb_rb, Qm, n_layers, R); + // target_code_rate in terms of 0.1 bits + float Coderate = (float) pusch_pdu->target_code_rate / (float) 10240; - if (R<1024) - Coderate = (float) R /(float) 1024; - else - Coderate = (float) R /(float) 2048; + LOG_D(NR_PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d, Coderate %f\n", harq_pid, A, G, mcs, n_layers, nb_rb, Qm, n_layers, Coderate); if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ p_decParams->BG = 2; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 54b7c34608..5cdf6f4b19 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -440,8 +440,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint16_t nb_symb_sch, uint8_t nr_slot_rx, uint8_t harq_pid, - uint8_t is_crnti, - uint8_t llr8_flag) { + uint8_t is_crnti) { uint32_t A,E; uint32_t G; uint32_t ret,offset; @@ -460,7 +459,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint8_t kc; uint32_t Tbslbrm;// = 950984; uint16_t nb_rb;// = 30; - double Coderate;// = 0.0; uint8_t dmrs_Type = harq_process->dmrsConfigType; AssertFatal(dmrs_Type == 0 || dmrs_Type == 1, "Illegal dmrs_type %d\n", dmrs_Type); uint8_t nb_re_dmrs; @@ -510,21 +508,17 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, */ nb_rb = harq_process->nb_rb; harq_process->trials[harq_process->round]++; - uint16_t nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs - harq_process->TBS = nr_compute_tbs(harq_process->Qm,harq_process->R,nb_rb,nb_symb_sch,nb_re_dmrs*dmrs_length, nb_rb_oh, 0, harq_process->Nl); A = harq_process->TBS; ret = dlsch->max_ldpc_iterations + 1; dlsch->last_iteration_cnt = ret; harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, harq_process->Qm,harq_process->Nl); G = harq_process->G; - LOG_D(PHY,"%d.%d DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n", - frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); + // target_code_rate in terms of 0.1 bits + float Coderate = (float) harq_process->R / (float) 10240; - if ((harq_process->R)<1024) - Coderate = (float) (harq_process->R) /(float) 1024; - else - Coderate = (float) (harq_process->R) /(float) 2048; + LOG_D(PHY,"%d.%d DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d Qm %d Coderate %f\n", + frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, harq_process->mcs, harq_process->Nl, nb_symb_sch, nb_rb, harq_process->Qm, Coderate); if ((A <=292) || ((A <= NR_MAX_PDSCH_TBS) && (Coderate <= 0.6667)) || Coderate <= 0.25) { p_decParams->BG = 2; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index f3baa45df4..24bfa9ffc8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -269,13 +269,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, return -1; } - dlsch0_harq->Qm = nr_get_Qm_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); - dlsch0_harq->R = nr_get_code_rate_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); - if (dlsch0_harq->Qm == 0 || dlsch0_harq->R == 0) { - LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\n"); - return -1; - } - #ifdef DEBUG_HARQ printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode); printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1); @@ -3145,7 +3138,7 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, } if (dlsch1_harq) { - switch (nr_get_Qm_dl(dlsch1_harq->mcs,dlsch1_harq->mcs_table)) { + switch (dlsch1_harq->Qm) { case 2 : if (rx_type==rx_standard) { nr_dlsch_qpsk_llr(frame_parms, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index aac59a7da1..db21323cdd 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1040,8 +1040,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint16_t nb_symb_sch, uint8_t nr_slot_rx, uint8_t harq_pid, - uint8_t is_crnti, - uint8_t llr8_flag); + uint8_t is_crnti); int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, NR_UE_ULSCH_t *ulsch, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 87ba2090e7..342cc52cf5 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -181,23 +181,24 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, unsigned int crc = 1; NR_UL_UE_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; uint16_t nb_rb = harq_process->pusch_pdu.rb_size; - uint32_t A = harq_process->pusch_pdu.pusch_data.tb_size*8; + uint32_t A = harq_process->pusch_pdu.pusch_data.tb_size<<3; uint32_t *pz = &harq_process->Z; - uint8_t mod_order = nr_get_Qm_ul(harq_process->pusch_pdu.mcs_index, harq_process->pusch_pdu.mcs_table); - uint16_t R = nr_get_code_rate_ul(harq_process->pusch_pdu.mcs_index, harq_process->pusch_pdu.mcs_table); + uint8_t mod_order = harq_process->pusch_pdu.qam_mod_order; uint16_t Kr=0; uint32_t r_offset=0; uint32_t F=0; uint8_t Ilbrm = 0; uint32_t Tbslbrm = 950984; //max tbs - float Coderate = 0.0; + // target_code_rate in terms of 0.1 bits + float Coderate = (float) harq_process->pusch_pdu.target_code_rate / (float) 10240; + /////////// ///////////////////////////////////////////////////////////////////////////////////////// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_UE_ULSCH_ENCODING, VCD_FUNCTION_IN); LOG_D(NR_PHY, "ulsch coding nb_rb %d, Nl = %d\n", nb_rb, harq_process->pusch_pdu.nrOfLayers); - LOG_D(NR_PHY, "ulsch coding A %d G %d mod_order %d\n", A, G, mod_order); + LOG_D(NR_PHY, "ulsch coding A %d G %d mod_order %d Coderate %f\n", A, G, mod_order, Coderate); LOG_D(NR_PHY, "harq_pid %d harq_process->ndi %d, pusch_data.new_data_indicator %d\n", harq_pid,harq_process->ndi,harq_process->pusch_pdu.pusch_data.new_data_indicator); @@ -252,11 +253,6 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, ///////////////////////// b---->| block segmentation |---->c ///////////////////////// /////////// - if (R<1024) - Coderate = (float) R /(float) 1024; - else - Coderate = (float) R /(float) 2048; - if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ harq_process->BG = 2; } diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index a206d1c614..88403e3006 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -243,6 +243,9 @@ void configure_dlsch(NR_UE_DLSCH_t *dlsch0, dlsch0_harq->mcs = dlsch_config_pdu->mcs; dlsch0_harq->rvidx = dlsch_config_pdu->rv; dlsch0->g_pucch = dlsch_config_pdu->accumulated_delta_PUCCH; + dlsch0_harq->R = dlsch_config_pdu->targetCodeRate; + dlsch0_harq->Qm = dlsch_config_pdu->qamModOrder; + dlsch0_harq->TBS = dlsch_config_pdu->TBS; //get nrOfLayers from DCI info uint8_t Nl = 0; for (int i = 0; i < 12; i++) { // max 12 ports diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index ddddcd09e2..c61fb4ea51 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -788,8 +788,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, nb_symb_sch, nr_slot_rx, harq_pid, - pdsch==PDSCH?1:0, - dlsch0->harq_processes[harq_pid]->TBS>256?1:0); + pdsch==PDSCH?1:0); LOG_T(PHY,"dlsch decoding, ret = %d\n", ret); @@ -865,8 +864,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, nb_symb_sch, nr_slot_rx, harq_pid, - pdsch==PDSCH?1:0,//proc->decoder_switch, - dlsch1->harq_processes[harq_pid]->TBS>256?1:0); + pdsch==PDSCH?1:0);//proc->decoder_switch LOG_T(PHY,"CW dlsch decoding, ret1 = %d\n", ret1); stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index d6812dd541..b9141a9ab8 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -47,6 +47,7 @@ #include "openair1/SIMULATION/RF/rf.h" #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" +#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" //#define DEBUG_NR_DLSCHSIM @@ -426,7 +427,7 @@ int main(int argc, char **argv) NR_gNB_DLSCH_t *dlsch = msgDataTx.dlsch[0][0]; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15; //time_stats_t *rm_stats, *te_stats, *i_stats; - uint8_t is_crnti = 0, llr8_flag = 0; + uint8_t is_crnti = 0; unsigned int TBS = 8424; unsigned int available_bits; uint8_t nb_re_dmrs = 6; // No data in dmrs symbol @@ -451,7 +452,7 @@ int main(int argc, char **argv) rel15->qamModOrder[0] = mod_order; rel15->nrOfLayers = Nl; rel15->TBSize[0] = TBS>>3; - rel15->targetCodeRate[0] = rate; + rel15->targetCodeRate[0] = (rate>1024)?rate*5:rate*10; rel15->NrOfCodewords = 1; rel15->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; rel15->dlDmrsSymbPos = 4; @@ -472,7 +473,8 @@ int main(int argc, char **argv) harq_process->nb_rb = nb_rb; harq_process->Qm = mod_order; harq_process->rvidx = rvidx; - harq_process->R = rate; + harq_process->R = (rate>1024)?rate*5:rate*10; + harq_process->TBS = TBS; harq_process->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; harq_process->dlDmrsSymbPos = 4; harq_process->n_dmrs_cdm_groups = 1; @@ -495,8 +497,8 @@ int main(int argc, char **argv) //printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32)); // generate signal - unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32))); - bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS); + unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32))); + bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS); if (input_fd == NULL) { nr_dlsch_encoding(gNB, test_input, frame, slot, dlsch, frame_parms,output,NULL,NULL,NULL,NULL,NULL,NULL,NULL); } @@ -548,7 +550,7 @@ int main(int argc, char **argv) ret = nr_dlsch_decoding(UE, &proc, 0, channel_output_fixed, &UE->frame_parms, dlsch0_ue, dlsch0_ue->harq_processes[0], frame, nb_symb_sch, - slot,harq_pid, is_crnti, llr8_flag); + slot,harq_pid, is_crnti); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DECODING0, VCD_FUNCTION_OUT); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index f6227e1769..06aaeb8c27 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -47,6 +47,7 @@ #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include "common/utils/threadPool/thread-pool.h" +#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" //#define DEBUG_NR_ULSCHSIM @@ -446,8 +447,8 @@ int main(int argc, char **argv) rel15_ul->mcs_index = Imcs; rel15_ul->pusch_data.rv_index = rvidx; rel15_ul->nrOfLayers = Nl; - rel15_ul->target_code_rate = code_rate; - rel15_ul->pusch_data.tb_size = TBS/8; + rel15_ul->target_code_rate = (code_rate>1024)?code_rate*5:code_rate*10; + rel15_ul->pusch_data.tb_size = TBS>>3; /////////////////////////////////////////////////// double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc @@ -474,7 +475,9 @@ int main(int argc, char **argv) harq_process_ul_ue->pusch_pdu.nr_of_symbols = nb_symb_sch; harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*nb_codewords; harq_process_ul_ue->pusch_pdu.pusch_data.rv_index = rvidx; - harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = TBS/8; + harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = TBS>>3; + harq_process_ul_ue->pusch_pdu.target_code_rate = (code_rate>1024)?code_rate*5:code_rate*10; + harq_process_ul_ue->pusch_pdu.qam_mod_order = mod_order; unsigned char *test_input = harq_process_ul_ue->a; /////////// diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 5e4ae2deb7..6dec62e6a5 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -1083,7 +1083,7 @@ int main(int argc, char **argv) pusch_pdu->rnti = n_rnti; pusch_pdu->mcs_index = Imcs; pusch_pdu->mcs_table = mcs_table; - pusch_pdu->target_code_rate = code_rate; + pusch_pdu->target_code_rate = (code_rate>1024)?code_rate*5:code_rate*10; pusch_pdu->qam_mod_order = mod_order; pusch_pdu->transform_precoding = transform_precoding; pusch_pdu->data_scrambling_id = *scc->physCellId; @@ -1160,6 +1160,7 @@ int main(int argc, char **argv) ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers; ul_config.ul_config_list[0].pusch_config_pdu.absolute_delta_PUSCH = 0; + ul_config.ul_config_list[0].pusch_config_pdu.target_code_rate = (code_rate>1024)?code_rate*5:code_rate*10; ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS/8; ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = trial & 0x1; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index c150c4f134..63277022ce 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -119,6 +119,23 @@ int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmr uint8_t get_L_ptrs(uint8_t mcs1, uint8_t mcs2, uint8_t mcs3, uint8_t I_mcs, uint8_t mcs_table); uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB); +uint32_t nr_compute_tbs(uint16_t Qm, + uint16_t R, + uint16_t nb_rb, + uint16_t nb_symb_sch, + uint16_t nb_dmrs_prb, + uint16_t nb_rb_oh, + uint8_t tb_scaling, + uint8_t Nl); + +/** \brief Computes Q based on I_MCS PDSCH and table_idx for downlink. Implements MCS Tables from 38.214. */ +uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx); +uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); + +/** \brief Computes Q based on I_MCS PDSCH and table_idx for uplink. Implements MCS Tables from 38.214. */ +uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx); +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); void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c57736990c..31a1752158 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -900,6 +900,23 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_W(MAC, "[%d.%d] MCS value %d out of bounds! Possibly due to false DCI. Ignoring DCI!\n", frame, slot, dlsch_config_pdu_1_0->mcs); return -1; } + dlsch_config_pdu_1_0->qamModOrder = nr_get_Qm_dl(dlsch_config_pdu_1_0->mcs, dlsch_config_pdu_1_0->mcs_table); + int R = nr_get_code_rate_dl(dlsch_config_pdu_1_0->mcs, dlsch_config_pdu_1_0->mcs_table); + dlsch_config_pdu_1_0->targetCodeRate = (R>1024)?R*5:R*10; + if (dlsch_config_pdu_1_0->targetCodeRate == 0 || dlsch_config_pdu_1_0->qamModOrder == 0) { + LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\n"); + return -1; + } + + int nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs + int nb_re_dmrs = ((dlsch_config_pdu_1_0->dmrsConfigType == NFAPI_NR_DMRS_TYPE1) ? 6:4)*dlsch_config_pdu_1_0->n_dmrs_cdm_groups; + dlsch_config_pdu_1_0->TBS = nr_compute_tbs(dlsch_config_pdu_1_0->qamModOrder, + R, + dlsch_config_pdu_1_0->number_rbs, + dlsch_config_pdu_1_0->number_symbols, + nb_re_dmrs*get_num_dmrs(dlsch_config_pdu_1_0->dlDmrsSymbPos), + nb_rb_oh, 0, 1); + /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ dlsch_config_pdu_1_0->ndi = dci->ndi; /* RV (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ @@ -1288,6 +1305,25 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dl_config->number_pdus = dl_config->number_pdus + 1; /* TODO same calculation for MCS table as done in UL */ dlsch_config_pdu_1_1->mcs_table = (pdsch_Config->mcs_Table) ? (*pdsch_Config->mcs_Table + 1) : 0; + dlsch_config_pdu_1_1->qamModOrder = nr_get_Qm_dl(dlsch_config_pdu_1_1->mcs, dlsch_config_pdu_1_1->mcs_table); + int R = nr_get_code_rate_dl(dlsch_config_pdu_1_1->mcs, dlsch_config_pdu_1_1->mcs_table); + dlsch_config_pdu_1_1->targetCodeRate = (R>1024)?R*5:R*10; + if (dlsch_config_pdu_1_1->targetCodeRate == 0 || dlsch_config_pdu_1_1->qamModOrder == 0) { + LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\n"); + return -1; + } + uint8_t Nl = 0; + for (int i = 0; i < 12; i++) { // max 12 ports + if ((dlsch_config_pdu_1_1->dmrs_ports>>i)&0x01) Nl += 1; + } + int nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs + int nb_re_dmrs = ((dmrs_type == NULL) ? 6:4)*dlsch_config_pdu_1_1->n_dmrs_cdm_groups; + dlsch_config_pdu_1_1->TBS = nr_compute_tbs(dlsch_config_pdu_1_1->qamModOrder, + R, + dlsch_config_pdu_1_1->number_rbs, + dlsch_config_pdu_1_1->number_symbols, + nb_re_dmrs*get_num_dmrs(dlsch_config_pdu_1_1->dlDmrsSymbPos), + nb_rb_oh, 0, Nl); /*PTRS configuration */ dlsch_config_pdu_1_1->pduBitmap = 0; if(pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index bc9895ac2e..fbcb820c07 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -867,7 +867,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, rnti_types[rnti_type]); pusch_config_pdu->ul_dmrs_symb_pos = l_prime_mask; - pusch_config_pdu->target_code_rate = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); + uint16_t R = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); + pusch_config_pdu->target_code_rate = (R>1024)?R*5:R*10; pusch_config_pdu->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); if (pusch_config_pdu->target_code_rate == 0 || pusch_config_pdu->qam_mod_order == 0) { @@ -886,14 +887,13 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, // Compute TBS pusch_config_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_config_pdu->qam_mod_order, - pusch_config_pdu->target_code_rate, + R, pusch_config_pdu->rb_size, pusch_config_pdu->nr_of_symbols, nb_dmrs_re_per_rb*number_dmrs_symbols, N_PRB_oh, 0, // TBR to verify tb scaling - pusch_config_pdu->nrOfLayers)/8; - + pusch_config_pdu->nrOfLayers)>>3; return 0; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index f36dbc4a16..7d486928ef 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1085,13 +1085,14 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, for(int i = start_symbol_index; i < start_symbol_index+nr_of_symbols; i++) num_dmrs_symb += (pusch_pdu->ul_dmrs_symb_pos >> i) & 1; - int TBS = 0; + int R, TBS = 0; while(TBS<7) { // TBS for msg3 is 7 bytes (except for RRCResumeRequest1 currently not implemented) mcsindex++; - pusch_pdu->target_code_rate = nr_get_code_rate_ul(mcsindex,pusch_pdu->mcs_table); + R = nr_get_code_rate_ul(mcsindex,pusch_pdu->mcs_table); + pusch_pdu->target_code_rate = (R>1024)?R*5:R*10; pusch_pdu->qam_mod_order = nr_get_Qm_ul(mcsindex,pusch_pdu->mcs_table); TBS = nr_compute_tbs(pusch_pdu->qam_mod_order, - pusch_pdu->target_code_rate, + R, pusch_pdu->rb_size, pusch_pdu->nr_of_symbols, num_dmrs_symb*12, // nb dmrs set for no data in dmrs symbol @@ -1402,7 +1403,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra tb_scaling, // tb scaling 1)>>3; // layers - pdsch_pdu_rel15->targetCodeRate[0] = R; + pdsch_pdu_rel15->targetCodeRate[0] = (R>1024)?R*5:R*10; pdsch_pdu_rel15->qamModOrder[0] = Qm; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->TBSize[0] = TBS; @@ -1763,7 +1764,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->SubcarrierSpacing = genericParameters->subcarrierSpacing; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; - pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); + int R = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); + pdsch_pdu_rel15->targetCodeRate[0] = (R>1024)?R*5:R*10; pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index cddeb364d5..872dbf6ca4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -475,7 +475,8 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; - pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, 0); + int R = nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, 0); + pdsch_pdu_rel15->targetCodeRate[0] = (R>1024)?R*5:R*10; pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = gNB_mac->sched_ctrlCommon->sched_pdsch.mcs; pdsch_pdu_rel15->mcsTable[0] = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 5032ee601f..f7a45535a5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1152,7 +1152,8 @@ void nr_schedule_ue_spec(module_id_t module_id, // Codeword information pdsch_pdu->NrOfCodewords = 1; - pdsch_pdu->targetCodeRate[0] = R; + //number of information bits per 1024 coded bits expressed in 0.1 bit units + pdsch_pdu->targetCodeRate[0] = (R>1024)?R*5:R*10; pdsch_pdu->qamModOrder[0] = Qm; pdsch_pdu->mcsIndex[0] = sched_pdsch->mcs; pdsch_pdu->mcsTable[0] = ps->mcsTableIdx; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 7866cc4915..4a42ff0f67 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -117,7 +117,8 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; int mcsIndex = 9; - pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,0); + int R = nr_get_code_rate_dl(mcsIndex,0); + pdsch_pdu_rel15->targetCodeRate[0] = (R>1024)?R*5:R*10; pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->mcsTable[0] = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index aa49b14fe5..ed95491945 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1709,7 +1709,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->cyclic_prefix = 0; /* FAPI: PUSCH information always included */ - pusch_pdu->target_code_rate = sched_pusch->R; + uint16_t R = sched_pusch->R; + pusch_pdu->target_code_rate = (R>1024)?R*5:R*10; pusch_pdu->qam_mod_order = sched_pusch->Qm; pusch_pdu->mcs_index = sched_pusch->mcs; pusch_pdu->mcs_table = ps->mcs_table; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 8b734e3b95..2aacacb74f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -344,13 +344,6 @@ void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, int x_overhead, uint8_t numdmrscdmgroupnodata, uint8_t tb_scaling); -/** \brief Computes Q based on I_MCS PDSCH and table_idx for downlink. Implements MCS Tables from 38.214. */ -uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx); -uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); - -/** \brief Computes Q based on I_MCS PDSCH and table_idx for uplink. Implements MCS Tables from 38.214. */ -uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx); -uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); int NRRIV2BW(int locationAndBandwidth,int N_RB); From 181e576698dc5d7c8f40872ee4f214551e33541b Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 28 Mar 2022 10:31:50 +0100 Subject: [PATCH 054/105] Fix warning after merge --- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 8b734e3b95..c422184bdc 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -38,12 +38,13 @@ void set_cset_offset(uint16_t); void mac_top_init_gNB(void); +void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); + void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts, int pusch_AntennaPorts, - NR_ServingCellConfigCommon_t *scc - ); + NR_ServingCellConfigCommon_t *scc); int rrc_mac_config_req_gNB(module_id_t Mod_idP, int ssb_SubcarrierOffset, From e322bdb289953ab187a91303f10d18850eba1fe9 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 28 Mar 2022 14:10:39 +0100 Subject: [PATCH 055/105] Fix warning after merge --- openair1/PHY/INIT/nr_init_ue.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 83b2df2ced..6d2655cb93 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -166,7 +166,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) NR_UE_CSI_RS **const csirs_vars = ue->csirs_vars; NR_UE_SRS **const srs_vars = ue->srs_vars; - int i,j,k,l,slot,symb,q; + int i,j,k,l,slot,symb; int gNB_id; int th_id; diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 13c1c67c16..fd33398f5c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -333,7 +333,7 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][0]; - printf("Channel port_tx %d --> ant_rx %d : ls (%4d,%4d), int (%4d,%4d), noise (%4d,%4d) |", + printf("Channel port_tx %d --> ant_rx %d : ls (%4d,%4d), int (%4d,%4d), noise (%4d,%4d) | ", port_tx+3000, ant_rx, csi_rs_ls_estimated_channel[k<<1], csi_rs_ls_estimated_channel[(k<<1)+1], csi_rs_estimated_channel16[k<<1], csi_rs_estimated_channel16[(k<<1)+1], From 139a33d6446e6f42651b766e6b54c3e6c4f63a42 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 28 Mar 2022 14:36:01 +0100 Subject: [PATCH 056/105] Remove multiple nr_gold_csi_rs initializations --- openair1/PHY/INIT/nr_init.c | 37 ++++++++++------------- openair1/PHY/defs_gNB.h | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 9a3a888359..99eeed9736 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -188,20 +188,18 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, // CSI RS init // ceil((NB_RB*8(max allocation per RB)*2(QPSK))/32) int csi_dmrs_init_length = ((fp->N_RB_DL<<4)>>5)+1; - for (int id=0; idnr_csi_rs_info[id] = (nr_csi_rs_info_t *)malloc16_clear(sizeof(nr_csi_rs_info_t)); - gNB->nr_csi_rs_info[id]->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); - AssertFatal(gNB->nr_csi_rs_info[id]->nr_gold_csi_rs!=NULL, "NR init: csi reference signal malloc failed\n"); - for (int slot=0; slotslots_per_frame; slot++) { - gNB->nr_csi_rs_info[id]->nr_gold_csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *)); - AssertFatal(gNB->nr_csi_rs_info[id]->nr_gold_csi_rs[slot]!=NULL, "NR init: csi reference signal for slot %d - malloc failed\n", slot); - for (int symb=0; symbsymbols_per_slot; symb++) { - gNB->nr_csi_rs_info[id]->nr_gold_csi_rs[slot][symb] = (uint32_t *)malloc16(csi_dmrs_init_length*sizeof(uint32_t)); - AssertFatal(gNB->nr_csi_rs_info[id]->nr_gold_csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); - } + gNB->nr_csi_rs_info = (nr_csi_rs_info_t *)malloc16_clear(sizeof(nr_csi_rs_info_t)); + gNB->nr_csi_rs_info->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); + AssertFatal(gNB->nr_csi_rs_info->nr_gold_csi_rs!=NULL, "NR init: csi reference signal malloc failed\n"); + for (int slot=0; slotslots_per_frame; slot++) { + gNB->nr_csi_rs_info->nr_gold_csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *)); + AssertFatal(gNB->nr_csi_rs_info->nr_gold_csi_rs[slot]!=NULL, "NR init: csi reference signal for slot %d - malloc failed\n", slot); + for (int symb=0; symbsymbols_per_slot; symb++) { + gNB->nr_csi_rs_info->nr_gold_csi_rs[slot][symb] = (uint32_t *)malloc16(csi_dmrs_init_length*sizeof(uint32_t)); + AssertFatal(gNB->nr_csi_rs_info->nr_gold_csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); } - nr_init_csi_rs(&gNB->frame_parms, gNB->nr_csi_rs_info[id]->nr_gold_csi_rs, cfg->cell_config.phy_cell_id.value); } + nr_init_csi_rs(&gNB->frame_parms, gNB->nr_csi_rs_info->nr_gold_csi_rs, cfg->cell_config.phy_cell_id.value); for (int id=0; idnr_srs_info[id] = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); @@ -346,16 +344,13 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) } free_and_zero(pusch_dmrs); - for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) { - uint32_t ***csi_rs = gNB->nr_csi_rs_info[id]->nr_gold_csi_rs; - for (int slot = 0; slot < fp->slots_per_frame; slot++) { - for (int symb = 0; symb < fp->symbols_per_slot; symb++) - free_and_zero(csi_rs[slot][symb]); - free_and_zero(csi_rs[slot]); - } - free_and_zero(csi_rs); - free_and_zero(gNB->nr_csi_rs_info[id]); + uint32_t ***csi_rs = gNB->nr_csi_rs_info->nr_gold_csi_rs; + for (int slot = 0; slot < fp->slots_per_frame; slot++) { + for (int symb = 0; symb < fp->symbols_per_slot; symb++) + free_and_zero(csi_rs[slot][symb]); + free_and_zero(csi_rs[slot]); } + free_and_zero(csi_rs); for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) { for (int i = 0; i < Prx; i++){ diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 75aa328c8a..29ac8374e0 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -783,7 +783,7 @@ typedef struct PHY_VARS_gNB_s { nr_srs_info_t *nr_srs_info[NUMBER_OF_NR_SRS_MAX]; /// CSI-RS variables - nr_csi_rs_info_t *nr_csi_rs_info[NUMBER_OF_NR_CSIRS_MAX]; + nr_csi_rs_info_t *nr_csi_rs_info; uint8_t pbch_configured; char gNB_generate_rar; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 9582b66e59..fb689cf83e 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -178,7 +178,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, if (csirs->active == 1) { LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params = &csirs->csirs_pdu.csi_rs_pdu_rel15; - nr_generate_csi_rs(gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info[i], csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); + nr_generate_csi_rs(gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info, csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); csirs->active = 0; } } From cb32c7505ed281889fcace6df6fdf926b5f3a1fa Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 30 Mar 2022 19:08:20 +0200 Subject: [PATCH 057/105] tabulated values * 10 to simplify the code --- openair1/SIMULATION/NR_PHY/dlschsim.c | 13 ++++---- openair1/SIMULATION/NR_PHY/ulschsim.c | 4 +-- openair1/SIMULATION/NR_PHY/ulsim.c | 4 +-- .../NR_MAC_COMMON/nr_compute_tbs_common.c | 7 ++--- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 30 +++++++++---------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 4 +-- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 4 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 3 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 3 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 14 ++++----- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 5 ++-- 13 files changed, 43 insertions(+), 52 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index b9141a9ab8..520c2deebd 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -429,11 +429,8 @@ int main(int argc, char **argv) //time_stats_t *rm_stats, *te_stats, *i_stats; uint8_t is_crnti = 0; unsigned int TBS = 8424; - unsigned int available_bits; uint8_t nb_re_dmrs = 6; // No data in dmrs symbol uint16_t length_dmrs = 1; - unsigned char mod_order; - uint16_t rate; uint8_t Nl = 1; uint8_t rvidx = 0; dlsch->rnti = 1; @@ -441,9 +438,9 @@ int main(int argc, char **argv) dlsch->harq_processes[0]->rvidx = rvidx;*/ //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); - mod_order = nr_get_Qm_dl(Imcs, mcs_table); - rate = nr_get_code_rate_dl(Imcs, mcs_table); - available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); + unsigned char mod_order = nr_get_Qm_dl(Imcs, mcs_table); + uint16_t rate = nr_get_code_rate_dl(Imcs, mcs_table); + unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); TBS = nr_compute_tbs(mod_order,rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, 0, Nl); printf("available bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order); //dlsch->harq_ids[subframe]= 0; @@ -452,7 +449,7 @@ int main(int argc, char **argv) rel15->qamModOrder[0] = mod_order; rel15->nrOfLayers = Nl; rel15->TBSize[0] = TBS>>3; - rel15->targetCodeRate[0] = (rate>1024)?rate*5:rate*10; + rel15->targetCodeRate[0] = rate; rel15->NrOfCodewords = 1; rel15->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; rel15->dlDmrsSymbPos = 4; @@ -473,7 +470,7 @@ int main(int argc, char **argv) harq_process->nb_rb = nb_rb; harq_process->Qm = mod_order; harq_process->rvidx = rvidx; - harq_process->R = (rate>1024)?rate*5:rate*10; + harq_process->R = rate; harq_process->TBS = TBS; harq_process->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; harq_process->dlDmrsSymbPos = 4; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 06aaeb8c27..aea1aceb58 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -447,7 +447,7 @@ int main(int argc, char **argv) rel15_ul->mcs_index = Imcs; rel15_ul->pusch_data.rv_index = rvidx; rel15_ul->nrOfLayers = Nl; - rel15_ul->target_code_rate = (code_rate>1024)?code_rate*5:code_rate*10; + rel15_ul->target_code_rate = code_rate; rel15_ul->pusch_data.tb_size = TBS>>3; /////////////////////////////////////////////////// @@ -476,7 +476,7 @@ int main(int argc, char **argv) harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*nb_codewords; harq_process_ul_ue->pusch_pdu.pusch_data.rv_index = rvidx; harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = TBS>>3; - harq_process_ul_ue->pusch_pdu.target_code_rate = (code_rate>1024)?code_rate*5:code_rate*10; + harq_process_ul_ue->pusch_pdu.target_code_rate = code_rate; harq_process_ul_ue->pusch_pdu.qam_mod_order = mod_order; unsigned char *test_input = harq_process_ul_ue->a; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 6dec62e6a5..7cd745fed5 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -1083,7 +1083,7 @@ int main(int argc, char **argv) pusch_pdu->rnti = n_rnti; pusch_pdu->mcs_index = Imcs; pusch_pdu->mcs_table = mcs_table; - pusch_pdu->target_code_rate = (code_rate>1024)?code_rate*5:code_rate*10; + pusch_pdu->target_code_rate = code_rate; pusch_pdu->qam_mod_order = mod_order; pusch_pdu->transform_precoding = transform_precoding; pusch_pdu->data_scrambling_id = *scc->physCellId; @@ -1160,7 +1160,7 @@ int main(int argc, char **argv) ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers; ul_config.ul_config_list[0].pusch_config_pdu.absolute_delta_PUSCH = 0; - ul_config.ul_config_list[0].pusch_config_pdu.target_code_rate = (code_rate>1024)?code_rate*5:code_rate*10; + ul_config.ul_config_list[0].pusch_config_pdu.target_code_rate = code_rate; ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS/8; ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = trial & 0x1; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c index c33946fa5a..74245de59c 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c @@ -49,16 +49,15 @@ uint32_t nr_compute_tbs(uint16_t Qm, uint16_t nbp_re, nb_re; uint32_t nr_tbs=0; uint32_t Ninfo, Np_info, C; - uint8_t n, scale; + uint8_t n; LOG_D(NR_MAC, "In %s: nb_symb_sch %d, nb_dmrs_prb %d, nb_rb %d, nb_rb_oh %d, tb_scaling %d Nl %d\n", __FUNCTION__, nb_symb_sch, nb_dmrs_prb, nb_rb, nb_rb_oh, tb_scaling, Nl); nbp_re = NR_NB_SC_PER_RB * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; nb_re = min(156, nbp_re) * nb_rb; - scale = (R>1024)?11:10; // Intermediate number of information bits - Ninfo = ((nb_re * R * Qm * Nl)>>scale)>>tb_scaling; - + // R is tabulated as 10 times the actual code rate + Ninfo = ((nb_re * R * Qm * Nl / 10)>>10)>>tb_scaling; if (Ninfo <=3824) { n = max(3, floor(log2(Ninfo)) - 6); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 94b7ab18bf..bbc8e65940 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -2094,17 +2094,15 @@ void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, uint16_t N_RE_prime = NR_NB_SC_PER_RB*N_sh_symb - N_PRB_DMRS*dmrs_length - N_PRB_oh; LOG_D(MAC, "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", N_RE_prime, N_sh_symb, N_PRB_DMRS, N_PRB_oh); - uint16_t R; uint32_t TBS=0; - uint8_t table_idx, Qm; /*uint8_t mcs_table = config.pdsch_config.mcs_table.value; uint8_t ss_type = params_rel15.search_space_type; uint8_t dci_format = params_rel15.dci_format; get_table_idx(mcs_table, dci_format, rnti_type, ss_type);*/ - table_idx = 0; - R = nr_get_code_rate_dl(Imcs, table_idx); - Qm = nr_get_Qm_dl(Imcs, table_idx); + uint8_t table_idx = 0; + uint16_t R = nr_get_code_rate_dl(Imcs, table_idx); + uint8_t Qm = nr_get_Qm_dl(Imcs, table_idx); TBS = nr_compute_tbs(Qm, R, @@ -2125,25 +2123,25 @@ void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, TBS, N_PRB_DMRS, N_sh_symb, N_PRB_oh, R, Qm, table_idx,N_RE_prime*pdsch_rel15->rbSize*pdsch_rel15->NrOfCodewords ); } +// the following tables contain 10 times the value reported in 214 (in line with SCF specification and to avoid fractional values) //Table 5.1.3.1-1 of 38.214 -uint16_t Table_51311[29][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616}, - {4,658},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}}; +uint16_t Table_51311[29][2] = {{2,1200},{2,1570},{2,1930},{2,2510},{2,3080},{2,3790},{2,4490},{2,5260},{2,6020},{2,6790},{4,3400},{4,3780},{4,4340},{4,4900},{4,5530},{4,6160}, + {4,6580},{6,4380},{6,4660},{6,5170},{6,5670},{6,6160},{6,6660},{6,7190},{6,7720},{6,8220},{6,8730}, {6,9100}, {6,9480}}; //Table 5.1.3.1-2 of 38.214 // Imcs values 20 and 26 have been multiplied by 2 to avoid the floating point -uint16_t Table_51312[28][2] = {{2,120},{2,193},{2,308},{2,449},{2,602},{4,378},{4,434},{4,490},{4,553},{4,616},{4,658},{6,466},{6,517},{6,567},{6,616},{6,666}, - {6,719},{6,772},{6,822},{6,873},{8,1365},{8,711},{8,754},{8,797},{8,841},{8,885},{8,1833},{8,948}}; +uint16_t Table_51312[28][2] = {{2,1200},{2,1930},{2,3080},{2,4490},{2,6020},{4,3780},{4,4340},{4,4900},{4,5530},{4,6160},{4,6580},{6,4660},{6,5170},{6,5670},{6,6160},{6,6660}, + {6,7190},{6,7720},{6,8220},{6,8730},{8,6825},{8,7110},{8,7540},{8,7970},{8,8410},{8,8850},{8,9165},{8,9480}}; //Table 5.1.3.1-3 of 38.214 -uint16_t Table_51313[29][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{4,340}, - {4,378},{4,434},{4,490},{4,553},{4,616},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666}, {6,719}, {6,772}}; +uint16_t Table_51313[29][2] = {{2,300},{2,400},{2,500},{2,640},{2,780},{2,990},{2,1200},{2,1570},{2,1930},{2,2510},{2,3080},{2,3790},{2,4490},{2,5260},{2,6020},{4,3400}, + {4,3780},{4,4340},{4,4900},{4,5530},{4,6160},{6,4380},{6,4660},{6,5170},{6,5670},{6,6160},{6,6660},{6,7190},{6,7720}}; -uint16_t Table_61411[28][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616}, - {4,658},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}}; - -uint16_t Table_61412[28][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679}, - {4,378},{4,434},{4,490},{4,553},{4,616},{4,658},{4,699},{4,772},{6,567},{6,616},{6,666}, {6,772}}; +uint16_t Table_61411[28][2] = {{2,1200},{2,1570},{2,1930},{2,2510},{2,3080},{2,3790},{2,4490},{2,5260},{2,6020},{2,6790},{4,3400},{4,3780},{4,4340},{4,4900},{4,5530},{4,6160}, + {4,6580},{6,4660},{6,5170},{6,5670},{6,6160},{6,6660},{6,7190},{6,7720},{6,8220},{6,8730},{6,9100},{6,9480}}; +uint16_t Table_61412[28][2] = {{2,300},{2,400},{2,500},{2,640},{2,780},{2,990},{2,1200},{2,1570},{2,1930},{2,2510},{2,3080},{2,3790},{2,4490},{2,5260},{2,6020},{2,6790}, + {4,3780},{4,4340},{4,4900},{4,5530},{4,6160},{4,6580},{4,6990},{4,7720},{6,5670},{6,6160},{6,6660},{6,7720}}; uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 31a1752158..effd8568e3 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -902,7 +902,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } dlsch_config_pdu_1_0->qamModOrder = nr_get_Qm_dl(dlsch_config_pdu_1_0->mcs, dlsch_config_pdu_1_0->mcs_table); int R = nr_get_code_rate_dl(dlsch_config_pdu_1_0->mcs, dlsch_config_pdu_1_0->mcs_table); - dlsch_config_pdu_1_0->targetCodeRate = (R>1024)?R*5:R*10; + dlsch_config_pdu_1_0->targetCodeRate = R; if (dlsch_config_pdu_1_0->targetCodeRate == 0 || dlsch_config_pdu_1_0->qamModOrder == 0) { LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\n"); return -1; @@ -1307,7 +1307,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dlsch_config_pdu_1_1->mcs_table = (pdsch_Config->mcs_Table) ? (*pdsch_Config->mcs_Table + 1) : 0; dlsch_config_pdu_1_1->qamModOrder = nr_get_Qm_dl(dlsch_config_pdu_1_1->mcs, dlsch_config_pdu_1_1->mcs_table); int R = nr_get_code_rate_dl(dlsch_config_pdu_1_1->mcs, dlsch_config_pdu_1_1->mcs_table); - dlsch_config_pdu_1_1->targetCodeRate = (R>1024)?R*5:R*10; + dlsch_config_pdu_1_1->targetCodeRate = R; if (dlsch_config_pdu_1_1->targetCodeRate == 0 || dlsch_config_pdu_1_1->qamModOrder == 0) { LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\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 fbcb820c07..2aa8fa2597 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -868,7 +868,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->ul_dmrs_symb_pos = l_prime_mask; uint16_t R = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); - pusch_config_pdu->target_code_rate = (R>1024)?R*5:R*10; + pusch_config_pdu->target_code_rate = R; pusch_config_pdu->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); if (pusch_config_pdu->target_code_rate == 0 || pusch_config_pdu->qam_mod_order == 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 7d486928ef..5a3656417b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1403,7 +1403,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra tb_scaling, // tb scaling 1)>>3; // layers - pdsch_pdu_rel15->targetCodeRate[0] = (R>1024)?R*5:R*10; + pdsch_pdu_rel15->targetCodeRate[0] = R; pdsch_pdu_rel15->qamModOrder[0] = Qm; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->TBSize[0] = TBS; @@ -1765,7 +1765,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; int R = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); - pdsch_pdu_rel15->targetCodeRate[0] = (R>1024)?R*5:R*10; + pdsch_pdu_rel15->targetCodeRate[0] = R; pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 872dbf6ca4..cddeb364d5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -475,8 +475,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; - int R = nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, 0); - pdsch_pdu_rel15->targetCodeRate[0] = (R>1024)?R*5:R*10; + pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, 0); pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = gNB_mac->sched_ctrlCommon->sched_pdsch.mcs; pdsch_pdu_rel15->mcsTable[0] = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index f7a45535a5..80704a7a04 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1153,7 +1153,7 @@ void nr_schedule_ue_spec(module_id_t module_id, // Codeword information pdsch_pdu->NrOfCodewords = 1; //number of information bits per 1024 coded bits expressed in 0.1 bit units - pdsch_pdu->targetCodeRate[0] = (R>1024)?R*5:R*10; + pdsch_pdu->targetCodeRate[0] = R; pdsch_pdu->qamModOrder[0] = Qm; pdsch_pdu->mcsIndex[0] = sched_pdsch->mcs; pdsch_pdu->mcsTable[0] = ps->mcsTableIdx; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 4a42ff0f67..7866cc4915 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -117,8 +117,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; int mcsIndex = 9; - int R = nr_get_code_rate_dl(mcsIndex,0); - pdsch_pdu_rel15->targetCodeRate[0] = (R>1024)?R*5:R*10; + pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,0); pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->mcsTable[0] = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index ac0b186218..3267f8484c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -113,18 +113,18 @@ uint8_t nr_ss_first_symb_idx_scs_120_120_mux3[4] = {4,8,2,6}; uint8_t nr_max_number_of_candidates_per_slot[4] = {44, 36, 22, 20}; uint8_t nr_max_number_of_cces_per_slot[4] = {56, 56, 48, 32}; -// CQI TABLES +// CQI TABLES (10 times the value in 214 to adequately compare with R) // Table 1 (38.214 5.2.2.1-2) -uint16_t cqi_table1[16][2] = {{0,0},{2,78},{2,120},{2,193},{2,308},{2,449},{2,602},{4,378}, - {4,490},{4,616},{6,466},{6,567},{6,666},{6,772},{6,873},{6,948}}; +uint16_t cqi_table1[16][2] = {{0,0},{2,780},{2,1200},{2,1930},{2,3080},{2,4490},{2,6020},{4,3780}, + {4,4900},{4,6160},{6,4660},{6,5670},{6,6660},{6,7720},{6,8730},{6,9480}}; // Table 2 (38.214 5.2.2.1-3) -uint16_t cqi_table2[16][2] = {{0,0},{2,78},{2,193},{2,449},{4,378},{4,490},{4,616},{6,466}, - {6,567},{6,666},{6,772},{6,873},{8,711},{8,797},{8,885},{8,948}}; +uint16_t cqi_table2[16][2] = {{0,0},{2,780},{2,1930},{2,4490},{4,3780},{4,4900},{4,6160},{6,4660}, + {6,5670},{6,6660},{6,7720},{6,8730},{8,7110},{8,7970},{8,8850},{8,9480}}; // Table 2 (38.214 5.2.2.1-4) -uint16_t cqi_table3[16][2] = {{0,0},{2,30},{2,50},{2,78},{2,120},{2,193},{2,308},{2,449}, - {2,602},{4,378},{4,490},{4,616},{6,466},{6,567},{6,666},{6,772}}; +uint16_t cqi_table3[16][2] = {{0,0},{2,300},{2,500},{2,780},{2,1200},{2,1930},{2,3080},{2,4490}, + {2,6020},{4,3780},{4,4900},{4,6160},{6,4660},{6,5670},{6,6660},{6,7720}}; static inline uint8_t get_max_candidates(uint8_t scs) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index ed95491945..74618e18a7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1534,7 +1534,7 @@ nr_pp_impl_ul nr_init_fr1_ulsch_preprocessor(module_id_t module_id, int CC_id) if (mcs > 27 && mcsTableIdx == 1) continue; const uint8_t Qm = nr_get_Qm_dl(mcs, mcsTableIdx); - const uint16_t R = nr_get_code_rate_dl(mcs, mcsTableIdx); + const uint16_t R = nr_get_code_rate_ul(mcs, mcsTableIdx); /* note: we do not update R/Qm based on low MCS or pi2BPSK */ ul_pf_tbs[mcsTableIdx][mcs] = nr_compute_tbs(Qm, R, @@ -1709,8 +1709,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->cyclic_prefix = 0; /* FAPI: PUSCH information always included */ - uint16_t R = sched_pusch->R; - pusch_pdu->target_code_rate = (R>1024)?R*5:R*10; + pusch_pdu->target_code_rate = sched_pusch->R; pusch_pdu->qam_mod_order = sched_pusch->Qm; pusch_pdu->mcs_index = sched_pusch->mcs; pusch_pdu->mcs_table = ps->mcs_table; From 25614263baec66880377e47fc4b6ff733ade60b5 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Fri, 1 Apr 2022 16:15:58 +0100 Subject: [PATCH 058/105] Fix build after merge --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 6e5bc3d299..a972f2a946 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1005,15 +1005,16 @@ long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS) { void fill_default_csi_MeasConfig(int uid, NR_SetupRelease_CSI_MeasConfig_t *setupRelease_csi_MeasConfig, NR_ServingCellConfigCommon_t *scc, - rrc_gNB_carrier_data_t *carrier) { + const gNB_RrcConfigurationReq* configuration) { int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + int dl_antenna_ports = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP; setupRelease_csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); setupRelease_csi_MeasConfig->choice.setup = csi_MeasConfig; - if (carrier->pdsch_AntennaPorts > 1) { + if (dl_antenna_ports > 1) { csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList)); NR_CSI_IM_Resource_t *imres0 = calloc(1,sizeof(*imres0)); imres0->csi_IM_ResourceId = 0; @@ -1044,7 +1045,7 @@ void fill_default_csi_MeasConfig(int uid, csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL; - config_csirs(scc, csi_MeasConfig, uid, carrier->pdsch_AntennaPorts, curr_bwp, carrier->do_CSIRS); + config_csirs(scc, csi_MeasConfig, uid, dl_antenna_ports, curr_bwp, configuration->do_CSIRS); csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; @@ -1094,7 +1095,6 @@ void fill_default_csi_MeasConfig(int uid, csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); - NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); csires1->csi_ResourceConfigId=1; csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; @@ -1107,7 +1107,7 @@ void fill_default_csi_MeasConfig(int uid, csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); - if (carrier->pdsch_AntennaPorts > 1) { + if (dl_antenna_ports > 1) { NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); csires2->csi_ResourceConfigId=2; csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList; @@ -1125,7 +1125,7 @@ void fill_default_csi_MeasConfig(int uid, pucchcsires1->pucch_Resource=1; csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; - if (carrier->pdsch_AntennaPorts > 1) { + if (dl_antenna_ports > 1) { LOG_I(NR_RRC,"Filling CSI Report Config for RI_PMI_CQI\n"); NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); csirep1->reportConfigId=0; @@ -1739,7 +1739,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, if(!SpCellConfig->spCellConfigDedicated->csi_MeasConfig) { SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); } - fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig, scc, carrier); + fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig, scc, configuration); } // Set DL MCS table From a772400ffa0965e019bb10ae545fe13605b0a8ee Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 4 Apr 2022 13:14:18 +0100 Subject: [PATCH 059/105] Fix memory leak --- openair1/PHY/INIT/nr_init.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 06b0016140..26f25cec6c 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -758,13 +758,14 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) } free_and_zero(pusch_dmrs); - uint32_t ***csi_rs = gNB->nr_csi_rs_info->nr_gold_csi_rs; + uint32_t ***nr_gold_csi_rs = gNB->nr_csi_rs_info->nr_gold_csi_rs; for (int slot = 0; slot < fp->slots_per_frame; slot++) { for (int symb = 0; symb < fp->symbols_per_slot; symb++) - free_and_zero(csi_rs[slot][symb]); - free_and_zero(csi_rs[slot]); + free_and_zero(nr_gold_csi_rs[slot][symb]); + free_and_zero(nr_gold_csi_rs[slot]); } - free_and_zero(csi_rs); + free_and_zero(nr_gold_csi_rs); + free_and_zero(gNB->nr_csi_rs_info); for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) { for (int i = 0; i < Prx; i++){ From e297ccfa2616b80097aba5836aa3136abf042218 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Thu, 7 Apr 2022 10:34:37 +0200 Subject: [PATCH 060/105] Add nr_prachsim test case for 15 kHz SCS --- cmake_targets/autotests/test_case_list.xml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index e8023d2d52..2d7067f028 100755 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1341,10 +1341,11 @@ nr_prachsim Test cases. (Test1: 30kHz SCS, 106 PRBs, Prach format A2), (Test2: 30kHz SCS, 217 PRBs, Prach format A2), (Test3: 30kHz SCS, 273 PRBs, Prach format A2), - (Test4: 30kHz SCS, 106 PRBs, Prach format 0), + (Test4: 30kHz SCS, 106 PRBs, Prach format 0), (Test5: 120kHz SCS, 32 PRBs, Prach format A2), (Test6: 120kHz SCS, 66 PRBs, Prach format A2), - (Test7: 120kHz SCS, 66 PRBs, High Speed Enabled) + (Test7: 120kHz SCS, 66 PRBs, High Speed Enabled), + (Test8: 15kHz SCS, 25 PRBs) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1354,11 +1355,12 @@ -a -s -30 -n 100 -p 63 -R 106 -a -s -30 -n 100 -p 63 -R 217 -a -s -30 -n 100 -p 63 -R 273 - -a -s -30 -n 100 -p 63 -R 106 -c 4 - -a -s -30 -n 100 -p 32 -R 32 -m 3 -c52 - -a -s -30 -n 100 -p 32 -R 66 -m 3 -c52 - -a -s -30 -n 100 -R 66 -m 3 -c52 -H - nr_prachsim.test1 nr_prachsim.test2 nr_prachsim.test3 nr_prachsim.test4 nr_prachsim.test5 nr_prachsim.test6 nr_prachsim.test7 + -a -s -30 -n 100 -p 63 -R 106 -c 4 + -a -s -30 -n 100 -p 32 -R 32 -m 3 -c52 + -a -s -30 -n 100 -p 32 -R 66 -m 3 -c52 + -a -s -30 -n 100 -R 66 -m 3 -c52 -H + -a -s -30 -n 100 -p 99 -R 25 -m 0 + nr_prachsim.test1 nr_prachsim.test2 nr_prachsim.test3 nr_prachsim.test4 nr_prachsim.test5 nr_prachsim.test6 nr_prachsim.test7 nr_prachsim.test8 PRACH test OK segmentation fault|assertion|exiting|fatal 3 From d6072cb5d2c5d296bc1673bd96c06cf5bf2155d4 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 12 Apr 2022 14:31:39 +0100 Subject: [PATCH 061/105] Fix build after merge --- openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 4 ++-- openair1/PHY/NR_TRANSPORT/nr_transport_proto.h | 1 - openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 1 - openair1/PHY/defs_gNB.h | 1 - openair1/PHY/defs_nr_common.h | 1 + openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf | 2 +- targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf | 2 +- .../CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf | 2 +- .../CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf | 2 +- .../CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf | 2 +- .../CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf | 2 +- .../CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf | 2 +- .../CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf | 2 +- 15 files changed, 13 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index ab38278207..8bb56cb9f8 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -608,7 +608,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, } } - gNB->csi_gold_init = cfg->cell_config.phy_cell_id.value; + gNB->nr_csi_rs_info->csi_gold_init = cfg->cell_config.phy_cell_id.value; nr_init_csi_rs(&gNB->frame_parms, gNB->nr_csi_rs_info->nr_gold_csi_rs, cfg->cell_config.phy_cell_id.value); for (int id=0; idscramb_id != gNB->csi_gold_init) { - gNB->csi_gold_init = csi_params->scramb_id; + if (csi_params->scramb_id != nr_csi_rs_info->csi_gold_init) { + nr_csi_rs_info->csi_gold_init = csi_params->scramb_id; nr_init_csi_rs(&frame_parms, nr_csi_rs_info->nr_gold_csi_rs, csi_params->scramb_id); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 68e37e49f1..061e54403f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -340,7 +340,6 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, int16_t amp, nr_csi_rs_info_t *nr_csi_rs_info, nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, - uint16_t cell_id, int slot); void free_nr_prach_entry(PHY_VARS_gNB *gNB, int prach_id); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index fd33398f5c..8666de2018 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -389,7 +389,6 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t AMP, ue->nr_csi_rs_info, (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *) csirs_config_pdu, - ue->frame_parms.first_carrier_offset, proc->nr_slot_rx); nr_get_csi_rs_signal(ue, diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 24d813ebc1..54478d5f3b 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -850,7 +850,6 @@ typedef struct PHY_VARS_gNB_s { /// counter to average prach energh over first 100 prach opportunities int prach_energy_counter; - int csi_gold_init; int pdcch_gold_init; int pdsch_gold_init[2]; int pusch_gold_init[2]; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index f436d249c4..e91ee5d885 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -256,6 +256,7 @@ typedef struct { uint8_t j[16]; uint8_t koverline[16]; uint8_t loverline[16]; + uint16_t csi_gold_init; uint32_t ***nr_gold_csi_rs; uint8_t csi_rs_generated_signal_bits; int32_t **csi_rs_generated_signal; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 9eb63898ad..2a6d9bca7b 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -177,7 +177,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, if (csirs->active == 1) { LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params = &csirs->csirs_pdu.csi_rs_pdu_rel15; - nr_generate_csi_rs(gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info, csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); + nr_generate_csi_rs(gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info, csi_params, slot); csirs->active = 0; } } diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf index c07a0db649..1bddae6036 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf @@ -48,7 +48,7 @@ gNBs = pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; min_rxtxtime = 6; - sib1_tda = 0; + sib1_tda = 1; pdcch_ConfigSIB1 = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf index 256d724f3f..92a21e507f 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf @@ -38,7 +38,7 @@ gNBs = ssb_SubcarrierOffset = 0; min_rxtxtime = 6; - sib1_tda = 0; + sib1_tda = 1; pdcch_ConfigSIB1 = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf index 726e43d7ad..dfcd4a185c 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf @@ -37,7 +37,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - sib1_tda = 0; + sib1_tda = 1; servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf index e1c970aa62..1567b628da 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf @@ -36,7 +36,7 @@ gNBs = pdsch_AntennaPorts_N1 = 1; pusch_AntennaPorts = 1; min_rxtxtime = 2; - sib1_tda = 0; + sib1_tda = 1; do_CSIRS = 1; do_SRS = 0; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf index cab801525b..5df21c1f4b 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf @@ -36,7 +36,7 @@ gNBs = pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; min_rxtxtime = 6; - sib1_tda = 0; + sib1_tda = 1; pdcch_ConfigSIB1 = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf index 80ce09abe8..626c532269 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf @@ -36,7 +36,7 @@ gNBs = pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 2; min_rxtxtime = 2; - sib1_tda = 0; + sib1_tda = 1; do_CSIRS = 1; do_SRS = 0; ul_prbblacklist = "51,52,53,54" diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index 69bd4f7a7c..d498ce47b5 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -36,7 +36,7 @@ gNBs = pdsch_AntennaPorts_N1 = 1; pusch_AntennaPorts = 1; min_rxtxtime = 2; - sib1_tda = 0; + sib1_tda = 1; do_CSIRS = 1; do_SRS = 0; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf index b3e4699955..7d05fb9b21 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf @@ -36,7 +36,7 @@ gNBs = pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 2; min_rxtxtime = 2; - sib1_tda = 0; + sib1_tda = 1; do_CSIRS = 1; do_SRS = 0; ul_prbblacklist = "79,80,81,82" From a254545b7c0beca812f46070065fb10e3ce5bfe9 Mon Sep 17 00:00:00 2001 From: laurent Date: Mon, 16 May 2022 09:31:29 +0200 Subject: [PATCH 062/105] fix ra bug --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index c9c3b2e289..3f26b4e454 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -465,27 +465,24 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, int FR = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0] >= 257 ? nr_FR2 : nr_FR1; - uint8_t start_next_period = (rach_slot-(rach_slot%tdd_period_slot)+tdd_period_slot)%nr_slots_per_frame[mu]; - *msg2_slot = start_next_period + last_dl_slot_period; // initializing scheduling of slot to next mixed (or last dl) slot - *msg2_frame = ((*msg2_slot>(rach_slot))? rach_frame : (rach_frame+1))%1024; + uint8_t start_next_period = rach_slot-(rach_slot%tdd_period_slot)+tdd_period_slot; + int eff_slot = start_next_period + last_dl_slot_period; // initializing scheduling of slot to next mixed (or last dl) slot // we can't schedule msg2 before sl_ahead since prach - int eff_slot = *msg2_slot+(*msg2_frame-rach_frame)*nr_slots_per_frame[mu]; while ((eff_slot-rach_slot)<=sl_ahead) { - *msg2_slot = (*msg2_slot+tdd_period_slot)%nr_slots_per_frame[mu]; - *msg2_frame = ((*msg2_slot>(rach_slot))? rach_frame : (rach_frame+1))%1024; - eff_slot = *msg2_slot+(*msg2_frame-rach_frame)*nr_slots_per_frame[mu]; + eff_slot += tdd_period_slot; } if (FR==nr_FR2) { - int num_tdd_period = *msg2_slot/tdd_period_slot; + int num_tdd_period = (eff_slot%nr_slots_per_frame[mu])/tdd_period_slot; while((tdd_beam_association[num_tdd_period]!=-1)&&(tdd_beam_association[num_tdd_period]!=beam_index)) { - *msg2_slot = (*msg2_slot+tdd_period_slot)%nr_slots_per_frame[mu]; - *msg2_frame = ((*msg2_slot>(rach_slot))? rach_frame : (rach_frame+1))%1024; - num_tdd_period = *msg2_slot/tdd_period_slot; + eff_slot += tdd_period_slot; + num_tdd_period = (eff_slot % nr_slots_per_frame[mu])/tdd_period_slot; } if(tdd_beam_association[num_tdd_period] == -1) tdd_beam_association[num_tdd_period] = beam_index; } + *msg2_frame=(rach_frame + eff_slot/nr_slots_per_frame[mu])%1024; + *msg2_slot=eff_slot%nr_slots_per_frame[mu]; // go to previous slot if the current scheduled slot is beyond the response window // and if the slot is not among the PDCCH monitored ones (38.213 10.1) while (*msg2_frame > frame_limit From f94a479829bdb7fbf228a8843807fd517b2b88d0 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 12:51:18 +0100 Subject: [PATCH 063/105] Fix warning after merge --- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index c2a2b9eaee..16a0d596f7 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -840,12 +840,13 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, mappingtype, add_pos, dmrslength, pusch_config_pdu->start_symbol_index, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); - if ((mac->ULbwp[ul_bwp_id-1] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled)) + if ((mac->ULbwp[ul_bwp_id-1] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled)) { if (*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 || (mac->ULbwp[ul_bwp_id-1] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled)) + } else if (*dci_format == NR_UL_DCI_FORMAT_0_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 (mac->cg && From e5c4e0f3d3167b7542319b193087559d04f13f45 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 12:59:24 +0100 Subject: [PATCH 064/105] Address review comments --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 31de80c5c4..40dff1bb20 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2530,7 +2530,7 @@ uint8_t nr_get_csi_payload(NR_UE_MAC_INST_t *mac, case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_i1_CQI: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_CQI: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_LI_PMI_CQI: - LOG_D(NR_MAC,"Measurement report based on CSI-RS not available\n"); + LOG_E(NR_MAC,"Measurement report based on CSI-RS not available\n"); break; default: AssertFatal(1==0,"Invalid CSI report quantity type %d\n",csi_reportconfig->reportQuantity.present); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 742a700e2f..ef80f7bc79 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1727,6 +1727,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int rbSize = 0; uint8_t tb_scaling = 0; uint16_t *vrb_map = cc[CC_id].vrb_map; + // increase PRBs until we get to BWPSize or TBS is bigger than MAC PDU size do { if(rbSize < BWPSize) rbSize++; From 2d96262d7c952789e5800b53a0be14c0c5c129dd Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 14:31:13 +0100 Subject: [PATCH 065/105] Fix channel estimation based on CSI-RS --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 33 ++------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 8666de2018..79fd7a3dd2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -150,34 +150,6 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, return 0; } -int get_wf(int kp, int s) { - int wf = 0; - if (kp == 0) { - wf = 1; - } else { - wf = -2*(s%2)+1; - } - return wf; -} - -int get_wt(int lp, int s) { - int wt = 0; - if (s < 2) { - wt = 1; - } else if (s < 4) { - wt = -2*(lp%2)+1; - } else if (s < 6) { - wt = -2*(lp/2)+1; - } else { - if ((lp == 0) || (lp == 3)) { - wt = 1; - } else { - wt = -1; - } - } - return wt; -} - uint32_t calc_power_csirs(uint16_t *x, fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu) { uint64_t sum_x = 0; uint64_t sum_x2 = 0; @@ -245,9 +217,8 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, // This is not just the LS estimation for each (k,l), but also the sum of the different contributions // for the sake of optimizing the memory used. - int w = get_wf(kp,s)*get_wt(lp,s); - csi_rs_ls_estimated_channel[kinit<<1] += w*csi_rs_ls_estimated_channel_re; - csi_rs_ls_estimated_channel[(kinit<<1)+1] += w*csi_rs_ls_estimated_channel_im; + csi_rs_ls_estimated_channel[kinit<<1] += csi_rs_ls_estimated_channel_re; + csi_rs_ls_estimated_channel[(kinit<<1)+1] += csi_rs_ls_estimated_channel_im; } } } From 1fbf968676919b5f203c8285585ebdc529ed8e53 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 4 Mar 2022 14:57:26 +0100 Subject: [PATCH 066/105] Set DL MCS when receiving CQI report - Introduce generic get_mcs_from_cqi() that gets MCS for a particular CQI - Set MCS after receiving CQI - Distinguish "global" max MCS from UE-measured max MCS --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 10 +-- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 85 +++++++++---------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 7 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 5 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 +- 5 files changed, 52 insertions(+), 59 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index e2291b9745..83e8dd5e0f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -404,13 +404,9 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t const NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; int max_allowed_mcs = (mcs_table == 1) ? 27 : 28; - int max_mcs = nrmac->dl_max_mcs; - - if (nrmac->dl_max_mcs>max_allowed_mcs) - max_mcs = max_allowed_mcs; - - NR_DL_bler_stats_t *bler_stats = &nrmac->UE_info.UE_sched_ctrl[UE_id].dl_bler_stats; + NR_UE_sched_ctrl_t *sched_ctrl = &nrmac->UE_info.UE_sched_ctrl[UE_id]; + NR_DL_bler_stats_t *bler_stats = &sched_ctrl->dl_bler_stats; /* first call: everything is zero. Initialize to sensible default */ if (bler_stats->last_frame_slot == 0 && bler_stats->mcs == 0) { bler_stats->last_frame_slot = frame * n + slot; @@ -458,6 +454,7 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t if (bler_stats->rd2_bler > nrmac->dl_rd2_bler_threshold && old_mcs > 6) { new_mcs -= 2; } else if (bler_stats->rd2_bler < nrmac->dl_rd2_bler_threshold) {*/ + const int max_mcs = min(max_allowed_mcs, min(sched_ctrl->dl_max_mcs, nrmac->dl_max_mcs)); if (bler_stats->bler < nrmac->dl_bler_target_lower && old_mcs < max_mcs && dtx > 9) new_mcs += 1; else if (bler_stats->bler > nrmac->dl_bler_target_upper && old_mcs > 6) @@ -772,7 +769,6 @@ void pf_dl(module_id_t module_id, continue; /* Calculate coeff */ - set_dl_mcs(sched_pdsch,sched_ctrl,&mac->dl_max_mcs,ps->mcsTableIdx); sched_pdsch->mcs = get_mcs_from_bler(module_id, /* CC_id = */ 0, frame, slot, UE_id, ps->mcsTableIdx); layers[UE_id] = set_dl_nrOfLayers(sched_ctrl); const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 45327eda73..09b890a860 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -145,7 +145,6 @@ uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl) { } - uint16_t set_pm_index(NR_UE_sched_ctrl_t *sched_ctrl, int layers, int N1, int N2, @@ -169,51 +168,45 @@ uint16_t set_pm_index(NR_UE_sched_ctrl_t *sched_ctrl, AssertFatal(1==0,"More than 2 antenna ports not yet supported\n"); } - -void set_dl_mcs(NR_sched_pdsch_t *sched_pdsch, - NR_UE_sched_ctrl_t *sched_ctrl, - uint8_t *target_mcs, - uint8_t mcs_table_idx) { - - if (sched_ctrl->set_mcs) { - // TODO for wideband case and multiple TB - int cqi_idx = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb; - uint16_t target_coderate,target_qm; - if (cqi_idx>0) { - int cqi_table = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.cqi_table; - if (cqi_table != mcs_table_idx) - LOG_W(NR_MAC,"Indices of MCS tables don't correspond yet, cri_ri_li_pmi_cqi_report.cqi_table %d, mcs_table_index %d\n",cqi_table,mcs_table_idx); - switch (cqi_table) { - case 0: - target_qm = cqi_table1[cqi_idx][0]; - target_coderate = cqi_table1[cqi_idx][1]; - break; - case 1: - target_qm = cqi_table2[cqi_idx][0]; - target_coderate = cqi_table2[cqi_idx][1]; - break; - case 2: - target_qm = cqi_table3[cqi_idx][0]; - target_coderate = cqi_table3[cqi_idx][1]; - break; - default: - AssertFatal(1==0,"Invalid cqi table index %d\n",cqi_table); - } - int max_mcs = 28; - int R,Qm; - if (mcs_table_idx == 1) - max_mcs = 27; - for (int i=0; i<=max_mcs; i++) { - R = nr_get_code_rate_dl(i, mcs_table_idx); - Qm = nr_get_Qm_dl(i, mcs_table_idx); - if ((Qm == target_qm) && (target_coderate <= R)) { - *target_mcs = i; - break; - } - } - } - sched_ctrl->set_mcs = false; +uint8_t get_mcs_from_cqi(int mcs_table, int cqi_table, int cqi_idx) +{ + if (cqi_idx <= 0) { + LOG_E(NR_MAC, "invalid cqi_idx %d, default to MCS 9\n", cqi_idx); + return 9; } + + if (mcs_table != cqi_table) { + LOG_E(NR_MAC, "indices of CQI (%d) and MCS (%d) tables don't correspond yet\n", cqi_table, mcs_table); + return 9; + } + + uint16_t target_coderate, target_qm; + switch (cqi_table) { + case 0: + target_qm = cqi_table1[cqi_idx][0]; + target_coderate = cqi_table1[cqi_idx][1]; + break; + case 1: + target_qm = cqi_table2[cqi_idx][0]; + target_coderate = cqi_table2[cqi_idx][1]; + break; + case 2: + target_qm = cqi_table3[cqi_idx][0]; + target_coderate = cqi_table3[cqi_idx][1]; + break; + default: + AssertFatal(1==0,"Invalid cqi table index %d\n",cqi_table); + } + const int max_mcs = mcs_table == 1 ? 27 : 28; + for (int i = 0; i <= max_mcs; i++) { + const int R = nr_get_code_rate_dl(i, mcs_table); + const int Qm = nr_get_Qm_dl(i, mcs_table); + if (Qm == target_qm && target_coderate <= R) + return i; + } + + LOG_E(NR_MAC, "could not find maximum MCS from cqi_idx %d, default to 9\n", cqi_idx); + return 9; } void set_dl_dmrs_ports(NR_pdsch_semi_static_t *ps) { @@ -2359,7 +2352,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info, UE_id, mod_idP); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; memset(sched_ctrl, 0, sizeof(*sched_ctrl)); - sched_ctrl->set_mcs = true; + sched_ctrl->dl_max_mcs = 28; /* do not limit MCS for individual UEs */ sched_ctrl->set_pmi = false; sched_ctrl->ta_frame = 0; sched_ctrl->ta_update = 31; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index a29aa8018c..b05c4175cb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1250,7 +1250,12 @@ void evaluate_cqi_report(uint8_t *payload, sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_2tb = temp_cqi; LOG_D(MAC,"Wide-band CQI for the second TB %d\n", temp_cqi); } - sched_ctrl->set_mcs = true; + + // TODO for wideband case and multiple TB + const int cqi_idx = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb; + const int mcs_table = sched_ctrl->pdsch_semi_static.mcsTableIdx; + const int cqi_table = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.cqi_table; + sched_ctrl->dl_max_mcs = get_mcs_from_cqi(mcs_table, cqi_table, cqi_idx); } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 6d15641592..cdb1658f55 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -514,10 +514,7 @@ uint16_t set_pm_index(NR_UE_sched_ctrl_t *sched_ctrl, int xp_pdsch_antenna_ports, int codebook_mode); -void set_dl_mcs(NR_sched_pdsch_t *sched_pdsch, - NR_UE_sched_ctrl_t *sched_ctrl, - uint8_t *target_mcs, - uint8_t mcs_table_idx); +uint8_t get_mcs_from_cqi(int mcs_table, int cqi_table, int cqi_idx); uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 9d8e28da97..d8ff37ef15 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -613,6 +613,9 @@ typedef struct { NR_pdsch_semi_static_t pdsch_semi_static; /// Sched PDSCH: scheduling decisions, copied into HARQ and cleared every TTI NR_sched_pdsch_t sched_pdsch; + /// UE-estimated maximum MCS (from CSI-RS) + uint8_t dl_max_mcs; + /// For UL synchronization: store last UL scheduling grant frame_t last_ul_frame; sub_frame_t last_ul_slot; @@ -641,7 +644,6 @@ typedef struct { int ul_failure; struct CSI_Report CSI_report; bool SR; - bool set_mcs; bool set_pmi; /// information about every HARQ process NR_UE_harq_t harq_processes[NR_MAX_NB_HARQ_PROCESSES]; From 61d434339eab154597746a727de75ae666517e58 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 20 Jan 2022 16:44:19 +0100 Subject: [PATCH 067/105] DL MCS: switch back to 9 on inactivity --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 83e8dd5e0f..75957f991b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -457,7 +457,8 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t const int max_mcs = min(max_allowed_mcs, min(sched_ctrl->dl_max_mcs, nrmac->dl_max_mcs)); if (bler_stats->bler < nrmac->dl_bler_target_lower && old_mcs < max_mcs && dtx > 9) new_mcs += 1; - else if (bler_stats->bler > nrmac->dl_bler_target_upper && old_mcs > 6) + else if ((bler_stats->bler > nrmac->dl_bler_target_upper && old_mcs > 6) // above threshold + || (dtx <= 3 && old_mcs > 9)) // no activity new_mcs -= 1; // else we are within threshold boundaries From 26c2c0add8c0a10bd5f726d4cdd2f9815bc456d6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 21 Jan 2022 14:40:46 +0100 Subject: [PATCH 068/105] MAC stats: group UL&DL common stats --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 4 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 26 +++++++++-------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 4 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 19 +++++++------ openair2/LAYER2/NR_MAC_gNB/main.c | 28 +++++++++---------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 22 +++++++-------- 6 files changed, 53 insertions(+), 50 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 9ac9f0d880..f8c3b24cce 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1981,8 +1981,8 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram if (harq->is_waiting == 0) { if (harq->round == 0) { - if (stats->dlsch_errors == 0) { - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", UE_id, ra->rnti); + if (stats->dl.errors == 0) { + LOG_A(NR_MAC, "(ue %i, rnti 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", UE_id, ra->rnti); UE_info->active[UE_id] = true; UE_info->Msg4_ACKed[UE_id] = true; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 75957f991b..3a179fbaea 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -425,13 +425,13 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t const NR_mac_stats_t *stats = &nrmac->UE_info.mac_stats[UE_id]; // TODO put back this condition when relevant - /*const int dret3x = stats->dlsch_rounds[3] - bler_stats->dlsch_rounds[3]; + /*const int dret3x = stats->dl.rounds[3] - bler_stats->dlsch_rounds[3]; if (dret3x > 0) { if there is a third retransmission, decrease MCS for stabilization and restart averaging window to stabilize transmission bler_stats->last_frame_slot = now; bler_stats->mcs = max(9, bler_stats->mcs - 1); - memcpy(bler_stats->dlsch_rounds, stats->dlsch_rounds, sizeof(stats->dlsch_rounds)); + memcpy(bler_stats->dlsch_rounds, stats->dl.rounds, sizeof(stats->dl.rounds)); LOG_D(MAC, "%4d.%2d: %d retx in 3rd round, setting MCS to %d and restarting window\n", frame, slot, dret3x, bler_stats->mcs); return bler_stats->mcs; }*/ @@ -439,9 +439,9 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t return old_mcs; // no update // last update is longer than x frames ago - const int dtx = (int)(stats->dlsch_rounds[0] - bler_stats->dlsch_rounds[0]); - const int dretx = (int)(stats->dlsch_rounds[1] - bler_stats->dlsch_rounds[1]); - const int dretx2 = (int)(stats->dlsch_rounds[2] - bler_stats->dlsch_rounds[2]); + const int dtx = (int)(stats->dl.rounds[0] - bler_stats->dlsch_rounds[0]); + const int dretx = (int)(stats->dl.rounds[1] - bler_stats->dlsch_rounds[1]); + const int dretx2 = (int)(stats->dl.rounds[2] - bler_stats->dlsch_rounds[2]); const float bler_window = dtx > 0 ? (float) dretx / dtx : bler_stats->bler; const float rd2_bler_wnd = dtx > 0 ? (float) dretx2 / dtx : bler_stats->rd2_bler; bler_stats->bler = BLER_FILTER * bler_stats->bler + (1 - BLER_FILTER) * bler_window; @@ -464,7 +464,7 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t // else we are within threshold boundaries bler_stats->last_frame_slot = now; bler_stats->mcs = new_mcs; - memcpy(bler_stats->dlsch_rounds, stats->dlsch_rounds, sizeof(stats->dlsch_rounds)); + memcpy(bler_stats->dlsch_rounds, stats->dl.rounds, sizeof(stats->dl.rounds)); LOG_D(MAC, "%4d.%2d MCS %d -> %d (dtx %d, dretx %d, BLER wnd %.3f avg %.6f, dretx2 %d, RD2 BLER wnd %.3f avg %.6f)\n", frame, slot, old_mcs, new_mcs, dtx, dretx, bler_window, bler_stats->bler, dretx2, rd2_bler_wnd, bler_stats->rd2_bler); return new_mcs; @@ -747,7 +747,7 @@ void pf_dl(module_id_t module_id, layers[UE_id] = ps->nrOfLayers; // initialization of layers to the previous value in the strcuture /* Calculate Throughput */ const float a = 0.0005f; // corresponds to 200ms window - const uint32_t b = UE_info->mac_stats[UE_id].dlsch_current_bytes; + const uint32_t b = UE_info->mac_stats[UE_id].dl.current_bytes; thr_ue[UE_id] = (1 - a) * thr_ue[UE_id] + a * b; /* retransmission */ @@ -1088,7 +1088,7 @@ void nr_schedule_ue_spec(module_id_t module_id, if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; - UE_info->mac_stats[UE_id].dlsch_current_bytes = 0; + UE_info->mac_stats[UE_id].dl.current_bytes = 0; NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; NR_BWP_DownlinkDedicated_t *bwpd = @@ -1146,7 +1146,7 @@ void nr_schedule_ue_spec(module_id_t module_id, harq->feedback_frame = pucch->frame; harq->feedback_slot = pucch->ul_slot; harq->is_waiting = true; - UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++; + UE_info->mac_stats[UE_id].dl.rounds[harq->round]++; LOG_D(NR_MAC, "%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d nrOfLayers %d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) PUCCH allocation %d TPC %d\n", frame, @@ -1479,7 +1479,7 @@ void nr_schedule_ue_spec(module_id_t module_id, lcid_bytes += len; } - UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += lcid_bytes; + UE_info->mac_stats[UE_id].dl.lc_bytes[lcid] += lcid_bytes; } } else if (get_softmodem_params()->phy_test || get_softmodem_params()->do_ra) { /* we will need the large header, phy-test typically allocates all @@ -1517,8 +1517,10 @@ void nr_schedule_ue_spec(module_id_t module_id, buf=bufEnd; } - UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; - UE_info->mac_stats[UE_id].dlsch_current_bytes = TBS; + NR_mac_stats_t *mac_stats = &UE_info->mac_stats[UE_id]; + mac_stats->dl.total_bytes += TBS; + mac_stats->dl.current_bytes = TBS; + /* save retransmission information */ harq->sched_pdsch = *sched_pdsch; /* save which time allocation has been used, to be used on diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index b05c4175cb..b9292876e3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -838,8 +838,8 @@ static void handle_dl_harq(module_id_t mod_id, harq->round = 0; harq->ndi ^= 1; NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; - stats->dlsch_errors++; - LOG_D(NR_MAC, "retransmission error for UE %d (total %"PRIu64")\n", UE_id, stats->dlsch_errors); + stats->dl.errors++; + LOG_D(NR_MAC, "retransmission error for UE %d (total %"PRIu64")\n", UE_id, stats->dl.errors); } else { LOG_D(PHY,"NACK for: pid %d, ue %x\n",harq_pid, UE_id); add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].retrans_dl_harq, harq_pid); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 7a34527166..57cd91e286 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -464,7 +464,7 @@ int nr_process_mac_pdu(module_id_t module_idP, rx_lcid, module_idP, mac_len); - UE_info->mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_len; + UE_info->mac_stats[UE_id].ul.lc_bytes[rx_lcid] += mac_len; mac_rlc_data_ind(module_idP, UE_info->rnti[UE_id], @@ -526,7 +526,7 @@ void abort_nr_ul_harq(module_id_t mod_id, int UE_id, int8_t harq_pid) harq->ndi ^= 1; harq->round = 0; - UE_info->mac_stats[UE_id].ulsch_errors++; + UE_info->mac_stats[UE_id].ul.errors++; add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); /* the transmission failed: the UE won't send the data we expected initially, @@ -637,7 +637,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(harq_pid), T_BUFFER(sduP, sdu_lenP)); - UE_info->mac_stats[UE_id].ulsch_total_bytes_rx += sdu_lenP; + UE_info->mac_stats[UE_id].ul.total_bytes += sdu_lenP; LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d TA %d sduP %p, rssi %d\n", gnb_mod_idP, harq_pid, @@ -1177,7 +1177,7 @@ void pf_ul(module_id_t module_id, /* Calculate throughput */ const float a = 0.0005f; // corresponds to 200ms window - const uint32_t b = UE_info->mac_stats[UE_id].ulsch_current_bytes; + const uint32_t b = UE_info->mac_stats[UE_id].ul.current_bytes; ul_thr_ue[UE_id] = (1 - a) * ul_thr_ue[UE_id] + a * b; /* Check if retransmission is necessary */ @@ -1652,7 +1652,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - UE_info->mac_stats[UE_id].ulsch_current_bytes = 0; + NR_mac_stats_t *mac_stats = &UE_info->mac_stats[UE_id]; + mac_stats->ul.current_bytes = 0; /* dynamic PUSCH values (RB alloc, MCS, hence R, Qm, TBS) that change in * every TTI are pre-populated by the preprocessor and used below */ @@ -1696,10 +1697,10 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; /* Statistics */ - AssertFatal(cur_harq->round < 8, "Indexing ulsch_rounds[%d] is out of bounds\n", cur_harq->round); - UE_info->mac_stats[UE_id].ulsch_rounds[cur_harq->round]++; + AssertFatal(cur_harq->round < 8, "Indexing UL rounds[%d] is out of bounds\n", cur_harq->round); + mac_stats->ul.rounds[cur_harq->round]++; if (cur_harq->round == 0) { - UE_info->mac_stats[UE_id].ulsch_total_bytes_scheduled += sched_pusch->tb_size; + mac_stats->ulsch_total_bytes_scheduled += sched_pusch->tb_size; /* Save information on MCS, TBS etc for the current initial transmission * so we have access to it when retransmitting */ cur_harq->sched_pusch = *sched_pusch; @@ -1719,7 +1720,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) cur_harq->round, cur_harq->ndi); } - UE_info->mac_stats[UE_id].ulsch_current_bytes = sched_pusch->tb_size; + mac_stats->ul.current_bytes = sched_pusch->tb_size; sched_ctrl->last_ul_frame = sched_pusch->frame; sched_ctrl->last_ul_slot = sched_pusch->slot; diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index e047494b52..b813063e7c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -102,9 +102,9 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp stroff+=sprintf(output+stroff,"UE %d: dlsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n", UE_id, - stats->dlsch_rounds[0], stats->dlsch_rounds[1], - stats->dlsch_rounds[2], stats->dlsch_rounds[3], - stats->dlsch_errors, + stats->dl.rounds[0], stats->dl.rounds[1], + stats->dl.rounds[2], stats->dl.rounds[3], + stats->dl.errors, stats->pucch0_DTX, sched_ctrl->dl_bler_stats.bler, sched_ctrl->dl_bler_stats.mcs); @@ -112,25 +112,25 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp stats->num_rsrp_meas = 0; stats->cumul_rsrp = 0; } - stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %"PRIu64"\n", UE_id, stats->dlsch_total_bytes); + stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %"PRIu64"\n", UE_id, stats->dl.total_bytes); stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64"\n", UE_id, - stats->ulsch_rounds[0], stats->ulsch_rounds[1], - stats->ulsch_rounds[2], stats->ulsch_rounds[3], + stats->ul.rounds[0], stats->ul.rounds[1], + stats->ul.rounds[2], stats->ul.rounds[3], stats->ulsch_DTX, - stats->ulsch_errors); + stats->ul.errors); stroff+=sprintf(output+stroff, "UE %d: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n", UE_id, - stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx); + stats->ulsch_total_bytes_scheduled, stats->ul.total_bytes); for (int lc_id = 0; lc_id < 63; lc_id++) { - if (stats->lc_bytes_tx[lc_id] > 0) { - stroff+=sprintf(output+stroff, "UE %d: LCID %d: %"PRIu64" bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); - LOG_D(NR_MAC, "UE %d: LCID %d: %"PRIu64" bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); + if (stats->dl.lc_bytes[lc_id] > 0) { + stroff+=sprintf(output+stroff, "UE %d: LCID %d: %"PRIu64" bytes TX\n", UE_id, lc_id, stats->dl.lc_bytes[lc_id]); + LOG_D(NR_MAC, "UE %d: LCID %d: %"PRIu64" bytes TX\n", UE_id, lc_id, stats->dl.lc_bytes[lc_id]); } - if (stats->lc_bytes_rx[lc_id] > 0) { - stroff+=sprintf(output+stroff, "UE %d: LCID %d: %"PRIu64" bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); - LOG_D(NR_MAC, "UE %d: LCID %d: %"PRIu64" bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); + if (stats->ul.lc_bytes[lc_id] > 0) { + stroff+=sprintf(output+stroff, "UE %d: LCID %d: %"PRIu64" bytes RX\n", UE_id, lc_id, stats->ul.lc_bytes[lc_id]); + LOG_D(NR_MAC, "UE %d: LCID %d: %"PRIu64" bytes RX\n", UE_id, lc_id, stats->ul.lc_bytes[lc_id]); } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index d8ff37ef15..6f5f7b3d95 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -676,19 +676,19 @@ typedef struct { uicc_t *uicc; } NRUEcontext_t; -typedef struct { - uint64_t lc_bytes_tx[64]; - uint64_t lc_bytes_rx[64]; - uint64_t dlsch_rounds[8]; - uint64_t dlsch_errors; - uint64_t dlsch_total_bytes; - int dlsch_current_bytes; - uint64_t ulsch_rounds[8]; - uint64_t ulsch_errors; +typedef struct NR_mac_dir_stats { + uint64_t lc_bytes[64]; + uint64_t rounds[8]; + uint64_t errors; + uint64_t total_bytes; + uint32_t current_bytes; +} NR_mac_dir_stats_t; + +typedef struct NR_mac_stats { + NR_mac_dir_stats_t dl; + NR_mac_dir_stats_t ul; uint32_t ulsch_DTX; uint64_t ulsch_total_bytes_scheduled; - uint64_t ulsch_total_bytes_rx; - int ulsch_current_bytes; uint32_t pucch0_DTX; int cumul_rsrp; uint8_t num_rsrp_meas; From 17cbc4dbf4c347b5dd3f0383f0c4130533dbd14b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 21 Jan 2022 16:55:14 +0100 Subject: [PATCH 069/105] Generalize get_mcs_from_bler() --- openair2/GNB_APP/MACRLC_nr_paramdef.h | 12 ++- openair2/GNB_APP/gnb_config.c | 8 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 81 ++----------------- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 45 +++++++++++ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 6 ++ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 21 ++--- 6 files changed, 77 insertions(+), 96 deletions(-) diff --git a/openair2/GNB_APP/MACRLC_nr_paramdef.h b/openair2/GNB_APP/MACRLC_nr_paramdef.h index e634f077e2..b7c8401971 100644 --- a/openair2/GNB_APP/MACRLC_nr_paramdef.h +++ b/openair2/GNB_APP/MACRLC_nr_paramdef.h @@ -62,7 +62,6 @@ #define CONFIG_STRING_MACRLC_PUSCHFAILURETHRES "pusch_FailureThres" #define CONFIG_STRING_MACRLC_DL_BLER_TARGET_UPPER "dl_bler_target_upper" #define CONFIG_STRING_MACRLC_DL_BLER_TARGET_LOWER "dl_bler_target_lower" -#define CONFIG_STRING_MACRLC_DL_RD2_BLER_THRESHOLD "dl_rd2_bler_threshold" #define CONFIG_STRING_MACRLC_DL_MAX_MCS "dl_max_mcs" #define CONFIG_STRING_MACRLC_HARQ_ROUND_MAX "harq_round_max" #define CONFIG_STRING_MACRLC_MIN_GRANT_PRB "min_grant_prb" @@ -97,7 +96,6 @@ {CONFIG_STRING_MACRLC_PUSCHFAILURETHRES, NULL, 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ {CONFIG_STRING_MACRLC_DL_BLER_TARGET_UPPER, "Upper threshold of BLER to decrease DL MCS", 0, dblptr:NULL, defdblval:0.15, TYPE_DOUBLE, 0}, \ {CONFIG_STRING_MACRLC_DL_BLER_TARGET_LOWER, "Lower threshold of BLER to increase DL MCS", 0, dblptr:NULL, defdblval:0.05, TYPE_DOUBLE, 0}, \ -{CONFIG_STRING_MACRLC_DL_RD2_BLER_THRESHOLD, "Threshold of RD2/RETX2 BLER to decrease DL MCS", 0, dblptr:NULL, defdblval:0.01, TYPE_DOUBLE, 0}, \ {CONFIG_STRING_MACRLC_DL_MAX_MCS, "Maximum DL MCS that should be used", 0, u8ptr:NULL, defintval:28, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_HARQ_ROUND_MAX, "Maximum number of HARQ rounds", 0, u8ptr:NULL, defintval:4, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_MIN_GRANT_PRB, "Minimal Periodic ULSCH Grant PRBs", 0, u8ptr:NULL, defintval:5, TYPE_UINT8, 0}, \ @@ -127,10 +125,10 @@ #define MACRLC_PUSCHFAILURETHRES_IDX 21 #define MACRLC_DL_BLER_TARGET_UPPER_IDX 22 #define MACRLC_DL_BLER_TARGET_LOWER_IDX 23 -#define MACRLC_DL_RD2_BLER_THRESHOLD_IDX 24 -#define MACRLC_DL_MAX_MCS_IDX 25 -#define MACRLC_HARQ_ROUND_MAX_IDX 26 -#define MACRLC_MIN_GRANT_PRB_IDX 27 -#define MACRLC_MIN_GRANT_MCS_IDX 28 +#define MACRLC_DL_MAX_MCS_IDX 24 +#define MACRLC_HARQ_ROUND_MAX_IDX 25 +#define MACRLC_MIN_GRANT_PRB_IDX 26 +#define MACRLC_MIN_GRANT_MCS_IDX 27 + /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index c11d6b8092..f57402c184 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -873,10 +873,10 @@ void RCconfig_nr_macrlc() { AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr)); } RC.nrmac[j]->ulsch_max_frame_inactivity = *(MacRLC_ParamList.paramarray[j][MACRLC_ULSCH_MAX_FRAME_INACTIVITY].uptr); - RC.nrmac[j]->dl_bler_target_upper = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_UPPER_IDX].dblptr); - RC.nrmac[j]->dl_bler_target_lower = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_LOWER_IDX].dblptr); - RC.nrmac[j]->dl_rd2_bler_threshold = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_RD2_BLER_THRESHOLD_IDX].dblptr); - RC.nrmac[j]->dl_max_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_MAX_MCS_IDX].u8ptr); + NR_bler_options_t *dl_bler_options = &RC.nrmac[j]->dl_bler; + dl_bler_options->upper = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_UPPER_IDX].dblptr); + dl_bler_options->lower = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_LOWER_IDX].dblptr); + dl_bler_options->max_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_MAX_MCS_IDX].u8ptr); RC.nrmac[j]->harq_round_max = *(MacRLC_ParamList.paramarray[j][MACRLC_HARQ_ROUND_MAX_IDX].u8ptr); RC.nrmac[j]->min_grant_prb = *(MacRLC_ParamList.paramarray[j][MACRLC_MIN_GRANT_PRB_IDX].u8ptr); RC.nrmac[j]->min_grant_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_MIN_GRANT_MCS_IDX].u8ptr); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 3a179fbaea..30127847dc 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -397,79 +397,6 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP, return offset; } -#define BLER_UPDATE_FRAME 10 -#define BLER_FILTER 0.9f -int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t slot, int UE_id, int mcs_table) { - gNB_MAC_INST *nrmac = RC.nrmac[mod_id]; - const NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; - const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - int max_allowed_mcs = (mcs_table == 1) ? 27 : 28; - - NR_UE_sched_ctrl_t *sched_ctrl = &nrmac->UE_info.UE_sched_ctrl[UE_id]; - NR_DL_bler_stats_t *bler_stats = &sched_ctrl->dl_bler_stats; - /* first call: everything is zero. Initialize to sensible default */ - if (bler_stats->last_frame_slot == 0 && bler_stats->mcs == 0) { - bler_stats->last_frame_slot = frame * n + slot; - bler_stats->mcs = 9; - bler_stats->bler = (nrmac->dl_bler_target_lower + nrmac->dl_bler_target_upper) / 2; - bler_stats->rd2_bler = nrmac->dl_rd2_bler_threshold; - } - - const int now = frame * n + slot; - int diff = now - bler_stats->last_frame_slot; - - if (diff < 0) // wrap around - diff += 1024 * n; - - const uint8_t old_mcs = bler_stats->mcs; - const NR_mac_stats_t *stats = &nrmac->UE_info.mac_stats[UE_id]; - - // TODO put back this condition when relevant - /*const int dret3x = stats->dl.rounds[3] - bler_stats->dlsch_rounds[3]; - if (dret3x > 0) { - if there is a third retransmission, decrease MCS for stabilization and - restart averaging window to stabilize transmission - bler_stats->last_frame_slot = now; - bler_stats->mcs = max(9, bler_stats->mcs - 1); - memcpy(bler_stats->dlsch_rounds, stats->dl.rounds, sizeof(stats->dl.rounds)); - LOG_D(MAC, "%4d.%2d: %d retx in 3rd round, setting MCS to %d and restarting window\n", frame, slot, dret3x, bler_stats->mcs); - return bler_stats->mcs; - }*/ - if (diff < BLER_UPDATE_FRAME * n) - return old_mcs; // no update - - // last update is longer than x frames ago - const int dtx = (int)(stats->dl.rounds[0] - bler_stats->dlsch_rounds[0]); - const int dretx = (int)(stats->dl.rounds[1] - bler_stats->dlsch_rounds[1]); - const int dretx2 = (int)(stats->dl.rounds[2] - bler_stats->dlsch_rounds[2]); - const float bler_window = dtx > 0 ? (float) dretx / dtx : bler_stats->bler; - const float rd2_bler_wnd = dtx > 0 ? (float) dretx2 / dtx : bler_stats->rd2_bler; - bler_stats->bler = BLER_FILTER * bler_stats->bler + (1 - BLER_FILTER) * bler_window; - bler_stats->rd2_bler = BLER_FILTER / 4 * bler_stats->rd2_bler + (1 - BLER_FILTER / 4) * rd2_bler_wnd; - int new_mcs = old_mcs; - - // TODO put back this condition when relevant - /* first ensure that number of 2nd retx is below threshold. If this is the - * case, use 1st retx to adjust faster - if (bler_stats->rd2_bler > nrmac->dl_rd2_bler_threshold && old_mcs > 6) { - new_mcs -= 2; - } else if (bler_stats->rd2_bler < nrmac->dl_rd2_bler_threshold) {*/ - const int max_mcs = min(max_allowed_mcs, min(sched_ctrl->dl_max_mcs, nrmac->dl_max_mcs)); - if (bler_stats->bler < nrmac->dl_bler_target_lower && old_mcs < max_mcs && dtx > 9) - new_mcs += 1; - else if ((bler_stats->bler > nrmac->dl_bler_target_upper && old_mcs > 6) // above threshold - || (dtx <= 3 && old_mcs > 9)) // no activity - new_mcs -= 1; - - // else we are within threshold boundaries - bler_stats->last_frame_slot = now; - bler_stats->mcs = new_mcs; - memcpy(bler_stats->dlsch_rounds, stats->dl.rounds, sizeof(stats->dl.rounds)); - LOG_D(MAC, "%4d.%2d MCS %d -> %d (dtx %d, dretx %d, BLER wnd %.3f avg %.6f, dretx2 %d, RD2 BLER wnd %.3f avg %.6f)\n", - frame, slot, old_mcs, new_mcs, dtx, dretx, bler_window, bler_stats->bler, dretx2, rd2_bler_wnd, bler_stats->rd2_bler); - return new_mcs; -} - void nr_store_dlsch_buffer(module_id_t module_id, frame_t frame, sub_frame_t slot) { @@ -740,6 +667,7 @@ void pf_dl(module_id_t module_id, if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; + const NR_mac_dir_stats_t *stats = &UE_info->mac_stats[UE_id].dl; NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; /* get the PID of a HARQ process awaiting retrnasmission, or -1 otherwise */ @@ -747,7 +675,7 @@ void pf_dl(module_id_t module_id, layers[UE_id] = ps->nrOfLayers; // initialization of layers to the previous value in the strcuture /* Calculate Throughput */ const float a = 0.0005f; // corresponds to 200ms window - const uint32_t b = UE_info->mac_stats[UE_id].dl.current_bytes; + const uint32_t b = stats->current_bytes; thr_ue[UE_id] = (1 - a) * thr_ue[UE_id] + a * b; /* retransmission */ @@ -770,7 +698,10 @@ void pf_dl(module_id_t module_id, continue; /* Calculate coeff */ - sched_pdsch->mcs = get_mcs_from_bler(module_id, /* CC_id = */ 0, frame, slot, UE_id, ps->mcsTableIdx); + const NR_bler_options_t *bo = &mac->dl_bler; + const int max_mcs_table = ps->mcsTableIdx == 1 ? 27 : 28; + const int max_mcs = min(sched_ctrl->dl_max_mcs, max_mcs_table); + sched_pdsch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->dl_bler_stats, max_mcs, frame); layers[UE_id] = set_dl_nrOfLayers(sched_ctrl); const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 09b890a860..933dee8be4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -761,6 +761,51 @@ void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, : num_dmrs_cdm_grps_no_data * 4; } +#define BLER_UPDATE_FRAME 10 +#define BLER_FILTER 0.9f +int get_mcs_from_bler(const NR_bler_options_t *bler_options, + const NR_mac_dir_stats_t *stats, + NR_bler_stats_t *bler_stats, + int max_mcs, + frame_t frame) +{ + /* first call: everything is zero. Initialize to sensible default */ + if (bler_stats->last_frame == 0 && bler_stats->mcs == 0) { + bler_stats->last_frame = frame; + bler_stats->mcs = 9; + bler_stats->bler = (bler_options->lower + bler_options->upper) / 2.0f; + } + int diff = frame - bler_stats->last_frame; + if (diff < 0) // wrap around + diff += 1024; + + max_mcs = min(max_mcs, bler_options->max_mcs); + const uint8_t old_mcs = min(bler_stats->mcs, max_mcs); + if (diff < BLER_UPDATE_FRAME) + return old_mcs; // no update + + // last update is longer than x frames ago + const int dtx = (int)(stats->rounds[0] - bler_stats->rounds[0]); + const int dretx = (int)(stats->rounds[1] - bler_stats->rounds[1]); + const float bler_window = dtx > 0 ? (float) dretx / dtx : bler_stats->bler; + bler_stats->bler = BLER_FILTER * bler_stats->bler + (1 - BLER_FILTER) * bler_window; + + int new_mcs = old_mcs; + if (bler_stats->bler < bler_options->lower && old_mcs < max_mcs && dtx > 9) + new_mcs += 1; + else if ((bler_stats->bler > bler_options->upper && old_mcs > 6) // above threshold + || (dtx <= 3 && old_mcs > 9)) // no activity + new_mcs -= 1; + // else we are within threshold boundaries + + bler_stats->last_frame = frame; + bler_stats->mcs = new_mcs; + memcpy(bler_stats->rounds, stats->rounds, sizeof(stats->rounds)); + LOG_D(MAC, "frame %4d MCS %d -> %d (dtx %d, dretx %d, BLER wnd %.3f avg %.6f)\n", + frame, old_mcs, new_mcs, dtx, dretx, bler_window, bler_stats->bler); + return new_mcs; +} + void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, nr_scs_e scs_common, nr_scs_e pdcch_scs, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index cdb1658f55..f645bc9148 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -535,6 +535,12 @@ bool nr_find_nb_rb(uint16_t Qm, uint32_t *tbs, uint16_t *nb_rb); +int get_mcs_from_bler(const NR_bler_options_t *bler_options, + const NR_mac_dir_stats_t *stats, + NR_bler_stats_t *bler_stats, + int max_mcs, + frame_t frame); + void nr_sr_reporting(int Mod_idP, frame_t frameP, sub_frame_t slotP); void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 6f5f7b3d95..33fe7c8bda 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -459,13 +459,12 @@ typedef struct NR_UE_harq { //! fixme : need to enhace for the multiple TB CQI report -typedef struct NR_DL_bler_stats { - frame_t last_frame_slot; +typedef struct NR_bler_stats { + frame_t last_frame; float bler; - float rd2_bler; uint8_t mcs; - uint64_t dlsch_rounds[8]; -} NR_DL_bler_stats_t; + uint64_t rounds[8]; +} NR_bler_stats_t; // /*! As per spec 38.214 section 5.2.1.4.2 @@ -627,7 +626,7 @@ typedef struct { mac_rlc_status_resp_t rlc_status[NR_MAX_NUM_LCID]; /// Estimation of HARQ from BLER - NR_DL_bler_stats_t dl_bler_stats; + NR_bler_stats_t dl_bler_stats; uint16_t ta_frame; int16_t ta_update; @@ -694,6 +693,11 @@ typedef struct NR_mac_stats { uint8_t num_rsrp_meas; } NR_mac_stats_t; +typedef struct NR_bler_options { + double upper; + double lower; + uint8_t max_mcs; +} NR_bler_options_t; /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ #define MAX_CSI_REPORTCONFIG 48 @@ -835,10 +839,7 @@ typedef struct gNB_MAC_INST_s { int xp_pdsch_antenna_ports; bool first_MIB; - double dl_bler_target_upper; - double dl_bler_target_lower; - double dl_rd2_bler_threshold; - uint8_t dl_max_mcs; + NR_bler_options_t dl_bler; uint8_t harq_round_max; uint8_t min_grant_prb; uint8_t min_grant_mcs; From 34b821433b6021d201778ee85d268e4865ef81da Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 4 Mar 2022 17:14:35 +0100 Subject: [PATCH 070/105] Add UL BLER options and read from config --- openair2/GNB_APP/MACRLC_nr_paramdef.h | 16 +++++++++++++--- openair2/GNB_APP/gnb_config.c | 4 ++++ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/openair2/GNB_APP/MACRLC_nr_paramdef.h b/openair2/GNB_APP/MACRLC_nr_paramdef.h index b7c8401971..a7bc3e8545 100644 --- a/openair2/GNB_APP/MACRLC_nr_paramdef.h +++ b/openair2/GNB_APP/MACRLC_nr_paramdef.h @@ -63,10 +63,14 @@ #define CONFIG_STRING_MACRLC_DL_BLER_TARGET_UPPER "dl_bler_target_upper" #define CONFIG_STRING_MACRLC_DL_BLER_TARGET_LOWER "dl_bler_target_lower" #define CONFIG_STRING_MACRLC_DL_MAX_MCS "dl_max_mcs" +#define CONFIG_STRING_MACRLC_UL_BLER_TARGET_UPPER "ul_bler_target_upper" +#define CONFIG_STRING_MACRLC_UL_BLER_TARGET_LOWER "ul_bler_target_lower" +#define CONFIG_STRING_MACRLC_UL_MAX_MCS "ul_max_mcs" #define CONFIG_STRING_MACRLC_HARQ_ROUND_MAX "harq_round_max" #define CONFIG_STRING_MACRLC_MIN_GRANT_PRB "min_grant_prb" #define CONFIG_STRING_MACRLC_MIN_GRANT_MCS "min_grant_mcs" + /*-------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* MacRLC configuration parameters */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ @@ -97,6 +101,9 @@ {CONFIG_STRING_MACRLC_DL_BLER_TARGET_UPPER, "Upper threshold of BLER to decrease DL MCS", 0, dblptr:NULL, defdblval:0.15, TYPE_DOUBLE, 0}, \ {CONFIG_STRING_MACRLC_DL_BLER_TARGET_LOWER, "Lower threshold of BLER to increase DL MCS", 0, dblptr:NULL, defdblval:0.05, TYPE_DOUBLE, 0}, \ {CONFIG_STRING_MACRLC_DL_MAX_MCS, "Maximum DL MCS that should be used", 0, u8ptr:NULL, defintval:28, TYPE_UINT8, 0}, \ +{CONFIG_STRING_MACRLC_UL_BLER_TARGET_UPPER, "Upper threshold of BLER to decrease UL MCS", 0, dblptr:NULL, defdblval:0.15, TYPE_DOUBLE, 0}, \ +{CONFIG_STRING_MACRLC_UL_BLER_TARGET_LOWER, "Lower threshold of BLER to increase UL MCS", 0, dblptr:NULL, defdblval:0.05, TYPE_DOUBLE, 0}, \ +{CONFIG_STRING_MACRLC_UL_MAX_MCS, "Maximum UL MCS that should be used", 0, u8ptr:NULL, defintval:9, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_HARQ_ROUND_MAX, "Maximum number of HARQ rounds", 0, u8ptr:NULL, defintval:4, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_MIN_GRANT_PRB, "Minimal Periodic ULSCH Grant PRBs", 0, u8ptr:NULL, defintval:5, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_MIN_GRANT_MCS, "Minimal Periodic ULSCH Grant MCS", 0, u8ptr:NULL, defintval:9, TYPE_UINT8, 0} \ @@ -126,9 +133,12 @@ #define MACRLC_DL_BLER_TARGET_UPPER_IDX 22 #define MACRLC_DL_BLER_TARGET_LOWER_IDX 23 #define MACRLC_DL_MAX_MCS_IDX 24 -#define MACRLC_HARQ_ROUND_MAX_IDX 25 -#define MACRLC_MIN_GRANT_PRB_IDX 26 -#define MACRLC_MIN_GRANT_MCS_IDX 27 +#define MACRLC_UL_BLER_TARGET_UPPER_IDX 25 +#define MACRLC_UL_BLER_TARGET_LOWER_IDX 26 +#define MACRLC_UL_MAX_MCS_IDX 27 +#define MACRLC_HARQ_ROUND_MAX_IDX 28 +#define MACRLC_MIN_GRANT_PRB_IDX 29 +#define MACRLC_MIN_GRANT_MCS_IDX 30 /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index f57402c184..9292d1f962 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -877,6 +877,10 @@ void RCconfig_nr_macrlc() { dl_bler_options->upper = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_UPPER_IDX].dblptr); dl_bler_options->lower = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_LOWER_IDX].dblptr); dl_bler_options->max_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_MAX_MCS_IDX].u8ptr); + NR_bler_options_t *ul_bler_options = &RC.nrmac[j]->ul_bler; + ul_bler_options->upper = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_BLER_TARGET_UPPER_IDX].dblptr); + ul_bler_options->lower = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_BLER_TARGET_LOWER_IDX].dblptr); + ul_bler_options->max_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_MAX_MCS_IDX].u8ptr); RC.nrmac[j]->harq_round_max = *(MacRLC_ParamList.paramarray[j][MACRLC_HARQ_ROUND_MAX_IDX].u8ptr); RC.nrmac[j]->min_grant_prb = *(MacRLC_ParamList.paramarray[j][MACRLC_MIN_GRANT_PRB_IDX].u8ptr); RC.nrmac[j]->min_grant_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_MIN_GRANT_MCS_IDX].u8ptr); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 33fe7c8bda..8e72447351 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -840,6 +840,7 @@ typedef struct gNB_MAC_INST_s { bool first_MIB; NR_bler_options_t dl_bler; + NR_bler_options_t ul_bler; uint8_t harq_round_max; uint8_t min_grant_prb; uint8_t min_grant_mcs; From 3ca4cb708cf30664bd84666a3b3540a965a1f92c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 4 Mar 2022 17:42:00 +0100 Subject: [PATCH 071/105] Select UL MCS from BLER --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 10 +++++++--- openair2/LAYER2/NR_MAC_gNB/main.c | 6 ++++-- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 57cd91e286..92746a9b13 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1174,10 +1174,11 @@ void pf_ul(module_id_t module_id, const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; + const NR_mac_dir_stats_t *stats = &UE_info->mac_stats[UE_id].ul; /* Calculate throughput */ const float a = 0.0005f; // corresponds to 200ms window - const uint32_t b = UE_info->mac_stats[UE_id].ul.current_bytes; + const uint32_t b = stats->current_bytes; ul_thr_ue[UE_id] = (1 - a) * ul_thr_ue[UE_id] + a * b; /* Check if retransmission is necessary */ @@ -1209,6 +1210,10 @@ void pf_ul(module_id_t module_id, continue; } + const NR_bler_options_t *bo = &nrmac->ul_bler; + const int max_mcs = bo->max_mcs; /* no per-user maximum MCS yet */ + sched_pusch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->ul_bler_stats, max_mcs, frame); + /* Schedule UE on SR or UL inactivity and no data (otherwise, will be scheduled * based on data to transmit) */ if (B == 0 && do_sched) { @@ -1284,7 +1289,7 @@ void pf_ul(module_id_t module_id, sched_ctrl->aggregation_level); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; - sched_pusch->mcs = nrmac->min_grant_mcs; + sched_pusch->mcs = min(nrmac->min_grant_mcs, sched_pusch->mcs); update_ul_ue_R_Qm(sched_pusch, ps); sched_pusch->rbStart = rbStart; sched_pusch->rbSize = min_rb; @@ -1310,7 +1315,6 @@ void pf_ul(module_id_t module_id, add_tail_nr_list(&UE_sched, UE_id); /* Calculate coefficient*/ - sched_pusch->mcs = nrmac->min_grant_mcs; const uint32_t tbs = ul_pf_tbs[ps->mcs_table][sched_pusch->mcs]; coeff_ue[UE_id] = (float) tbs / ul_thr_ue[UE_id]; LOG_D(NR_MAC,"b %d, ul_thr_ue[%d] %f, tbs %d, coeff_ue[%d] %f\n", diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index b813063e7c..4c14233a32 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -113,12 +113,14 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp stats->cumul_rsrp = 0; } stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %"PRIu64"\n", UE_id, stats->dl.total_bytes); - stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64"\n", + stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.5f MCS %d\n", UE_id, stats->ul.rounds[0], stats->ul.rounds[1], stats->ul.rounds[2], stats->ul.rounds[3], stats->ulsch_DTX, - stats->ul.errors); + stats->ul.errors, + sched_ctrl->ul_bler_stats.bler, + sched_ctrl->ul_bler_stats.mcs); stroff+=sprintf(output+stroff, "UE %d: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n", UE_id, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 8e72447351..99095e1ded 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -627,6 +627,7 @@ typedef struct { /// Estimation of HARQ from BLER NR_bler_stats_t dl_bler_stats; + NR_bler_stats_t ul_bler_stats; uint16_t ta_frame; int16_t ta_update; From 436eb2d5a9beed5d4bc7523783ae9bc5a79a5315 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 16:05:38 +0100 Subject: [PATCH 072/105] Fix PUCCH config in fill_default_uplinkBWP to consider the enabled CSI-RS --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 98 ++++++++++++----------------- 1 file changed, 41 insertions(+), 57 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index f633ea6fcc..370608db4e 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1464,18 +1464,28 @@ void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); pucch_Config->resourceSetToReleaseList = NULL; NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); + NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); pucchresset0->pucch_ResourceSetId = 0; - NR_PUCCH_ResourceId_t *pucchres0id0=calloc(1,sizeof(*pucchres0id0)); - *pucchres0id0=ubwp->bwp_Id; // To uniquely identify each pucchresource lets derive it from the BWPId - ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchres0id0); + NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); + *pucchresset0id0=0; + ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0); pucchresset0->maxPayloadSize=NULL; ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); + pucchresset1->pucch_ResourceSetId = 1; + NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); + *pucchresset1id0=1; + ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0); + pucchresset1->maxPayloadSize=NULL; + ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); pucch_Config->resourceToReleaseList = NULL; + // configure one single PUCCH0 opportunity for initial connection procedure + // one symbol (13) int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); - pucchres0->pucch_ResourceId=*pucchres0id0; - pucchres0->startingPRB=(8+uid) % curr_bwp; + pucchres0->pucch_ResourceId=0; + pucchres0->startingPRB=(8+uid) % (curr_bwp/2); + LOG_D(NR_RRC, "pucchres0->startPRB %ld uid %d curr_bwp %d\n", pucchres0->startingPRB, uid, curr_bwp); pucchres0->intraSlotFrequencyHopping=NULL; pucchres0->secondHopPRB=NULL; pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; @@ -1484,8 +1494,17 @@ void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, pucchres0->format.choice.format0->nrofSymbols=1; pucchres0->format.choice.format0->startingSymbolIndex=13; ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); - -/* + NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); + pucchres2->pucch_ResourceId=1; + pucchres2->startingPRB=0; + pucchres2->intraSlotFrequencyHopping=NULL; + pucchres2->secondHopPRB=NULL; + pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2; + pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2)); + pucchres2->format.choice.format2->nrofPRBs=8; + pucchres2->format.choice.format2->nrofSymbols=1; + pucchres2->format.choice.format2->startingSymbolIndex=13; + ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); @@ -1498,72 +1517,37 @@ void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, pucchfmt2->pi2BPSK=NULL; pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; -*/ - - // PUCCH config - Scheduling request configuration + pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); + NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); + pucchspatial->pucch_SpatialRelationInfoId = 1; + pucchspatial->servingCellId = NULL; + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; + pucchspatial->referenceSignal.choice.ssb_Index = 0; + pucchspatial->pucch_PathlossReferenceRS_Id = 0; + pucchspatial->p0_PUCCH_Id = 1; + pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; + ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); schedulingRequestResourceConfig->schedulingRequestResourceId = 1; schedulingRequestResourceConfig->schedulingRequestID = 0; schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; // 40 slot period - // note: make sure that there is no issue here. Later choose the RNTI accordingly. - // Here we would be limited to 3 UEs on this resource (1 1/2 Frames 30 kHz SCS, 5 ms TDD periodicity => slots 7,8,9). - // This should be a temporary resource until the first RRCReconfiguration gives new pucch resources. - // Check for above configuration and exit for now if it is not the case + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; AssertFatal(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing==NR_SubcarrierSpacing_kHz30, "SCS != 30kHz\n"); - AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity==NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5, - "TDD period != 5ms : %ld\n",scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = 8; schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); - *schedulingRequestResourceConfig->resource = *pucchres0id0; + *schedulingRequestResourceConfig->resource = 0; ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); - pucch_Config->schedulingRequestResourceToReleaseList=NULL; - - pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); long *delay[8]; for (int i=0;i<8;i++) { delay[i] = calloc(1,sizeof(*delay[i])); - AssertFatal(configuration->minRXTXTIME >=2 && configuration->minRXTXTIME <7, "check minRXTXTIME %d\n",configuration->minRXTXTIME); - *delay[i] = i+configuration->minRXTXTIME; + AssertFatal(configuration->minRXTXTIME >= 2 && configuration->minRXTXTIME < 7, + "minRXTXTIME is %d but should be within [2,7)\n", configuration->minRXTXTIME); + *delay[i] = i + configuration->minRXTXTIME; ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); } - pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); - NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); - pucchspatial->pucch_SpatialRelationInfoId = 1; - pucchspatial->servingCellId = NULL; - if(configuration->do_CSIRS) { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - pucchspatial->referenceSignal.choice.csi_RS_Index = 0; - } - else { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; - } - pucchspatial->pucch_PathlossReferenceRS_Id = 0; - pucchspatial->p0_PUCCH_Id = 1; - pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; - ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); - pucch_Config->spatialRelationInfoToReleaseList=NULL; - pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; - pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); - NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); - p00->p0_PUCCH_Id=1; - p00->p0_PUCCH_Value = 0; - ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); - pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; // PUSCH config ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); From d56f2c8e12d97963868659875222e442afb548cf Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 18 May 2022 17:36:32 +0200 Subject: [PATCH 073/105] addressing review comments --- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 4 ++-- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 4 ++-- openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 4 ++-- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 4 ++-- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index bb91d8e5cf..8e97a8cbdc 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -368,8 +368,8 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, memcpy(harq->b, a, (A / 8) + 3); // using 3 bytes to mimic the case of 24 bit crc } - // target_code_rate in terms of 0.1 bits - float Coderate = (float) rel15->targetCodeRate[0] / (float) 10240; + // target_code_rate is in 0.1 units + float Coderate = (float) rel15->targetCodeRate[0] / 10240.0f; LOG_D(PHY,"DLSCH Coderate %f\n",Coderate); if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 5fadc0946c..b9a1430be6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -439,8 +439,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, A = (harq_process->TBS)<<3; - // target_code_rate in terms of 0.1 bits - float Coderate = (float) pusch_pdu->target_code_rate / (float) 10240; + // target_code_rate is in 0.1 units + float Coderate = (float) pusch_pdu->target_code_rate / 10240.0f; LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d\n", harq_pid, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index fe96190efb..403f016e79 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -504,8 +504,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, harq_process->Qm,harq_process->Nl); G = harq_process->G; - // target_code_rate in terms of 0.1 bits - float Coderate = (float) harq_process->R / (float) 10240; + // target_code_rate is in 0.1 units + float Coderate = (float) harq_process->R / 10240.0f; LOG_D(PHY,"%d.%d DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d Qm %d Coderate %f\n", frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, harq_process->mcs, harq_process->Nl, nb_symb_sch, nb_rb, harq_process->Qm, Coderate); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 80fe3c8107..d09f2554cc 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -198,8 +198,8 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, uint16_t Kr=0; uint32_t r_offset=0; uint32_t F=0; - // target_code_rate in terms of 0.1 bits - float Coderate = (float) harq_process->pusch_pdu.target_code_rate / (float) 10240; + // target_code_rate is in 0.1 units + float Coderate = (float) harq_process->pusch_pdu.target_code_rate / 10240.0f; /////////// ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 8c4f28ecd1..99731c8cb1 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -802,7 +802,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, nb_symb_sch, nr_slot_rx, harq_pid, - pdsch==PDSCH?1:0); + pdsch==PDSCH); LOG_T(PHY,"dlsch decoding, ret = %d\n", ret); @@ -878,7 +878,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, nb_symb_sch, nr_slot_rx, harq_pid, - pdsch==PDSCH?1:0);//proc->decoder_switch + pdsch==PDSCH);//proc->decoder_switch LOG_T(PHY,"CW dlsch decoding, ret1 = %d\n", ret1); stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index a58004dfa8..20951be0e8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1106,11 +1106,11 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, for(int i = start_symbol_index; i < start_symbol_index+nr_of_symbols; i++) num_dmrs_symb += (pusch_pdu->ul_dmrs_symb_pos >> i) & 1; - int R, TBS = 0; + int TBS = 0; while(TBS<7) { // TBS for msg3 is 7 bytes (except for RRCResumeRequest1 currently not implemented) mcsindex++; - R = nr_get_code_rate_ul(mcsindex,pusch_pdu->mcs_table); - pusch_pdu->target_code_rate = (R>1024)?R*5:R*10; + int R = nr_get_code_rate_ul(mcsindex,pusch_pdu->mcs_table); + pusch_pdu->target_code_rate = R; pusch_pdu->qam_mod_order = nr_get_Qm_ul(mcsindex,pusch_pdu->mcs_table); TBS = nr_compute_tbs(pusch_pdu->qam_mod_order, R, From 3d5cfb6642cfc47140ef36aae02224c647ac0f93 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 17:00:05 +0100 Subject: [PATCH 074/105] Update the spatialRelationInfoToAddModList for dedicated UL-BWPs --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 370608db4e..647c42d399 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -2247,6 +2247,16 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; ASN_SEQUENCE_ADD(&spatialRelationInfoToAddModList->list,pucchspatial); SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->spatialRelationInfoToAddModList = spatialRelationInfoToAddModList; + struct NR_UplinkConfig__uplinkBWP_ToAddModList *UL_BWP_list = SpCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList; + if (UL_BWP_list) { + for (int i=0; ilist.count; i++){ + NR_BWP_Uplink_t *ubwp = UL_BWP_list->list.array[i]; + if (ubwp->bwp_Dedicated->pucch_Config->choice.setup->spatialRelationInfoToAddModList) { + free(ubwp->bwp_Dedicated->pucch_Config->choice.setup->spatialRelationInfoToAddModList); + } + ubwp->bwp_Dedicated->pucch_Config->choice.setup->spatialRelationInfoToAddModList = spatialRelationInfoToAddModList; + } + } if(!SpCellConfig->spCellConfigDedicated->csi_MeasConfig) { SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); } From b46077c22dc84cf21f67e919e48bd824e714d642 Mon Sep 17 00:00:00 2001 From: KARIM BOUTIBA Date: Tue, 22 Mar 2022 11:57:52 +0100 Subject: [PATCH 075/105] add multiple pdu session support (tested with 2 pdu sessions) --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 +- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 5 -- openair2/RRC/NR/MESSAGES/asn1_msg.c | 66 ++++++++++--------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 8 ++- openair2/RRC/NR/rrc_gNB.c | 22 +++++-- openair2/RRC/NR/rrc_gNB_NGAP.c | 2 +- openair3/ocp-gtpu/gtp_itf.cpp | 2 +- 7 files changed, 60 insertions(+), 47 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 7a34527166..ec6c9a3cd3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -451,7 +451,7 @@ int nr_process_mac_pdu(module_id_t module_idP, 0); break; - case UL_SCH_LCID_DTCH: + case UL_SCH_LCID_DTCH ... (UL_SCH_LCID_DTCH + 28): // check if LCID is valid at current time. if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) return 0; diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index b5cea6bdb9..ea4b7e80c7 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -977,11 +977,6 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s, exit(1); } - if (drb_id != 1) { - LOG_E(PDCP, "%s:%d:%s: fatal, bad drb id %d\n", - __FILE__, __LINE__, __FUNCTION__, drb_id); - exit(1); - } nr_pdcp_manager_lock(nr_pdcp_ue_manager); ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 7e38cac8a0..900f5b8b1f 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -2161,7 +2161,7 @@ void fill_initial_SpCellConfig(int uid, } -void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup,int use_rlc_um_for_drb) { +void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, int use_rlc_um_for_drb, uint8_t configure_srb, uint8_t bearer_id_start, uint8_t nb_bearers_to_setup, long *priority ) { cellGroupConfig->cellGroupId = 0; cellGroupConfig->rlc_BearerToReleaseList = NULL; @@ -2169,6 +2169,7 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr // RLC Bearer Config // TS38.331 9.2.1 Default SRB configurations + if (configure_srb){ NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; NR_RLC_Config_t *rlc_Config = NULL; NR_LogicalChannelConfig_t *logicalChannelConfig = NULL; @@ -2208,40 +2209,41 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); - + } // DRB Configuration - NR_RLC_BearerConfig_t *rlc_BearerConfig_drb = NULL; - NR_RLC_Config_t *rlc_Config_drb = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig_drb = NULL; - long *logicalChannelGroup_drb = NULL; - rlc_BearerConfig_drb = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig_drb->logicalChannelIdentity = 4; - rlc_BearerConfig_drb->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig_drb->servedRadioBearer)); - rlc_BearerConfig_drb->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; - rlc_BearerConfig_drb->servedRadioBearer->choice.drb_Identity = 1; - rlc_BearerConfig_drb->reestablishRLC = NULL; - rlc_Config_drb = calloc(1, sizeof(NR_RLC_Config_t)); + for (int i = bearer_id_start; i < bearer_id_start + nb_bearers_to_setup; i++ ){ + NR_RLC_BearerConfig_t *rlc_BearerConfig_drb = NULL; + NR_RLC_Config_t *rlc_Config_drb = NULL; + NR_LogicalChannelConfig_t *logicalChannelConfig_drb = NULL; + long *logicalChannelGroup_drb = NULL; + rlc_BearerConfig_drb = calloc(1, sizeof(NR_RLC_BearerConfig_t)); + rlc_BearerConfig_drb->logicalChannelIdentity = 3 + i ; + rlc_BearerConfig_drb->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig_drb->servedRadioBearer)); + rlc_BearerConfig_drb->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; + rlc_BearerConfig_drb->servedRadioBearer->choice.drb_Identity = i; + rlc_BearerConfig_drb->reestablishRLC = NULL; + rlc_Config_drb = calloc(1, sizeof(NR_RLC_Config_t)); - if (use_rlc_um_for_drb) nr_drb_config(rlc_Config_drb, NR_RLC_Config_PR_um_Bi_Directional); - else nr_drb_config(rlc_Config_drb, NR_RLC_Config_PR_am); + if (use_rlc_um_for_drb) nr_drb_config(rlc_Config_drb, NR_RLC_Config_PR_um_Bi_Directional); + else nr_drb_config(rlc_Config_drb, NR_RLC_Config_PR_am); - - rlc_BearerConfig_drb->rlc_Config = rlc_Config_drb; - logicalChannelConfig_drb = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig_drb->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters)); - logicalChannelConfig_drb->ul_SpecificParameters->priority = 13; - logicalChannelConfig_drb->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; - logicalChannelConfig_drb->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; - logicalChannelGroup_drb = CALLOC(1, sizeof(long)); - *logicalChannelGroup_drb = 1; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup_drb; - logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - rlc_BearerConfig_drb->mac_LogicalChannelConfig = logicalChannelConfig_drb; - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); - ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); + rlc_BearerConfig_drb->rlc_Config = rlc_Config_drb; + logicalChannelConfig_drb = calloc(1, sizeof(NR_LogicalChannelConfig_t)); + logicalChannelConfig_drb->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters)); + logicalChannelConfig_drb->ul_SpecificParameters->priority = priority[i-bearer_id_start]; + logicalChannelConfig_drb->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; + logicalChannelConfig_drb->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; + logicalChannelGroup_drb = CALLOC(1, sizeof(long)); + *logicalChannelGroup_drb = 1; + logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup_drb; + logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID)); + *logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = 0; + logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_Mask = 0; + logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; + rlc_BearerConfig_drb->mac_LogicalChannelConfig = logicalChannelConfig_drb; + ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); + ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); + } } diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 3b4605ff91..e79f79493d 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -117,7 +117,13 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_UE_NR_Capability_t *uecap, const gNB_RrcConfigurationReq *configuration); -void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, int use_rlc_um_for_drb); +void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, + NR_CellGroupConfig_t *ue_context_mastercellGroup, + int use_rlc_um_for_drb, + uint8_t configure_srb, + uint8_t bearer_id_start, + uint8_t nb_bearers_to_setup, + long *priority); int16_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, uint8_t *const buffer, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 3d41787a2d..9536ca0c69 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -845,6 +845,9 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( int qos_flow_index = 0; int pdu_sessions_done = 0; int i; + uint8_t drb_id_to_setup_start = 1; + uint8_t nb_drb_to_setup = 0; + long drb_priority[1] = {13}; // For now, we assume only one drb per pdu sessions with a default preiority (will be dynamique in future) NR_CellGroupConfig_t *cellGroupConfig; uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); @@ -887,6 +890,8 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( DRB_config = CALLOC(1, sizeof(*DRB_config)); DRB_config->drb_Identity = i+1; + if (drb_id_to_setup_start == 1) drb_id_to_setup_start = DRB_config->drb_Identity; + nb_drb_to_setup++; DRB_config->cnAssociation = CALLOC(1, sizeof(*DRB_config->cnAssociation)); DRB_config->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config; // sdap_Config @@ -1000,8 +1005,8 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( memset(buffer, 0, sizeof(buffer)); cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup, - rrc->um_on_default_drb); + + fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup, rrc->um_on_default_drb, (drb_id_to_setup_start < 2) ? 1 : 0, drb_id_to_setup_start, nb_drb_to_setup, drb_priority); size = do_RRCReconfiguration(ctxt_pP, buffer, sizeof(buffer), xid, *SRB_configList2, @@ -3245,10 +3250,9 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha f1ap_ue_context_setup_t * resp=&F1AP_UE_CONTEXT_SETUP_RESP(message_p); uint32_t incoming_teid = 0; - - NR_CellGroupConfig_t *cellGroupConfig; - cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup,rrc->um_on_default_drb); + uint8_t drb_id_to_setup_start = 0; + uint8_t nb_drb_to_setup = 0; + long drb_priority[1] = {13}; // For now, we assume only one drb per pdu sessions with a default preiority (will be dynamique in future) /* Configure SRB2 */ NR_SRB_ToAddMod_t *SRB2_config = NULL; @@ -3277,6 +3281,7 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha ue_context_p->ue_context.DRB_configList = CALLOC(1, sizeof(*ue_context_p->ue_context.DRB_configList)); } DRB_configList = ue_context_p->ue_context.DRB_configList; + nb_drb_to_setup = req->drbs_to_be_setup_length; for (int i=0; idrbs_to_be_setup_length; i++){ DRB_config = CALLOC(1, sizeof(*DRB_config)); DRB_config->drb_Identity = req->drbs_to_be_setup[i].drb_id; @@ -3286,6 +3291,7 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha memcpy(addr.buffer, &drb_p.up_ul_tnl[0].tl_address, sizeof(drb_p.up_ul_tnl[0].tl_address)); addr.length=sizeof(drb_p.up_ul_tnl[0].tl_address)*8; extern instance_t DUuniqInstance; + if (!drb_id_to_setup_start) drb_id_to_setup_start = drb_p.drb_id; incoming_teid=newGtpuCreateTunnel(DUuniqInstance, req->rnti, drb_p.drb_id, @@ -3297,6 +3303,10 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha } } + NR_CellGroupConfig_t *cellGroupConfig; + cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); + fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup, rrc->um_on_default_drb, SRB2_config ? 1 : 0, drb_id_to_setup_start, nb_drb_to_setup, drb_priority); + apply_macrlc_config(rrc, ue_context_p, &ctxt); /* Fill the UE context setup response ITTI message to send to F1AP */ resp->gNB_CU_ue_id = req->gNB_CU_ue_id; diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index c73c3d9649..96ec634433 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -905,7 +905,7 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( for (pdusession = 0; pdusession < ue_context_pP->ue_context.setup_pdu_sessions; pdusession++) { // if (xid == ue_context_pP->ue_context.pdusession[pdusession].xid) { if (ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_DONE) { - pdusession_setup_t * tmp=&NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession]; + pdusession_setup_t * tmp=&NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdu_sessions_done]; tmp->pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id; // tmp->pdusession_id = 1; tmp->nb_of_qos_flow = ue_context_pP->ue_context.pduSession[pdusession].param.nb_qos; diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 7b8ba308bf..9537f9e18a 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -462,7 +462,7 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer auto inst=&globGtp.instances[instance]; auto it=inst->ue2te_mapping.find(rnti); - if ( it != inst->ue2te_mapping.end() ) { + if ( it != inst->ue2te_mapping.end() && it->second.bearers.find(outgoing_bearer_id) != it->second.bearers.end()) { LOG_W(GTPU,"[%ld] Create a config for a already existing GTP tunnel (rnti %x)\n", instance, rnti); inst->ue2te_mapping.erase(it); } From a5d0615048d3b6ec26f6a8114b041493614dc8fd Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 19 May 2022 17:36:56 +0200 Subject: [PATCH 076/105] Harmonize SRB configuration in function --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 91 +++++++++++------------------ 1 file changed, 33 insertions(+), 58 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 900f5b8b1f..0de2deeed5 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -2161,26 +2161,19 @@ void fill_initial_SpCellConfig(int uid, } -void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, int use_rlc_um_for_drb, uint8_t configure_srb, uint8_t bearer_id_start, uint8_t nb_bearers_to_setup, long *priority ) { - - cellGroupConfig->cellGroupId = 0; - cellGroupConfig->rlc_BearerToReleaseList = NULL; - cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); - - // RLC Bearer Config - // TS38.331 9.2.1 Default SRB configurations - if (configure_srb){ - NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; - NR_RLC_Config_t *rlc_Config = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig = NULL; - long *logicalChannelGroup = NULL; +NR_RLC_BearerConfig_t *get_SRB_RLC_BearerConfig(long channelId, + long priority, + e_NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration bucketSizeDuration) +{ + NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig->logicalChannelIdentity = 2; + rlc_BearerConfig->logicalChannelIdentity = channelId; rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity; - rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 2; + rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = channelId; rlc_BearerConfig->reestablishRLC = NULL; - rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); + + NR_RLC_Config_t *rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); rlc_Config->present = NR_RLC_Config_PR_am; rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); @@ -2194,12 +2187,14 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; rlc_BearerConfig->rlc_Config = rlc_Config; - logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); + + NR_LogicalChannelConfig_t *logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); - logicalChannelConfig->ul_SpecificParameters->priority = 3; + logicalChannelConfig->ul_SpecificParameters->priority = priority; logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms5; - logicalChannelGroup = CALLOC(1, sizeof(long)); + logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = bucketSizeDuration; + + long *logicalChannelGroup = CALLOC(1, sizeof(long)); *logicalChannelGroup = 0; logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); @@ -2207,9 +2202,24 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); - ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); + + return rlc_BearerConfig; +} + +void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, int use_rlc_um_for_drb, uint8_t configure_srb, uint8_t bearer_id_start, uint8_t nb_bearers_to_setup, long *priority ) { + + cellGroupConfig->cellGroupId = 0; + cellGroupConfig->rlc_BearerToReleaseList = NULL; + cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + + // RLC Bearer Config + // TS38.331 9.2.1 Default SRB configurations + if (configure_srb){ + NR_RLC_BearerConfig_t *rlc_BearerConfig = get_SRB_RLC_BearerConfig(2, 3, NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms5); + ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); + ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); } + // DRB Configuration for (int i = bearer_id_start; i < bearer_id_start + nb_bearers_to_setup; i++ ){ NR_RLC_BearerConfig_t *rlc_BearerConfig_drb = NULL; @@ -2279,50 +2289,15 @@ void fill_initial_cellGroupConfig(int uid, NR_ServingCellConfig_t *servingcellconfigdedicated, const gNB_RrcConfigurationReq *configuration) { - NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; - NR_RLC_Config_t *rlc_Config = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig = NULL; NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = NULL; NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig = NULL; - long *logicalChannelGroup = NULL; cellGroupConfig->cellGroupId = 0; /* Rlc Bearer Config */ /* TS38.331 9.2.1 Default SRB configurations */ cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); - rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig->logicalChannelIdentity = 1; - rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); - rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity; - rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 1; - rlc_BearerConfig->reestablishRLC = NULL; - rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); - rlc_Config->present = NR_RLC_Config_PR_am; - rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); - rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; - rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; - rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; - rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; - rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; - rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; - rlc_BearerConfig->rlc_Config = rlc_Config; - logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); - logicalChannelConfig->ul_SpecificParameters->priority = 1; - logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - logicalChannelGroup = CALLOC(1, sizeof(long)); - *logicalChannelGroup = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; - logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; + NR_RLC_BearerConfig_t *rlc_BearerConfig = get_SRB_RLC_BearerConfig(1, 1, NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms1000); ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); cellGroupConfig->rlc_BearerToReleaseList = NULL; From 7bf5f018a1f9246af6ed39667cb261eb663b5642 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 19 May 2022 18:40:54 +0200 Subject: [PATCH 077/105] Refactor DRB configuration in function --- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 2 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 66 +++++++++++++------------ 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 0a8e03fc1e..7ba08aaa71 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -123,7 +123,7 @@ void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms15; break; default: - LOG_E (RLC, "Error in %s: RLC config type %d is not handled\n", __FUNCTION__, rlc_config_pr); + AssertFatal(0, "RLC config type %d not handled\n", rlc_config_pr); break; } diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 0de2deeed5..bc4c12222a 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -2206,6 +2206,37 @@ NR_RLC_BearerConfig_t *get_SRB_RLC_BearerConfig(long channelId, return rlc_BearerConfig; } +NR_RLC_BearerConfig_t *get_DRB_RLC_BearerConfig(long lcChannelId, long drbId, NR_RLC_Config_PR rlc_conf, long priority) +{ + NR_RLC_BearerConfig_t *rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); + rlc_BearerConfig->logicalChannelIdentity = lcChannelId; + rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); + rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; + rlc_BearerConfig->servedRadioBearer->choice.drb_Identity = drbId; + rlc_BearerConfig->reestablishRLC = NULL; + + NR_RLC_Config_t *rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); + nr_drb_config(rlc_Config, rlc_conf); + rlc_BearerConfig->rlc_Config = rlc_Config; + + NR_LogicalChannelConfig_t *logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); + logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); + logicalChannelConfig->ul_SpecificParameters->priority = priority; + logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; + logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; + + long *logicalChannelGroup = CALLOC(1, sizeof(long)); + *logicalChannelGroup = 1; + logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; + logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); + *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; + rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; + + return rlc_BearerConfig; +} + void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, int use_rlc_um_for_drb, uint8_t configure_srb, uint8_t bearer_id_start, uint8_t nb_bearers_to_setup, long *priority ) { cellGroupConfig->cellGroupId = 0; @@ -2222,37 +2253,10 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr // DRB Configuration for (int i = bearer_id_start; i < bearer_id_start + nb_bearers_to_setup; i++ ){ - NR_RLC_BearerConfig_t *rlc_BearerConfig_drb = NULL; - NR_RLC_Config_t *rlc_Config_drb = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig_drb = NULL; - long *logicalChannelGroup_drb = NULL; - rlc_BearerConfig_drb = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig_drb->logicalChannelIdentity = 3 + i ; - rlc_BearerConfig_drb->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig_drb->servedRadioBearer)); - rlc_BearerConfig_drb->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; - rlc_BearerConfig_drb->servedRadioBearer->choice.drb_Identity = i; - rlc_BearerConfig_drb->reestablishRLC = NULL; - rlc_Config_drb = calloc(1, sizeof(NR_RLC_Config_t)); - - if (use_rlc_um_for_drb) nr_drb_config(rlc_Config_drb, NR_RLC_Config_PR_um_Bi_Directional); - else nr_drb_config(rlc_Config_drb, NR_RLC_Config_PR_am); - - rlc_BearerConfig_drb->rlc_Config = rlc_Config_drb; - logicalChannelConfig_drb = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig_drb->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters)); - logicalChannelConfig_drb->ul_SpecificParameters->priority = priority[i-bearer_id_start]; - logicalChannelConfig_drb->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; - logicalChannelConfig_drb->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; - logicalChannelGroup_drb = CALLOC(1, sizeof(long)); - *logicalChannelGroup_drb = 1; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup_drb; - logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - rlc_BearerConfig_drb->mac_LogicalChannelConfig = logicalChannelConfig_drb; - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); - ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); + const NR_RLC_Config_PR rlc_conf = use_rlc_um_for_drb ? NR_RLC_Config_PR_um_Bi_Directional : NR_RLC_Config_PR_am; + NR_RLC_BearerConfig_t *rlc_BearerConfig = get_DRB_RLC_BearerConfig(3 + i, i, rlc_conf, priority[i-bearer_id_start]); + ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); + ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); } } From 00d021c66b85ec5510ceb2940d8705e22f23d17b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 23 May 2022 14:33:05 +0200 Subject: [PATCH 078/105] In TDD: enable slot 0 In the past, activation of slot 0 (i.e., after the switch UL->DL) resulted in many retransmissions. This does not seem to be the case anymore, and we can therefore activate slot 0 also in TDD. --- openair2/LAYER2/NR_MAC_gNB/config.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index d4cde4f3c3..f55130e4f4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -551,9 +551,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, AssertFatal(RC.nrmac[Mod_idP]->common_channels[0].frame_type == FDD,"Dynamic TDD not handled yet\n"); for (int slot = 0; slot < n; ++slot) { - if (RC.nrmac[Mod_idP]->common_channels[0].frame_type == FDD || - (slot != 0)) - RC.nrmac[Mod_idP]->dlsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) < nr_dl_slots) << (slot % 64); + RC.nrmac[Mod_idP]->dlsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) < nr_dl_slots) << (slot % 64); RC.nrmac[Mod_idP]->ulsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) >= nr_ulstart_slot) << (slot % 64); LOG_I(NR_MAC, "In %s: slot %d DL %d UL %d\n", From 9354d4305b14259983bf80c64af0f5b60efa5cd4 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 23 May 2022 14:34:32 +0200 Subject: [PATCH 079/105] Set k2=2 also in 5ms TDD periods In the past, setting k2=2 for 5ms TDD periods resulted in increased ping RTT and/or reestablishment requests. These problems do not appear anymore, and we can allow k2=2. --- openair2/RRC/NR/nr_rrc_config.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index ef95443a5d..039cb3dfd8 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -353,22 +353,7 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){ //TODO change to accomodate for SRS frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); - int temp_min_delay = 6; // k2 = 2 or 3 won'r work as well as higher values - if(frame_type==TDD && scc->tdd_UL_DL_ConfigurationCommon) { - - switch (scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity) { - case NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5: // 30kHz SCS - case NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2: // 60kHz SCS - case NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms1p25: // 60kHz SCS - case NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms1: // 120kHz SCS - case NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms0p625: // 120kHz SCS - case NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms0p5: // 120kHz SCS - temp_min_delay = 2; - break; - } - } - - int k2 = (min_fb_delayuplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; From 9f6b7dc6b9ca11a6eb8b842a5b723873ae2ae328 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 23 Mar 2022 16:15:21 +0100 Subject: [PATCH 080/105] Make USRP tune_offset configurable UHD documentation: "A tune request instructs the implementation how to tune the RF chain." This commit makes this configurable, from nr-softmodem, nr-uesoftmodem, lte-softmodem, and lte-uesoftmodem. --- executables/nr-ru.c | 9 ++++-- executables/nr-uesoftmodem.c | 1 + executables/softmodem-common.h | 4 +++ targets/ARCH/COMMON/common_lib.h | 1 + targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 34 ++++++++++++++------ targets/RT/USER/lte-ru.c | 7 ++-- targets/RT/USER/lte-uesoftmodem.c | 6 ++-- 7 files changed, 45 insertions(+), 17 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index fbe757ca30..e050c2776a 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1049,11 +1049,12 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->tx_gain[i] = ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx; cfg->configFilename = rf_config_file; - LOG_I(PHY, "Channel %d: setting tx_gain offset %f, rx_gain offset %f, tx_freq %lu Hz, rx_freq %lu Hz\n", + LOG_I(PHY, "Channel %d: setting tx_gain offset %f, rx_gain offset %f, tx_freq %.0f Hz, rx_freq %.0f Hz, tune_offset %.0f Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], - (unsigned long)cfg->tx_freq[i], - (unsigned long)cfg->rx_freq[i]); + cfg->tx_freq[i], + cfg->rx_freq[i], + cfg->tune_offset); } } @@ -2051,6 +2052,8 @@ static void NRRCconfig_RU(void) { RC.ru[j]->openair0_cfg.time_source = internal; } + RC.ru[j]->openair0_cfg.tune_offset = get_softmodem_params()->tune_offset; + if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { RC.ru[j]->if_south = LOCAL_RF; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index b1960faf7d..2347055402 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -354,6 +354,7 @@ void init_openair0(void) { openair0_cfg[card].num_rb_dl = frame_parms->N_RB_DL; openair0_cfg[card].clock_source = get_softmodem_params()->clock_source; openair0_cfg[card].time_source = get_softmodem_params()->timing_source; + openair0_cfg[card].tune_offset = get_softmodem_params()->tune_offset; openair0_cfg[card].tx_num_channels = min(4, frame_parms->nb_antennas_tx); openair0_cfg[card].rx_num_channels = min(4, frame_parms->nb_antennas_rx); diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index eb0c1a54f7..72a9491f27 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -60,6 +60,7 @@ extern "C" #define CONFIG_HLP_DMRSSYNC "tells RU to insert DMRS in subframe 1 slot 0" #define CONFIG_HLP_CLK "tells hardware to use a clock reference (0:internal, 1:external, 2:gpsdo)\n" #define CONFIG_HLP_TME "tells hardware to use a time reference (0:internal, 1:external, 2:gpsdo)\n" +#define CONFIG_HLP_TUNE_OFFSET "LO tuning offset to use in Hz\n" #define CONFIG_HLP_USIM "use XOR autentication algo in case of test usim mode\n" #define CONFIG_HLP_NOSNGLT "Disables single-thread mode in lte-softmodem\n" #define CONFIG_HLP_DLF "Set the downlink frequency for all component carriers\n" @@ -118,6 +119,7 @@ extern "C" #define EMULATE_RF softmodem_params.emulate_rf #define CLOCK_SOURCE softmodem_params.clock_source #define TIMING_SOURCE softmodem_params.timing_source +#define TUNE_OFFSET softmodem_params.tune_offset #define SEND_DMRSSYNC softmodem_params.send_dmrs_sync #define USIM_TEST softmodem_params.usim_test #define PRB_INTERPOLATION softmodem_params.prb_interpolation @@ -141,6 +143,7 @@ extern int usrp_tx_thread; {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&USIM_TEST, defintval:0, TYPE_UINT8, 0}, \ {"clock-source", CONFIG_HLP_CLK, 0, uptr:&CLOCK_SOURCE, defintval:0, TYPE_UINT, 0}, \ {"time-source", CONFIG_HLP_TME, 0, uptr:&TIMING_SOURCE, defintval:0, TYPE_UINT, 0}, \ + {"tune-offset", CONFIG_HLP_TUNE_OFFSET, 0, dblptr:&TUNE_OFFSET, defintval:0, TYPE_DOUBLE, 0}, \ {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&WAIT_FOR_SYNC, defintval:0, TYPE_INT, 0}, \ {"single-thread-enable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&SINGLE_THREAD_FLAG, defintval:0, TYPE_INT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, u64ptr:&(downlink_frequency[0][0]), defuintval:0, TYPE_UINT64, 0}, \ @@ -245,6 +248,7 @@ typedef struct { int band; uint32_t clock_source; uint32_t timing_source; + double tune_offset; int hw_timing_advance; uint32_t send_dmrs_sync; int prb_interpolation; diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 95e5e3ed03..78acc373ee 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -188,6 +188,7 @@ typedef struct { //! \brief Center frequency in Hz for TX. //! index: [0..rx_num_channels[ !!! see lte-ue.c:427 FIXME iterates over rx_num_channels double tx_freq[4]; + double tune_offset; //! \brief memory //! \brief Pointer to Calibration table for RX gains rx_gain_calib_table_t *rx_gain_calib_table; diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 731129b1d9..0896780bfd 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -746,8 +746,12 @@ static bool is_equal(double a, double b) { void *freq_thread(void *arg) { openair0_device *device=(openair0_device *)arg; usrp_state_t *s = (usrp_state_t *)device->priv; - s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]); - s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]); + uhd::tune_request_t tx_tune_req(device->openair0_cfg[0].tx_freq[0], + device->openair0_cfg[0].tune_offset); + uhd::tune_request_t rx_tune_req(device->openair0_cfg[0].rx_freq[0], + device->openair0_cfg[0].tune_offset); + s->usrp->set_tx_freq(tx_tune_req); + s->usrp->set_rx_freq(rx_tune_req); return NULL; } /*! \brief Set frequencies (TX/RX). Spawns a thread to handle the frequency change to not block the calling thread @@ -759,14 +763,18 @@ void *freq_thread(void *arg) { int trx_usrp_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dont_block) { usrp_state_t *s = (usrp_state_t *)device->priv; pthread_t f_thread; - printf("Setting USRP TX Freq %f, RX Freq %f\n",openair0_cfg[0].tx_freq[0],openair0_cfg[0].rx_freq[0]); + printf("Setting USRP TX Freq %f, RX Freq %f, tune_offset: %f, dont_block: %d\n", + openair0_cfg[0].tx_freq[0],openair0_cfg[0].rx_freq[0], + openair0_cfg[0].tune_offset, dont_block); // spawn a thread to handle the frequency change to not block the calling thread if (dont_block == 1) pthread_create(&f_thread,NULL,freq_thread,(void *)device); else { - s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]); - s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]); + uhd::tune_request_t tx_tune_req(openair0_cfg[0].tx_freq[0], openair0_cfg[0].tune_offset); + uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); + s->usrp->set_tx_freq(tx_tune_req); + s->usrp->set_rx_freq(rx_tune_req); } return(0); @@ -779,9 +787,11 @@ int trx_usrp_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, */ int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg) { usrp_state_t *s = (usrp_state_t *)device->priv; - uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0]); - rx_tune_req.rf_freq_policy = uhd::tune_request_t::POLICY_MANUAL; - rx_tune_req.rf_freq = openair0_cfg[0].rx_freq[0]; + uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); + printf("In openair0_set_rx_frequencies, freq: %f, tune offset: %f\n", + openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); + //rx_tune_req.rf_freq_policy = uhd::tune_request_t::POLICY_MANUAL; + //rx_tune_req.rf_freq = openair0_cfg[0].rx_freq[0]; s->usrp->set_rx_freq(rx_tune_req); return(0); } @@ -1276,7 +1286,9 @@ extern "C" { for(int i=0; i<((int) s->usrp->get_rx_num_channels()); i++) { if (iusrp->set_rx_rate(openair0_cfg[0].sample_rate,i+choffset); - s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[i],i+choffset); + uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[i], + openair0_cfg[0].tune_offset); + s->usrp->set_rx_freq(rx_tune_req, i+choffset); set_rx_gain_offset(&openair0_cfg[0],i,bw_gain_adjust); ::uhd::gain_range_t gain_range = s->usrp->get_rx_gain_range(i+choffset); // limit to maximum gain @@ -1302,7 +1314,9 @@ extern "C" { if (iusrp->set_tx_rate(openair0_cfg[0].sample_rate,i+choffset); - s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[i],i+choffset); + uhd::tune_request_t tx_tune_req(openair0_cfg[0].tx_freq[i], + openair0_cfg[0].tune_offset); + s->usrp->set_tx_freq(tx_tune_req, i+choffset); s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[i],i+choffset); LOG_I(HW,"USRP TX_GAIN:%3.2lf gain_range:%3.2lf tx_gain:%3.2lf\n", gain_range_tx.stop()-openair0_cfg[0].tx_gain[i], gain_range_tx.stop(), openair0_cfg[0].tx_gain[i]); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 571551cee9..4bef1e30cf 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1371,11 +1371,12 @@ void fill_rf_config(RU_t *ru, cfg->tx_gain[i] = (double)ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-(double)ru->att_rx; cfg->configFilename = rf_config_file; - LOG_I(PHY,"channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n", + LOG_I(PHY,"channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f, tune_offset %.0f Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], cfg->tx_freq[i], - cfg->rx_freq[i]); + cfg->rx_freq[i], + cfg->tune_offset); } } @@ -2972,6 +2973,8 @@ RU_t **RCconfig_RU(int nb_RU,int nb_L1_inst,PHY_VARS_eNB ***eNB,uint64_t *ru_mas ru[j]->openair0_cfg.time_source = unset; } + ru[j]->openair0_cfg.tune_offset = get_softmodem_params()->tune_offset; + LOG_I(PHY,"RU %d is_slave=%s\n",j,*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr)); if (strcmp(*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr), "yes") == 0) ru[j]->is_slave=1; diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 089941c7df..946ee76cc8 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -446,6 +446,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { openair0_cfg[card].num_rb_dl=frame_parms->N_RB_DL; openair0_cfg[card].clock_source = get_softmodem_params()->clock_source; openair0_cfg[card].time_source = get_softmodem_params()->timing_source; + openair0_cfg[card].tune_offset = get_softmodem_params()->tune_offset; openair0_cfg[card].tx_num_channels=min(2,frame_parms->nb_antennas_tx); openair0_cfg[card].rx_num_channels=min(2,frame_parms->nb_antennas_rx); @@ -464,11 +465,12 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; openair0_cfg[card].rx_gain[i] = rxgain - rx_gain_off; openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file; - printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", + printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f, tune_offset %.0f\n", card,i, openair0_cfg[card].tx_gain[i], openair0_cfg[card].rx_gain[i], openair0_cfg[card].tx_freq[i], - openair0_cfg[card].rx_freq[i]); + openair0_cfg[card].rx_freq[i], + openair0_cfg[card].tune_offset); } if (usrp_args) openair0_cfg[card].sdr_addrs = usrp_args; From e1b090cfaae2dae20cca521da00aac5cdb25a3b8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 23 Mar 2022 19:28:42 +0100 Subject: [PATCH 081/105] Improve logging --- executables/nr-ru.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c | 7 ++++--- targets/RT/USER/lte-ru.c | 2 +- targets/RT/USER/lte-uesoftmodem.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index e050c2776a..126e72e76d 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1049,7 +1049,7 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->tx_gain[i] = ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx; cfg->configFilename = rf_config_file; - LOG_I(PHY, "Channel %d: setting tx_gain offset %f, rx_gain offset %f, tx_freq %.0f Hz, rx_freq %.0f Hz, tune_offset %.0f Hz\n", + LOG_I(PHY, "Channel %d: setting tx_gain offset %.0f, rx_gain offset %.0f, tx_freq %.0f Hz, rx_freq %.0f Hz, tune_offset %.0f Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], cfg->tx_freq[i], diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c index d3f362b90c..80b803779d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c @@ -67,7 +67,7 @@ void nr_rf_card_config_gain(openair0_config_t *openair0_cfg, openair0_cfg->autocal[i] = 1; if (i < openair0_cfg->rx_num_channels) { - LOG_I(PHY, "HW: Configuring channel %d (rf_chain %d): setting tx_gain %f, rx_gain %f\n", + LOG_I(PHY, "HW: Configuring channel %d (rf_chain %d): setting tx_gain %.0f, rx_gain %.0f\n", i, rf_chain, openair0_cfg->tx_gain[i], @@ -103,11 +103,12 @@ void nr_rf_card_config_freq(openair0_config_t *openair0_cfg, openair0_cfg->autocal[i] = 1; if (i < openair0_cfg->rx_num_channels) { - LOG_I(PHY, "HW: Configuring channel %d (rf_chain %d): setting tx_freq %f Hz, rx_freq %f Hz\n", + LOG_I(PHY, "HW: Configuring channel %d (rf_chain %d): setting tx_freq %.0f Hz, rx_freq %.0f Hz, tune_offset %.0f\n", i, rf_chain, openair0_cfg->tx_freq[i], - openair0_cfg->rx_freq[i]); + openair0_cfg->rx_freq[i], + openair0_cfg->tune_offset); } } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 4bef1e30cf..836709b473 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1371,7 +1371,7 @@ void fill_rf_config(RU_t *ru, cfg->tx_gain[i] = (double)ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-(double)ru->att_rx; cfg->configFilename = rf_config_file; - LOG_I(PHY,"channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f, tune_offset %.0f Hz\n", + LOG_I(PHY,"channel %d, Setting tx_gain offset %.0f, rx_gain offset %.0f, tx_freq %.0f, rx_freq %.0f, tune_offset %.0f Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], cfg->tx_freq[i], diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 946ee76cc8..678b6e0401 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -465,7 +465,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; openair0_cfg[card].rx_gain[i] = rxgain - rx_gain_off; openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file; - printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f, tune_offset %.0f\n", + printf("Card %d, channel %d, Setting tx_gain %.0f, rx_gain %.0f, tx_freq %.0f, rx_freq %.0f, tune_offset %.0f\n", card,i, openair0_cfg[card].tx_gain[i], openair0_cfg[card].rx_gain[i], openair0_cfg[card].tx_freq[i], From 276b2d5e0cf7689daeb0ab9ce60a9cf7f4184c9a Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 7 Apr 2022 16:48:05 +0200 Subject: [PATCH 082/105] removing calculate_preferred_dl_tda --- openair2/LAYER2/NR_MAC_gNB/config.c | 12 -- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 115 +++--------------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 3 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 6 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 3 - openair2/RRC/NR/nr_rrc_config.c | 5 +- 7 files changed, 23 insertions(+), 123 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index d4cde4f3c3..749318f682 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -591,21 +591,9 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if (CellGroup) { - if (get_softmodem_params()->sa) { - calculate_preferred_dl_tda(Mod_idP, NULL); - } - const NR_ServingCellConfig_t *servingCellConfig = NULL; if(CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; - if(bwpList) { - AssertFatal(bwpList->list.count > 0, "downlinkBWP_ToAddModList has no BWPs!\n"); - for (int i = 0; i < bwpList->list.count; ++i) { - const NR_BWP_Downlink_t *bwp = bwpList->list.array[i]; - calculate_preferred_dl_tda(Mod_idP, bwp); - } - } const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; if(ubwpList) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index e2291b9745..a70098aa2b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -53,105 +53,25 @@ #define WORD 32 //#define SIZE_OF_POINTER sizeof (void *) -void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp) { - gNB_MAC_INST *nrmac = RC.nrmac[module_id]; - const int bwp_id = bwp ? bwp->bwp_Id : 0; +const int set_dl_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int slot) { - if (nrmac->preferred_dl_tda[bwp_id]) - return; - - /* there is a mixed slot only when in TDD */ - NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; - frame_type_t frame_type = nrmac->common_channels->frame_type; const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const NR_TDD_UL_DL_Pattern_t *tdd = - scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; - int symb_dlMixed = 0; - int nr_mix_slots = 0; - int nr_slots_period = n; + scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; if (tdd) { - symb_dlMixed = (1 << tdd->nrofDownlinkSymbols) - 1; - nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; - nr_slots_period /= get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); - } else + int nr_mix_slots = tdd->nrofDownlinkSymbols != 0; // there are dl symbols in mixed slot + if (nr_mix_slots != 0) { // if there is a mixed slot + int nr_slots_period = n/get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); + if ((slot%nr_slots_period) == tdd->nrofDownlinkSlots) + return 1; + } + } + else // if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration AssertFatal(nrmac->common_channels->frame_type == FDD,"Dynamic TDD not handled yet\n"); - int target_ss; - - if (bwp) { - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - } else { - target_ss = NR_SearchSpace__searchSpaceType_PR_common; - } - - const NR_SIB1_t *sib1 = nrmac->common_channels[0].sib1 ? nrmac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_SearchSpace_t *search_space = get_searchspace(sib1, - scc, - bwp ? bwp->bwp_Dedicated : NULL, - target_ss); - - NR_ControlResourceSet_t *coreset = get_coreset(module_id, scc, bwp ? bwp->bwp_Dedicated : NULL, search_space, target_ss); - // get coreset symbol "map" - const uint16_t symb_coreset = (1 << coreset->duration) - 1; - - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = get_pdsch_TimeDomainAllocationList(bwp, - scc, - sib1); - AssertFatal(tdaList->list.count >= 1, "need to have at least one TDA for DL slots\n"); - - /* check that TDA index 0 fits into DL and does not overlap CORESET */ - const NR_PDSCH_TimeDomainResourceAllocation_t *tdaP_DL = tdaList->list.array[0]; - AssertFatal(!tdaP_DL->k0 || *tdaP_DL->k0 == 0, - "TimeDomainAllocation at index 1: non-null k0 (%ld) is not supported by the scheduler\n", - *tdaP_DL->k0); - int start, len; - SLIV2SL(tdaP_DL->startSymbolAndLength, &start, &len); - const uint16_t symb_tda = ((1 << len) - 1) << start; - // check whether coreset and TDA overlap: then we cannot use it. Note that - // here we assume that the coreset is scheduled every slot (which it - // currently is) and starting at symbol 0 - AssertFatal((symb_coreset & symb_tda) == 0, "TDA index 0 for DL overlaps with CORESET\n"); - /* check that TDA index 1 fits into DL part of mixed slot, if it exists */ - int tdaMi = -1; - - if (frame_type == TDD && tdaList->list.count > 1) { - const NR_PDSCH_TimeDomainResourceAllocation_t *tdaP_Mi = tdaList->list.array[1]; - AssertFatal(!tdaP_Mi->k0 || *tdaP_Mi->k0 == 0, - "TimeDomainAllocation at index 1: non-null k0 (%ld) is not supported by the scheduler\n", - *tdaP_Mi->k0); - int start, len; - SLIV2SL(tdaP_Mi->startSymbolAndLength, &start, &len); - const uint16_t symb_tda = ((1 << len) - 1) << start; - - // check whether coreset and TDA overlap: then, we cannot use it. Also, - // check whether TDA is entirely within mixed slot DL. Note that - // here we assume that the coreset is scheduled every slot (which it - // currently is) - if ((symb_coreset & symb_tda) == 0 && (symb_dlMixed & symb_tda) == symb_tda) { - tdaMi = 1; - } else { - LOG_E(MAC, - "TDA index 1 DL overlaps with CORESET or is not entirely in mixed slot (symb_coreset %x symb_dlMixed %x symb_tda %x), won't schedule DL mixed slot\n", - symb_coreset, - symb_dlMixed, - symb_tda); - } - } - - nrmac->preferred_dl_tda[bwp_id] = malloc(n * sizeof(*nrmac->preferred_dl_tda[bwp_id])); - - for (int i = 0; i < n; ++i) { - nrmac->preferred_dl_tda[bwp_id][i] = -1; - - if (frame_type == FDD || i % nr_slots_period < tdd->nrofDownlinkSlots) - nrmac->preferred_dl_tda[bwp_id][i] = 0; - else if (nr_mix_slots && i % nr_slots_period == tdd->nrofDownlinkSlots) - nrmac->preferred_dl_tda[bwp_id][i] = tdaMi; - - LOG_D(MAC, "slot %d preferred_dl_tda %d\n", i, nrmac->preferred_dl_tda[bwp_id][i]); - } + return 0; // if FDD or not mixed slot in TDD, for now use default TDA (TODO handle CSI-RS slots) } // Compute and write all MAC CEs and subheaders, and return number of written @@ -536,7 +456,7 @@ bool allocate_dl_retransmission(module_id_t module_id, int current_harq_pid) { gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; - const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; + NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; @@ -566,7 +486,7 @@ bool allocate_dl_retransmission(module_id_t module_id, int rbStart = 0; // start wrt BWPstart NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; int rbSize = 0; - const int tda = RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0][slot]; + const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); if (tda == retInfo->time_domain_allocation) { @@ -910,7 +830,7 @@ void pf_dl(module_id_t module_id, if (max_num_ue < 0) return; /* MCS has been set above */ - const int tda = RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0][slot]; + const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; @@ -982,12 +902,7 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t /* This is temporary and it assumes all UEs have the same BWP and TDA*/ int UE_id = UE_info->list.head; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - - if (!RC.nrmac[module_id]->preferred_dl_tda[bwp_id]) - return; - - const int tda = RC.nrmac[module_id]->preferred_dl_tda[bwp_id][slot]; + const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 33dd96d9bf..30ec546a0c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -275,7 +275,8 @@ void nr_preprocessor_phytest(module_id_t module_id, __func__, UE_id); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; + + const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = target_dl_Nl; if (ps->time_domain_allocation != tda || ps->nrOfLayers != target_dl_Nl) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 45327eda73..4e0c6dbc5e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2858,6 +2858,7 @@ void nr_csirs_scheduling(int Mod_idP, void nr_mac_update_timers(module_id_t module_id, frame_t frame, sub_frame_t slot) { + NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; const NR_list_t *UE_list = &UE_info->list; for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { @@ -2894,12 +2895,11 @@ void nr_mac_update_timers(module_id_t module_id, cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - int **preferred_dl_tda = RC.nrmac[module_id]->preferred_dl_tda; + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; const uint8_t layers = set_dl_nrOfLayers(sched_ctrl); - const int tda = bwp && preferred_dl_tda[bwp->bwp_Id][slot] >= 0 ? - preferred_dl_tda[bwp->bwp_Id][slot] : (ps->time_domain_allocation >= 0 ? ps->time_domain_allocation : 0); + const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); nr_set_pdsch_semi_static(sib1, scc, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 6d15641592..083a0c8ad9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -522,7 +522,7 @@ void set_dl_mcs(NR_sched_pdsch_t *sched_pdsch, uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl); int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl); -void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp); +const int set_dl_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int slot); void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ubwp); bool find_free_CCE(module_id_t module_id, sub_frame_t slot, int UE_id); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 9d8e28da97..dcbdf8f77c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -807,9 +807,6 @@ typedef struct gNB_MAC_INST_s { /// bitmap of DLSCH slots, can hold up to 160 slots uint64_t dlsch_slot_bitmap[3]; - /// Lookup for preferred time domain allocation for BWP, in DL, slots - /// dynamically allocated - int *preferred_dl_tda[MAX_NUM_BWP]; /// bitmap of ULSCH slots, can hold up to 160 slots uint64_t ulsch_slot_bitmap[3]; /// Lookup for preferred time domain allocation for UL BWP, dynamically diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index ef95443a5d..9bc575be9c 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -321,8 +321,7 @@ void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc, int len_coreset = 1; if (curr_bwp < 48) len_coreset = 2; - - // setting default TDA for DL with + // setting default TDA for DL with TDA index 0 struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); // k0: Slot offset between DCI and its scheduled PDSCH (see TS 38.214 clause 5.1.2.1) When the field is absent the UE applies the value 0. //timedomainresourceallocation->k0 = calloc(1,sizeof(*timedomainresourceallocation->k0)); @@ -331,10 +330,10 @@ void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc, timedomainresourceallocation->startSymbolAndLength = get_SLIV(len_coreset,14-len_coreset); // basic slot configuration starting in symbol 1 til the end of the slot ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation); if(frame_type==TDD) { - // TDD if(scc->tdd_UL_DL_ConfigurationCommon) { int dl_symb = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols; if(dl_symb > 1) { + // mixed slot TDA with TDA index 1 timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); // k0: Slot offset between DCI and its scheduled PDSCH (see TS 38.214 clause 5.1.2.1) When the field is absent the UE applies the value 0. //timedomainresourceallocation->k0 = calloc(1,sizeof(*timedomainresourceallocation->k0)); From d3f90a90fe1ba43a4a674691cfd0cbb7a61506f6 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 7 Apr 2022 18:20:24 +0200 Subject: [PATCH 083/105] removing calculate_preferred_ul_tda --- openair2/LAYER2/NR_MAC_gNB/config.c | 12 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 3 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 5 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 141 ++---------------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 - openair2/RRC/NR/nr_rrc_config.c | 46 +++--- 8 files changed, 44 insertions(+), 171 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 749318f682..599f95a72f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -592,19 +592,9 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if (CellGroup) { const NR_ServingCellConfig_t *servingCellConfig = NULL; - if(CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { + if(CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; - const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; - if(ubwpList) { - AssertFatal(ubwpList->list.count > 0, "uplinkBWP_ToAddModList no BWPs!\n"); - for (int i = 0; i < ubwpList->list.count; ++i) { - const NR_BWP_Uplink_t *ubwp = ubwpList->list.array[i]; - calculate_preferred_ul_tda(Mod_idP, ubwp); - } - } - } - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; if (add_ue == 1 && get_softmodem_params()->phy_test) { const int UE_id = add_new_nr_ue(Mod_idP, rnti, CellGroup); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index a70098aa2b..f4af5e4521 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -60,8 +60,7 @@ const int set_dl_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; if (tdd) { - int nr_mix_slots = tdd->nrofDownlinkSymbols != 0; // there are dl symbols in mixed slot - if (nr_mix_slots != 0) { // if there is a mixed slot + if (tdd->nrofDownlinkSymbols > 1) { // if there is a mixed slot where we can transmit DL int nr_slots_period = n/get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); if ((slot%nr_slots_period) == tdd->nrofDownlinkSlots) return 1; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 30ec546a0c..b7d4b04b72 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -436,7 +436,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = sched_ctrl->active_ubwp ? RC.nrmac[module_id]->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 1; + const int tda = set_ul_tda(nr_mac, scc, slot); if (tda < 0) return false; const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 4e0c6dbc5e..0c86f85ae2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2917,14 +2917,13 @@ void nr_mac_update_timers(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - int **preferred_ul_tda = RC.nrmac[module_id]->preferred_ul_tda; + NR_pusch_semi_static_t *ups = &sched_ctrl->pusch_semi_static; int dci_format = get_dci_format(sched_ctrl); const uint8_t num_dmrs_cdm_grps_no_data = (ubwp || ubwpd) ? 1 : 2; const uint8_t nrOfLayers = 1; - const int utda = ubwp && preferred_ul_tda[ubwp->bwp_Id][slot] >= 0 ? - preferred_ul_tda[ubwp->bwp_Id][slot] : (ups->time_domain_allocation >= 0 ? ups->time_domain_allocation : 0); + const int utda = set_ul_tda(RC.nrmac[module_id], scc, slot); nr_set_pusch_semi_static(sib1, scc, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 7a34527166..2da6fcb63d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -46,138 +46,25 @@ int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl) { return(dci_format); } -void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ubwp) -{ - gNB_MAC_INST *nrmac = RC.nrmac[module_id]; - const int bwp_id = ubwp->bwp_Id; - if (nrmac->preferred_ul_tda[bwp_id]) - return; +const int set_ul_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int slot) { /* there is a mixed slot only when in TDD */ - NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; - frame_type_t frame_type = nrmac->common_channels->frame_type; const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + const NR_TDD_UL_DL_Pattern_t *tdd = + scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; - NR_ServingCellConfigCommonSIB_t *scc_sib1 = nrmac->common_channels[0].sib1 ? - RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1->servingCellConfigCommon : NULL; - - AssertFatal(scc!=NULL || scc_sib1!=NULL,"We need one serving cell config common\n"); - - const int mu = scc ? scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing : - scc_sib1->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; - - NR_TDD_UL_DL_Pattern_t *tdd = NULL; - if (scc && scc->tdd_UL_DL_ConfigurationCommon) { - tdd = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; - } else if (scc_sib1 && scc_sib1->tdd_UL_DL_ConfigurationCommon) { - tdd = &scc_sib1->tdd_UL_DL_ConfigurationCommon->pattern1; - } - - /* Uplink symbols are at the end of the slot */ - int symb_ulMixed = 0; - int nr_mix_slots = 0; - int nr_slots_period = n; if (tdd) { - symb_ulMixed = ((1 << tdd->nrofUplinkSymbols) - 1) << (14 - tdd->nrofUplinkSymbols); - nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; - nr_slots_period /= get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); + if (tdd->nrofUplinkSymbols > 1) { // if there is uplink symbols in mixed slot + int nr_slots_period = n/get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); + if ((slot%nr_slots_period) == tdd->nrofUplinkSlots) + return 1; + } } else // if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration AssertFatal(nrmac->common_channels->frame_type == FDD,"Dynamic TDD not handled yet\n"); - const struct NR_PUCCH_Config__resourceToAddModList *resList = ubwp->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList; - // for the moment, just block any symbol that might hold a PUCCH, regardless - // of the RB. This is a big simplification, as most RBs will NOT have a PUCCH - // in the respective symbols, but it simplifies scheduling - uint16_t symb_pucch = 0; - for (int i = 0; i < resList->list.count; ++i) { - const NR_PUCCH_Resource_t *resource = resList->list.array[i]; - int nrofSymbols = 0; - int startingSymbolIndex = 0; - switch (resource->format.present) { - case NR_PUCCH_Resource__format_PR_format0: - nrofSymbols = resource->format.choice.format0->nrofSymbols; - startingSymbolIndex = resource->format.choice.format0->startingSymbolIndex; - break; - case NR_PUCCH_Resource__format_PR_format1: - nrofSymbols = resource->format.choice.format1->nrofSymbols; - startingSymbolIndex = resource->format.choice.format1->startingSymbolIndex; - break; - case NR_PUCCH_Resource__format_PR_format2: - nrofSymbols = resource->format.choice.format2->nrofSymbols; - startingSymbolIndex = resource->format.choice.format2->startingSymbolIndex; - break; - case NR_PUCCH_Resource__format_PR_format3: - nrofSymbols = resource->format.choice.format3->nrofSymbols; - startingSymbolIndex = resource->format.choice.format3->startingSymbolIndex; - break; - case NR_PUCCH_Resource__format_PR_format4: - nrofSymbols = resource->format.choice.format4->nrofSymbols; - startingSymbolIndex = resource->format.choice.format4->startingSymbolIndex; - break; - default: - AssertFatal(0, "found NR_PUCCH format index %d\n", resource->format.present); - break; - } - symb_pucch |= ((1 << nrofSymbols) - 1) << startingSymbolIndex; - } - - /* check that TDA index 1 fits into UL slot and does not overlap with PUCCH */ - const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - const NR_PUSCH_TimeDomainResourceAllocation_t *tdaP_UL = tdaList->list.array[0]; - const int k2 = get_K2(scc, scc_sib1, (NR_BWP_Uplink_t*)ubwp,0, mu); - int start, len; - SLIV2SL(tdaP_UL->startSymbolAndLength, &start, &len); - const uint16_t symb_tda = ((1 << len) - 1) << start; - // check whether PUCCH and TDA overlap: then, we cannot use it. Note that - // here we assume that the PUCCH is scheduled in every slot, and on all RBs - // (which is mostly not true, this is a simplification) - AssertFatal((symb_pucch & symb_tda) == 0, "TDA index 0 for UL overlaps with PUCCH\n"); - - // get largest time domain allocation (TDA) for UL slot and UL in mixed slot - int tdaMi = -1; - if (nr_mix_slots>0) { - const NR_PUSCH_TimeDomainResourceAllocation_t *tdaP_Mi = tdaList->list.array[1]; - AssertFatal(k2 == get_K2(scc, scc_sib1, (NR_BWP_Uplink_t*)ubwp, 1, mu), - "scheduler cannot handle different k2 for UL slot (%d) and UL Mixed slot (%ld)\n", - k2, - get_K2(scc, scc_sib1, (NR_BWP_Uplink_t*)ubwp, 1, mu)); - SLIV2SL(tdaP_Mi->startSymbolAndLength, &start, &len); - const uint16_t symb_tda_mi = ((1 << len) - 1) << start; - // check whether PUCCH and TDA overlap: then, we cannot use it. Also, check - // whether TDA is entirely within mixed slot, UL. Note that here we assume - // that the PUCCH is scheduled in every slot, and on all RBs (which is - // mostly not true, this is a simplification) - if ((symb_pucch & symb_tda_mi) == 0 && (symb_ulMixed & symb_tda_mi) == symb_tda_mi) { - tdaMi = 1; - } else { - LOG_E(NR_MAC, - "TDA index 1 UL overlaps with PUCCH or is not entirely in mixed slot (symb_pucch %x symb_ulMixed %x symb_tda_mi %x), won't schedule UL mixed slot\n", - symb_pucch, - symb_ulMixed, - symb_tda_mi); - } - } - - nrmac->preferred_ul_tda[bwp_id] = malloc(n * sizeof(*nrmac->preferred_ul_tda[bwp_id])); - - for (int slot = 0; slot < n; ++slot) { - const int sched_slot = (slot + k2) % n; - nrmac->preferred_ul_tda[bwp_id][slot] = -1; - if (frame_type == FDD || sched_slot % nr_slots_period >= tdd->nrofDownlinkSlots + nr_mix_slots) - nrmac->preferred_ul_tda[bwp_id][slot] = 0; - else if (nr_mix_slots && sched_slot % nr_slots_period == tdd->nrofDownlinkSlots) - nrmac->preferred_ul_tda[bwp_id][slot] = tdaMi; - LOG_D(MAC, "DL slot %d UL slot %d preferred_ul_tda %d\n", slot, sched_slot, nrmac->preferred_ul_tda[bwp_id][slot]); - } - - if (tdd && k2 < tdd->nrofUplinkSlots) { - LOG_W(NR_MAC, - "k2 %d < tdd->nrofUplinkSlots %ld: not all UL slots can be scheduled\n", - k2, - tdd->nrofUplinkSlots); - } + return 0; // if FDD or not mixed slot in TDD, for now use default TDA (TODO handle CSI-RS slots) } // For both UL-SCH except: @@ -961,7 +848,7 @@ bool allocate_ul_retransmission(module_id_t module_id, { const int CC_id = 0; gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; - const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels[CC_id].ServingCellConfigCommon; + NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels[CC_id].ServingCellConfigCommon; NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; NR_sched_pusch_t *retInfo = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch; @@ -980,7 +867,7 @@ bool allocate_ul_retransmission(module_id_t module_id, const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2; - const int tda = sched_ctrl->active_ubwp ? RC.nrmac[module_id]->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; + const int tda = set_ul_tda(nr_mac, scc, slot); LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data, retInfo->tb_size); if (tda == retInfo->time_domain_allocation) { @@ -1249,7 +1136,7 @@ void pf_ul(module_id_t module_id, const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; int dci_format = get_dci_format(sched_ctrl); - const int tda = sched_ctrl->active_ubwp ? nrmac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; + const int tda = set_ul_tda(nrmac, scc, slot); if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->nrOfLayers != nrOfLayers @@ -1389,7 +1276,7 @@ void pf_ul(module_id_t module_id, const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; int dci_format = get_dci_format(sched_ctrl); - const int tda = sched_ctrl->active_ubwp ? nrmac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; + const int tda = set_ul_tda(nrmac, scc, slot); if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->nrOfLayers != nrOfLayers @@ -1482,7 +1369,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * schedule now (slot + k2 is not UL slot) */ int UE_id = UE_info->list.head; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = sched_ctrl->active_ubwp ? nr_mac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; + const int tda = set_ul_tda(nr_mac, scc, slot); if (tda < 0) return false; int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, tda, mu); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 083a0c8ad9..8fbaefdf4c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -523,7 +523,7 @@ uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl); int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl); const int set_dl_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int slot); -void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ubwp); +const int set_ul_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int slot); bool find_free_CCE(module_id_t module_id, sub_frame_t slot, int UE_id); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index dcbdf8f77c..9c3bd1b711 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -809,10 +809,6 @@ typedef struct gNB_MAC_INST_s { uint64_t dlsch_slot_bitmap[3]; /// bitmap of ULSCH slots, can hold up to 160 slots uint64_t ulsch_slot_bitmap[3]; - /// Lookup for preferred time domain allocation for UL BWP, dynamically - /// allocated. The index refers to the DL slot, and the indicated TDA's k2 - /// points to the right UL slot - int *preferred_ul_tda[MAX_NUM_BWP]; /// maximum number of slots before a UE will be scheduled ULSCH automatically uint32_t ulsch_max_frame_inactivity; diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 9bc575be9c..843e6e7834 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -372,38 +372,40 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){ uint8_t DELTA[4]= {2,3,4,6}; // Delta parameter for Msg3 int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + // UL TDA index 0 is basic slot configuration starting in symbol 0 til the last but one symbol struct NR_PUSCH_TimeDomainResourceAllocation *pusch_timedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); pusch_timedomainresourceallocation->k2 = CALLOC(1,sizeof(long)); *pusch_timedomainresourceallocation->k2 = k2; pusch_timedomainresourceallocation->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(0,13); // basic slot configuration starting in symbol 0 til the last but one symbol + pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(0,13); ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation); if(frame_type==TDD) { - - // TDD if(scc->tdd_UL_DL_ConfigurationCommon) { int ul_symb = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; - pusch_timedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); - pusch_timedomainresourceallocation->k2 = CALLOC(1,sizeof(long)); - *pusch_timedomainresourceallocation->k2 = k2; - pusch_timedomainresourceallocation->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one - ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation); + if (ul_symb>1) { + // UL TDA index 1 for mixed slot (TDD) + pusch_timedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); + pusch_timedomainresourceallocation->k2 = CALLOC(1,sizeof(long)); + *pusch_timedomainresourceallocation->k2 = k2; + pusch_timedomainresourceallocation->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; + pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one + ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation); - // for msg3 in the mixed slot - int nb_periods_per_frame = get_nb_periods_per_frame(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - int nb_slots_per_period = ((1<k2 = CALLOC(1,sizeof(long)); - *pusch_timedomainresourceallocation_msg3->k2 = nb_slots_per_period - DELTA[mu]; - if(*pusch_timedomainresourceallocation_msg3->k2 < min_fb_delay) - *pusch_timedomainresourceallocation_msg3->k2 += nb_slots_per_period; - AssertFatal(*pusch_timedomainresourceallocation_msg3->k2<33,"Computed k2 for msg3 %ld is larger than the range allowed by RRC (0..32)\n", - *pusch_timedomainresourceallocation_msg3->k2); - pusch_timedomainresourceallocation_msg3->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - pusch_timedomainresourceallocation_msg3->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one - ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation_msg3); + // UL TDA index 2 for msg3 in the mixed slot (TDD) + int nb_periods_per_frame = get_nb_periods_per_frame(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); + int nb_slots_per_period = ((1<k2 = CALLOC(1,sizeof(long)); + *pusch_timedomainresourceallocation_msg3->k2 = nb_slots_per_period - DELTA[mu]; + if(*pusch_timedomainresourceallocation_msg3->k2 < min_fb_delay) + *pusch_timedomainresourceallocation_msg3->k2 += nb_slots_per_period; + AssertFatal(*pusch_timedomainresourceallocation_msg3->k2<33,"Computed k2 for msg3 %ld is larger than the range allowed by RRC (0..32)\n", + *pusch_timedomainresourceallocation_msg3->k2); + pusch_timedomainresourceallocation_msg3->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; + pusch_timedomainresourceallocation_msg3->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one + ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation_msg3); + } } } } From c6498ccf581df9c97e3612662f5d837de0c2bb8d Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 14 Apr 2022 09:01:31 +0200 Subject: [PATCH 084/105] addressing review --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 13 ++++++------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 4 ++-- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 4 ++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 18 ++++++++---------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 4 ++-- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index f4af5e4521..3803c240ac 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -53,15 +53,14 @@ #define WORD 32 //#define SIZE_OF_POINTER sizeof (void *) -const int set_dl_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int slot) { +const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot) { - const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; if (tdd) { if (tdd->nrofDownlinkSymbols > 1) { // if there is a mixed slot where we can transmit DL - int nr_slots_period = n/get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; if ((slot%nr_slots_period) == tdd->nrofDownlinkSlots) return 1; } @@ -455,7 +454,7 @@ bool allocate_dl_retransmission(module_id_t module_id, int current_harq_pid) { gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; - NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; + const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; @@ -485,7 +484,7 @@ bool allocate_dl_retransmission(module_id_t module_id, int rbStart = 0; // start wrt BWPstart NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; int rbSize = 0; - const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); if (tda == retInfo->time_domain_allocation) { @@ -829,7 +828,7 @@ void pf_dl(module_id_t module_id, if (max_num_ue < 0) return; /* MCS has been set above */ - const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; @@ -901,7 +900,7 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t /* This is temporary and it assumes all UEs have the same BWP and TDA*/ int UE_id = UE_info->list.head; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index b7d4b04b72..47775aaf05 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -276,7 +276,7 @@ void nr_preprocessor_phytest(module_id_t module_id, UE_id); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = target_dl_Nl; if (ps->time_domain_allocation != tda || ps->nrOfLayers != target_dl_Nl) @@ -436,7 +436,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = set_ul_tda(nr_mac, scc, slot); + const int tda = get_ul_tda(nr_mac, scc, slot); if (tda < 0) return false; const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 0c86f85ae2..09719880b8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2899,7 +2899,7 @@ void nr_mac_update_timers(module_id_t module_id, NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; const uint8_t layers = set_dl_nrOfLayers(sched_ctrl); - const int tda = set_dl_tda(RC.nrmac[module_id], scc, slot); + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); nr_set_pdsch_semi_static(sib1, scc, @@ -2923,7 +2923,7 @@ void nr_mac_update_timers(module_id_t module_id, int dci_format = get_dci_format(sched_ctrl); const uint8_t num_dmrs_cdm_grps_no_data = (ubwp || ubwpd) ? 1 : 2; const uint8_t nrOfLayers = 1; - const int utda = set_ul_tda(RC.nrmac[module_id], scc, slot); + const int utda = get_ul_tda(RC.nrmac[module_id], scc, slot); nr_set_pusch_semi_static(sib1, scc, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 2da6fcb63d..975c056e49 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -46,16 +46,14 @@ int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl) { return(dci_format); } -const int set_ul_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int slot) { +const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot) { /* there is a mixed slot only when in TDD */ - const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - const NR_TDD_UL_DL_Pattern_t *tdd = - scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; if (tdd) { if (tdd->nrofUplinkSymbols > 1) { // if there is uplink symbols in mixed slot - int nr_slots_period = n/get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; if ((slot%nr_slots_period) == tdd->nrofUplinkSlots) return 1; } @@ -848,7 +846,7 @@ bool allocate_ul_retransmission(module_id_t module_id, { const int CC_id = 0; gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; - NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels[CC_id].ServingCellConfigCommon; + const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels[CC_id].ServingCellConfigCommon; NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; NR_sched_pusch_t *retInfo = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch; @@ -867,7 +865,7 @@ bool allocate_ul_retransmission(module_id_t module_id, const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2; - const int tda = set_ul_tda(nr_mac, scc, slot); + const int tda = get_ul_tda(nr_mac, scc, slot); LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data, retInfo->tb_size); if (tda == retInfo->time_domain_allocation) { @@ -1136,7 +1134,7 @@ void pf_ul(module_id_t module_id, const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; int dci_format = get_dci_format(sched_ctrl); - const int tda = set_ul_tda(nrmac, scc, slot); + const int tda = get_ul_tda(nrmac, scc, slot); if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->nrOfLayers != nrOfLayers @@ -1276,7 +1274,7 @@ void pf_ul(module_id_t module_id, const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; int dci_format = get_dci_format(sched_ctrl); - const int tda = set_ul_tda(nrmac, scc, slot); + const int tda = get_ul_tda(nrmac, scc, slot); if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->nrOfLayers != nrOfLayers @@ -1369,7 +1367,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * schedule now (slot + k2 is not UL slot) */ int UE_id = UE_info->list.head; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = set_ul_tda(nr_mac, scc, slot); + const int tda = get_ul_tda(nr_mac, scc, slot); if (tda < 0) return false; int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, tda, mu); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 8fbaefdf4c..84b5b47d9d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -522,8 +522,8 @@ void set_dl_mcs(NR_sched_pdsch_t *sched_pdsch, uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl); int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl); -const int set_dl_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int slot); -const int set_ul_tda(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, int slot); +const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); +const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); bool find_free_CCE(module_id_t module_id, sub_frame_t slot, int UE_id); From 25086576e513ea65835822199cbab79fb9ca2015 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 22 Apr 2022 19:16:17 +0200 Subject: [PATCH 085/105] simplyfying tda functions according to review --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 18 ++++++------------ .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 15 +++++---------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 3803c240ac..41bc61e009 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -55,20 +55,14 @@ const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot) { - const NR_TDD_UL_DL_Pattern_t *tdd = - scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + AssertFatal(tdd || nrmac->common_channels->frame_type == FDD, "Dynamic TDD not handled yet\n"); - if (tdd) { - if (tdd->nrofDownlinkSymbols > 1) { // if there is a mixed slot where we can transmit DL - const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; - if ((slot%nr_slots_period) == tdd->nrofDownlinkSlots) - return 1; - } + if (tdd && tdd->nrofDownlinkSymbols > 1) { // if there is a mixed slot where we can transmit DL + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; + if ((slot%nr_slots_period) == tdd->nrofDownlinkSlots) + return 1; } - else - // if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration - AssertFatal(nrmac->common_channels->frame_type == FDD,"Dynamic TDD not handled yet\n"); - return 0; // if FDD or not mixed slot in TDD, for now use default TDA (TODO handle CSI-RS slots) } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 975c056e49..92823afa9b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -50,18 +50,13 @@ const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon /* there is a mixed slot only when in TDD */ const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + AssertFatal(tdd || nrmac->common_channels->frame_type == FDD, "Dynamic TDD not handled yet\n"); - if (tdd) { - if (tdd->nrofUplinkSymbols > 1) { // if there is uplink symbols in mixed slot - const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; - if ((slot%nr_slots_period) == tdd->nrofUplinkSlots) - return 1; - } + if (tdd && tdd->nrofUplinkSymbols > 1) { // if there is uplink symbols in mixed slot + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; + if ((slot%nr_slots_period) == tdd->nrofUplinkSlots) + return 1; } - else - // if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration - AssertFatal(nrmac->common_channels->frame_type == FDD,"Dynamic TDD not handled yet\n"); - return 0; // if FDD or not mixed slot in TDD, for now use default TDA (TODO handle CSI-RS slots) } From fac44b15e800d4713a01eaed1ccf4450977ba172 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 25 Apr 2022 14:20:06 +0200 Subject: [PATCH 086/105] adding option for CSI slot --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 7 ++++++- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 3 +++ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 3 ++- openair2/RRC/NR/nr_rrc_config.c | 18 ++++++++++-------- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 41bc61e009..ecca72154b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -58,10 +58,15 @@ const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; AssertFatal(tdd || nrmac->common_channels->frame_type == FDD, "Dynamic TDD not handled yet\n"); + // Use special TDA in case of CSI-RS + const NR_UE_info_t *UE_info = &nrmac->UE_info; + if(UE_info->sched_csirs) + return 1; + if (tdd && tdd->nrofDownlinkSymbols > 1) { // if there is a mixed slot where we can transmit DL const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; if ((slot%nr_slots_period) == tdd->nrofDownlinkSlots) - return 1; + return 2; } return 0; // if FDD or not mixed slot in TDD, for now use default TDA (TODO handle CSI-RS slots) } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 09719880b8..ede77d06cd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2659,6 +2659,8 @@ void nr_csirs_scheduling(int Mod_idP, gNB_MAC_INST *gNB_mac = RC.nrmac[Mod_idP]; uint16_t *vrb_map = gNB_mac->common_channels[CC_id].vrb_map; + UE_info->sched_csirs = false; + for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; @@ -2691,6 +2693,7 @@ void nr_csirs_scheduling(int Mod_idP, if((frame*n_slots_frame+slot-offset)%period == 0) { LOG_D(NR_MAC,"Scheduling CSI-RS in frame %d slot %d\n",frame,slot); + UE_info->sched_csirs = true; nfapi_nr_dl_tti_request_pdu_t *dl_tti_csirs_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset((void*)dl_tti_csirs_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 9c3bd1b711..1521374f87 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -710,7 +710,8 @@ typedef struct { // UE selected beam index uint8_t UE_beam_index[MAX_MOBILES_PER_GNB]; bool Msg4_ACKed[MAX_MOBILES_PER_GNB]; - + /// Sched CSI-RS: scheduling decisions + bool sched_csirs; } NR_UE_info_t; typedef void (*nr_pp_impl_dl)(module_id_t mod_id, diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 843e6e7834..e0f72fc485 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -329,18 +329,20 @@ void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc, timedomainresourceallocation->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; timedomainresourceallocation->startSymbolAndLength = get_SLIV(len_coreset,14-len_coreset); // basic slot configuration starting in symbol 1 til the end of the slot ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation); + // setting TDA for CSI-RS symbol with index 1 + struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation1 = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + timedomainresourceallocation1->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; + timedomainresourceallocation1->startSymbolAndLength = get_SLIV(len_coreset,14-len_coreset-1); // 1 symbol CSI-RS + ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation1); if(frame_type==TDD) { if(scc->tdd_UL_DL_ConfigurationCommon) { int dl_symb = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols; if(dl_symb > 1) { - // mixed slot TDA with TDA index 1 - timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); - // k0: Slot offset between DCI and its scheduled PDSCH (see TS 38.214 clause 5.1.2.1) When the field is absent the UE applies the value 0. - //timedomainresourceallocation->k0 = calloc(1,sizeof(*timedomainresourceallocation->k0)); - //*timedomainresourceallocation->k0 = 0; - timedomainresourceallocation->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - timedomainresourceallocation->startSymbolAndLength = get_SLIV(len_coreset,dl_symb-len_coreset); // mixed slot configuration starting in symbol 1 til the end of the dl allocation - ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation); + // mixed slot TDA with TDA index 2 + struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation2 = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + timedomainresourceallocation2->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; + timedomainresourceallocation2->startSymbolAndLength = get_SLIV(len_coreset,dl_symb-len_coreset); // mixed slot configuration starting in symbol 1 til the end of the dl allocation + ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation2); } } } From 3a0bccde30f73def10a683d54c0fd92c99dd8c05 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 10 May 2022 14:47:23 +0200 Subject: [PATCH 087/105] fix for msg2 tda --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 9ac9f0d880..42cad7063e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1200,20 +1200,13 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t nr_fill_rar(module_idP, ra, RAR_pdu, pusch_pdu); } -void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra) -{ +void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra) { gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) { - //TODO time domain assignment for msg2 needs to be improved - uint8_t time_domain_assignment; - if(cc->frame_type == TDD) - time_domain_assignment = 1; - else - time_domain_assignment = 0; int mcsIndex = -1; // initialization value int rbStart = 0; int rbSize = 8; @@ -1253,6 +1246,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } // Calculate number of symbols + int time_domain_assignment = get_dl_tda(nr_mac, scc, slotP); int startSymbolIndex, nrOfSymbols; const int startSymbolAndLength = pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); From 3c753aec7150267f46a0d781cc710e1a1fbf3855 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 23 May 2022 18:41:10 +0200 Subject: [PATCH 088/105] fix in calling get_ul_tda --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 19 +++++++++++++------ .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 18 ++++++++++-------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 47775aaf05..8cca07a51a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -436,18 +436,25 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = get_ul_tda(nr_mac, scc, slot); - if (tda < 0) - return false; const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + const int temp_tda = get_ul_tda(nr_mac, scc, slot); + if (temp_tda < 0) + return false; + AssertFatal(temp_tda < tdaList->list.count, + "time domain assignment %d >= %d\n", + temp_tda, + tdaList->list.count); + int K2 = get_K2(scc,NULL,sched_ctrl->active_ubwp, temp_tda, mu); + const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); + const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; + const int tda = get_ul_tda(nr_mac, scc, sched_slot); + if (tda < 0) + return false; AssertFatal(tda < tdaList->list.count, "time domain assignment %d >= %d\n", tda, tdaList->list.count); - int K2 = get_K2(scc,NULL,sched_ctrl->active_ubwp, tda, mu); - const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); - const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; /* check if slot is UL, and that slot is 8 (assuming K2=6 because of UE * limitations). Note that if K2 or the TDD configuration is changed, below * conditions might exclude each other and never be true */ diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 92823afa9b..e22f84272f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -54,7 +54,7 @@ const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon if (tdd && tdd->nrofUplinkSymbols > 1) { // if there is uplink symbols in mixed slot const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; - if ((slot%nr_slots_period) == tdd->nrofUplinkSlots) + if ((slot%nr_slots_period) == tdd->nrofDownlinkSlots) return 1; } return 0; // if FDD or not mixed slot in TDD, for now use default TDA (TODO handle CSI-RS slots) @@ -860,7 +860,7 @@ bool allocate_ul_retransmission(module_id_t module_id, const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2; - const int tda = get_ul_tda(nr_mac, scc, slot); + const int tda = get_ul_tda(nr_mac, scc, retInfo->slot); LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data, retInfo->tb_size); if (tda == retInfo->time_domain_allocation) { @@ -1129,7 +1129,7 @@ void pf_ul(module_id_t module_id, const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; int dci_format = get_dci_format(sched_ctrl); - const int tda = get_ul_tda(nrmac, scc, slot); + const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->nrOfLayers != nrOfLayers @@ -1269,7 +1269,7 @@ void pf_ul(module_id_t module_id, const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; int dci_format = get_dci_format(sched_ctrl); - const int tda = get_ul_tda(nrmac, scc, slot); + const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda || ps->dci_format != dci_format || ps->nrOfLayers != nrOfLayers @@ -1362,12 +1362,14 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * schedule now (slot + k2 is not UL slot) */ int UE_id = UE_info->list.head; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = get_ul_tda(nr_mac, scc, slot); - if (tda < 0) - return false; - int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, tda, mu); + const int temp_tda = get_ul_tda(nr_mac, scc, slot); + int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; + const int tda = get_ul_tda(nr_mac, scc, sched_slot); + if (tda < 0) + return false; + DevAssert(K2 == get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, tda, mu)); if (!is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot)) return false; From 38f7d772e64479276f50175e7f9235a40b436d1a Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Tue, 24 May 2022 10:55:50 +0200 Subject: [PATCH 089/105] small fix for USRP X410 --- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 731129b1d9..ba3bf0c4f3 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -644,6 +644,7 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp break; case USRP_X300_DEV: case USRP_N300_DEV: + case USRP_X400_DEV: rxshift=2; break; default: From 1450e2fb9fb70ef3d18c2fa8d6a49c47752fb35f Mon Sep 17 00:00:00 2001 From: laurent Date: Tue, 24 May 2022 13:29:05 +0200 Subject: [PATCH 090/105] issue 545 --- cmake_targets/build_oai | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 5cafb95cba..6e788c9676 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -713,11 +713,11 @@ function main() { # simlist="ldpctest" for f in $simlist ; do compilations \ - ran_build $f \ + $BUILD_DIR $f \ $f $dbin/$f.$REL done compilations \ - ran_build coding \ + $BUILD_DIR coding \ libcoding.so $dbin/libcoding.so fi @@ -729,7 +729,7 @@ function main() { simlist="secu_knas_encrypt_eia1 secu_kenb aes128_ctr_encrypt aes128_ctr_decrypt secu_knas_encrypt_eea2 secu_knas secu_knas_encrypt_eea1 kdf aes128_cmac_encrypt secu_knas_encrypt_eia2" for f in $simlist ; do compilations \ - ran_build test_$f \ + $BUILD_DIR test_$f \ test_$f $dbin/test_$f.$REL done fi From ab1df8bbc4a202752d8be138f3895af67d103d20 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Tue, 24 May 2022 13:45:35 +0100 Subject: [PATCH 091/105] Revert CSI configuration from update_cellGroupConfig to fill_initial_SpCellConfig --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 481 ++++++++++++++-------------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 1 - 2 files changed, 242 insertions(+), 240 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 647c42d399..c442108b67 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1011,193 +1011,6 @@ long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS) { return c_srs; } -void fill_default_csi_MeasConfig(int uid, - NR_SetupRelease_CSI_MeasConfig_t *setupRelease_csi_MeasConfig, - NR_ServingCellConfigCommon_t *scc, - const gNB_RrcConfigurationReq* configuration) { - - int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); - int dl_antenna_ports = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP; - - setupRelease_csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; - NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); - setupRelease_csi_MeasConfig->choice.setup = csi_MeasConfig; - - config_csirs(scc, csi_MeasConfig, uid, dl_antenna_ports, curr_bwp, configuration->do_CSIRS); - config_csiim(configuration->do_CSIRS, dl_antenna_ports, curr_bwp, csi_MeasConfig); - - csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); - csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; - - NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); - ssbresset0->csi_SSB_ResourceSetId=0; - - uint64_t bitmap=0; - switch (scc->ssb_PositionsInBurst->present) { - case 1 : - bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; - break; - case 2 : - bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; - break; - case 3 : - for (int i=0; i<8; i++) { - bitmap |= (((uint64_t) scc->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); - } - break; - default: - AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); - } - - NR_SSB_Index_t *ssbresset[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - ssbresset[i]=calloc(1,sizeof(*ssbresset[i])); - *ssbresset[i] = i; - ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset[i]); - } - } - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); - - csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); - - csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; - NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); - csires0->csi_ResourceConfigId=0; - csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; - csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); - csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList)); - NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0)); - *nzp0 = 0; - ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); - csires0->bwp_Id = 0; - csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); - - NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); - csires1->csi_ResourceConfigId=1; - csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; - csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); - csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); - NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); - *ssbres00 = 0; - ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); - csires1->bwp_Id = 0; - csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); - - if (dl_antenna_ports > 1) { - NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); - csires2->csi_ResourceConfigId=2; - csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList; - csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList)); - NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00)); - *csiim00 = 0; - ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); - csires2->bwp_Id=0; - csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2); - } - - NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); - pucchcsires1->uplinkBandwidthPartId=0; - pucchcsires1->pucch_Resource=1; - csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); - csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; - if (dl_antenna_ports > 1) { - LOG_I(NR_RRC,"Filling CSI Report Config for RI_PMI_CQI\n"); - NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); - csirep1->reportConfigId=0; - csirep1->carrier=NULL; - csirep1->resourcesForChannelMeasurement=0; - csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); - *csirep1->csi_IM_ResourcesForInterference=2; - csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; - csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); - csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9 + (20 * uid) % 320; - ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; - csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; - csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); - csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); - *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; - csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); - *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; - csirep1->reportFreqConfiguration->csi_ReportingBand = NULL; - /*calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand)); - csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1); - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254;*/ - csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_notConfigured; - csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_notConfigured; - csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig)); - csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1; - csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); - csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= - calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; - csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; - csirep1->dummy = NULL; - csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; - csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); - //csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); - //*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; - csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table)); - *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; - csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value2; - csirep1->non_PMI_PortIndication = NULL; - csirep1->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1); - } - - LOG_I(NR_RRC,"Filling CSI Report Config for CRI_RSRP\n"); - NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); - csirep2->reportConfigId=1; - csirep2->carrier=NULL; - csirep2->resourcesForChannelMeasurement=0; - csirep2->csi_IM_ResourcesForInterference=NULL; - csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; - csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); - csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; - ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; - csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; - csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); - csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL; - csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL; - csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; - csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; - csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; - csirep2->codebookConfig=NULL; - csirep2->dummy = NULL; - csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; - csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); - csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); - *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; - csirep2->cqi_Table = NULL; - csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; - csirep2->non_PMI_PortIndication = NULL; - csirep2->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); -} - void fill_default_downlinkBWP(NR_BWP_Downlink_t *bwp, int bwp_loop, NR_ServingCellConfig_t *servingcellconfigdedicated, @@ -1479,8 +1292,6 @@ void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); pucch_Config->resourceToReleaseList = NULL; - // configure one single PUCCH0 opportunity for initial connection procedure - // one symbol (13) int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); pucchres0->pucch_ResourceId=0; @@ -1517,37 +1328,71 @@ void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, pucchfmt2->pi2BPSK=NULL; pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; - pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); - NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); - pucchspatial->pucch_SpatialRelationInfoId = 1; - pucchspatial->servingCellId = NULL; - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; - pucchspatial->pucch_PathlossReferenceRS_Id = 0; - pucchspatial->p0_PUCCH_Id = 1; - pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; - ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); + + // PUCCH config - Scheduling request configuration pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); schedulingRequestResourceConfig->schedulingRequestResourceId = 1; schedulingRequestResourceConfig->schedulingRequestID = 0; schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; // 40 slot period + // note: make sure that there is no issue here. Later choose the RNTI accordingly. + // Here we would be limited to 3 UEs on this resource (1 1/2 Frames 30 kHz SCS, 5 ms TDD periodicity => slots 7,8,9). + // This should be a temporary resource until the first RRCReconfiguration gives new pucch resources. + // Check for above configuration and exit for now if it is not the case AssertFatal(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing==NR_SubcarrierSpacing_kHz30, "SCS != 30kHz\n"); + AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity==NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5, + "TDD period != 5ms : %ld\n",scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = 8; schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); *schedulingRequestResourceConfig->resource = 0; ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); + pucch_Config->schedulingRequestResourceToReleaseList=NULL; + + pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); long *delay[8]; for (int i=0;i<8;i++) { delay[i] = calloc(1,sizeof(*delay[i])); - AssertFatal(configuration->minRXTXTIME >= 2 && configuration->minRXTXTIME < 7, - "minRXTXTIME is %d but should be within [2,7)\n", configuration->minRXTXTIME); - *delay[i] = i + configuration->minRXTXTIME; + AssertFatal(configuration->minRXTXTIME >=2 && configuration->minRXTXTIME <7, "check minRXTXTIME %d\n",configuration->minRXTXTIME); + *delay[i] = i+configuration->minRXTXTIME; ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); } + pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); + NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); + pucchspatial->pucch_SpatialRelationInfoId = 1; + pucchspatial->servingCellId = NULL; + if(configuration->do_CSIRS) { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + pucchspatial->referenceSignal.choice.csi_RS_Index = 0; + } + else { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; + pucchspatial->referenceSignal.choice.ssb_Index = 0; + } + pucchspatial->pucch_PathlossReferenceRS_Id = 0; + pucchspatial->p0_PUCCH_Id = 1; + pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; + ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); + pucch_Config->spatialRelationInfoToReleaseList=NULL; + pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; + pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); + NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); + p00->p0_PUCCH_Id=1; + p00->p0_PUCCH_Value = 0; + ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); + pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; // PUSCH config ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); @@ -1790,8 +1635,14 @@ void fill_initial_SpCellConfig(int uid, NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); pucchspatial->pucch_SpatialRelationInfoId = 1; pucchspatial->servingCellId = NULL; - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; + if(configuration->do_CSIRS) { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + pucchspatial->referenceSignal.choice.csi_RS_Index = 0; + } + else { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; + pucchspatial->referenceSignal.choice.ssb_Index = 0; + } pucchspatial->pucch_PathlossReferenceRS_Id = 0; pucchspatial->p0_PUCCH_Id = 1; pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; @@ -2086,6 +1937,190 @@ void fill_initial_SpCellConfig(int uid, SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup; SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig; + if (configuration->do_CSIRS) { + + SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; + + NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig; + int pdsch_AntennaPorts = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP; + + config_csirs(scc, csi_MeasConfig, uid, pdsch_AntennaPorts, curr_bwp, configuration->do_CSIRS); + config_csiim(configuration->do_CSIRS, pdsch_AntennaPorts, curr_bwp, csi_MeasConfig); + + csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); + csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; + + NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); + ssbresset0->csi_SSB_ResourceSetId=0; + + uint64_t bitmap=0; + switch (scc->ssb_PositionsInBurst->present) { + case 1 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; + break; + case 2 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; + break; + case 3 : + for (int i=0; i<8; i++) { + bitmap |= (((uint64_t) scc->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); + } + break; + default: + AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); + } + + NR_SSB_Index_t *ssbresset[64]; + for (int i=0;i<64;i++) { + if ((bitmap>>(63-i))&0x01){ + ssbresset[i]=calloc(1,sizeof(*ssbresset[i])); + *ssbresset[i] = i; + ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset[i]); + } + } + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); + + csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); + + csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; + NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); + csires0->csi_ResourceConfigId=0; + csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; + csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); + csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList)); + NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0)); + *nzp0 = 0; + ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); + csires0->bwp_Id = 0; + csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); + + + NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); + csires1->csi_ResourceConfigId=1; + csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; + csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); + csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); + NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); + *ssbres00 = 0; + ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); + csires1->bwp_Id = 0; + csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); + + if (pdsch_AntennaPorts > 1) { + NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); + csires2->csi_ResourceConfigId=2; + csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList; + csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList)); + NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00)); + *csiim00 = 0; + ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); + csires2->bwp_Id=0; + csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2); + } + + NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); + pucchcsires1->uplinkBandwidthPartId=0; + pucchcsires1->pucch_Resource=1; + csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); + csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; + if (pdsch_AntennaPorts > 1) { + LOG_I(NR_RRC,"Filling CSI Report Config for RI_PMI_CQI\n"); + NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); + csirep1->reportConfigId=0; + csirep1->carrier=NULL; + csirep1->resourcesForChannelMeasurement=0; + csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); + *csirep1->csi_IM_ResourcesForInterference=2; + csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); + csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (7 + (20 * uid)) % 320; + ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; + csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; + csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); + csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); + *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; + csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); + *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; + csirep1->reportFreqConfiguration->csi_ReportingBand = NULL; + /*calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand)); + csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1); + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254;*/ + csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_notConfigured; + csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_notConfigured; + csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig)); + csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1; + csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); + csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= + calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; + csirep1->dummy = NULL; + csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); + //csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + //*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table)); + *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; + csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value2; + csirep1->non_PMI_PortIndication = NULL; + csirep1->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1); + } + + LOG_I(NR_RRC,"Filling CSI Report Config for CRI_RSRP\n"); + NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); + csirep2->reportConfigId=1; + csirep2->carrier=NULL; + csirep2->resourcesForChannelMeasurement=0; + csirep2->csi_IM_ResourcesForInterference=NULL; + csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); + csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (27 + (20 * uid)) % 320; + ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; + csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; + csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); + csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL; + csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL; + csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; + csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; + csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; + csirep2->codebookConfig=NULL; + csirep2->dummy = NULL; + csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); + csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep2->cqi_Table = NULL; + csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; + csirep2->non_PMI_PortIndication = NULL; + csirep2->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); + } pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; pdsch_servingcellconfig->xOverhead = NULL; pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH)); @@ -2223,7 +2258,6 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr } void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, - int uid, NR_UE_NR_Capability_t *uecap, const gNB_RrcConfigurationReq* configuration) { @@ -2232,38 +2266,8 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc = configuration ? configuration->scc : NULL; + // Set DL MCS table if(scc) { - - // Config CSI-RS - if (configuration->do_CSIRS) { - struct NR_PUCCH_Config__spatialRelationInfoToAddModList *spatialRelationInfoToAddModList = calloc(1,sizeof(*spatialRelationInfoToAddModList)); - NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); - pucchspatial->pucch_SpatialRelationInfoId = 1; - pucchspatial->servingCellId = NULL; - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - pucchspatial->referenceSignal.choice.csi_RS_Index = 0; - pucchspatial->pucch_PathlossReferenceRS_Id = 0; - pucchspatial->p0_PUCCH_Id = 1; - pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; - ASN_SEQUENCE_ADD(&spatialRelationInfoToAddModList->list,pucchspatial); - SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->spatialRelationInfoToAddModList = spatialRelationInfoToAddModList; - struct NR_UplinkConfig__uplinkBWP_ToAddModList *UL_BWP_list = SpCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList; - if (UL_BWP_list) { - for (int i=0; ilist.count; i++){ - NR_BWP_Uplink_t *ubwp = UL_BWP_list->list.array[i]; - if (ubwp->bwp_Dedicated->pucch_Config->choice.setup->spatialRelationInfoToAddModList) { - free(ubwp->bwp_Dedicated->pucch_Config->choice.setup->spatialRelationInfoToAddModList); - } - ubwp->bwp_Dedicated->pucch_Config->choice.setup->spatialRelationInfoToAddModList = spatialRelationInfoToAddModList; - } - } - if(!SpCellConfig->spCellConfigDedicated->csi_MeasConfig) { - SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); - } - fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig, scc, configuration); - } - - // Set DL MCS table NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP; set_dl_mcs_table(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing, configuration->force_256qam_off ? NULL : uecap, SpCellConfig, bwp_Dedicated, scc); @@ -2275,8 +2279,8 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, set_dl_mcs_table(scs, configuration->force_256qam_off ? NULL : uecap, SpCellConfig, bwp->bwp_Dedicated, scc); } } - } + } void fill_initial_cellGroupConfig(int uid, @@ -2755,7 +2759,6 @@ int16_t do_RRCReconfiguration( if(cellGroupConfig!=NULL){ update_cellGroupConfig(cellGroupConfig, - ue_context_pP->local_uid, ue_context_pP ? ue_context_pP->ue_context.UE_Capability_nr : NULL, configuration); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 6a85cf6cbb..3b4605ff91 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -114,7 +114,6 @@ void fill_initial_cellGroupConfig(int uid, const gNB_RrcConfigurationReq *configuration); void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, - int uid, NR_UE_NR_Capability_t *uecap, const gNB_RrcConfigurationReq *configuration); From 09ecb8a33cfdecddf55ac682d30446484f481562 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 24 May 2022 16:48:53 +0200 Subject: [PATCH 092/105] bugfix in fill_searchSpaceZero --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 9a0a4f5ae7..562d62f304 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3940,25 +3940,17 @@ void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *ty if(ss0->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 == NULL) ss0->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss0->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - uint32_t duration,periodicity,offset; - uint16_t symbols,max_agg; - AssertFatal(type0_PDCCH_CSS_config!=NULL,"No type0 CSS configuration\n"); - max_agg = (type0_PDCCH_CSS_config->num_symbols*type0_PDCCH_CSS_config->num_rbs)/6; - - symbols = (1-(1<num_symbols))<first_symbol_index; - duration = type0_PDCCH_CSS_config->search_space_duration; - periodicity = type0_PDCCH_CSS_config->search_space_frame_period; - if (type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1) - offset = type0_PDCCH_CSS_config->n_0; - else - offset = type0_PDCCH_CSS_config->n_c; + const uint32_t periodicity = type0_PDCCH_CSS_config->search_space_frame_period; + const uint32_t offset = type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1 + ? type0_PDCCH_CSS_config->n_0 : type0_PDCCH_CSS_config->n_c; ss0->searchSpaceId = 0; *ss0->controlResourceSetId = 0; ss0->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss0->monitoringSlotPeriodicityAndOffset)); set_monitoring_periodicity_offset(ss0,periodicity,offset); + const uint32_t duration = type0_PDCCH_CSS_config->search_space_duration; if (duration==1) ss0->duration = NULL; else{ @@ -3966,6 +3958,7 @@ void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *ty *ss0->duration = duration; } + const uint16_t symbols = SL_to_bitmap(type0_PDCCH_CSS_config->first_symbol_index, type0_PDCCH_CSS_config->num_symbols); ss0->monitoringSymbolsWithinSlot->size = 2; ss0->monitoringSymbolsWithinSlot->bits_unused = 2; ss0->monitoringSymbolsWithinSlot->buf[1] = 0; @@ -3975,6 +3968,7 @@ void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *ty ss0->monitoringSymbolsWithinSlot->buf[0] |= ((symbols>>i)&0x01)<<(7-i); } + const uint16_t max_agg = (type0_PDCCH_CSS_config->num_symbols*type0_PDCCH_CSS_config->num_rbs)/6; // max values are set according to TS38.213 Section 10.1 Table 10.1-1 ss0->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; ss0->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; From 9228f12d926755bc32e9c5bf12f4314440da9282 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 26 May 2022 13:47:17 +0200 Subject: [PATCH 093/105] bugfix --- openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c index 910d2272b7..1acf23197c 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c @@ -72,7 +72,7 @@ uint32_t nr_compute_tbs(uint16_t Qm, n = log2(Ninfo-24)-5; Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< Date: Tue, 10 May 2022 13:12:29 +0200 Subject: [PATCH 094/105] Remove UEid in the MAC After this commit, only the RNTI is used as an identifier in the MAC. Further, it removes some module_id, but a lot of them remain (the goal to remove all is still far from us) --- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 1 - openair1/SIMULATION/NR_PHY/dlsim.c | 17 +- openair2/F1AP/f1ap_du_ue_context_management.c | 9 +- openair2/LAYER2/NR_MAC_gNB/config.c | 43 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 7 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 58 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 232 +++++----- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 40 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 335 +++++++------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c | 27 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 289 ++++++------ .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 438 +++++++++--------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 24 +- openair2/LAYER2/NR_MAC_gNB/main.c | 84 ++-- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 35 +- openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 3 - openair2/RRC/NR/rrc_gNB.c | 7 +- openair2/RRC/NR/rrc_gNB_nsa.c | 3 +- openair2/UTIL/OPT/opt.h | 5 +- openair2/UTIL/OPT/probe.c | 8 + 22 files changed, 821 insertions(+), 848 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 8e97a8cbdc..548cc6dbd4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -310,7 +310,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, uint32_t A = rel15->TBSize[0]<<3; unsigned char *a=harq->pdu; if ( rel15->rnti != SI_RNTI) - trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, rel15->rnti, frame, slot,0, 0); + trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], WS_C_RNTI, rel15->rnti, frame, slot,0, 0); NR_gNB_SCH_STATS_t *stats=NULL; int first_free=-1; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 450805a26c..a07a19d085 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -171,7 +171,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, trace_NRpdu(DIRECTION_UPLINK, harq_process_ul_ue->a, harq_process_ul_ue->pusch_pdu.pusch_data.tb_size, - 0, WS_C_RNTI, rnti, frame, slot, 0, 0); + WS_C_RNTI, rnti, frame, slot, 0, 0); if (nr_ulsch_encoding(UE, ulsch_ue, frame_parms, harq_pid, G) == -1) return; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 99731c8cb1..6ee9a95b59 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -134,7 +134,6 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, trace_NRpdu(DIRECTION_DOWNLINK, dlsch0->harq_processes[dlsch0->current_harq_pid]->b, dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8, - pdu_type, WS_C_RNTI, dlsch0->rnti, proc->frame_rx, diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index d7503ce738..c804fc7173 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -270,9 +270,9 @@ int g_mcsIndex = -1, g_mcsTableIdx = 0, g_rbStart = -1, g_rbSize = -1, g_nrOfLay void nr_dlsim_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) { - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - AssertFatal(UE_info->num_UEs == 1, "can have only a single UE\n"); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[0]; + NR_UE_info_t *UE_info = RC.nrmac[module_id]->UE_info.list[0]; + AssertFatal(RC.nrmac[module_id]->UE_info.list[1]==NULL, "can have only a single UE\n"); + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; /* manually set free CCE to 0 */ @@ -282,14 +282,14 @@ void nr_dlsim_preprocessor(module_id_t module_id, find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, sched_ctrl->search_space,4); - sched_ctrl->coreset = get_coreset(module_id, scc, sched_ctrl->active_bwp->bwp_Dedicated, sched_ctrl->search_space, target_ss); + sched_ctrl->coreset = get_coreset(RC.nrmac[module_id], scc, sched_ctrl->active_bwp->bwp_Dedicated, sched_ctrl->search_space, target_ss); sched_ctrl->cce_index = 0; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; nr_set_pdsch_semi_static(NULL, scc, - UE_info->CellGroup[0], + UE_info->CellGroup, sched_ctrl->active_bwp, NULL, /* tda = */ 0, @@ -837,8 +837,7 @@ int main(int argc, char **argv) gNB_mac->pre_processor_dl = nr_dlsim_preprocessor; phy_init_nr_gNB(gNB,0,1); N_RB_DL = gNB->frame_parms.N_RB_DL; - NR_UE_info_t *UE_info = &RC.nrmac[0]->UE_info; - UE_info->num_UEs=1; + NR_UE_info_t *UE_info = RC.nrmac[0]->UE_info.list[0]; // stub to configure frame_parms // nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); @@ -1098,10 +1097,10 @@ int main(int argc, char **argv) clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot); - UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].ndi = !(trial&1); + UE_info->UE_sched_ctrl.harq_processes[harq_pid].ndi = !(trial&1); - UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].round = round; + UE_info->UE_sched_ctrl.harq_processes[harq_pid].round = round; for (int i=0; ipdcch_cand[i] = 0; diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 7b20bfb2aa..e19f077592 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -683,15 +683,15 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n", rnti, ctxt.rnti); int UE_out_of_sync = 0; - if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { - for (int n = 0; n < MAX_MOBILES_PER_GNB; ++n) { - if (RC.nrmac[instance]->UE_info.active[n] == TRUE - && rnti == RC.nrmac[instance]->UE_info.rnti[n]) { + UE_iterator(RC.nrmac[instance]->UE_info.list, UE) { + if (UE->rnti == rnti) { UE_out_of_sync = 0; break; } } + if (!UE) + LOG_E(F1AP,"Not found rnti: %x\n", rnti); } else { for (int n = 0; n < MAX_MOBILES_PER_ENB; ++n) { if (RC.mac[instance]->UE_info.active[n] == TRUE @@ -701,7 +701,6 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, } } } - /* We don't need the Cause */ /* Optional RRC Container: if present, send to UE */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index b524f6ab4e..0e55b519ab 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -455,18 +455,17 @@ int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, rnti_t rnti, NR_S if (rrc_reconfiguration_delay == 0) { return -1; } - const int UE_id = find_nr_UE_id(Mod_idP,rnti); - if (UE_id < 0) { + + NR_UE_info_t *UE_info = find_nr_UE(&RC.nrmac[Mod_idP]->UE_info,rnti); + if (!UE_info) { LOG_W(NR_MAC, "Could not find UE for RNTI 0x%04x\n", rnti); return -1; } - - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; const uint16_t sf_ahead = 6/(0x01<0); const uint16_t sl_ahead = sf_ahead * (0x01<rrc_processing_timer = (rrc_reconfiguration_delay<rnti, rrc_reconfiguration_delay); return 0; } @@ -593,11 +592,15 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if(CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; if (add_ue == 1 && get_softmodem_params()->phy_test) { - const int UE_id = add_new_nr_ue(Mod_idP, rnti, CellGroup); - LOG_I(NR_MAC,"Added new UE_id %d/%x with initial CellGroup\n",UE_id,rnti); - process_CellGroup(CellGroup,&UE_info->UE_sched_ctrl[UE_id]); + NR_UE_info_t* UE = add_new_nr_ue(RC.nrmac[Mod_idP], rnti, CellGroup); + if (UE) + LOG_I(NR_MAC,"Added new UE %x with initial CellGroup\n", rnti); + else { + LOG_E(NR_MAC,"Error adding UE %04x\n", rnti); + return -1; + } + process_CellGroup(CellGroup,&UE->UE_sched_ctrl); } else if (add_ue == 1 && !get_softmodem_params()->phy_test) { const int CC_id = 0; NR_COMMON_channels_t *cc = &RC.nrmac[Mod_idP]->common_channels[CC_id]; @@ -644,12 +647,18 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, LOG_I(NR_MAC,"Added new RA process for UE RNTI %04x with initial CellGroup\n", rnti); } else { // CellGroup has been updated NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels[0].ServingCellConfigCommon; - const int UE_id = find_nr_UE_id(Mod_idP,rnti); + NR_UE_info_t * UE = find_nr_UE(&RC.nrmac[Mod_idP]->UE_info,rnti); + if (!UE) { + LOG_E(NR_MAC, "Can't find UE %04x\n", rnti); + return -1; + } int target_ss; - UE_info->CellGroup[UE_id] = CellGroup; - LOG_I(NR_MAC,"Modified UE_id %d/%x with CellGroup\n",UE_id,rnti); - process_CellGroup(CellGroup,&UE_info->UE_sched_ctrl[UE_id]); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + + UE->CellGroup = CellGroup; + LOG_I(NR_MAC,"Modified rnti %04x with CellGroup\n",rnti); + process_CellGroup(CellGroup,&UE->UE_sched_ctrl); + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; if (get_softmodem_params()->sa) { // add all available DL HARQ processes for this UE in SA @@ -672,7 +681,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; } sched_ctrl->search_space = get_searchspace(sib1 ? sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL, scc, bwpd, target_ss); - sched_ctrl->coreset = get_coreset(Mod_idP, scc, bwpd, sched_ctrl->search_space, target_ss); + sched_ctrl->coreset = get_coreset(RC.nrmac[Mod_idP], scc, bwpd, sched_ctrl->search_space, target_ss); sched_ctrl->sched_pdcch = set_pdcch_structure(RC.nrmac[Mod_idP], sched_ctrl->search_space, sched_ctrl->coreset, @@ -685,7 +694,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup ) - compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info, UE_id, Mod_idP); + compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); } } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 9293739235..198e08610b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -218,7 +218,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram if ((1 << tmp) & deltaTSFC) { // This is an SRS subframe, loop over UEs - for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) { + UEs_iterator() { if (!RC.nrmac[module_idP]->UE_info.active[UE_id]) continue; ul_req = &RC.nrmac[module_idP]->UL_req[CC_id].ul_config_request_body; // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet @@ -372,7 +372,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, schedule_nr_prach(module_idP, f, s); } - // Schedule CSI-RS transmission nr_csirs_scheduling(module_idP, frame, slot, nr_slots_per_frame[*scc->ssbSubcarrierSpacing]); @@ -398,10 +397,10 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_schedule_ue_spec(module_idP, frame, slot); stop_meas(&gNB->schedule_dlsch); - nr_schedule_pucch(module_idP, frame, slot); + nr_schedule_pucch(RC.nrmac[module_idP], frame, slot); // This schedule SR after PUCCH for multiplexing - nr_sr_reporting(module_idP, frame, slot); + nr_sr_reporting(RC.nrmac[module_idP], frame, slot); stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 19db162d96..302685bfaf 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -539,8 +539,10 @@ void nr_initiate_ra_proc(module_id_t module_idP, for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { NR_RA_t *ra = &cc->ra[i]; pr_found = 0; - const int UE_id = find_nr_UE_id(module_idP, ra->rnti); - if (UE_id != -1) { + const NR_UE_info_t * UE = find_nr_UE(&nr_mac->UE_info, ra->rnti); + if (UE) { + // the UE is already registered + LOG_W(NR_MAC, "Received RA for existing RNTI %04x\n", ra->rnti); continue; } if (ra->state == RA_IDLE) { @@ -634,7 +636,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, AssertFatal(ra->ra_ss!=NULL,"SearchSpace cannot be null for RA\n"); - ra->coreset = get_coreset(module_idP, scc, bwp, ra->ra_ss, NR_SearchSpace__searchSpaceType_PR_common); + ra->coreset = get_coreset(nr_mac, scc, bwp, ra->ra_ss, NR_SearchSpace__searchSpaceType_PR_common); ra->sched_pdcch = set_pdcch_structure(nr_mac, ra->ra_ss, ra->coreset, @@ -669,7 +671,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->rnti = (taus() % 65518) + 1; loop++; } while (loop != 100 - && !((find_nr_UE_id(module_idP, ra->rnti) == -1) && (find_nr_RA_id(module_idP, CC_id, ra->rnti) == -1) + && !((find_nr_UE(&nr_mac->UE_info, ra->rnti) == NULL) && (find_nr_RA_id(module_idP, CC_id, ra->rnti) == -1) && ra->rnti >= 1 && ra->rnti <= 65519)); if (loop == 100) { LOG_E(NR_MAC, "%s:%d:%s: [RAPROC] initialisation random access aborted\n", __FILE__, __LINE__, __FUNCTION__); @@ -682,7 +684,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->beam_id = beam_index; LOG_I(NR_MAC, - "[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x SSB " + "[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x SSB, new rnti %04x " "index %u RA index %d\n", module_idP, CC_id, @@ -690,6 +692,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->Msg2_frame, ra->Msg2_slot, ra->RA_rnti, + ra->rnti, cc->ssb_index[beam_index], i); @@ -1517,7 +1520,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } ra->state = WAIT_Msg3; - LOG_D(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); + LOG_W(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: rnti %04x RA state %d\n", module_idP, frameP, slotP, ra->rnti, ra->state); } } @@ -1560,9 +1563,14 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra ra->rnti = ra->crnti; } - int UE_id = find_nr_UE_id(module_idP, ra->rnti); - NR_UE_info_t *UE_info = &nr_mac->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_info_t * UE = find_nr_UE(&nr_mac->UE_info, ra->rnti); + if (!UE) { + LOG_E(NR_MAC,"want to generate Msg4, but rnti %04x not in the table\n", ra->rnti); + return; + } + + LOG_I(NR_MAC,"Generate msg4, rnti: %04x\n", ra->rnti); + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_BWP_t *genericParameters = bwp ? & bwp->bwp_Common->genericParameters : &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; @@ -1595,7 +1603,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // Remove UE associated to TC-RNTI if(harq->round==0 && ra->msg3_dcch_dtch) { - mac_remove_nr_ue(module_idP, tc_rnti); + mac_remove_nr_ue(nr_mac, tc_rnti); } // get CCEindex, needed also for PUCCH and then later for PDCCH @@ -1626,7 +1634,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra LOG_D(NR_MAC,"[RAPROC] Msg4 r_pucch %d (CCEIndex %d, nb_of_candidates %d, delta_PRI %d)\n", r_pucch, CCEIndex, nr_of_candidates, delta_PRI); - int alloc = nr_acknack_scheduling(module_idP, UE_id, frameP, slotP, r_pucch, 1); + int alloc = nr_acknack_scheduling(module_idP, UE, frameP, slotP, r_pucch, 1); AssertFatal(alloc>=0,"Couldn't find a pucch allocation for ack nack (msg4)\n"); NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[alloc]; harq->feedback_slot = pucch->ul_slot; @@ -1942,10 +1950,9 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra if(ra->msg3_dcch_dtch) { // If the UE used MSG3 to transfer a DCCH or DTCH message, then contention resolution is successful upon transmission of PDCCH - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CBRA procedure succeeded!\n", UE_id, ra->rnti); + LOG_I(NR_MAC, "(ue rnti 0x%04x) CBRA procedure succeeded!\n", ra->rnti); nr_clear_ra_proc(module_idP, CC_id, frameP, ra); - UE_info->active[UE_id] = true; - UE_info->Msg4_ACKed[UE_id] = true; + UE->Msg4_ACKed = true; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); harq->feedback_slot = -1; @@ -1962,28 +1969,27 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t slot, NR_RA_t *ra) { - int UE_id = find_nr_UE_id(module_id, ra->rnti); + NR_UE_info_t * UE = find_nr_UE(&RC.nrmac[module_id]->UE_info, ra->rnti); const int current_harq_pid = ra->harq_pid; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; - NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; + NR_mac_stats_t *stats = &UE->mac_stats; - LOG_D(NR_MAC, "ue %d, rnti 0x%04x, harq is waiting %d, round %d, frame %d %d, harq id %d\n", UE_id, ra->rnti, harq->is_waiting, harq->round, frame, slot, current_harq_pid); + LOG_D(NR_MAC, "ue rnti 0x%04x, harq is waiting %d, round %d, frame %d %d, harq id %d\n", ra->rnti, harq->is_waiting, harq->round, frame, slot, current_harq_pid); if (harq->is_waiting == 0) { if (harq->round == 0) { + if (stats->dl.errors == 0) { - LOG_A(NR_MAC, "(ue %i, rnti 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", UE_id, ra->rnti); - UE_info->active[UE_id] = true; - UE_info->Msg4_ACKed[UE_id] = true; + LOG_A(NR_MAC, "(UE RNTI 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", ra->rnti); + UE->Msg4_ACKed = true; // Pause scheduling according to: // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs const NR_COMMON_channels_t *common_channels = &RC.nrmac[module_id]->common_channels[0]; const NR_SIB1_t *sib1 = common_channels->sib1 ? common_channels->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const NR_ServingCellConfig_t *servingCellConfig = UE_info->CellGroup[UE_id] ? UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated : NULL; + const NR_ServingCellConfig_t *servingCellConfig = UE->CellGroup ? UE->CellGroup->spCellConfig->spCellConfigDedicated : NULL; NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, common_channels->ServingCellConfigCommon, sib1); @@ -1991,9 +1997,9 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); - LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %d with %d ms\n", frame, slot, UE_id, delay_ms); + LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frame, slot, UE->rnti, delay_ms); } else { - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) RA Procedure failed at Msg4!\n", UE_id, ra->rnti); + LOG_I(NR_MAC, "(ue rnti 0x%04x) RA Procedure failed at Msg4!\n", ra->rnti); } nr_clear_ra_proc(module_id, CC_id, frame, ra); @@ -2001,7 +2007,7 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid); } } else { - LOG_D(NR_MAC, "(ue %i, rnti 0x%04x) Received Nack of RA-Msg4. Preparing retransmission!\n", UE_id, ra->rnti); + LOG_I(NR_MAC, "(UE %04x) Received Nack of RA-Msg4. Preparing retransmission!\n", ra->rnti); ra->Msg4_frame = (frame + 1) % 1024; ra->Msg4_slot = 1; ra->state = Msg4; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 4fc4eae1a2..2e983e0664 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -317,10 +317,9 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP, void nr_store_dlsch_buffer(module_id_t module_id, frame_t frame, sub_frame_t slot) { - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(RC.nrmac[module_id]->UE_info.list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; sched_ctrl->num_total_bytes = 0; sched_ctrl->dl_pdus_total = 0; @@ -328,13 +327,11 @@ void nr_store_dlsch_buffer(module_id_t module_id, // Note: DL_SCH_LCID_DCCH, DL_SCH_LCID_DCCH1, DL_SCH_LCID_DTCH for (int i = 0; i < sched_ctrl->dl_lc_num; ++i) { const int lcid = sched_ctrl->dl_lc_ids[i]; - const uint16_t rnti = UE_info->rnti[UE_id]; - LOG_D(NR_MAC, "In %s: UE %d/%x: LCID %d\n", __FUNCTION__, UE_id, rnti, lcid); - + const uint16_t rnti = UE->rnti; + LOG_D(NR_MAC, "In %s: UE %x: LCID %d\n", __FUNCTION__, rnti, lcid); if (lcid == DL_SCH_LCID_DTCH && sched_ctrl->rrc_processing_timer > 0) { continue; } - start_meas(&RC.nrmac[module_id]->rlc_status_ind); sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id, rnti, @@ -360,7 +357,7 @@ void nr_store_dlsch_buffer(module_id_t module_id, slot, lcid < 4 ? "DCCH":"DTCH", lcid, - UE_id, + UE->rnti, sched_ctrl->rlc_status[lcid].bytes_in_buffer, sched_ctrl->num_total_bytes, sched_ctrl->dl_pdus_total, @@ -374,15 +371,14 @@ bool allocate_dl_retransmission(module_id_t module_id, sub_frame_t slot, uint16_t *rballoc_mask, int *n_rb_sched, - int UE_id, + NR_UE_info_t * UE, int current_harq_pid) { gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; - NR_UE_info_t *UE_info = &nr_mac->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_CellGroupConfig_t *cg = UE->CellGroup; NR_BWP_DownlinkDedicated_t *bwpd = cg && @@ -422,7 +418,7 @@ bool allocate_dl_retransmission(module_id_t module_id, rbStart++; if (rbStart >= bwpSize) { - LOG_D(NR_MAC, "cannot allocate retransmission for UE %d/RNTI %04x: no resources\n", UE_id, UE_info->rnti[UE_id]); + LOG_D(NR_MAC, "cannot allocate retransmission for RNTI %04x: no resources\n", UE->rnti); return false; } @@ -495,7 +491,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* Find a free CCE */ const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint16_t Y = get_Y(cid%3, slot, UE->rnti); uint8_t nr_of_candidates; for (int i=0; i<5; i++) { @@ -517,8 +513,8 @@ bool allocate_dl_retransmission(module_id_t module_id, Y); if (CCEIndex<0) { - LOG_D(MAC, "%4d.%2d could not find CCE for DL DCI retransmission UE %d/RNTI %04x\n", - frame, slot, UE_id, UE_info->rnti[UE_id]); + LOG_D(MAC, "%4d.%2d could not find CCE for DL DCI retransmission RNTI %04x\n", + frame, slot, UE->rnti); return false; } @@ -526,12 +522,11 @@ bool allocate_dl_retransmission(module_id_t module_id, * allocation after CCE alloc fail would be more complex) */ int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, r_pucch, 0); + const int alloc = nr_acknack_scheduling(module_id, UE, frame, slot, r_pucch, 0); if (alloc<0) { LOG_D(MAC, - "could not find PUCCH for UE %d/%04x@%d.%d\n", - UE_id, - UE_info->rnti[UE_id], + "could not find PUCCH for UE %04x@%d.%d\n", + UE->rnti, frame, slot); RC.nrmac[module_id]->pdcch_cand[cid]--; @@ -557,48 +552,54 @@ bool allocate_dl_retransmission(module_id_t module_id, return true; } -float thr_ue[MAX_MOBILES_PER_GNB]; uint32_t pf_tbs[3][29]; // pre-computed, approximate TBS values for PF coefficient +typedef struct UEsched_s { + float coef; + NR_UE_info_t * UE; +} UEsched_t; + +static int comparator(const void *p, const void *q) { + return ((UEsched_t*)p)->coef < ((UEsched_t*)q)->coef; +} void pf_dl(module_id_t module_id, frame_t frame, sub_frame_t slot, - NR_list_t *UE_list, + NR_UE_info_t **UE_list, int max_num_ue, int n_rb_sched, uint16_t *rballoc_mask) { gNB_MAC_INST *mac = RC.nrmac[module_id]; - NR_UE_info_t *UE_info = &mac->UE_info; NR_ServingCellConfigCommon_t *scc=mac->common_channels[0].ServingCellConfigCommon; - float coeff_ue[MAX_MOBILES_PER_GNB]; // UEs that could be scheduled - int ue_array[MAX_MOBILES_PER_GNB]; - int layers[MAX_MOBILES_PER_GNB]; - NR_list_t UE_sched = { .head = -1, .next = ue_array, .tail = -1, .len = MAX_MOBILES_PER_GNB }; + UEsched_t UE_sched[MAX_MOBILES_PER_GNB] = {0}; + int remainUEs = max_num_ue; + int curUE = 0; /* Loop UE_info->list to check retransmission */ - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - if (UE_info->Msg4_ACKed[UE_id] != true) continue; + UE_iterator(UE_list, UE) { + if (UE->Msg4_ACKed != true) + continue; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; - const NR_mac_dir_stats_t *stats = &UE_info->mac_stats[UE_id].dl; + const NR_mac_dir_stats_t *stats = &UE->mac_stats.dl; NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; /* get the PID of a HARQ process awaiting retrnasmission, or -1 otherwise */ sched_pdsch->dl_harq_pid = sched_ctrl->retrans_dl_harq.head; - layers[UE_id] = ps->nrOfLayers; // initialization of layers to the previous value in the strcuture + UE->layers = ps->nrOfLayers; // initialization of layers to the previous value in the strcuture /* Calculate Throughput */ const float a = 0.0005f; // corresponds to 200ms window - const uint32_t b = stats->current_bytes; - thr_ue[UE_id] = (1 - a) * thr_ue[UE_id] + a * b; + const uint32_t b = UE->mac_stats.dl.current_bytes; + UE->dl_thr_ue = (1 - a) * UE->dl_thr_ue + a * b; /* retransmission */ if (sched_pdsch->dl_harq_pid >= 0) { /* Allocate retransmission */ - bool r = allocate_dl_retransmission(module_id, frame, slot, rballoc_mask, &n_rb_sched, UE_id, sched_pdsch->dl_harq_pid); + bool r = allocate_dl_retransmission(module_id, frame, slot, rballoc_mask, &n_rb_sched, UE, sched_pdsch->dl_harq_pid); if (!r) { LOG_D(NR_MAC, "%4d.%2d retransmission can NOT be allocated\n", frame, slot); @@ -606,9 +607,12 @@ void pf_dl(module_id_t module_id, } /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ - max_num_ue--; + remainUEs--; - if (max_num_ue < 0) return; + if (remainUEs == 0) + // we have filled all with mandatory retransmissions + // no need to schedule new transmissions + return; } else { /* Check DL buffer and skip this UE if no bytes and no TA necessary */ if (sched_ctrl->num_total_bytes == 0 && frame != (sched_ctrl->ta_frame + 10) % 1024) @@ -619,7 +623,7 @@ void pf_dl(module_id_t module_id, const int max_mcs_table = ps->mcsTableIdx == 1 ? 27 : 28; const int max_mcs = min(sched_ctrl->dl_max_mcs, max_mcs_table); sched_pdsch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->dl_bler_stats, max_mcs, frame); - layers[UE_id] = set_dl_nrOfLayers(sched_ctrl); + UE->layers = set_dl_nrOfLayers(sched_ctrl); const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); uint32_t tbs = nr_compute_tbs(Qm, @@ -629,40 +633,26 @@ void pf_dl(module_id_t module_id, 0, /* N_PRB_DMRS * N_DMRS_SLOT */ 0 /* N_PRB_oh, 0 for initialBWP */, 0 /* tb_scaling */, - layers[UE_id]) >> 3; - coeff_ue[UE_id] = (float) tbs / thr_ue[UE_id]; - LOG_D(NR_MAC,"b %d, thr_ue[%d] %f, tbs %d, coeff_ue[%d] %f\n", - b, UE_id, thr_ue[UE_id], tbs, UE_id, coeff_ue[UE_id]); + UE->layers) >> 3; + float coeff_ue = (float) tbs / UE->dl_thr_ue; + LOG_D(NR_MAC,"UE %04x b %d, thr_ue %f, tbs %d, coeff_ue %f\n", + UE->rnti, b, UE->dl_thr_ue, tbs, coeff_ue); /* Create UE_sched list for UEs eligible for new transmission*/ - add_tail_nr_list(&UE_sched, UE_id); + UE_sched[curUE].coef=coeff_ue; + UE_sched[curUE].UE=UE; + curUE++; } } + qsort(UE_sched, sizeof(*UE_sched), sizeofArray(UE_sched), comparator); + UEsched_t *iterator = UE_sched; + const int min_rbSize = 5; /* Loop UE_sched to find max coeff and allocate transmission */ - while (max_num_ue > 0 && n_rb_sched >= min_rbSize && UE_sched.head >= 0) { - /* Find max coeff from UE_sched*/ - int *max = &UE_sched.head; /* assume head is max */ - int *p = &UE_sched.next[*max]; - - while (*p >= 0) { - /* if the current one has larger coeff, save for later */ - if (coeff_ue[*p] > coeff_ue[*max]) - max = p; - - p = &UE_sched.next[*p]; - } - - /* remove the max one: do not use remove_nr_list() it goes through the - * whole list every time. Note that UE_sched.tail might not be set - * correctly anymore */ - const int UE_id = *max; - p = &UE_sched.next[*max]; - *max = UE_sched.next[*max]; - *p = -1; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + while (remainUEs> 0 && n_rb_sched >= min_rbSize && iterator->UE != NULL) { + NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; NR_BWP_DownlinkDedicated_t *bwpd = cg && @@ -677,26 +667,33 @@ void pf_dl(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const uint16_t rnti = UE_info->rnti[UE_id]; - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; + const uint16_t rnti = iterator->UE->rnti; + const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? + RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : + NULL; NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, sib1); - const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const int coresetid = (sched_ctrl->active_bwp||bwpd) ? + sched_ctrl->coreset->controlResourceSetId : + RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; + const uint16_t bwpSize = coresetid == 0 ? + RC.nrmac[module_id]->cset0_bwp_size : + NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); int rbStart = 0; // start wrt BWPstart if (sched_ctrl->available_dl_harq.head < 0) { - LOG_D(MAC, "UE %d RNTI %04x has no free HARQ process, skipping\n", UE_id, UE_info->rnti[UE_id]); + LOG_D(MAC, "RNTI %04x has no free HARQ process, skipping\n", iterator->UE->rnti); + iterator++; continue; } /* Find a free CCE */ const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint16_t Y = get_Y(cid%3, slot, iterator->UE->rnti); uint8_t nr_of_candidates; for (int i=0; i<5; i++) { @@ -718,7 +715,8 @@ void pf_dl(module_id_t module_id, Y); if (CCEIndex<0) { - LOG_D(NR_MAC, "%4d.%2d could not find CCE for DL DCI UE %d/RNTI %04x\n", frame, slot, UE_id, rnti); + LOG_D(NR_MAC, "%4d.%2d could not find CCE for DL DCI RNTI %04x\n", frame, slot, rnti); + iterator++; continue; } @@ -726,33 +724,25 @@ void pf_dl(module_id_t module_id, * allocation after CCE alloc fail would be more complex) */ int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, r_pucch, 0); + const int alloc = nr_acknack_scheduling(module_id, iterator->UE, frame, slot, r_pucch, 0); if (alloc<0) { LOG_D(NR_MAC, - "could not find PUCCH for UE %d/%04x@%d.%d\n", - UE_id, + "could not find PUCCH for %04x@%d.%d\n", rnti, frame, slot); mac->pdcch_cand[cid]--; + iterator++; continue; } - /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE - * and PUCCH */ - max_num_ue--; - AssertFatal(max_num_ue >= 0, "Illegal max_num_ue %d\n", max_num_ue); sched_ctrl->cce_index = CCEIndex; fill_pdcch_vrb_map(mac, /* CC_id = */ 0, &sched_ctrl->sched_pdcch, CCEIndex, sched_ctrl->aggregation_level); - /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ - max_num_ue--; - - if (max_num_ue < 0) return; /* MCS has been set above */ const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); @@ -760,14 +750,14 @@ void pf_dl(module_id_t module_id, NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - if (ps->nrOfLayers != layers[UE_id] || ps->time_domain_allocation != tda) { + if (ps->nrOfLayers != iterator->UE->layers || ps->time_domain_allocation != tda ) { nr_set_pdsch_semi_static(sib1, scc, - UE_info->CellGroup[UE_id], + iterator->UE->CellGroup, sched_ctrl->active_bwp, bwpd, tda, - layers[UE_id], + iterator->UE->layers, sched_ctrl, ps); } @@ -812,21 +802,24 @@ void pf_dl(module_id_t module_id, for (int rb = 0; rb < sched_pdsch->rbSize; rb++) rballoc_mask[rb + sched_pdsch->rbStart] ^= slbitmap; + + remainUEs--; + iterator++; } } void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) { - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; - if (UE_info->num_UEs == 0) + if (UE_info->list[0] == NULL) return; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; const int CC_id = 0; /* Get bwpSize and TDAfrom the first UE */ /* This is temporary and it assumes all UEs have the same BWP and TDA*/ - int UE_id = UE_info->list.head; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_info_t *UE=UE_info->list[0]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp ? @@ -842,10 +835,10 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t sib1); NR_BWP_DownlinkDedicated_t *bwpd = - UE_info->CellGroup[UE_id] && - UE_info->CellGroup[UE_id]->spCellConfig && - UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated ? - UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; + UE->CellGroup && + UE->CellGroup->spCellConfig && + UE->CellGroup->spCellConfig->spCellConfigDedicated ? + UE->CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; @@ -874,7 +867,7 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t pf_dl(module_id, frame, slot, - &UE_info->list, + UE_info->list, MAX_MOBILES_PER_GNB, n_rb_sched, rballoc_mask); @@ -921,18 +914,17 @@ void nr_schedule_ue_spec(module_id_t module_id, gNB_mac->pre_processor_dl(module_id, frame, slot); const int CC_id = 0; NR_ServingCellConfigCommon_t *scc = gNB_mac->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &gNB_mac->UE_info; + NR_UEs_t *UE_info = &gNB_mac->UE_info; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - NR_list_t *UE_list = &UE_info->list; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(UE_info->list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; - UE_info->mac_stats[UE_id].dl.current_bytes = 0; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + UE->mac_stats.dl.current_bytes = 0; + NR_CellGroupConfig_t *cg = UE->CellGroup; NR_BWP_DownlinkDedicated_t *bwpd = cg && @@ -946,13 +938,13 @@ void nr_schedule_ue_spec(module_id_t module_id, * If we add the CE, ta_apply will be reset */ if (frame == (sched_ctrl->ta_frame + 10) % 1024) { sched_ctrl->ta_apply = true; /* the timer is reset once TA CE is scheduled */ - LOG_D(NR_MAC, "[UE %d][%d.%d] UL timing alignment procedures: setting flag for Timing Advance command\n", UE_id, frame, slot); + LOG_D(NR_MAC, "[UE %04x][%d.%d] UL timing alignment procedures: setting flag for Timing Advance command\n", UE->rnti, frame, slot); } if (sched_pdsch->rbSize <= 0) continue; - const rnti_t rnti = UE_info->rnti[UE_id]; + const rnti_t rnti = UE->rnti; /* pre-computed PDSCH values that only change if time domain * allocation/DMRS parameters change. Updated in the preprocessor through * nr_set_pdsch_semi_static() */ @@ -968,8 +960,8 @@ void nr_schedule_ue_spec(module_id_t module_id, /* PP has not selected a specific HARQ Process, get a new one */ current_harq_pid = sched_ctrl->available_dl_harq.head; AssertFatal(current_harq_pid >= 0, - "no free HARQ process available for UE %d\n", - UE_id); + "no free HARQ process available for UE %04x\n", + UE->rnti); remove_front_nr_list(&sched_ctrl->available_dl_harq); sched_pdsch->dl_harq_pid = current_harq_pid; } else { @@ -989,12 +981,11 @@ void nr_schedule_ue_spec(module_id_t module_id, harq->feedback_frame = pucch->frame; harq->feedback_slot = pucch->ul_slot; harq->is_waiting = true; - UE_info->mac_stats[UE_id].dl.rounds[harq->round]++; + UE->mac_stats.dl.rounds[harq->round]++; LOG_D(NR_MAC, - "%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d nrOfLayers %d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) PUCCH allocation %d TPC %d\n", + "%4d.%2d [DLSCH/PDSCH/PUCCH] RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d nrOfLayers %d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) PUCCH allocation %d TPC %d\n", frame, slot, - UE_id, rnti, sched_ctrl->aggregation_level, sched_pdsch->rbStart, @@ -1037,7 +1028,7 @@ void nr_schedule_ue_spec(module_id_t module_id, dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - LOG_D(NR_MAC,"Trying to configure DL pdcch for UE %d, bwp %d, cs %d\n",UE_id,bwp_id,coresetid); + LOG_D(NR_MAC,"Trying to configure DL pdcch for UE %04x, bwp %d, cs %d\n", UE->rnti, bwp_id, coresetid); NR_ControlResourceSet_t *coreset = (bwp||bwpd)? sched_ctrl->coreset:gNB_mac->sched_ctrlCommon->coreset; nr_configure_pdcch(pdcch_pdu, coreset, genericParameters, &sched_ctrl->sched_pdcch); gNB_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu; @@ -1099,8 +1090,8 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->NrOfSymbols = ps->nrOfSymbols; // Precoding if (sched_ctrl->set_pmi) { - int report_id = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id; - nr_csi_report_t *csi_report = &UE_info->csi_report_template[UE_id][report_id]; + const int report_id = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id; + nr_csi_report_t *csi_report = &UE->csi_report_template[report_id]; pdsch_pdu->precodingAndBeamforming.prg_size = pdsch_pdu->rbSize; pdsch_pdu->precodingAndBeamforming.prgs_list[0].pm_idx = set_pm_index(sched_ctrl, nrOfLayers, @@ -1241,17 +1232,16 @@ void nr_schedule_ue_spec(module_id_t module_id, * from RLC or encode MAC CEs. The TX_req structure is filled below * or copy data to FAPI structures */ LOG_D(NR_MAC, - "%d.%2d DL retransmission UE %d/RNTI %04x HARQ PID %d round %d NDI %d\n", + "%d.%2d DL retransmission RNTI %04x HARQ PID %d round %d NDI %d\n", frame, slot, - UE_id, rnti, current_harq_pid, harq->round, harq->ndi); AssertFatal(harq->sched_pdsch.tb_size == TBS, - "UE %d mismatch between scheduled TBS and buffered TB for HARQ PID %d\n", - UE_id, + "UE %04x mismatch between scheduled TBS and buffered TB for HARQ PID %d\n", + UE->rnti, current_harq_pid); T(T_GNB_MAC_RETRANSMISSION_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti), T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_INT(harq->round), T_BUFFER(harq->transportBlock, TBS)); @@ -1323,7 +1313,7 @@ void nr_schedule_ue_spec(module_id_t module_id, lcid_bytes += len; } - UE_info->mac_stats[UE_id].dl.lc_bytes[lcid] += lcid_bytes; + UE->mac_stats.dl.lc_bytes[lcid] += lcid_bytes; } } else if (get_softmodem_params()->phy_test || get_softmodem_params()->do_ra) { /* we will need the large header, phy-test typically allocates all @@ -1361,10 +1351,8 @@ void nr_schedule_ue_spec(module_id_t module_id, buf=bufEnd; } - NR_mac_stats_t *mac_stats = &UE_info->mac_stats[UE_id]; - mac_stats->dl.total_bytes += TBS; - mac_stats->dl.current_bytes = TBS; - + UE->mac_stats.dl.total_bytes += TBS; + UE->mac_stats.dl.current_bytes = TBS; /* save retransmission information */ harq->sched_pdsch = *sched_pdsch; /* save which time allocation has been used, to be used on @@ -1376,10 +1364,10 @@ void nr_schedule_ue_spec(module_id_t module_id, sched_ctrl->ta_apply = false; sched_ctrl->ta_frame = frame; LOG_D(NR_MAC, - "%d.%2d UE %d TA scheduled, resetting TA frame\n", + "%d.%2d UE %04x TA scheduled, resetting TA frame\n", frame, slot, - UE_id); + UE->rnti); } T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti), diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 8cca07a51a..8a0e966a8a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -69,7 +69,6 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, nfapi_nr_pdu_t *TX_req; uint16_t rnti = 0x1234; - // int time_domain_assignment,k0; NR_ServingCellConfigCommon_t *scc=cc->ServingCellConfigCommon; @@ -266,21 +265,16 @@ void nr_preprocessor_phytest(module_id_t module_id, { if (!is_xlsch_in_slot(dlsch_slot_bitmap, slot)) return; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; + NR_UE_info_t *UE = RC.nrmac[module_id]->UE_info.list[0]; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; - const int UE_id = 0; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; const int CC_id = 0; - AssertFatal(UE_info->active[UE_id], - "%s(): expected UE %d to be active\n", - __func__, - UE_id); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = target_dl_Nl; if (ps->time_domain_allocation != tda || ps->nrOfLayers != target_dl_Nl) - nr_set_pdsch_semi_static(NULL, scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, NULL, tda, target_dl_Nl, sched_ctrl, ps); + nr_set_pdsch_semi_static(NULL, scc, UE->CellGroup, sched_ctrl->active_bwp, NULL, tda, target_dl_Nl,sched_ctrl , ps); /* find largest unallocated chunk */ const int bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -316,7 +310,7 @@ void nr_preprocessor_phytest(module_id_t module_id, sched_ctrl->dl_lc_num = 1; const int lcid = DL_SCH_LCID_DTCH; sched_ctrl->dl_lc_ids[sched_ctrl->dl_lc_num - 1] = lcid; - const uint16_t rnti = UE_info->rnti[UE_id]; + const uint16_t rnti = UE->rnti; /* update sched_ctrl->num_total_bytes so that postprocessor schedules data, * if available */ sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id, @@ -343,7 +337,7 @@ void nr_preprocessor_phytest(module_id_t module_id, AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint16_t Y = get_Y(cid%3, slot, UE->rnti); int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], CC_id, @@ -354,17 +348,16 @@ void nr_preprocessor_phytest(module_id_t module_id, Y); AssertFatal(CCEIndex >= 0, - "%s(): could not find CCE for UE %d\n", + "%s(): could not find CCE for UE %04x\n", __func__, - UE_id); + UE->rnti); int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, NULL, CCEIndex); - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, r_pucch, 0); + const int alloc = nr_acknack_scheduling(module_id, UE, frame, slot, r_pucch, 0); if (alloc < 0) { LOG_D(MAC, - "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", + "%s(): could not find PUCCH for UE %04x@%d.%d\n", __func__, - UE_id, rnti, frame, slot); @@ -422,19 +415,16 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; const int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - NR_UE_info_t *UE_info = &nr_mac->UE_info; + NR_UE_info_t *UE = nr_mac->UE_info.list[0]; - AssertFatal(UE_info->num_UEs <= 1, - "%s() cannot handle more than one UE, but found %d\n", - __func__, - UE_info->num_UEs); - if (UE_info->num_UEs == 0) + AssertFatal(nr_mac->UE_info.list[1] == NULL, + "cannot handle more than one UE\n"); + if (UE == NULL) return false; - const int UE_id = 0; const int CC_id = 0; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; @@ -523,7 +513,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint16_t Y = get_Y(cid%3, slot, UE->rnti); int CCEIndex = find_pdcch_candidate(nr_mac, CC_id, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 1e749a9592..574cfa2615 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -288,7 +288,7 @@ NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList( } -NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, +NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, void *bwp, NR_SearchSpace_t *ss, @@ -298,7 +298,7 @@ NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { // common search space NR_ControlResourceSet_t *coreset; if(coreset_id == 0) { - coreset = RC.nrmac[module_idP]->sched_ctrlCommon->coreset; // this is coreset 0 + coreset = nrmac->sched_ctrlCommon->coreset; // this is coreset 0 } else if (bwp) { coreset = ((NR_BWP_Downlink_t*)bwp)->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; } else if (scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet) { @@ -607,11 +607,10 @@ void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, bwpd->pdsch_Config && bwpd->pdsch_Config->choice.setup && bwpd->pdsch_Config->choice.setup->mcs_Table) { - if (*bwpd->pdsch_Config->choice.setup->mcs_Table == 0) { + if (*bwpd->pdsch_Config->choice.setup->mcs_Table == 0) ps->mcsTableIdx = 1; - } else { + else ps->mcsTableIdx = 2; - } } else { ps->mcsTableIdx = 0; } @@ -628,9 +627,9 @@ void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, ps->mapping_type = tdaList->list.array[tda]->mappingType; if (pdsch_Config) { if (ps->mapping_type == NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB) - ps->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_Type == NULL ? 0 : 1; + ps->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_Type != NULL; else - ps->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; + ps->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type != NULL; } else ps->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; @@ -2135,10 +2134,11 @@ int extract_length(int startSymbolAndLength) { /* * Dump the UL or DL UE_info into LOG_T(MAC) */ -void dump_nr_list(NR_list_t *listP) +void dump_nr_list(NR_UE_info_t **list) { - for (int j = listP->head; j >= 0; j = listP->next[j]) - LOG_T(NR_MAC, "NR list node %d => %d\n", j, listP->next[j]); + UE_iterator(list, UE) { + LOG_T(NR_MAC, "NR list UEs rntis %04x\n", (*list)->rnti); + } } /* @@ -2193,7 +2193,7 @@ void destroy_nr_list(NR_list_t *list) { free(list->next); } - +//------------------------------------------------------------------------------ /* * Add an ID to an NR_list at the end, traversing the whole list. Note: * add_tail_nr_list() is a faster alternative, but this implementation ensures @@ -2222,16 +2222,7 @@ void remove_nr_list(NR_list_t *listP, int id) prev = cur; cur = &listP->next[*cur]; } - if (*cur == -1) { - cur = &listP->head; - prev=&listP->head; - while (*cur != -1 && *cur != id) { - LOG_I(NR_MAC,"remove_nr_list : id %d, *cur %d\n",id,*cur); - prev = cur; - cur = &listP->next[*cur]; - } - AssertFatal(1==0, "ID %d not found in UE_list\n", id); - } + AssertFatal(*cur != -1, "ID %d not found in UE_list\n", id); int *next = &listP->next[*cur]; *cur = listP->next[*cur]; *next = -1; @@ -2276,21 +2267,17 @@ void remove_front_nr_list(NR_list_t *listP) listP->tail = -1; } -int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) +NR_UE_info_t * find_nr_UE(NR_UEs_t* UEs, rnti_t rntiP) //------------------------------------------------------------------------------ { - int UE_id; - NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info; - - for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) { - if (UE_info->active[UE_id]) { - if (UE_info->rnti[UE_id] == rntiP) { - return UE_id; - } + UE_iterator(UEs->list, UE) { + if (UE->rnti == rntiP) { + LOG_D(NR_MAC,"Search and found rnti: %04x\n", rntiP); + return UE; } } - - return -1; + LOG_W(NR_MAC,"Search for not existing rnti: %04x\n", rntiP); + return NULL; } uint16_t get_Y(int cid, int slot, rnti_t rnti) { @@ -2363,39 +2350,80 @@ int get_ul_bwp_id(const NR_ServingCellConfig_t *servingCellConfig) return 1; } -//------------------------------------------------------------------------------ -int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup) -{ - gNB_MAC_INST *nr_mac = RC.nrmac[mod_idP]; - NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels[0].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &nr_mac->UE_info; - LOG_I(NR_MAC, "[gNB %d] Adding UE with rnti 0x%04x (num_UEs %d)\n", - mod_idP, - rntiP, - UE_info->num_UEs); - dump_nr_list(&UE_info->list); +/* hack data to remove UE in the phy */ +int rnti_to_remove[10]; +volatile int rnti_to_remove_count; +pthread_mutex_t rnti_to_remove_mutex = PTHREAD_MUTEX_INITIALIZER; - for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) { - if (UE_info->active[i]) { - LOG_D(NR_MAC,"UE %x is active, skipping\n",rntiP); - continue; +void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) +{ + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + destroy_nr_list(&sched_ctrl->available_dl_harq); + destroy_nr_list(&sched_ctrl->feedback_dl_harq); + destroy_nr_list(&sched_ctrl->retrans_dl_harq); + destroy_nr_list(&sched_ctrl->available_ul_harq); + destroy_nr_list(&sched_ctrl->feedback_ul_harq); + destroy_nr_list(&sched_ctrl->retrans_ul_harq); + LOG_I(NR_MAC, "Remove NR rnti 0x%04x\n", UE->rnti); + const rnti_t rnti = UE->rnti; + free(UE); + /* hack to remove UE in the phy */ + if (pthread_mutex_lock(&rnti_to_remove_mutex)) + exit(1); + if (rnti_to_remove_count == 10) + exit(1); + rnti_to_remove[rnti_to_remove_count] = rnti; + LOG_W(NR_MAC, "to remove in mac rnti_to_remove[%d] = 0x%04x\n", rnti_to_remove_count, rnti); + rnti_to_remove_count++; + if (pthread_mutex_unlock(&rnti_to_remove_mutex)) + exit(1); + + /* clear RA process(es?) associated to the UE */ + for (int cc_id = 0; cc_id < NFAPI_CC_MAX; cc_id++) { + for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { + NR_COMMON_channels_t *cc = &ccPtr[cc_id]; + if (cc->ra[i].rnti == rnti) { + LOG_D(NR_MAC, "free RA process %d for rnti %04x\n", i, rnti); + /* is it enough? */ + cc->ra[i].cfra = false; + cc->ra[i].rnti = 0; + cc->ra[i].crnti = 0; + } } - int UE_id = i; - UE_info->num_UEs++; - UE_info->active[UE_id] = true; - if (CellGroup) UE_info->Msg4_ACKed[UE_id] = true; - else UE_info->Msg4_ACKed[UE_id] = false; - UE_info->rnti[UE_id] = rntiP; - UE_info->CellGroup[UE_id] = CellGroup; - add_nr_list(&UE_info->list, UE_id); - memset(&UE_info->mac_stats[UE_id], 0, sizeof(NR_mac_stats_t)); - if (CellGroup && - CellGroup->spCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated && - CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && - CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) - compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info, UE_id, mod_idP); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + } +} + +//------------------------------------------------------------------------------ +NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup) +{ + NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels[0].ServingCellConfigCommon; + NR_UEs_t *UE_info = &nr_mac->UE_info; + LOG_I(NR_MAC, "Adding UE with rnti 0x%04x\n", + rntiP); + dump_nr_list(UE_info->list); + + // We will attach at the end, to mitigate race conditions + // This is not good, but we will fix it progressively + NR_UE_info_t *UE=calloc(1,sizeof(NR_UE_info_t)); + if(!UE) { + LOG_E(NR_MAC,"want to add UE %04x but the fixed allocated size is full\n",rntiP); + return NULL; + } + + UE->rnti = rntiP; + UE->CellGroup = CellGroup; + + if (CellGroup) + UE->Msg4_ACKed = true; + else + UE->Msg4_ACKed = false; + if (CellGroup && + CellGroup->spCellConfig && + CellGroup->spCellConfig->spCellConfigDedicated && + CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && + CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) + compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; memset(sched_ctrl, 0, sizeof(*sched_ctrl)); sched_ctrl->dl_max_mcs = 28; /* do not limit MCS for individual UEs */ sched_ctrl->set_pmi = false; @@ -2406,7 +2434,6 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG sched_ctrl->pucch_consecutive_dtx_cnt = 0; sched_ctrl->pusch_consecutive_dtx_cnt = 0; sched_ctrl->ul_failure = 0; - sched_ctrl->sched_srs.frame = -1; sched_ctrl->sched_srs.slot = -1; sched_ctrl->sched_srs.srs_scheduled = false; @@ -2416,11 +2443,8 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG sched_ctrl->pusch_semi_static.time_domain_allocation = -1; const NR_ServingCellConfig_t *servingCellConfig = CellGroup && CellGroup->spCellConfig ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; - /* Set default BWPs */ - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig ? servingCellConfig->downlinkBWP_ToAddModList : NULL; - if (bwpList) AssertFatal(bwpList->list.count <= NR_MAX_NUM_BWP, - "downlinkBWP_ToAddModList has %d BWP!\n", - bwpList->list.count); + /* Set default BWPs */ + const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig ? servingCellConfig->downlinkBWP_ToAddModList : NULL; const int bwp_id = servingCellConfig ? *servingCellConfig->firstActiveDownlinkBWP_Id : 0; sched_ctrl->active_bwp = bwpList && bwp_id > 0 ? bwpList->list.array[bwp_id - 1] : NULL; @@ -2433,10 +2457,12 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); - sched_ctrl->coreset = get_coreset(mod_idP, scc, - sched_ctrl->active_bwp ? (void*)sched_ctrl->active_bwp->bwp_Dedicated : NULL, - sched_ctrl->search_space, target_ss); - sched_ctrl->sched_pdcch = set_pdcch_structure(RC.nrmac[mod_idP], + sched_ctrl->coreset = get_coreset(nr_mac, + scc, + sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, + sched_ctrl->search_space, + target_ss); + sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, sched_ctrl->search_space, sched_ctrl->coreset, scc, @@ -2445,16 +2471,18 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG sched_ctrl->next_dl_bwp_id = -1; sched_ctrl->next_ul_bwp_id = -1; const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; - if (ubwpList) AssertFatal(ubwpList->list.count <= NR_MAX_NUM_BWP, + if (ubwpList) + AssertFatal(ubwpList->list.count <= NR_MAX_NUM_BWP, "uplinkBWP_ToAddModList has %d BWP!\n", ubwpList->list.count); const int ul_bwp_id = servingCellConfig ? *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id : 0; sched_ctrl->active_ubwp = ubwpList && ul_bwp_id > 0 ? ubwpList->list.array[ul_bwp_id - 1] : NULL; /* get Number of HARQ processes for this UE */ - if (servingCellConfig) AssertFatal(servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, - "no pdsch-ServingCellConfig found for UE %d\n", - UE_id); + if (servingCellConfig) + AssertFatal(servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, + "no pdsch-ServingCellConfig found for UE %04x\n", + UE->rnti); const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; // pdsch == NULL in SA -> will create default (8) number of HARQ processes create_dl_harq_list(sched_ctrl, pdsch); @@ -2465,21 +2493,27 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); create_nr_list(&sched_ctrl->feedback_ul_harq, 16); create_nr_list(&sched_ctrl->retrans_ul_harq, 16); - LOG_D(NR_MAC, "[gNB %d] Add NR UE_id %d : rnti %x\n", - mod_idP, - UE_id, - rntiP); - dump_nr_list(&UE_info->list); - return (UE_id); + + pthread_mutex_lock(&UE_info->mutex); + int i; + for(i=0; ilist[i] == NULL) { + UE_info->list[i] = UE; + break; + } + if (i == MAX_MOBILES_PER_GNB) { + LOG_E(NR_MAC,"Try to add UE %04x but the list is full\n", rntiP); + delete_nr_ue_data(UE, nr_mac->common_channels); + pthread_mutex_unlock(&UE_info->mutex); + return NULL; } + pthread_mutex_unlock(&UE_info->mutex); - // printf("MAC: cannot add new UE for rnti %x\n", rntiP); - LOG_E(NR_MAC, "error in add_new_ue(), could not find space in UE_info, Dumping UE list\n"); - dump_nr_list(&UE_info->list); - return -1; + LOG_D(NR_MAC, "Add NR rnti %x\n", rntiP); + dump_nr_list(UE_info->list); + return (UE); } - void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_PDSCH_ServingCellConfig_t *pdsch) { const int nrofHARQ = pdsch && pdsch->nrofHARQ_ProcessesForPDSCH ? @@ -2512,66 +2546,30 @@ void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, } } -/* hack data to remove UE in the phy */ -int rnti_to_remove[10]; -volatile int rnti_to_remove_count; -pthread_mutex_t rnti_to_remove_mutex = PTHREAD_MUTEX_INITIALIZER; - -void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti) +void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti) { - int UE_id; - int i; - int cc_id; - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; + NR_UEs_t *UE_info = &nr_mac->UE_info; + pthread_mutex_lock(&UE_info->mutex); + UE_iterator(UE_info->list, UE) { + if (UE->rnti==rnti) + break; + } - for (i = 0; i < MAX_MOBILES_PER_GNB; i++) { + if (!UE) { + LOG_W(NR_MAC,"Call to del rnti %04x, but not existing\n", rnti); + pthread_mutex_unlock(&UE_info->mutex); + return; + } - if (UE_info->active[i] != TRUE) - continue; - if (UE_info->rnti[i] != rnti) - continue; + NR_UE_info_t * newUEs[MAX_MOBILES_PER_GNB+1]={0}; + int newListIdx=0; + for (int i=0; ilist[i] && UE_info->list[i]->rnti != rnti) + newUEs[newListIdx++]=UE_info->list[i]; + memcpy(UE_info->list, newUEs, sizeof(UE_info->list)); + pthread_mutex_unlock(&UE_info->mutex); - /* UE found, remove it */ - UE_id = i; - - UE_info->num_UEs--; - UE_info->active[UE_id] = FALSE; - UE_info->rnti[UE_id] = 0; - remove_nr_list(&UE_info->list, UE_id); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - destroy_nr_list(&sched_ctrl->available_dl_harq); - destroy_nr_list(&sched_ctrl->feedback_dl_harq); - destroy_nr_list(&sched_ctrl->retrans_dl_harq); - destroy_nr_list(&sched_ctrl->available_ul_harq); - destroy_nr_list(&sched_ctrl->feedback_ul_harq); - destroy_nr_list(&sched_ctrl->retrans_ul_harq); - LOG_I(NR_MAC, "[gNB %d] Remove NR UE_id %d: rnti 0x%04x\n", - mod_id, - UE_id, - rnti); - - /* hack to remove UE in the phy */ - if (pthread_mutex_lock(&rnti_to_remove_mutex)) exit(1); - if (rnti_to_remove_count == 10) exit(1); - rnti_to_remove[rnti_to_remove_count] = rnti; - LOG_W(NR_MAC, "to remove in mac rnti_to_remove[%d] = 0x%04x\n", rnti_to_remove_count, rnti); - rnti_to_remove_count++; - if (pthread_mutex_unlock(&rnti_to_remove_mutex)) exit(1); - } - - /* clear RA process(es?) associated to the UE */ - for (cc_id = 0; cc_id < NFAPI_CC_MAX; cc_id++) { - NR_COMMON_channels_t *cc = &RC.nrmac[mod_id]->common_channels[cc_id]; - for (i = 0; i < NR_NB_RA_PROC_MAX; i++) { - if (cc->ra[i].rnti == rnti) { - LOG_D(NR_MAC, "free RA process %d for rnti %d\n", i, rnti); - /* is it enough? */ - cc->ra[i].cfra = false; - cc->ra[i].rnti = 0; - cc->ra[i].crnti = 0; - } - } - } + delete_nr_ue_data(UE, nr_mac->common_channels); } void nr_mac_remove_ra_rnti(module_id_t mod_id, rnti_t rnti) { @@ -2595,20 +2593,18 @@ uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) { } -void get_pdsch_to_harq_feedback(int Mod_idP, - int UE_id, +void get_pdsch_to_harq_feedback( NR_UE_info_t * UE, int bwp_id, NR_SearchSpace__searchSpaceType_PR ss_type, int *max_fb_time, uint8_t *pdsch_to_harq_feedback) { - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; + NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_BWP_DownlinkDedicated_t *bwpd=NULL; NR_BWP_UplinkDedicated_t *ubwpd=NULL; if (ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { - AssertFatal(CellGroup!=NULL,"Cellgroup is not defined for UE_id %d\n",UE_id); + AssertFatal(CellGroup!=NULL,"Cellgroup is not defined for UE %04x\n",UE->rnti); AssertFatal(CellGroup->spCellConfig!=NULL,"Cellgroup->spCellConfig is null\n"); AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated!=NULL,"CellGroup->spCellConfig->spCellConfigDedicated is null\n"); } @@ -2692,22 +2688,18 @@ void nr_csirs_scheduling(int Mod_idP, int n_slots_frame){ int CC_id = 0; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_list_t *UE_list = &UE_info->list; + NR_UEs_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; gNB_MAC_INST *gNB_mac = RC.nrmac[Mod_idP]; uint16_t *vrb_map = gNB_mac->common_channels[CC_id].vrb_map; - UE_info->sched_csirs = false; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(UE_info->list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->rrc_processing_timer > 0) { continue; } - - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; + NR_CellGroupConfig_t *CellGroup = UE->CellGroup; if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; @@ -2723,6 +2715,7 @@ void nr_csirs_scheduling(int Mod_idP, NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? &sched_ctrl->active_bwp->bwp_Common->genericParameters : &gNB_mac->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + for (int id = 0; id < csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.count; id++){ nzpcsi = csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.array[id]; NR_CSI_RS_ResourceMapping_t resourceMapping = nzpcsi->resourceMapping; @@ -2731,7 +2724,7 @@ void nr_csirs_scheduling(int Mod_idP, if((frame*n_slots_frame+slot-offset)%period == 0) { LOG_D(NR_MAC,"Scheduling CSI-RS in frame %d slot %d\n",frame,slot); - UE_info->sched_csirs = true; + UE->sched_csirs = true; nfapi_nr_dl_tti_request_pdu_t *dl_tti_csirs_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset((void*)dl_tti_csirs_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); @@ -2899,18 +2892,17 @@ void nr_csirs_scheduling(int Mod_idP, void nr_mac_update_timers(module_id_t module_id, frame_t frame, sub_frame_t slot) { + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - const NR_list_t *UE_list = &UE_info->list; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(UE_info->list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->rrc_processing_timer > 0) { sched_ctrl->rrc_processing_timer--; if (sched_ctrl->rrc_processing_timer == 0) { - LOG_I(NR_MAC, "(%d.%d) De-activating RRC processing timer for UE %d\n", frame, slot, UE_id); + LOG_I(NR_MAC, "(%d.%d) De-activating RRC processing timer for UE %04x\n", frame, slot, UE->rnti); const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_CellGroupConfig_t *cg = UE->CellGroup; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; const NR_ServingCellConfig_t *spCellConfigDedicated = cg && cg->spCellConfig ? cg->spCellConfig->spCellConfigDedicated : NULL; @@ -2984,23 +2976,22 @@ void schedule_nr_bwp_switch(module_id_t module_id, frame_t frame, sub_frame_t slot) { - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - const NR_list_t *UE_list = &UE_info->list; + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; // TODO: Implementation of a algorithm to perform: // - DL BWP selection: sched_ctrl->next_dl_bwp_id = dl_bwp_id // - UL BWP selection: sched_ctrl->next_ul_bwp_id = ul_bwp_id - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(UE_info->list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->rrc_processing_timer == 0 && - UE_info->Msg4_ACKed[UE_id] == true && + UE->Msg4_ACKed && ((sched_ctrl->next_dl_bwp_id >= 0 && sched_ctrl->active_bwp && sched_ctrl->active_bwp->bwp_Id != sched_ctrl->next_dl_bwp_id) || (sched_ctrl->next_ul_bwp_id >= 0 && sched_ctrl->active_ubwp && sched_ctrl->active_ubwp->bwp_Id != sched_ctrl->next_ul_bwp_id))) { - LOG_W(NR_MAC,"(%d.%d) [UE_id %d] Schedule BWP switch from dl_bwp_id %ld to %ld and from ul_bwp_id %ld to %ld\n", - frame, slot, UE_id, sched_ctrl->active_bwp->bwp_Id, sched_ctrl->next_dl_bwp_id, sched_ctrl->active_ubwp->bwp_Id, sched_ctrl->next_ul_bwp_id); - nr_mac_rrc_bwp_switch_req(module_id, frame, slot, UE_info->rnti[UE_id], sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); + LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from dl_bwp_id %ld to %ld and from ul_bwp_id %ld to %ld\n", + frame, slot, UE->rnti, sched_ctrl->active_bwp->bwp_Id, sched_ctrl->next_dl_bwp_id, sched_ctrl->active_ubwp->bwp_Id, sched_ctrl->next_ul_bwp_id); + nr_mac_rrc_bwp_switch_req(module_id, frame, slot, UE->rnti, sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index 8680cc25d1..c156ebf36d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -34,18 +34,17 @@ extern RAN_CONTEXT_t RC; -void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id, int UE_id, NR_SRS_Resource_t *srs_resource) { +void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id,NR_UE_info_t* UE, NR_SRS_Resource_t *srs_resource) { gNB_MAC_INST *nrmac = RC.nrmac[module_id]; NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &nrmac->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_BWP_t ubwp = sched_ctrl->active_ubwp ? sched_ctrl->active_ubwp->bwp_Common->genericParameters : scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - srs_pdu->rnti = UE_info->rnti[UE_id]; + srs_pdu->rnti = UE->rnti; srs_pdu->handle = 0; srs_pdu->bwp_size = NRRIV2BW(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; srs_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; @@ -82,7 +81,7 @@ void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id, int srs_pdu->t_offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p); } -void nr_fill_nfapi_srs(int module_id, int CC_id, int UE_id, sub_frame_t slot, NR_SRS_Resource_t *srs_resource) { +void nr_fill_nfapi_srs(int module_id, int CC_id, NR_UE_info_t* UE, sub_frame_t slot, NR_SRS_Resource_t *srs_resource) { nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[module_id]->UL_tti_req_ahead[0][slot]; AssertFatal(future_ul_tti_req->n_pdus < @@ -94,7 +93,7 @@ void nr_fill_nfapi_srs(int module_id, int CC_id, int UE_id, sub_frame_t slot, NR memset(srs_pdu, 0, sizeof(nfapi_nr_srs_pdu_t)); future_ul_tti_req->n_pdus += 1; - nr_configure_srs(srs_pdu, module_id, CC_id, UE_id, srs_resource); + nr_configure_srs(srs_pdu, module_id, CC_id, UE, srs_resource); } /******************************************************************* @@ -111,21 +110,19 @@ void nr_fill_nfapi_srs(int module_id, int CC_id, int UE_id, sub_frame_t slot, NR void nr_schedule_srs(int module_id, frame_t frame) { gNB_MAC_INST *nrmac = RC.nrmac[module_id]; - NR_UE_info_t *UE_info = &nrmac->UE_info; - const NR_list_t *UE_list = &UE_info->list; - - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { + NR_UEs_t *UE_info = &nrmac->UE_info; + UE_iterator(UE_info->list, UE) { const int CC_id = 0; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[CC_id].ServingCellConfigCommon; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_CellGroupConfig_t *cg = UE->CellGroup; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; sched_ctrl->sched_srs.frame = -1; sched_ctrl->sched_srs.slot = -1; sched_ctrl->sched_srs.srs_scheduled = false; - if(!UE_info->Msg4_ACKed[UE_id] || sched_ctrl->rrc_processing_timer > 0) { + if(!UE->Msg4_ACKed || sched_ctrl->rrc_processing_timer > 0) { continue; } @@ -178,11 +175,11 @@ void nr_schedule_srs(int module_id, frame_t frame) { // Check if UE will transmit the SRS in this frame if ( ((frame - offset/n_slots_frame)*n_slots_frame)%period == 0) { LOG_D(NR_MAC,"Scheduling SRS reception for %d.%d\n", frame, offset%n_slots_frame); - nr_fill_nfapi_srs(module_id, CC_id, UE_id, offset%n_slots_frame, srs_resource); + nr_fill_nfapi_srs(module_id, CC_id, UE, offset%n_slots_frame, srs_resource); sched_ctrl->sched_srs.frame = frame; sched_ctrl->sched_srs.slot = offset%n_slots_frame; sched_ctrl->sched_srs.srs_scheduled = true; } } } -} \ No newline at end of file +} diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index b9292876e3..9dd147d21f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -38,17 +38,15 @@ extern RAN_CONTEXT_t RC; -void nr_fill_nfapi_pucch(module_id_t mod_id, - frame_t frame, - sub_frame_t slot, - const NR_sched_pucch_t *pucch, - int UE_id) -{ - gNB_MAC_INST *nr_mac = RC.nrmac[mod_id]; - NR_UE_info_t *UE_info = &nr_mac->UE_info; +static void nr_fill_nfapi_pucch(gNB_MAC_INST *nrmac, + frame_t frame, + sub_frame_t slot, + const NR_sched_pucch_t *pucch, + NR_UE_info_t* UE) +{ nfapi_nr_ul_tti_request_t *future_ul_tti_req = - &RC.nrmac[mod_id]->UL_tti_req_ahead[0][pucch->ul_slot]; + &nrmac->UL_tti_req_ahead[0][pucch->ul_slot]; AssertFatal(future_ul_tti_req->SFN == pucch->frame && future_ul_tti_req->Slot == pucch->ul_slot, "Current %4d.%2d : future UL_tti_req's frame.slot %4d.%2d does not match PUCCH %4d.%2d\n", @@ -57,8 +55,7 @@ void nr_fill_nfapi_pucch(module_id_t mod_id, future_ul_tti_req->Slot, pucch->frame, pucch->ul_slot); - AssertFatal(future_ul_tti_req->n_pdus < - sizeof(future_ul_tti_req->pdus_list) / sizeof(future_ul_tti_req->pdus_list[0]), + AssertFatal(future_ul_tti_req->n_pdus < sizeofArray(future_ul_tti_req->pdus_list), "Invalid future_ul_tti_req->n_pdus %d\n", future_ul_tti_req->n_pdus); future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE; future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pucch_pdu_t); @@ -77,9 +74,9 @@ void nr_fill_nfapi_pucch(module_id_t mod_id, pucch->dai_c, pucch->csi_bits, pucch->resource_indicator); - - NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; - NR_CellGroupConfig_t *cg=UE_info->CellGroup[UE_id]; + NR_COMMON_channels_t * common_ch=nrmac->common_channels; + NR_ServingCellConfigCommon_t *scc = common_ch->ServingCellConfigCommon; + NR_CellGroupConfig_t *cg=UE->CellGroup; NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? @@ -88,14 +85,14 @@ void nr_fill_nfapi_pucch(module_id_t mod_id, LOG_D(NR_MAC,"%4d.%2d Calling nr_configure_pucch (ubwpd %p,r_pucch %d) pucch to be scheduled in %4d.%2d\n", frame,slot,ubwpd,pucch->r_pucch,pucch->frame,pucch->ul_slot); - const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + const NR_SIB1_t *sib1 = common_ch->sib1 ? common_ch->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; nr_configure_pucch(sib1, pucch_pdu, scc, - UE_info->CellGroup[UE_id], - UE_info->UE_sched_ctrl[UE_id].active_ubwp, + UE->CellGroup, + UE->UE_sched_ctrl.active_ubwp, ubwpd, - UE_info->rnti[UE_id], + UE->rnti, pucch->resource_indicator, pucch->csi_bits, pucch->dai_c, @@ -139,22 +136,18 @@ int diff_rsrp_ssb_csi_meas_10_1_6_1_2[16] = { }; -void nr_schedule_pucch(int Mod_idP, +void nr_schedule_pucch(gNB_MAC_INST *nrmac, frame_t frameP, sub_frame_t slotP) { - gNB_MAC_INST *nrmac = RC.nrmac[Mod_idP]; if (!is_xlsch_in_slot(nrmac->ulsch_slot_bitmap[slotP / 64], slotP)) return; - NR_UE_info_t *UE_info = &nrmac->UE_info; - const NR_list_t *UE_list = &UE_info->list; - - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(nrmac->UE_info.list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; const int n = sizeof(sched_ctrl->sched_pucch) / sizeof(*sched_ctrl->sched_pucch); for (int i = 0; i < n; i++) { - NR_sched_pucch_t *curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[i]; + NR_sched_pucch_t *curr_pucch = &UE->UE_sched_ctrl.sched_pucch[i]; const uint16_t O_ack = curr_pucch->dai_c; const uint16_t O_csi = curr_pucch->csi_bits; const uint8_t O_sr = curr_pucch->sr_flag; @@ -162,9 +155,11 @@ void nr_schedule_pucch(int Mod_idP, || frameP != curr_pucch->frame || slotP != curr_pucch->ul_slot) continue; - if (O_csi > 0) LOG_D(NR_MAC,"Scheduling PUCCH[%d] RX for UE %d in %4d.%2d O_ack %d, O_sr %d, O_csi %d\n", - i,UE_id,curr_pucch->frame,curr_pucch->ul_slot,O_ack,O_sr,O_csi); - nr_fill_nfapi_pucch(Mod_idP, frameP, slotP, curr_pucch, UE_id); + + if (O_csi > 0) + LOG_D(NR_MAC,"Scheduling PUCCH[%d] RX for UE %04x in %4d.%2d O_ack %d, O_sr %d, O_csi %d\n", + i,UE->rnti,curr_pucch->frame,curr_pucch->ul_slot,O_ack,O_sr,O_csi); + nr_fill_nfapi_pucch(nrmac, frameP, slotP, curr_pucch, UE); memset(curr_pucch, 0, sizeof(*curr_pucch)); } } @@ -565,7 +560,7 @@ void compute_cqi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, //!TODO : same function can be written to handle csi_resources -void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_info, int UE_id, module_id_t Mod_idP){ +void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE){ uint8_t csi_report_id = 0; uint8_t nb_resources = 0; NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type; @@ -577,7 +572,7 @@ void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_in for (csi_report_id=0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ struct NR_CSI_ReportConfig *csi_reportconfig = csi_MeasConfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; // MAC structure for CSI measurement reports (per UE and per report) - nr_csi_report_t *csi_report = &UE_info->csi_report_template[UE_id][csi_report_id]; + nr_csi_report_t *csi_report = &UE->csi_report_template[csi_report_id]; // csi-ResourceConfigId of a CSI-ResourceConfig included in the configuration // (either CSI-RS or SSB) csi_ResourceConfigId = csi_reportconfig->resourcesForChannelMeasurement; @@ -662,24 +657,22 @@ void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_in } -uint16_t nr_get_csi_bitlen(int Mod_idP, - int UE_id, +uint16_t nr_get_csi_bitlen(NR_UE_info_t *UE, uint8_t csi_report_id) { uint16_t csi_bitlen = 0; uint16_t max_bitlen = 0; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; L1_RSRP_bitlen_t * CSI_report_bitlen = NULL; CSI_Meas_bitlen_t * csi_meas_bitlen = NULL; - if (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP==UE_info->csi_report_template[UE_id][csi_report_id].reportQuantity_type|| - NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP==UE_info->csi_report_template[UE_id][csi_report_id].reportQuantity_type){ - CSI_report_bitlen = &(UE_info->csi_report_template[UE_id][csi_report_id].CSI_report_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements + if (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP==UE->csi_report_template[csi_report_id].reportQuantity_type|| + NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP==UE->csi_report_template[csi_report_id].reportQuantity_type){ + CSI_report_bitlen = &(UE->csi_report_template[csi_report_id].CSI_report_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements csi_bitlen+= ((CSI_report_bitlen->cri_ssbri_bitlen * CSI_report_bitlen->nb_ssbri_cri) + CSI_report_bitlen->rsrp_bitlen +(CSI_report_bitlen->diff_rsrp_bitlen * (CSI_report_bitlen->nb_ssbri_cri -1 ))); } else{ - csi_meas_bitlen = &(UE_info->csi_report_template[UE_id][csi_report_id].csi_meas_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements + csi_meas_bitlen = &(UE->csi_report_template[csi_report_id].csi_meas_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements uint16_t temp_bitlen; for (int i=0; i<8; i++) { temp_bitlen = (csi_meas_bitlen->cri_bitlen+ @@ -705,11 +698,10 @@ void nr_csi_meas_reporting(int Mod_idP, NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_list_t *UE_list = &UE_info->list; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - const NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + + UE_iterator(RC.nrmac[Mod_idP]->UE_info.list, UE ) { + const NR_CellGroupConfig_t *CellGroup = UE->CellGroup; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if ((sched_ctrl->rrc_processing_timer > 0) || (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0)) { continue; } @@ -761,13 +753,13 @@ void nr_csi_meas_reporting(int Mod_idP, && !curr_pucch->sr_flag && curr_pucch->dai_c == 0, "PUCCH not free at index 1 for UE %04x\n", - UE_info->rnti[UE_id]); + UE->rnti); curr_pucch->r_pucch = -1; curr_pucch->frame = frame; curr_pucch->ul_slot = sched_slot; curr_pucch->resource_indicator = res_index; curr_pucch->csi_bits += - nr_get_csi_bitlen(Mod_idP,UE_id,csi_report_id); + nr_get_csi_bitlen(UE,csi_report_id); const NR_SIB1_t *sib1 = RC.nrmac[Mod_idP]->common_channels[0].sib1 ? RC.nrmac[Mod_idP]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, @@ -819,37 +811,37 @@ void nr_csi_meas_reporting(int Mod_idP, } } -__attribute__((unused)) -static void handle_dl_harq(module_id_t mod_id, - int UE_id, +static void handle_dl_harq(NR_UE_info_t * UE, int8_t harq_pid, - bool success) + bool success, + int harq_round_max) { - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_harq_t *harq = &UE_info->UE_sched_ctrl[UE_id].harq_processes[harq_pid]; + NR_UE_harq_t *harq = &UE->UE_sched_ctrl.harq_processes[harq_pid]; harq->feedback_slot = -1; harq->is_waiting = false; if (success) { - add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].available_dl_harq, harq_pid); + add_tail_nr_list(&UE->UE_sched_ctrl.available_dl_harq, harq_pid); harq->round = 0; harq->ndi ^= 1; - } else if (harq->round >= RC.nrmac[mod_id]->harq_round_max - 1) { - add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].available_dl_harq, harq_pid); + + } else if (harq->round >= harq_round_max - 1) { + add_tail_nr_list(&UE->UE_sched_ctrl.available_dl_harq, harq_pid); harq->round = 0; harq->ndi ^= 1; - NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; + + NR_mac_stats_t *stats = &UE->mac_stats; stats->dl.errors++; - LOG_D(NR_MAC, "retransmission error for UE %d (total %"PRIu64")\n", UE_id, stats->dl.errors); + LOG_D(NR_MAC, "retransmission error for UE %04x (total %"PRIu64")\n", UE->rnti, stats->dl.errors); + } else { - LOG_D(PHY,"NACK for: pid %d, ue %x\n",harq_pid, UE_id); - add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].retrans_dl_harq, harq_pid); + LOG_D(PHY,"NACK for: pid %d, ue %04x\n",harq_pid, UE->rnti); + add_tail_nr_list(&UE->UE_sched_ctrl.retrans_dl_harq, harq_pid); harq->round++; } } -int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, int Mod_idP, int UE_id) { - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id] ; +int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, NR_UE_info_t * UE) { + NR_CellGroupConfig_t *CellGroup = UE->CellGroup; int nb_tci_states = CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.count; NR_TCI_State_t *tci =NULL; int i; @@ -874,13 +866,12 @@ int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, int Mod_idP, i return -1; } -int checkTargetSSBInTCIStates_pdcchConfig(int ssb_index_t, int Mod_idP, int UE_id) { - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id] ; +int checkTargetSSBInTCIStates_pdcchConfig(int ssb_index_t, NR_UE_info_t *UE) { + NR_CellGroupConfig_t *CellGroup = UE->CellGroup ; int nb_tci_states = CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.count; NR_TCI_State_t *tci =NULL; NR_TCI_StateId_t *tci_id = NULL; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_ControlResourceSet_t *coreset = sched_ctrl->coreset; int i; int flag = 0; @@ -935,7 +926,7 @@ int get_diff_rsrp(uint8_t index, int strongest_rsrp) { //identifies the target SSB Beam index //keeps the required date for PDCCH and PDSCH TCI state activation/deactivation CE consutruction globally //handles triggering of PDCCH and PDSCH MAC CEs -void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { +void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { int strongest_ssb_rsrp = 0; int cqi_idx = 0; @@ -947,10 +938,10 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { int ssb_index[MAX_NUM_SSB] = {0}; int ssb_rsrp[MAX_NUM_SSB] = {0}; uint8_t idx = 0; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; + + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + const int bwp_id = sched_ctrl->active_bwp ? 1 : 0; + NR_CellGroupConfig_t *CellGroup = UE->CellGroup; //bwp indicator int n_dl_bwp=0; @@ -960,7 +951,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { n_dl_bwp = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; uint8_t nr_ssbri_cri = 0; - uint8_t nb_of_csi_ssb_report = UE_info->csi_report_template[UE_id][cqi_idx].nb_of_csi_ssb_report; + uint8_t nb_of_csi_ssb_report = UE->csi_report_template[cqi_idx].nb_of_csi_ssb_report; int better_rsrp_reported = -140-(-0); /*minimum_measured_RSRP_value - minimum_differntail_RSRP_value*///considering the minimum RSRP value as better RSRP initially uint8_t diff_rsrp_idx = 0; uint8_t i, j; @@ -1031,7 +1022,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { The length of the field is 7 bits */ if(sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.coresetId == 0) { - int tci_state_id = checkTargetSSBInFirst64TCIStates_pdschConfig(ssb_index[target_ssb_beam_index], Mod_idP, UE_id); + int tci_state_id = checkTargetSSBInFirst64TCIStates_pdschConfig(ssb_index[target_ssb_beam_index], UE); if( tci_state_id != -1) sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tciStateId = tci_state_id; @@ -1041,7 +1032,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { int flag = 0; for(i =0; ssb_index_sorted[i]!=0; i++) { - tci_state_id = checkTargetSSBInFirst64TCIStates_pdschConfig(ssb_index_sorted[i], Mod_idP, UE_id) ; + tci_state_id = checkTargetSSBInFirst64TCIStates_pdschConfig(ssb_index_sorted[i],UE) ; if(tci_state_id != -1 && ssb_rsrp_sorted[i] > ssb_rsrp[curr_ssb_beam_index] && ssb_rsrp_sorted[i] - ssb_rsrp[curr_ssb_beam_index] > L1_RSRP_HYSTERIS) { sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tciStateId = tci_state_id; @@ -1055,7 +1046,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { } } } else { - int tci_state_id = checkTargetSSBInTCIStates_pdcchConfig(ssb_index[target_ssb_beam_index], Mod_idP, UE_id); + int tci_state_id = checkTargetSSBInTCIStates_pdcchConfig(ssb_index[target_ssb_beam_index], UE); if (tci_state_id !=-1) sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tciStateId = tci_state_id; @@ -1065,7 +1056,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { int flag = 0; for(i =0; ssb_index_sorted[i]!=0; i++) { - tci_state_id = checkTargetSSBInTCIStates_pdcchConfig(ssb_index_sorted[i], Mod_idP, UE_id); + tci_state_id = checkTargetSSBInTCIStates_pdcchConfig(ssb_index_sorted[i], UE); if( tci_state_id != -1 && ssb_rsrp_sorted[i] > ssb_rsrp[curr_ssb_beam_index] && ssb_rsrp_sorted[i] - ssb_rsrp[curr_ssb_beam_index] > L1_RSRP_HYSTERIS) { sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tciStateId = tci_state_id; @@ -1126,15 +1117,14 @@ uint8_t pickandreverse_bits(uint8_t *payload, uint16_t bitlen, uint8_t start_bit } -void evaluate_rsrp_report(NR_UE_info_t *UE_info, +void evaluate_rsrp_report(NR_UE_info_t *UE, NR_UE_sched_ctrl_t *sched_ctrl, - int UE_id, uint8_t csi_report_id, uint8_t *payload, int *cumul_bits, NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type){ - nr_csi_report_t *csi_report = &UE_info->csi_report_template[UE_id][csi_report_id]; + nr_csi_report_t *csi_report = &UE->csi_report_template[csi_report_id]; uint8_t cri_ssbri_bitlen = csi_report->CSI_report_bitlen.cri_ssbri_bitlen; uint16_t curr_payload; @@ -1186,7 +1176,7 @@ void evaluate_rsrp_report(NR_UE_info_t *UE_info, } csi_report->nb_of_csi_ssb_report++; int strongest_ssb_rsrp = get_measured_rsrp(sched_ctrl->CSI_report.ssb_cri_report.RSRP); - NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; + NR_mac_stats_t *stats = &UE->mac_stats; // including ssb rsrp in mac stats stats->cumul_rsrp += strongest_ssb_rsrp; stats->num_rsrp_meas++; @@ -1324,22 +1314,19 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu, frame_t frame, slot_t slot, - int UE_id, - module_id_t Mod_idP) { - + NR_UE_info_t *UE, + NR_ServingCellConfigCommon_t *scc) +{ /** From Table 6.3.1.1.2-3: RI, LI, CQI, and CRI of codebookType=typeI-SinglePanel */ - NR_ServingCellConfigCommon_t *scc = - RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; uint8_t *payload = uci_pdu->csi_part1.csi_part1_payload; uint16_t bitlen = uci_pdu->csi_part1.csi_part1_bit_len; NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type = NR_CSI_ReportConfig__reportQuantity_PR_NOTHING; - NR_UE_info_t *UE_info = &(RC.nrmac[Mod_idP]->UE_info); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; int cumul_bits = 0; int r_index = -1; for (int csi_report_id = 0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++ ) { - nr_csi_report_t *csi_report = &UE_info->csi_report_template[UE_id][csi_report_id]; + nr_csi_report_t *csi_report = &UE->csi_report_template[csi_report_id]; csi_report->nb_of_csi_ssb_report = 0; uint8_t cri_bitlen = 0; uint8_t ri_bitlen = 0; @@ -1354,10 +1341,10 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, LOG_D(MAC,"SFN/SF:%d/%d reportQuantity type = %d\n",frame,slot,reportQuantity_type); switch(reportQuantity_type){ case NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP: - evaluate_rsrp_report(UE_info,sched_ctrl,UE_id,csi_report_id,payload,&cumul_bits,reportQuantity_type); + evaluate_rsrp_report(UE,sched_ctrl,csi_report_id,payload,&cumul_bits,reportQuantity_type); break; case NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP: - evaluate_rsrp_report(UE_info,sched_ctrl,UE_id,csi_report_id,payload,&cumul_bits,reportQuantity_type); + evaluate_rsrp_report(UE,sched_ctrl,csi_report_id,payload,&cumul_bits,reportQuantity_type); break; case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_CQI: cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; @@ -1413,7 +1400,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, } } -static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t slot, int UE_id) +static NR_UE_harq_t *find_harq(frame_t frame, sub_frame_t slot, NR_UE_info_t * UE, int harq_round_max) { /* In case of realtime problems: we can only identify a HARQ process by * timing. If the HARQ process's feedback_frame/feedback_slot is not the one we @@ -1421,7 +1408,7 @@ static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t sl * skip this HARQ process, which is what happens in the loop below. * Similarly, we might be "in advance", in which case we need to skip * this result. */ - NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[mod_id]->UE_info.UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; int8_t pid = sched_ctrl->feedback_dl_harq.head; if (pid < 0) return NULL; @@ -1437,7 +1424,7 @@ static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t sl frame, slot); remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - handle_dl_harq(mod_id, UE_id, pid, 0); + handle_dl_harq(UE, pid, 0, harq_round_max); pid = sched_ctrl->feedback_dl_harq.head; if (pid < 0) return NULL; @@ -1462,20 +1449,19 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, sub_frame_t slot, const nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_01) { - int UE_id = find_nr_UE_id(mod_id, uci_01->rnti); - if (UE_id < 0) { + NR_UE_info_t * UE = find_nr_UE(&RC.nrmac[mod_id]->UE_info, uci_01->rnti); + if (!UE) { LOG_E(NR_MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_01->rnti); return; } - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (((uci_01->pduBitmap >> 1) & 0x01)) { // iterate over received harq bits for (int harq_bit = 0; harq_bit < uci_01->harq->num_harq; harq_bit++) { const uint8_t harq_value = uci_01->harq->harq_list[harq_bit].harq_value; const uint8_t harq_confidence = uci_01->harq->harq_confidence_level; - NR_UE_harq_t *harq = find_harq(mod_id, frame, slot, UE_id); + NR_UE_harq_t *harq = find_harq(frame, slot, UE, RC.nrmac[mod_id]->harq_round_max); if (!harq) { LOG_E(NR_MAC, "Oh no! Could not find a harq in %s!\n", __FUNCTION__); break; @@ -1484,8 +1470,8 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, const int8_t pid = sched_ctrl->feedback_dl_harq.head; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); LOG_D(NR_MAC,"%4d.%2d bit %d pid %d ack/nack %d\n",frame, slot, harq_bit,pid,harq_value); - handle_dl_harq(mod_id, UE_id, pid, harq_value == 0 && harq_confidence == 0); - if (harq_confidence == 1) UE_info->mac_stats[UE_id].pucch0_DTX++; + handle_dl_harq(UE, pid, harq_value == 0 && harq_confidence == 0, RC.nrmac[mod_id]->harq_round_max); + if (harq_confidence == 1) UE->mac_stats.pucch0_DTX++; } } @@ -1510,19 +1496,21 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, sub_frame_t slot, const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_234) { - int UE_id = find_nr_UE_id(mod_id, uci_234->rnti); - if (UE_id < 0) { + NR_UE_info_t * UE = find_nr_UE(&RC.nrmac[mod_id]->UE_info, uci_234->rnti); + if (!UE) { LOG_E(NR_MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_234->rnti); return; } - AssertFatal(RC.nrmac[mod_id]->UE_info.CellGroup[UE_id],"Cellgroup is null for UE %d/%x\n",UE_id,uci_234->rnti); - AssertFatal(RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig, "Cellgroup->spCellConfig is null for UE %d/%x\n",UE_id,uci_234->rnti); - AssertFatal(RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated, "Cellgroup->spCellConfig->spCellConfigDedicated is null for UE %d/%x\n",UE_id,uci_234->rnti); - if ( RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->csi_MeasConfig==NULL) return; + AssertFatal(UE->CellGroup,"Cellgroup is null for UE %04x\n", uci_234->rnti); + AssertFatal(UE->CellGroup->spCellConfig, + "Cellgroup->spCellConfig is null for UE %04x\n", uci_234->rnti); + AssertFatal(UE->CellGroup->spCellConfig->spCellConfigDedicated, + "Cellgroup->spCellConfig->spCellConfigDedicated is null for UE %04x\n", uci_234->rnti); + if ( UE->CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig==NULL) + return; - NR_CSI_MeasConfig_t *csi_MeasConfig = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_CSI_MeasConfig_t *csi_MeasConfig = UE->CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; // tpc (power control) // TODO PUCCH2 SNR computation is not correct -> ignore the following @@ -1535,20 +1523,20 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, // iterate over received harq bits for (int harq_bit = 0; harq_bit < uci_234->harq.harq_bit_len; harq_bit++) { const int acknack = ((uci_234->harq.harq_payload[harq_bit >> 3]) >> harq_bit) & 0x01; - NR_UE_harq_t *harq = find_harq(mod_id, frame, slot, UE_id); + NR_UE_harq_t *harq = find_harq(frame, slot, UE, RC.nrmac[mod_id]->harq_round_max); if (!harq) break; DevAssert(harq->is_waiting); const int8_t pid = sched_ctrl->feedback_dl_harq.head; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - handle_dl_harq(mod_id, UE_id, pid, uci_234->harq.harq_crc != 1 && acknack); + handle_dl_harq(UE, pid, uci_234->harq.harq_crc != 1 && acknack, RC.nrmac[mod_id]->harq_round_max); } } if ((uci_234->pduBitmap >> 2) & 0x01) { //API to parse the csi report and store it into sched_ctrl - extract_pucch_csi_report(csi_MeasConfig, uci_234, frame, slot, UE_id, mod_id); + extract_pucch_csi_report(csi_MeasConfig, uci_234, frame, slot, UE, RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon); //TCI handling function - tci_handling(mod_id, UE_id,frame, slot); + tci_handling(UE,frame, slot); } if ((uci_234->pduBitmap >> 3) & 0x01) { //@TODO:Handle CSI Report 2 @@ -1616,12 +1604,11 @@ bool test_acknack_vrb_occupation(NR_UE_sched_ctrl_t *sched_ctrl, // if the function returns -1 it was not possible to schedule acknack // when current pucch is ready to be scheduled nr_fill_nfapi_pucch is called int nr_acknack_scheduling(int mod_id, - int UE_id, + NR_UE_info_t * UE, frame_t frame, sub_frame_t slot, int r_pucch, int is_common) { - const int CC_id = 0; const int minfbtime = RC.nrmac[mod_id]->minRXTXTIMEpdsch; const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels[CC_id].ServingCellConfigCommon; @@ -1639,8 +1626,8 @@ int nr_acknack_scheduling(int mod_id, * * SR uses format 0 and is allocated in the first UL (mixed) slot (and not * later) * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ - NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[mod_id]->UE_info.UE_sched_ctrl[UE_id]; - NR_CellGroupConfig_t *cg = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_CellGroupConfig_t *cg = UE->CellGroup; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { @@ -1675,11 +1662,13 @@ int nr_acknack_scheduling(int mod_id, const int f = pucch->frame; const int s = pucch->ul_slot; LOG_D(NR_MAC, "In %s: %4d.%2d DAI = 2 pucch currently in %4d.%2d, advancing by 1 slot\n", __FUNCTION__, frame, slot, f, s); - if (!(csi_pucch - && csi_pucch->csi_bits > 0 - && csi_pucch->frame == f - && csi_pucch->ul_slot == s)) - nr_fill_nfapi_pucch(mod_id, frame, slot, pucch, UE_id); + + if (!(csi_pucch + && csi_pucch->csi_bits > 0 + && csi_pucch->frame == f + && csi_pucch->ul_slot == s)) + nr_fill_nfapi_pucch(RC.nrmac[mod_id], frame, slot, pucch, UE); + memset(pucch, 0, sizeof(*pucch)); pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; if(((s + 1)%nr_slots_period) == 0) @@ -1696,7 +1685,8 @@ int nr_acknack_scheduling(int mod_id, && csi_pucch->ul_slot == pucch->ul_slot && !csi_pucch->simultaneous_harqcsi) { LOG_D(NR_MAC,"Cannot multiplex csi_pucch for %d.%d\n",csi_pucch->frame,csi_pucch->ul_slot); - nr_fill_nfapi_pucch(mod_id, frame, slot, csi_pucch, UE_id); + nr_fill_nfapi_pucch(RC.nrmac[mod_id], frame, slot, csi_pucch, UE); + memset(csi_pucch, 0, sizeof(*csi_pucch)); pucch->frame = pucch->ul_slot == n_slots_frame - 1 ? (pucch->frame + 1) % 1024 : pucch->frame; if(((pucch->ul_slot + 1)%nr_slots_period) == 0) @@ -1723,7 +1713,7 @@ int nr_acknack_scheduling(int mod_id, const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; int max_fb_time = 0; - get_pdsch_to_harq_feedback(mod_id, UE_id, bwp_id, ss_type, &max_fb_time, pdsch_to_harq_feedback); + get_pdsch_to_harq_feedback(UE, bwp_id, ss_type, &max_fb_time, pdsch_to_harq_feedback); LOG_D(NR_MAC, "In %s: 1b. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c); /* there is a HARQ. Check whether we can use it for this ACKNACK */ @@ -1750,14 +1740,14 @@ int nr_acknack_scheduling(int mod_id, csi_pucch->csi_bits > 0 && csi_pucch->frame == f && csi_pucch->ul_slot == s)) - nr_fill_nfapi_pucch(mod_id, frame, slot, pucch, UE_id); + nr_fill_nfapi_pucch(RC.nrmac[mod_id], frame, slot, pucch, UE); memset(pucch, 0, sizeof(*pucch)); pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; if(((s + 1)%nr_slots_period) == 0) pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; else pucch->ul_slot = (s + 1) % n_slots_frame; - return nr_acknack_scheduling(mod_id, UE_id, frame, slot, r_pucch,is_common); + return nr_acknack_scheduling(mod_id, UE, frame, slot, r_pucch,is_common); } pucch->timing_indicator = i; @@ -1783,10 +1773,11 @@ int nr_acknack_scheduling(int mod_id, ((pucch->frame*n_slots_frame + pucch->ul_slot) < (frame*n_slots_frame + slot))) { AssertFatal(pucch->sr_flag + pucch->dai_c == 0, - "expected no SR/AckNack for UE %d in %4d.%2d, but has %d/%d for %4d.%2d\n", - UE_id, frame, slot, pucch->sr_flag, pucch->dai_c, pucch->frame, pucch->ul_slot); + "expected no SR/AckNack for UE %04x in %4d.%2d, but has %d/%d for %4d.%2d\n", + UE->rnti, frame, slot, pucch->sr_flag, pucch->dai_c, pucch->frame, pucch->ul_slot); const int s = next_ul_slot; pucch->frame = s < n_slots_frame ? frame : (frame + 1) % 1024; + pucch->ul_slot = s % n_slots_frame; } @@ -1834,11 +1825,11 @@ int nr_acknack_scheduling(int mod_id, } if (ind_found==-1) { LOG_D(NR_MAC, - "%4d.%2d could not find pdsch_to_harq_feedback for UE %d: earliest " + "%4d.%2d could not find pdsch_to_harq_feedback for UE %04x: earliest " "ack slot %d\n", frame, slot, - UE_id, + UE->rnti, pucch->ul_slot); return -1; } @@ -1852,8 +1843,9 @@ int nr_acknack_scheduling(int mod_id, // FIXME currently we support at most 11 bits in pucch2 so skip also in that case if(!csi_pucch->simultaneous_harqcsi || ((csi_pucch->csi_bits + csi_pucch->dai_c) >= 11)) { + LOG_D(NR_MAC,"Cannot multiplex csi_pucch %d +csi_pucch->dai_c %d for %d.%d\n",csi_pucch->csi_bits,csi_pucch->dai_c,csi_pucch->frame,csi_pucch->ul_slot); - nr_fill_nfapi_pucch(mod_id, frame, slot, csi_pucch, UE_id); + nr_fill_nfapi_pucch(RC.nrmac[mod_id], frame, slot, csi_pucch, UE); memset(csi_pucch, 0, sizeof(*csi_pucch)); /* advance the UL slot information in PUCCH by one so we won't schedule in * the same slot again */ @@ -1865,7 +1857,7 @@ int nr_acknack_scheduling(int mod_id, pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; else pucch->ul_slot = (s + 1) % n_slots_frame; - return nr_acknack_scheduling(mod_id, UE_id, frame, slot, r_pucch,is_common); + return nr_acknack_scheduling(mod_id, UE, frame, slot, r_pucch,is_common); } // multiplexing harq and csi in a pucch else { @@ -1902,29 +1894,26 @@ int nr_acknack_scheduling(int mod_id, } -void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) +void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t SFN, sub_frame_t slot) { - gNB_MAC_INST *nrmac = RC.nrmac[Mod_idP]; if (!is_xlsch_in_slot(nrmac->ulsch_slot_bitmap[slot / 64], slot)) return; NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - NR_UE_info_t *UE_info = &nrmac->UE_info; - NR_list_t *UE_list = &UE_info->list; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(nrmac->UE_info.list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->ul_failure==1) continue; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - } else if (RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id] && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + } else if (UE->CellGroup && + UE->CellGroup->spCellConfig && + UE->CellGroup->spCellConfig->spCellConfigDedicated && + UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && + UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && + UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { + pucch_Config = UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } else continue; @@ -1971,7 +1960,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) continue; nfapi_nr_pucch_pdu_t *pdu = &ul_tti_req->pdus_list[i].pucch_pdu; /* check that it is our PUCCH F0. Assuming there can be only one */ - if (pdu->rnti == UE_info->rnti[UE_id] + if (pdu->rnti == UE->rnti && pdu->format_type == 0 // does not use NR_PUCCH_Resource__format_PR_format0 && pdu->initial_cyclic_shift == pucch_res->format.choice.format0->initialCyclicShift && pdu->nr_of_symbols == pucch_res->format.choice.format0->nrofSymbols @@ -1981,7 +1970,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) nfapi_allocated = true; break; } - else if (pdu->rnti == UE_info->rnti[UE_id] + else if (pdu->rnti == UE->rnti && pdu->format_type == 2 // does not use NR_PUCCH_Resource__format_PR_format0 && pdu->nr_of_symbols == pucch_res->format.choice.format2->nrofSymbols && pdu->start_symbol_index == pucch_res->format.choice.format2->startingSymbolIndex) { @@ -1991,7 +1980,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) break; } - else if (pdu->rnti == UE_info->rnti[UE_id] + else if (pdu->rnti == UE->rnti && pdu->format_type == 1 // does not use NR_PUCCH_Resource__format_PR_format0 && pdu->nr_of_symbols == pucch_res->format.choice.format1->nrofSymbols && pdu->start_symbol_index == pucch_res->format.choice.format1->startingSymbolIndex) { @@ -2001,7 +1990,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) break; } - else if (pdu->rnti == UE_info->rnti[UE_id] + else if (pdu->rnti == UE->rnti && pdu->format_type == 3 // does not use NR_PUCCH_Resource__format_PR_format0 && pdu->nr_of_symbols == pucch_res->format.choice.format3->nrofSymbols && pdu->start_symbol_index == pucch_res->format.choice.format3->startingSymbolIndex) { @@ -2011,7 +2000,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) break; } - else if (pdu->rnti == UE_info->rnti[UE_id] + else if (pdu->rnti == UE->rnti && pdu->format_type == 4 // does not use NR_PUCCH_Resource__format_PR_format0 && pdu->nr_of_symbols == pucch_res->format.choice.format4->nrofSymbols && pdu->start_symbol_index == pucch_res->format.choice.format4->startingSymbolIndex) { @@ -2043,7 +2032,7 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) .resource_indicator = found, .r_pucch = -1 }; - nr_fill_nfapi_pucch(Mod_idP, SFN, slot, &sched_sr, UE_id); + nr_fill_nfapi_pucch(nrmac, SFN, slot, &sched_sr, UE); } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 591a549c0a..f2f50d86c6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -84,8 +84,8 @@ const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon // F: length of L is 0:8 or 1:16 bits wide // R: Reserved bit, set to zero. -int nr_process_mac_pdu(module_id_t module_idP, - int UE_id, +int nr_process_mac_pdu( instance_t module_idP, + NR_UE_info_t* UE, uint8_t CC_id, frame_t frameP, sub_frame_t slot, @@ -96,11 +96,10 @@ int nr_process_mac_pdu(module_id_t module_idP, uint8_t done = 0; - NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if ( pduP[0] != UL_SCH_LCID_PADDING ) - trace_NRpdu(DIRECTION_UPLINK, pduP, pdu_len, UE_id, WS_C_RNTI, UE_info->rnti[UE_id], frameP, 0, 0, 0); + trace_NRpdu(DIRECTION_UPLINK, pduP, pdu_len, WS_C_RNTI, UE->rnti, frameP, 0, 0, 0); #ifdef ENABLE_MAC_PAYLOAD_DEBUG LOG_I(NR_MAC, "In %s: dumping MAC PDU in %d.%d:\n", __func__, frameP, slot); @@ -197,7 +196,7 @@ int nr_process_mac_pdu(module_id_t module_idP, for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i]; - if (ra->state >= WAIT_Msg3 && ra->rnti == UE_info->rnti[UE_id]) { + if (ra->state >= WAIT_Msg3 && ra->rnti == UE->rnti) { ra->crnti = ((pduP[1]&0xFF)<<8)|(pduP[2]&0xFF); ra->msg3_dcch_dtch = true; LOG_I(NR_MAC, "Received UL_SCH_LCID_C_RNTI with C-RNTI 0x%04x\n", ra->crnti); @@ -258,22 +257,23 @@ int nr_process_mac_pdu(module_id_t module_idP, if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) return 0; - rnti_t crnti = UE_info->rnti[UE_id]; - int UE_idx = UE_id; + rnti_t crnti = UE->rnti; + NR_UE_info_t* UE_idx = UE; for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i]; - if (ra->state >= WAIT_Msg3 && ra->rnti == UE_info->rnti[UE_id]) { + if (ra->state >= WAIT_Msg3 && ra->rnti == UE->rnti) { uint8_t *next_subpduP = pduP + mac_subheader_len + mac_len; if ((pduP[mac_subheader_len+mac_len] & 0x3F) == UL_SCH_LCID_C_RNTI) { crnti = ((next_subpduP[1]&0xFF)<<8)|(next_subpduP[2]&0xFF); - UE_idx = find_nr_UE_id(module_idP, crnti); + LOG_W(NR_MAC, " UL_SCH_LCID_SRB for rnti %04x\n", crnti); + UE_idx = find_nr_UE(&RC.nrmac[module_idP]->UE_info, crnti); break; } } } - if (UE_info->CellGroup[UE_idx]) { - LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: 0x%04x \n", module_idP, frameP, rx_lcid, module_idP, mac_len, crnti); + if (UE_idx->CellGroup) { + LOG_D(NR_MAC, "Frame %d : ULSCH -> UL-DCCH %d (gNB %ld, %d bytes), rnti: 0x%04x \n", frameP, rx_lcid, module_idP, mac_len, crnti); mac_rlc_data_ind(module_idP, crnti, module_idP, @@ -286,7 +286,7 @@ int nr_process_mac_pdu(module_id_t module_idP, 1, NULL); } else { - AssertFatal(1==0,"[UE %d] Frame/Slot %d.%d : Received LCID %d which is not configured, dropping packet\n",UE_id,frameP,slot,rx_lcid); + AssertFatal(1==0,"[UE %04x] Frame/Slot %d.%d : Received LCID %d which is not configured, dropping packet\n",UE->rnti,frameP,slot,rx_lcid); } break; case UL_SCH_LCID_SRB3: @@ -324,7 +324,7 @@ int nr_process_mac_pdu(module_id_t module_idP, frameP, 0, 0, - UE_info->rnti[UE_id], + UE->rnti, CCCH, pduP + mac_subheader_len, mac_len, @@ -336,18 +336,19 @@ int nr_process_mac_pdu(module_id_t module_idP, if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) return 0; - LOG_D(NR_MAC, "[UE %x] %d.%d: ULSCH -> UL-%s %d (gNB %d, %d bytes)\n", - UE_info->rnti[UE_id], + + LOG_D(NR_MAC, "[UE %04x] %d.%d : ULSCH -> UL-%s %d (gNB %ld, %d bytes)\n", + UE->rnti, frameP, slot, rx_lcid<4?"DCCH":"DTCH", rx_lcid, module_idP, mac_len); - UE_info->mac_stats[UE_id].ul.lc_bytes[rx_lcid] += mac_len; + UE->mac_stats.ul.lc_bytes[rx_lcid] += mac_len; mac_rlc_data_ind(module_idP, - UE_info->rnti[UE_id], + UE->rnti, module_idP, frameP, ENB_FLAG_YES, @@ -398,15 +399,14 @@ int nr_process_mac_pdu(module_id_t module_idP, return 0; } -void abort_nr_ul_harq(module_id_t mod_id, int UE_id, int8_t harq_pid) +void abort_nr_ul_harq( NR_UE_info_t* UE, int8_t harq_pid) { - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_ul_harq_t *harq = &sched_ctrl->ul_harq_processes[harq_pid]; harq->ndi ^= 1; harq->round = 0; - UE_info->mac_stats[UE_id].ul.errors++; + UE->mac_stats.ul.errors++; add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); /* the transmission failed: the UE won't send the data we expected initially, @@ -422,11 +422,11 @@ void handle_nr_ul_harq(const int CC_idP, sub_frame_t slot, const nfapi_nr_crc_t *crc_pdu) { - gNB_MAC_INST *gNB_mac = RC.nrmac[mod_id]; - int UE_id = find_nr_UE_id(mod_id, crc_pdu->rnti); - if (UE_id < 0) { + NR_UE_info_t* UE = find_nr_UE(&RC.nrmac[mod_id]->UE_info, crc_pdu->rnti); + if (!UE) { + LOG_W(NR_MAC, "handle harq for rnti %04x, in RA process\n", crc_pdu->rnti); for (int i = 0; i < NR_NB_RA_PROC_MAX; ++i) { - NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[i]; + NR_RA_t *ra = &RC.nrmac[mod_id]->common_channels[CC_idP].ra[i]; if (ra->state >= WAIT_Msg3 && ra->rnti == crc_pdu->rnti) return; @@ -434,8 +434,7 @@ void handle_nr_ul_harq(const int CC_idP, LOG_E(NR_MAC, "%s(): unknown RNTI 0x%04x in PUSCH\n", __func__, crc_pdu->rnti); return; } - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; int8_t harq_pid = sched_ctrl->feedback_ul_harq.head; LOG_D(NR_MAC, "Comparing crc_pdu->harq_id vs feedback harq_pid = %d %d\n",crc_pdu->harq_id, harq_pid); while (crc_pdu->harq_id != harq_pid || harq_pid < 0) { @@ -449,8 +448,9 @@ void handle_nr_ul_harq(const int CC_idP, remove_front_nr_list(&sched_ctrl->feedback_ul_harq); sched_ctrl->ul_harq_processes[harq_pid].is_waiting = false; - if(sched_ctrl->ul_harq_processes[harq_pid].round >= gNB_mac->harq_round_max - 1) { - abort_nr_ul_harq(mod_id, UE_id, harq_pid); + + if(sched_ctrl->ul_harq_processes[harq_pid].round >= RC.nrmac[mod_id]->harq_round_max - 1) { + abort_nr_ul_harq(UE, harq_pid); } else { sched_ctrl->ul_harq_processes[harq_pid].round++; add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid); @@ -470,8 +470,8 @@ void handle_nr_ul_harq(const int CC_idP, harq_pid, crc_pdu->rnti); add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); - } else if (harq->round >= gNB_mac->harq_round_max - 1) { - abort_nr_ul_harq(mod_id, UE_id, harq_pid); + } else if (harq->round >= RC.nrmac[mod_id]->harq_round_max - 1) { + abort_nr_ul_harq(UE, harq_pid); LOG_D(NR_MAC, "RNTI %04x: Ulharq id %d crc failed in all rounds\n", crc_pdu->rnti, @@ -501,15 +501,15 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, const uint16_t rssi){ gNB_MAC_INST *gNB_mac = RC.nrmac[gnb_mod_idP]; - NR_UE_info_t *UE_info = &gNB_mac->UE_info; const int current_rnti = rntiP; - const int UE_id = find_nr_UE_id(gnb_mod_idP, current_rnti); + LOG_D(NR_MAC, "rx_sdu for rnti %04x\n", current_rnti); const int target_snrx10 = gNB_mac->pusch_target_snrx10; const int pusch_failure_thres = gNB_mac->pusch_failure_thres; - - if (UE_id != -1) { - NR_UE_sched_ctrl_t *UE_scheduling_control = &UE_info->UE_sched_ctrl[UE_id]; + + NR_UE_info_t* UE = find_nr_UE(&gNB_mac->UE_info, current_rnti); + if (UE) { + NR_UE_sched_ctrl_t *UE_scheduling_control = &UE->UE_sched_ctrl; const int8_t harq_pid = UE_scheduling_control->feedback_ul_harq.head; if (sduP) @@ -517,15 +517,14 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(harq_pid), T_BUFFER(sduP, sdu_lenP)); - UE_info->mac_stats[UE_id].ul.total_bytes += sdu_lenP; - LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d TA %d sduP %p, rssi %d\n", + UE->mac_stats.ul.total_bytes += sdu_lenP; + LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %04x) ul_cqi %d TA %d sduP %p, rssi %d\n", gnb_mod_idP, harq_pid, CC_idP, frameP, slotP, current_rnti, - UE_id, ul_cqi, timing_advance, sduP, @@ -538,11 +537,13 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_scheduling_control->ta_update = timing_advance; UE_scheduling_control->raw_rssi = rssi; UE_scheduling_control->pusch_snrx10 = ul_cqi * 5 - 640; - LOG_D(NR_MAC, "[UE %d] PUSCH TPC %d(SNRx10 %d) and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->pusch_snrx10,UE_scheduling_control->ta_update); + + LOG_D(NR_MAC, "[UE %04x] PUSCH TPC %d and TA %d\n",UE->rnti,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); } else{ - LOG_D(NR_MAC,"[UE %d] Detected DTX : increasing UE TX power\n",UE_id); + LOG_D(NR_MAC,"[UE %04x] Detected DTX : increasing UE TX power\n",UE->rnti); UE_scheduling_control->tpc0 = 1; + } #if defined(ENABLE_MAC_PAYLOAD_DEBUG) @@ -560,13 +561,13 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, if (sduP != NULL){ LOG_D(NR_MAC, "Received PDU at MAC gNB \n"); - UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt = 0; + UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt = 0; const uint32_t tb_size = UE_scheduling_control->ul_harq_processes[harq_pid].sched_pusch.tb_size; UE_scheduling_control->sched_ul_bytes -= tb_size; if (UE_scheduling_control->sched_ul_bytes < 0) UE_scheduling_control->sched_ul_bytes = 0; - nr_process_mac_pdu(gnb_mod_idP, UE_id, CC_idP, frameP, slotP, sduP, sdu_lenP); + nr_process_mac_pdu(gnb_mod_idP, UE, CC_idP, frameP, slotP, sduP, sdu_lenP); } else { NR_UE_ul_harq_t *cur_harq = &UE_scheduling_control->ul_harq_processes[harq_pid]; @@ -578,13 +579,15 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_scheduling_control->sched_ul_bytes = 0; } if (ul_cqi <= 128) { - UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt++; - UE_info->mac_stats[UE_id].ulsch_DTX++; + UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt++; + UE->mac_stats.ulsch_DTX++; } - if (!get_softmodem_params()->phy_test && UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt >= pusch_failure_thres) { - LOG_W(NR_MAC,"%d.%d Detected UL Failure on PUSCH after %d PUSCH DTX, stopping scheduling\n", - frameP,slotP,UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt); - UE_info->UE_sched_ctrl[UE_id].ul_failure = 1; + + if (!get_softmodem_params()->phy_test && UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt >= pusch_failure_thres) { + LOG_W(NR_MAC,"Detected UL Failure on PUSCH after %d PUSCH DTX, stopping scheduling\n", + UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt); + UE->UE_sched_ctrl.ul_failure = 1; + nr_mac_gNB_rrc_ul_failure(gnb_mod_idP,CC_idP,frameP,slotP,rntiP); } } @@ -605,7 +608,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, T(T_GNB_MAC_UL_PDU_WITH_DATA, T_INT(gnb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(-1) /* harq_pid */, T_BUFFER(sduP, sdu_lenP)); - + /* we don't know this UE (yet). Check whether there is a ongoing RA (Msg 3) * and check the corresponding UE's RNTI match, in which case we activate * it. */ @@ -613,7 +616,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[i]; if (ra->state != WAIT_Msg3) continue; - + if(no_sig) { LOG_D(NR_MAC, "Random Access %i failed at state %i (no signal)\n", i, ra->state); nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); @@ -636,20 +639,20 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, continue; } - int UE_id=-1; - UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti, ra->CellGroup); - if (UE_id<0) { - LOG_D(NR_MAC, "Random Access %i discarded at state %i (TC_RNTI %04x RNTI %04x): max number of users achieved!\n", i, ra->state,ra->rnti,current_rnti); + NR_UE_info_t* UE = add_new_nr_ue(gNB_mac, ra->rnti, ra->CellGroup); + if (!UE) { + LOG_W(NR_MAC, "Random Access %i discarded at state %i (TC_RNTI %04x RNTI %04x): max number of users achieved!\n", i, ra->state,ra->rnti,current_rnti); + nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); return; } - UE_info->UE_beam_index[UE_id] = ra->beam_id; + UE->UE_beam_index = ra->beam_id; // re-initialize ta update variables after RA procedure completion - UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; + UE->UE_sched_ctrl.ta_frame = frameP; LOG_D(NR_MAC, "reset RA state information for RA-RNTI 0x%04x/index %d\n", @@ -658,27 +661,24 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, LOG_I(NR_MAC, "[gNB %d][RAPROC] PUSCH with TC_RNTI 0x%04x received correctly, " - "adding UE MAC Context UE_id %d/RNTI 0x%04x\n", + "adding UE MAC Context RNTI 0x%04x\n", gnb_mod_idP, current_rnti, - UE_id, ra->rnti); - NR_UE_sched_ctrl_t *UE_scheduling_control = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *UE_scheduling_control = &UE->UE_sched_ctrl; UE_scheduling_control->tpc0 = nr_get_tpc(target_snrx10,ul_cqi,30); if (timing_advance != 0xffff) UE_scheduling_control->ta_update = timing_advance; UE_scheduling_control->raw_rssi = rssi; UE_scheduling_control->pusch_snrx10 = ul_cqi * 5 - 640; - LOG_D(NR_MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); + LOG_D(NR_MAC, "[UE %04x] PUSCH TPC %d and TA %d\n",UE->rnti,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); if(ra->cfra) { - LOG_A(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti); + LOG_A(NR_MAC, "(rnti 0x%04x) CFRA procedure succeeded!\n", ra->rnti); nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); - UE_info->active[UE_id] = true; - process_CellGroup(ra->CellGroup, UE_scheduling_control); } else { @@ -694,25 +694,25 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, // First byte corresponds to R/LCID MAC sub-header memcpy(ra->cont_res_id, &sduP[1], sizeof(uint8_t) * 6); - if (nr_process_mac_pdu(gnb_mod_idP, UE_id, CC_idP, frameP, slotP, sduP, sdu_lenP) == 0) { + if (nr_process_mac_pdu(gnb_mod_idP, UE, CC_idP, frameP, slotP, sduP, sdu_lenP) == 0) { ra->state = Msg4; ra->Msg4_frame = (frameP + 2) % 1024; ra->Msg4_slot = 1; if (ra->msg3_dcch_dtch) { // Check if the UE identified by C-RNTI still exists at the gNB - int UE_id_C = find_nr_UE_id(gnb_mod_idP, ra->crnti); - if (UE_id_C < 0) { + NR_UE_info_t * UE_C = find_nr_UE(&gNB_mac->UE_info, ra->crnti); + if (!UE_C) { // The UE identified by C-RNTI no longer exists at the gNB // Let's abort the current RA, so the UE will trigger a new RA later but using RRCSetupRequest instead. A better solution may be implemented - mac_remove_nr_ue(gnb_mod_idP, ra->rnti); + mac_remove_nr_ue(gNB_mac, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); return; } else { // The UE identified by C-RNTI still exists at the gNB // Reset uplink failure flags/counters/timers at MAC and at RRC so gNB will resume again scheduling resources for this UE - UE_info->UE_sched_ctrl[UE_id_C].pusch_consecutive_dtx_cnt = 0; - UE_info->UE_sched_ctrl[UE_id_C].ul_failure = 0; + UE_C->UE_sched_ctrl.pusch_consecutive_dtx_cnt = 0; + UE_C->UE_sched_ctrl.ul_failure = 0; nr_mac_gNB_rrc_ul_failure_reset(gnb_mod_idP, frameP, slotP, ra->crnti); } } @@ -751,7 +751,9 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, return; } + LOG_D(NR_MAC, "Random Access %i Msg3 CRC did not pass)\n", i); + ra->msg3_round++; ra->state = Msg3_retransmission; } @@ -783,19 +785,20 @@ long get_K2(NR_ServingCellConfigCommon_t *scc, return 3; } -bool nr_UE_is_to_be_scheduled(module_id_t mod_id, int CC_id, int UE_id, frame_t frame, sub_frame_t slot) +static bool nr_UE_is_to_be_scheduled(const NR_ServingCellConfigCommon_t *scc, + int CC_id, NR_UE_info_t* UE, frame_t frame, sub_frame_t slot, uint32_t ulsch_max_frame_inactivity) { - const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const int now = frame * n + slot; - const struct gNB_MAC_INST_s *nrmac = RC.nrmac[mod_id]; - const NR_UE_sched_ctrl_t *sched_ctrl = &nrmac->UE_info.UE_sched_ctrl[UE_id]; + + const NR_UE_sched_ctrl_t *sched_ctrl =&UE->UE_sched_ctrl; + const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; int num_slots_per_period; - int last_ul_slot,last_ul_sched; + int last_ul_slot; int tdd_period_len[8] = {500,625,1000,1250,2000,2500,5000,10000}; if (tdd) { // Force the default transmission in a full slot as early as possible in the UL portion of TDD period (last_ul_slot) num_slots_per_period = n*tdd_period_len[tdd->dl_UL_TransmissionPeriodicity]/10000; @@ -806,14 +809,14 @@ bool nr_UE_is_to_be_scheduled(module_id_t mod_id, int CC_id, int UE_id, frame_t last_ul_slot = sched_ctrl->last_ul_slot; } - last_ul_sched = sched_ctrl->last_ul_frame * n + last_ul_slot; + const int last_ul_sched = sched_ctrl->last_ul_frame * n + last_ul_slot; const int diff = (now - last_ul_sched + 1024 * n) % (1024 * n); /* UE is to be scheduled if * (1) we think the UE has more bytes awaiting than what we scheduled * (2) there is a scheduling request * (3) or we did not schedule it in more than 10 frames */ const bool has_data = sched_ctrl->estimated_ul_buffer > sched_ctrl->sched_ul_bytes; - const bool high_inactivity = diff >= (nrmac->ulsch_max_frame_inactivity>0 ? (nrmac->ulsch_max_frame_inactivity * n) : num_slots_per_period); + const bool high_inactivity = diff >= (ulsch_max_frame_inactivity > 0 ? ulsch_max_frame_inactivity * n : num_slots_per_period); LOG_D(NR_MAC, "%4d.%2d UL inactivity %d slots has_data %d SR %d\n", frame, @@ -824,34 +827,26 @@ bool nr_UE_is_to_be_scheduled(module_id_t mod_id, int CC_id, int UE_id, frame_t return has_data || sched_ctrl->SR || high_inactivity; } -int next_list_entry_looped(NR_list_t *list, int UE_id) -{ - if (UE_id < 0) - return list->head; - return list->next[UE_id] < 0 ? list->head : list->next[UE_id]; -} - -bool allocate_ul_retransmission(module_id_t module_id, - frame_t frame, - sub_frame_t slot, - uint16_t *rballoc_mask, - int *n_rb_sched, - int UE_id, - int harq_pid) +static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, + frame_t frame, + sub_frame_t slot, + uint16_t *rballoc_mask, + int *n_rb_sched, + NR_UE_info_t* UE, + int harq_pid, + const NR_SIB1_t *sib1, + const NR_ServingCellConfigCommon_t *scc, + const int tda) { const int CC_id = 0; - gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; - const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &nr_mac->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_sched_pusch_t *retInfo = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_CellGroupConfig_t *cg = UE->CellGroup; NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, (NR_ServingCellConfigCommon_t *)scc, sib1); @@ -860,7 +855,6 @@ bool allocate_ul_retransmission(module_id_t module_id, const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2; - const int tda = get_ul_tda(nr_mac, scc, retInfo->slot); LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data, retInfo->tb_size); if (tda == retInfo->time_domain_allocation) { @@ -890,7 +884,7 @@ bool allocate_ul_retransmission(module_id_t module_id, while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) rbStart++; if (rbStart + retInfo->rbSize > bwpSize) { - LOG_W(NR_MAC, "cannot allocate retransmission of UE %d/RNTI %04x: no resources (rbStart %d, retInfo->rbSize %d, bwpSize %d\n", UE_id, UE_info->rnti[UE_id], rbStart, retInfo->rbSize, bwpSize); + LOG_W(NR_MAC, "cannot allocate retransmission of RNTI %04x: no resources (rbStart %d, retInfo->rbSize %d, bwpSize %d\n", UE->rnti, rbStart, retInfo->rbSize, bwpSize); return false; } LOG_D(NR_MAC, "%s(): retransmission keeping TDA %d and TBS %d\n", __func__, tda, retInfo->tb_size); @@ -941,7 +935,7 @@ bool allocate_ul_retransmission(module_id_t module_id, /* Find a free CCE */ const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint16_t Y = get_Y(cid%3, slot, UE->rnti); uint8_t nr_of_candidates; for (int i=0; i<5; i++) { // for now taking the lowest value among the available aggregation levels @@ -951,7 +945,7 @@ bool allocate_ul_retransmission(module_id_t module_id, 1<0) break; } - int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], + int CCEIndex = find_pdcch_candidate(nrmac, CC_id, sched_ctrl->aggregation_level, nr_of_candidates, @@ -960,12 +954,12 @@ bool allocate_ul_retransmission(module_id_t module_id, Y); if (CCEIndex<0) { - LOG_D(NR_MAC, "%4d.%2d no free CCE for retransmission UL DCI UE %04x\n", frame, slot, UE_info->rnti[UE_id]); + LOG_D(NR_MAC, "%4d.%2d no free CCE for retransmission UL DCI UE %04x\n", frame, slot, UE->rnti); return false; } sched_ctrl->cce_index = CCEIndex; - fill_pdcch_vrb_map(RC.nrmac[module_id], + fill_pdcch_vrb_map(nrmac, CC_id, &sched_ctrl->sched_pdcch, CCEIndex, @@ -981,11 +975,10 @@ bool allocate_ul_retransmission(module_id_t module_id, NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; LOG_D(NR_MAC, - "%4d.%2d Allocate UL retransmission UE %d/RNTI %04x sched %4d.%2d (%d RBs)\n", + "%4d.%2d Allocate UL retransmission RNTI %04x sched %4d.%2d (%d RBs)\n", frame, slot, - UE_id, - UE_info->rnti[UE_id], + UE->rnti, sched_pusch->frame, sched_pusch->slot, sched_pusch->rbSize); @@ -1012,12 +1005,20 @@ void update_ul_ue_R_Qm(NR_sched_pusch_t *sched_pusch, const NR_pusch_semi_static } } -float ul_thr_ue[MAX_MOBILES_PER_GNB]; uint32_t ul_pf_tbs[3][29]; // pre-computed, approximate TBS values for PF coefficient +typedef struct UEsched_s { + float coef; + NR_UE_info_t * UE; +} UEsched_t; + +static int comparator(const void *p, const void *q) { + return ((UEsched_t*)p)->coef < ((UEsched_t*)q)->coef; +} + void pf_ul(module_id_t module_id, frame_t frame, sub_frame_t slot, - NR_list_t *UE_list, + NR_UE_info_t *UE_list[], int max_num_ue, int n_rb_sched, uint16_t *rballoc_mask) { @@ -1025,28 +1026,29 @@ void pf_ul(module_id_t module_id, const int CC_id = 0; gNB_MAC_INST *nrmac = RC.nrmac[module_id]; NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &nrmac->UE_info; const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const int min_rb = nrmac->min_grant_prb; - float coeff_ue[MAX_MOBILES_PER_GNB]; + + const int min_rb = 5; // UEs that could be scheduled - int ue_array[MAX_MOBILES_PER_GNB]; - NR_list_t UE_sched = { .head = -1, .next = ue_array, .tail = -1, .len = MAX_MOBILES_PER_GNB }; + UEsched_t UE_sched[MAX_MOBILES_PER_GNB] = {0}; + int remainUEs=max_num_ue; + int curUE=0; /* Loop UE_list to calculate throughput and coeff */ - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { + UE_iterator(UE_list, UE) { - if (UE_info->Msg4_ACKed[UE_id] != true) continue; + if (UE->Msg4_ACKed != true) + continue; - LOG_D(NR_MAC,"pf_ul: preparing UL scheduling for UE %d\n",UE_id); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + LOG_D(NR_MAC,"pf_ul: preparing UL scheduling for UE %04x\n",UE->rnti); + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, scc, sib1); int rbStart = 0; // wrt BWP start - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_CellGroupConfig_t *cg = UE->CellGroup; NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; @@ -1054,45 +1056,46 @@ void pf_ul(module_id_t module_id, const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; - const NR_mac_dir_stats_t *stats = &UE_info->mac_stats[UE_id].ul; + const NR_mac_dir_stats_t *stats = &UE->mac_stats.ul; /* Calculate throughput */ const float a = 0.0005f; // corresponds to 200ms window const uint32_t b = stats->current_bytes; - ul_thr_ue[UE_id] = (1 - a) * ul_thr_ue[UE_id] + a * b; + UE->ul_thr_ue = (1 - a) * UE->ul_thr_ue + a * b; /* Check if retransmission is necessary */ sched_pusch->ul_harq_pid = sched_ctrl->retrans_ul_harq.head; - LOG_D(NR_MAC,"pf_ul: UE %d harq_pid %d\n",UE_id,sched_pusch->ul_harq_pid); + LOG_D(NR_MAC,"pf_ul: UE %04x harq_pid %d\n",UE->rnti,sched_pusch->ul_harq_pid); if (sched_pusch->ul_harq_pid >= 0) { /* Allocate retransmission*/ - bool r = allocate_ul_retransmission( - module_id, frame, slot, rballoc_mask, &n_rb_sched, UE_id, sched_pusch->ul_harq_pid); + const int tda = get_ul_tda(nrmac, scc, slot); + bool r = allocate_ul_retransmission(nrmac, frame, slot, rballoc_mask, &n_rb_sched, UE, sched_pusch->ul_harq_pid, sib1, scc, tda); if (!r) { - LOG_D(NR_MAC, "%4d.%2d UL retransmission UE RNTI %04x can NOT be allocated\n", frame, slot, UE_info->rnti[UE_id]); + LOG_D(NR_MAC, "%4d.%2d UL retransmission UE RNTI %04x can NOT be allocated\n", frame, slot, UE->rnti); continue; } - else LOG_D(NR_MAC,"%4d.%2d UL Retransmission UE RNTI %04x to be allocated, max_num_ue %d\n",frame,slot,UE_info->rnti[UE_id],max_num_ue); + else LOG_D(NR_MAC,"%4d.%2d UL Retransmission UE RNTI %04x to be allocated, max_num_ue %d\n",frame,slot,UE->rnti,max_num_ue); /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ - max_num_ue--; - if (max_num_ue < 0) - return; - continue; - } + remainUEs--; + if (remainUEs == 0) + // we have filled all with mandatory retransmissions + // no need to schedule new transmissions + return; + continue; + } const int B = max(0, sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes); /* preprocessor computed sched_frame/sched_slot */ - const bool do_sched = nr_UE_is_to_be_scheduled(module_id, 0, UE_id, sched_pusch->frame, sched_pusch->slot); + const bool do_sched = nr_UE_is_to_be_scheduled(scc, 0, UE, sched_pusch->frame, sched_pusch->slot, nrmac->ulsch_max_frame_inactivity); - LOG_D(NR_MAC,"pf_ul: do_sched UE %d => %s\n",UE_id,do_sched ? "yes" : "no"); - if ((B == 0 && !do_sched) || (sched_ctrl->rrc_processing_timer > 0)) { + LOG_D(NR_MAC,"pf_ul: do_sched UE %04x => %s\n",UE->rnti,do_sched ? "yes" : "no"); + if ((B == 0 && !do_sched) || (sched_ctrl->rrc_processing_timer > 0)) continue; - } - + const NR_bler_options_t *bo = &nrmac->ul_bler; const int max_mcs = bo->max_mcs; /* no per-user maximum MCS yet */ - sched_pusch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->ul_bler_stats, max_mcs, frame); + sched_pusch->mcs = get_mcs_from_bler(bo, stats, &UE->UE_sched_ctrl.ul_bler_stats, max_mcs, frame); /* Schedule UE on SR or UL inactivity and no data (otherwise, will be scheduled * based on data to transmit) */ @@ -1100,32 +1103,35 @@ void pf_ul(module_id_t module_id, /* if no data, pre-allocate 5RB */ /* Find a free CCE */ const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint16_t Y = get_Y(cid%3, slot, UE->rnti); uint8_t nr_of_candidates; for (int i=0; i<5; i++) { - // for now taking the lowest value among the available aggregation levels - find_aggregation_candidates(&sched_ctrl->aggregation_level, - &nr_of_candidates, - sched_ctrl->search_space, - 1<0) break; + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<0) break; } int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], - CC_id, - sched_ctrl->aggregation_level, - nr_of_candidates, - &sched_ctrl->sched_pdcch, - sched_ctrl->coreset, - Y); - + CC_id, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + if (CCEIndex<0) { - LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x (BSR 0)\n", frame, slot, UE_info->rnti[UE_id]); - continue; + LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x (BSR 0)\n", frame, slot, UE->rnti); + continue; } /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ - max_num_ue--; - if (max_num_ue < 0) - return; + remainUEs--; + + if (remainUEs == 0) + // we have filled all with mandatory retransmissions + // no need to schedule new transmissions + return; /* Save PUSCH field */ /* we want to avoid a lengthy deduction of DMRS and other parameters in @@ -1156,8 +1162,8 @@ void pf_ul(module_id_t module_id, while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) rbStart++; if (rbStart + min_rb >= bwpSize) { - LOG_W(NR_MAC, "cannot allocate continuous UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", - UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); + LOG_W(NR_MAC, "cannot allocate continuous UL data for RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", + UE->rnti,rbStart,min_rb,bwpSize); return; } @@ -1192,40 +1198,27 @@ void pf_ul(module_id_t module_id, } /* Create UE_sched for UEs eligibale for new data transmission*/ - add_tail_nr_list(&UE_sched, UE_id); - /* Calculate coefficient*/ const uint32_t tbs = ul_pf_tbs[ps->mcs_table][sched_pusch->mcs]; - coeff_ue[UE_id] = (float) tbs / ul_thr_ue[UE_id]; - LOG_D(NR_MAC,"b %d, ul_thr_ue[%d] %f, tbs %d, coeff_ue[%d] %f\n", - b, UE_id, ul_thr_ue[UE_id], tbs, UE_id, coeff_ue[UE_id]); + float coeff_ue = (float) tbs / UE->ul_thr_ue; + LOG_D(NR_MAC,"rnti %04x b %d, ul_thr_ue %f, tbs %d, coeff_ue %f\n", + UE->rnti, b, UE->ul_thr_ue, tbs, coeff_ue); + UE_sched[curUE].coef=coeff_ue; + UE_sched[curUE].UE=UE; + curUE++; } - + qsort(UE_sched, sizeof(*UE_sched), sizeofArray(UE_sched), comparator); + UEsched_t *iterator=UE_sched; + const int min_rbSize = 5; /* Loop UE_sched to find max coeff and allocate transmission */ - while (UE_sched.head >= 0 && max_num_ue> 0 && n_rb_sched >= min_rbSize) { - /* Find max coeff */ - int *max = &UE_sched.head; /* Find max coeff: assume head is max */ - int *p = &UE_sched.next[*max]; - while (*p >= 0) { - /* Find max coeff: if the current one has larger coeff, save for later */ - if (coeff_ue[*p] > coeff_ue[*max]) - max = p; - p = &UE_sched.next[*p]; - } - /* Find max coeff: remove the max one: do not use remove_nr_list() since it - * goes through the whole list every time. Note that UE_sched.tail might - * not be set correctly anymore */ - const int UE_id = *max; - p = &UE_sched.next[*max]; - *max = UE_sched.next[*max]; - *p = -1; + while (remainUEs> 0 && n_rb_sched >= min_rbSize && iterator->UE != NULL) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint16_t Y = get_Y(cid%3, slot, iterator->UE->rnti); uint8_t nr_of_candidates; for (int i=0; i<5; i++) { // for now taking the lowest value among the available aggregation levels @@ -1233,7 +1226,8 @@ void pf_ul(module_id_t module_id, &nr_of_candidates, sched_ctrl->search_space, 1<0) break; + if(nr_of_candidates>0) + break; } int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], CC_id, @@ -1243,16 +1237,13 @@ void pf_ul(module_id_t module_id, sched_ctrl->coreset, Y); if (CCEIndex<0) { - LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x\n", frame, slot, UE_info->rnti[UE_id]); + LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x\n", frame, slot, iterator->UE->rnti); + iterator++; continue; } - else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, UE_info->rnti[UE_id]); + else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, iterator->UE->rnti); - /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ - max_num_ue--; - AssertFatal(max_num_ue >= 0, "Illegal max_num_ue %d\n", max_num_ue); - - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; @@ -1299,11 +1290,12 @@ void pf_ul(module_id_t module_id, max_rbSize++; if (rbStart + min_rb >= bwpSize) { - LOG_W(NR_MAC, "cannot allocate UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", - UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); + LOG_W(NR_MAC, "cannot allocate UL data for RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d)\n", + iterator->UE->rnti,rbStart,min_rb,bwpSize); return; } - else LOG_D(NR_MAC,"allocating UL data for UE %d/RNTI %04x (rbStsart %d, min_rb %d, bwpSize %d\n",UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); + else + LOG_D(NR_MAC,"allocating UL data for RNTI %04x (rbStsart %d, min_rb %d, bwpSize %d)\n", iterator->UE->rnti,rbStart,min_rb,bwpSize); /* Calculate the current scheduling bytes and the necessary RBs */ const int B = cmax(sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, 0); @@ -1336,7 +1328,11 @@ void pf_ul(module_id_t module_id, n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] ^= slbitmap; + /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ + remainUEs--; + iterator++; } } @@ -1353,9 +1349,8 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t const int mu = scc ? scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing : scc_sib1->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; - NR_UE_info_t *UE_info = &nr_mac->UE_info; - - if (UE_info->num_UEs == 0) + if (nr_mac->UE_info.list[0] == NULL) + // no UEs return false; const int CC_id = 0; @@ -1364,8 +1359,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * have the same K2 (we don't support multiple/different K2s via different * TDAs yet). If the TDA is negative, it means that there is no UL slot to * schedule now (slot + k2 is not UL slot) */ - int UE_id = UE_info->list.head; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &nr_mac->UE_info.list[0]->UE_sched_ctrl; const int temp_tda = get_ul_tda(nr_mac, scc, slot); int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; @@ -1391,9 +1385,8 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t return false; // Avoid slots with the SRS - const NR_list_t *UE_list = &UE_info->list; - for (int UE_idx = UE_list->head; UE_idx >= 0; UE_idx = UE_list->next[UE_idx]) { - NR_sched_srs_t sched_srs = UE_info->UE_sched_ctrl[UE_idx].sched_srs; + UE_iterator(nr_mac->UE_info.list, UE) { + NR_sched_srs_t sched_srs = UE->UE_sched_ctrl.sched_srs; if(sched_srs.srs_scheduled && sched_srs.frame==sched_frame && sched_srs.slot==sched_slot) { return false; } @@ -1401,10 +1394,11 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; - for (UE_id = UE_info->list.next[UE_id]; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(nr_mac->UE_info.list, UE2) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE2->UE_sched_ctrl; AssertFatal(K2 == get_K2(scc,scc_sib1,sched_ctrl->active_ubwp, tda, mu), - "Different K2, %d(UE%d) != %ld(UE%d)\n", K2, 0, get_K2(scc,scc_sib1,sched_ctrl->active_ubwp, tda, mu), UE_id); + "Different K2, %d(UE%d) != %ld(UE%04x)\n", + K2, 0, get_K2(scc,scc_sib1,sched_ctrl->active_ubwp, tda, mu), UE2->rnti); sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; } @@ -1464,7 +1458,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t pf_ul(module_id, frame, slot, - &UE_info->list, + nr_mac->UE_info.list, 2, len, rballoc_mask); @@ -1525,30 +1519,28 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const NR_list_t *UE_list = &UE_info->list; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator( UE_info->list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->ul_failure == 1 && get_softmodem_params()->phy_test==0) continue; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_CellGroupConfig_t *cg = UE->CellGroup; NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - NR_mac_stats_t *mac_stats = &UE_info->mac_stats[UE_id]; - mac_stats->ul.current_bytes = 0; + UE->mac_stats.ul.current_bytes = 0; /* dynamic PUSCH values (RB alloc, MCS, hence R, Qm, TBS) that change in * every TTI are pre-populated by the preprocessor and used below */ NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; - LOG_D(NR_MAC,"UE %x : sched_pusch->rbSize %d\n",UE_info->rnti[UE_id],sched_pusch->rbSize); + LOG_D(NR_MAC,"UE %04x : sched_pusch->rbSize %d\n",UE->rnti,sched_pusch->rbSize); if (sched_pusch->rbSize <= 0) continue; - uint16_t rnti = UE_info->rnti[UE_id]; + uint16_t rnti = UE->rnti; sched_ctrl->SR = false; int8_t harq_id = sched_pusch->ul_harq_pid; @@ -1556,8 +1548,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* PP has not selected a specific HARQ Process, get a new one */ harq_id = sched_ctrl->available_ul_harq.head; AssertFatal(harq_id >= 0, - "no free HARQ process available for UE %d\n", - UE_id); + "no free HARQ process available for UE %04x\n", + UE->rnti); remove_front_nr_list(&sched_ctrl->available_ul_harq); sched_pusch->ul_harq_pid = harq_id; } else { @@ -1583,10 +1575,10 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; /* Statistics */ - AssertFatal(cur_harq->round < 8, "Indexing UL rounds[%d] is out of bounds\n", cur_harq->round); - mac_stats->ul.rounds[cur_harq->round]++; + AssertFatal(cur_harq->round < 8, "Indexing ulsch_rounds[%d] is out of bounds\n", cur_harq->round); + UE->mac_stats.ul.rounds[cur_harq->round]++; if (cur_harq->round == 0) { - mac_stats->ulsch_total_bytes_scheduled += sched_pusch->tb_size; + UE->mac_stats.ulsch_total_bytes_scheduled += sched_pusch->tb_size; /* Save information on MCS, TBS etc for the current initial transmission * so we have access to it when retransmitting */ cur_harq->sched_pusch = *sched_pusch; @@ -1606,7 +1598,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) cur_harq->round, cur_harq->ndi); } - mac_stats->ul.current_bytes = sched_pusch->tb_size; + UE->mac_stats.ul.current_bytes = sched_pusch->tb_size; sched_ctrl->last_ul_frame = sched_pusch->frame; sched_ctrl->last_ul_slot = sched_pusch->slot; @@ -1789,7 +1781,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pdcch_pdu_coreset[coresetid] = pdcch_pdu; } - LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d at CCE %d, rnti %x\n", frame,slot,sched_ctrl->cce_index,rnti); + LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d at CCE %d, rnti %04x\n", frame,slot,sched_ctrl->cce_index,rnti); /* Fill PDCCH DL DCI PDU */ nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu->dci_pdu[pdcch_pdu->numDlDci]; @@ -1827,7 +1819,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) &uldci_payload, ps->dci_format, ps->time_domain_allocation, - UE_info->UE_sched_ctrl[UE_id].tpc0, + UE->UE_sched_ctrl.tpc0, n_ubwp, bwp_id); fill_dci_pdu_rel15(scc, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index f568cf3f65..f3dd5208d6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -203,7 +203,7 @@ void config_uldci(const NR_SIB1_t *sib1, int n_ubwp, int bwp_id); -void nr_schedule_pucch(int Mod_idP, +void nr_schedule_pucch(gNB_MAC_INST* nrmac, frame_t frameP, sub_frame_t slotP); @@ -218,15 +218,14 @@ void nr_csi_meas_reporting(int Mod_idP, frame_t frameP, sub_frame_t slotP); -int nr_acknack_scheduling(int Mod_idP, - int UE_id, +int nr_acknack_scheduling( int Mod_idP, + NR_UE_info_t * UE, frame_t frameP, sub_frame_t slotP, int r_pucch, int do_common); -void get_pdsch_to_harq_feedback(int Mod_idP, - int UE_id, +void get_pdsch_to_harq_feedback(NR_UE_info_t *, int bwp_id, NR_SearchSpace__searchSpaceType_PR ss_type, int *max_fb_time, @@ -336,7 +335,7 @@ NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList( const NR_SIB1_t *sib1); /* find coreset within the search space */ -NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, +NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, void *bwp, NR_SearchSpace_t *ss, @@ -394,7 +393,6 @@ int NRRIV2BW(int locationAndBandwidth,int N_RB); int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB); /* Functions to manage an NR_list_t */ -void dump_nr_list(NR_list_t *listP); void create_nr_list(NR_list_t *listP, int len); void resize_nr_list(NR_list_t *list, int new_len); void destroy_nr_list(NR_list_t *list); @@ -404,13 +402,13 @@ void add_tail_nr_list(NR_list_t *listP, int id); void add_front_nr_list(NR_list_t *listP, int id); void remove_front_nr_list(NR_list_t *listP); -int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP); +NR_UE_info_t * find_nr_UE(NR_UEs_t* UEs, rnti_t rntiP); int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP); -int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); +NR_UE_info_t*add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); -void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti); +void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti); void nr_mac_remove_ra_rnti(module_id_t mod_id, rnti_t rnti); @@ -424,7 +422,7 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, int nr_get_default_pucch_res(int pucch_ResourceCommon); -void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_info, int UE_id, module_id_t Mod_idP); +void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE); int get_dlscs(nfapi_nr_config_request_t *cfg); @@ -515,7 +513,7 @@ int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl); const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); -bool find_free_CCE(module_id_t module_id, sub_frame_t slot, int UE_id); +bool find_free_CCE(sub_frame_t slot, NR_UE_info_t *UE); bool nr_find_nb_rb(uint16_t Qm, uint16_t R, @@ -534,7 +532,7 @@ int get_mcs_from_bler(const NR_bler_options_t *bler_options, int max_mcs, frame_t frame); -void nr_sr_reporting(int Mod_idP, frame_t frameP, sub_frame_t slotP); +void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t frameP, sub_frame_t slotP); void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp); diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 4c14233a32..e318b4be8e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -57,7 +57,7 @@ void *nrmac_stats_thread(void *arg) { AssertFatal(fd!=NULL,"Cannot open nrMAC_stats.log, error %s\n",strerror(errno)); while (oai_exit == 0) { - dump_mac_stats(gNB,output,MACSTATSSTRLEN,false); + dump_mac_stats(gNB,output,MACSTATSSTRLEN,false); fprintf(fd,"%s\n",output); fflush(fd); usleep(200000); @@ -68,40 +68,40 @@ void *nrmac_stats_thread(void *arg) { } void clear_mac_stats(gNB_MAC_INST *gNB) { - memset((void*)gNB->UE_info.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t)); + UE_iterator(gNB->UE_info.list, UE) { + memset(&UE->mac_stats,0,sizeof(UE->mac_stats)); + } } void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp) { - NR_UE_info_t *UE_info = &gNB->UE_info; int num = 1; int stroff=0; - if (UE_info->num_UEs == 0) return; - - for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { - - const NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; + pthread_mutex_lock(&gNB->UE_info.mutex); + UE_iterator(gNB->UE_info.list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_mac_stats_t *stats = &UE->mac_stats; const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0; - stroff+=sprintf(output+stroff,"UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n", - UE_id, - UE_info->rnti[UE_id], - num++, - UE_info->num_UEs, - sched_ctrl->ph, - sched_ctrl->pcmax, - avg_rsrp, - stats->num_rsrp_meas); - stroff+=sprintf(output+stroff,"UE %d: CQI %d, RI %d, PMI (%d,%d)\n", - UE_id, - UE_info->UE_sched_ctrl[UE_id].CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb, - UE_info->UE_sched_ctrl[UE_id].CSI_report.cri_ri_li_pmi_cqi_report.ri+1, - UE_info->UE_sched_ctrl[UE_id].CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1, - UE_info->UE_sched_ctrl[UE_id].CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2); - stroff+=sprintf(output+stroff,"UE %d: dlsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n", - UE_id, + + stroff+=sprintf(output+stroff,"UE RNTI %04x (%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n", + UE->rnti, + num++, + sched_ctrl->ph, + sched_ctrl->pcmax, + avg_rsrp, + stats->num_rsrp_meas); + stroff+=sprintf(output+stroff,"UE %04x: CQI %d, RI %d, PMI (%d,%d)\n", + UE->rnti, + UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb, + UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.ri+1, + UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1, + UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2); + + stroff+=sprintf(output+stroff,"UE %04x: dlsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n", + UE->rnti, + stats->dl.rounds[0], stats->dl.rounds[1], stats->dl.rounds[2], stats->dl.rounds[3], stats->dl.errors, @@ -112,9 +112,9 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp stats->num_rsrp_meas = 0; stats->cumul_rsrp = 0; } - stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %"PRIu64"\n", UE_id, stats->dl.total_bytes); - stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.5f MCS %d\n", - UE_id, + stroff+=sprintf(output+stroff,"UE %04x: dlsch_total_bytes %"PRIu64"\n", UE->rnti, stats->dl.total_bytes); + stroff+=sprintf(output+stroff,"UE %04x: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64"\n", + UE->rnti, stats->ul.rounds[0], stats->ul.rounds[1], stats->ul.rounds[2], stats->ul.rounds[3], stats->ulsch_DTX, @@ -122,20 +122,22 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp sched_ctrl->ul_bler_stats.bler, sched_ctrl->ul_bler_stats.mcs); stroff+=sprintf(output+stroff, - "UE %d: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n", - UE_id, + "UE %04x: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n", + UE->rnti, stats->ulsch_total_bytes_scheduled, stats->ul.total_bytes); for (int lc_id = 0; lc_id < 63; lc_id++) { if (stats->dl.lc_bytes[lc_id] > 0) { - stroff+=sprintf(output+stroff, "UE %d: LCID %d: %"PRIu64" bytes TX\n", UE_id, lc_id, stats->dl.lc_bytes[lc_id]); - LOG_D(NR_MAC, "UE %d: LCID %d: %"PRIu64" bytes TX\n", UE_id, lc_id, stats->dl.lc_bytes[lc_id]); + stroff+=sprintf(output+stroff, "UE %04x: LCID %d: %"PRIu64" bytes TX\n", UE->rnti, lc_id, stats->dl.lc_bytes[lc_id]); + LOG_D(NR_MAC, "UE %04x: LCID %d: %"PRIu64" bytes TX\n", UE->rnti, lc_id, stats->dl.lc_bytes[lc_id]); } if (stats->ul.lc_bytes[lc_id] > 0) { - stroff+=sprintf(output+stroff, "UE %d: LCID %d: %"PRIu64" bytes RX\n", UE_id, lc_id, stats->ul.lc_bytes[lc_id]); - LOG_D(NR_MAC, "UE %d: LCID %d: %"PRIu64" bytes RX\n", UE_id, lc_id, stats->ul.lc_bytes[lc_id]); + stroff+=sprintf(output+stroff, "UE %04x: LCID %d: %"PRIu64" bytes RX\n", UE->rnti, lc_id, stats->ul.lc_bytes[lc_id]); + LOG_D(NR_MAC, "UE %04x: LCID %d: %"PRIu64" bytes RX\n", UE->rnti, lc_id, stats->ul.lc_bytes[lc_id]); + } } } + pthread_mutex_unlock(&gNB->UE_info.mutex); print_meas(&gNB->eNB_scheduler, "DL & UL scheduling timing stats", NULL, NULL); print_meas(&gNB->schedule_dlsch,"dlsch scheduler",NULL,NULL); print_meas(&gNB->rlc_data_req, "rlc_data_req",NULL,NULL); @@ -146,8 +148,6 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp void mac_top_init_gNB(void) { module_id_t i; - int list_el; - NR_UE_info_t *UE_info; gNB_MAC_INST *nrmac; LOG_I(MAC, "[MAIN] Init function start:nb_nr_macrlc_inst=%d\n",RC.nb_nr_macrlc_inst); @@ -181,6 +181,8 @@ void mac_top_init_gNB(void) RC.nrmac[i]->first_MIB = true; + pthread_mutex_init(&RC.nrmac[i]->UE_info.mutex, NULL); + if (get_softmodem_params()->phy_test) { RC.nrmac[i]->pre_processor_dl = nr_preprocessor_phytest; RC.nrmac[i]->pre_processor_ul = nr_ul_preprocessor_phytest; @@ -212,13 +214,7 @@ void mac_top_init_gNB(void) nrmac = RC.nrmac[i]; nrmac->if_inst = NR_IF_Module_init(i); - - UE_info = &nrmac->UE_info; - UE_info->num_UEs = 0; - create_nr_list(&UE_info->list, MAX_MOBILES_PER_GNB); - for (list_el = 0; list_el < MAX_MOBILES_PER_GNB; list_el++) { - UE_info->active[list_el] = false; - } + memset(&nrmac->UE_info, 0, sizeof(nrmac->UE_info)); } srand48(0); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 4918e4ee08..1aca7cae57 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -91,6 +91,7 @@ typedef struct { int len; } NR_list_t; + typedef enum { RA_IDLE = 0, Msg2 = 1, @@ -703,24 +704,34 @@ typedef struct NR_bler_options { /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ #define MAX_CSI_REPORTCONFIG 48 typedef struct { + rnti_t rnti; /// scheduling control info - nr_csi_report_t csi_report_template[MAX_MOBILES_PER_GNB][MAX_CSI_REPORTCONFIG]; - NR_UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB]; - NR_mac_stats_t mac_stats[MAX_MOBILES_PER_GNB]; - NR_list_t list; - int num_UEs; - bool active[MAX_MOBILES_PER_GNB]; - rnti_t rnti[MAX_MOBILES_PER_GNB]; - NR_CellGroupConfig_t *CellGroup[MAX_MOBILES_PER_GNB]; + nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG]; + NR_UE_sched_ctrl_t UE_sched_ctrl; + NR_mac_stats_t mac_stats; + NR_CellGroupConfig_t *CellGroup; /// CCE indexing - int m[MAX_MOBILES_PER_GNB]; + int m; // UE selected beam index - uint8_t UE_beam_index[MAX_MOBILES_PER_GNB]; - bool Msg4_ACKed[MAX_MOBILES_PER_GNB]; + uint8_t UE_beam_index; + bool Msg4_ACKed; /// Sched CSI-RS: scheduling decisions bool sched_csirs; + NR_gNB_UCI_STATS_t uci_statS; + float ul_thr_ue; + float dl_thr_ue; + int layers; } NR_UE_info_t; +typedef struct { + /// scheduling control info + // last element always NULL + pthread_mutex_t mutex; + NR_UE_info_t *list[MAX_MOBILES_PER_GNB+1]; +} NR_UEs_t; + +#define UE_iterator(BaSe, VaR) NR_UE_info_t ** VaR##pptr=BaSe, *VaR; while ((VaR=*(VaR##pptr++))) + typedef void (*nr_pp_impl_dl)(module_id_t mod_id, frame_t frame, sub_frame_t slot); @@ -779,7 +790,7 @@ typedef struct gNB_MAC_INST_s { /// NFAPI DL PDU structure nfapi_nr_tx_data_request_t TX_req[NFAPI_CC_MAX]; int pdcch_cand[MAX_NUM_CORESET]; - NR_UE_info_t UE_info; + NR_UEs_t UE_info; /// UL handle uint32_t ul_handle; diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index c860d847d9..8d4de8823b 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -372,9 +372,6 @@ static void match_crc_rx_pdu(nfapi_nr_rx_data_indication_t *rx_ind, nfapi_nr_crc void NR_UL_indication(NR_UL_IND_t *UL_info) { AssertFatal(UL_info!=NULL,"UL_info is null\n"); -#ifdef DUMP_FAPI - dump_ul(UL_info); -#endif module_id_t module_id = UL_info->module_id; int CC_id = UL_info->CC_id; NR_Sched_Rsp_t *sched_info = &NR_Sched_INFO[module_id][CC_id]; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 3d41787a2d..f5879a0c49 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1643,7 +1643,7 @@ rrc_gNB_generate_RRCReestablishment( ue_context->Srb0.Tx_buffer.payload_size); #if(0) /* TODO : It may be needed if gNB goes into full stack working. */ - UE_id = find_nr_UE_id(module_id, rnti); + UE = find_nr_UE(module_id, rnti); if (UE_id != -1) { /* Activate reject timer, if RRCComplete not received after 10 frames, reject UE */ RC.nrmac[module_id]->UE_info.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1; @@ -3549,6 +3549,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { FILE *fd=NULL;//fopen("nrRRCstats.log","w"); RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &(RC.nrrrc[ctxt_pP->module_id]->rrc_ue_head)) { ctxt_pP->rnti = ue_context_p->ue_id_rnti; + gNB_MAC_INST *nrmac=RC.nrmac[ctxt_pP->module_id]; //WHAT A BEAUTIFULL RACE CONDITION !!! if (fd) { if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence == TRUE) { @@ -3588,7 +3589,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { // Remove here the MAC and RRC context when RRC is not connected or gNB is not connected to CN5G if(ue_context_p->ue_context.StatusRrc < NR_RRC_CONNECTED || ue_context_p->ue_context.gNB_ue_ngap_id == 0) { - mac_remove_nr_ue(ctxt_pP->module_id, ctxt_pP->rnti); + mac_remove_nr_ue(nrmac, ctxt_pP->rnti); rrc_rlc_remove_ue(ctxt_pP); pdcp_remove_UE(ctxt_pP); @@ -3612,7 +3613,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { ue_context_p->ue_context.rnti); ue_context_p->ue_context.ue_release_timer_rrc = 0; - mac_remove_nr_ue(ctxt_pP->module_id, ctxt_pP->rnti); + mac_remove_nr_ue(nrmac, ctxt_pP->rnti); rrc_rlc_remove_ue(ctxt_pP); pdcp_remove_UE(ctxt_pP); newGtpuDeleteAllTunnels(ctxt_pP->instance, ctxt_pP->rnti); diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 8040fcb13c..07a6bd85be 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -426,7 +426,8 @@ void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti) { rrc_rlc_remove_ue(&ctxt); - mac_remove_nr_ue(rrc->module_id, rnti); + // WHAT A RACE CONDITION + mac_remove_nr_ue(RC.nrmac[rrc->module_id], rnti); gtpv1u_enb_delete_tunnel_req_t tmp={0}; tmp.rnti=rnti; tmp.from_gnb=1; diff --git a/openair2/UTIL/OPT/opt.h b/openair2/UTIL/OPT/opt.h index ae6a3eb2a6..d08790a058 100644 --- a/openair2/UTIL/OPT/opt.h +++ b/openair2/UTIL/OPT/opt.h @@ -109,11 +109,14 @@ typedef enum radio_type_e { extern int opt_enabled; #define trace_pdu(x...) if (opt_enabled) trace_pdu_implementation(0, x) -#define trace_NRpdu(x...) if (opt_enabled) trace_pdu_implementation(1, x) +#define trace_NRpdu(x...) if (opt_enabled) nr_trace_pdu_implementation(1, x) void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, int ueid, int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe, int oob_event, int oob_event_value); +void nr_trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, + int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe, + int oob_event, int oob_event_value); int init_opt(void); diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index 8731eb294a..9359c48e95 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -476,6 +476,14 @@ static void SendFrameNR(guint8 radioType, guint8 direction, guint8 rntiType, extern RAN_CONTEXT_t RC; #include /* Remote serveraddress (where Wireshark is running) */ +void nr_trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, + int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event, + int oob_event_value) { + trace_pdu_implementation(nr, direction, pdu_buffer, pdu_buffer_size, + rnti, rntiType, rnti, sysFrameNumber, subFrameNumber, oob_event, + oob_event_value); +} + void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, int ueid, int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event, int oob_event_value) { From b6adb329890ce1904d6528ad145d2dbaea253edb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 13 May 2022 17:06:25 +0200 Subject: [PATCH 095/105] Delete commented code --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 161 ---------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 74 ----- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 304 ------------------ 3 files changed, 539 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 198e08610b..d7e2c78c35 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -104,167 +104,6 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, TX_req[CC_idP].Number_of_PDUs = 0; } -/* -void check_nr_ul_failure(module_id_t module_idP, - int CC_id, - int UE_id, - frame_t frameP, - sub_frame_t slotP) { - - NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info; - nfapi_nr_dl_dci_request_t *DL_req = &RC.nrmac[module_idP]->DL_req[0]; - uint16_t rnti = UE_RNTI(module_idP, UE_id); - NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels; - - // check uplink failure - if ((UE_info->UE_sched_ctrl[UE_id].ul_failure_timer > 0) && - (UE_info->UE_sched_ctrl[UE_id].ul_out_of_sync == 0)) { - LOG_I(MAC, "UE %d rnti %x: UL Failure timer %d \n", UE_id, rnti, - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer); - if (UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent == 0) { - UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 1; - - // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe) - nfapi_nr_dl_dci_request_pdu_t *dl_config_pdu = &DL_req[CC_id].dl_tti_request_body.dl_config_pdu_list[DL_req[CC_id].dl_tti_request_body.number_pdu]; - memset((void *) dl_config_pdu, 0,sizeof(nfapi_dl_dci_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_DCI_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP, CC_id), - UE_info->UE_sched_ctrl[UE_id]. - dl_cqi[CC_id], format1A); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - AssertFatal((cc[CC_id].mib->message.dl_Bandwidth >= 0) && (cc[CC_id].mib->message.dl_Bandwidth < 6), - "illegal dl_Bandwidth %d\n", - (int) cc[CC_id].mib->message.dl_Bandwidth); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = nr_pdcch_order_table[cc[CC_id].mib->message.dl_Bandwidth]; - DL_req[CC_id].dl_tti_request_body.number_dci++; - DL_req[CC_id].dl_tti_request_body.number_pdu++; - DL_req[CC_id].dl_tti_request_body.tl.tag = NFAPI_DL_TTI_REQUEST_BODY_TAG; - LOG_I(MAC, - "UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d), resource_block_coding %d \n", - UE_id, rnti, - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer, - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.resource_block_coding); - } else { // ra_pdcch_sent==1 - LOG_I(MAC, - "UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n", - UE_id, rnti, - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer); - if ((UE_info->UE_sched_ctrl[UE_id].ul_failure_timer % 40) == 0) UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 4 frames - } - - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer++; - // check threshold - if (UE_info->UE_sched_ctrl[UE_id].ul_failure_timer > 20000) { - // inform RRC of failure and clear timer - LOG_I(MAC, - "UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n", - UE_id, rnti); - mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, subframeP,rnti); - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer = 0; - UE_info->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; - - //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future - if (rrc_agent_registered[module_idP]) { - LOG_W(MAC, "notify flexran Agent of UE state change\n"); - agent_rrc_xface[module_idP]->flexran_agent_notify_ue_state_change(module_idP, - rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); - } - } - } // ul_failure_timer>0 - -} -*/ -/* -void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) -{ - gNB_MAC_INST *gNB = RC.nrmac[module_idP]; - NR_UE_info_t *UE_info = &gNB->UE_info; - nfapi_ul_config_request_body_t *ul_req; - int CC_id, UE_id; - NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels; - SoundingRS_UL_ConfigCommon_t *soundingRS_UL_ConfigCommon; - struct SoundingRS_UL_ConfigDedicated *soundingRS_UL_ConfigDedicated; - uint8_t TSFC; - uint16_t deltaTSFC; // bitmap - uint8_t srs_SubframeConfig; - - // table for TSFC (Period) and deltaSFC (offset) - const uint16_t deltaTSFCTabType1[15][2] = { {1, 1}, {1, 2}, {2, 2}, {1, 5}, {2, 5}, {4, 5}, {8, 5}, {3, 5}, {12, 5}, {1, 10}, {2, 10}, {4, 10}, {8, 10}, {351, 10}, {383, 10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD - const uint16_t deltaTSFCTabType2[14][2] = { {2, 5}, {6, 5}, {10, 5}, {18, 5}, {14, 5}, {22, 5}, {26, 5}, {30, 5}, {70, 10}, {74, 10}, {194, 10}, {326, 10}, {586, 10}, {210, 10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD - - uint16_t srsPeriodicity, srsOffset; - - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - soundingRS_UL_ConfigCommon = &cc[CC_id].radioResourceConfigCommon->soundingRS_UL_ConfigCommon; - // check if SRS is enabled in this frame/subframe - if (soundingRS_UL_ConfigCommon) { - srs_SubframeConfig = soundingRS_UL_ConfigCommon->choice.setup.srs_SubframeConfig; - if (cc[CC_id].tdd_Config == NULL) { // FDD - deltaTSFC = deltaTSFCTabType1[srs_SubframeConfig][0]; - TSFC = deltaTSFCTabType1[srs_SubframeConfig][1]; - } else { // TDD - deltaTSFC = deltaTSFCTabType2[srs_SubframeConfig][0]; - TSFC = deltaTSFCTabType2[srs_SubframeConfig][1]; - } - // Sounding reference signal subframes are the subframes satisfying ns/2 mod TSFC (- deltaTSFC - uint16_t tmp = (subframeP % TSFC); - - if ((1 << tmp) & deltaTSFC) { - // This is an SRS subframe, loop over UEs - UEs_iterator() { - if (!RC.nrmac[module_idP]->UE_info.active[UE_id]) continue; - ul_req = &RC.nrmac[module_idP]->UL_req[CC_id].ul_config_request_body; - // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet - if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue; - - AssertFatal(UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, - "physicalConfigDedicated is null for UE %d\n", - UE_id); - - if ((soundingRS_UL_ConfigDedicated = UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated) != NULL) { - if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { - get_srs_pos(&cc[CC_id], - soundingRS_UL_ConfigDedicated->choice. - setup.srs_ConfigIndex, - &srsPeriodicity, &srsOffset); - if (((10 * frameP + subframeP) % srsPeriodicity) == srsOffset) { - // Program SRS - ul_req->srs_present = 1; - nfapi_ul_config_request_pdu_t * ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; - memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_SRS_PDU_TYPE; - ul_config_pdu->pdu_size = 2 + (uint8_t) (2 + sizeof(nfapi_ul_config_srs_pdu)); - ul_config_pdu->srs_pdu.srs_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG; - ul_config_pdu->srs_pdu.srs_pdu_rel8.size = (uint8_t)sizeof(nfapi_ul_config_srs_pdu); - ul_config_pdu->srs_pdu.srs_pdu_rel8.rnti = UE_info->UE_template[CC_id][UE_id].rnti; - ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; - ul_config_pdu->srs_pdu.srs_pdu_rel8.frequency_domain_position = soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; - ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_hopping_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth;; - ul_config_pdu->srs_pdu.srs_pdu_rel8.transmission_comb = soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; - ul_config_pdu->srs_pdu.srs_pdu_rel8.i_srs = soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; - ul_config_pdu->srs_pdu.srs_pdu_rel8.sounding_reference_cyclic_shift = soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; // ul_config_pdu->srs_pdu.srs_pdu_rel10.antenna_port = ;// - // ul_config_pdu->srs_pdu.srs_pdu_rel13.number_of_combs = ;// - RC.nrmac[module_idP]->UL_req[CC_id].sfn_sf = (frameP << 4) + subframeP; - RC.nrmac[module_idP]->UL_req[CC_id].header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req->number_of_pdus++; - } // if (((10*frameP+subframeP) % srsPeriodicity) == srsOffset) - } // if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) - } // if ((soundingRS_UL_ConfigDedicated = UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) - } // for (UE_id ... - } // if((1<=64) return false; //quickfix for FR2 where there are more than 64 slots (bitmap to be removed) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 8a0e966a8a..aff03a5323 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -151,8 +151,6 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, NrOfSymbols = NrOfSymbols_tmp; StartSymbolIndex = StartSymbolIndex_tmp; mappingtype = mappingtype_tmp; - // k0 = *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; - // time_domain_assignment = i; } } AssertFatal(StartSymbolIndex>=0,"StartSymbolIndex is negative\n"); @@ -164,78 +162,6 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, StartSymbolIndex, mappingtype, 1); - /* - AssertFatal(k0==0,"k0 is not zero for Initial DL BWP TimeDomain Alloc\n"); - nr_configure_css_dci_initial(pdcch_pdu_rel15, - scs, - scs, - FR, - 0, - 0, - 0, - sfn_sf, slotP, - slots_per_frame, - dlBWP_carrier_bandwidth); - - - pdu_rel15->frequency_domain_assignment = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize, - pdsch_pdu_rel15->rbStart, - dlBWP_carrier_bandwidth); - pdu_rel15->time_domain_assignment = time_domain_assignment; - - pdu_rel15->vrb_to_prb_mapping = 1; - pdu_rel15->mcs = 9; - pdu_rel15->tb_scaling = 1; - - pdu_rel15->ra_preamble_index = 25; - pdu_rel15->format_indicator = 1; - pdu_rel15->ndi = 1; - pdu_rel15->rv = 0; - pdu_rel15->harq_pid = 0; - pdu_rel15->dai = 2; - pdu_rel15->tpc = 2; - 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", - 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->rv); - - params_rel15->rnti = rnti; - 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 type 1 params: rnti %x, rnti_type %d, dci_format %d\n \ - coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ - ss params : nb_ss_sets_per_slot %d, first symb %d, nb_slots %d, sfn_mod2 %d, first slot %d\n", - params_rel15->rnti, - params_rel15->rnti_type, - params_rel15->dci_format, - params_rel15->mux_pattern, - params_rel15->n_rb, - params_rel15->n_symb, - params_rel15->rb_offset, - params_rel15->nb_ss_sets_per_slot, - params_rel15->first_symbol, - params_rel15->nb_slots, - params_rel15->sfn_mod2, - params_rel15->first_slot); - nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, dl_tti_dci_pdu->dci_dl_pdu,0); - LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d\n", - pdsch_pdu_rel15->rbStart, - pdsch_pdu_rel15->rbSize, - pdsch_pdu_rel15->StartSymbolIndex, - pdsch_pdu_rel15->NrOfSymbols, - pdsch_pdu_rel15->nrOfLayers, - pdsch_pdu_rel15->NrOfCodewords, - pdsch_pdu_rel15->mcsIndex[0]); - */ - nr_mac->DL_req[CC_id].dl_tti_request_body.nPDUs+=2; TX_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 574cfa2615..03dd076265 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2995,307 +2995,3 @@ void schedule_nr_bwp_switch(module_id_t module_id, } } } - -/*void fill_nfapi_coresets_and_searchspaces(NR_CellGroupConfig_t *cg, - nfapi_nr_coreset_t *coreset, - nfapi_nr_search_space_t *search_space) { - - nfapi_nr_coreset_t *cs; - nfapi_nr_search_space_t *ss; - NR_ServingCellConfigCommon_t *scc=cg->spCellConfig->reconfigurationWithSync->spCellConfigCommon; - AssertFatal(cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", - cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); - - NR_BWP_Downlink_t *bwp=cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[0]; - struct NR_PDCCH_Config__controlResourceSetToAddModList *coreset_list = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList; - AssertFatal(coreset_list->list.count>0, - "cs list has 0 elements\n"); - for (int i=0;ilist.count;i++) { - NR_ControlResourceSet_t *coreset_i=coreset_list->list.array[i]; - cs = coreset + coreset_i->controlResourceSetId; - - cs->coreset_id = coreset_i->controlResourceSetId; - AssertFatal(coreset_i->frequencyDomainResources.size <=8 && coreset_i->frequencyDomainResources.size>0, - "coreset_i->frequencyDomainResources.size=%d\n", - (int)coreset_i->frequencyDomainResources.size); - - for (int f=0;ffrequencyDomainResources.size;f++) - ((uint8_t*)&cs->frequency_domain_resources)[coreset_i->frequencyDomainResources.size-1-f]=coreset_i->frequencyDomainResources.buf[f]; - - cs->frequency_domain_resources>>=coreset_i->frequencyDomainResources.bits_unused; - - cs->duration = coreset_i->duration; - // Need to add information about TCI_StateIDs - - if (coreset_i->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved) - cs->cce_reg_mapping_type = NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED; - else { - cs->cce_reg_mapping_type = NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED; - - if (coreset_i->cce_REG_MappingType.choice.interleaved->reg_BundleSize==NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) - cs->reg_bundle_size = 6; - else cs->reg_bundle_size = 2+coreset_i->cce_REG_MappingType.choice.interleaved->reg_BundleSize; - - if (coreset_i->cce_REG_MappingType.choice.interleaved->interleaverSize==NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) - cs->interleaver_size = 6; - else cs->interleaver_size = 2+coreset_i->cce_REG_MappingType.choice.interleaved->interleaverSize; - - if (coreset_i->cce_REG_MappingType.choice.interleaved->shiftIndex) - cs->shift_index = *coreset_i->cce_REG_MappingType.choice.interleaved->shiftIndex; - else cs->shift_index = 0; - } - - if (coreset_i->precoderGranularity == NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle) - cs->precoder_granularity = NFAPI_NR_CSET_SAME_AS_REG_BUNDLE; - else cs->precoder_granularity = NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS; - if (coreset_i->tci_PresentInDCI == NULL) cs->tci_present_in_dci = 0; - else cs->tci_present_in_dci = 1; - - if (coreset_i->tci_PresentInDCI == NULL) cs->dmrs_scrambling_id = 0; - else cs->dmrs_scrambling_id = *coreset_i->tci_PresentInDCI; - } - - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - AssertFatal(commonSearchSpaceList->list.count>0, - "common SearchSpace list has 0 elements\n"); - // Common searchspace list - for (int i=0;ilist.count;i++) { - NR_SearchSpace_t *searchSpace_i=commonSearchSpaceList->list.array[i]; - ss=search_space + searchSpace_i->searchSpaceId; - if (searchSpace_i->controlResourceSetId) ss->coreset_id = *searchSpace_i->controlResourceSetId; - switch(searchSpace_i->monitoringSlotPeriodicityAndOffset->present) { - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL4; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl4; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL5; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl5; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL8; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl8; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL10; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl10; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL16; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl16; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL20; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl20; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL40; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl40; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL80; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl80; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL160; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl160; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL320; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl320; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL640; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl640; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1280; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl1280; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2560; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2560; - break; - default: - AssertFatal(1==0,"Shouldn't get here\n"); - break; - } - if (searchSpace_i->duration) ss->duration = *searchSpace_i->duration; - else ss->duration = 1; - - - AssertFatal(searchSpace_i->monitoringSymbolsWithinSlot->size == 2, - "ss_i->monitoringSymbolsWithinSlot = %d != 2\n", - (int)searchSpace_i->monitoringSymbolsWithinSlot->size); - ((uint8_t*)&ss->monitoring_symbols_in_slot)[1] = searchSpace_i->monitoringSymbolsWithinSlot->buf[0]; - ((uint8_t*)&ss->monitoring_symbols_in_slot)[0] = searchSpace_i->monitoringSymbolsWithinSlot->buf[1]; - - AssertFatal(searchSpace_i->nrofCandidates!=NULL,"searchSpace_%d->nrofCandidates is null\n",(int)searchSpace_i->searchSpaceId); - if (searchSpace_i->nrofCandidates->aggregationLevel1 == NR_SearchSpace__nrofCandidates__aggregationLevel1_n8) - ss->number_of_candidates[0] = 8; - else ss->number_of_candidates[0] = searchSpace_i->nrofCandidates->aggregationLevel1; - if (searchSpace_i->nrofCandidates->aggregationLevel2 == NR_SearchSpace__nrofCandidates__aggregationLevel2_n8) - ss->number_of_candidates[1] = 8; - else ss->number_of_candidates[1] = searchSpace_i->nrofCandidates->aggregationLevel2; - if (searchSpace_i->nrofCandidates->aggregationLevel4 == NR_SearchSpace__nrofCandidates__aggregationLevel4_n8) - ss->number_of_candidates[2] = 8; - else ss->number_of_candidates[2] = searchSpace_i->nrofCandidates->aggregationLevel4; - if (searchSpace_i->nrofCandidates->aggregationLevel8 == NR_SearchSpace__nrofCandidates__aggregationLevel8_n8) - ss->number_of_candidates[3] = 8; - else ss->number_of_candidates[3] = searchSpace_i->nrofCandidates->aggregationLevel8; - if (searchSpace_i->nrofCandidates->aggregationLevel16 == NR_SearchSpace__nrofCandidates__aggregationLevel16_n8) - ss->number_of_candidates[4] = 8; - else ss->number_of_candidates[4] = searchSpace_i->nrofCandidates->aggregationLevel16; - - AssertFatal(searchSpace_i->searchSpaceType->present==NR_SearchSpace__searchSpaceType_PR_common, - "searchspace %d is not common\n",(int)searchSpace_i->searchSpaceId); - AssertFatal(searchSpace_i->searchSpaceType->choice.common!=NULL, - "searchspace %d common is null\n",(int)searchSpace_i->searchSpaceId); - ss->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_COMMON; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0) - ss->css_formats_0_0_and_1_0 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_0) { - ss->css_format_2_0 = 1; - // add aggregation info - } - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_1) - ss->css_format_2_1 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_2) - ss->css_format_2_2 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_3) - ss->css_format_2_3 = 1; - } - - struct NR_PDCCH_Config__searchSpacesToAddModList *dedicatedSearchSpaceList = bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList; - AssertFatal(dedicatedSearchSpaceList->list.count>0, - "Dedicated Search Space list has 0 elements\n"); - // Dedicated searchspace list - for (int i=0;ilist.count;i++) { - NR_SearchSpace_t *searchSpace_i=dedicatedSearchSpaceList->list.array[i]; - ss=search_space + searchSpace_i->searchSpaceId; - ss->search_space_id = searchSpace_i->searchSpaceId; - if (searchSpace_i->controlResourceSetId) ss->coreset_id = *searchSpace_i->controlResourceSetId; - switch(searchSpace_i->monitoringSlotPeriodicityAndOffset->present) { - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL4; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl4; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL5; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl5; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL8; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl8; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL10; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl10; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL16; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl16; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL20; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl20; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL40; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl40; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL80; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl80; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL160; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl160; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL320; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl320; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL640; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl640; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1280; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl1280; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2560; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2560; - break; - default: - AssertFatal(1==0,"Shouldn't get here\n"); - break; - } - if (searchSpace_i->duration) ss->duration = *searchSpace_i->duration; - else ss->duration = 1; - - - AssertFatal(searchSpace_i->monitoringSymbolsWithinSlot->size == 2, - "ss_i->monitoringSymbolsWithinSlot = %d != 2\n", - (int)searchSpace_i->monitoringSymbolsWithinSlot->size); - ((uint8_t*)&ss->monitoring_symbols_in_slot)[1] = searchSpace_i->monitoringSymbolsWithinSlot->buf[0]; - ((uint8_t*)&ss->monitoring_symbols_in_slot)[0] = searchSpace_i->monitoringSymbolsWithinSlot->buf[1]; - - AssertFatal(searchSpace_i->nrofCandidates!=NULL,"searchSpace_%d->nrofCandidates is null\n",(int)searchSpace_i->searchSpaceId); - if (searchSpace_i->nrofCandidates->aggregationLevel1 == NR_SearchSpace__nrofCandidates__aggregationLevel1_n8) - ss->number_of_candidates[0] = 8; - else ss->number_of_candidates[0] = searchSpace_i->nrofCandidates->aggregationLevel1; - if (searchSpace_i->nrofCandidates->aggregationLevel2 == NR_SearchSpace__nrofCandidates__aggregationLevel2_n8) - ss->number_of_candidates[1] = 8; - else ss->number_of_candidates[1] = searchSpace_i->nrofCandidates->aggregationLevel2; - if (searchSpace_i->nrofCandidates->aggregationLevel4 == NR_SearchSpace__nrofCandidates__aggregationLevel4_n8) - ss->number_of_candidates[2] = 8; - else ss->number_of_candidates[2] = searchSpace_i->nrofCandidates->aggregationLevel4; - if (searchSpace_i->nrofCandidates->aggregationLevel8 == NR_SearchSpace__nrofCandidates__aggregationLevel8_n8) - ss->number_of_candidates[3] = 8; - else ss->number_of_candidates[3] = searchSpace_i->nrofCandidates->aggregationLevel8; - if (searchSpace_i->nrofCandidates->aggregationLevel16 == NR_SearchSpace__nrofCandidates__aggregationLevel16_n8) - ss->number_of_candidates[4] = 8; - else ss->number_of_candidates[4] = searchSpace_i->nrofCandidates->aggregationLevel16; - - if (searchSpace_i->searchSpaceType->present==NR_SearchSpace__searchSpaceType_PR_ue_Specific && searchSpace_i->searchSpaceType->choice.ue_Specific!=NULL) { - - ss->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC; - - ss->uss_dci_formats = searchSpace_i->searchSpaceType->choice.ue_Specific-> dci_Formats; - - } else if (searchSpace_i->searchSpaceType->present==NR_SearchSpace__searchSpaceType_PR_common && searchSpace_i->searchSpaceType->choice.common!=NULL) { - ss->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_COMMON; - - if (searchSpace_i->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0) - ss->css_formats_0_0_and_1_0 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_0) { - ss->css_format_2_0 = 1; - // add aggregation info - } - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_1) - ss->css_format_2_1 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_2) - ss->css_format_2_2 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_3) - ss->css_format_2_3 = 1; - } - } -} -*/ From a51c1f93b5c741247662c4bddae8a0aaa328235f Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Tue, 24 May 2022 08:52:13 +0200 Subject: [PATCH 096/105] Remove unused code --- openair1/PHY/NR_REFSIG/dmrs_nr.c | 68 ----------------------------- openair1/PHY/NR_REFSIG/dmrs_nr.h | 1 - openair1/PHY/NR_REFSIG/ss_pbch_nr.h | 2 - 3 files changed, 71 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.c b/openair1/PHY/NR_REFSIG/dmrs_nr.c index 2e270318f8..ca901e1452 100644 --- a/openair1/PHY/NR_REFSIG/dmrs_nr.c +++ b/openair1/PHY/NR_REFSIG/dmrs_nr.c @@ -295,74 +295,6 @@ uint16_t get_dmrs_freq_idx_ul(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_ #define CHECK_DMRS_PBCH_SEQUENCE -void generate_dmrs_pbch(uint32_t dmrs_pbch_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE], uint16_t Nid_cell) -{ - uint32_t cinit; - int i_ssb; - int n_hf; - int _i_ssb; - -#ifdef CHECK_DMRS_PBCH_SEQUENCE - - uint32_t dmrs_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE]; - uint32_t *dmrs_sequence = calloc(CELL_DMRS_LENGTH, sizeof(uint32_t)); - if (dmrs_sequence == NULL) { - msg("Fatal error: memory allocation problem \n"); - assert(0); - } - else - { - printf("Check of demodulation reference signal of pbch sequence \n"); - } - -#endif - - /* for each slot number */ - for (i_ssb = 0; i_ssb>4) + 1))<<11) + ((_i_ssb + 1)<<6) + (Nid_cell%4); - - pseudo_random_sequence_optimised(DMRS_BITMAP_SIZE, &(dmrs_pbch_bitmap[i_ssb][n_hf][0]), cinit); - -#ifdef CHECK_DMRS_PBCH_SEQUENCE - - /* it allows checking generated with standard generation code */ - pseudo_random_sequence(DMRS_BITMAP_SIZE*sizeof(uint32_t), dmrs_sequence, cinit); - - int j = 0; - int k = 0; - - /* format for getting bitmap from uint32_t */ - for (int i=0; i Date: Tue, 24 May 2022 08:52:33 +0200 Subject: [PATCH 097/105] Correctly format code to avoid warnings/ambiguities --- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 864f142fdc..a2a3120705 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -840,12 +840,14 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, mappingtype, add_pos, dmrslength, pusch_config_pdu->start_symbol_index, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); - if (mac->ULbwp[ul_bwp_id-1] && (pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled)) { - if (*dci_format != NR_UL_DCI_FORMAT_0_1) + if ((mac->ULbwp[ul_bwp_id-1] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled)) { + if (*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 || (mac->ULbwp[ul_bwp_id-1] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled)) + } + } else if (*dci_format == NR_UL_DCI_FORMAT_0_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 (mac->cg && @@ -1087,7 +1089,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id, dl_info->phy_data); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) LOG_D(NR_MAC,"1# scheduled_response transmitted, %d, %d\n", rx_frame, rx_slot); - mac->if_module->scheduled_response(&scheduled_response); + mac->if_module->scheduled_response(&scheduled_response); } else { // this is for Msg2/Msg4 From 16e8154d71a9cb962a38693cf4510106f6e7cef6 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Tue, 24 May 2022 08:56:48 +0200 Subject: [PATCH 098/105] Handle full UL TTI Req list more gracefully --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 9dd147d21f..a86767ffbc 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -55,8 +55,12 @@ static void nr_fill_nfapi_pucch(gNB_MAC_INST *nrmac, future_ul_tti_req->Slot, pucch->frame, pucch->ul_slot); - AssertFatal(future_ul_tti_req->n_pdus < sizeofArray(future_ul_tti_req->pdus_list), - "Invalid future_ul_tti_req->n_pdus %d\n", future_ul_tti_req->n_pdus); + // n_pdus is number of pdus, so, in the array, it is the index of the next free element + if (future_ul_tti_req->n_pdus >= sizeofArray(future_ul_tti_req->pdus_list) ) { + LOG_E(NR_MAC,"future_ul_tti_req->n_pdus %d is full, slot: %d, sr flag %d dropping request\n", + future_ul_tti_req->n_pdus, pucch->ul_slot, pucch->sr_flag); + return; + } future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE; future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pucch_pdu_t); nfapi_nr_pucch_pdu_t *pucch_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pucch_pdu; From 43033e20b6c299d913c510352e04d7b2428caaf6 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Tue, 24 May 2022 09:09:57 +0200 Subject: [PATCH 099/105] Avoid SEGV in nr_decode_pucch0() --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index fa177b98f5..8309349491 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -190,7 +190,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, pucch_pdu->bit_len_harq,pucch_pdu->sr_flag); NR_gNB_UCI_STATS_t *uci_stats=NULL; - NR_gNB_UCI_STATS_t *first_uci_stats=NULL; + NR_gNB_UCI_STATS_t *first_uci_stats = gNB->uci_stats; for (int i=0;iuci_stats[i].rnti == pucch_pdu->rnti) { uci_stats = &gNB->uci_stats[i]; From 23c8336a3795254e4b38819c0b0ba1b5949c74c8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 30 May 2022 14:50:55 +0200 Subject: [PATCH 100/105] Fix warning --- openair2/LAYER2/NR_MAC_gNB/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index e318b4be8e..6547544a68 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -113,7 +113,7 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp stats->cumul_rsrp = 0; } stroff+=sprintf(output+stroff,"UE %04x: dlsch_total_bytes %"PRIu64"\n", UE->rnti, stats->dl.total_bytes); - stroff+=sprintf(output+stroff,"UE %04x: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64"\n", + stroff+=sprintf(output+stroff,"UE %04x: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.5f MCS %d\n", UE->rnti, stats->ul.rounds[0], stats->ul.rounds[1], stats->ul.rounds[2], stats->ul.rounds[3], From df8f632ae3fb4e625f77fea8260d514e3b1d2f58 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 30 May 2022 14:52:50 +0200 Subject: [PATCH 101/105] Make sched_csirs common to all UEs --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 3 +-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 3 ++- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 2e983e0664..95834e84c5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -59,8 +59,7 @@ const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon AssertFatal(tdd || nrmac->common_channels->frame_type == FDD, "Dynamic TDD not handled yet\n"); // Use special TDA in case of CSI-RS - const NR_UE_info_t *UE_info = &nrmac->UE_info; - if(UE_info->sched_csirs) + if(nrmac->UE_info.sched_csirs) return 1; if (tdd && tdd->nrofDownlinkSymbols > 1) { // if there is a mixed slot where we can transmit DL diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 03dd076265..65d2ce09c5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2692,6 +2692,7 @@ void nr_csirs_scheduling(int Mod_idP, gNB_MAC_INST *gNB_mac = RC.nrmac[Mod_idP]; uint16_t *vrb_map = gNB_mac->common_channels[CC_id].vrb_map; + UE_info->sched_csirs = false; UE_iterator(UE_info->list, UE) { @@ -2724,7 +2725,7 @@ void nr_csirs_scheduling(int Mod_idP, if((frame*n_slots_frame+slot-offset)%period == 0) { LOG_D(NR_MAC,"Scheduling CSI-RS in frame %d slot %d\n",frame,slot); - UE->sched_csirs = true; + UE_info->sched_csirs = true; nfapi_nr_dl_tti_request_pdu_t *dl_tti_csirs_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset((void*)dl_tti_csirs_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 1aca7cae57..974d6dff4a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -716,7 +716,6 @@ typedef struct { uint8_t UE_beam_index; bool Msg4_ACKed; /// Sched CSI-RS: scheduling decisions - bool sched_csirs; NR_gNB_UCI_STATS_t uci_statS; float ul_thr_ue; float dl_thr_ue; @@ -728,6 +727,7 @@ typedef struct { // last element always NULL pthread_mutex_t mutex; NR_UE_info_t *list[MAX_MOBILES_PER_GNB+1]; + bool sched_csirs; } NR_UEs_t; #define UE_iterator(BaSe, VaR) NR_UE_info_t ** VaR##pptr=BaSe, *VaR; while ((VaR=*(VaR##pptr++))) From 83d40a9b7c4b297133a9e0950fddab27300a1c76 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Mon, 16 May 2022 23:40:13 +0200 Subject: [PATCH 102/105] Add missing parameter preambleTransMax_CE_rel13 To SIB2 and its passing to RRC. Parameter was read but not transfered before. Basic LTE-M functionality should ok on develop branch with this fix. Tested with uBlox SARA-R4 (QCOM chipset) --- openair2/COMMON/rrc_messages_types.h | 2 +- openair2/ENB_APP/enb_config_eMTC.c | 52 ++++++++++++++++++++++++++++ openair2/ENB_APP/enb_paramdef_emtc.h | 4 +-- openair2/RRC/LTE/MESSAGES/asn1_msg.c | 6 ++-- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 5b214cf95a..67b0b610cc 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -167,7 +167,7 @@ typedef struct RadioResourceConfig_s { long ue_TransmissionMode; long ue_multiple_max; //SIB2 BR Options - long *preambleTransMax_CE_r13; + long preambleTransMax_CE_r13; BOOLEAN_t prach_ConfigCommon_v1310; BOOLEAN_t *mpdcch_startSF_CSS_RA_r13; long mpdcch_startSF_CSS_RA_r13_val; diff --git a/openair2/ENB_APP/enb_config_eMTC.c b/openair2/ENB_APP/enb_config_eMTC.c index cfd057bad8..2e71f17e9d 100644 --- a/openair2/ENB_APP/enb_config_eMTC.c +++ b/openair2/ENB_APP/enb_config_eMTC.c @@ -681,6 +681,58 @@ void fill_eMTC_configuration(MessageDef *msg_p, ccparams_eMTC_t *eMTCconfig, in "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_maxHARQ_Msg3Tx choice: 1..8!\n", config_fname, cell_idx,eMTCconfig->ccparams.rach_maxHARQ_Msg3Tx); + switch (eMTCconfig->preambleTransMax_CE_r13) { + case 3: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n3; + break; + + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n4; + break; + + case 5: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n5; + break; + + case 6: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n6; + break; + + case 7: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n7; + break; + + case 8: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n8; + break; + + case 10: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n10; + break; + + case 20: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n20; + break; + + case 50: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n50; + break; + + case 100: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n100; + break; + + case 200: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n200; + break; + + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax_CE_r13 choice: 3,4,5,6,7,8,10,20,50,100,200!\n", + config_fname, cell_idx,eMTCconfig->preambleTransMax_CE_r13); + break; + } + switch (eMTCconfig->ccparams.pcch_defaultPagingCycle) { case 32: RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf32; diff --git a/openair2/ENB_APP/enb_paramdef_emtc.h b/openair2/ENB_APP/enb_paramdef_emtc.h index de774c4ea6..928c9d22e3 100644 --- a/openair2/ENB_APP/enb_paramdef_emtc.h +++ b/openair2/ENB_APP/enb_paramdef_emtc.h @@ -147,7 +147,7 @@ typedef struct ccparams_eMTC_s { int interval_DLHoppingConfigCommonModeA_r13_val; int interval_DLHoppingConfigCommonModeB_r13_val; int mpdcch_pdsch_HoppingOffset_r13; - char *preambleTransMax_CE_r13; + int preambleTransMax_CE_r13; int prach_HoppingOffset_r13; int schedulingInfoSIB1_BR_r13; int64_t fdd_DownlinkOrTddSubframeBitmapBR_val_r13; @@ -253,7 +253,7 @@ typedef struct ccparams_eMTC_s { {ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_B_R13, NULL, 0, strptr:&eMTCconfig->interval_DLHoppingConfigCommonModeB_r13, defstrval:"interval-FDD-r13", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_B_R13_VAL, NULL, 0, iptr:&eMTCconfig->interval_DLHoppingConfigCommonModeB_r13_val, defintval:0, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_MPDCCH_PDSCH_HOPPING_OFFSET_R13, NULL, 0, iptr:&eMTCconfig->mpdcch_pdsch_HoppingOffset_r13, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_PREAMBLE_TRANSMAX_CE_R13, NULL, 0, strptr:&eMTCconfig->preambleTransMax_CE_r13, defstrval:"n10", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_PREAMBLE_TRANSMAX_CE_R13, NULL, 0, iptr:&eMTCconfig->preambleTransMax_CE_r13, defintval:10, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL0, NULL, 0, strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level0_r13, defstrval:"n1", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL1, NULL, 0, strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level1_r13, defstrval:"", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL2, NULL, 0, strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level2_r13, defstrval:"", TYPE_STRING, 0}, \ diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index bd09540627..c34c65b195 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -1331,10 +1331,8 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1 = calloc(1, sizeof(struct LTE_RACH_ConfigCommon__ext1)); memset((*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1, 0, sizeof(struct LTE_RACH_ConfigCommon__ext1)); - if (rrconfig->preambleTransMax_CE_r13) { - (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = calloc(1, sizeof(LTE_PreambleTransMax_t)); - *(*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = *rrconfig->preambleTransMax_CE_r13; // to be re-initialized when we find the enum - } else (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = NULL; + (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = calloc(1, sizeof(LTE_PreambleTransMax_t)); + *(*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = rrconfig->preambleTransMax_CE_r13; // to be re-initialized when we find the enum (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13 = calloc(1, sizeof(LTE_RACH_CE_LevelInfoList_r13_t)); memset((*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13, 0, sizeof(LTE_RACH_CE_LevelInfoList_r13_t)); From 426bc2f0888fec22ba593ef26bfed0d255bf5cca Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 31 May 2022 09:36:39 +0000 Subject: [PATCH 103/105] fix in get_ul_tda call for rtx --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index f2f50d86c6..dfc8b24ed8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1068,7 +1068,7 @@ void pf_ul(module_id_t module_id, LOG_D(NR_MAC,"pf_ul: UE %04x harq_pid %d\n",UE->rnti,sched_pusch->ul_harq_pid); if (sched_pusch->ul_harq_pid >= 0) { /* Allocate retransmission*/ - const int tda = get_ul_tda(nrmac, scc, slot); + const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); bool r = allocate_ul_retransmission(nrmac, frame, slot, rballoc_mask, &n_rb_sched, UE, sched_pusch->ul_harq_pid, sib1, scc, tda); if (!r) { LOG_D(NR_MAC, "%4d.%2d UL retransmission UE RNTI %04x can NOT be allocated\n", frame, slot, UE->rnti); From cd4bc84bd8b3f2feaeaaa51077c51f99e3457cf3 Mon Sep 17 00:00:00 2001 From: KARIM BOUTIBA Date: Thu, 2 Jun 2022 08:05:21 +0000 Subject: [PATCH 104/105] small fix in nr_sdap_get_entity --- openair2/SDAP/nr_sdap/nr_sdap_entity.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.c b/openair2/SDAP/nr_sdap/nr_sdap_entity.c index c5d1c1d6fe..79532748d2 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap_entity.c +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.c @@ -450,7 +450,7 @@ nr_sdap_entity_t *nr_sdap_get_entity(uint16_t rnti, int pdusession_id) { if(sdap_entity == NULL) return NULL; - while(sdap_entity->rnti != rnti && sdap_entity->next_entity != NULL) { + while(( sdap_entity->rnti != rnti || sdap_entity->pdusession_id != pdusession_id ) && sdap_entity->next_entity != NULL) { sdap_entity = sdap_entity->next_entity; } @@ -460,6 +460,7 @@ nr_sdap_entity_t *nr_sdap_get_entity(uint16_t rnti, int pdusession_id) { return NULL; } + void delete_nr_sdap_entity(uint16_t rnti) { nr_sdap_entity_t *entityPtr, *entityPrev = NULL; entityPtr = sdap_info.sdap_entity_llist; From 45522ae86c5e591beeafe5bab97cce26f5ed4c3e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sat, 4 Jun 2022 10:10:47 +0200 Subject: [PATCH 105/105] [CI] Increase LTE-2x2 test ping thresholds to make test pass --- ci-scripts/xml_files/lte_2x2_tm1_quectel.xml | 4 ++-- ci-scripts/xml_files/lte_2x2_tm2_quectel.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml b/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml index 6aa53200c8..0d18a52839 100644 --- a/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml +++ b/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml @@ -88,7 +88,7 @@ nrmodule2_quectel -c 20 1 - 40 + 60 Ping @@ -96,7 +96,7 @@ nrmodule2_quectel -c 100 -s 1024 -i 0,2 1 - 40 + 60 diff --git a/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml b/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml index 84aa87aa23..f84691ab48 100644 --- a/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml +++ b/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml @@ -88,7 +88,7 @@ nrmodule2_quectel -c 20 1 - 40 + 60 Ping @@ -96,7 +96,7 @@ nrmodule2_quectel -c 100 -s 1024 -i 0,2 1 - 40 + 60