From d820051397c829a15fb8589c7fb9352aed74e4c2 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 21 Feb 2022 17:46:02 +0000 Subject: [PATCH 01/50] 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; -- GitLab From 777074ff7921b2e3dbf676ad2adffec81fe5112d Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 21 Feb 2022 20:23:27 +0000 Subject: [PATCH 02/50] 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; -- GitLab From 580f56c869ec38e30a558caa690375ec7b707584 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 10:08:39 +0000 Subject: [PATCH 03/50] 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; -- GitLab From 628726caae481303412f73219c523899bcd26c63 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 13:33:36 +0000 Subject: [PATCH 04/50] 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 -- GitLab From cf284d76f090016f11a2284f66488a1367ab3e53 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 17:49:59 +0000 Subject: [PATCH 05/50] 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) { -- GitLab From bb82697819c30459e8e6053cc4be18d382ce89d7 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 19:14:17 +0000 Subject: [PATCH 06/50] 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; -- GitLab From 0ced14a56d1e5a2eaeb4001d965e85066fb4c1e0 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 20:02:15 +0000 Subject: [PATCH 07/50] 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; -- GitLab From ed6aa9f505e7ba65817acab7a58c12056ae27502 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Feb 2022 20:09:58 +0000 Subject: [PATCH 08/50] 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 { -- GitLab From 4d1736414264dbe87bdd90b9ad83f37c9ff154ba Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 14:16:58 +0000 Subject: [PATCH 09/50] 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) -- GitLab From 3ae8f393f4e37a54f3287cc08b968149e5579ba3 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 15:05:02 +0000 Subject: [PATCH 10/50] 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; -- GitLab From 5bae6dd6f3630e4205dc36e93b1b32d83b4f6e94 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 16:11:13 +0000 Subject: [PATCH 11/50] 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; -- GitLab From fdce62f7995aae6dbc8ec91b881ae26c01d3d080 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 18:05:45 +0000 Subject: [PATCH 12/50] 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 -- GitLab From 05a9c0e264d7f519c70e66bdad91cc9e21228a4a Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 18:12:36 +0000 Subject: [PATCH 13/50] 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; } } } -- GitLab From 853776ef2f46ee6669fab5ba3d424829cd3cc530 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 19:32:20 +0000 Subject: [PATCH 14/50] 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; -- GitLab From 3eaebbca935d871dde073c94ef273e50a0b34143 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 23 Feb 2022 20:23:34 +0000 Subject: [PATCH 15/50] 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]) { -- GitLab From c272bb2f7cbe07caa14464e86e84a52a8cfcac80 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 2 Mar 2022 15:23:15 +0000 Subject: [PATCH 16/50] 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; } } -- GitLab From 6c27a40f0915cf63b7ef37318fc6d02ae555dfc2 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 2 Mar 2022 16:30:54 +0000 Subject: [PATCH 17/50] 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; } } -- GitLab From 35324cfa1259313aa83fc3b473318515bfb2d577 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 2 Mar 2022 18:30:02 +0000 Subject: [PATCH 18/50] 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; } -- GitLab From de8aa24de5474360f44b721e619821c6546b5e41 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Sat, 5 Mar 2022 01:37:38 +0000 Subject: [PATCH 19/50] 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; } -- GitLab From bb89ae3aca13ed28d957c80a5c075c775f60667a Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Fri, 4 Mar 2022 14:34:26 +0000 Subject: [PATCH 20/50] 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; -- GitLab From a77769d45b9e4823e4a87bbd2515b121aef08c32 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Sat, 5 Mar 2022 02:32:34 +0000 Subject: [PATCH 21/50] 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"); -- GitLab From db0ce84aa5bc57feb16fe711d1d155e7d396e9f5 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 8 Mar 2022 13:18:17 +0000 Subject: [PATCH 22/50] 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; -- GitLab From 51a72b847947e550adef85514e529247971848eb Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 9 Mar 2022 15:07:23 +0000 Subject: [PATCH 23/50] 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; -- GitLab From 19d8ea274257ee1afdf536554db11389bd0d8ba7 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 9 Mar 2022 17:59:32 +0000 Subject: [PATCH 24/50] 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; } -- GitLab From 0126bd849b8935ed23a69ddd618c1b2de36604b1 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 9 Mar 2022 19:18:30 +0000 Subject: [PATCH 25/50] 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; -- GitLab From 670f979f977ad68612c56fc1ede58118166dd4ae Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 9 Mar 2022 20:00:41 +0000 Subject: [PATCH 26/50] 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; -- GitLab From e56f28434712c4da0ac73f9b5dca9170ff8c513c Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 14 Mar 2022 15:29:10 +0000 Subject: [PATCH 27/50] 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; -- GitLab From ce1613ad7c73faf60500980f3c212dd4e748eced Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 15 Mar 2022 18:55:50 +0000 Subject: [PATCH 28/50] 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 | 196 +++++++++++++-------- openair1/PHY/defs_nr_common.h | 15 +- 5 files changed, 171 insertions(+), 87 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++) { - - 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 (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; } - 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; -- GitLab From 8b0409d349390cc19a5cf0e076fd7e044d5ad09a Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 16 Mar 2022 01:34:23 +0000 Subject: [PATCH 29/50] 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; - - 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]; + 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)); + } - 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]; + 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]; + } + } + } + } - 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 -- GitLab From f1eb2e15d4402b5a2abe415af1d98449f0ae590c Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 16 Mar 2022 13:03:31 +0000 Subject: [PATCH 30/50] 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)); -- GitLab From 2f9d8e759dc534aa8ca09bb0ccc2804604c4a58f Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 16 Mar 2022 15:21:55 +0000 Subject: [PATCH 31/50] 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 } -- GitLab From 3f88cc1fb109de78cd154b9da1ea159691c8b6b3 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 16 Mar 2022 17:19:36 +0000 Subject: [PATCH 32/50] 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)); -- GitLab From ea22da6e7a71f58631c4b730a6208b519793710c Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 17 Mar 2022 00:50:35 +0000 Subject: [PATCH 33/50] 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; } -- GitLab From 8704f810256b6c9a7386643dd677169bb5617293 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 17 Mar 2022 16:35:06 +0000 Subject: [PATCH 34/50] 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); -- GitLab From 190eaa1e4247a24e38cccce11f56275bf68cf744 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 17 Mar 2022 16:36:50 +0000 Subject: [PATCH 35/50] 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, -- GitLab From f439095c6ee036ca46211352144b11f7a0af2495 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Thu, 17 Mar 2022 18:19:42 +0000 Subject: [PATCH 36/50] 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++; -- GitLab From 7ecd593f6b1972482c66261391f79e14af2c7e1a Mon Sep 17 00:00:00 2001 From: rmagueta Date: Fri, 18 Mar 2022 17:55:53 +0000 Subject: [PATCH 37/50] 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]); -- GitLab From 199680d24df1bd0ea7529fafd8849e19b64779af Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 21 Mar 2022 17:37:29 +0000 Subject: [PATCH 38/50] 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); -- GitLab From 181e576698dc5d7c8f40872ee4f214551e33541b Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 28 Mar 2022 10:31:50 +0100 Subject: [PATCH 39/50] 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, -- GitLab From e322bdb289953ab187a91303f10d18850eba1fe9 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 28 Mar 2022 14:10:39 +0100 Subject: [PATCH 40/50] 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], -- GitLab From 139a33d6446e6f42651b766e6b54c3e6c4f63a42 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 28 Mar 2022 14:36:01 +0100 Subject: [PATCH 41/50] 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; } } -- GitLab From 25614263baec66880377e47fc4b6ff733ade60b5 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Fri, 1 Apr 2022 16:15:58 +0100 Subject: [PATCH 42/50] 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 -- GitLab From a772400ffa0965e019bb10ae545fe13605b0a8ee Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 4 Apr 2022 13:14:18 +0100 Subject: [PATCH 43/50] 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++){ -- GitLab From d6072cb5d2c5d296bc1673bd96c06cf5bf2155d4 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 12 Apr 2022 14:31:39 +0100 Subject: [PATCH 44/50] 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" -- GitLab From f94a479829bdb7fbf228a8843807fd517b2b88d0 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 12:51:18 +0100 Subject: [PATCH 45/50] 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 && -- GitLab From e5c4e0f3d3167b7542319b193087559d04f13f45 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 12:59:24 +0100 Subject: [PATCH 46/50] 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++; -- GitLab From 2d96262d7c952789e5800b53a0be14c0c5c129dd Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 14:31:13 +0100 Subject: [PATCH 47/50] 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; } } } -- GitLab From 436eb2d5a9beed5d4bc7523783ae9bc5a79a5315 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 16:05:38 +0100 Subject: [PATCH 48/50] 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)); -- GitLab From 3d5cfb6642cfc47140ef36aae02224c647ac0f93 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 18 May 2022 17:00:05 +0100 Subject: [PATCH 49/50] 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)); } -- GitLab From ab1df8bbc4a202752d8be138f3895af67d103d20 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Tue, 24 May 2022 13:45:35 +0100 Subject: [PATCH 50/50] 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); -- GitLab