From 184e151fde961300bf7179b6123a728dee7ee0a3 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Mar 2022 17:40:06 +0000 Subject: [PATCH 01/71] Fix build after merge --- openair1/PHY/INIT/nr_init_ue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 45cb2849dd..f1dd418dbf 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -337,6 +337,9 @@ 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; + // ceil((NB_RB*8(max allocation per RB)*2(QPSK))/32) + int csi_dmrs_init_length = ((fp->N_RB_DL<<4)>>5)+1; + 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"); @@ -344,7 +347,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) 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)); + ue->nr_csi_rs_info->nr_gold_csi_rs[slot][symb] = (uint32_t *)malloc16(csi_dmrs_init_length*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); } } From 17504695f833173413593e2f8c56970689d0cb44 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Mar 2022 18:02:12 +0000 Subject: [PATCH 02/71] Fix updated configurations that was reverted in merge --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 319aa535e7..5f1b43c998 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1137,7 +1137,7 @@ void fill_default_csi_MeasConfig(int uid, 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; + csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (8 + (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; @@ -1196,7 +1196,7 @@ void fill_default_csi_MeasConfig(int uid, 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; + csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (28 + (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; From e834acfaf2396b7a56088d85ccb92a9090213621 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Mar 2022 18:25:29 +0000 Subject: [PATCH 03/71] Temporary commit to test CSI-RS without core --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 44 +++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 5f1b43c998..f90bdaa597 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1307,8 +1307,13 @@ 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; + + // TODO: Remove this if + if(!carrier->do_CSIRS) { + 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; @@ -1575,13 +1580,13 @@ void fill_initial_SpCellConfig(int uid, bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); - *bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; - bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation = NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; - bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; - bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); - bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = - calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); - *bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; + *bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; + bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation = NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; + bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; + bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); + bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = + calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); + *bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList)); NR_TCI_State_t *tcic; @@ -1602,6 +1607,25 @@ 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; + // TODO: Delete this code and calls in update_cellGroupConfig() + 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); + } + pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; pdsch_servingcellconfig->xOverhead = NULL; pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH)); @@ -1709,6 +1733,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc = carrier->servingcellconfigcommon; // Config CSI-RS + /* if (carrier->do_CSIRS) { struct NR_PUCCH_Config__spatialRelationInfoToAddModList *spatialRelationInfoToAddModList = calloc(1,sizeof(*spatialRelationInfoToAddModList)); NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); @@ -1726,6 +1751,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, } fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig, scc, carrier); } + */ // Set DL MCS table NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP; From 3e664b5eb7e5b26396e147a5b0786c4df7adc59a Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 22 Mar 2022 18:28:49 +0000 Subject: [PATCH 04/71] Fix warning --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 1a37e8c6d9..8a5535c1a7 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -225,7 +225,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { } } - int dumpsig=0; + //int dumpsig=0; // if all segments are done if (rdata->nbSegments == ulsch_harq->processedSegments) { if (decodeSuccess) { From c7a54269de4dd75bf94765b2fe9f71fe48cd9ae2 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 30 Mar 2022 16:16:58 +0100 Subject: [PATCH 05/71] First version of rank indicator computation at UE --- openair1/PHY/INIT/nr_init_ue.c | 2 + openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 123 ++++++++++++++++++++++++++ openair1/PHY/defs_nr_common.h | 7 ++ 3 files changed, 132 insertions(+) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 6d2655cb93..033ea2eec6 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -351,6 +351,7 @@ 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->rank_indicator = (uint8_t*)malloc16_clear(sizeof(uint8_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)); @@ -642,6 +643,7 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) 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->rank_indicator); 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); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index fd33398f5c..138d5ff7ca 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -355,6 +355,114 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, return 0; } +int nr_csi_rs_ri_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_estimated_channel_freq, + uint8_t *rank_indicator) { + + NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + int16_t cond_dB_threshold = 0; + int count=0; + *rank_indicator = 0; + + /* Example 2x2: Hh x H = + * | conjch00 conjch10 | x | ch00 ch01 | = | conjch00*ch00+conjch10*ch10 conjch00*ch01+conjch10*ch11 | + * | conjch01 conjch11 | | ch10 ch11 | | conjch01*ch00+conjch11*ch10 conjch01*ch01+conjch11*ch11 | + */ + + 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; + + // conjch x ch computation + for (int ant_rx_conjch = 0; ant_rx_conjch < frame_parms->nb_antennas_rx; ant_rx_conjch++) { + for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { + for (int ant_rx_ch = 0; ant_rx_ch < frame_parms->nb_antennas_rx; ant_rx_ch++) { + for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { + nr_conjch0_mult_ch1(&csi_rs_estimated_channel_freq[ant_rx_conjch][port_tx_conjch][k], + &csi_rs_estimated_channel_freq[ant_rx_ch][port_tx_ch][k], + &nr_csi_rs_info->csi_rs_estimated_conjch_ch[ant_rx_conjch][port_tx_conjch][ant_rx_ch][port_tx_ch][k], + 1, + 0); + } + } + } + } + + // construct Hh x H elements + nr_construct_HhH_elements(0 < frame_parms->nb_antennas_rx && 0 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[0][0][0][0][k] : NULL, + 0 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[0][1][0][1][k] : NULL, + 1 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[1][1][1][1][k] : NULL, + 1 < frame_parms->nb_antennas_rx && 0 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[1][0][1][0][k] : NULL, + 2 < frame_parms->nb_antennas_rx && 0 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[2][0][2][0][k] : NULL, + 2 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[2][1][2][1][k] : NULL, + 3 < frame_parms->nb_antennas_rx && 0 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[3][0][3][0][k] : NULL, + 3 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[3][1][3][1][k] : NULL, + 0 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[0][0][0][1][k] : NULL, + 0 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[0][1][0][0][k] : NULL, + 1 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[1][0][1][1][k] : NULL, + 1 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[1][1][1][0][k] : NULL, + 2 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[2][0][2][1][k] : NULL, + 2 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[2][1][2][0][k] : NULL, + 3 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[3][0][3][1][k] : NULL, + 3 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[3][1][3][0][k] : NULL, + &nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], + 1, + 0); + + // compute the determinant of A_MF (denominator) + nr_det_HhH(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], + &nr_csi_rs_info->csi_rs_estimated_determ_fin[k], + 1, + 0, + 0); + + // compute the square of A_MF (numerator) + squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][0][k], 1); + squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][1][k], 1); + squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][0][k], 1); + squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][1][k], 1); + numer(&nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][1][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][1][k], + &nr_csi_rs_info->csi_rs_estimated_numer_fin[k], + 1); + + // compute the conditional number + for (int sc_idx=0; sc_idx < NR_NB_SC_PER_RB; sc_idx++) { + int8_t csi_rs_estimated_denum_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_determ_fin[k + sc_idx]); + int8_t csi_rs_estimated_numer_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_numer_fin[k + k]); + int8_t cond_db = csi_rs_estimated_numer_db - csi_rs_estimated_denum_db; + if (cond_db < cond_dB_threshold) { + count++; + } else { + count--; + } + } + } + + // conditional number is lower than cond_dB_threshold in half on more REs + if (count > 0) { + *rank_indicator = 1; + } + + LOG_I(NR_PHY, "count %i, RI = %i\n", *rank_indicator + 1); + + 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; } @@ -406,5 +514,20 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t 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); + + if(ue->frame_parms.nb_antennas_rx == 1 || ue->nr_csi_rs_info->N_ports == 1) { + *ue->nr_csi_rs_info->rank_indicator = 0; + } else if(ue->frame_parms.nb_antennas_rx == 2 && ue->nr_csi_rs_info->N_ports == 2) { + nr_csi_rs_ri_estimation(ue, + proc, + csirs_config_pdu, + ue->nr_csi_rs_info, + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + ue->nr_csi_rs_info->rank_indicator); + } else { + LOG_D(NR_PHY, "Rank indicator computation is not implemented for %i x %i system\n", + ue->frame_parms.nb_antennas_rx, ue->nr_csi_rs_info->N_ports); + } + return 0; } diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 87eed8c4fc..1ed5eee07c 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -43,6 +43,7 @@ #define nr_slot_t lte_subframe_t #define MAX_NUM_SUBCARRIER_SPACING 5 +#define NR_MAX_OFDM_SYMBOL_SIZE 4096 #define NR_NB_SC_PER_RB 12 #define NR_NB_REG_PER_CCE 6 @@ -260,7 +261,13 @@ typedef struct { int32_t **csi_rs_received_signal; int32_t ***csi_rs_ls_estimated_channel; int32_t ***csi_rs_estimated_channel_freq; + int32_t csi_rs_estimated_conjch_ch[4][4][4][4][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); + int32_t csi_rs_estimated_A_MF[2][2][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); + int32_t csi_rs_estimated_A_MF_sq[2][2][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); + int32_t csi_rs_estimated_determ_fin[NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); + int32_t csi_rs_estimated_numer_fin[NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); uint32_t *noise_power; + uint8_t *rank_indicator; } nr_csi_rs_info_t; typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; From 38d0dca0bf2df12799db7adcd101d2fa7a4400d4 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 30 Mar 2022 17:00:25 +0100 Subject: [PATCH 06/71] Minor fixes --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 138d5ff7ca..5465e22874 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -443,7 +443,7 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, // compute the conditional number for (int sc_idx=0; sc_idx < NR_NB_SC_PER_RB; sc_idx++) { int8_t csi_rs_estimated_denum_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_determ_fin[k + sc_idx]); - int8_t csi_rs_estimated_numer_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_numer_fin[k + k]); + int8_t csi_rs_estimated_numer_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_numer_fin[k + sc_idx]); int8_t cond_db = csi_rs_estimated_numer_db - csi_rs_estimated_denum_db; if (cond_db < cond_dB_threshold) { count++; @@ -458,7 +458,7 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, *rank_indicator = 1; } - LOG_I(NR_PHY, "count %i, RI = %i\n", *rank_indicator + 1); + LOG_I(NR_PHY, "RI = %i\n", *rank_indicator + 1); return 0; } From fba2df755796101683383f7e26ef51fae385075e Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 30 Mar 2022 19:27:24 +0100 Subject: [PATCH 07/71] Fix config files after merge --- targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf | 2 +- .../GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf | 2 +- .../GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf | 2 +- .../GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf | 2 +- .../GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf index c07a0db649..29acadb708 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf @@ -45,7 +45,7 @@ gNBs = remote_s_portc = 500; remote_s_portd = 2152; ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_N1 = 1; pusch_AntennaPorts = 1; min_rxtxtime = 6; sib1_tda = 0; 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 b5fe03c89b..e1c970aa62 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 @@ -33,7 +33,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_N1 = 1; pusch_AntennaPorts = 1; min_rxtxtime = 2; sib1_tda = 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..4b3d886cdf 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 @@ -33,7 +33,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_N1 = 1; pusch_AntennaPorts = 1; min_rxtxtime = 6; sib1_tda = 0; 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 1fe6b30bf2..69bd4f7a7c 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 @@ -33,7 +33,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_N1 = 1; pusch_AntennaPorts = 1; min_rxtxtime = 2; sib1_tda = 0; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf index bd3076a014..1259951422 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf @@ -33,7 +33,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_N1 = 1; pusch_AntennaPorts = 1; sib1_tda = 15; min_rxtxtime = 6; From da1e542a31669ef10d9fbc64d00c721384682617 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 30 Mar 2022 20:14:57 +0100 Subject: [PATCH 08/71] Fix dl_antenna_ports after merge --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index f90bdaa597..ba785f8cf2 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1008,12 +1008,13 @@ void fill_default_csi_MeasConfig(int uid, rrc_gNB_carrier_data_t *carrier) { int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + int dl_antenna_ports = carrier->pdsch_AntennaPorts.N1 * carrier->pdsch_AntennaPorts.N2 * carrier->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, carrier->do_CSIRS); csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; @@ -1107,7 +1108,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 +1126,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; From bc2ea375c846f36410177f042b379f00b5503d9f Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 31 Mar 2022 20:30:00 +0100 Subject: [PATCH 09/71] Replace nr_construct_HhH_elements by nr_a_sum_b function in nr_csi_rs_ri_estimation --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 74 +++++++---------- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 83 +++++++++++++++++++ .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 42 ++++++---- 3 files changed, 140 insertions(+), 59 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 5465e22874..6b7c045061 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -372,6 +372,12 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, * | conjch01 conjch11 | | ch10 ch11 | | conjch01*ch00+conjch11*ch10 conjch01*ch01+conjch11*ch11 | */ + for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { + for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { + memset(nr_csi_rs_info->csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch],0,NR_MAX_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++) { if (csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { @@ -379,66 +385,48 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, } uint16_t k = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; - // conjch x ch computation for (int ant_rx_conjch = 0; ant_rx_conjch < frame_parms->nb_antennas_rx; ant_rx_conjch++) { for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { for (int ant_rx_ch = 0; ant_rx_ch < frame_parms->nb_antennas_rx; ant_rx_ch++) { for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { + + // conjch x ch computation nr_conjch0_mult_ch1(&csi_rs_estimated_channel_freq[ant_rx_conjch][port_tx_conjch][k], &csi_rs_estimated_channel_freq[ant_rx_ch][port_tx_ch][k], &nr_csi_rs_info->csi_rs_estimated_conjch_ch[ant_rx_conjch][port_tx_conjch][ant_rx_ch][port_tx_ch][k], 1, 0); + + // construct Hh x H elements + if(ant_rx_conjch == ant_rx_ch) { + nr_a_sum_b((__m128i *)&nr_csi_rs_info->csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch][k], + (__m128i *)&nr_csi_rs_info->csi_rs_estimated_conjch_ch[ant_rx_conjch][port_tx_conjch][ant_rx_ch][port_tx_ch][k], + 1); + } } } } } - // construct Hh x H elements - nr_construct_HhH_elements(0 < frame_parms->nb_antennas_rx && 0 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[0][0][0][0][k] : NULL, - 0 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[0][1][0][1][k] : NULL, - 1 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[1][1][1][1][k] : NULL, - 1 < frame_parms->nb_antennas_rx && 0 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[1][0][1][0][k] : NULL, - 2 < frame_parms->nb_antennas_rx && 0 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[2][0][2][0][k] : NULL, - 2 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[2][1][2][1][k] : NULL, - 3 < frame_parms->nb_antennas_rx && 0 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[3][0][3][0][k] : NULL, - 3 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[3][1][3][1][k] : NULL, - 0 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[0][0][0][1][k] : NULL, - 0 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[0][1][0][0][k] : NULL, - 1 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[1][0][1][1][k] : NULL, - 1 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[1][1][1][0][k] : NULL, - 2 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[2][0][2][1][k] : NULL, - 2 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[2][1][2][0][k] : NULL, - 3 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[3][0][3][1][k] : NULL, - 3 < frame_parms->nb_antennas_rx && 1 < nr_csi_rs_info->N_ports ? &nr_csi_rs_info->csi_rs_estimated_conjch_ch[3][1][3][0][k] : NULL, - &nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], - 1, - 0); - // compute the determinant of A_MF (denominator) - nr_det_HhH(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], - &nr_csi_rs_info->csi_rs_estimated_determ_fin[k], - 1, - 0, - 0); + nr_det_A_MF_2x2(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], + &nr_csi_rs_info->csi_rs_estimated_determ_fin[k], + 1); // compute the square of A_MF (numerator) - squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][0][k], 1); - squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][1][k], 1); - squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][0][k], 1); - squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][1][k], 1); - numer(&nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][1][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][1][k], - &nr_csi_rs_info->csi_rs_estimated_numer_fin[k], - 1); + nr_squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][0][k], 1); + nr_squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][1][k], 1); + nr_squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][0][k], 1); + nr_squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][1][k], 1); + nr_numer_2x2(&nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][1][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][0][k], + &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][1][k], + &nr_csi_rs_info->csi_rs_estimated_numer_fin[k], + 1); // compute the conditional number for (int sc_idx=0; sc_idx < NR_NB_SC_PER_RB; sc_idx++) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 69eccaf02e..07e7e5c3bb 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -1869,6 +1869,89 @@ void nr_dlsch_detection_mrc(int **rxdataF_comp, #endif } +void nr_det_A_MF_2x2(int32_t *a_mf_00, + int32_t *a_mf_01, + int32_t *a_mf_10, + int32_t *a_mf_11, + int32_t *det_fin, + unsigned short nb_rb) { + + int16_t nr_conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; + + __m128i ad_re_128, bc_re_128, det_re_128; + + __m128i *a_mf_00_128 = (__m128i *)a_mf_00; + __m128i *a_mf_01_128 = (__m128i *)a_mf_01; + __m128i *a_mf_10_128 = (__m128i *)a_mf_10; + __m128i *a_mf_11_128 = (__m128i *)a_mf_11; + __m128i *det_fin_128 = (__m128i *)det_fin; + + for (int rb = 0; rb<3*nb_rb; rb++) { + + //complex multiplication (I_a+jQ_a)(I_d+jQ_d) = (I_aI_d - Q_aQ_d) + j(Q_aI_d + I_aQ_d) + //The imag part is often zero, we compute only the real part + ad_re_128 = _mm_sign_epi16(a_mf_00_128[0],*(__m128i*)&nr_conjug2[0]); + ad_re_128 = _mm_madd_epi16(ad_re_128,a_mf_11_128[0]); //Re: I_a0*I_d0 - Q_a1*Q_d1 + + //complex multiplication (I_b+jQ_b)(I_c+jQ_c) = (I_bI_c - Q_bQ_c) + j(Q_bI_c + I_bQ_c) + //The imag part is often zero, we compute only the real part + bc_re_128 = _mm_sign_epi16(a_mf_01_128[0],*(__m128i*)&nr_conjug2[0]); + bc_re_128 = _mm_madd_epi16(bc_re_128,a_mf_10_128[0]); //Re: I_b0*I_c0 - Q_b1*Q_c1 + + det_re_128 = _mm_sub_epi32(ad_re_128, bc_re_128); + + //det in Q30 format + det_fin_128[0] = _mm_abs_epi32(det_re_128); + + det_fin_128+=1; + a_mf_00_128+=1; + a_mf_01_128+=1; + a_mf_10_128+=1; + a_mf_11_128+=1; + } + _mm_empty(); + _m_empty(); +} + +void nr_squared_matrix_element(int32_t *a, + int32_t *a_sq, + unsigned short nb_rb) { + __m128i *a_128 = (__m128i *)a; + __m128i *a_sq_128 = (__m128i *)a_sq; + for (int rb=0; rb<3*nb_rb; rb++) { + a_sq_128[0] = _mm_madd_epi16(a_128[0], a_128[0]); + a_sq_128+=1; + a_128+=1; + } + _mm_empty(); + _m_empty(); +} + +void nr_numer_2x2(int32_t *a_00_sq, + int32_t *a_01_sq, + int32_t *a_10_sq, + int32_t *a_11_sq, + int32_t *num_fin, + unsigned short nb_rb) { + __m128i *a_00_sq_128 = (__m128i *)a_00_sq; + __m128i *a_01_sq_128 = (__m128i *)a_01_sq; + __m128i *a_10_sq_128 = (__m128i *)a_10_sq; + __m128i *a_11_sq_128 = (__m128i *)a_11_sq; + __m128i *num_fin_128 = (__m128i *)num_fin; + for (int rb=0; rb<3*nb_rb; rb++) { + __m128i sq_a_plus_sq_d_128 = _mm_add_epi32(a_00_sq_128[0], a_11_sq_128[0]); + __m128i sq_b_plus_sq_c_128 = _mm_add_epi32(a_01_sq_128[0], a_10_sq_128[0]); + num_fin_128[0] = _mm_add_epi32(sq_a_plus_sq_d_128, sq_b_plus_sq_c_128); + num_fin_128+=1; + a_00_sq_128+=1; + a_01_sq_128+=1; + a_10_sq_128+=1; + a_11_sq_128+=1; + } + _mm_empty(); + _m_empty(); +} + /* Zero Forcing Rx function: nr_a_sum_b() * Compute the complex addition x=x+y * diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index e1df279abf..c2bf41c923 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -851,10 +851,6 @@ void construct_HhH_elements(int *ch0conj_ch0, int32_t *after_mf_11, unsigned short nb_rb); -void squared_matrix_element(int32_t *Hh_h_00, - int32_t *Hh_h_00_sq, - unsigned short nb_rb); - void dlsch_channel_level_TM34_meas(int *ch00, int *ch01, int *ch10, @@ -881,19 +877,33 @@ void nr_dlsch_detection_mrc(int **rxdataF_comp, unsigned short nb_rb, int length); -void det_HhH(int32_t *after_mf_00, - int32_t *after_mf_01, - int32_t *after_mf_10, - int32_t *after_mf_11, - int32_t *det_fin_128, - unsigned short nb_rb); +void nr_conjch0_mult_ch1(int *ch0, + int *ch1, + int32_t *ch0conj_ch1, + unsigned short nb_rb, + unsigned char output_shift0); -void numer(int32_t *Hh_h_00_sq, - int32_t *Hh_h_01_sq, - int32_t *Hh_h_10_sq, - int32_t *Hh_h_11_sq, - int32_t *num_fin, - unsigned short nb_rb); +void nr_a_sum_b(__m128i *input_x, + __m128i *input_y, + unsigned short nb_rb); + +void nr_det_A_MF_2x2(int32_t *a_mf_00, + int32_t *a_mf_01, + int32_t *a_mf_10, + int32_t *a_mf_11, + int32_t *det_fin, + unsigned short nb_rb); + +void nr_squared_matrix_element(int32_t *a, + int32_t *a_sq, + unsigned short nb_rb); + +void nr_numer_2x2(int32_t *a_00_sq, + int32_t *a_01_sq, + int32_t *a_10_sq, + int32_t *a_11_sq, + int32_t *num_fin, + unsigned short nb_rb); uint8_t rank_estimation_tm3_tm4(int *dl_ch_estimates_00, int *dl_ch_estimates_01, From e628c8c2c41a8296f16f0af2090db3570aafc3c0 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Fri, 1 Apr 2022 20:13:06 +0100 Subject: [PATCH 10/71] Fix build after merge --- openair2/GNB_APP/gnb_paramdef.h | 2 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 10 +++++----- openair2/RRC/NR/nr_rrc_config.c | 3 ++- openair2/RRC/NR/nr_rrc_config.h | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h index 1503342f0f..3458be4f45 100644 --- a/openair2/GNB_APP/gnb_paramdef.h +++ b/openair2/GNB_APP/gnb_paramdef.h @@ -160,7 +160,7 @@ typedef enum { {GNB_CONFIG_STRING_NRCELLID, NULL, 0, u64ptr:NULL, defint64val:1, TYPE_UINT64, 0}, \ {GNB_CONFIG_STRING_MINRXTXTIME, NULL, 0, iptr:NULL, defintval:2, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_ULPRBBLACKLIST, NULL, 0, strptr:NULL, defstrval:"", TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_UMONDEFAULTDRB, NULL, 0, uptr:NULL, defuintval:0, TYPE_UINT, 0} \ +{GNB_CONFIG_STRING_UMONDEFAULTDRB, NULL, 0, uptr:NULL, defuintval:0, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_FORCE256QAMOFF, GNB_CONFIG_HLP_FORCE256QAMOFF, PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0} \ } diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index c3a1a49084..562eaad64d 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1310,7 +1310,7 @@ void fill_initial_SpCellConfig(int uid, pucchspatial->servingCellId = NULL; // TODO: Remove this if - if(!carrier->do_CSIRS) { + if(!configuration->do_CSIRS) { pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; pucchspatial->referenceSignal.choice.ssb_Index = 0; } @@ -1609,7 +1609,7 @@ void fill_initial_SpCellConfig(int uid, SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig; // TODO: Delete this code and calls in update_cellGroupConfig() - if (carrier->do_CSIRS) { + 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; @@ -1624,7 +1624,7 @@ void fill_initial_SpCellConfig(int uid, 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); } pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; @@ -1758,14 +1758,14 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, // 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, bwp_Dedicated, scc); + configuration->force_256qam_off ? NULL : uecap, SpCellConfig, bwp_Dedicated, scc); struct NR_ServingCellConfig__downlinkBWP_ToAddModList *DL_BWP_list = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; if (DL_BWP_list) { for (int i=0; ilist.count; i++){ NR_BWP_Downlink_t *bwp = DL_BWP_list->list.array[i]; int scs = bwp->bwp_Common->genericParameters.subcarrierSpacing; - set_dl_mcs_table(scs, configuration->force_256qam_off ? NULL : uecap, bwp->bwp_Dedicated, carrier->servingcellconfigcommon); + set_dl_mcs_table(scs, configuration->force_256qam_off ? NULL : uecap, SpCellConfig, bwp->bwp_Dedicated, carrier->servingcellconfigcommon); } } } diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 6025105350..4e373900bd 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -304,7 +304,8 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){ } } -void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, +void set_dl_mcs_table(int scs, + NR_UE_NR_Capability_t *cap, NR_SpCellConfig_t *SpCellConfig, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_ServingCellConfigCommon_t *scc) { diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 63df31d1a7..cce03ed02a 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -119,7 +119,8 @@ void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, int num_dl_antenna_ports, int curr_bwp, int do_csirs); -void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, +void set_dl_mcs_table(int scs, + NR_UE_NR_Capability_t *cap, NR_SpCellConfig_t *SpCellConfig, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_ServingCellConfigCommon_t *scc); From c37e0af9b0aa8878fc8a9efb9bd2f1614ea28958 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 4 Apr 2022 14:42:37 +0100 Subject: [PATCH 11/71] Change LOG levels --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 6b7c045061..6e84f80894 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -364,9 +364,18 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int16_t cond_dB_threshold = 0; - int count=0; + int count = 0; *rank_indicator = 0; + if (ue->frame_parms.nb_antennas_rx == 1 || ue->nr_csi_rs_info->N_ports == 1) { + LOG_I(NR_PHY, "RI = %i\n", *rank_indicator + 1); + return 0; + } else if( !(ue->frame_parms.nb_antennas_rx == 2 && ue->nr_csi_rs_info->N_ports == 2) ) { + LOG_W(NR_PHY, "Rank indicator computation is not implemented for %i x %i system\n", + ue->frame_parms.nb_antennas_rx, ue->nr_csi_rs_info->N_ports); + return -1; + } + /* Example 2x2: Hh x H = * | conjch00 conjch10 | x | ch00 ch01 | = | conjch00*ch00+conjch10*ch10 conjch00*ch01+conjch10*ch11 | * | conjch01 conjch11 | | ch10 ch11 | | conjch01*ch00+conjch11*ch10 conjch01*ch01+conjch11*ch11 | @@ -503,19 +512,12 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, ue->nr_csi_rs_info->noise_power); - if(ue->frame_parms.nb_antennas_rx == 1 || ue->nr_csi_rs_info->N_ports == 1) { - *ue->nr_csi_rs_info->rank_indicator = 0; - } else if(ue->frame_parms.nb_antennas_rx == 2 && ue->nr_csi_rs_info->N_ports == 2) { - nr_csi_rs_ri_estimation(ue, - proc, - csirs_config_pdu, - ue->nr_csi_rs_info, - ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, - ue->nr_csi_rs_info->rank_indicator); - } else { - LOG_D(NR_PHY, "Rank indicator computation is not implemented for %i x %i system\n", - ue->frame_parms.nb_antennas_rx, ue->nr_csi_rs_info->N_ports); - } + nr_csi_rs_ri_estimation(ue, + proc, + csirs_config_pdu, + ue->nr_csi_rs_info, + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + ue->nr_csi_rs_info->rank_indicator); return 0; } From 03f7bd34686cb72d7299938a89750fae20859c6b Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 4 Apr 2022 14:44:22 +0100 Subject: [PATCH 12/71] Remove unused input in nr_csi_rs_ri_estimation --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 6e84f80894..215f6d3d6a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -356,7 +356,6 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, } int nr_csi_rs_ri_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_estimated_channel_freq, @@ -513,7 +512,6 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->nr_csi_rs_info->noise_power); nr_csi_rs_ri_estimation(ue, - proc, csirs_config_pdu, ue->nr_csi_rs_info, ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, From f12c6ea65b8aa43d21dc8506f2c564a98af8cb74 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 4 Apr 2022 15:55:16 +0100 Subject: [PATCH 13/71] Add log2_maxh for nr_conjch0_mult_ch1 in nr_csi_rs_ri_estimation --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 5 ++++- openair1/PHY/defs_nr_common.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 215f6d3d6a..4d34cf7d8c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -205,6 +205,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; + int maxh = 0; for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { @@ -318,6 +319,7 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, 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]); + maxh = cmax3(maxh, abs(csi_rs_estimated_channel16[0]), abs(csi_rs_estimated_channel16[1])); } } for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { @@ -347,6 +349,7 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, } *noise_power /= (frame_parms->nb_antennas_rx*nr_csi_rs_info->N_ports); + nr_csi_rs_info->log2_maxh = log2_approx(maxh-1); #ifdef NR_CSIRS_DEBUG LOG_I(NR_PHY, "Noise power estimation based on CSI-RS: %i\n", *noise_power); @@ -403,7 +406,7 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, &csi_rs_estimated_channel_freq[ant_rx_ch][port_tx_ch][k], &nr_csi_rs_info->csi_rs_estimated_conjch_ch[ant_rx_conjch][port_tx_conjch][ant_rx_ch][port_tx_ch][k], 1, - 0); + nr_csi_rs_info->log2_maxh); // construct Hh x H elements if(ant_rx_conjch == ant_rx_ch) { diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 658a3e20cf..7d4557e340 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -261,6 +261,7 @@ typedef struct { int32_t **csi_rs_received_signal; int32_t ***csi_rs_ls_estimated_channel; int32_t ***csi_rs_estimated_channel_freq; + int16_t log2_maxh; int32_t csi_rs_estimated_conjch_ch[4][4][4][4][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); int32_t csi_rs_estimated_A_MF[2][2][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); int32_t csi_rs_estimated_A_MF_sq[2][2][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); From 4254d59a960e9db5e07de60b62076de94bd8159b Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 4 Apr 2022 20:13:33 +0100 Subject: [PATCH 14/71] Create nr_csi_rs_pmi_estimation function for PMI computation (still almost empty) --- openair1/PHY/INIT/nr_init_ue.c | 1 + openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 36 +++++++++++++++++++++++++++ openair1/PHY/defs_nr_common.h | 1 + 3 files changed, 38 insertions(+) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 59c526b818..07988f9665 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -347,6 +347,7 @@ 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->rank_indicator = (uint8_t*)malloc16_clear(sizeof(uint8_t)); + ue->nr_csi_rs_info->pmi = (uint8_t*)malloc16_clear(sizeof(uint8_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)); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 4d34cf7d8c..f5ecc874eb 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -462,6 +462,35 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, return 0; } +int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, + nr_csi_rs_info_t *nr_csi_rs_info, + int32_t ***csi_rs_estimated_channel_freq, + uint8_t rank_indicator, + uint8_t *pmi) { + + // TS 38.214: For 2 antenna ports {3000, 3001} and the UE configured with higher layer parameter codebookType set to + // 'typeISinglePanel' each PMI value corresponds to a codebook index given in Table 5.2.2.2.1-1. + // The first column is applicable if the UE is reporting a Rank = 1, whereas the second column is applicable if the + // UE is reporting a Rank = 2. + + *pmi = 0; + + if(ue->nr_csi_rs_info->N_ports == 1) { + return 0; + } + + if(rank_indicator == 0) { + + } else if(rank_indicator == 1) { + + } else { + LOG_W(NR_PHY, "PMI computation is not implemented for rank indicator %i\n", rank_indicator); + } + + 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; } @@ -520,5 +549,12 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, ue->nr_csi_rs_info->rank_indicator); + nr_csi_rs_pmi_estimation(ue, + csirs_config_pdu, + ue->nr_csi_rs_info, + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + *ue->nr_csi_rs_info->rank_indicator, + ue->nr_csi_rs_info->pmi); + return 0; } diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 7d4557e340..6ae2608a16 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -269,6 +269,7 @@ typedef struct { int32_t csi_rs_estimated_numer_fin[NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); uint32_t *noise_power; uint8_t *rank_indicator; + uint8_t *pmi; } nr_csi_rs_info_t; typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; From 886b580fac06f7e3630f9f7dfcbf16a7de336720 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 5 Apr 2022 19:56:13 +0100 Subject: [PATCH 15/71] PMI computation for rank=1 case --- openair1/PHY/INIT/nr_init_ue.c | 3 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 59 ++++++++++++++++++++++++--- openair1/PHY/defs_nr_common.h | 3 +- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 07988f9665..e5402c1c04 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -347,7 +347,8 @@ 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->rank_indicator = (uint8_t*)malloc16_clear(sizeof(uint8_t)); - ue->nr_csi_rs_info->pmi = (uint8_t*)malloc16_clear(sizeof(uint8_t)); + ue->nr_csi_rs_info->i1 = (uint8_t*)malloc16_clear(3*sizeof(uint8_t)); + ue->nr_csi_rs_info->i2 = (uint8_t*)malloc16_clear(sizeof(uint8_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)); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index f5ecc874eb..09b32f1a33 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -457,8 +457,6 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, *rank_indicator = 1; } - LOG_I(NR_PHY, "RI = %i\n", *rank_indicator + 1); - return 0; } @@ -467,21 +465,64 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, nr_csi_rs_info_t *nr_csi_rs_info, int32_t ***csi_rs_estimated_channel_freq, uint8_t rank_indicator, - uint8_t *pmi) { + uint8_t *i1, + uint8_t *i2) { + + NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + i1[0] = 1; + i1[1] = 1; + i1[2] = 1; + *i2 = 0; // TS 38.214: For 2 antenna ports {3000, 3001} and the UE configured with higher layer parameter codebookType set to // 'typeISinglePanel' each PMI value corresponds to a codebook index given in Table 5.2.2.2.1-1. // The first column is applicable if the UE is reporting a Rank = 1, whereas the second column is applicable if the // UE is reporting a Rank = 2. - *pmi = 0; - if(ue->nr_csi_rs_info->N_ports == 1) { return 0; } if(rank_indicator == 0) { + uint32_t metric[4] = {0}; + uint16_t shift = nr_csi_rs_info->log2_maxh + log2_approx(frame_parms->nb_antennas_rx) + log2_approx(csirs_config_pdu->nr_of_rbs) - 1; + + 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 (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { + int16_t *csi_rs_estimated_channel_p0 = (int16_t *) &csi_rs_estimated_channel_freq[ant_rx][0][k]; + int16_t *csi_rs_estimated_channel_p1 = (int16_t *) &csi_rs_estimated_channel_freq[ant_rx][1][k]; + + // H_p0 + 1*H_p1 = (H_p0_re + H_p1_re) + 1j*(H_p0_im + H_p1_im) + metric[0] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0]) + + (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1]))>>shift; + + // H_p0 + 1j*H_p1 = (H_p0_re - H_p1_im) + 1j*(H_p0_im + H_p1_re) + metric[1] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1]) + + (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0]))>>shift; + + // H_p0 - 1*H_p1 = (H_p0_re - H_p1_re) + 1j*(H_p0_im - H_p1_im) + metric[2] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0]) + + (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1]))>>shift; + + // H_p0 - 1j*H_p1 = (H_p0_re + H_p1_im) + 1j*(H_p0_im - H_p1_re) + metric[3] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1]) + + (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0]))>>shift; + } + } + + for(int tested_i2 = 0; tested_i2 < 4; tested_i2++) { + if(metric[tested_i2] > metric[*i2]) { + *i2 = tested_i2; + } + } + } else if(rank_indicator == 1) { } else { @@ -554,7 +595,13 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->nr_csi_rs_info, ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, *ue->nr_csi_rs_info->rank_indicator, - ue->nr_csi_rs_info->pmi); + ue->nr_csi_rs_info->i1, + ue->nr_csi_rs_info->i2); + + LOG_I(NR_PHY, "RI = %i, i1 = [%i %i %i], i2 = %i\n", + *ue->nr_csi_rs_info->rank_indicator + 1, + ue->nr_csi_rs_info->i1[0], ue->nr_csi_rs_info->i1[1], ue->nr_csi_rs_info->i1[2], + *ue->nr_csi_rs_info->i2); return 0; } diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 6ae2608a16..c1157e452f 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -269,7 +269,8 @@ typedef struct { int32_t csi_rs_estimated_numer_fin[NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); uint32_t *noise_power; uint8_t *rank_indicator; - uint8_t *pmi; + uint8_t *i1; + uint8_t *i2; } nr_csi_rs_info_t; typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; From 8e58e83be62400a3762a7e080487e4e74bb45395 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 6 Apr 2022 14:52:34 +0100 Subject: [PATCH 16/71] Remove log --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 09b32f1a33..532c27e247 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -370,7 +370,6 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, *rank_indicator = 0; if (ue->frame_parms.nb_antennas_rx == 1 || ue->nr_csi_rs_info->N_ports == 1) { - LOG_I(NR_PHY, "RI = %i\n", *rank_indicator + 1); return 0; } else if( !(ue->frame_parms.nb_antennas_rx == 2 && ue->nr_csi_rs_info->N_ports == 2) ) { LOG_W(NR_PHY, "Rank indicator computation is not implemented for %i x %i system\n", From 66b3fffbf00c63fac96e2e86134666b4301164de Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 6 Apr 2022 17:44:47 +0100 Subject: [PATCH 17/71] Minor improvements --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 532c27e247..b3325fba47 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -468,13 +468,15 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, uint8_t *i2) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - i1[0] = 1; - i1[1] = 1; - i1[2] = 1; - *i2 = 0; + memset(i1,0,3*sizeof(uint8_t)); + i2[0] = 0; - // TS 38.214: For 2 antenna ports {3000, 3001} and the UE configured with higher layer parameter codebookType set to - // 'typeISinglePanel' each PMI value corresponds to a codebook index given in Table 5.2.2.2.1-1. + // i1 is a three-element vector in the form of [i11 i12 i13], when CodebookType is specified as 'Type1SinglePanel'. + // Note that i13 is not applicable when the number of transmission layers is one of {1, 5, 6, 7, 8}. + // i2, for 'Type1SinglePanel' codebook type, it is a scalar when PMIMode is specified as 'wideband', and when PMIMode + // is specified as 'subband' or when PRGSize, the length of the i2 vector equals to the number of subbands or PRGs. + // Note that when the number of CSI-RS ports is 2, the applicable codebook type is 'Type1SinglePanel'. In this case, + // the precoding matrix is obtained by a single index (i2 field here) based on TS 38.214 Table 5.2.2.2.1-1. // The first column is applicable if the UE is reporting a Rank = 1, whereas the second column is applicable if the // UE is reporting a Rank = 2. @@ -517,8 +519,8 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, } for(int tested_i2 = 0; tested_i2 < 4; tested_i2++) { - if(metric[tested_i2] > metric[*i2]) { - *i2 = tested_i2; + if(metric[tested_i2] > metric[i2[0]]) { + i2[0] = tested_i2; } } @@ -597,10 +599,10 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->nr_csi_rs_info->i1, ue->nr_csi_rs_info->i2); - LOG_I(NR_PHY, "RI = %i, i1 = [%i %i %i], i2 = %i\n", + LOG_I(NR_PHY, "RI = %i, i1 = %i.%i.%i, i2 = %i\n", *ue->nr_csi_rs_info->rank_indicator + 1, ue->nr_csi_rs_info->i1[0], ue->nr_csi_rs_info->i1[1], ue->nr_csi_rs_info->i1[2], - *ue->nr_csi_rs_info->i2); + ue->nr_csi_rs_info->i2[0]); return 0; } From 6e4bbe8f49c9a19e876fa8e065b8a70a4d59d513 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 6 Apr 2022 18:42:00 +0100 Subject: [PATCH 18/71] PMI computation for rank=2 case --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index b3325fba47..684de4a462 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -484,7 +484,7 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, return 0; } - if(rank_indicator == 0) { + if(rank_indicator == 0 || rank_indicator == 1) { uint32_t metric[4] = {0}; uint16_t shift = nr_csi_rs_info->log2_maxh + log2_approx(frame_parms->nb_antennas_rx) + log2_approx(csirs_config_pdu->nr_of_rbs) - 1; @@ -518,14 +518,16 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, } } - for(int tested_i2 = 0; tested_i2 < 4; tested_i2++) { - if(metric[tested_i2] > metric[i2[0]]) { - i2[0] = tested_i2; + if(rank_indicator == 0) { + for(int tested_i2 = 0; tested_i2 < 4; tested_i2++) { + if(metric[tested_i2] > metric[i2[0]]) { + i2[0] = tested_i2; + } } + } else { + i2[0] = metric[0]+metric[2] > metric[1]+metric[3] ? 0 : 1; } - } else if(rank_indicator == 1) { - } else { LOG_W(NR_PHY, "PMI computation is not implemented for rank indicator %i\n", rank_indicator); } From bf56e881b2ba458bde7f74d0f53685d56cfe562e Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 6 Apr 2022 18:43:56 +0100 Subject: [PATCH 19/71] Fix log --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 684de4a462..4e3ac6dd69 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -529,7 +529,8 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, } } else { - LOG_W(NR_PHY, "PMI computation is not implemented for rank indicator %i\n", rank_indicator); + LOG_W(NR_PHY, "PMI computation is not implemented for rank indicator %i\n", rank_indicator+1); + return -1; } return 0; From 7286552aa5eda07958f2029e6685c5d89fb58a12 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 7 Apr 2022 18:58:18 +0100 Subject: [PATCH 20/71] Improvements in PMI computation to allow computation CQI more easily --- openair1/PHY/INIT/nr_init_ue.c | 1 + openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 60 ++++++++++++++++++++------- openair1/PHY/defs_nr_common.h | 2 + 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index e5402c1c04..2e32b7e3e6 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -349,6 +349,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) ue->nr_csi_rs_info->rank_indicator = (uint8_t*)malloc16_clear(sizeof(uint8_t)); ue->nr_csi_rs_info->i1 = (uint8_t*)malloc16_clear(3*sizeof(uint8_t)); ue->nr_csi_rs_info->i2 = (uint8_t*)malloc16_clear(sizeof(uint8_t)); + ue->nr_csi_rs_info->precoded_sinr = (uint32_t*)malloc16_clear(sizeof(uint32_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)); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 4e3ac6dd69..7eb0b68307 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -206,6 +206,7 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; *noise_power = 0; int maxh = 0; + int count = 0; for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { @@ -291,6 +292,8 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, continue; } + count++; + 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]; @@ -350,6 +353,7 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, *noise_power /= (frame_parms->nb_antennas_rx*nr_csi_rs_info->N_ports); nr_csi_rs_info->log2_maxh = log2_approx(maxh-1); + nr_csi_rs_info->log2_re = log2_approx(count-1); #ifdef NR_CSIRS_DEBUG LOG_I(NR_PHY, "Noise power estimation based on CSI-RS: %i\n", *noise_power); @@ -463,9 +467,11 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, nr_csi_rs_info_t *nr_csi_rs_info, int32_t ***csi_rs_estimated_channel_freq, + uint32_t noise_power, uint8_t rank_indicator, uint8_t *i1, - uint8_t *i2) { + uint8_t *i2, + uint32_t *precoded_sinr) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; memset(i1,0,3*sizeof(uint8_t)); @@ -480,13 +486,18 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, // The first column is applicable if the UE is reporting a Rank = 1, whereas the second column is applicable if the // UE is reporting a Rank = 2. - if(ue->nr_csi_rs_info->N_ports == 1) { + if(nr_csi_rs_info->N_ports == 1 || noise_power == 0) { return 0; } if(rank_indicator == 0 || rank_indicator == 1) { - uint32_t metric[4] = {0}; + int32_t sum_re[4] = {0}; + int32_t sum_im[4] = {0}; + int32_t sum2_re[4] = {0}; + int32_t sum2_im[4] = {0}; + int32_t tested_precoded_sinr[4] = {0}; + uint16_t shift = nr_csi_rs_info->log2_maxh + log2_approx(frame_parms->nb_antennas_rx) + log2_approx(csirs_config_pdu->nr_of_rbs) - 1; for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { @@ -497,35 +508,54 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, uint16_t k = (frame_parms->first_carrier_offset + rb * NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { + int16_t *csi_rs_estimated_channel_p0 = (int16_t *) &csi_rs_estimated_channel_freq[ant_rx][0][k]; int16_t *csi_rs_estimated_channel_p1 = (int16_t *) &csi_rs_estimated_channel_freq[ant_rx][1][k]; // H_p0 + 1*H_p1 = (H_p0_re + H_p1_re) + 1j*(H_p0_im + H_p1_im) - metric[0] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0]) - + (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1]))>>shift; + sum_re[0] += (csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0]); + sum_im[0] += (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1]); + sum2_re[0] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0]))>>nr_csi_rs_info->log2_re; + sum2_im[0] += ((csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1]))>>nr_csi_rs_info->log2_re; // H_p0 + 1j*H_p1 = (H_p0_re - H_p1_im) + 1j*(H_p0_im + H_p1_re) - metric[1] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1]) - + (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0]))>>shift; + sum_re[1] += (csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1]); + sum_im[1] += (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0]); + sum2_re[1] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1]))>>nr_csi_rs_info->log2_re; + sum2_im[1] += ((csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0]))>>nr_csi_rs_info->log2_re; // H_p0 - 1*H_p1 = (H_p0_re - H_p1_re) + 1j*(H_p0_im - H_p1_im) - metric[2] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0]) - + (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1]))>>shift; + sum_re[2] += (csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0]); + sum_im[2] += (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1]); + sum2_re[2] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0]))>>nr_csi_rs_info->log2_re; + sum2_im[2] += ((csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1]))>>nr_csi_rs_info->log2_re; // H_p0 - 1j*H_p1 = (H_p0_re + H_p1_im) + 1j*(H_p0_im - H_p1_re) - metric[3] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1]) - + (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0]))>>shift; + sum_re[3] += (csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1]); + sum_im[3] += (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0]); + sum2_re[3] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1]))>>nr_csi_rs_info->log2_re; + sum2_im[3] += ((csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0]))>>nr_csi_rs_info->log2_re; } } + // We should perform >>nr_csi_rs_info->log2_re here for all terms, but since sum2_re and sum2_im can be high values, + // we performed this above. + for(int p = 0; p<4; p++) { + int32_t power_re = sum2_re[p] - (sum_re[p]>>nr_csi_rs_info->log2_re)*(sum_re[p]>>nr_csi_rs_info->log2_re); + int32_t power_im = sum2_im[p] - (sum_im[p]>>nr_csi_rs_info->log2_re)*(sum_im[p]>>nr_csi_rs_info->log2_re); + tested_precoded_sinr[p] = (power_re+power_im)/(int32_t)noise_power; + } + if(rank_indicator == 0) { for(int tested_i2 = 0; tested_i2 < 4; tested_i2++) { - if(metric[tested_i2] > metric[i2[0]]) { + if(tested_precoded_sinr[tested_i2] > tested_precoded_sinr[i2[0]]) { i2[0] = tested_i2; } } + *precoded_sinr = tested_precoded_sinr[i2[0]]; } else { - i2[0] = metric[0]+metric[2] > metric[1]+metric[3] ? 0 : 1; + i2[0] = tested_precoded_sinr[0]+tested_precoded_sinr[2] > tested_precoded_sinr[1]+tested_precoded_sinr[3] ? 0 : 1; + *precoded_sinr = (tested_precoded_sinr[i2[0]] + tested_precoded_sinr[i2[0]+2])>>1; } } else { @@ -598,9 +628,11 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t csirs_config_pdu, ue->nr_csi_rs_info, ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + *ue->nr_csi_rs_info->noise_power, *ue->nr_csi_rs_info->rank_indicator, ue->nr_csi_rs_info->i1, - ue->nr_csi_rs_info->i2); + ue->nr_csi_rs_info->i2, + ue->nr_csi_rs_info->precoded_sinr); LOG_I(NR_PHY, "RI = %i, i1 = %i.%i.%i, i2 = %i\n", *ue->nr_csi_rs_info->rank_indicator + 1, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index c1157e452f..4616a87f16 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -261,6 +261,7 @@ typedef struct { int32_t **csi_rs_received_signal; int32_t ***csi_rs_ls_estimated_channel; int32_t ***csi_rs_estimated_channel_freq; + int16_t log2_re; int16_t log2_maxh; int32_t csi_rs_estimated_conjch_ch[4][4][4][4][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); int32_t csi_rs_estimated_A_MF[2][2][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); @@ -271,6 +272,7 @@ typedef struct { uint8_t *rank_indicator; uint8_t *i1; uint8_t *i2; + uint32_t *precoded_sinr; } nr_csi_rs_info_t; typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; From d6a155a803dca272099af4aa3e0657074eacb4e4 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 7 Apr 2022 19:30:33 +0100 Subject: [PATCH 21/71] SINR in dB --- openair1/PHY/INIT/nr_init_ue.c | 3 ++- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 27 +++++++++++++++++++-------- openair1/PHY/defs_nr_common.h | 3 ++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 2e32b7e3e6..1d44475d81 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -349,7 +349,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) ue->nr_csi_rs_info->rank_indicator = (uint8_t*)malloc16_clear(sizeof(uint8_t)); ue->nr_csi_rs_info->i1 = (uint8_t*)malloc16_clear(3*sizeof(uint8_t)); ue->nr_csi_rs_info->i2 = (uint8_t*)malloc16_clear(sizeof(uint8_t)); - ue->nr_csi_rs_info->precoded_sinr = (uint32_t*)malloc16_clear(sizeof(uint32_t)); + ue->nr_csi_rs_info->precoded_sinr_dB = (uint32_t*)malloc16_clear(sizeof(uint32_t)); + ue->nr_csi_rs_info->cqi = (uint8_t*)malloc16_clear(sizeof(uint8_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)); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 7eb0b68307..4e16a63302 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -471,7 +471,7 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, uint8_t rank_indicator, uint8_t *i1, uint8_t *i2, - uint32_t *precoded_sinr) { + uint32_t *precoded_sinr_dB) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; memset(i1,0,3*sizeof(uint8_t)); @@ -498,8 +498,6 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, int32_t sum2_im[4] = {0}; int32_t tested_precoded_sinr[4] = {0}; - uint16_t shift = nr_csi_rs_info->log2_maxh + log2_approx(frame_parms->nb_antennas_rx) + log2_approx(csirs_config_pdu->nr_of_rbs) - 1; - 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)) { @@ -552,10 +550,10 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, i2[0] = tested_i2; } } - *precoded_sinr = tested_precoded_sinr[i2[0]]; + *precoded_sinr_dB = dB_fixed(tested_precoded_sinr[i2[0]]); } else { i2[0] = tested_precoded_sinr[0]+tested_precoded_sinr[2] > tested_precoded_sinr[1]+tested_precoded_sinr[3] ? 0 : 1; - *precoded_sinr = (tested_precoded_sinr[i2[0]] + tested_precoded_sinr[i2[0]+2])>>1; + *precoded_sinr_dB = dB_fixed((tested_precoded_sinr[i2[0]] + tested_precoded_sinr[i2[0]+2]))>>1; } } else { @@ -566,6 +564,14 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, return 0; } +int nr_csi_rs_cqi_estimation(uint32_t precoded_sinr, + uint8_t *cqi) { + + *cqi = 0; + + 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; } @@ -632,12 +638,17 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t *ue->nr_csi_rs_info->rank_indicator, ue->nr_csi_rs_info->i1, ue->nr_csi_rs_info->i2, - ue->nr_csi_rs_info->precoded_sinr); + ue->nr_csi_rs_info->precoded_sinr_dB); - LOG_I(NR_PHY, "RI = %i, i1 = %i.%i.%i, i2 = %i\n", + nr_csi_rs_cqi_estimation(*ue->nr_csi_rs_info->precoded_sinr_dB, + ue->nr_csi_rs_info->cqi); + + LOG_I(NR_PHY, "RI = %i, i1 = %i.%i.%i, i2 = %i. SINR = %i dB, CQI = %i\n", *ue->nr_csi_rs_info->rank_indicator + 1, ue->nr_csi_rs_info->i1[0], ue->nr_csi_rs_info->i1[1], ue->nr_csi_rs_info->i1[2], - ue->nr_csi_rs_info->i2[0]); + ue->nr_csi_rs_info->i2[0], + *ue->nr_csi_rs_info->precoded_sinr_dB, + *ue->nr_csi_rs_info->cqi); return 0; } diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 4616a87f16..0e90c2087b 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -272,7 +272,8 @@ typedef struct { uint8_t *rank_indicator; uint8_t *i1; uint8_t *i2; - uint32_t *precoded_sinr; + uint32_t *precoded_sinr_dB; + uint8_t *cqi; } nr_csi_rs_info_t; typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; From 8ffecf4bdf350c1ea701e2293ce7c493a6b67dee Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 7 Apr 2022 19:58:56 +0100 Subject: [PATCH 22/71] CQI computation --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 29 ++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 4e16a63302..ad80261aa2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -569,6 +569,33 @@ int nr_csi_rs_cqi_estimation(uint32_t precoded_sinr, *cqi = 0; + // Default SINR table for an AWGN channel for SISO scenario, considering 0.1 BLER condition and TS 38.214 Table 5.2.2.1-2 + if(precoded_sinr>0 && precoded_sinr<=2) { + *cqi = 4; + } else if(precoded_sinr==3) { + *cqi = 5; + } else if(precoded_sinr>3 && precoded_sinr<=5) { + *cqi = 6; + } else if(precoded_sinr>5 && precoded_sinr<=7) { + *cqi = 7; + } else if(precoded_sinr>7 && precoded_sinr<=9) { + *cqi = 8; + } else if(precoded_sinr==10) { + *cqi = 9; + } else if(precoded_sinr>10 && precoded_sinr<=12) { + *cqi = 10; + } else if(precoded_sinr>12 && precoded_sinr<=15) { + *cqi = 11; + } else if(precoded_sinr==16) { + *cqi = 12; + } else if(precoded_sinr>16 && precoded_sinr<=18) { + *cqi = 13; + } else if(precoded_sinr==19) { + *cqi = 14; + } else if(precoded_sinr>19) { + *cqi = 15; + } + return 0; } @@ -643,7 +670,7 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t nr_csi_rs_cqi_estimation(*ue->nr_csi_rs_info->precoded_sinr_dB, ue->nr_csi_rs_info->cqi); - LOG_I(NR_PHY, "RI = %i, i1 = %i.%i.%i, i2 = %i. SINR = %i dB, CQI = %i\n", + LOG_I(NR_PHY, "RI = %i, i1 = %i.%i.%i, i2 = %i, SINR = %i dB, CQI = %i\n", *ue->nr_csi_rs_info->rank_indicator + 1, ue->nr_csi_rs_info->i1[0], ue->nr_csi_rs_info->i1[1], ue->nr_csi_rs_info->i1[2], ue->nr_csi_rs_info->i2[0], From 04b234c8784a85e38d4dd261c281f66b190df209 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 12 Apr 2022 19:06:02 +0100 Subject: [PATCH 23/71] Send CSI-RS measurements from PHY to MAC at UE --- .../nfapi/public_inc/fapi_nr_ue_constants.h | 1 + .../nfapi/public_inc/fapi_nr_ue_interface.h | 11 +++++++---- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 17 +++++++++++++++++ openair1/SCHED_NR_UE/defs.h | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 10 +++++++--- openair1/SIMULATION/NR_PHY/nr_dummy_functions.c | 2 +- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 3 +++ openair2/LAYER2/NR_MAC_UE/mac_proto.h | 1 + openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 10 ++++++++++ openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 12 +++++++++++- 10 files changed, 59 insertions(+), 10 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h index 7fb42e566a..6524fcb396 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h @@ -19,6 +19,7 @@ #define FAPI_NR_RX_PDU_TYPE_DLSCH 0x03 #define FAPI_NR_DCI_IND 0x04 #define FAPI_NR_RX_PDU_TYPE_RAR 0x05 +#define FAPI_NR_CSIRS_IND 0x06 #define FAPI_NR_SIBS_MASK_SIB1 0x1 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 725c389070..e67897b44d 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 @@ -36,9 +36,6 @@ */ - - - typedef struct { uint8_t uci_format; uint8_t uci_channel; @@ -50,7 +47,12 @@ typedef struct { uint32_t sr; } fapi_nr_uci_pdu_rel15_t; - +typedef struct { + uint8_t *rank_indicator; + uint8_t *i1; + uint8_t *i2; + uint8_t *cqi; +} fapi_nr_csirs_measurements_t; typedef struct { /// frequency_domain_resource; @@ -130,6 +132,7 @@ typedef struct { fapi_nr_pdsch_pdu_t pdsch_pdu; fapi_nr_ssb_pdu_t ssb_pdu; fapi_nr_sib_pdu_t sib_pdu; + fapi_nr_csirs_measurements_t csirs_measurements; }; } fapi_nr_rx_indication_body_t; diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 77b611d73c..0b63c4a149 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -676,5 +676,22 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t *ue->nr_csi_rs_info->precoded_sinr_dB, *ue->nr_csi_rs_info->cqi); + // Send CSI measurements to MAC + fapi_nr_csirs_measurements_t csirs_measurements; + csirs_measurements.rank_indicator = ue->nr_csi_rs_info->rank_indicator; + csirs_measurements.i1 = ue->nr_csi_rs_info->i1; + csirs_measurements.i2 = ue->nr_csi_rs_info->i2; + csirs_measurements.cqi = ue->nr_csi_rs_info->cqi; + nr_downlink_indication_t *dl_indication = calloc(sizeof(*dl_indication),1); + fapi_nr_rx_indication_t *rx_ind = calloc(sizeof(*rx_ind),1); + nr_fill_dl_indication(dl_indication, NULL, rx_ind, proc, ue, gNB_id); + nr_fill_rx_indication(rx_ind, FAPI_NR_CSIRS_IND, gNB_id, ue, NULL, NULL, 1, proc, (void *)&csirs_measurements); + if (ue->if_inst && ue->if_inst->dl_indication) { + ue->if_inst->dl_indication(dl_indication, NULL); + } else { + free(dl_indication); + free(rx_ind); + } + return 0; } diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index c449dba159..39faaa0cb3 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -402,7 +402,7 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, NR_UE_DLSCH_t *dlsch1, uint16_t n_pdus, UE_nr_rxtx_proc_t *proc, - void * typeSpecific); + void *typeSpecific); bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 262acdec3a..59b08d9823 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -118,9 +118,8 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, uint16_t n_pdus, - UE_nr_rxtx_proc_t *proc, - void * typeSpecific){ - + UE_nr_rxtx_proc_t *proc, + void *typeSpecific){ NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; @@ -174,6 +173,11 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_start_subcarrier = frame_parms->ssb_start_subcarrier; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.rsrp_dBm = ue->measurements.rsrp_dBm[gNB_id]; break; + case FAPI_NR_CSIRS_IND: + memcpy(&rx_ind->rx_indication_body[n_pdus - 1].csirs_measurements, + (fapi_nr_csirs_measurements_t*)typeSpecific, + sizeof(*(fapi_nr_csirs_measurements_t*)typeSpecific)); + break; default: break; } diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index 351c2f33c4..de715214b9 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -37,4 +37,4 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, NR_UE_DLSCH_t *dlsch1, uint16_t n_pdus, UE_nr_rxtx_proc_t *proc, - void * typeSpecific ) {} + void *typeSpecific ) {} diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index fc2c2d2c8b..09153e6f13 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -399,6 +399,9 @@ typedef struct { /// measured SSB RSRP in dBm short ssb_rsrp_dBm; + /// measurements from CSI-RS + fapi_nr_csirs_measurements_t csirs_measurements; + /// Last NDI of UL HARQ processes uint8_t UL_ndi[NR_MAX_HARQ_PROCESSES]; /// first ULTX of UL HARQ processes diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 3e4d53b985..c57c427f14 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -193,6 +193,7 @@ int nr_get_sf_retxBSRTimer(uint8_t retxBSR_Timer); int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, frame_t frame, int slot, dci_pdu_rel15_t *dci, fapi_nr_dci_indication_pdu_t *dci_ind); int nr_ue_process_dci_indication_pdu(module_id_t module_id, int cc_id, int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci); +int8_t nr_ue_process_csirs_measurements(module_id_t module_id, frame_t frame, int slot, fapi_nr_csirs_measurements_t *csirs_measurements); uint32_t get_ssb_frame(uint32_t test); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 192fb25405..220dc799e5 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1371,6 +1371,16 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } +int8_t nr_ue_process_csirs_measurements(module_id_t module_id, + frame_t frame, + int slot, + fapi_nr_csirs_measurements_t *csirs_measurements) { + LOG_D(NR_MAC,"(%d.%d) Received CSI-RS measurements\n", frame, slot); + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + memcpy(&mac->csirs_measurements, csirs_measurements, sizeof(*csirs_measurements)); + return 0; +} + void set_harq_status(NR_UE_MAC_INST_t *mac, uint8_t pucch_id, uint8_t harq_id, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 26c60fbb9b..30aa921765 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1112,6 +1112,10 @@ int8_t handle_dlsch(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *u return 0; } +int8_t handle_csirs_measurements(module_id_t module_id, frame_t frame, int slot, fapi_nr_csirs_measurements_t *csirs_measurements) { + return nr_ue_process_csirs_measurements(module_id, frame, slot, csirs_measurements); +} + void update_harq_status(module_id_t module_id, uint8_t harq_pid, uint8_t ack_nack) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); @@ -1236,7 +1240,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_length, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_start_subcarrier, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.cell_id)) << FAPI_NR_RX_PDU_TYPE_SSB; - free((dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.pdu); + free((dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.pdu); break; case FAPI_NR_RX_PDU_TYPE_SIB: ret_mask |= (handle_bcch_dlsch(dl_info->module_id, @@ -1251,6 +1255,12 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ case FAPI_NR_RX_PDU_TYPE_RAR: ret_mask |= (handle_dlsch(dl_info, ul_time_alignment, i)) << FAPI_NR_RX_PDU_TYPE_RAR; break; + case FAPI_NR_CSIRS_IND: + ret_mask |= (handle_csirs_measurements(dl_info->module_id, + dl_info->frame, + dl_info->slot, + &(dl_info->rx_ind->rx_indication_body+i)->csirs_measurements)) << FAPI_NR_CSIRS_IND; + break; default: break; } From 40279dddf3548962a97ef264154114a31bd7d708 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 13 Apr 2022 01:07:01 +0100 Subject: [PATCH 24/71] Get cri_bitlen, ri_bitlen, pmi_bitlen and cqi_bitlen at UE --- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 31 ++ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 481 +++++++++++++++++ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 32 +- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 2 + openair2/LAYER2/NR_MAC_UE/mac_proto.h | 6 + openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 44 +- openair2/LAYER2/NR_MAC_gNB/config.c | 2 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 485 ------------------ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 - openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 30 -- 11 files changed, 596 insertions(+), 521 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 9dd03ddcf6..7b687f6bda 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -39,6 +39,7 @@ #include #include "NR_SubcarrierSpacing.h" +#include "NR_CSI-ReportConfig.h" #include "openair1/SCHED_NR_UE/harq_nr.h" #define NR_SHORT_BSR_TABLE_SIZE 32 @@ -63,6 +64,7 @@ #define CCCH_PAYLOAD_SIZE_MAX 512 #define RAR_PAYLOAD_SIZE_MAX 128 #define MAX_BWP_SIZE 275 +#define MAX_CSI_REPORTCONFIG 48 typedef enum frequency_range_e { FR1 = 0, @@ -496,5 +498,34 @@ typedef struct Type0_PDCCH_CSS_config_s { bool active; } NR_Type0_PDCCH_CSS_config_t; +typedef struct { + uint8_t nb_ssbri_cri; + uint8_t cri_ssbri_bitlen; + uint8_t rsrp_bitlen; + uint8_t diff_rsrp_bitlen; +} L1_RSRP_bitlen_t; + +typedef struct{ + uint8_t ri_restriction; + uint8_t cri_bitlen; + uint8_t ri_bitlen; + uint8_t li_bitlen[8]; + uint8_t pmi_x1_bitlen[8]; + uint8_t pmi_x2_bitlen[8]; + uint8_t cqi_bitlen[8]; +} CSI_Meas_bitlen_t; + +typedef struct nr_csi_report { + NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type; + long periodicity; + uint16_t offset; + long ** SSB_Index_list; + long ** CSI_Index_list; +// uint8_t nb_of_nzp_csi_report; + uint8_t nb_of_csi_ssb_report; + L1_RSRP_bitlen_t CSI_report_bitlen; + CSI_Meas_bitlen_t csi_meas_bitlen; +} nr_csi_report_t; + #endif /*__LAYER2_MAC_H__ */ diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 26ccbb473a..e8634e7f9e 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -4161,3 +4161,484 @@ bool set_ul_ptrs_values(NR_PTRS_UplinkConfig_t *ul_ptrs_config, } return valid; } + +//! Calculating number of bits set +uint8_t number_of_bits_set(uint8_t buf) { + uint8_t nb_of_bits_set = 0; + uint8_t mask = 0xff; + uint8_t index = 0; + + for (index=7; (buf & mask) && (index>=0) ; index--){ + if (buf & (1<>=1; + } + return nb_of_bits_set; +} + +void compute_rsrp_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + uint8_t nb_resources, + nr_csi_report_t *csi_report) { + + if (NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled == csi_reportconfig->groupBasedBeamReporting.present) { + if (NULL != csi_reportconfig->groupBasedBeamReporting.choice.disabled->nrofReportedRS) + csi_report->CSI_report_bitlen.nb_ssbri_cri = *(csi_reportconfig->groupBasedBeamReporting.choice.disabled->nrofReportedRS)+1; + else + /*! From Spec 38.331 + * nrofReportedRS + * The number (N) of measured RS resources to be reported per report setting in a non-group-based report. N <= N_max, where N_max is either 2 or 4 depending on UE + * capability. FFS: The signaling mechanism for the gNB to select a subset of N beams for the UE to measure and report. + * When the field is absent the UE applies the value 1 + */ + csi_report->CSI_report_bitlen.nb_ssbri_cri= 1; + } else + csi_report->CSI_report_bitlen.nb_ssbri_cri= 2; + + if (nb_resources) { + csi_report->CSI_report_bitlen.cri_ssbri_bitlen =ceil(log2 (nb_resources)); + csi_report->CSI_report_bitlen.rsrp_bitlen = 7; //From spec 38.212 Table 6.3.1.1.2-6: CRI, SSBRI, and RSRP + csi_report->CSI_report_bitlen.diff_rsrp_bitlen =4; //From spec 38.212 Table 6.3.1.1.2-6: CRI, SSBRI, and RSRP + } else { + csi_report->CSI_report_bitlen.cri_ssbri_bitlen =0; + csi_report->CSI_report_bitlen.rsrp_bitlen = 0; + csi_report->CSI_report_bitlen.diff_rsrp_bitlen =0; + } +} + +uint8_t compute_ri_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + nr_csi_report_t *csi_report) { + + struct NR_CodebookConfig *codebookConfig = csi_reportconfig->codebookConfig; + uint8_t nb_allowed_ri, ri_bitlen; + uint8_t ri_restriction = 0; + + if (codebookConfig == NULL) { + csi_report->csi_meas_bitlen.ri_bitlen=0; + return ri_restriction; + } + + // codebook type1 single panel + if (NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel==codebookConfig->codebookType.choice.type1->subType.present){ + struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel *type1single = codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel; + if (type1single->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two){ + + ri_restriction = csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]; + + nb_allowed_ri = number_of_bits_set(ri_restriction); + ri_bitlen = ceil(log2(nb_allowed_ri)); + + ri_bitlen = ri_bitlen<1?ri_bitlen:1; //from the spec 38.212 and table 6.3.1.1.2-3: RI, LI, CQI, and CRI of codebookType=typeI-SinglePanel + csi_report->csi_meas_bitlen.ri_bitlen=ri_bitlen; + } + if (type1single->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo){ + if (type1single->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present == + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction) { + // 4 ports + + ri_restriction = csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]; + + nb_allowed_ri = number_of_bits_set(ri_restriction); + ri_bitlen = ceil(log2(nb_allowed_ri)); + + ri_bitlen = ri_bitlen<2?ri_bitlen:2; //from the spec 38.212 and table 6.3.1.1.2-3: RI, LI, CQI, and CRI of codebookType=typeI-SinglePanel + csi_report->csi_meas_bitlen.ri_bitlen=ri_bitlen; + } + else { + // more than 4 ports + + ri_restriction = csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]; + + nb_allowed_ri = number_of_bits_set(ri_restriction); + ri_bitlen = ceil(log2(nb_allowed_ri)); + + csi_report->csi_meas_bitlen.ri_bitlen=ri_bitlen; + } + } + return ri_restriction; + } + else + AssertFatal(1==0,"Other configurations not yet implemented\n"); + return -1; +} + +void compute_li_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + uint8_t ri_restriction, + nr_csi_report_t *csi_report) { + + struct NR_CodebookConfig *codebookConfig = csi_reportconfig->codebookConfig; + for(int i=0; i<8; i++) { + if (codebookConfig == NULL || ((ri_restriction>>i)&0x01) == 0) + csi_report->csi_meas_bitlen.li_bitlen[i]=0; + else { + // codebook type1 single panel + if (NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel==codebookConfig->codebookType.choice.type1->subType.present) + csi_report->csi_meas_bitlen.li_bitlen[i]=ceil(log2(i+1))<2?ceil(log2(i+1)):2; + else + AssertFatal(1==0,"Other configurations not yet implemented\n"); + } + } +} + +void get_n1n2_o1o2_singlepanel(int *n1, int *n2, int *o1, int *o2, + struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo *morethantwo) { + + // Table 5.2.2.2.1-2 in 38.214 for supported configurations + switch(morethantwo->n1_n2.present){ + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction): + *n1 = 2; + *n2 = 1; + *o1 = 4; + *o2 = 1; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_two_TypeI_SinglePanel_Restriction): + *n1 = 2; + *n2 = 2; + *o1 = 4; + *o2 = 4; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction): + *n1 = 4; + *n2 = 1; + *o1 = 4; + *o2 = 1; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_three_two_TypeI_SinglePanel_Restriction): + *n1 = 3; + *n2 = 2; + *o1 = 4; + *o2 = 4; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction): + *n1 = 6; + *n2 = 1; + *o1 = 4; + *o2 = 1; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_two_TypeI_SinglePanel_Restriction): + *n1 = 4; + *n2 = 2; + *o1 = 4; + *o2 = 4; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_one_TypeI_SinglePanel_Restriction): + *n1 = 8; + *n2 = 1; + *o1 = 4; + *o2 = 1; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_three_TypeI_SinglePanel_Restriction): + *n1 = 4; + *n2 = 3; + *o1 = 4; + *o2 = 4; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_two_TypeI_SinglePanel_Restriction): + *n1 = 4; + *n2 = 2; + *o1 = 4; + *o2 = 4; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_twelve_one_TypeI_SinglePanel_Restriction): + *n1 = 12; + *n2 = 1; + *o1 = 4; + *o2 = 1; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_four_TypeI_SinglePanel_Restriction): + *n1 = 4; + *n2 = 4; + *o1 = 4; + *o2 = 4; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_two_TypeI_SinglePanel_Restriction): + *n1 = 8; + *n2 = 2; + *o1 = 4; + *o2 = 4; + break; + case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_sixteen_one_TypeI_SinglePanel_Restriction): + *n1 = 16; + *n2 = 1; + *o1 = 4; + *o2 = 1; + break; + default: + AssertFatal(1==0,"Not supported configuration for n1_n2 in codebook configuration"); + } +} + +void get_x1x2_bitlen_singlepanel(int n1, int n2, int o1, int o2, + int *x1, int *x2, int rank, int codebook_mode) { + + // Table 6.3.1.1.2-1 in 38.212 + switch(rank){ + case 1: + if(n2>1) { + if (codebook_mode == 1) { + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); + *x2 = 2; + } + else { + *x1 = ceil(log2(n1*o1/2)) + ceil(log2(n2*o2/2)); + *x2 = 4; + } + } + else{ + if (codebook_mode == 1) { + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); + *x2 = 2; + } + else { + *x1 = ceil(log2(n1*o1/2)); + *x2 = 4; + } + } + break; + case 2: + if(n1*n2 == 2) { + if (codebook_mode == 1) { + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); + *x2 = 1; + } + else { + *x1 = ceil(log2(n1*o1/2)); + *x2 = 3; + } + *x1 += 1; + } + else { + if(n2>1) { + if (codebook_mode == 1) { + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); + *x2 = 3; + } + else { + *x1 = ceil(log2(n1*o1/2)) + ceil(log2(n2*o2/2)); + *x2 = 3; + } + } + else{ + if (codebook_mode == 1) { + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); + *x2 = 1; + } + else { + *x1 = ceil(log2(n1*o1/2)); + *x2 = 3; + } + } + *x1 += 2; + } + break; + case 3: + case 4: + if(n1*n2 == 2) { + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); + *x2 = 1; + } + else { + if(n1*n2 >= 8) { + *x1 = ceil(log2(n1*o1/2)) + ceil(log2(n2*o2)) + 2; + *x2 = 1; + } + else { + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)) + 2; + *x2 = 1; + } + } + break; + case 5: + case 6: + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); + *x2 = 1; + break; + case 7: + case 8: + if(n1 == 4 && n2 == 1) { + *x1 = ceil(log2(n1*o1/2)) + ceil(log2(n2*o2)); + *x2 = 1; + } + else { + if(n1 > 2 && n2 == 2) { + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2/2)); + *x2 = 1; + } + else { + *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); + *x2 = 1; + } + } + break; + default: + AssertFatal(1==0,"Invalid rank in x1 x2 bit length computation\n"); + } +} + + +void compute_pmi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + uint8_t ri_restriction, + nr_csi_report_t *csi_report) { + + struct NR_CodebookConfig *codebookConfig = csi_reportconfig->codebookConfig; + for(int i=0; i<8; i++) { + csi_report->csi_meas_bitlen.pmi_x1_bitlen[i]=0; + csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=0; + if (codebookConfig == NULL || ((ri_restriction>>i)&0x01) == 0) + return; + else { + if(codebookConfig->codebookType.present == NR_CodebookConfig__codebookType_PR_type1) { + if(codebookConfig->codebookType.choice.type1->subType.present == NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel) { + if(codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present == + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two) { + if (i==0) + csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=2; + if (i==1) + csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=1; + } + else { // more than two + int n1,n2,o1,o2,x1,x2; + get_n1n2_o1o2_singlepanel(&n1,&n2,&o1,&o2,codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo); + get_x1x2_bitlen_singlepanel(n1,n2,o1,o2,&x1,&x2,i+1,codebookConfig->codebookType.choice.type1->codebookMode); + csi_report->csi_meas_bitlen.pmi_x1_bitlen[i]=x1; + csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=x2; + } + } + else + AssertFatal(1==0,"Type1 Multi-panel Codebook Config not yet implemented\n"); + } + else + AssertFatal(1==0,"Type2 Codebook Config not yet implemented\n"); + } + } +} + +void compute_cqi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + uint8_t ri_restriction, + nr_csi_report_t *csi_report) { + + struct NR_CodebookConfig *codebookConfig = csi_reportconfig->codebookConfig; + struct NR_CSI_ReportConfig__reportFreqConfiguration *freq_config = csi_reportconfig->reportFreqConfiguration; + + if (*freq_config->cqi_FormatIndicator == NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI) { + for(int i=0; i<8; i++) { + if ((ri_restriction>>i)&0x01) { + csi_report->csi_meas_bitlen.cqi_bitlen[i] = 4; + if(codebookConfig != NULL) { + if (NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel == codebookConfig->codebookType.choice.type1->subType.present){ + struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel *type1single = codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel; + if (type1single->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo) { + if (type1single->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present > + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction) { + // more than 4 antenna ports + if (i > 4) + csi_report->csi_meas_bitlen.cqi_bitlen[i] += 4; // CQI for second TB + } + } + } + } + } + else + csi_report->csi_meas_bitlen.cqi_bitlen[i] = 0; + } + } + else + 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_csi_report_t *csi_report_template) { + uint8_t csi_report_id = 0; + uint8_t nb_resources = 0; + NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type; + NR_CSI_ResourceConfigId_t csi_ResourceConfigId; + struct NR_CSI_ResourceConfig *csi_resourceconfig; + + // for each CSI measurement report configuration (list of CSI-ReportConfig) + LOG_D(NR_MAC,"Searching %d csi_reports\n",csi_MeasConfig->csi_ReportConfigToAddModList->list.count); + for (csi_report_id=0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ + struct NR_CSI_ReportConfig *csi_reportconfig = csi_MeasConfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; + // MAC structure for CSI measurement reports (per UE and per report) + nr_csi_report_t *csi_report = &csi_report_template[csi_report_id]; + // csi-ResourceConfigId of a CSI-ResourceConfig included in the configuration + // (either CSI-RS or SSB) + csi_ResourceConfigId = csi_reportconfig->resourcesForChannelMeasurement; + // looking for CSI-ResourceConfig + int found_resource = 0; + int csi_resourceidx = 0; + while (found_resource == 0 && csi_resourceidx < csi_MeasConfig->csi_ResourceConfigToAddModList->list.count) { + csi_resourceconfig = csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[csi_resourceidx]; + if ( csi_resourceconfig->csi_ResourceConfigId == csi_ResourceConfigId) + found_resource = 1; + csi_resourceidx++; + } + AssertFatal(found_resource==1,"Not able to found any CSI-ResourceConfig with csi-ResourceConfigId %ld\n", + csi_ResourceConfigId); + + long resourceType = csi_resourceconfig->resourceType; + + reportQuantity_type = csi_reportconfig->reportQuantity.present; + csi_report->reportQuantity_type = reportQuantity_type; + + // setting the CSI or SSB index list + if (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP == csi_report->reportQuantity_type) { + for (int csi_idx = 0; csi_idx < csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.count; csi_idx++) { + if (csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceSetId == + *(csi_resourceconfig->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list.array[0])){ + //We can configure only one SSB resource set from spec 38.331 IE CSI-ResourceConfig + nb_resources= csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceList.list.count; + csi_report->SSB_Index_list = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceList.list.array; + csi_report->CSI_Index_list = NULL; + break; + } + } + } + else { + if (resourceType == NR_CSI_ResourceConfig__resourceType_periodic) { + AssertFatal(csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList != NULL, + "Wrong settings! Report quantity requires CSI-RS but csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList is NULL\n"); + for (int csi_idx = 0; csi_idx < csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.count; csi_idx++) { + if (csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[csi_idx]->nzp_CSI_ResourceSetId == + *(csi_resourceconfig->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list.array[0])) { + //For periodic and semi-persistent CSI Resource Settings, the number of CSI-RS Resource Sets configured is limited to S=1 for spec 38.212 + nb_resources = csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[csi_idx]->nzp_CSI_RS_Resources.list.count; + csi_report->CSI_Index_list = csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[csi_idx]->nzp_CSI_RS_Resources.list.array; + csi_report->SSB_Index_list = NULL; + break; + } + } + } + else AssertFatal(1==0,"Only periodic resource configuration currently supported\n"); + } + LOG_D(NR_MAC,"nb_resources %d\n",nb_resources); + // computation of bit length depending on the report type + switch(reportQuantity_type){ + case (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP): + compute_rsrp_bitlen(csi_reportconfig, nb_resources, csi_report); + break; + case (NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP): + compute_rsrp_bitlen(csi_reportconfig, nb_resources, csi_report); + break; + case (NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_CQI): + csi_report->csi_meas_bitlen.cri_bitlen=ceil(log2(nb_resources)); + csi_report->csi_meas_bitlen.ri_restriction = compute_ri_bitlen(csi_reportconfig, csi_report); + compute_cqi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); + break; + case (NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI): + csi_report->csi_meas_bitlen.cri_bitlen=ceil(log2(nb_resources)); + csi_report->csi_meas_bitlen.ri_restriction = compute_ri_bitlen(csi_reportconfig, csi_report); + compute_cqi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); + compute_pmi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); + break; + case (NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_LI_PMI_CQI): + csi_report->csi_meas_bitlen.cri_bitlen=ceil(log2(nb_resources)); + csi_report->csi_meas_bitlen.ri_restriction = compute_ri_bitlen(csi_reportconfig, csi_report); + compute_li_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); + compute_cqi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); + compute_pmi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); + break; + default: + AssertFatal(1==0,"Not yet supported CSI report quantity type"); + } + } +} \ No newline at end of file diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 0f2cb42b88..e4316f8d06 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -102,7 +102,7 @@ uint8_t get_pusch_mcs_table(long *mcs_Table, uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config, uint8_t nb_preambles, uint8_t unpaired, - frequency_range_t); + frequency_range_t); int ul_ant_bits(NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig,long transformPrecoder); @@ -203,4 +203,34 @@ void nr_mac_gNB_rrc_ul_failure_reset(const module_id_t Mod_instP, const frame_t frameP, const sub_frame_t subframeP, const rnti_t rntiP); + +uint8_t number_of_bits_set(uint8_t buf); + +void compute_rsrp_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + uint8_t nb_resources, + nr_csi_report_t *csi_report); + +uint8_t compute_ri_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + nr_csi_report_t *csi_report); + +void compute_li_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + uint8_t ri_restriction, + nr_csi_report_t *csi_report); + +void get_n1n2_o1o2_singlepanel(int *n1, int *n2, int *o1, int *o2, + struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo *morethantwo); + +void get_x1x2_bitlen_singlepanel(int n1, int n2, int o1, int o2, + int *x1, int *x2, int rank, int codebook_mode); + +void compute_pmi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + uint8_t ri_restriction, + nr_csi_report_t *csi_report); + +void compute_cqi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, + uint8_t ri_restriction, + nr_csi_report_t *csi_report); + +void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, nr_csi_report_t *csi_report_template); + #endif diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 09153e6f13..1d9852ccfb 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -399,6 +399,8 @@ typedef struct { /// measured SSB RSRP in dBm short ssb_rsrp_dBm; + nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG]; + /// measurements from CSI-RS fapi_nr_csirs_measurements_t csirs_measurements; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index c57c427f14..3997da63b0 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -213,6 +213,12 @@ uint8_t get_ssb_rsrp_payload(NR_UE_MAC_INST_t *mac, NR_CSI_ResourceConfigId_t csi_ResourceConfigId, NR_CSI_MeasConfig_t *csi_MeasConfig); +uint8_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, + PUCCH_sched_t *pucch, + struct NR_CSI_ReportConfig *csi_reportconfig, + NR_CSI_ResourceConfigId_t csi_ResourceConfigId, + NR_CSI_MeasConfig_t *csi_MeasConfig); + uint8_t nr_get_csi_payload(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, int csi_report_id, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 220dc799e5..a2391809ad 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2486,8 +2486,10 @@ uint8_t nr_get_csi_payload(NR_UE_MAC_INST_t *mac, case NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP: n_csi_bits = get_ssb_rsrp_payload(mac,pucch,csi_reportconfig,csi_ResourceConfigId,csi_MeasConfig); break; - case NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI: + n_csi_bits = get_csirs_RI_PMI_CQI_payload(mac,pucch,csi_reportconfig,csi_ResourceConfigId,csi_MeasConfig); + break; + case NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_i1: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_i1_CQI: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_CQI: @@ -2580,6 +2582,46 @@ uint8_t get_ssb_rsrp_payload(NR_UE_MAC_INST_t *mac, return bits; } +uint8_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, + PUCCH_sched_t *pucch, + struct NR_CSI_ReportConfig *csi_reportconfig, + NR_CSI_ResourceConfigId_t csi_ResourceConfigId, + NR_CSI_MeasConfig_t *csi_MeasConfig) { + + int bits = 0; + uint32_t temp_payload = 0; + + for (int csi_resourceidx = 0; csi_resourceidx < csi_MeasConfig->csi_ResourceConfigToAddModList->list.count; csi_resourceidx++) { + + struct NR_CSI_ResourceConfig *csi_resourceconfig = csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[csi_resourceidx]; + if (csi_resourceconfig->csi_ResourceConfigId == csi_ResourceConfigId) { + + for (int csi_idx = 0; csi_idx < csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.count; csi_idx++) { + if (csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[csi_idx]->nzp_CSI_ResourceSetId == + *(csi_resourceconfig->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list.array[0])) { + + nr_csi_report_t *csi_report = &mac->csi_report_template[csi_reportconfig->reportConfigId]; + compute_csi_bitlen(csi_MeasConfig, mac->csi_report_template); + + int cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; + int ri_bitlen = csi_report->csi_meas_bitlen.ri_bitlen; + int pmi_bitlen = csi_report->csi_meas_bitlen.pmi_x1_bitlen[*mac->csirs_measurements.rank_indicator] + + csi_report->csi_meas_bitlen.pmi_x2_bitlen[*mac->csirs_measurements.rank_indicator]; + int cqi_bitlen = csi_report->csi_meas_bitlen.cqi_bitlen[*mac->csirs_measurements.rank_indicator]; + + LOG_I(NR_MAC, "cri_bitlen = %d\n", cri_bitlen); + LOG_I(NR_MAC, "ri_bitlen = %d\n", ri_bitlen); + LOG_I(NR_MAC, "pmi_bitlen = %d\n", pmi_bitlen); + LOG_I(NR_MAC, "cqi_bitlen = %d\n", cqi_bitlen); + + break; + } + } + } + } + pucch->csi_part1_payload = temp_payload; + return bits; +} // returns index from RSRP // according to Table 10.1.6.1-1 in 38.133 diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index c39f4fa510..27041a27e3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -687,7 +687,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, CellGroup->spCellConfig->spCellConfigDedicated && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { - compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info, UE_id, Mod_idP); + compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info->csi_report_template[UE_id]); } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index aac73d55f2..ee07250ad4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2296,7 +2296,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG CellGroup->spCellConfig->spCellConfigDedicated && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { - compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info, UE_id, mod_idP); + compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info->csi_report_template[UE_id]); } NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; memset(sched_ctrl, 0, sizeof(*sched_ctrl)); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index ed80910bd0..c43e54d883 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -170,491 +170,6 @@ void nr_schedule_pucch(int Mod_idP, } } - -//! Calculating number of bits set -uint8_t number_of_bits_set (uint8_t buf){ - uint8_t nb_of_bits_set = 0; - uint8_t mask = 0xff; - uint8_t index = 0; - - for (index=7; (buf & mask) && (index>=0) ; index--){ - if (buf & (1<>=1; - } - return nb_of_bits_set; -} - - -void compute_rsrp_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, - uint8_t nb_resources, - nr_csi_report_t *csi_report) { - - if (NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled == csi_reportconfig->groupBasedBeamReporting.present) { - if (NULL != csi_reportconfig->groupBasedBeamReporting.choice.disabled->nrofReportedRS) - csi_report->CSI_report_bitlen.nb_ssbri_cri = *(csi_reportconfig->groupBasedBeamReporting.choice.disabled->nrofReportedRS)+1; - else - /*! From Spec 38.331 - * nrofReportedRS - * The number (N) of measured RS resources to be reported per report setting in a non-group-based report. N <= N_max, where N_max is either 2 or 4 depending on UE - * capability. FFS: The signaling mechanism for the gNB to select a subset of N beams for the UE to measure and report. - * When the field is absent the UE applies the value 1 - */ - csi_report->CSI_report_bitlen.nb_ssbri_cri= 1; - } else - csi_report->CSI_report_bitlen.nb_ssbri_cri= 2; - - if (nb_resources) { - csi_report->CSI_report_bitlen.cri_ssbri_bitlen =ceil(log2 (nb_resources)); - csi_report->CSI_report_bitlen.rsrp_bitlen = 7; //From spec 38.212 Table 6.3.1.1.2-6: CRI, SSBRI, and RSRP - csi_report->CSI_report_bitlen.diff_rsrp_bitlen =4; //From spec 38.212 Table 6.3.1.1.2-6: CRI, SSBRI, and RSRP - } else { - csi_report->CSI_report_bitlen.cri_ssbri_bitlen =0; - csi_report->CSI_report_bitlen.rsrp_bitlen = 0; - csi_report->CSI_report_bitlen.diff_rsrp_bitlen =0; - } -} - - -uint8_t compute_ri_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, - nr_csi_report_t *csi_report){ - - struct NR_CodebookConfig *codebookConfig = csi_reportconfig->codebookConfig; - uint8_t nb_allowed_ri, ri_bitlen; - uint8_t ri_restriction = 0; - - if (codebookConfig == NULL) { - csi_report->csi_meas_bitlen.ri_bitlen=0; - return ri_restriction; - } - - // codebook type1 single panel - if (NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel==codebookConfig->codebookType.choice.type1->subType.present){ - struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel *type1single = codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel; - if (type1single->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two){ - - ri_restriction = csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]; - - nb_allowed_ri = number_of_bits_set(ri_restriction); - ri_bitlen = ceil(log2(nb_allowed_ri)); - - ri_bitlen = ri_bitlen<1?ri_bitlen:1; //from the spec 38.212 and table 6.3.1.1.2-3: RI, LI, CQI, and CRI of codebookType=typeI-SinglePanel - csi_report->csi_meas_bitlen.ri_bitlen=ri_bitlen; - } - if (type1single->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo){ - if (type1single->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present == - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction) { - // 4 ports - - ri_restriction = csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]; - - nb_allowed_ri = number_of_bits_set(ri_restriction); - ri_bitlen = ceil(log2(nb_allowed_ri)); - - ri_bitlen = ri_bitlen<2?ri_bitlen:2; //from the spec 38.212 and table 6.3.1.1.2-3: RI, LI, CQI, and CRI of codebookType=typeI-SinglePanel - csi_report->csi_meas_bitlen.ri_bitlen=ri_bitlen; - } - else { - // more than 4 ports - - ri_restriction = csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]; - - nb_allowed_ri = number_of_bits_set(ri_restriction); - ri_bitlen = ceil(log2(nb_allowed_ri)); - - csi_report->csi_meas_bitlen.ri_bitlen=ri_bitlen; - } - } - return ri_restriction; - } - else - AssertFatal(1==0,"Other configurations not yet implemented\n"); - return -1; -} - -void compute_li_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, - uint8_t ri_restriction, - nr_csi_report_t *csi_report){ - - struct NR_CodebookConfig *codebookConfig = csi_reportconfig->codebookConfig; - for(int i=0; i<8; i++) { - if (codebookConfig == NULL || ((ri_restriction>>i)&0x01) == 0) - csi_report->csi_meas_bitlen.li_bitlen[i]=0; - else { - // codebook type1 single panel - if (NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel==codebookConfig->codebookType.choice.type1->subType.present) - csi_report->csi_meas_bitlen.li_bitlen[i]=ceil(log2(i+1))<2?ceil(log2(i+1)):2; - else - AssertFatal(1==0,"Other configurations not yet implemented\n"); - } - } -} - -void get_n1n2_o1o2_singlepanel(int *n1, int *n2, int *o1, int *o2, - struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo *morethantwo) { - - // Table 5.2.2.2.1-2 in 38.214 for supported configurations - switch(morethantwo->n1_n2.present){ - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction): - *n1 = 2; - *n2 = 1; - *o1 = 4; - *o2 = 1; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_two_TypeI_SinglePanel_Restriction): - *n1 = 2; - *n2 = 2; - *o1 = 4; - *o2 = 4; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction): - *n1 = 4; - *n2 = 1; - *o1 = 4; - *o2 = 1; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_three_two_TypeI_SinglePanel_Restriction): - *n1 = 3; - *n2 = 2; - *o1 = 4; - *o2 = 4; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction): - *n1 = 6; - *n2 = 1; - *o1 = 4; - *o2 = 1; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_two_TypeI_SinglePanel_Restriction): - *n1 = 4; - *n2 = 2; - *o1 = 4; - *o2 = 4; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_one_TypeI_SinglePanel_Restriction): - *n1 = 8; - *n2 = 1; - *o1 = 4; - *o2 = 1; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_three_TypeI_SinglePanel_Restriction): - *n1 = 4; - *n2 = 3; - *o1 = 4; - *o2 = 4; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_two_TypeI_SinglePanel_Restriction): - *n1 = 4; - *n2 = 2; - *o1 = 4; - *o2 = 4; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_twelve_one_TypeI_SinglePanel_Restriction): - *n1 = 12; - *n2 = 1; - *o1 = 4; - *o2 = 1; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_four_TypeI_SinglePanel_Restriction): - *n1 = 4; - *n2 = 4; - *o1 = 4; - *o2 = 4; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_two_TypeI_SinglePanel_Restriction): - *n1 = 8; - *n2 = 2; - *o1 = 4; - *o2 = 4; - break; - case (NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_sixteen_one_TypeI_SinglePanel_Restriction): - *n1 = 16; - *n2 = 1; - *o1 = 4; - *o2 = 1; - break; - default: - AssertFatal(1==0,"Not supported configuration for n1_n2 in codebook configuration"); - } -} - -void get_x1x2_bitlen_singlepanel(int n1, int n2, int o1, int o2, - int *x1, int *x2, int rank, int codebook_mode) { - - // Table 6.3.1.1.2-1 in 38.212 - switch(rank){ - case 1: - if(n2>1) { - if (codebook_mode == 1) { - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); - *x2 = 2; - } - else { - *x1 = ceil(log2(n1*o1/2)) + ceil(log2(n2*o2/2)); - *x2 = 4; - } - } - else{ - if (codebook_mode == 1) { - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); - *x2 = 2; - } - else { - *x1 = ceil(log2(n1*o1/2)); - *x2 = 4; - } - } - break; - case 2: - if(n1*n2 == 2) { - if (codebook_mode == 1) { - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); - *x2 = 1; - } - else { - *x1 = ceil(log2(n1*o1/2)); - *x2 = 3; - } - *x1 += 1; - } - else { - if(n2>1) { - if (codebook_mode == 1) { - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); - *x2 = 3; - } - else { - *x1 = ceil(log2(n1*o1/2)) + ceil(log2(n2*o2/2)); - *x2 = 3; - } - } - else{ - if (codebook_mode == 1) { - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); - *x2 = 1; - } - else { - *x1 = ceil(log2(n1*o1/2)); - *x2 = 3; - } - } - *x1 += 2; - } - break; - case 3: - case 4: - if(n1*n2 == 2) { - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); - *x2 = 1; - } - else { - if(n1*n2 >= 8) { - *x1 = ceil(log2(n1*o1/2)) + ceil(log2(n2*o2)) + 2; - *x2 = 1; - } - else { - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)) + 2; - *x2 = 1; - } - } - break; - case 5: - case 6: - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); - *x2 = 1; - break; - case 7: - case 8: - if(n1 == 4 && n2 == 1) { - *x1 = ceil(log2(n1*o1/2)) + ceil(log2(n2*o2)); - *x2 = 1; - } - else { - if(n1 > 2 && n2 == 2) { - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2/2)); - *x2 = 1; - } - else { - *x1 = ceil(log2(n1*o1)) + ceil(log2(n2*o2)); - *x2 = 1; - } - } - break; - default: - AssertFatal(1==0,"Invalid rank in x1 x2 bit length computation\n"); - } -} - - -void compute_pmi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, - uint8_t ri_restriction, - nr_csi_report_t *csi_report){ - - struct NR_CodebookConfig *codebookConfig = csi_reportconfig->codebookConfig; - for(int i=0; i<8; i++) { - csi_report->csi_meas_bitlen.pmi_x1_bitlen[i]=0; - csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=0; - if (codebookConfig == NULL || ((ri_restriction>>i)&0x01) == 0) - return; - else { - if(codebookConfig->codebookType.present == NR_CodebookConfig__codebookType_PR_type1) { - if(codebookConfig->codebookType.choice.type1->subType.present == NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel) { - if(codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present == - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two) { - if (i==0) - csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=2; - if (i==1) - csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=1; - } - else { // more than two - int n1,n2,o1,o2,x1,x2; - get_n1n2_o1o2_singlepanel(&n1,&n2,&o1,&o2,codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo); - get_x1x2_bitlen_singlepanel(n1,n2,o1,o2,&x1,&x2,i+1,codebookConfig->codebookType.choice.type1->codebookMode); - csi_report->csi_meas_bitlen.pmi_x1_bitlen[i]=x1; - csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=x2; - } - } - else - AssertFatal(1==0,"Type1 Multi-panel Codebook Config not yet implemented\n"); - } - else - AssertFatal(1==0,"Type2 Codebook Config not yet implemented\n"); - } - } -} - -void compute_cqi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, - uint8_t ri_restriction, - nr_csi_report_t *csi_report){ - - struct NR_CodebookConfig *codebookConfig = csi_reportconfig->codebookConfig; - struct NR_CSI_ReportConfig__reportFreqConfiguration *freq_config = csi_reportconfig->reportFreqConfiguration; - - if (*freq_config->cqi_FormatIndicator == NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI) { - for(int i=0; i<8; i++) { - if ((ri_restriction>>i)&0x01) { - csi_report->csi_meas_bitlen.cqi_bitlen[i] = 4; - if(codebookConfig != NULL) { - if (NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel == codebookConfig->codebookType.choice.type1->subType.present){ - struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel *type1single = codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel; - if (type1single->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo) { - if (type1single->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present > - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction) { - // more than 4 antenna ports - if (i > 4) - csi_report->csi_meas_bitlen.cqi_bitlen[i] += 4; // CQI for second TB - } - } - } - } - } - else - csi_report->csi_meas_bitlen.cqi_bitlen[i] = 0; - } - } - else - 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; - uint8_t nb_resources = 0; - NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type; - NR_CSI_ResourceConfigId_t csi_ResourceConfigId; - struct NR_CSI_ResourceConfig *csi_resourceconfig; - - // for each CSI measurement report configuration (list of CSI-ReportConfig) - LOG_D(NR_MAC,"Searching %d csi_reports\n",csi_MeasConfig->csi_ReportConfigToAddModList->list.count); - for (csi_report_id=0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ - struct NR_CSI_ReportConfig *csi_reportconfig = csi_MeasConfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; - // MAC structure for CSI measurement reports (per UE and per report) - nr_csi_report_t *csi_report = &UE_info->csi_report_template[UE_id][csi_report_id]; - // csi-ResourceConfigId of a CSI-ResourceConfig included in the configuration - // (either CSI-RS or SSB) - csi_ResourceConfigId = csi_reportconfig->resourcesForChannelMeasurement; - // looking for CSI-ResourceConfig - int found_resource = 0; - int csi_resourceidx = 0; - while (found_resource == 0 && csi_resourceidx < csi_MeasConfig->csi_ResourceConfigToAddModList->list.count) { - csi_resourceconfig = csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[csi_resourceidx]; - if ( csi_resourceconfig->csi_ResourceConfigId == csi_ResourceConfigId) - found_resource = 1; - csi_resourceidx++; - } - AssertFatal(found_resource==1,"Not able to found any CSI-ResourceConfig with csi-ResourceConfigId %ld\n", - csi_ResourceConfigId); - - long resourceType = csi_resourceconfig->resourceType; - - reportQuantity_type = csi_reportconfig->reportQuantity.present; - csi_report->reportQuantity_type = reportQuantity_type; - - // setting the CSI or SSB index list - if (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP == csi_report->reportQuantity_type) { - for (int csi_idx = 0; csi_idx < csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.count; csi_idx++) { - if (csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceSetId == - *(csi_resourceconfig->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list.array[0])){ - //We can configure only one SSB resource set from spec 38.331 IE CSI-ResourceConfig - nb_resources= csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceList.list.count; - csi_report->SSB_Index_list = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_idx]->csi_SSB_ResourceList.list.array; - csi_report->CSI_Index_list = NULL; - break; - } - } - } - else { - if (resourceType == NR_CSI_ResourceConfig__resourceType_periodic) { - AssertFatal(csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList != NULL, - "Wrong settings! Report quantity requires CSI-RS but csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList is NULL\n"); - for (int csi_idx = 0; csi_idx < csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.count; csi_idx++) { - if (csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[csi_idx]->nzp_CSI_ResourceSetId == - *(csi_resourceconfig->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list.array[0])) { - //For periodic and semi-persistent CSI Resource Settings, the number of CSI-RS Resource Sets configured is limited to S=1 for spec 38.212 - nb_resources = csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[csi_idx]->nzp_CSI_RS_Resources.list.count; - csi_report->CSI_Index_list = csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[csi_idx]->nzp_CSI_RS_Resources.list.array; - csi_report->SSB_Index_list = NULL; - break; - } - } - } - else AssertFatal(1==0,"Only periodic resource configuration currently supported\n"); - } - LOG_D(NR_MAC,"nb_resources %d\n",nb_resources); - // computation of bit length depending on the report type - switch(reportQuantity_type){ - case (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP): - compute_rsrp_bitlen(csi_reportconfig, nb_resources, csi_report); - break; - case (NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP): - compute_rsrp_bitlen(csi_reportconfig, nb_resources, csi_report); - break; - case (NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_CQI): - csi_report->csi_meas_bitlen.cri_bitlen=ceil(log2(nb_resources)); - csi_report->csi_meas_bitlen.ri_restriction = compute_ri_bitlen(csi_reportconfig, csi_report); - compute_cqi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); - break; - case (NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI): - csi_report->csi_meas_bitlen.cri_bitlen=ceil(log2(nb_resources)); - csi_report->csi_meas_bitlen.ri_restriction = compute_ri_bitlen(csi_reportconfig, csi_report); - compute_cqi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); - compute_pmi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); - break; - case (NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_LI_PMI_CQI): - csi_report->csi_meas_bitlen.cri_bitlen=ceil(log2(nb_resources)); - csi_report->csi_meas_bitlen.ri_restriction = compute_ri_bitlen(csi_reportconfig, csi_report); - compute_li_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); - compute_cqi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); - compute_pmi_bitlen(csi_reportconfig, csi_report->csi_meas_bitlen.ri_restriction, csi_report); - break; - default: - AssertFatal(1==0,"Not yet supported CSI report quantity type"); - } - } -} - - uint16_t nr_get_csi_bitlen(int Mod_idP, int UE_id, uint8_t csi_report_id) { diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 399033abd0..05faa2849b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -416,8 +416,6 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, int nr_get_default_pucch_res(int pucch_ResourceCommon); -void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_info, int UE_id, module_id_t Mod_idP); - int get_dlscs(nfapi_nr_config_request_t *cfg); int get_ulscs(nfapi_nr_config_request_t *cfg); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 9021a58079..155d67c2f1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -502,35 +502,6 @@ struct CSI_Report { #define MAX_SR_BITLEN 8 -typedef struct { - uint8_t nb_ssbri_cri; - uint8_t cri_ssbri_bitlen; - uint8_t rsrp_bitlen; - uint8_t diff_rsrp_bitlen; -}L1_RSRP_bitlen_t; - -typedef struct{ - uint8_t ri_restriction; - uint8_t cri_bitlen; - uint8_t ri_bitlen; - uint8_t li_bitlen[8]; - uint8_t pmi_x1_bitlen[8]; - uint8_t pmi_x2_bitlen[8]; - uint8_t cqi_bitlen[8]; -} CSI_Meas_bitlen_t; - -typedef struct nr_csi_report { - NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type; - long periodicity; - uint16_t offset; - long ** SSB_Index_list; - long ** CSI_Index_list; -// uint8_t nb_of_nzp_csi_report; - uint8_t nb_of_csi_ssb_report; - L1_RSRP_bitlen_t CSI_report_bitlen; - CSI_Meas_bitlen_t csi_meas_bitlen; -} nr_csi_report_t; - /*! As per the spec 38.212 and table: 6.3.1.1.2-12 in a single UCI sequence we can have multiple CSI_report the number of CSI_report will depend on number of CSI resource sets that are configured in CSI-ResourceConfig RRC IE From spec 38.331 from the IE CSI-ResourceConfig for SSB RSRP reporting we can configure only one resource set @@ -679,7 +650,6 @@ typedef struct { /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ -#define MAX_CSI_REPORTCONFIG 48 typedef struct { /// scheduling control info nr_csi_report_t csi_report_template[MAX_MOBILES_PER_GNB][MAX_CSI_REPORTCONFIG]; From cd6ee6a01ef456366c91c7c8925bb484ea0acf52 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 13 Apr 2022 11:12:49 +0100 Subject: [PATCH 25/71] Fix build after merge --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 0b63c4a149..09522a5411 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -684,7 +684,7 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t csirs_measurements.cqi = ue->nr_csi_rs_info->cqi; nr_downlink_indication_t *dl_indication = calloc(sizeof(*dl_indication),1); fapi_nr_rx_indication_t *rx_ind = calloc(sizeof(*rx_ind),1); - nr_fill_dl_indication(dl_indication, NULL, rx_ind, proc, ue, gNB_id); + nr_fill_dl_indication(dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); nr_fill_rx_indication(rx_ind, FAPI_NR_CSIRS_IND, gNB_id, ue, NULL, NULL, 1, proc, (void *)&csirs_measurements); if (ue->if_inst && ue->if_inst->dl_indication) { ue->if_inst->dl_indication(dl_indication, NULL); From 27bac2f2c4ae09c2f7ee73593ef030066de9b393 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 13 Apr 2022 15:33:37 +0100 Subject: [PATCH 26/71] The RI, PMI and CQI estimated at the UE are sent by the UE and correctly received by the gNB --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 29 ++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 7bb8fa93a3..b46bfecc35 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2590,7 +2590,7 @@ uint8_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, NR_CSI_ResourceConfigId_t csi_ResourceConfigId, NR_CSI_MeasConfig_t *csi_MeasConfig) { - int bits = 0; + int n_bits = 0; uint32_t temp_payload = 0; for (int csi_resourceidx = 0; csi_resourceidx < csi_MeasConfig->csi_ResourceConfigToAddModList->list.count; csi_resourceidx++) { @@ -2607,14 +2607,27 @@ uint8_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, int cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; int ri_bitlen = csi_report->csi_meas_bitlen.ri_bitlen; - int pmi_bitlen = csi_report->csi_meas_bitlen.pmi_x1_bitlen[*mac->csirs_measurements.rank_indicator] + - csi_report->csi_meas_bitlen.pmi_x2_bitlen[*mac->csirs_measurements.rank_indicator]; + int pmi_x1_bitlen = csi_report->csi_meas_bitlen.pmi_x1_bitlen[*mac->csirs_measurements.rank_indicator]; + int pmi_x2_bitlen = csi_report->csi_meas_bitlen.pmi_x2_bitlen[*mac->csirs_measurements.rank_indicator]; int cqi_bitlen = csi_report->csi_meas_bitlen.cqi_bitlen[*mac->csirs_measurements.rank_indicator]; - LOG_I(NR_MAC, "cri_bitlen = %d\n", cri_bitlen); - LOG_I(NR_MAC, "ri_bitlen = %d\n", ri_bitlen); - LOG_I(NR_MAC, "pmi_bitlen = %d\n", pmi_bitlen); - LOG_I(NR_MAC, "cqi_bitlen = %d\n", cqi_bitlen); + n_bits = cri_bitlen + ri_bitlen + pmi_x1_bitlen + pmi_x2_bitlen + cqi_bitlen; + + // TODO: Improvements will be needed to cri_bitlen>0 and pmi_x1_bitlen>0 + temp_payload = (*mac->csirs_measurements.rank_indicator<<(cri_bitlen+cqi_bitlen+pmi_x2_bitlen+pmi_x1_bitlen)) | + (*mac->csirs_measurements.i1<<(cri_bitlen+cqi_bitlen+pmi_x2_bitlen)) | + (*mac->csirs_measurements.i2<<(cri_bitlen+cqi_bitlen)) | + (*mac->csirs_measurements.cqi<csi_part1_payload = temp_payload; - return bits; + return n_bits; } // returns index from RSRP From ad3253fef62adaa029da975ec6fc6f8cdeb242c4 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Wed, 13 Apr 2022 19:45:10 +0100 Subject: [PATCH 27/71] Move CSI-RS configuration from fill_initial_SpCellConfig to update_cellGroupConfig --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 30 ++--------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index d690db3a75..81582a57c8 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1308,13 +1308,8 @@ void fill_initial_SpCellConfig(int uid, NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); pucchspatial->pucch_SpatialRelationInfoId = 1; pucchspatial->servingCellId = NULL; - - // TODO: Remove this if - if(!configuration->do_CSIRS) { - 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; @@ -1608,25 +1603,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; - // TODO: Delete this code and calls in update_cellGroupConfig() - 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; - 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); - } - pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; pdsch_servingcellconfig->xOverhead = NULL; pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH)); @@ -1734,7 +1710,6 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc = configuration->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)); @@ -1752,7 +1727,6 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, } fill_default_csi_MeasConfig(uid, SpCellConfig->spCellConfigDedicated->csi_MeasConfig, scc, configuration); } - */ // Set DL MCS table NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP; From eb12cb8f10a446468cc0fa4202cd750ec503ca2b Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 18 Apr 2022 15:19:29 +0100 Subject: [PATCH 28/71] Fix CI test for FR2 RA --- ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf index 9353bd12d2..dcb3dd89b7 100644 --- a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf @@ -225,6 +225,7 @@ RUs = ( att_tx = 0; att_rx = 0; bands = [7]; + sl_ahead = 12; max_pdschReferenceSignalPower = -27; max_rxgain = 75; eNB_instances = [0]; From 2f753873bc9ebdf6c0156f440970cd8748c11e95 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Sat, 30 Apr 2022 16:12:27 +0100 Subject: [PATCH 29/71] =?UTF-8?q?Fix=20warning:=20this=20=E2=80=98if?= =?UTF-8?q?=E2=80=99=20clause=20does=20not=20guard...=20[-Wmisleading-inde?= =?UTF-8?q?ntation]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 8aace75610..18ffe85cad 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -451,10 +451,11 @@ int nr_process_mac_pdu(module_id_t module_idP, 0); break; - case UL_SCH_LCID_DTCH: - // check if LCID is valid at current time. - if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) - return 0; + case UL_SCH_LCID_DTCH: + // check if LCID is valid at current time. + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) { + return 0; + } struct timespec time_request; clock_gettime(CLOCK_REALTIME, &time_request); @@ -471,24 +472,26 @@ int nr_process_mac_pdu(module_id_t module_idP, mac_len); UE_info->mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_len; - mac_rlc_data_ind(module_idP, - UE_info->rnti[UE_id], - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - rx_lcid, - (char *)(pduP + mac_subheader_len), - mac_len, - 1, - NULL); + mac_rlc_data_ind(module_idP, + UE_info->rnti[UE_id], + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + rx_lcid, + (char *)(pduP + mac_subheader_len), + mac_len, + 1, + NULL); - /* Updated estimated buffer when receiving data */ - if (sched_ctrl->estimated_ul_buffer >= mac_len) - sched_ctrl->estimated_ul_buffer -= mac_len; - else - sched_ctrl->estimated_ul_buffer = 0; - break; + /* Updated estimated buffer when receiving data */ + if (sched_ctrl->estimated_ul_buffer >= mac_len) { + sched_ctrl->estimated_ul_buffer -= mac_len; + } else { + sched_ctrl->estimated_ul_buffer = 0; + } + + break; default: LOG_E(NR_MAC, "Received unknown MAC header (LCID = 0x%02x)\n", rx_lcid); From 73a1e92249c7dac925b98dca27955989b2d2d902 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Tue, 3 May 2022 12:09:19 +0100 Subject: [PATCH 30/71] Fix memory leaks --- openair1/PHY/INIT/nr_init_ue.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index e56de7d4db..941b59c8ed 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -523,6 +523,10 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) } free_and_zero(ue->nr_csi_rs_info->noise_power); free_and_zero(ue->nr_csi_rs_info->rank_indicator); + free_and_zero(ue->nr_csi_rs_info->i1); + free_and_zero(ue->nr_csi_rs_info->i2); + free_and_zero(ue->nr_csi_rs_info->precoded_sinr_dB); + free_and_zero(ue->nr_csi_rs_info->cqi); 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); From 7018b7c84110f953a12fb7061ce19ff7237031a5 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Thu, 19 May 2022 13:38:22 +0100 Subject: [PATCH 31/71] Fixes after merge --- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 3 +++ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 71e4f53279..58e435f3f1 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -541,6 +541,9 @@ typedef struct nr_csi_report { uint8_t nb_of_csi_ssb_report; L1_RSRP_bitlen_t CSI_report_bitlen; CSI_Meas_bitlen_t csi_meas_bitlen; + int codebook_mode; + int N1; + int N2; } nr_csi_report_t; #endif /*__LAYER2_MAC_H__ */ diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 67e4557975..b4e52ef96c 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -4543,6 +4543,8 @@ void compute_pmi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, if(codebookConfig->codebookType.choice.type1->subType.present == NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel) { if(codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two) { + csi_report->N1 = 1; + csi_report->N2 = 1; if (i==0) csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=2; if (i==1) @@ -4552,6 +4554,9 @@ void compute_pmi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, int n1,n2,o1,o2,x1,x2; get_n1n2_o1o2_singlepanel(&n1,&n2,&o1,&o2,codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo); get_x1x2_bitlen_singlepanel(n1,n2,o1,o2,&x1,&x2,i+1,codebookConfig->codebookType.choice.type1->codebookMode); + csi_report->N1 = n1; + csi_report->N2 = n2; + csi_report->codebook_mode = codebookConfig->codebookType.choice.type1->codebookMode; csi_report->csi_meas_bitlen.pmi_x1_bitlen[i]=x1; csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=x2; } From 4eac17e1c8f720b9cdb29062d9dc1eeacc1197c4 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Fri, 20 May 2022 20:51:22 +0100 Subject: [PATCH 32/71] Fix in RI computation --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 33 +++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 25c0d06008..12068210cb 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -340,7 +340,7 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, uint8_t *rank_indicator) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int16_t cond_dB_threshold = 0; + int16_t cond_dB_threshold = 5; int count = 0; *rank_indicator = 0; @@ -357,6 +357,8 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, * | conjch01 conjch11 | | ch10 ch11 | | conjch01*ch00+conjch11*ch10 conjch01*ch01+conjch11*ch11 | */ + uint8_t sum_shift = 1; // log2(2x2) = 2, which is a shift of 1 bit + for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { memset(nr_csi_rs_info->csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch],0,NR_MAX_OFDM_SYMBOL_SIZE*sizeof(int32_t)); @@ -413,11 +415,33 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, &nr_csi_rs_info->csi_rs_estimated_numer_fin[k], 1); +#ifdef NR_CSIRS_DEBUG + for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { + for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { + int16_t *csi_rs_estimated_A_MF = (int16_t *) &nr_csi_rs_info->csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch][k]; + LOG_I(NR_PHY, "(%i) csi_rs_estimated_A_MF[%i][%i] = (%i, %i)\n", + k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF[0], csi_rs_estimated_A_MF[1]); + int16_t *csi_rs_estimated_A_MF_sq = (int16_t *) &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[port_tx_conjch][port_tx_ch][k]; + LOG_I(NR_PHY, "(%i) csi_rs_estimated_A_MF_sq[%i][%i] = (%i, %i)\n", + k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF_sq[0], csi_rs_estimated_A_MF_sq[1]); + } + } + LOG_I(NR_PHY, "(%i) csi_rs_estimated_determ_fin = %i\n", k, nr_csi_rs_info->csi_rs_estimated_determ_fin[k]); + LOG_I(NR_PHY, "(%i) csi_rs_estimated_numer_fin = %i\n", k, nr_csi_rs_info->csi_rs_estimated_numer_fin[k]>>sum_shift); +#endif + // compute the conditional number for (int sc_idx=0; sc_idx < NR_NB_SC_PER_RB; sc_idx++) { int8_t csi_rs_estimated_denum_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_determ_fin[k + sc_idx]); - int8_t csi_rs_estimated_numer_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_numer_fin[k + sc_idx]); + int8_t csi_rs_estimated_numer_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_numer_fin[k + sc_idx]>>sum_shift); int8_t cond_db = csi_rs_estimated_numer_db - csi_rs_estimated_denum_db; + +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "csi_rs_estimated_denum_db = %i\n", csi_rs_estimated_denum_db); + LOG_I(NR_PHY, "csi_rs_estimated_numer_db = %i\n", csi_rs_estimated_numer_db); + LOG_I(NR_PHY, "cond_db = %i\n", cond_db); +#endif + if (cond_db < cond_dB_threshold) { count++; } else { @@ -431,6 +455,11 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, *rank_indicator = 1; } +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "count = %i\n", count); + LOG_I(NR_PHY, "rank = %i\n", (*rank_indicator)+1); +#endif + return 0; } From c67d3659f148052038d3001b9612edddb9878373 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Fri, 20 May 2022 21:12:06 +0100 Subject: [PATCH 33/71] Fix precoded_sinr_dB computation for rank = 2 --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 12068210cb..5a05e256e2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -553,7 +553,7 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, *precoded_sinr_dB = dB_fixed(tested_precoded_sinr[i2[0]]); } else { i2[0] = tested_precoded_sinr[0]+tested_precoded_sinr[2] > tested_precoded_sinr[1]+tested_precoded_sinr[3] ? 0 : 1; - *precoded_sinr_dB = dB_fixed((tested_precoded_sinr[i2[0]] + tested_precoded_sinr[i2[0]+2]))>>1; + *precoded_sinr_dB = dB_fixed((tested_precoded_sinr[i2[0]] + tested_precoded_sinr[i2[0]+2])>>1); } } else { From 23dab34e7c7a77db1458aa03d4ddb9b9d8f0ea43 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Sat, 21 May 2022 01:15:26 +0100 Subject: [PATCH 34/71] Fix CSI bitlen for rank = 2 --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 32 ++++++++++++++++ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 2 + openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 6 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 38 +------------------ 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index b4e52ef96c..7d27528a35 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -4698,4 +4698,36 @@ void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, nr_csi_report_t *cs AssertFatal(1==0,"Not yet supported CSI report quantity type"); } } +} + +uint16_t nr_get_csi_bitlen(nr_csi_report_t *csi_report_template, uint8_t csi_report_id) { + + uint16_t csi_bitlen = 0; + uint16_t max_bitlen = 0; + L1_RSRP_bitlen_t *CSI_report_bitlen = NULL; + CSI_Meas_bitlen_t *csi_meas_bitlen = NULL; + + if (csi_report_template[csi_report_id].reportQuantity_type == NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP || + csi_report_template[csi_report_id].reportQuantity_type == NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP) { + CSI_report_bitlen = &(csi_report_template[csi_report_id].CSI_report_bitlen); // This might need to be moodif for Aperiodic CSI-RS measurements + csi_bitlen += ((CSI_report_bitlen->cri_ssbri_bitlen * CSI_report_bitlen->nb_ssbri_cri) + + CSI_report_bitlen->rsrp_bitlen +(CSI_report_bitlen->diff_rsrp_bitlen * + (CSI_report_bitlen->nb_ssbri_cri -1 ))); + } else { + csi_meas_bitlen = &(csi_report_template[csi_report_id].csi_meas_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements + uint16_t temp_bitlen; + for (int i=0; i<8; i++) { + temp_bitlen = (csi_meas_bitlen->cri_bitlen+ + csi_meas_bitlen->ri_bitlen+ + csi_meas_bitlen->li_bitlen[i]+ + csi_meas_bitlen->cqi_bitlen[i]+ + csi_meas_bitlen->pmi_x1_bitlen[i]+ + csi_meas_bitlen->pmi_x2_bitlen[i]); + if(temp_bitlen>max_bitlen) + max_bitlen = temp_bitlen; + } + csi_bitlen += max_bitlen; + } + + return csi_bitlen; } \ No newline at end of file diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 982e683e0c..f626328ad8 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -245,4 +245,6 @@ void compute_cqi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, nr_csi_report_t *csi_report_template); +uint16_t nr_get_csi_bitlen(nr_csi_report_t *csi_report_template, uint8_t csi_report_id); + #endif diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index e7d188bd0a..1e73df7d76 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2650,17 +2650,17 @@ uint8_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, nr_csi_report_t *csi_report = &mac->csi_report_template[csi_reportconfig->reportConfigId]; compute_csi_bitlen(csi_MeasConfig, mac->csi_report_template); + n_bits = nr_get_csi_bitlen(mac->csi_report_template, csi_reportconfig->reportConfigId); int cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; int ri_bitlen = csi_report->csi_meas_bitlen.ri_bitlen; int pmi_x1_bitlen = csi_report->csi_meas_bitlen.pmi_x1_bitlen[*mac->csirs_measurements.rank_indicator]; int pmi_x2_bitlen = csi_report->csi_meas_bitlen.pmi_x2_bitlen[*mac->csirs_measurements.rank_indicator]; int cqi_bitlen = csi_report->csi_meas_bitlen.cqi_bitlen[*mac->csirs_measurements.rank_indicator]; - - n_bits = cri_bitlen + ri_bitlen + pmi_x1_bitlen + pmi_x2_bitlen + cqi_bitlen; + int padding_bitlen = n_bits - (cri_bitlen + ri_bitlen + pmi_x1_bitlen + pmi_x2_bitlen + cqi_bitlen); // TODO: Improvements will be needed to cri_bitlen>0 and pmi_x1_bitlen>0 - temp_payload = (*mac->csirs_measurements.rank_indicator<<(cri_bitlen+cqi_bitlen+pmi_x2_bitlen+pmi_x1_bitlen)) | + temp_payload = (*mac->csirs_measurements.rank_indicator<<(cri_bitlen+cqi_bitlen+pmi_x2_bitlen+padding_bitlen+pmi_x1_bitlen)) | (*mac->csirs_measurements.i1<<(cri_bitlen+cqi_bitlen+pmi_x2_bitlen)) | (*mac->csirs_measurements.i2<<(cri_bitlen+cqi_bitlen)) | (*mac->csirs_measurements.cqi<UE_info; - L1_RSRP_bitlen_t * CSI_report_bitlen = NULL; - CSI_Meas_bitlen_t * csi_meas_bitlen = NULL; - - if (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP==UE_info->csi_report_template[UE_id][csi_report_id].reportQuantity_type|| - NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP==UE_info->csi_report_template[UE_id][csi_report_id].reportQuantity_type){ - CSI_report_bitlen = &(UE_info->csi_report_template[UE_id][csi_report_id].CSI_report_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements - csi_bitlen+= ((CSI_report_bitlen->cri_ssbri_bitlen * CSI_report_bitlen->nb_ssbri_cri) + - CSI_report_bitlen->rsrp_bitlen +(CSI_report_bitlen->diff_rsrp_bitlen * - (CSI_report_bitlen->nb_ssbri_cri -1 ))); - } else{ - csi_meas_bitlen = &(UE_info->csi_report_template[UE_id][csi_report_id].csi_meas_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements - uint16_t temp_bitlen; - for (int i=0; i<8; i++) { - temp_bitlen = (csi_meas_bitlen->cri_bitlen+ - csi_meas_bitlen->ri_bitlen+ - csi_meas_bitlen->li_bitlen[i]+ - csi_meas_bitlen->cqi_bitlen[i]+ - csi_meas_bitlen->pmi_x1_bitlen[i]+ - csi_meas_bitlen->pmi_x2_bitlen[i]); - if(temp_bitlen>max_bitlen) - max_bitlen = temp_bitlen; - } - csi_bitlen += max_bitlen; - } - - return csi_bitlen; -} - - void nr_csi_meas_reporting(int Mod_idP, frame_t frame, sub_frame_t slot) { @@ -275,7 +239,7 @@ void nr_csi_meas_reporting(int Mod_idP, curr_pucch->ul_slot = sched_slot; curr_pucch->resource_indicator = res_index; curr_pucch->csi_bits += - nr_get_csi_bitlen(Mod_idP,UE_id,csi_report_id); + nr_get_csi_bitlen(UE_info->csi_report_template[UE_id], csi_report_id); const NR_SIB1_t *sib1 = RC.nrmac[Mod_idP]->common_channels[0].sib1 ? RC.nrmac[Mod_idP]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, From 8bc5f273bda7819c037993aacb1ec18cb3cb1952 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Sat, 21 May 2022 01:24:02 +0100 Subject: [PATCH 35/71] Improve log --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- 1 file changed, 1 insertion(+), 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 1e73df7d76..9d3804f309 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2542,7 +2542,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_E(NR_MAC,"Measurement report based on CSI-RS not available\n"); + LOG_E(NR_MAC,"Measurement report %d based on CSI-RS is not available\n", csi_reportconfig->reportQuantity.present); break; default: AssertFatal(1==0,"Invalid CSI report quantity type %d\n",csi_reportconfig->reportQuantity.present); From 91189bd4f83ef736c17c99538324e4e80113154a Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 1 Jun 2022 14:30:45 +0100 Subject: [PATCH 36/71] Fixes after merge --- openair2/LAYER2/NR_MAC_gNB/config.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 19845c708b..7dda0ab5eb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -694,7 +694,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, CellGroup->spCellConfig->spCellConfigDedicated && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { - compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); + compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE->csi_report_template); } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index cdd754cc03..4ce4180fa5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2418,7 +2418,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf CellGroup->spCellConfig->spCellConfigDedicated && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { - compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); + compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE->csi_report_template); } NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index ef9f1b9c63..76c49b8257 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -235,7 +235,7 @@ void nr_csi_meas_reporting(int Mod_idP, curr_pucch->frame = frame; curr_pucch->ul_slot = sched_slot; curr_pucch->resource_indicator = res_index; - curr_pucch->csi_bits += nr_get_csi_bitlen(UE,csi_report_id); + curr_pucch->csi_bits += nr_get_csi_bitlen(UE->csi_report_template, csi_report_id); const NR_SIB1_t *sib1 = RC.nrmac[Mod_idP]->common_channels[0].sib1 ? RC.nrmac[Mod_idP]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, From 55e943c34740990092f49aac89c38188f49f8a5a Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Thu, 9 Jun 2022 00:48:39 +0100 Subject: [PATCH 37/71] Remove obsolete code after merge --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 187 ---------------------------- 1 file changed, 187 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 5b8bfa13a4..36d45a4905 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 = (8 + (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 = (28 + (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, From e32d55dff9eef4f945a0e27a09b94270557e4252 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Mon, 13 Jun 2022 11:30:37 +0100 Subject: [PATCH 38/71] Update the feature set for the UE --- doc/FEATURE_SET.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/FEATURE_SET.md b/doc/FEATURE_SET.md index d0856b415d..5db6e44d8d 100644 --- a/doc/FEATURE_SET.md +++ b/doc/FEATURE_SET.md @@ -440,6 +440,10 @@ The following features are valid for the gNB and the 5G-NR UE. - PTRS support - Support for 1, 2 and 4 RX antennas - Support for up to 2 layers (currently limited to DMRS configuration type 2) +* Measurements based on NR-CSIRS + - RI, PMI and CQI computation + - Support for 1 and 2 RX antennas + - Support for up to 2 layers * NR-PUSCH (including Segmentation, LDPC encoding, rate matching, scrambling, modulation, RB mapping, etc). - PUSCH mapping type A and B - DMRS configuration type 1 and 2 @@ -488,12 +492,15 @@ The following features are valid for the gNB and the 5G-NR UE. * UCI processing - ACK/NACK processing - Triggering periodic SR - - CSI measurement reporting (SSB RSRP only) -* DLSH scheduler + - CSI measurement reporting +* DLSCH scheduler - Configuration of fapi PDU according to DCI - HARQ procedures * ULSCH scheduler - Configuration of fapi PDU according to DCI +* NR-CSIRS scheduler + - Scheduling of NR-CSIRS reception + - Fill UCI for CSI measurement reporting * Scheduler procedures for SRS transmission - Periodic SRS transmission * Bandwidth part (BWP) operation From 504ce6d793802208e7f3e51ba7b76ec721509fb2 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Sun, 19 Jun 2022 02:13:33 +0100 Subject: [PATCH 39/71] Fix after merge --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 2 +- 1 file changed, 1 insertion(+), 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 2c7ec7efa4..34258c737c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -3002,7 +3002,7 @@ void nr_mac_update_timers(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig && cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { - compute_csi_bitlen (cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); + compute_csi_bitlen (cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE->csi_report_template); } NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; From 420ce608003ab33de8c9d4ec48347eedf47799af Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 22 Jun 2022 17:54:34 +0100 Subject: [PATCH 40/71] Fix flag related to received CSI-IM FAPI pdu at UE --- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 046f67a7d0..f4c863bb40 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -393,7 +393,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ case FAPI_NR_DL_CONFIG_TYPE_CSI_IM: 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; + csiim_vars->active = true; break; case FAPI_NR_DL_CONFIG_TYPE_CSI_RS: csirs_config_pdu = &dl_config->dl_config_list[i].csirs_config_pdu.csirs_config_rel15; From 32ec53baa5546241f9961c9e481d19291bfe9486 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 22 Jun 2022 18:10:28 +0100 Subject: [PATCH 41/71] Get CSI-IM pdu at phy layer and add debug logs --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 5a05e256e2..719d8e11b4 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -41,6 +41,7 @@ //#define NR_CSIRS_DEBUG +//#define NR_CSIIM_DEBUG bool is_csi_rs_in_symbol(fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, int symbol) { @@ -600,6 +601,23 @@ int nr_csi_rs_cqi_estimation(uint32_t precoded_sinr, } int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { + + if(!ue->csiim_vars[gNB_id]->active) { + return -1; + } + + fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu = (fapi_nr_dl_config_csiim_pdu_rel15_t*)&ue->csiim_vars[gNB_id]->csiim_config_pdu; + +#ifdef NR_CSIIM_DEBUG + LOG_I(NR_PHY, "csiim_config_pdu->bwp_size = %i\n", csiim_config_pdu->bwp_size); + LOG_I(NR_PHY, "csiim_config_pdu->bwp_start = %i\n", csiim_config_pdu->bwp_start); + LOG_I(NR_PHY, "csiim_config_pdu->subcarrier_spacing = %i\n", csiim_config_pdu->subcarrier_spacing); + LOG_I(NR_PHY, "csiim_config_pdu->start_rb = %i\n", csiim_config_pdu->start_rb); + LOG_I(NR_PHY, "csiim_config_pdu->nr_of_rbs = %i\n", csiim_config_pdu->nr_of_rbs); + LOG_I(NR_PHY, "csiim_config_pdu->k_csiim = %i.%i.%i.%i\n", csiim_config_pdu->k_csiim[0], csiim_config_pdu->k_csiim[1], csiim_config_pdu->k_csiim[2], csiim_config_pdu->k_csiim[3]); + LOG_I(NR_PHY, "csiim_config_pdu->l_csiim = %i.%i.%i.%i\n", csiim_config_pdu->l_csiim[0], csiim_config_pdu->l_csiim[1], csiim_config_pdu->l_csiim[2], csiim_config_pdu->l_csiim[3]); +#endif + return 0; } From b9a207a6b40cf532f6d6ccc7372ed6adb56294ec Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 22 Jun 2022 18:38:05 +0100 Subject: [PATCH 42/71] Call nr_slot_fep for CSI-IM symbols --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 739f6010d4..8bb4181c49 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1696,6 +1696,19 @@ 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)) { + int l_csiim[4] = {-1, -1, -1, -1}; + for(int symb_idx = 0; symb_idx < 4; symb_idx++) { + bool nr_slot_fep_done = false; + for (int symb_idx2 = 0; symb_idx2 < symb_idx; symb_idx2++) { + if (l_csiim[symb_idx2] == ue->csiim_vars[gNB_id]->csiim_config_pdu.l_csiim[symb_idx]) { + nr_slot_fep_done = true; + } + } + l_csiim[symb_idx] = ue->csiim_vars[gNB_id]->csiim_config_pdu.l_csiim[symb_idx]; + if(nr_slot_fep_done == false) { + nr_slot_fep(ue, proc, ue->csiim_vars[gNB_id]->csiim_config_pdu.l_csiim[symb_idx], nr_slot_rx); + } + } nr_ue_csi_im_procedures(ue, proc, gNB_id); ue->csiim_vars[gNB_id]->active = 0; } From a1806c92a2a8350364c39820717fca0876b4fa52 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 22 Jun 2022 20:41:57 +0100 Subject: [PATCH 43/71] Interference plus noise power computation based on CSI-IM --- openair1/PHY/INIT/nr_init_ue.c | 4 ++ openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 76 +++++++++++++++++++++++++++ openair1/PHY/defs_nr_UE.h | 3 ++ openair1/PHY/defs_nr_common.h | 4 ++ 4 files changed, 87 insertions(+) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 077302b207..ac2b7e21f6 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -381,6 +381,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) } } + ue->nr_csi_im_info = (nr_csi_im_info_t *)malloc16_clear(sizeof(nr_csi_im_info_t)); + ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); ue->nr_srs_info->sc_list = (uint16_t *) malloc16_clear(6*fp->N_RB_UL*sizeof(uint16_t)); ue->nr_srs_info->srs_generated_signal = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) ); @@ -530,6 +532,8 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) free_and_zero(ue->nr_csi_rs_info->csi_rs_estimated_channel_freq); free_and_zero(ue->nr_csi_rs_info); + free_and_zero(ue->nr_csi_im_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_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 719d8e11b4..e9baf7e722 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -600,6 +600,80 @@ int nr_csi_rs_cqi_estimation(uint32_t precoded_sinr, return 0; } +int nr_csi_im_power_estimation(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu, + uint32_t *interference_plus_noise_power) { + + 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; + + uint16_t end_rb = csiim_config_pdu->start_rb + csiim_config_pdu->nr_of_rbs > csiim_config_pdu->bwp_size ? + csiim_config_pdu->bwp_size : csiim_config_pdu->start_rb + csiim_config_pdu->nr_of_rbs; + + int32_t count = 0; + int32_t sum_re = 0; + int32_t sum_im = 0; + int32_t sum2_re = 0; + int32_t sum2_im = 0; + + int l_csiim[4] = {-1, -1, -1, -1}; + + for(int symb_idx = 0; symb_idx < 4; symb_idx++) { + + uint8_t symb = csiim_config_pdu->l_csiim[symb_idx]; + bool done = false; + for (int symb_idx2 = 0; symb_idx2 < symb_idx; symb_idx2++) { + if (l_csiim[symb_idx2] == symb) { + done = true; + } + } + + if (done) { + continue; + } + + l_csiim[symb_idx] = symb; + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + + for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { + + c16_t *rx_signal = (c16_t*)&rxdataF[ant_rx][symbol_offset]; + + for (int rb = csiim_config_pdu->start_rb; rb < end_rb; rb++) { + + uint16_t sc0_offset = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; + + for (int sc_idx = 0; sc_idx<4; sc_idx++) { + + uint16_t sc = sc0_offset + csiim_config_pdu->k_csiim[sc_idx]; + +#ifdef NR_CSIIM_DEBUG + LOG_I(NR_PHY, "(ant_rx %i, sc %i) real %i, imag %i\n", ant_rx, rb, rx_signal[sc].r, rx_signal[sc].i); +#endif + + sum_re += rx_signal[sc].r; + sum_im += rx_signal[sc].i; + sum2_re += rx_signal[sc].r*rx_signal[sc].r; + sum2_im += rx_signal[sc].i*rx_signal[sc].i; + count++; + } + } + } + } + + int32_t power_re = sum2_re/count - (sum_re/count)*(sum_re/count); + int32_t power_im = sum2_im/count - (sum_im/count)*(sum_im/count); + + *interference_plus_noise_power = power_re + power_im; + +#ifdef NR_CSIIM_DEBUG + LOG_I(NR_PHY, "interference_plus_noise_power based on CSI-IM = %i\n", *interference_plus_noise_power); +#endif + + return 0; +} + int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { if(!ue->csiim_vars[gNB_id]->active) { @@ -618,6 +692,8 @@ int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t LOG_I(NR_PHY, "csiim_config_pdu->l_csiim = %i.%i.%i.%i\n", csiim_config_pdu->l_csiim[0], csiim_config_pdu->l_csiim[1], csiim_config_pdu->l_csiim[2], csiim_config_pdu->l_csiim[3]); #endif + nr_csi_im_power_estimation(ue, proc, csiim_config_pdu, &ue->nr_csi_im_info->interference_plus_noise_power); + return 0; } diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index bd6808c54d..0c8dcc195c 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -881,6 +881,9 @@ typedef struct { /// CSI-RS variables nr_csi_rs_info_t *nr_csi_rs_info; + /// CSI-IM variables + nr_csi_im_info_t *nr_csi_im_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 a94bb30787..1d23e48a3b 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -284,6 +284,10 @@ typedef struct { uint8_t *cqi; } nr_csi_rs_info_t; +typedef struct { + uint32_t interference_plus_noise_power; +} nr_csi_im_info_t; + typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; typedef uint32_t (*get_samples_per_slot_t)(int slot, NR_DL_FRAME_PARMS* fp); From 05dde0a30d86cbd1b5d7042564f41544dd43c3b8 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 22 Jun 2022 20:59:19 +0100 Subject: [PATCH 44/71] Compute CQI using CSI-IM --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 9 +++++---- openair1/PHY/defs_nr_common.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index e9baf7e722..6be4d399bf 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -468,7 +468,7 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, nr_csi_rs_info_t *nr_csi_rs_info, int32_t ***csi_rs_estimated_channel_freq, - uint32_t noise_power, + uint32_t interference_plus_noise_power, uint8_t rank_indicator, uint8_t *i1, uint8_t *i2, @@ -487,7 +487,7 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, // The first column is applicable if the UE is reporting a Rank = 1, whereas the second column is applicable if the // UE is reporting a Rank = 2. - if(nr_csi_rs_info->N_ports == 1 || noise_power == 0) { + if(nr_csi_rs_info->N_ports == 1 || interference_plus_noise_power == 0) { return 0; } @@ -542,7 +542,7 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, for(int p = 0; p<4; p++) { int32_t power_re = sum2_re[p] - (sum_re[p]>>nr_csi_rs_info->log2_re)*(sum_re[p]>>nr_csi_rs_info->log2_re); int32_t power_im = sum2_im[p] - (sum_im[p]>>nr_csi_rs_info->log2_re)*(sum_im[p]>>nr_csi_rs_info->log2_re); - tested_precoded_sinr[p] = (power_re+power_im)/(int32_t)noise_power; + tested_precoded_sinr[p] = (power_re+power_im)/(int32_t)interference_plus_noise_power; } if(rank_indicator == 0) { @@ -693,6 +693,7 @@ int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t #endif nr_csi_im_power_estimation(ue, proc, csiim_config_pdu, &ue->nr_csi_im_info->interference_plus_noise_power); + ue->nr_csi_im_info->meas_computed = true; return 0; } @@ -754,7 +755,7 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t csirs_config_pdu, ue->nr_csi_rs_info, ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, - *ue->nr_csi_rs_info->noise_power, + ue->nr_csi_im_info->meas_computed ? ue->nr_csi_im_info->interference_plus_noise_power : *ue->nr_csi_rs_info->noise_power, *ue->nr_csi_rs_info->rank_indicator, ue->nr_csi_rs_info->i1, ue->nr_csi_rs_info->i2, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 1d23e48a3b..c1c94cc2cc 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -285,6 +285,7 @@ typedef struct { } nr_csi_rs_info_t; typedef struct { + bool meas_computed; uint32_t interference_plus_noise_power; } nr_csi_im_info_t; From d864cf945759a70319af8b1fd1845dc8176ffc8f Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Mon, 4 Jul 2022 11:31:33 +0100 Subject: [PATCH 45/71] Fix indentation --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 2ade30efc6..131cc059ac 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1018,7 +1018,7 @@ static int comparator(const void *p, const void *q) { void pf_ul(module_id_t module_id, frame_t frame, sub_frame_t slot, - NR_UE_info_t *UE_list[], + NR_UE_info_t *UE_list[], int max_num_ue, int n_rb_sched, uint16_t *rballoc_mask) { diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 119c6a3839..851890af19 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -217,7 +217,7 @@ void nr_csi_meas_reporting(int Mod_idP, sub_frame_t slotP); int nr_acknack_scheduling(int Mod_idP, - NR_UE_info_t * UE, + NR_UE_info_t *UE, frame_t frameP, sub_frame_t slotP, int r_pucch, From 2b36f2d8f282dbe555df47297145cfb1eaaf33e2 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Mon, 4 Jul 2022 14:18:04 +0100 Subject: [PATCH 46/71] Move nr_det_A_MF_2x2, nr_squared_matrix_element and nr_numer_2x2 to csi_rx.c --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 83 +++++++++++++++++++ .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 83 ------------------- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 18 ---- 3 files changed, 83 insertions(+), 101 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 6be4d399bf..3a585d3eac 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -43,6 +43,89 @@ //#define NR_CSIRS_DEBUG //#define NR_CSIIM_DEBUG +void nr_det_A_MF_2x2(int32_t *a_mf_00, + int32_t *a_mf_01, + int32_t *a_mf_10, + int32_t *a_mf_11, + int32_t *det_fin, + unsigned short nb_rb) { + + int16_t nr_conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; + + __m128i ad_re_128, bc_re_128, det_re_128; + + __m128i *a_mf_00_128 = (__m128i *)a_mf_00; + __m128i *a_mf_01_128 = (__m128i *)a_mf_01; + __m128i *a_mf_10_128 = (__m128i *)a_mf_10; + __m128i *a_mf_11_128 = (__m128i *)a_mf_11; + __m128i *det_fin_128 = (__m128i *)det_fin; + + for (int rb = 0; rb<3*nb_rb; rb++) { + + //complex multiplication (I_a+jQ_a)(I_d+jQ_d) = (I_aI_d - Q_aQ_d) + j(Q_aI_d + I_aQ_d) + //The imag part is often zero, we compute only the real part + ad_re_128 = _mm_sign_epi16(a_mf_00_128[0],*(__m128i*)&nr_conjug2[0]); + ad_re_128 = _mm_madd_epi16(ad_re_128,a_mf_11_128[0]); //Re: I_a0*I_d0 - Q_a1*Q_d1 + + //complex multiplication (I_b+jQ_b)(I_c+jQ_c) = (I_bI_c - Q_bQ_c) + j(Q_bI_c + I_bQ_c) + //The imag part is often zero, we compute only the real part + bc_re_128 = _mm_sign_epi16(a_mf_01_128[0],*(__m128i*)&nr_conjug2[0]); + bc_re_128 = _mm_madd_epi16(bc_re_128,a_mf_10_128[0]); //Re: I_b0*I_c0 - Q_b1*Q_c1 + + det_re_128 = _mm_sub_epi32(ad_re_128, bc_re_128); + + //det in Q30 format + det_fin_128[0] = _mm_abs_epi32(det_re_128); + + det_fin_128+=1; + a_mf_00_128+=1; + a_mf_01_128+=1; + a_mf_10_128+=1; + a_mf_11_128+=1; + } + _mm_empty(); + _m_empty(); +} + +void nr_squared_matrix_element(int32_t *a, + int32_t *a_sq, + unsigned short nb_rb) { + __m128i *a_128 = (__m128i *)a; + __m128i *a_sq_128 = (__m128i *)a_sq; + for (int rb=0; rb<3*nb_rb; rb++) { + a_sq_128[0] = _mm_madd_epi16(a_128[0], a_128[0]); + a_sq_128+=1; + a_128+=1; + } + _mm_empty(); + _m_empty(); +} + +void nr_numer_2x2(int32_t *a_00_sq, + int32_t *a_01_sq, + int32_t *a_10_sq, + int32_t *a_11_sq, + int32_t *num_fin, + unsigned short nb_rb) { + __m128i *a_00_sq_128 = (__m128i *)a_00_sq; + __m128i *a_01_sq_128 = (__m128i *)a_01_sq; + __m128i *a_10_sq_128 = (__m128i *)a_10_sq; + __m128i *a_11_sq_128 = (__m128i *)a_11_sq; + __m128i *num_fin_128 = (__m128i *)num_fin; + for (int rb=0; rb<3*nb_rb; rb++) { + __m128i sq_a_plus_sq_d_128 = _mm_add_epi32(a_00_sq_128[0], a_11_sq_128[0]); + __m128i sq_b_plus_sq_c_128 = _mm_add_epi32(a_01_sq_128[0], a_10_sq_128[0]); + num_fin_128[0] = _mm_add_epi32(sq_a_plus_sq_d_128, sq_b_plus_sq_c_128); + num_fin_128+=1; + a_00_sq_128+=1; + a_01_sq_128+=1; + a_10_sq_128+=1; + a_11_sq_128+=1; + } + _mm_empty(); + _m_empty(); +} + bool is_csi_rs_in_symbol(fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, int symbol) { bool ret = false; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 19a680c6be..eb43d80525 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -1870,89 +1870,6 @@ void nr_dlsch_detection_mrc(int **rxdataF_comp, #endif } -void nr_det_A_MF_2x2(int32_t *a_mf_00, - int32_t *a_mf_01, - int32_t *a_mf_10, - int32_t *a_mf_11, - int32_t *det_fin, - unsigned short nb_rb) { - - int16_t nr_conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; - - __m128i ad_re_128, bc_re_128, det_re_128; - - __m128i *a_mf_00_128 = (__m128i *)a_mf_00; - __m128i *a_mf_01_128 = (__m128i *)a_mf_01; - __m128i *a_mf_10_128 = (__m128i *)a_mf_10; - __m128i *a_mf_11_128 = (__m128i *)a_mf_11; - __m128i *det_fin_128 = (__m128i *)det_fin; - - for (int rb = 0; rb<3*nb_rb; rb++) { - - //complex multiplication (I_a+jQ_a)(I_d+jQ_d) = (I_aI_d - Q_aQ_d) + j(Q_aI_d + I_aQ_d) - //The imag part is often zero, we compute only the real part - ad_re_128 = _mm_sign_epi16(a_mf_00_128[0],*(__m128i*)&nr_conjug2[0]); - ad_re_128 = _mm_madd_epi16(ad_re_128,a_mf_11_128[0]); //Re: I_a0*I_d0 - Q_a1*Q_d1 - - //complex multiplication (I_b+jQ_b)(I_c+jQ_c) = (I_bI_c - Q_bQ_c) + j(Q_bI_c + I_bQ_c) - //The imag part is often zero, we compute only the real part - bc_re_128 = _mm_sign_epi16(a_mf_01_128[0],*(__m128i*)&nr_conjug2[0]); - bc_re_128 = _mm_madd_epi16(bc_re_128,a_mf_10_128[0]); //Re: I_b0*I_c0 - Q_b1*Q_c1 - - det_re_128 = _mm_sub_epi32(ad_re_128, bc_re_128); - - //det in Q30 format - det_fin_128[0] = _mm_abs_epi32(det_re_128); - - det_fin_128+=1; - a_mf_00_128+=1; - a_mf_01_128+=1; - a_mf_10_128+=1; - a_mf_11_128+=1; - } - _mm_empty(); - _m_empty(); -} - -void nr_squared_matrix_element(int32_t *a, - int32_t *a_sq, - unsigned short nb_rb) { - __m128i *a_128 = (__m128i *)a; - __m128i *a_sq_128 = (__m128i *)a_sq; - for (int rb=0; rb<3*nb_rb; rb++) { - a_sq_128[0] = _mm_madd_epi16(a_128[0], a_128[0]); - a_sq_128+=1; - a_128+=1; - } - _mm_empty(); - _m_empty(); -} - -void nr_numer_2x2(int32_t *a_00_sq, - int32_t *a_01_sq, - int32_t *a_10_sq, - int32_t *a_11_sq, - int32_t *num_fin, - unsigned short nb_rb) { - __m128i *a_00_sq_128 = (__m128i *)a_00_sq; - __m128i *a_01_sq_128 = (__m128i *)a_01_sq; - __m128i *a_10_sq_128 = (__m128i *)a_10_sq; - __m128i *a_11_sq_128 = (__m128i *)a_11_sq; - __m128i *num_fin_128 = (__m128i *)num_fin; - for (int rb=0; rb<3*nb_rb; rb++) { - __m128i sq_a_plus_sq_d_128 = _mm_add_epi32(a_00_sq_128[0], a_11_sq_128[0]); - __m128i sq_b_plus_sq_c_128 = _mm_add_epi32(a_01_sq_128[0], a_10_sq_128[0]); - num_fin_128[0] = _mm_add_epi32(sq_a_plus_sq_d_128, sq_b_plus_sq_c_128); - num_fin_128+=1; - a_00_sq_128+=1; - a_01_sq_128+=1; - a_10_sq_128+=1; - a_11_sq_128+=1; - } - _mm_empty(); - _m_empty(); -} - /* Zero Forcing Rx function: nr_a_sum_b() * Compute the complex addition x=x+y * diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 30bc0ffe92..6d99ac9b8c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -891,24 +891,6 @@ void nr_a_sum_b(__m128i *input_x, __m128i *input_y, unsigned short nb_rb); -void nr_det_A_MF_2x2(int32_t *a_mf_00, - int32_t *a_mf_01, - int32_t *a_mf_10, - int32_t *a_mf_11, - int32_t *det_fin, - unsigned short nb_rb); - -void nr_squared_matrix_element(int32_t *a, - int32_t *a_sq, - unsigned short nb_rb); - -void nr_numer_2x2(int32_t *a_00_sq, - int32_t *a_01_sq, - int32_t *a_10_sq, - int32_t *a_11_sq, - int32_t *num_fin, - unsigned short nb_rb); - uint8_t rank_estimation_tm3_tm4(int *dl_ch_estimates_00, int *dl_ch_estimates_01, int *dl_ch_estimates_10, From 0c2b3a1eebe028f24b88a09e931007b51656fb37 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 6 Jul 2022 20:18:44 +0100 Subject: [PATCH 47/71] Remove some variables from nr_csi_rs_info_t --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 8 +- openair1/PHY/INIT/nr_init_ue.c | 17 -- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 224 ++++++++++-------- openair1/PHY/defs_nr_common.h | 13 - openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 14 +- 5 files changed, 130 insertions(+), 146 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 f8ba448727..6e1a4adb65 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 @@ -48,10 +48,10 @@ typedef struct { } fapi_nr_uci_pdu_rel15_t; typedef struct { - uint8_t *rank_indicator; - uint8_t *i1; - uint8_t *i2; - uint8_t *cqi; + uint8_t rank_indicator; + uint8_t i1; + uint8_t i2; + uint8_t cqi; } fapi_nr_csirs_measurements_t; typedef struct { diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index ac2b7e21f6..cb174dc81f 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -358,12 +358,6 @@ 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->rank_indicator = (uint8_t*)malloc16_clear(sizeof(uint8_t)); - ue->nr_csi_rs_info->i1 = (uint8_t*)malloc16_clear(3*sizeof(uint8_t)); - ue->nr_csi_rs_info->i2 = (uint8_t*)malloc16_clear(sizeof(uint8_t)); - ue->nr_csi_rs_info->precoded_sinr_dB = (uint32_t*)malloc16_clear(sizeof(uint32_t)); - ue->nr_csi_rs_info->cqi = (uint8_t*)malloc16_clear(sizeof(uint8_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)); @@ -497,7 +491,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) { for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) { - free_and_zero(ue->pdcch_vars[th_id][gNB_id]); } @@ -519,17 +512,7 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) } 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->rank_indicator); - free_and_zero(ue->nr_csi_rs_info->i1); - free_and_zero(ue->nr_csi_rs_info->i2); - free_and_zero(ue->nr_csi_rs_info->precoded_sinr_dB); - free_and_zero(ue->nr_csi_rs_info->cqi); 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); free_and_zero(ue->nr_csi_im_info); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 3a585d3eac..482f2ea2a5 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -48,7 +48,7 @@ void nr_det_A_MF_2x2(int32_t *a_mf_00, int32_t *a_mf_10, int32_t *a_mf_11, int32_t *det_fin, - unsigned short nb_rb) { + const unsigned short nb_rb) { int16_t nr_conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; @@ -89,7 +89,7 @@ void nr_det_A_MF_2x2(int32_t *a_mf_00, void nr_squared_matrix_element(int32_t *a, int32_t *a_sq, - unsigned short nb_rb) { + const unsigned short nb_rb) { __m128i *a_128 = (__m128i *)a; __m128i *a_sq_128 = (__m128i *)a_sq; for (int rb=0; rb<3*nb_rb; rb++) { @@ -106,7 +106,7 @@ void nr_numer_2x2(int32_t *a_00_sq, int32_t *a_10_sq, int32_t *a_11_sq, int32_t *num_fin, - unsigned short nb_rb) { + const unsigned short nb_rb) { __m128i *a_00_sq_128 = (__m128i *)a_00_sq; __m128i *a_01_sq_128 = (__m128i *)a_01_sq; __m128i *a_10_sq_128 = (__m128i *)a_10_sq; @@ -126,7 +126,7 @@ void nr_numer_2x2(int32_t *a_00_sq, _m_empty(); } -bool is_csi_rs_in_symbol(fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, int symbol) { +bool is_csi_rs_in_symbol(const fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, const int symbol) { bool ret = false; @@ -174,14 +174,14 @@ bool is_csi_rs_in_symbol(fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, i 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, +int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, + const 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; + const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; 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)); @@ -234,7 +234,7 @@ int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, return 0; } -uint32_t calc_power_csirs(uint16_t *x, fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu) { +uint32_t calc_power_csirs(const uint16_t *x, const 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; @@ -249,17 +249,20 @@ uint32_t calc_power_csirs(uint16_t *x, fapi_nr_dl_config_csirs_pdu_rel15_t *csir 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, - nr_csi_rs_info_t *nr_csi_rs_info, - int32_t **csi_rs_generated_signal, - int32_t **csi_rs_received_signal, +int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, + const nr_csi_rs_info_t *nr_csi_rs_info, + const int32_t **csi_rs_generated_signal, + const int32_t **csi_rs_received_signal, + int32_t ***csi_rs_ls_estimated_channel, int32_t ***csi_rs_estimated_channel_freq, + int16_t *log2_re, + int16_t *log2_maxh, 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; + const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + const int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; *noise_power = 0; int maxh = 0; int count = 0; @@ -407,8 +410,8 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, } *noise_power /= (frame_parms->nb_antennas_rx*nr_csi_rs_info->N_ports); - nr_csi_rs_info->log2_maxh = log2_approx(maxh-1); - nr_csi_rs_info->log2_re = log2_approx(count-1); + *log2_maxh = log2_approx(maxh-1); + *log2_re = log2_approx(count-1); #ifdef NR_CSIRS_DEBUG LOG_I(NR_PHY, "Noise power estimation based on CSI-RS: %i\n", *noise_power); @@ -417,14 +420,15 @@ int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, return 0; } -int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, - fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, - nr_csi_rs_info_t *nr_csi_rs_info, +int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, + const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, + const nr_csi_rs_info_t *nr_csi_rs_info, int32_t ***csi_rs_estimated_channel_freq, + const int16_t log2_maxh, uint8_t *rank_indicator) { - NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int16_t cond_dB_threshold = 5; + const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + const int16_t cond_dB_threshold = 5; int count = 0; *rank_indicator = 0; @@ -441,14 +445,14 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, * | conjch01 conjch11 | | ch10 ch11 | | conjch01*ch00+conjch11*ch10 conjch01*ch01+conjch11*ch11 | */ - uint8_t sum_shift = 1; // log2(2x2) = 2, which is a shift of 1 bit - - for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { - for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { - memset(nr_csi_rs_info->csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch],0,NR_MAX_OFDM_SYMBOL_SIZE*sizeof(int32_t)); - } - } + int32_t csi_rs_estimated_conjch_ch[frame_parms->nb_antennas_rx][nr_csi_rs_info->N_ports][frame_parms->nb_antennas_rx][nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); + int32_t csi_rs_estimated_A_MF[nr_csi_rs_info->N_ports][nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); + int32_t csi_rs_estimated_A_MF_sq[nr_csi_rs_info->N_ports][nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); + int32_t csi_rs_estimated_determ_fin[frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); + int32_t csi_rs_estimated_numer_fin[frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); + const uint8_t sum_shift = 1; // log2(2x2) = 2, which is a shift of 1 bit + 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)) { @@ -464,14 +468,14 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, // conjch x ch computation nr_conjch0_mult_ch1(&csi_rs_estimated_channel_freq[ant_rx_conjch][port_tx_conjch][k], &csi_rs_estimated_channel_freq[ant_rx_ch][port_tx_ch][k], - &nr_csi_rs_info->csi_rs_estimated_conjch_ch[ant_rx_conjch][port_tx_conjch][ant_rx_ch][port_tx_ch][k], + &csi_rs_estimated_conjch_ch[ant_rx_conjch][port_tx_conjch][ant_rx_ch][port_tx_ch][k], 1, - nr_csi_rs_info->log2_maxh); + log2_maxh); // construct Hh x H elements if(ant_rx_conjch == ant_rx_ch) { - nr_a_sum_b((__m128i *)&nr_csi_rs_info->csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch][k], - (__m128i *)&nr_csi_rs_info->csi_rs_estimated_conjch_ch[ant_rx_conjch][port_tx_conjch][ant_rx_ch][port_tx_ch][k], + nr_a_sum_b((__m128i *)&csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch][k], + (__m128i *)&csi_rs_estimated_conjch_ch[ant_rx_conjch][port_tx_conjch][ant_rx_ch][port_tx_ch][k], 1); } } @@ -480,44 +484,44 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, } // compute the determinant of A_MF (denominator) - nr_det_A_MF_2x2(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], - &nr_csi_rs_info->csi_rs_estimated_determ_fin[k], + nr_det_A_MF_2x2(&csi_rs_estimated_A_MF[0][0][k], + &csi_rs_estimated_A_MF[0][1][k], + &csi_rs_estimated_A_MF[1][0][k], + &csi_rs_estimated_A_MF[1][1][k], + &csi_rs_estimated_determ_fin[k], 1); // compute the square of A_MF (numerator) - nr_squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][0][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][0][k], 1); - nr_squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[0][1][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][1][k], 1); - nr_squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[1][0][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][0][k], 1); - nr_squared_matrix_element(&nr_csi_rs_info->csi_rs_estimated_A_MF[1][1][k], &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][1][k], 1); - nr_numer_2x2(&nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[0][1][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][0][k], - &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[1][1][k], - &nr_csi_rs_info->csi_rs_estimated_numer_fin[k], + nr_squared_matrix_element(&csi_rs_estimated_A_MF[0][0][k], &csi_rs_estimated_A_MF_sq[0][0][k], 1); + nr_squared_matrix_element(&csi_rs_estimated_A_MF[0][1][k], &csi_rs_estimated_A_MF_sq[0][1][k], 1); + nr_squared_matrix_element(&csi_rs_estimated_A_MF[1][0][k], &csi_rs_estimated_A_MF_sq[1][0][k], 1); + nr_squared_matrix_element(&csi_rs_estimated_A_MF[1][1][k], &csi_rs_estimated_A_MF_sq[1][1][k], 1); + nr_numer_2x2(&csi_rs_estimated_A_MF_sq[0][0][k], + &csi_rs_estimated_A_MF_sq[0][1][k], + &csi_rs_estimated_A_MF_sq[1][0][k], + &csi_rs_estimated_A_MF_sq[1][1][k], + &csi_rs_estimated_numer_fin[k], 1); #ifdef NR_CSIRS_DEBUG for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { - int16_t *csi_rs_estimated_A_MF = (int16_t *) &nr_csi_rs_info->csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch][k]; + int16_t *csi_rs_estimated_A_MF_k = (int16_t *) &csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch][k]; LOG_I(NR_PHY, "(%i) csi_rs_estimated_A_MF[%i][%i] = (%i, %i)\n", - k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF[0], csi_rs_estimated_A_MF[1]); - int16_t *csi_rs_estimated_A_MF_sq = (int16_t *) &nr_csi_rs_info->csi_rs_estimated_A_MF_sq[port_tx_conjch][port_tx_ch][k]; + k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF_k[0], csi_rs_estimated_A_MF_k[1]); + int16_t *csi_rs_estimated_A_MF_sq_k = (int16_t *) &csi_rs_estimated_A_MF_sq[port_tx_conjch][port_tx_ch][k]; LOG_I(NR_PHY, "(%i) csi_rs_estimated_A_MF_sq[%i][%i] = (%i, %i)\n", - k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF_sq[0], csi_rs_estimated_A_MF_sq[1]); + k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF_sq_k[0], csi_rs_estimated_A_MF_sq_k[1]); } } - LOG_I(NR_PHY, "(%i) csi_rs_estimated_determ_fin = %i\n", k, nr_csi_rs_info->csi_rs_estimated_determ_fin[k]); - LOG_I(NR_PHY, "(%i) csi_rs_estimated_numer_fin = %i\n", k, nr_csi_rs_info->csi_rs_estimated_numer_fin[k]>>sum_shift); + LOG_I(NR_PHY, "(%i) csi_rs_estimated_determ_fin = %i\n", k, csi_rs_estimated_determ_fin[k]); + LOG_I(NR_PHY, "(%i) csi_rs_estimated_numer_fin = %i\n", k, csi_rs_estimated_numer_fin[k]>>sum_shift); #endif // compute the conditional number for (int sc_idx=0; sc_idx < NR_NB_SC_PER_RB; sc_idx++) { - int8_t csi_rs_estimated_denum_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_determ_fin[k + sc_idx]); - int8_t csi_rs_estimated_numer_db = dB_fixed(nr_csi_rs_info->csi_rs_estimated_numer_fin[k + sc_idx]>>sum_shift); + int8_t csi_rs_estimated_denum_db = dB_fixed(csi_rs_estimated_determ_fin[k + sc_idx]); + int8_t csi_rs_estimated_numer_db = dB_fixed(csi_rs_estimated_numer_fin[k + sc_idx]>>sum_shift); int8_t cond_db = csi_rs_estimated_numer_db - csi_rs_estimated_denum_db; #ifdef NR_CSIRS_DEBUG @@ -547,17 +551,18 @@ int nr_csi_rs_ri_estimation(PHY_VARS_NR_UE *ue, return 0; } -int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, - fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, - nr_csi_rs_info_t *nr_csi_rs_info, - int32_t ***csi_rs_estimated_channel_freq, - uint32_t interference_plus_noise_power, - uint8_t rank_indicator, +int nr_csi_rs_pmi_estimation(const PHY_VARS_NR_UE *ue, + const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, + const nr_csi_rs_info_t *nr_csi_rs_info, + const int32_t ***csi_rs_estimated_channel_freq, + const uint32_t interference_plus_noise_power, + const uint8_t rank_indicator, + const int16_t log2_re, uint8_t *i1, uint8_t *i2, uint32_t *precoded_sinr_dB) { - NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; memset(i1,0,3*sizeof(uint8_t)); i2[0] = 0; @@ -597,34 +602,34 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, // H_p0 + 1*H_p1 = (H_p0_re + H_p1_re) + 1j*(H_p0_im + H_p1_im) sum_re[0] += (csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0]); sum_im[0] += (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1]); - sum2_re[0] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0]))>>nr_csi_rs_info->log2_re; - sum2_im[0] += ((csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1]))>>nr_csi_rs_info->log2_re; + sum2_re[0] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0]))>>log2_re; + sum2_im[0] += ((csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1]))>>log2_re; // H_p0 + 1j*H_p1 = (H_p0_re - H_p1_im) + 1j*(H_p0_im + H_p1_re) sum_re[1] += (csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1]); sum_im[1] += (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0]); - sum2_re[1] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1]))>>nr_csi_rs_info->log2_re; - sum2_im[1] += ((csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0]))>>nr_csi_rs_info->log2_re; + sum2_re[1] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1]))>>log2_re; + sum2_im[1] += ((csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0]))>>log2_re; // H_p0 - 1*H_p1 = (H_p0_re - H_p1_re) + 1j*(H_p0_im - H_p1_im) sum_re[2] += (csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0]); sum_im[2] += (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1]); - sum2_re[2] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0]))>>nr_csi_rs_info->log2_re; - sum2_im[2] += ((csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1]))>>nr_csi_rs_info->log2_re; + sum2_re[2] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0]))>>log2_re; + sum2_im[2] += ((csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1]))>>log2_re; // H_p0 - 1j*H_p1 = (H_p0_re + H_p1_im) + 1j*(H_p0_im - H_p1_re) sum_re[3] += (csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1]); sum_im[3] += (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0]); - sum2_re[3] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1]))>>nr_csi_rs_info->log2_re; - sum2_im[3] += ((csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0]))>>nr_csi_rs_info->log2_re; + sum2_re[3] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1]))>>log2_re; + sum2_im[3] += ((csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0]))>>log2_re; } } // We should perform >>nr_csi_rs_info->log2_re here for all terms, but since sum2_re and sum2_im can be high values, // we performed this above. for(int p = 0; p<4; p++) { - int32_t power_re = sum2_re[p] - (sum_re[p]>>nr_csi_rs_info->log2_re)*(sum_re[p]>>nr_csi_rs_info->log2_re); - int32_t power_im = sum2_im[p] - (sum_im[p]>>nr_csi_rs_info->log2_re)*(sum_im[p]>>nr_csi_rs_info->log2_re); + int32_t power_re = sum2_re[p] - (sum_re[p]>>log2_re)*(sum_re[p]>>log2_re); + int32_t power_im = sum2_im[p] - (sum_im[p]>>log2_re)*(sum_im[p]>>log2_re); tested_precoded_sinr[p] = (power_re+power_im)/(int32_t)interference_plus_noise_power; } @@ -648,7 +653,7 @@ int nr_csi_rs_pmi_estimation(PHY_VARS_NR_UE *ue, return 0; } -int nr_csi_rs_cqi_estimation(uint32_t precoded_sinr, +int nr_csi_rs_cqi_estimation(const uint32_t precoded_sinr, uint8_t *cqi) { *cqi = 0; @@ -683,16 +688,16 @@ int nr_csi_rs_cqi_estimation(uint32_t precoded_sinr, return 0; } -int nr_csi_im_power_estimation(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu, +int nr_csi_im_power_estimation(const PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + const fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu, uint32_t *interference_plus_noise_power) { 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; + const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - uint16_t end_rb = csiim_config_pdu->start_rb + csiim_config_pdu->nr_of_rbs > csiim_config_pdu->bwp_size ? - csiim_config_pdu->bwp_size : csiim_config_pdu->start_rb + csiim_config_pdu->nr_of_rbs; + const uint16_t end_rb = csiim_config_pdu->start_rb + csiim_config_pdu->nr_of_rbs > csiim_config_pdu->bwp_size ? + csiim_config_pdu->bwp_size : csiim_config_pdu->start_rb + csiim_config_pdu->nr_of_rbs; int32_t count = 0; int32_t sum_re = 0; @@ -763,7 +768,7 @@ int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t return -1; } - fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu = (fapi_nr_dl_config_csiim_pdu_rel15_t*)&ue->csiim_vars[gNB_id]->csiim_config_pdu; + const fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu = (fapi_nr_dl_config_csiim_pdu_rel15_t*)&ue->csiim_vars[gNB_id]->csiim_config_pdu; #ifdef NR_CSIIM_DEBUG LOG_I(NR_PHY, "csiim_config_pdu->bwp_size = %i\n", csiim_config_pdu->bwp_size); @@ -787,7 +792,7 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t 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; + const 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->subcarrier_spacing = %i\n", csirs_config_pdu->subcarrier_spacing); @@ -806,6 +811,15 @@ 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 + int16_t log2_re = 0; + int16_t log2_maxh = 0; + uint32_t noise_power = 0; + uint8_t rank_indicator = 0; + uint32_t precoded_sinr_dB = 0; + uint8_t cqi = 0; + uint8_t i1[3]; + uint8_t i2[1]; + nr_generate_csi_rs(ue->frame_parms, ue->nr_csi_rs_info->csi_rs_generated_signal, AMP, @@ -823,43 +837,43 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t 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, + (const int32_t **) ue->nr_csi_rs_info->csi_rs_generated_signal, + (const int32_t **) ue->nr_csi_rs_info->csi_rs_received_signal, + ue->nr_csi_rs_info->csi_rs_ls_estimated_channel, ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, - ue->nr_csi_rs_info->noise_power); + &log2_re, + &log2_maxh, + &noise_power); nr_csi_rs_ri_estimation(ue, csirs_config_pdu, ue->nr_csi_rs_info, ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, - ue->nr_csi_rs_info->rank_indicator); + log2_maxh, + &rank_indicator); nr_csi_rs_pmi_estimation(ue, csirs_config_pdu, ue->nr_csi_rs_info, - ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, - ue->nr_csi_im_info->meas_computed ? ue->nr_csi_im_info->interference_plus_noise_power : *ue->nr_csi_rs_info->noise_power, - *ue->nr_csi_rs_info->rank_indicator, - ue->nr_csi_rs_info->i1, - ue->nr_csi_rs_info->i2, - ue->nr_csi_rs_info->precoded_sinr_dB); + (const int32_t ***) ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + ue->nr_csi_im_info->meas_computed ? ue->nr_csi_im_info->interference_plus_noise_power : noise_power, + rank_indicator, + log2_re, + i1, + i2, + &precoded_sinr_dB); - nr_csi_rs_cqi_estimation(*ue->nr_csi_rs_info->precoded_sinr_dB, - ue->nr_csi_rs_info->cqi); + nr_csi_rs_cqi_estimation(precoded_sinr_dB, &cqi); LOG_I(NR_PHY, "RI = %i, i1 = %i.%i.%i, i2 = %i, SINR = %i dB, CQI = %i\n", - *ue->nr_csi_rs_info->rank_indicator + 1, - ue->nr_csi_rs_info->i1[0], ue->nr_csi_rs_info->i1[1], ue->nr_csi_rs_info->i1[2], - ue->nr_csi_rs_info->i2[0], - *ue->nr_csi_rs_info->precoded_sinr_dB, - *ue->nr_csi_rs_info->cqi); + rank_indicator+1, i1[0], i1[1], i1[2], i2[0], precoded_sinr_dB, cqi); // Send CSI measurements to MAC fapi_nr_csirs_measurements_t csirs_measurements; - csirs_measurements.rank_indicator = ue->nr_csi_rs_info->rank_indicator; - csirs_measurements.i1 = ue->nr_csi_rs_info->i1; - csirs_measurements.i2 = ue->nr_csi_rs_info->i2; - csirs_measurements.cqi = ue->nr_csi_rs_info->cqi; + csirs_measurements.rank_indicator = rank_indicator; + csirs_measurements.i1 = *i1; + csirs_measurements.i2 = *i2; + csirs_measurements.cqi = cqi; nr_downlink_indication_t *dl_indication = calloc(sizeof(*dl_indication),1); fapi_nr_rx_indication_t *rx_ind = calloc(sizeof(*rx_ind),1); nr_fill_dl_indication(dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 1b7dffb04e..34f089d9f9 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -269,19 +269,6 @@ typedef struct { int32_t **csi_rs_received_signal; int32_t ***csi_rs_ls_estimated_channel; int32_t ***csi_rs_estimated_channel_freq; - int16_t log2_re; - int16_t log2_maxh; - int32_t csi_rs_estimated_conjch_ch[4][4][4][4][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); - int32_t csi_rs_estimated_A_MF[2][2][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); - int32_t csi_rs_estimated_A_MF_sq[2][2][NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); - int32_t csi_rs_estimated_determ_fin[NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); - int32_t csi_rs_estimated_numer_fin[NR_MAX_OFDM_SYMBOL_SIZE] __attribute__((aligned(32))); - uint32_t *noise_power; - uint8_t *rank_indicator; - uint8_t *i1; - uint8_t *i2; - uint32_t *precoded_sinr_dB; - uint8_t *cqi; } nr_csi_rs_info_t; typedef struct { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index a41b9db0cb..67331c1865 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2688,16 +2688,16 @@ uint8_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, int cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; int ri_bitlen = csi_report->csi_meas_bitlen.ri_bitlen; - int pmi_x1_bitlen = csi_report->csi_meas_bitlen.pmi_x1_bitlen[*mac->csirs_measurements.rank_indicator]; - int pmi_x2_bitlen = csi_report->csi_meas_bitlen.pmi_x2_bitlen[*mac->csirs_measurements.rank_indicator]; - int cqi_bitlen = csi_report->csi_meas_bitlen.cqi_bitlen[*mac->csirs_measurements.rank_indicator]; + int pmi_x1_bitlen = csi_report->csi_meas_bitlen.pmi_x1_bitlen[mac->csirs_measurements.rank_indicator]; + int pmi_x2_bitlen = csi_report->csi_meas_bitlen.pmi_x2_bitlen[mac->csirs_measurements.rank_indicator]; + int cqi_bitlen = csi_report->csi_meas_bitlen.cqi_bitlen[mac->csirs_measurements.rank_indicator]; int padding_bitlen = n_bits - (cri_bitlen + ri_bitlen + pmi_x1_bitlen + pmi_x2_bitlen + cqi_bitlen); // TODO: Improvements will be needed to cri_bitlen>0 and pmi_x1_bitlen>0 - temp_payload = (*mac->csirs_measurements.rank_indicator<<(cri_bitlen+cqi_bitlen+pmi_x2_bitlen+padding_bitlen+pmi_x1_bitlen)) | - (*mac->csirs_measurements.i1<<(cri_bitlen+cqi_bitlen+pmi_x2_bitlen)) | - (*mac->csirs_measurements.i2<<(cri_bitlen+cqi_bitlen)) | - (*mac->csirs_measurements.cqi<csirs_measurements.rank_indicator<<(cri_bitlen+cqi_bitlen+pmi_x2_bitlen+padding_bitlen+pmi_x1_bitlen)) | + (mac->csirs_measurements.i1<<(cri_bitlen+cqi_bitlen+pmi_x2_bitlen)) | + (mac->csirs_measurements.i2<<(cri_bitlen+cqi_bitlen)) | + (mac->csirs_measurements.cqi< Date: Wed, 6 Jul 2022 21:08:08 +0100 Subject: [PATCH 48/71] To use cast for c16_t --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 116 +++++++++++++------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 482f2ea2a5..cc1ead7dc9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -205,24 +205,24 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, 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]; + c16_t *rx_signal = (c16_t*)&rxdataF[ant_rx][symbol_offset]; + c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; + rx_csi_rs_signal[k].r = rx_signal[k].r; + rx_csi_rs_signal[k].i = rx_signal[k].i; #ifdef NR_CSIRS_DEBUG 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]; + c16_t *tx_csi_rs_signal = (c16_t*)&nr_csi_rs_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; LOG_I(NR_PHY, "l,k (%2d,%4d) |\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], + tx_csi_rs_signal[k].r, + tx_csi_rs_signal[k].i, ant_rx, - rx_csi_rs_signal[k<<1], - rx_csi_rs_signal[(k<<1)+1]); + rx_csi_rs_signal[k].r, + rx_csi_rs_signal[k].i); #endif } } @@ -272,7 +272,7 @@ int nr_csi_rs_channel_estimation(const 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->ofdm_symbol_size*sizeof(int32_t)); + memset(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++) { @@ -297,17 +297,17 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, 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*)&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]; + c16_t *tx_csi_rs_signal = (c16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; + c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; - 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); + int16_t csi_rs_ls_estimated_channel_re = (int16_t)(((int32_t)tx_csi_rs_signal[k].r*rx_csi_rs_signal[k].r + (int32_t)tx_csi_rs_signal[k].i*rx_csi_rs_signal[k].i)>>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].r*rx_csi_rs_signal[k].i - (int32_t)tx_csi_rs_signal[k].i*rx_csi_rs_signal[k].r)>>nr_csi_rs_info->csi_rs_generated_signal_bits); // 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. - 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; + csi_rs_ls_estimated_channel16[kinit].r += csi_rs_ls_estimated_channel_re; + csi_rs_ls_estimated_channel16[kinit].i += csi_rs_ls_estimated_channel_im; } } } @@ -323,14 +323,14 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, 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]; + c16_t *tx_csi_rs_signal = (c16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; + c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&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]); + tx_csi_rs_signal[k].r, tx_csi_rs_signal[k].i, + rx_csi_rs_signal[k].r, rx_csi_rs_signal[k].i, + csi_rs_ls_estimated_channel16[k].r, csi_rs_ls_estimated_channel16[k].i); } printf("\n"); } @@ -354,15 +354,15 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, 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_ls_estimated_channel16 = (int16_t*)&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, csi_rs_ls_estimated_channel, csi_rs_estimated_channel16, 24); + multadd_real_vector_complex_scalar(filt24_start, csi_rs_ls_estimated_channel16, 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, csi_rs_ls_estimated_channel, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + multadd_real_vector_complex_scalar(filt24_end, csi_rs_ls_estimated_channel16, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); } else { // Middle case - multadd_real_vector_complex_scalar(filt24_middle, csi_rs_ls_estimated_channel, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + multadd_real_vector_complex_scalar(filt24_middle, csi_rs_ls_estimated_channel16, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); } } } @@ -376,11 +376,11 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, } 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]); - maxh = cmax3(maxh, abs(csi_rs_estimated_channel16[0]), abs(csi_rs_estimated_channel16[1])); + c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][k]; + c16_t *csi_rs_estimated_channel16 = (c16_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_channel16->r-csi_rs_estimated_channel16->r); + noise_imag[ant_rx][port_tx][rb-csirs_config_pdu->start_rb] = abs(csi_rs_ls_estimated_channel16->i-csi_rs_estimated_channel16->i); + maxh = cmax3(maxh, abs(csi_rs_estimated_channel16->r), abs(csi_rs_estimated_channel16->i)); } } for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { @@ -394,12 +394,12 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, (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++) { - 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]; + c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; + c16_t *csi_rs_estimated_channel16 = (c16_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) | ", 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], + csi_rs_ls_estimated_channel16[k].r, csi_rs_ls_estimated_channel16[k].i, + csi_rs_estimated_channel16[k].r, csi_rs_estimated_channel16[k].i, 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]); } @@ -506,12 +506,12 @@ int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, #ifdef NR_CSIRS_DEBUG for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { - int16_t *csi_rs_estimated_A_MF_k = (int16_t *) &csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch][k]; + c16_t *csi_rs_estimated_A_MF_k = (c16_t *) &csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch][k]; LOG_I(NR_PHY, "(%i) csi_rs_estimated_A_MF[%i][%i] = (%i, %i)\n", - k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF_k[0], csi_rs_estimated_A_MF_k[1]); - int16_t *csi_rs_estimated_A_MF_sq_k = (int16_t *) &csi_rs_estimated_A_MF_sq[port_tx_conjch][port_tx_ch][k]; + k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF_k->r, csi_rs_estimated_A_MF_k->i); + c16_t *csi_rs_estimated_A_MF_sq_k = (c16_t *) &csi_rs_estimated_A_MF_sq[port_tx_conjch][port_tx_ch][k]; LOG_I(NR_PHY, "(%i) csi_rs_estimated_A_MF_sq[%i][%i] = (%i, %i)\n", - k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF_sq_k[0], csi_rs_estimated_A_MF_sq_k[1]); + k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF_sq_k->r, csi_rs_estimated_A_MF_sq_k->i); } } LOG_I(NR_PHY, "(%i) csi_rs_estimated_determ_fin = %i\n", k, csi_rs_estimated_determ_fin[k]); @@ -596,32 +596,32 @@ int nr_csi_rs_pmi_estimation(const PHY_VARS_NR_UE *ue, for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { - int16_t *csi_rs_estimated_channel_p0 = (int16_t *) &csi_rs_estimated_channel_freq[ant_rx][0][k]; - int16_t *csi_rs_estimated_channel_p1 = (int16_t *) &csi_rs_estimated_channel_freq[ant_rx][1][k]; + c16_t *csi_rs_estimated_channel_p0 = (c16_t *) &csi_rs_estimated_channel_freq[ant_rx][0][k]; + c16_t *csi_rs_estimated_channel_p1 = (c16_t *) &csi_rs_estimated_channel_freq[ant_rx][1][k]; // H_p0 + 1*H_p1 = (H_p0_re + H_p1_re) + 1j*(H_p0_im + H_p1_im) - sum_re[0] += (csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0]); - sum_im[0] += (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1]); - sum2_re[0] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[0]))>>log2_re; - sum2_im[0] += ((csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[1]))>>log2_re; + sum_re[0] += (csi_rs_estimated_channel_p0->r+csi_rs_estimated_channel_p1->r); + sum_im[0] += (csi_rs_estimated_channel_p0->i+csi_rs_estimated_channel_p1->i); + sum2_re[0] += ((csi_rs_estimated_channel_p0->r+csi_rs_estimated_channel_p1->r)*(csi_rs_estimated_channel_p0->r+csi_rs_estimated_channel_p1->r))>>log2_re; + sum2_im[0] += ((csi_rs_estimated_channel_p0->i+csi_rs_estimated_channel_p1->i)*(csi_rs_estimated_channel_p0->i+csi_rs_estimated_channel_p1->i))>>log2_re; // H_p0 + 1j*H_p1 = (H_p0_re - H_p1_im) + 1j*(H_p0_im + H_p1_re) - sum_re[1] += (csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1]); - sum_im[1] += (csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0]); - sum2_re[1] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[1]))>>log2_re; - sum2_im[1] += ((csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]+csi_rs_estimated_channel_p1[0]))>>log2_re; + sum_re[1] += (csi_rs_estimated_channel_p0->r-csi_rs_estimated_channel_p1->i); + sum_im[1] += (csi_rs_estimated_channel_p0->i+csi_rs_estimated_channel_p1->r); + sum2_re[1] += ((csi_rs_estimated_channel_p0->r-csi_rs_estimated_channel_p1->i)*(csi_rs_estimated_channel_p0->r-csi_rs_estimated_channel_p1->i))>>log2_re; + sum2_im[1] += ((csi_rs_estimated_channel_p0->i+csi_rs_estimated_channel_p1->r)*(csi_rs_estimated_channel_p0->i+csi_rs_estimated_channel_p1->r))>>log2_re; // H_p0 - 1*H_p1 = (H_p0_re - H_p1_re) + 1j*(H_p0_im - H_p1_im) - sum_re[2] += (csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0]); - sum_im[2] += (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1]); - sum2_re[2] += ((csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[0]-csi_rs_estimated_channel_p1[0]))>>log2_re; - sum2_im[2] += ((csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[1]))>>log2_re; + sum_re[2] += (csi_rs_estimated_channel_p0->r-csi_rs_estimated_channel_p1->r); + sum_im[2] += (csi_rs_estimated_channel_p0->i-csi_rs_estimated_channel_p1->i); + sum2_re[2] += ((csi_rs_estimated_channel_p0->r-csi_rs_estimated_channel_p1->r)*(csi_rs_estimated_channel_p0->r-csi_rs_estimated_channel_p1->r))>>log2_re; + sum2_im[2] += ((csi_rs_estimated_channel_p0->i-csi_rs_estimated_channel_p1->i)*(csi_rs_estimated_channel_p0->i-csi_rs_estimated_channel_p1->i))>>log2_re; // H_p0 - 1j*H_p1 = (H_p0_re + H_p1_im) + 1j*(H_p0_im - H_p1_re) - sum_re[3] += (csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1]); - sum_im[3] += (csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0]); - sum2_re[3] += ((csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1])*(csi_rs_estimated_channel_p0[0]+csi_rs_estimated_channel_p1[1]))>>log2_re; - sum2_im[3] += ((csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0])*(csi_rs_estimated_channel_p0[1]-csi_rs_estimated_channel_p1[0]))>>log2_re; + sum_re[3] += (csi_rs_estimated_channel_p0->r+csi_rs_estimated_channel_p1->i); + sum_im[3] += (csi_rs_estimated_channel_p0->i-csi_rs_estimated_channel_p1->r); + sum2_re[3] += ((csi_rs_estimated_channel_p0->r+csi_rs_estimated_channel_p1->i)*(csi_rs_estimated_channel_p0->r+csi_rs_estimated_channel_p1->i))>>log2_re; + sum2_im[3] += ((csi_rs_estimated_channel_p0->i-csi_rs_estimated_channel_p1->r)*(csi_rs_estimated_channel_p0->i-csi_rs_estimated_channel_p1->r))>>log2_re; } } From acd4e39566de51fb1e3daa9d3f253ab31fa03d17 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Thu, 7 Jul 2022 11:48:37 +0100 Subject: [PATCH 49/71] Remove csi_rs_received_signal from nr_csi_rs_info_t --- openair1/PHY/INIT/nr_init_ue.c | 3 -- openair1/PHY/NR_REFSIG/nr_refsig.h | 2 +- openair1/PHY/NR_REFSIG/refsig_defs_ue.h | 2 +- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 28 +++++++++---------- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 2 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 14 ++++++---- openair1/PHY/defs_nr_common.h | 1 - openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 8 files changed, 26 insertions(+), 28 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index cb174dc81f..09bc80c4ed 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -362,11 +362,9 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) 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_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 *)); for (j=0; jnr_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]); free_and_zero(ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i][j]); diff --git a/openair1/PHY/NR_REFSIG/nr_refsig.h b/openair1/PHY/NR_REFSIG/nr_refsig.h index d4d91d7060..110ff321bd 100644 --- a/openair1/PHY/NR_REFSIG/nr_refsig.h +++ b/openair1/PHY/NR_REFSIG/nr_refsig.h @@ -38,7 +38,7 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB); */ void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid); void nr_init_pdsch_dmrs(PHY_VARS_gNB* gNB, uint8_t nscid, uint32_t Nid); -void nr_init_csi_rs(NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Nid); +void nr_init_csi_rs(const NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Nid); void nr_gold_pusch(PHY_VARS_gNB* gNB, int nscid, uint32_t nid); diff --git a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h index eb5c573368..a6e57fb298 100644 --- a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h +++ b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h @@ -68,6 +68,6 @@ void nr_init_pusch_dmrs(PHY_VARS_NR_UE* ue, uint16_t N_n_scid, uint8_t n_scid); -void nr_init_csi_rs(NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Nid); +void nr_init_csi_rs(const NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Nid); #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index ab8d915d6e..86917473b7 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -27,7 +27,7 @@ //#define NR_CSIRS_DEBUG -void nr_init_csi_rs(NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Nid) { +void nr_init_csi_rs(const NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Nid) { uint32_t x1, x2; uint8_t reset; int csi_dmrs_init_length = ((fp->N_RB_DL<<4)>>5)+1; @@ -43,7 +43,7 @@ void nr_init_csi_rs(NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Nid) { } } -void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, +void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, int32_t **dataF, int16_t amp, nr_csi_rs_info_t *nr_csi_rs_info, @@ -67,11 +67,11 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, 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; + 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]; //*8(max allocation per RB)*2(QPSK)) - int csi_rs_length = frame_parms.N_RB_DL<<4; - int16_t mod_csi[frame_parms.symbols_per_slot][csi_rs_length>>1] __attribute__((aligned(16))); + int csi_rs_length = frame_parms->N_RB_DL<<4; + int16_t mod_csi[frame_parms->symbols_per_slot][csi_rs_length>>1] __attribute__((aligned(16))); uint16_t b = csi_params->freq_domain; uint16_t n, p, k, l, mprime, na, kpn; uint8_t size, ports, kprime, lprime, i, gs; @@ -88,7 +88,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, // if the scrambling id is not the one previously used to initialize we need to re-initialize the rs 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); + nr_init_csi_rs(frame_parms, nr_csi_rs_info->nr_gold_csi_rs, csi_params->scramb_id); } switch (csi_params->row) { @@ -584,7 +584,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, } } - uint16_t start_sc = frame_parms.first_carrier_offset; + uint16_t start_sc = frame_parms->first_carrier_offset; // resource mapping according to 38.211 7.4.1.5.3 for (n=csi_params->start_rb; n<(csi_params->start_rb+csi_params->nr_of_rbs); n++) { @@ -593,7 +593,7 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, for (int s=0 ; sofdm_symbol_size); // frequency index of current resource element // wf according to tables 7.4.5.3-2 to 7.4.5.3-5 if (kp == 0) wf = 1; @@ -620,17 +620,17 @@ void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, // 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; - ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_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*)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; + ((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*)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)]); + ((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 e3b7efacfb..ce201b3302 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -337,7 +337,7 @@ 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(NR_DL_FRAME_PARMS frame_parms, +void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, int32_t **dataF, int16_t amp, nr_csi_rs_info_t *nr_csi_rs_info, diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index cc1ead7dc9..29958d7e77 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -178,13 +178,12 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, const nr_csi_rs_info_t *nr_csi_rs_info, - int32_t **csi_rs_received_signal) { + int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP]) { int32_t **rxdataF = ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; 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++) { @@ -254,7 +253,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, const nr_csi_rs_info_t *nr_csi_rs_info, const int32_t **csi_rs_generated_signal, - const int32_t **csi_rs_received_signal, + const int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP], int32_t ***csi_rs_ls_estimated_channel, int32_t ***csi_rs_estimated_channel_freq, int16_t *log2_re, @@ -811,6 +810,9 @@ 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 + const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + int32_t csi_rs_received_signal[frame_parms->nb_antennas_rx][frame_parms->samples_per_slot_wCP]; + int16_t log2_re = 0; int16_t log2_maxh = 0; uint32_t noise_power = 0; @@ -820,7 +822,7 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t uint8_t i1[3]; uint8_t i2[1]; - nr_generate_csi_rs(ue->frame_parms, + nr_generate_csi_rs(frame_parms, ue->nr_csi_rs_info->csi_rs_generated_signal, AMP, ue->nr_csi_rs_info, @@ -831,14 +833,14 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t proc, csirs_config_pdu, ue->nr_csi_rs_info, - ue->nr_csi_rs_info->csi_rs_received_signal); + csi_rs_received_signal); nr_csi_rs_channel_estimation(ue, proc, csirs_config_pdu, ue->nr_csi_rs_info, (const int32_t **) ue->nr_csi_rs_info->csi_rs_generated_signal, - (const int32_t **) ue->nr_csi_rs_info->csi_rs_received_signal, + csi_rs_received_signal, ue->nr_csi_rs_info->csi_rs_ls_estimated_channel, ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, &log2_re, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 34f089d9f9..9556c9cba2 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -266,7 +266,6 @@ typedef struct { uint32_t ***nr_gold_csi_rs; 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; } nr_csi_rs_info_t; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 1428987d40..9bd82fd4f9 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -168,7 +168,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, slot); + nr_generate_csi_rs(&gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info, csi_params, slot); csirs->active = 0; } } From e39be3917bfa62be6aa12b66a434c64cb12ce104 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Thu, 7 Jul 2022 14:33:40 +0100 Subject: [PATCH 50/71] Remove csi_rs_ls_estimated_channel and csi_rs_estimated_channel_freq from nr_csi_rs_info_t --- openair1/PHY/INIT/nr_init_ue.c | 20 +------------------- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 20 +++++++++++--------- openair1/PHY/defs_nr_common.h | 2 -- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 09bc80c4ed..acd945497f 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -159,7 +159,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, slot, symb, gNB_id, th_id; + int i, slot, symb, gNB_id, th_id; LOG_I(PHY, "Initializing UE vars for gNB TXant %u, UE RXant %u\n", fp->nb_antennas_tx, fp->nb_antennas_rx); @@ -362,16 +362,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) 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_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_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->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)); - } - } ue->nr_csi_im_info = (nr_csi_im_info_t *)malloc16_clear(sizeof(nr_csi_im_info_t)); @@ -495,14 +485,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) for (int i=0; inr_csi_rs_info->csi_rs_generated_signal[i]); } - for (int i = 0; i < fp->nb_antennas_rx; 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]); - } 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]); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 29958d7e77..09f21a96b9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -254,8 +254,8 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, const nr_csi_rs_info_t *nr_csi_rs_info, const int32_t **csi_rs_generated_signal, const int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP], - int32_t ***csi_rs_ls_estimated_channel, - int32_t ***csi_rs_estimated_channel_freq, + int32_t csi_rs_ls_estimated_channel[][ue->nr_csi_rs_info->N_ports][ue->frame_parms.ofdm_symbol_size], + int32_t csi_rs_estimated_channel_freq[][ue->nr_csi_rs_info->N_ports][ue->frame_parms.ofdm_symbol_size], int16_t *log2_re, int16_t *log2_maxh, uint32_t *noise_power) { @@ -422,7 +422,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, const nr_csi_rs_info_t *nr_csi_rs_info, - int32_t ***csi_rs_estimated_channel_freq, + int32_t csi_rs_estimated_channel_freq[][ue->nr_csi_rs_info->N_ports][ue->frame_parms.ofdm_symbol_size], const int16_t log2_maxh, uint8_t *rank_indicator) { @@ -553,7 +553,7 @@ int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, int nr_csi_rs_pmi_estimation(const PHY_VARS_NR_UE *ue, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, const nr_csi_rs_info_t *nr_csi_rs_info, - const int32_t ***csi_rs_estimated_channel_freq, + const int32_t csi_rs_estimated_channel_freq[][ue->nr_csi_rs_info->N_ports][ue->frame_parms.ofdm_symbol_size], const uint32_t interference_plus_noise_power, const uint8_t rank_indicator, const int16_t log2_re, @@ -812,7 +812,6 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int32_t csi_rs_received_signal[frame_parms->nb_antennas_rx][frame_parms->samples_per_slot_wCP]; - int16_t log2_re = 0; int16_t log2_maxh = 0; uint32_t noise_power = 0; @@ -829,6 +828,9 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *) csirs_config_pdu, proc->nr_slot_rx); + int32_t csi_rs_ls_estimated_channel[frame_parms->nb_antennas_rx][ue->nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size]; + int32_t csi_rs_estimated_channel_freq[frame_parms->nb_antennas_rx][ue->nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size]; + nr_get_csi_rs_signal(ue, proc, csirs_config_pdu, @@ -841,8 +843,8 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->nr_csi_rs_info, (const int32_t **) ue->nr_csi_rs_info->csi_rs_generated_signal, csi_rs_received_signal, - ue->nr_csi_rs_info->csi_rs_ls_estimated_channel, - ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + csi_rs_ls_estimated_channel, + csi_rs_estimated_channel_freq, &log2_re, &log2_maxh, &noise_power); @@ -850,14 +852,14 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t nr_csi_rs_ri_estimation(ue, csirs_config_pdu, ue->nr_csi_rs_info, - ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + csi_rs_estimated_channel_freq, log2_maxh, &rank_indicator); nr_csi_rs_pmi_estimation(ue, csirs_config_pdu, ue->nr_csi_rs_info, - (const int32_t ***) ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + csi_rs_estimated_channel_freq, ue->nr_csi_im_info->meas_computed ? ue->nr_csi_im_info->interference_plus_noise_power : noise_power, rank_indicator, log2_re, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 9556c9cba2..3cc2a1245a 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -266,8 +266,6 @@ typedef struct { uint32_t ***nr_gold_csi_rs; uint8_t csi_rs_generated_signal_bits; int32_t **csi_rs_generated_signal; - int32_t ***csi_rs_ls_estimated_channel; - int32_t ***csi_rs_estimated_channel_freq; } nr_csi_rs_info_t; typedef struct { From 36a9139a660401a8e2f30548d241c88e099b1867 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Thu, 7 Jul 2022 15:51:02 +0100 Subject: [PATCH 51/71] Remove N_cdm_groups, CDM_group_size, kprime and lprime from nr_csi_rs_info_t --- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 37 +++--- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 11 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 108 ++++++++++++------ openair1/PHY/defs_nr_common.h | 5 - openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 5 files changed, 101 insertions(+), 62 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index 86917473b7..74630ece74 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -45,10 +45,15 @@ void nr_init_csi_rs(const NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Ni void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, int32_t **dataF, - int16_t amp, + const int16_t amp, nr_csi_rs_info_t *nr_csi_rs_info, - nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, - int slot){ + const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, + const int slot, + uint8_t *N_cdm_groups, + uint8_t *CDM_group_size, + uint8_t *k_prime, + uint8_t *l_prime, + uint8_t *N_ports) { #ifdef NR_CSIRS_DEBUG LOG_I(NR_PHY, "csi_params->subcarrier_spacing = %i\n", csi_params->subcarrier_spacing); @@ -638,23 +643,25 @@ void nr_generate_csi_rs(const 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; - nr_csi_rs_info->N_ports = ports; + if (N_cdm_groups) *N_cdm_groups = size; + if (CDM_group_size) *CDM_group_size = gs; + if (k_prime) *k_prime = kprime; + if (l_prime) *l_prime = lprime; + if (N_ports) *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)); #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]); + if (N_ports) LOG_I(NR_PHY, "nr_csi_rs_info->N_ports = %d\n", *N_ports); + if (N_cdm_groups) LOG_I(NR_PHY, "nr_csi_rs_info->N_cdm_groups = %d\n", *N_cdm_groups); + if (CDM_group_size) LOG_I(NR_PHY, "nr_csi_rs_info->CDM_group_size = %d\n", *CDM_group_size); + if (k_prime) LOG_I(NR_PHY, "nr_csi_rs_info->kprime = %d\n", *k_prime); + if (l_prime) LOG_I(NR_PHY, "nr_csi_rs_info->lprime = %d\n", *l_prime); + if (N_cdm_groups) { + for(int ji=0; ji<*N_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_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index ce201b3302..76a4931c96 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -339,10 +339,15 @@ uint8_t get_nr_prach_duration(uint8_t prach_format); void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, int32_t **dataF, - int16_t amp, + const int16_t amp, nr_csi_rs_info_t *nr_csi_rs_info, - nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, - int slot); + const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, + const int slot, + uint8_t *N_cdm_groups, + uint8_t *CDM_group_size, + uint8_t *k_prime, + uint8_t *l_prime, + uint8_t *N_ports); 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 09f21a96b9..aacdfb7f22 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -178,6 +178,10 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, const nr_csi_rs_info_t *nr_csi_rs_info, + const uint8_t N_cdm_groups, + const uint8_t CDM_group_size, + const uint8_t k_prime, + const uint8_t l_prime, int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP]) { int32_t **rxdataF = ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; @@ -192,16 +196,16 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, continue; } - 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++) { + for (int cdm_id = 0; cdm_id < N_cdm_groups; cdm_id++) { + for (int s = 0; s < CDM_group_size; s++) { // loop over frequency resource elements within a group - for (int kp = 0; kp <= nr_csi_rs_info->kprime; kp++) { + for (int kp = 0; kp <= k_prime; 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++) { + for (int lp = 0; lp <= l_prime; lp++) { uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; c16_t *rx_signal = (c16_t*)&rxdataF[ant_rx][symbol_offset]; @@ -211,7 +215,7 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, #ifdef NR_CSIRS_DEBUG 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; + uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*CDM_group_size; c16_t *tx_csi_rs_signal = (c16_t*)&nr_csi_rs_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; LOG_I(NR_PHY, "l,k (%2d,%4d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\n", symb, @@ -254,8 +258,13 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, const nr_csi_rs_info_t *nr_csi_rs_info, const int32_t **csi_rs_generated_signal, const int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP], - int32_t csi_rs_ls_estimated_channel[][ue->nr_csi_rs_info->N_ports][ue->frame_parms.ofdm_symbol_size], - int32_t csi_rs_estimated_channel_freq[][ue->nr_csi_rs_info->N_ports][ue->frame_parms.ofdm_symbol_size], + const uint8_t N_cdm_groups, + const uint8_t CDM_group_size, + const uint8_t k_prime, + const uint8_t l_prime, + const uint8_t N_ports, + int32_t csi_rs_ls_estimated_channel[][N_ports][ue->frame_parms.ofdm_symbol_size], + int32_t csi_rs_estimated_channel_freq[][N_ports][ue->frame_parms.ofdm_symbol_size], int16_t *log2_re, int16_t *log2_maxh, uint32_t *noise_power) { @@ -270,7 +279,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, /// LS channel estimation - for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + for(uint16_t port_tx = 0; port_txofdm_symbol_size*sizeof(int32_t)); } @@ -281,19 +290,19 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, continue; } - 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++) { + for (int cdm_id = 0; cdm_id < N_cdm_groups; cdm_id++) { + for (int s = 0; s < CDM_group_size; s++) { - uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; + uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*CDM_group_size; // loop over frequency resource elements within a group - for (int kp = 0; kp <= nr_csi_rs_info->kprime; kp++) { + for (int kp = 0; kp <= k_prime; kp++) { 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++) { + for (int lp = 0; lp <= l_prime; lp++) { uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; c16_t *tx_csi_rs_signal = (c16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; @@ -320,7 +329,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, } 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++) { + for(uint16_t port_tx = 0; port_txofdm_symbol_size; c16_t *tx_csi_rs_signal = (c16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; @@ -338,7 +347,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, /// Channel interpolation - for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + for(uint16_t port_tx = 0; port_txofdm_symbol_size*sizeof(int32_t)); } @@ -352,7 +361,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, count++; 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++) { + for(uint16_t port_tx = 0; port_txfirst_carrier_offset) ) { // Start of OFDM symbol case or first occupied subcarrier case @@ -367,14 +376,14 @@ int nr_csi_rs_channel_estimation(const 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]; + uint16_t noise_real[frame_parms->nb_antennas_rx][N_ports][csirs_config_pdu->nr_of_rbs]; + uint16_t noise_imag[frame_parms->nb_antennas_rx][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++) { + for(uint16_t port_tx = 0; port_txstart_rb] = abs(csi_rs_ls_estimated_channel16->r-csi_rs_estimated_channel16->r); @@ -382,7 +391,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, maxh = cmax3(maxh, abs(csi_rs_estimated_channel16->r), abs(csi_rs_estimated_channel16->i)); } } - for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + for(uint16_t port_tx = 0; port_txfirst_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++) { + for(uint16_t port_tx = 0; port_tx ant_rx %d : ls (%4d,%4d), int (%4d,%4d), noise (%4d,%4d) | ", @@ -408,7 +417,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, } - *noise_power /= (frame_parms->nb_antennas_rx*nr_csi_rs_info->N_ports); + *noise_power /= (frame_parms->nb_antennas_rx*N_ports); *log2_maxh = log2_approx(maxh-1); *log2_re = log2_approx(count-1); @@ -422,7 +431,8 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, const nr_csi_rs_info_t *nr_csi_rs_info, - int32_t csi_rs_estimated_channel_freq[][ue->nr_csi_rs_info->N_ports][ue->frame_parms.ofdm_symbol_size], + const uint8_t N_ports, + int32_t csi_rs_estimated_channel_freq[][N_ports][ue->frame_parms.ofdm_symbol_size], const int16_t log2_maxh, uint8_t *rank_indicator) { @@ -431,11 +441,11 @@ int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, int count = 0; *rank_indicator = 0; - if (ue->frame_parms.nb_antennas_rx == 1 || ue->nr_csi_rs_info->N_ports == 1) { + if (ue->frame_parms.nb_antennas_rx == 1 || N_ports == 1) { return 0; - } else if( !(ue->frame_parms.nb_antennas_rx == 2 && ue->nr_csi_rs_info->N_ports == 2) ) { + } else if( !(ue->frame_parms.nb_antennas_rx == 2 && N_ports == 2) ) { LOG_W(NR_PHY, "Rank indicator computation is not implemented for %i x %i system\n", - ue->frame_parms.nb_antennas_rx, ue->nr_csi_rs_info->N_ports); + ue->frame_parms.nb_antennas_rx, N_ports); return -1; } @@ -444,9 +454,9 @@ int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, * | conjch01 conjch11 | | ch10 ch11 | | conjch01*ch00+conjch11*ch10 conjch01*ch01+conjch11*ch11 | */ - int32_t csi_rs_estimated_conjch_ch[frame_parms->nb_antennas_rx][nr_csi_rs_info->N_ports][frame_parms->nb_antennas_rx][nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); - int32_t csi_rs_estimated_A_MF[nr_csi_rs_info->N_ports][nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); - int32_t csi_rs_estimated_A_MF_sq[nr_csi_rs_info->N_ports][nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); + int32_t csi_rs_estimated_conjch_ch[frame_parms->nb_antennas_rx][N_ports][frame_parms->nb_antennas_rx][N_ports][frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); + int32_t csi_rs_estimated_A_MF[N_ports][N_ports][frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); + int32_t csi_rs_estimated_A_MF_sq[N_ports][N_ports][frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); int32_t csi_rs_estimated_determ_fin[frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); int32_t csi_rs_estimated_numer_fin[frame_parms->ofdm_symbol_size] __attribute__((aligned(32))); @@ -460,9 +470,9 @@ int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, uint16_t k = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; for (int ant_rx_conjch = 0; ant_rx_conjch < frame_parms->nb_antennas_rx; ant_rx_conjch++) { - for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { + for(uint16_t port_tx_conjch = 0; port_tx_conjch < N_ports; port_tx_conjch++) { for (int ant_rx_ch = 0; ant_rx_ch < frame_parms->nb_antennas_rx; ant_rx_ch++) { - for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { + for(uint16_t port_tx_ch = 0; port_tx_ch < N_ports; port_tx_ch++) { // conjch x ch computation nr_conjch0_mult_ch1(&csi_rs_estimated_channel_freq[ant_rx_conjch][port_tx_conjch][k], @@ -503,8 +513,8 @@ int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, 1); #ifdef NR_CSIRS_DEBUG - for(uint16_t port_tx_conjch = 0; port_tx_conjch < nr_csi_rs_info->N_ports; port_tx_conjch++) { - for(uint16_t port_tx_ch = 0; port_tx_ch < nr_csi_rs_info->N_ports; port_tx_ch++) { + for(uint16_t port_tx_conjch = 0; port_tx_conjch < N_ports; port_tx_conjch++) { + for(uint16_t port_tx_ch = 0; port_tx_ch < N_ports; port_tx_ch++) { c16_t *csi_rs_estimated_A_MF_k = (c16_t *) &csi_rs_estimated_A_MF[port_tx_conjch][port_tx_ch][k]; LOG_I(NR_PHY, "(%i) csi_rs_estimated_A_MF[%i][%i] = (%i, %i)\n", k, port_tx_conjch, port_tx_ch, csi_rs_estimated_A_MF_k->r, csi_rs_estimated_A_MF_k->i); @@ -553,7 +563,8 @@ int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, int nr_csi_rs_pmi_estimation(const PHY_VARS_NR_UE *ue, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, const nr_csi_rs_info_t *nr_csi_rs_info, - const int32_t csi_rs_estimated_channel_freq[][ue->nr_csi_rs_info->N_ports][ue->frame_parms.ofdm_symbol_size], + const uint8_t N_ports, + const int32_t csi_rs_estimated_channel_freq[][N_ports][ue->frame_parms.ofdm_symbol_size], const uint32_t interference_plus_noise_power, const uint8_t rank_indicator, const int16_t log2_re, @@ -574,7 +585,7 @@ int nr_csi_rs_pmi_estimation(const PHY_VARS_NR_UE *ue, // The first column is applicable if the UE is reporting a Rank = 1, whereas the second column is applicable if the // UE is reporting a Rank = 2. - if(nr_csi_rs_info->N_ports == 1 || interference_plus_noise_power == 0) { + if(N_ports == 1 || interference_plus_noise_power == 0) { return 0; } @@ -812,6 +823,11 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int32_t csi_rs_received_signal[frame_parms->nb_antennas_rx][frame_parms->samples_per_slot_wCP]; + uint8_t N_cdm_groups = 0; + uint8_t CDM_group_size = 0; + uint8_t k_prime = 0; + uint8_t l_prime = 0; + uint8_t N_ports = 0; int16_t log2_re = 0; int16_t log2_maxh = 0; uint32_t noise_power = 0; @@ -826,15 +842,24 @@ 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, - proc->nr_slot_rx); + proc->nr_slot_rx, + &N_cdm_groups, + &CDM_group_size, + &k_prime, + &l_prime, + &N_ports); - int32_t csi_rs_ls_estimated_channel[frame_parms->nb_antennas_rx][ue->nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size]; - int32_t csi_rs_estimated_channel_freq[frame_parms->nb_antennas_rx][ue->nr_csi_rs_info->N_ports][frame_parms->ofdm_symbol_size]; + int32_t csi_rs_ls_estimated_channel[frame_parms->nb_antennas_rx][N_ports][frame_parms->ofdm_symbol_size]; + int32_t csi_rs_estimated_channel_freq[frame_parms->nb_antennas_rx][N_ports][frame_parms->ofdm_symbol_size]; nr_get_csi_rs_signal(ue, proc, csirs_config_pdu, ue->nr_csi_rs_info, + N_cdm_groups, + CDM_group_size, + k_prime, + l_prime, csi_rs_received_signal); nr_csi_rs_channel_estimation(ue, @@ -843,6 +868,11 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->nr_csi_rs_info, (const int32_t **) ue->nr_csi_rs_info->csi_rs_generated_signal, csi_rs_received_signal, + N_cdm_groups, + CDM_group_size, + k_prime, + l_prime, + N_ports, csi_rs_ls_estimated_channel, csi_rs_estimated_channel_freq, &log2_re, @@ -852,6 +882,7 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t nr_csi_rs_ri_estimation(ue, csirs_config_pdu, ue->nr_csi_rs_info, + N_ports, csi_rs_estimated_channel_freq, log2_maxh, &rank_indicator); @@ -859,6 +890,7 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t nr_csi_rs_pmi_estimation(ue, csirs_config_pdu, ue->nr_csi_rs_info, + N_ports, csi_rs_estimated_channel_freq, ue->nr_csi_im_info->meas_computed ? ue->nr_csi_im_info->interference_plus_noise_power : noise_power, rank_indicator, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 3cc2a1245a..3180207b3a 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -254,11 +254,6 @@ 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]; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 9bd82fd4f9..7aa12cd812 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -168,7 +168,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, slot); + nr_generate_csi_rs(&gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info, csi_params, slot, NULL, NULL, NULL, NULL, NULL); csirs->active = 0; } } From 3025627c0634d65ae6a64df1a8a52ebeb179f082 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Thu, 7 Jul 2022 17:23:18 +0100 Subject: [PATCH 52/71] Remove j, koverline and loverline from nr_csi_rs_info_t --- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 13 +++++--- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 5 ++- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 32 +++++++++++++++---- openair1/PHY/defs_nr_common.h | 3 -- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index 74630ece74..e0b0432462 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -53,7 +53,10 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, uint8_t *CDM_group_size, uint8_t *k_prime, uint8_t *l_prime, - uint8_t *N_ports) { + uint8_t *N_ports, + uint8_t *j_cdm, + uint8_t *k_overline, + uint8_t *l_overline) { #ifdef NR_CSIRS_DEBUG LOG_I(NR_PHY, "csi_params->subcarrier_spacing = %i\n", csi_params->subcarrier_spacing); @@ -648,9 +651,9 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, if (k_prime) *k_prime = kprime; if (l_prime) *l_prime = lprime; if (N_ports) *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)); + if (j_cdm) memcpy(j_cdm,j,16*sizeof(uint8_t)); + if (k_overline) memcpy(k_overline,koverline,16*sizeof(uint8_t)); + if (l_overline) memcpy(l_overline,loverline,16*sizeof(uint8_t)); #ifdef NR_CSIRS_DEBUG if (N_ports) LOG_I(NR_PHY, "nr_csi_rs_info->N_ports = %d\n", *N_ports); @@ -660,7 +663,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, if (l_prime) LOG_I(NR_PHY, "nr_csi_rs_info->lprime = %d\n", *l_prime); if (N_cdm_groups) { for(int ji=0; ji<*N_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]); + LOG_I(NR_PHY, "(CDM group %d) j = %d, koverline = %d, loverline = %d\n", ji, j[ji], koverline[ji], loverline[ji]); } } #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 76a4931c96..4b0c056642 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -347,7 +347,10 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, uint8_t *CDM_group_size, uint8_t *k_prime, uint8_t *l_prime, - uint8_t *N_ports); + uint8_t *N_ports, + uint8_t *j_cdm, + uint8_t *k_overline, + uint8_t *l_overline); 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 aacdfb7f22..43b1ae8506 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -182,6 +182,9 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, const uint8_t CDM_group_size, const uint8_t k_prime, const uint8_t l_prime, + const uint8_t *j_cdm, + const uint8_t *k_overline, + const uint8_t *l_overline, int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP]) { int32_t **rxdataF = ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; @@ -202,11 +205,11 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, // loop over frequency resource elements within a group for (int kp = 0; kp <= k_prime; 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 k = (frame_parms->first_carrier_offset + (rb*NR_NB_SC_PER_RB)+k_overline[cdm_id] + kp) % frame_parms->ofdm_symbol_size; // loop over time resource elements within a group for (int lp = 0; lp <= l_prime; lp++) { - uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; + uint16_t symb = lp + l_overline[cdm_id]; uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; c16_t *rx_signal = (c16_t*)&rxdataF[ant_rx][symbol_offset]; c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; @@ -215,7 +218,7 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, #ifdef NR_CSIRS_DEBUG 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]*CDM_group_size; + uint16_t port_tx = s+j_cdm[cdm_id]*CDM_group_size; c16_t *tx_csi_rs_signal = (c16_t*)&nr_csi_rs_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; LOG_I(NR_PHY, "l,k (%2d,%4d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\n", symb, @@ -263,6 +266,9 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, const uint8_t k_prime, const uint8_t l_prime, const uint8_t N_ports, + const uint8_t *j_cdm, + const uint8_t *k_overline, + const uint8_t *l_overline, int32_t csi_rs_ls_estimated_channel[][N_ports][ue->frame_parms.ofdm_symbol_size], int32_t csi_rs_estimated_channel_freq[][N_ports][ue->frame_parms.ofdm_symbol_size], int16_t *log2_re, @@ -293,17 +299,17 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, for (int cdm_id = 0; cdm_id < N_cdm_groups; cdm_id++) { for (int s = 0; s < CDM_group_size; s++) { - uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*CDM_group_size; + uint16_t port_tx = s+j_cdm[cdm_id]*CDM_group_size; // loop over frequency resource elements within a group for (int kp = 0; kp <= k_prime; kp++) { 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; + uint16_t k = kinit + k_overline[cdm_id] + kp; // loop over time resource elements within a group for (int lp = 0; lp <= l_prime; lp++) { - uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; + uint16_t symb = lp + l_overline[cdm_id]; uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; c16_t *tx_csi_rs_signal = (c16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; @@ -828,6 +834,9 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t uint8_t k_prime = 0; uint8_t l_prime = 0; uint8_t N_ports = 0; + uint8_t j_cdm[16]; + uint8_t k_overline[16]; + uint8_t l_overline[16]; int16_t log2_re = 0; int16_t log2_maxh = 0; uint32_t noise_power = 0; @@ -847,7 +856,10 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t &CDM_group_size, &k_prime, &l_prime, - &N_ports); + &N_ports, + j_cdm, + k_overline, + l_overline); int32_t csi_rs_ls_estimated_channel[frame_parms->nb_antennas_rx][N_ports][frame_parms->ofdm_symbol_size]; int32_t csi_rs_estimated_channel_freq[frame_parms->nb_antennas_rx][N_ports][frame_parms->ofdm_symbol_size]; @@ -860,6 +872,9 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t CDM_group_size, k_prime, l_prime, + j_cdm, + k_overline, + l_overline, csi_rs_received_signal); nr_csi_rs_channel_estimation(ue, @@ -873,6 +888,9 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t k_prime, l_prime, N_ports, + j_cdm, + k_overline, + l_overline, csi_rs_ls_estimated_channel, csi_rs_estimated_channel_freq, &log2_re, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 3180207b3a..6b40847ea8 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -254,9 +254,6 @@ typedef struct { } nr_srs_info_t; 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; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 7aa12cd812..3a5d04500c 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -168,7 +168,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, slot, NULL, NULL, NULL, NULL, NULL); + nr_generate_csi_rs(&gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info, csi_params, slot, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); csirs->active = 0; } } From 70d7a6687b6df1f6a7fc44e6f4ba0a58815ef2f5 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Thu, 7 Jul 2022 18:28:05 +0100 Subject: [PATCH 53/71] Merge nr_csi_rs_info_t plus nr_csi_im_info_t into nr_csi_info_t --- openair1/PHY/INIT/nr_init.c | 22 ++++++------ openair1/PHY/INIT/nr_init_ue.c | 32 ++++++++--------- openair1/PHY/NR_TRANSPORT/nr_csi_rs.c | 22 ++++++------ .../PHY/NR_TRANSPORT/nr_transport_proto.h | 2 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 36 +++++++++---------- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 2 +- openair1/PHY/defs_gNB.h | 4 +-- openair1/PHY/defs_nr_UE.h | 7 ++-- openair1/PHY/defs_nr_common.h | 7 ++-- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 10 files changed, 63 insertions(+), 73 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index e2139a9903..b2167453e3 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -596,20 +596,20 @@ 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; - 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"); + gNB->nr_csi_info = (nr_csi_info_t *)malloc16_clear(sizeof(nr_csi_info_t)); + gNB->nr_csi_info->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame * sizeof(uint32_t **)); + AssertFatal(gNB->nr_csi_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); + gNB->nr_csi_info->nr_gold_csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot * sizeof(uint32_t *)); + AssertFatal(gNB->nr_csi_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); + gNB->nr_csi_info->nr_gold_csi_rs[slot][symb] = (uint32_t *)malloc16(csi_dmrs_init_length * sizeof(uint32_t)); + AssertFatal(gNB->nr_csi_info->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->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); + gNB->nr_csi_info->csi_gold_init = cfg->cell_config.phy_cell_id.value; + nr_init_csi_rs(&gNB->frame_parms, gNB->nr_csi_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)); @@ -775,14 +775,14 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) } free_and_zero(pusch_dmrs); - uint32_t ***nr_gold_csi_rs = gNB->nr_csi_rs_info->nr_gold_csi_rs; + uint32_t ***nr_gold_csi_rs = gNB->nr_csi_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(nr_gold_csi_rs[slot][symb]); free_and_zero(nr_gold_csi_rs[slot]); } free_and_zero(nr_gold_csi_rs); - free_and_zero(gNB->nr_csi_rs_info); + free_and_zero(gNB->nr_csi_info); for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) { for (int i = 0; i < Prx; i++) { diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index acd945497f..0efdb1e8e1 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -347,24 +347,22 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) // ceil((NB_RB*8(max allocation per RB)*2(QPSK))/32) int csi_dmrs_init_length = ((fp->N_RB_DL<<4)>>5)+1; - 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"); + ue->nr_csi_info = (nr_csi_info_t *)malloc16_clear(sizeof(nr_csi_info_t)); + ue->nr_csi_info->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame * sizeof(uint32_t **)); + AssertFatal(ue->nr_csi_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); + ue->nr_csi_info->nr_gold_csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot * sizeof(uint32_t *)); + AssertFatal(ue->nr_csi_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(csi_dmrs_init_length*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_info->nr_gold_csi_rs[slot][symb] = (uint32_t *)malloc16(csi_dmrs_init_length * sizeof(uint32_t)); + AssertFatal(ue->nr_csi_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_generated_signal = (int32_t **)malloc16(NR_MAX_NB_PORTS * sizeof(int32_t *) ); + ue->nr_csi_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_info->csi_rs_generated_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); } - ue->nr_csi_im_info = (nr_csi_im_info_t *)malloc16_clear(sizeof(nr_csi_im_info_t)); - ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); ue->nr_srs_info->sc_list = (uint16_t *) malloc16_clear(6*fp->N_RB_UL*sizeof(uint16_t)); ue->nr_srs_info->srs_generated_signal = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) ); @@ -483,18 +481,16 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) } for (int i=0; inr_csi_rs_info->csi_rs_generated_signal[i]); + free_and_zero(ue->nr_csi_info->csi_rs_generated_signal[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_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_info->nr_gold_csi_rs[slot]); } - free_and_zero(ue->nr_csi_rs_info->nr_gold_csi_rs); - free_and_zero(ue->nr_csi_rs_info); - - free_and_zero(ue->nr_csi_im_info); + free_and_zero(ue->nr_csi_info->nr_gold_csi_rs); + free_and_zero(ue->nr_csi_info); for (int i = 0; i < fp->nb_antennas_rx; i++) { free_and_zero(ue->nr_srs_info->srs_received_signal[i]); diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index e0b0432462..0a1619f3e0 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -46,7 +46,7 @@ void nr_init_csi_rs(const NR_DL_FRAME_PARMS *fp, uint32_t ***csi_rs, uint32_t Ni void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, int32_t **dataF, const int16_t amp, - nr_csi_rs_info_t *nr_csi_rs_info, + nr_csi_info_t *nr_csi_info, const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, const int slot, uint8_t *N_cdm_groups, @@ -76,7 +76,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, #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]; + uint32_t **nr_gold_csi_rs = nr_csi_info->nr_gold_csi_rs[slot]; //*8(max allocation per RB)*2(QPSK)) int csi_rs_length = frame_parms->N_RB_DL<<4; int16_t mod_csi[frame_parms->symbols_per_slot][csi_rs_length>>1] __attribute__((aligned(16))); @@ -89,14 +89,14 @@ void nr_generate_csi_rs(const 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); + nr_csi_info->csi_rs_generated_signal_bits = log2_approx(amp); AssertFatal(b!=0, "Invalid CSI frequency domain mapping: no bit selected in bitmap\n"); // if the scrambling id is not the one previously used to initialize we need to re-initialize the rs - 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); + if (csi_params->scramb_id != nr_csi_info->csi_gold_init) { + nr_csi_info->csi_gold_init = csi_params->scramb_id; + nr_init_csi_rs(frame_parms, nr_csi_info->nr_gold_csi_rs, csi_params->scramb_id); } switch (csi_params->row) { @@ -656,11 +656,11 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, if (l_overline) memcpy(l_overline,loverline,16*sizeof(uint8_t)); #ifdef NR_CSIRS_DEBUG - if (N_ports) LOG_I(NR_PHY, "nr_csi_rs_info->N_ports = %d\n", *N_ports); - if (N_cdm_groups) LOG_I(NR_PHY, "nr_csi_rs_info->N_cdm_groups = %d\n", *N_cdm_groups); - if (CDM_group_size) LOG_I(NR_PHY, "nr_csi_rs_info->CDM_group_size = %d\n", *CDM_group_size); - if (k_prime) LOG_I(NR_PHY, "nr_csi_rs_info->kprime = %d\n", *k_prime); - if (l_prime) LOG_I(NR_PHY, "nr_csi_rs_info->lprime = %d\n", *l_prime); + if (N_ports) LOG_I(NR_PHY, "nr_csi_info->N_ports = %d\n", *N_ports); + if (N_cdm_groups) LOG_I(NR_PHY, "nr_csi_info->N_cdm_groups = %d\n", *N_cdm_groups); + if (CDM_group_size) LOG_I(NR_PHY, "nr_csi_info->CDM_group_size = %d\n", *CDM_group_size); + if (k_prime) LOG_I(NR_PHY, "nr_csi_info->kprime = %d\n", *k_prime); + if (l_prime) LOG_I(NR_PHY, "nr_csi_info->lprime = %d\n", *l_prime); if (N_cdm_groups) { for(int ji=0; ji<*N_cdm_groups; ji++) { LOG_I(NR_PHY, "(CDM group %d) j = %d, koverline = %d, loverline = %d\n", ji, j[ji], koverline[ji], loverline[ji]); diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 4b0c056642..257ab5b2ab 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -340,7 +340,7 @@ uint8_t get_nr_prach_duration(uint8_t prach_format); void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, int32_t **dataF, const int16_t amp, - nr_csi_rs_info_t *nr_csi_rs_info, + nr_csi_info_t *nr_csi_info, const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, const int slot, uint8_t *N_cdm_groups, diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 43b1ae8506..e6fd841129 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -177,7 +177,7 @@ bool is_csi_rs_in_symbol(const fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, - const nr_csi_rs_info_t *nr_csi_rs_info, + const nr_csi_info_t *nr_csi_info, const uint8_t N_cdm_groups, const uint8_t CDM_group_size, const uint8_t k_prime, @@ -219,7 +219,7 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, #ifdef NR_CSIRS_DEBUG int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; uint16_t port_tx = s+j_cdm[cdm_id]*CDM_group_size; - c16_t *tx_csi_rs_signal = (c16_t*)&nr_csi_rs_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + c16_t *tx_csi_rs_signal = (c16_t*)&nr_csi_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; LOG_I(NR_PHY, "l,k (%2d,%4d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\n", symb, k, @@ -258,7 +258,7 @@ uint32_t calc_power_csirs(const uint16_t *x, const fapi_nr_dl_config_csirs_pdu_r int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, - const nr_csi_rs_info_t *nr_csi_rs_info, + const nr_csi_info_t *nr_csi_info, const int32_t **csi_rs_generated_signal, const int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP], const uint8_t N_cdm_groups, @@ -315,8 +315,8 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; - int16_t csi_rs_ls_estimated_channel_re = (int16_t)(((int32_t)tx_csi_rs_signal[k].r*rx_csi_rs_signal[k].r + (int32_t)tx_csi_rs_signal[k].i*rx_csi_rs_signal[k].i)>>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].r*rx_csi_rs_signal[k].i - (int32_t)tx_csi_rs_signal[k].i*rx_csi_rs_signal[k].r)>>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].r*rx_csi_rs_signal[k].r + (int32_t)tx_csi_rs_signal[k].i*rx_csi_rs_signal[k].i)>>nr_csi_info->csi_rs_generated_signal_bits); + int16_t csi_rs_ls_estimated_channel_im = (int16_t)(((int32_t)tx_csi_rs_signal[k].r*rx_csi_rs_signal[k].i - (int32_t)tx_csi_rs_signal[k].i*rx_csi_rs_signal[k].r)>>nr_csi_info->csi_rs_generated_signal_bits); // 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. @@ -436,7 +436,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, - const nr_csi_rs_info_t *nr_csi_rs_info, + const nr_csi_info_t *nr_csi_info, const uint8_t N_ports, int32_t csi_rs_estimated_channel_freq[][N_ports][ue->frame_parms.ofdm_symbol_size], const int16_t log2_maxh, @@ -568,7 +568,7 @@ int nr_csi_rs_ri_estimation(const PHY_VARS_NR_UE *ue, int nr_csi_rs_pmi_estimation(const PHY_VARS_NR_UE *ue, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, - const nr_csi_rs_info_t *nr_csi_rs_info, + const nr_csi_info_t *nr_csi_info, const uint8_t N_ports, const int32_t csi_rs_estimated_channel_freq[][N_ports][ue->frame_parms.ofdm_symbol_size], const uint32_t interference_plus_noise_power, @@ -641,7 +641,7 @@ int nr_csi_rs_pmi_estimation(const PHY_VARS_NR_UE *ue, } } - // We should perform >>nr_csi_rs_info->log2_re here for all terms, but since sum2_re and sum2_im can be high values, + // We should perform >>nr_csi_info->log2_re here for all terms, but since sum2_re and sum2_im can be high values, // we performed this above. for(int p = 0; p<4; p++) { int32_t power_re = sum2_re[p] - (sum_re[p]>>log2_re)*(sum_re[p]>>log2_re); @@ -796,8 +796,8 @@ int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t LOG_I(NR_PHY, "csiim_config_pdu->l_csiim = %i.%i.%i.%i\n", csiim_config_pdu->l_csiim[0], csiim_config_pdu->l_csiim[1], csiim_config_pdu->l_csiim[2], csiim_config_pdu->l_csiim[3]); #endif - nr_csi_im_power_estimation(ue, proc, csiim_config_pdu, &ue->nr_csi_im_info->interference_plus_noise_power); - ue->nr_csi_im_info->meas_computed = true; + nr_csi_im_power_estimation(ue, proc, csiim_config_pdu, &ue->nr_csi_info->interference_plus_noise_power); + ue->nr_csi_info->csi_im_meas_computed = true; return 0; } @@ -847,9 +847,9 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t uint8_t i2[1]; nr_generate_csi_rs(frame_parms, - ue->nr_csi_rs_info->csi_rs_generated_signal, + ue->nr_csi_info->csi_rs_generated_signal, AMP, - ue->nr_csi_rs_info, + ue->nr_csi_info, (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *) csirs_config_pdu, proc->nr_slot_rx, &N_cdm_groups, @@ -867,7 +867,7 @@ 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, csirs_config_pdu, - ue->nr_csi_rs_info, + ue->nr_csi_info, N_cdm_groups, CDM_group_size, k_prime, @@ -880,8 +880,8 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t nr_csi_rs_channel_estimation(ue, proc, csirs_config_pdu, - ue->nr_csi_rs_info, - (const int32_t **) ue->nr_csi_rs_info->csi_rs_generated_signal, + ue->nr_csi_info, + (const int32_t **) ue->nr_csi_info->csi_rs_generated_signal, csi_rs_received_signal, N_cdm_groups, CDM_group_size, @@ -899,7 +899,7 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t nr_csi_rs_ri_estimation(ue, csirs_config_pdu, - ue->nr_csi_rs_info, + ue->nr_csi_info, N_ports, csi_rs_estimated_channel_freq, log2_maxh, @@ -907,10 +907,10 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t nr_csi_rs_pmi_estimation(ue, csirs_config_pdu, - ue->nr_csi_rs_info, + ue->nr_csi_info, N_ports, csi_rs_estimated_channel_freq, - ue->nr_csi_im_info->meas_computed ? ue->nr_csi_im_info->interference_plus_noise_power : noise_power, + ue->nr_csi_info->csi_im_meas_computed ? ue->nr_csi_info->interference_plus_noise_power : noise_power, rank_indicator, log2_re, i1, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 5f3af5bb39..ea7bde5377 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -362,7 +362,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, nr_gold_pdsch(ue, i, ue->scramblingID_dlsch[i]); } - nr_init_csi_rs(fp, ue->nr_csi_rs_info->nr_gold_csi_rs, fp->Nid_cell); + nr_init_csi_rs(fp, ue->nr_csi_info->nr_gold_csi_rs, fp->Nid_cell); // initialize the pusch dmrs for (int i=0; iactive == 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, slot, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + nr_generate_csi_rs(&gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_info, csi_params, slot, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); csirs->active = 0; } } From 03bea3150a8927053a9ab021b020163d447fce76 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Thu, 7 Jul 2022 20:16:54 +0100 Subject: [PATCH 54/71] Fix memory leak --- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index e6fd841129..753040ecc6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -928,14 +928,13 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t csirs_measurements.i1 = *i1; csirs_measurements.i2 = *i2; csirs_measurements.cqi = cqi; - nr_downlink_indication_t *dl_indication = calloc(sizeof(*dl_indication),1); + nr_downlink_indication_t dl_indication; fapi_nr_rx_indication_t *rx_ind = calloc(sizeof(*rx_ind),1); - nr_fill_dl_indication(dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); nr_fill_rx_indication(rx_ind, FAPI_NR_CSIRS_IND, gNB_id, ue, NULL, NULL, 1, proc, (void *)&csirs_measurements); if (ue->if_inst && ue->if_inst->dl_indication) { - ue->if_inst->dl_indication(dl_indication, NULL); + ue->if_inst->dl_indication(&dl_indication, NULL); } else { - free(dl_indication); free(rx_ind); } From a574c47e9e0eff418d2e703527873c2f6d6e4dc2 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Fri, 8 Jul 2022 10:54:37 +0100 Subject: [PATCH 55/71] Fix memory leak --- openair1/PHY/INIT/nr_init_ue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 0efdb1e8e1..b901a038bb 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -483,6 +483,7 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) for (int i=0; inr_csi_info->csi_rs_generated_signal[i]); } + free_and_zero(ue->nr_csi_info->csi_rs_generated_signal); for (int slot=0; slotslots_per_frame; slot++) { for (int symb=0; symbsymbols_per_slot; symb++) { free_and_zero(ue->nr_csi_info->nr_gold_csi_rs[slot][symb]); From b0bcff0da2a20e89903f54a71778c2e32502ae33 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Fri, 8 Jul 2022 11:17:28 +0100 Subject: [PATCH 56/71] Fix build warnings in phy simulators --- openair1/SIMULATION/NR_PHY/dlschsim.c | 22 +++++++++++----------- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index e81871b146..39cd540795 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -114,16 +114,16 @@ int main(int argc, char **argv) //int run_initial_sync=0; int loglvl = OAILOG_WARNING; uint8_t dlsch_threads = 0; - float target_error_rate = 0.01; - uint64_t SSB_positions=0x01; - uint16_t nb_symb_sch = 12; - uint16_t nb_rb = 50; - uint8_t Imcs = 9; - uint8_t mcs_table = 0; - double DS_TDL = .03; - cpuf = get_cpu_freq_GHz(); - char gNBthreads[128]="n"; - int Tbslbrm = 950984; + float target_error_rate = 0.01; + uint64_t SSB_positions=0x01; + uint16_t nb_symb_sch = 12; + uint16_t nb_rb = 50; + uint8_t Imcs = 9; + uint8_t mcs_table = 0; + double DS_TDL = .03; + cpuf = get_cpu_freq_GHz(); + char gNBthreads[128]="n"; + int Tbslbrm = 950984; if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) { exit_fun("[NR_DLSCHSIM] Error, configuration module init failed\n"); @@ -299,7 +299,7 @@ int main(int argc, char **argv) break; case 'X': - strncpy(gNBthreads, optarg, sizeof(gNBthreads)); + strncpy(gNBthreads, optarg, sizeof(gNBthreads)-1); gNBthreads[sizeof(gNBthreads)-1]=0; break; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 78b253ca2a..1e81cf691a 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -670,7 +670,7 @@ int main(int argc, char **argv) break; case 'X': - strncpy(gNBthreads, optarg, sizeof(gNBthreads)); + strncpy(gNBthreads, optarg, sizeof(gNBthreads)-1); gNBthreads[sizeof(gNBthreads)-1]=0; break; From 1f818b41782ffcee64d4db3f5f13f3b8c9c857e3 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Tue, 26 Jul 2022 12:45:30 +0100 Subject: [PATCH 57/71] RSRP computation at UE based on CSI-RS --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 2 ++ openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 35 ++++++++++++++++--- 2 files changed, 33 insertions(+), 4 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 6e1a4adb65..d78eebd440 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 @@ -48,6 +48,8 @@ typedef struct { } fapi_nr_uci_pdu_rel15_t; typedef struct { + uint32_t rsrp; + int rsrp_dBm; uint8_t rank_indicator; uint8_t i1; uint8_t i2; diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 753040ecc6..43944b2fa8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -33,12 +33,15 @@ #include #include +#include "executables/nr-softmodem-common.h" #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" #include "PHY/NR_UE_ESTIMATION/filt16a_32.h" +// 10*log10(pow(2,30)) +#define pow_2_30_dB 90 //#define NR_CSIRS_DEBUG //#define NR_CSIIM_DEBUG @@ -185,10 +188,14 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, const uint8_t *j_cdm, const uint8_t *k_overline, const uint8_t *l_overline, - int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP]) { + int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP], + uint32_t *rsrp, + int *rsrp_dBm) { int32_t **rxdataF = ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + uint16_t meas_count = 0; + uint32_t rsrp_sum = 0; for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { @@ -216,6 +223,11 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, rx_csi_rs_signal[k].r = rx_signal[k].r; rx_csi_rs_signal[k].i = rx_signal[k].i; + rsrp_sum += (((int32_t)(rx_csi_rs_signal[k].r)*rx_csi_rs_signal[k].r) + + ((int32_t)(rx_csi_rs_signal[k].i)*rx_csi_rs_signal[k].i)); + + meas_count++; + #ifdef NR_CSIRS_DEBUG int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; uint16_t port_tx = s+j_cdm[cdm_id]*CDM_group_size; @@ -237,6 +249,15 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, } } + + *rsrp = rsrp_sum/meas_count; + *rsrp_dBm = dB_fixed(*rsrp) + 30 - pow_2_30_dB + - ((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0]) - dB_fixed(ue->frame_parms.ofdm_symbol_size); + +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "RSRP = %i (%i dBm)\n", *rsrp, *rsrp_dBm); +#endif + return 0; } @@ -839,6 +860,8 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t uint8_t l_overline[16]; int16_t log2_re = 0; int16_t log2_maxh = 0; + uint32_t rsrp = 0; + int rsrp_dBm = 0; uint32_t noise_power = 0; uint8_t rank_indicator = 0; uint32_t precoded_sinr_dB = 0; @@ -875,7 +898,9 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t j_cdm, k_overline, l_overline, - csi_rs_received_signal); + csi_rs_received_signal, + &rsrp, + &rsrp_dBm); nr_csi_rs_channel_estimation(ue, proc, @@ -919,11 +944,13 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t nr_csi_rs_cqi_estimation(precoded_sinr_dB, &cqi); - LOG_I(NR_PHY, "RI = %i, i1 = %i.%i.%i, i2 = %i, SINR = %i dB, CQI = %i\n", - rank_indicator+1, i1[0], i1[1], i1[2], i2[0], precoded_sinr_dB, cqi); + LOG_I(NR_PHY, "RSRP = %i dBm, RI = %i, i1 = %i.%i.%i, i2 = %i, SINR = %i dB, CQI = %i\n", + rsrp_dBm, rank_indicator+1, i1[0], i1[1], i1[2], i2[0], precoded_sinr_dB, cqi); // Send CSI measurements to MAC fapi_nr_csirs_measurements_t csirs_measurements; + csirs_measurements.rsrp = rsrp; + csirs_measurements.rsrp_dBm = rsrp_dBm; csirs_measurements.rank_indicator = rank_indicator; csirs_measurements.i1 = *i1; csirs_measurements.i2 = *i2; From 3ca83257cc1e8f675b9ebc1d0cf39d63db4db4b6 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Tue, 26 Jul 2022 15:45:11 +0100 Subject: [PATCH 58/71] UE sends the report with the RSRP based on CSI-RS to gNB --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 6 ++ openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 65 ++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index d5174b3a44..6bb833be31 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -220,6 +220,12 @@ uint8_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, NR_CSI_ResourceConfigId_t csi_ResourceConfigId, NR_CSI_MeasConfig_t *csi_MeasConfig); +uint8_t get_csirs_RSRP_payload(NR_UE_MAC_INST_t *mac, + PUCCH_sched_t *pucch, + struct NR_CSI_ReportConfig *csi_reportconfig, + NR_CSI_ResourceConfigId_t csi_ResourceConfigId, + NR_CSI_MeasConfig_t *csi_MeasConfig); + uint8_t nr_get_csi_payload(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, int csi_report_id, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 67331c1865..bf6e0c4b02 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2572,6 +2572,8 @@ uint8_t nr_get_csi_payload(NR_UE_MAC_INST_t *mac, n_csi_bits = get_csirs_RI_PMI_CQI_payload(mac,pucch,csi_reportconfig,csi_ResourceConfigId,csi_MeasConfig); break; case NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP: + n_csi_bits = get_csirs_RSRP_payload(mac,pucch,csi_reportconfig,csi_ResourceConfigId,csi_MeasConfig); + break; case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_i1: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_i1_CQI: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_CQI: @@ -2709,6 +2711,9 @@ uint8_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, LOG_D(NR_MAC, "cqi_bitlen = %d\n", cqi_bitlen); LOG_D(NR_MAC, "csi_part1_payload = 0x%x\n", temp_payload); + LOG_D(NR_MAC, "n_bits = %d\n", n_bits); + LOG_D(NR_MAC, "csi_part1_payload = 0x%x\n", temp_payload); + break; } } @@ -2718,6 +2723,66 @@ uint8_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, return n_bits; } +uint8_t get_csirs_RSRP_payload(NR_UE_MAC_INST_t *mac, + PUCCH_sched_t *pucch, + struct NR_CSI_ReportConfig *csi_reportconfig, + NR_CSI_ResourceConfigId_t csi_ResourceConfigId, + NR_CSI_MeasConfig_t *csi_MeasConfig) { + + int n_bits = 0; + uint32_t temp_payload = 0; + + for (int csi_resourceidx = 0; csi_resourceidx < csi_MeasConfig->csi_ResourceConfigToAddModList->list.count; csi_resourceidx++) { + + struct NR_CSI_ResourceConfig *csi_resourceconfig = csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[csi_resourceidx]; + if (csi_resourceconfig->csi_ResourceConfigId == csi_ResourceConfigId) { + + for (int csi_idx = 0; csi_idx < csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.count; csi_idx++) { + if (csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[csi_idx]->nzp_CSI_ResourceSetId == + *(csi_resourceconfig->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list.array[0])) { + + nr_csi_report_t *csi_report = &mac->csi_report_template[csi_reportconfig->reportConfigId]; + compute_csi_bitlen(csi_MeasConfig, mac->csi_report_template); + n_bits = nr_get_csi_bitlen(mac->csi_report_template, csi_reportconfig->reportConfigId); + + int cri_ssbri_bitlen = csi_report->CSI_report_bitlen.cri_ssbri_bitlen; + int rsrp_bitlen = csi_report->CSI_report_bitlen.rsrp_bitlen; + int diff_rsrp_bitlen = csi_report->CSI_report_bitlen.diff_rsrp_bitlen; + + if (cri_ssbri_bitlen > 0) { + LOG_E(NR_MAC, "Implementation for cri_ssbri_bitlen>0 is not supported yet!\n");; + } + + // TODO: Improvements will be needed to cri_ssbri_bitlen>0 + // TS 38.133 - Table 10.1.6.1-1 + int rsrp_dBm = mac->csirs_measurements.rsrp_dBm; + if (rsrp_dBm < -139) { + temp_payload = 17; + } else if (rsrp_dBm > -45) { + temp_payload = 112; + } else { + temp_payload = mac->csirs_measurements.rsrp_dBm + 157; + } + + reverse_n_bits((uint8_t *)&temp_payload, n_bits); + + LOG_D(NR_MAC, "cri_ssbri_bitlen = %d\n", cri_ssbri_bitlen); + LOG_D(NR_MAC, "rsrp_bitlen = %d\n", rsrp_bitlen); + LOG_D(NR_MAC, "diff_rsrp_bitlen = %d\n", diff_rsrp_bitlen); + + LOG_D(NR_MAC, "n_bits = %d\n", n_bits); + LOG_D(NR_MAC, "csi_part1_payload = 0x%x\n", temp_payload); + + break; + } + } + } + } + + pucch->csi_part1_payload = temp_payload; + return n_bits; +} + // returns index from RSRP // according to Table 10.1.6.1-1 in 38.133 From 8cd87999813f836830db9ba9c29c819abca7ab24 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 27 Jul 2022 18:43:47 +0100 Subject: [PATCH 59/71] Update range for reported RSRP --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index bf6e0c4b02..aade58421a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2756,10 +2756,10 @@ uint8_t get_csirs_RSRP_payload(NR_UE_MAC_INST_t *mac, // TODO: Improvements will be needed to cri_ssbri_bitlen>0 // TS 38.133 - Table 10.1.6.1-1 int rsrp_dBm = mac->csirs_measurements.rsrp_dBm; - if (rsrp_dBm < -139) { - temp_payload = 17; - } else if (rsrp_dBm > -45) { - temp_payload = 112; + if (rsrp_dBm < -140) { + temp_payload = 16; + } else if (rsrp_dBm > -44) { + temp_payload = 113; } else { temp_payload = mac->csirs_measurements.rsrp_dBm + 157; } From 970bfc92f02e71ecfc3cd6a63920f9986d599617 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Thu, 28 Jul 2022 07:20:31 +0100 Subject: [PATCH 60/71] Fix a segmentation fault when there is no spCellConfigDedicated with maxMIMO_Layers parameter --- 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 d9a0a50b7e..a4c034bb8f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1120,9 +1120,8 @@ void nr_schedule_ue_spec(module_id_t module_id, csi_report->codebook_mode); } // TBS_LBRM according to section 5.4.2.1 of 38.212 - long *maxMIMO_Layers = cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; - AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); - int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; + long maxMIMO_Layers = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated ? *cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers : 1; + int nl_tbslbrm = maxMIMO_Layers < 4 ? maxMIMO_Layers : 4; // Maximum number of PRBs across all configured DL BWPs int bw_tbslbrm = get_bw_tbslbrm(genericParameters, cg); pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(ps->mcsTableIdx, From 1a77e9ba37dd86e7f3a1c3041580df822ab9fd48 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Mon, 20 Jun 2022 14:08:43 +0100 Subject: [PATCH 61/71] Schedule BWP switching to the first active BWP (previous active BWP before RA with Msg3 carrying DCCH or DTCH message) --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 01a574f83c..842a3521cb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2957,6 +2957,10 @@ void nr_mac_update_timers(module_id_t module_id, LOG_I(NR_MAC, "(%d.%d) Switching to initialUplinkBWP\n", frame, slot); } UE->Msg3_dcch_dtch = false; + + // Schedule BWP switching to the first active BWP (previous active BWP before RA with Msg3 carrying DCCH or DTCH message) + sched_ctrl->next_dl_bwp_id = current_bwp_id; + sched_ctrl->next_ul_bwp_id = current_ubwp_id; } else if (spCellConfigDedicated && spCellConfigDedicated->downlinkBWP_ToAddModList && spCellConfigDedicated->uplinkConfig && @@ -2969,6 +2973,19 @@ void nr_mac_update_timers(module_id_t module_id, if (*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id != current_ubwp_id) { LOG_I(NR_MAC, "(%d.%d) Switching to UL-BWP %li\n", frame, slot, sched_ctrl->active_ubwp->bwp_Id); } + + // Update next_dl_bwp_id to not trigger BWP switching, UE should be already on active_bwp + sched_ctrl->next_dl_bwp_id = sched_ctrl->active_bwp->bwp_Id; + // Update next_ul_bwp_id to not trigger BWP switching, UE should be already on active_ubwp + sched_ctrl->next_ul_bwp_id = sched_ctrl->active_ubwp->bwp_Id; + } else { + sched_ctrl->active_bwp = NULL; + sched_ctrl->active_ubwp = NULL; + + // Update next_dl_bwp_id to not trigger BWP switching, UE should be already on Initial BWP + sched_ctrl->next_dl_bwp_id = 0; + // Update next_ul_bwp_id to not trigger BWP switching, UE should be already on Initial BWP + sched_ctrl->next_ul_bwp_id = 0; } // Update coreset/searchspace @@ -3062,14 +3079,27 @@ void schedule_nr_bwp_switch(module_id_t module_id, UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - if (sched_ctrl->rrc_processing_timer == 0 && - UE->Msg4_ACKed && - ((sched_ctrl->next_dl_bwp_id >= 0 && sched_ctrl->active_bwp && sched_ctrl->active_bwp->bwp_Id != sched_ctrl->next_dl_bwp_id) || - (sched_ctrl->next_ul_bwp_id >= 0 && sched_ctrl->active_ubwp && sched_ctrl->active_ubwp->bwp_Id != sched_ctrl->next_ul_bwp_id))) { + if (sched_ctrl->rrc_processing_timer == 0 && UE->Msg4_ACKed && sched_ctrl->next_dl_bwp_id >= 0) { - LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from dl_bwp_id %ld to %ld and from ul_bwp_id %ld to %ld\n", - frame, slot, UE->rnti, sched_ctrl->active_bwp->bwp_Id, sched_ctrl->next_dl_bwp_id, sched_ctrl->active_ubwp->bwp_Id, sched_ctrl->next_ul_bwp_id); - nr_mac_rrc_bwp_switch_req(module_id, frame, slot, UE->rnti, sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); + int schedule_bwp_switching = false; + if (sched_ctrl->active_bwp == NULL) { + // Switching from Initial BWP to Dedicated BWP + if (sched_ctrl->next_dl_bwp_id > 0 && sched_ctrl->next_ul_bwp_id > 0) { + schedule_bwp_switching = true; + LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from Initial DL BWP to %ld and from Initial UL BWP to %ld\n", + frame, slot, UE->rnti, sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); + } + } else if (sched_ctrl->active_bwp->bwp_Id != sched_ctrl->next_dl_bwp_id && sched_ctrl->active_ubwp->bwp_Id != sched_ctrl->next_ul_bwp_id) { + // Switching between Dedicated BWPs + schedule_bwp_switching = true; + LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from dl_bwp_id %ld to %ld and from ul_bwp_id %ld to %ld\n", + frame, slot, UE->rnti, sched_ctrl->active_bwp->bwp_Id, sched_ctrl->next_dl_bwp_id, sched_ctrl->active_ubwp->bwp_Id, sched_ctrl->next_ul_bwp_id); + } + + if (schedule_bwp_switching) { + AssertFatal(sched_ctrl->next_dl_bwp_id > 0 && sched_ctrl->next_ul_bwp_id > 0, "BWP switching from a Dedicated BWP to the Initial BWP not handled yet!"); + nr_mac_rrc_bwp_switch_req(module_id, frame, slot, UE->rnti, sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); + } } } } From 069bebfa480aa8989eb033cfe294b5bd1b3b1363 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Fri, 29 Jul 2022 10:05:34 +0100 Subject: [PATCH 62/71] Fix floating point --- openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c | 5 +++++ openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 00b053e3ff..e2e9500162 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -1141,6 +1141,11 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, if (count_estimates == n_noise_estimates) { noise_power_per_rb[rb] = sum_re2/n_noise_estimates - (sum_re/n_noise_estimates)*(sum_re/n_noise_estimates) + sum_im2/n_noise_estimates - (sum_im/n_noise_estimates)*(sum_im/n_noise_estimates); + + if (noise_power_per_rb[rb] == 0) { + noise_power_per_rb[rb] = 1; + } + snr_per_rb[rb] = dB_fixed((int32_t)((*signal_power<num_symbols; int32_t srs_received_signal[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size*N_symb_SRS]; int32_t srs_ls_estimated_channel[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size*N_symb_SRS]; - int32_t srs_estimated_channel_freq[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size*N_symb_SRS]; - int32_t srs_estimated_channel_time[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size]; + int32_t srs_estimated_channel_freq[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size*N_symb_SRS] __attribute__ ((aligned(32))); + int32_t srs_estimated_channel_time[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size] __attribute__ ((aligned(32))); int32_t srs_estimated_channel_time_shifted[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size]; uint32_t noise_power_per_rb[srs_pdu->bwp_size]; int8_t snr_per_rb[srs_pdu->bwp_size]; From 6f67792993077e318976e858eecd224e9c505f33 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Fri, 29 Jul 2022 10:42:55 +0100 Subject: [PATCH 63/71] Variable rename --- .../PHY/NR_ESTIMATION/nr_ul_channel_estimation.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index e2e9500162..e5c1ca37d8 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -1115,7 +1115,7 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, const uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*12; const uint8_t srs_symbols_per_rb = srs_pdu->comb_size == 0 ? 6 : 3; - const uint8_t n_noise_estimates = frame_parms->nb_antennas_rx*srs_symbols_per_rb; + const uint8_t n_noise_est = frame_parms->nb_antennas_rx * srs_symbols_per_rb; uint8_t count_estimates = 0; uint64_t sum_re = 0; uint64_t sum_re2 = 0; @@ -1138,14 +1138,9 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, sum_im2 = sum_im2 + noise_imag[ant*nr_srs_info->sc_list_length+sc_idx]*noise_imag[ant*nr_srs_info->sc_list_length+sc_idx]; count_estimates++; - if (count_estimates == n_noise_estimates) { - noise_power_per_rb[rb] = sum_re2/n_noise_estimates - (sum_re/n_noise_estimates)*(sum_re/n_noise_estimates) + - sum_im2/n_noise_estimates - (sum_im/n_noise_estimates)*(sum_im/n_noise_estimates); - - if (noise_power_per_rb[rb] == 0) { - noise_power_per_rb[rb] = 1; - } - + if (count_estimates == n_noise_est) { + noise_power_per_rb[rb] = max(sum_re2 / n_noise_est - (sum_re / n_noise_est) * (sum_re / n_noise_est) + + sum_im2 / n_noise_est - (sum_im / n_noise_est) * (sum_im / n_noise_est), 1); snr_per_rb[rb] = dB_fixed((int32_t)((*signal_power< Date: Mon, 1 Aug 2022 10:26:14 +0100 Subject: [PATCH 64/71] Remove unused code --- openair2/RRC/NR/L2_nr_interface.c | 104 ------------------------------ 1 file changed, 104 deletions(-) diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 6fc0566cbd..ab9e3984d8 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -49,102 +49,6 @@ extern RAN_CONTEXT_t RC; -int generate_pdcch_ConfigSIB1(NR_PDCCH_ConfigSIB1_t *pdcch_ConfigSIB1, - long ssbSubcarrierSpacing, - long subCarrierSpacingCommon, - channel_bandwidth_t min_channel_bw) { - - nr_ssb_and_cset_mux_pattern_type_t mux_pattern = 0; - - switch (ssbSubcarrierSpacing) { - - case NR_SubcarrierSpacing_kHz15: - if (subCarrierSpacingCommon == NR_SubcarrierSpacing_kHz15) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_1_NUM_INDEXES; - mux_pattern = table_38213_13_1_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else if (subCarrierSpacingCommon == NR_SubcarrierSpacing_kHz30) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_2_NUM_INDEXES; - mux_pattern = table_38213_13_2_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else { - AssertFatal(true,"Invalid subCarrierSpacingCommon\n"); - } - break; - - case NR_SubcarrierSpacing_kHz30: - if (subCarrierSpacingCommon == NR_SubcarrierSpacing_kHz15) { - - if ( (min_channel_bw == bw_5MHz) || (min_channel_bw == bw_10MHz) ) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_3_NUM_INDEXES; - mux_pattern = table_38213_13_3_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else if (min_channel_bw == bw_40MHz) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_5_NUM_INDEXES; - mux_pattern = table_38213_13_5_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else { - AssertFatal(true,"Invalid min_bandwidth\n"); - } - - } else if (subCarrierSpacingCommon == NR_SubcarrierSpacing_kHz30) { - - if ( (min_channel_bw == bw_5MHz) || (min_channel_bw == bw_10MHz) ) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_4_NUM_INDEXES; - mux_pattern = table_38213_13_4_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else if (min_channel_bw == bw_40MHz) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_6_NUM_INDEXES; - mux_pattern = table_38213_13_6_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else { - AssertFatal(true,"Invalid min_bandwidth\n"); - } - - } else { - AssertFatal(true,"Invalid subCarrierSpacingCommon\n"); - } - break; - - case NR_SubcarrierSpacing_kHz120: - if (subCarrierSpacingCommon == NR_SubcarrierSpacing_kHz60) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_7_NUM_INDEXES; - mux_pattern = table_38213_13_7_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else if (subCarrierSpacingCommon == NR_SubcarrierSpacing_kHz120) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_8_NUM_INDEXES; - mux_pattern = table_38213_13_8_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else { - AssertFatal(true,"Invalid subCarrierSpacingCommon\n"); - } - break; - - case NR_SubcarrierSpacing_kHz240: - if (subCarrierSpacingCommon == NR_SubcarrierSpacing_kHz60) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_9_NUM_INDEXES; - mux_pattern = table_38213_13_9_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else if (subCarrierSpacingCommon == NR_SubcarrierSpacing_kHz120) { - pdcch_ConfigSIB1->controlResourceSetZero = rand() % TABLE_38213_13_10_NUM_INDEXES; - mux_pattern = table_38213_13_10_c1[pdcch_ConfigSIB1->controlResourceSetZero]; - } else { - AssertFatal(true,"Invalid subCarrierSpacingCommon\n"); - } - break; - - default: - AssertFatal(true,"Invalid ssbSubcarrierSpacing\n"); - break; - } - - - frequency_range_t frequency_range = FR1; - if(ssbSubcarrierSpacing>=60) { - frequency_range = FR2; - } - - pdcch_ConfigSIB1->searchSpaceZero = 0; - if(mux_pattern == NR_SSB_AND_CSET_MUX_PATTERN_TYPE1 && frequency_range == FR1){ - pdcch_ConfigSIB1->searchSpaceZero = rand() % TABLE_38213_13_11_NUM_INDEXES; - } - if(mux_pattern == NR_SSB_AND_CSET_MUX_PATTERN_TYPE1 && frequency_range == FR2){ - pdcch_ConfigSIB1->searchSpaceZero = rand() % TABLE_38213_13_12_NUM_INDEXES; - } - - return 0; -} int nr_rrc_mac_remove_ue(module_id_t mod_idP, @@ -227,14 +131,6 @@ uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP, rrc_gNB_carrier_data_t *carrier = &RC.nrrrc[Mod_idP]->carrier; NR_BCCH_BCH_Message_t *mib = &carrier->mib; - // Currently we are getting the pdcch_ConfigSIB1 from the configuration file. - // Uncomment this function for a dynamic pdcch_ConfigSIB1. - //channel_bandwidth_t min_channel_bw = bw_10MHz; // Must be obtained based on TS 38.101-1 Table 5.3.5-1 - //generate_pdcch_ConfigSIB1(carrier->pdcch_ConfigSIB1, - // *carrier->servingcellconfigcommon->ssbSubcarrierSpacing, - // carrier->mib.message.choice.mib->subCarrierSpacingCommon, - // min_channel_bw); - mib->message.choice.mib->pdcch_ConfigSIB1.controlResourceSetZero = carrier->pdcch_ConfigSIB1->controlResourceSetZero; mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero = carrier->pdcch_ConfigSIB1->searchSpaceZero; From 47d604b41f4800af71ade6caa883e78a0bfa71b8 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Mon, 1 Aug 2022 10:35:08 +0100 Subject: [PATCH 65/71] Improve SIB1 length to support maximum value specified in 3GPP TS 38.331 section 5.2.1 The physical layer imposes a limit to the maximum size a SIB can take. The maximum SIB1 or SI message size is 2976 bits. --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 7 ++++--- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 12 ++++-------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 4 +--- openair2/RRC/NR/nr_rrc_defs.h | 2 +- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 828cb2b880..b26e89624c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -285,7 +285,7 @@ uint32_t schedule_control_sib1(module_id_t module_id, int nrOfSymbols, uint16_t dlDmrsSymbPos, uint8_t candidate_idx, - int num_total_bytes) { + uint16_t num_total_bytes) { gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; NR_COMMON_channels_t *cc = &gNB_mac->common_channels[CC_id]; @@ -570,7 +570,7 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) // Get SIB1 uint8_t sib1_payload[NR_MAX_SIB_LENGTH/8]; - uint8_t sib1_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, BCCH, SI_RNTI, 1, sib1_payload); + uint16_t sib1_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, BCCH, SI_RNTI, 1, sib1_payload); LOG_D(NR_MAC,"sib1_sdu_length = %i\n", sib1_sdu_length); LOG_D(NR_MAC,"SIB1: \n"); for (int k=0;kDL_req[CC_id].dl_tti_request_body; int pdu_index = gNB_mac->pdu_index[0]++; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 83097ae260..49c6909a4c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -93,7 +93,7 @@ uint32_t schedule_control_sib1(module_id_t module_id, int nrOfSymbols, uint16_t dlDmrsSymbPos, uint8_t candidate_idx, - int num_total_bytes); + uint16_t num_total_bytes); /* \brief default FR1 DL preprocessor init routine, returns preprocessor to call */ nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index ff139c9895..687784cafc 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -306,9 +306,8 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { return((enc_rval.encoded+7)/8); } -uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, - gNB_RrcConfigurationReq *configuration - ) { +uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, gNB_RrcConfigurationReq *configuration) { + asn_enc_rval_t enc_rval; NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t)); @@ -661,12 +660,9 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, (void *)sib1_message, carrier->SIB1, NR_MAX_SIB_LENGTH/8); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + AssertFatal(enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - - if (enc_rval.encoded==-1) { - return(-1); - } + AssertFatal(enc_rval.encoded <= NR_MAX_SIB_LENGTH, "ASN1 encoded length %zd bits. 3GPP TS 38.331 section 5.2.1 - The physical layer imposes a limit to the maximum size a SIB can take. The maximum SIB1 or SI message size is 2976 bits.\n", enc_rval.encoded); return((enc_rval.encoded+7)/8); } diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 7dfbabf6bb..ea4b185f6b 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -73,9 +73,7 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc, @param carrier pointer to Carrier information @param configuration Pointer Configuration Request structure @return size of encoded bit stream in bytes*/ -uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, - gNB_RrcConfigurationReq *configuration - ); +uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, gNB_RrcConfigurationReq *configuration); uint8_t do_SIB23_NR(rrc_gNB_carrier_data_t *carrier, gNB_RrcConfigurationReq *configuration); diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 1b322ed925..b6a92db7a8 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -435,7 +435,7 @@ typedef struct { uint8_t sizeof_MIB; uint8_t *SIB1; - uint8_t sizeof_SIB1; + uint16_t sizeof_SIB1; uint8_t *SIB23; uint8_t sizeof_SIB23; From 9e5a77e6e363318a911c3e1e975fa7cbc1588438 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 1 Aug 2022 15:59:16 +0200 Subject: [PATCH 66/71] Remove max number of HARQ rounds from L1 Contributors: francescomani Rodolphe Bertolini --- openair1/PHY/INIT/nr_init_ue.c | 13 ------------- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 1 - openair1/PHY/NR_TRANSPORT/nr_ulsch.c | 18 +++++++++++++----- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 3 --- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 9 --------- openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 12 ++---------- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 4 ---- openair1/PHY/defs_gNB.h | 6 ------ openair1/PHY/defs_nr_UE.h | 4 ++-- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 18 +----------------- openair1/SCHED_NR_UE/harq_nr.c | 13 ++++++------- 11 files changed, 24 insertions(+), 77 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index a332c2067c..7691ca592e 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -34,19 +34,6 @@ #include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/MODULATION/nr_modulation.h" -#if 0 -void phy_config_harq_ue(module_id_t Mod_id, - int CC_id, - uint8_t gNB_id, - uint16_t max_harq_tx) { - int num_of_threads,num_of_code_words; - PHY_VARS_NR_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; - - for (num_of_threads=0; num_of_threadsulsch[num_of_threads][gNB_id][num_of_code_words]->Mlimit = max_harq_tx; -} -#endif extern uint16_t beta_cqi[16]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index f0f9f4fe34..8672f3ae29 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -123,7 +123,6 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, bzero(dlsch,sizeof(NR_gNB_DLSCH_t)); dlsch->Kmimo = Kmimo; dlsch->Mdlharq = Mdlharq; - dlsch->Mlimit = 4; dlsch->Nsoft = Nsoft; int txdataf_size = frame_parms->N_RB_DL*NR_SYMBOLS_PER_SLOT*NR_NB_SC_PER_RB*8; // max pdsch encoded length for each layer diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index 5c6839366c..e56a4607e2 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -68,12 +68,20 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, ulsch->rnti = ulsch_pdu->rnti; //ulsch->rnti_type; ulsch->harq_mask |= 1<harq_process_id[slot] = harq_pid; - ulsch->harq_processes[harq_pid]->frame=frame; - ulsch->harq_processes[harq_pid]->slot=slot; - ulsch->harq_processes[harq_pid]->handled= 0; - ulsch->harq_processes[harq_pid]->status= NR_ACTIVE; + NR_UL_gNB_HARQ_t *harq = ulsch->harq_processes[harq_pid]; + harq->frame=frame; + harq->slot=slot; + harq->handled = 0; + harq->status= NR_ACTIVE; + harq->new_rx = harq->ndi != ulsch_pdu->pusch_data.new_data_indicator; + if (harq->new_rx) { + harq->ndi = ulsch_pdu->pusch_data.new_data_indicator; + harq->round = 0; + } else { + harq->round++; + } + memcpy((void*)&ulsch->harq_processes[harq_pid]->ulsch_pdu, (void*)ulsch_pdu, sizeof(nfapi_nr_pusch_pdu_t)); LOG_D(PHY,"Initializing nFAPI for ULSCH, UE %d, harq_pid %d\n",ulsch_id,harq_pid); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index b9a1430be6..ef5c0c069e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -101,7 +101,6 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL) ulsch = (NR_gNB_ULSCH_t *)malloc16_clear(sizeof(NR_gNB_ULSCH_t)); ulsch->max_ldpc_iterations = max_ldpc_iterations; - ulsch->Mlimit = 4; for (i=0; irnti_type = 0; ulsch->cyclicShift = 0; ulsch->cooperation_flag = 0; - ulsch->Mlimit = 0; ulsch->max_ldpc_iterations = 0; ulsch->last_iteration_cnt = 0; - for (i=0;iharq_process_id[i] = 0; for (i=0; iharq_processes[i]){ diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 403f016e79..1635c8bba9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -140,7 +140,6 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint dlsch->Mdlharq = Mdlharq; dlsch->number_harq_processes_for_pdsch = Mdlharq; dlsch->Nsoft = Nsoft; - dlsch->Mlimit = 4; dlsch->max_ldpc_iterations = max_ldpc_iterations; for (int i=0; iround %d\n", // phy_vars_ue->Mod_id,nr_slot_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round); harq_process->status = SCH_IDLE; - harq_process->DLround = 0; harq_process->ack = 1; //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d)\n", @@ -237,11 +235,6 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool //LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n", // phy_vars_ue->Mod_id, frame, nr_slot_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round); harq_process->ack = 0; - if (harq_process->DLround >= dlsch->Mlimit) { - harq_process->status = SCH_IDLE; - harq_process->DLround = 0; - phy_vars_ue->dl_stats[4]++; - } //if(is_crnti) { // LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for nr_slot_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", @@ -496,8 +489,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } */ nb_rb = harq_process->nb_rb; - harq_process->trials[harq_process->DLround]++; - A = harq_process->TBS; ret = dlsch->max_ldpc_iterations + 1; dlsch->last_iteration_cnt = ret; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index fd8eada245..96f31a1624 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -161,15 +161,13 @@ typedef struct { //uint8_t num_cba_dci[10]; /// allocated CBA RNTI //uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; - /// UL max-harq-retransmission - uint16_t Mlimit; } NR_UE_ULSCH_t; typedef struct { /// Indicator of first reception uint8_t first_rx; /// Last Ndi received for this process on DCI (used for C-RNTI only) - uint8_t DCINdi; + uint8_t Ndi; /// DLSCH status flag indicating SCH_status_t status; /// Transport block size @@ -241,10 +239,6 @@ typedef struct { vrb_t vrb_type; /// downlink power offset field uint8_t dl_power_off; - /// trials per round statistics - uint32_t trials[8]; - /// error statistics per round - uint32_t errors[8]; /// codeword this transport block is mapped to uint8_t codeword; /// HARQ-ACKs @@ -311,9 +305,7 @@ typedef struct { /// Maximum number of LDPC iterations uint8_t max_ldpc_iterations; /// number of iterations used in last turbo decoding - uint8_t last_iteration_cnt; - /// Maximum number of HARQ rounds - uint8_t Mlimit; + uint8_t last_iteration_cnt; } NR_UE_DLSCH_t; typedef enum {format0_0, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index d09f2554cc..ef952b0152 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -130,10 +130,6 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids, NR_DL_ memset(ulsch, 0, sizeof(*ulsch)); ulsch->number_harq_processes_for_pusch = NR_MAX_ULSCH_HARQ_PROCESSES; - ulsch->Mlimit = 4; // maximum harq retransmissions - - //for (i=0; i<10; i++) - //ulsch->harq_ids[i] = 0; for (int i = 0; i < number_of_harq_pids; i++) { diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 9ed6f50616..32c9af84cf 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -188,8 +188,6 @@ typedef struct { uint8_t codebook_index; /// Maximum number of HARQ processes uint8_t Mdlharq; - /// Maximum number of HARQ rounds - uint8_t Mlimit; /// MIMO transmission mode indicator for this sub-frame uint8_t Kmimo; /// Nsoft parameter related to UE Category @@ -345,8 +343,6 @@ typedef struct { typedef struct { /// Pointers to 16 HARQ processes for the ULSCH NR_UL_gNB_HARQ_t *harq_processes[NR_MAX_ULSCH_HARQ_PROCESSES]; - /// Current HARQ process id - int harq_process_id[NR_MAX_SLOTS_PER_FRAME]; /// HARQ process mask, indicates which processes are currently active uint16_t harq_mask; /// ACK/NAK Bundling flag @@ -373,8 +369,6 @@ typedef struct { uint8_t cyclicShift; /// for cooperative communication uint8_t cooperation_flag; - /// Maximum number of HARQ rounds - uint8_t Mlimit; /// Maximum number of LDPC iterations uint8_t max_ldpc_iterations; /// number of iterations used in last LDPC decoding diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index bd6808c54d..890e4e2ed0 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -978,8 +978,8 @@ typedef struct { SLIST_HEAD(ral_thresholds_gen_poll_s, ral_threshold_phy_t) ral_thresholds_gen_polled[RAL_LINK_PARAM_GEN_MAX]; SLIST_HEAD(ral_thresholds_lte_poll_s, ral_threshold_phy_t) ral_thresholds_lte_polled[RAL_LINK_PARAM_LTE_MAX]; #endif - - int dl_stats[5]; + int dl_errors; + int dl_stats[8]; void* scopeData; } PHY_VARS_NR_UE; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index ca0cd380d2..6d833a530a 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -242,13 +242,6 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { ulsch_harq->ulsch_pdu.rb_size, ulsch_harq->TBS, r); - ulsch_harq->round++; - if (ulsch_harq->round >= ulsch->Mlimit) { - ulsch_harq->status = SCH_IDLE; - ulsch_harq->round = 0; - ulsch_harq->handled = 0; - ulsch->harq_mask &= ~(1 << rdata->harq_pid); - } ulsch_harq->handled = 1; LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id); @@ -413,17 +406,8 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, if (timing_advance_update > 63) timing_advance_update = 63; if (crc_flag == 0) LOG_D(PHY, "%d.%d : Received PUSCH : Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n", frame,slot_rx,sync_pos,timing_advance_update); - else if (harq_process->round>0 || dtx_flag == 0) { // increment round if crc_flag == 1 and not(dtx_flag ==1 and round==0) - harq_process->round++; - if (harq_process->round >= ulsch->Mlimit) { - harq_process->status = SCH_IDLE; - harq_process->round = 0; - harq_process->handled = 0; - ulsch->harq_mask &= ~(1 << harq_pid); - } - } - // estimate UL_CQI for MAC + // estimate UL_CQI for MAC int SNRtimes10 = dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot) - dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot); diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index a9ff01d78a..795cea5dfa 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -308,7 +308,7 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) dl_harq->status = SCH_IDLE; dl_harq->first_rx = 1; dl_harq->DLround = 0; - dl_harq->DCINdi = 1; + dl_harq->Ndi = 1; dl_harq->ack = DL_ACKNACK_NO_SET; } @@ -329,7 +329,7 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) * *********************************************************************/ -void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, int rv, uint8_t rnti_type) { +void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int dci_ndi, int rv, uint8_t rnti_type) { if (rnti_type == _SI_RNTI_ || rnti_type == _P_RNTI_ || @@ -339,10 +339,9 @@ void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, int dl_harq->first_rx = 1; } else { LOG_D(PHY,"receive harq process: %p harqPid=%d, rv=%d, ndi=%d, rntiType=%d new transmission= %s\n", - dl_harq, harq_pid, rv, ndi, rnti_type, dl_harq->DCINdi != ndi ? "yes":"no"); + dl_harq, harq_pid, rv, dci_ndi, rnti_type, dl_harq->Ndi != dci_ndi ? "yes":"no"); AssertFatal(rv<4 && rv>=0, "invalid redondancy version %d\n", rv); - - if (ndi!=dl_harq->DCINdi) { + if (dci_ndi!=dl_harq->Ndi) { if (dl_harq->ack == DL_NACK) LOG_D(PHY,"New transmission on a harq pid (%d) never acknowledged\n", harq_pid); else @@ -354,7 +353,7 @@ void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, int LOG_D(PHY,"Starting retransmission on a harq pid (%d), rv (%d)\n", harq_pid, rv); } - if (ndi!=dl_harq->DCINdi) { + if (dci_ndi!=dl_harq->Ndi) { dl_harq->first_rx = true; dl_harq->DLround = 0; } else { @@ -364,7 +363,7 @@ void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, int dl_harq->status = ACTIVE; - dl_harq->DCINdi = ndi; + dl_harq->Ndi = dci_ndi; //dl_harq->status = SCH_IDLE; } } From 989c22a46c311e51cfca30c7c697da8ff89f8dd7 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 1 Aug 2022 16:05:26 +0200 Subject: [PATCH 67/71] Limit RV to interval of 0..3 Contributors francescomani Rodolphe Bertolini --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 9 ++++++--- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 6 +++--- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 6 +++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 6daa68afed..ef7c91151b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1090,13 +1090,16 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, pusch_pdu->vrb_to_prb_mapping = 0; pusch_pdu->frequency_hopping = fh; - //pusch_pdu->tx_direct_current_location;//The uplink Tx Direct Current location for the carrier. Only values in the value range of this field between 0 and 3299, which indicate the subcarrier index within the carrier corresponding 1o the numerology of the corresponding uplink BWP and value 3300, which indicates "Outside the carrier" and value 3301, which indicates "Undetermined position within the carrier" are used. [TS38.331, UplinkTxDirectCurrentBWP IE] + //pusch_pdu->tx_direct_current_location; + //The uplink Tx Direct Current location for the carrier. Only values in the value range of this field between 0 and 3299, + //which indicate the subcarrier index within the carrier corresponding 1o the numerology of the corresponding uplink BWP and value 3300, + //which indicates "Outside the carrier" and value 3301, which indicates "Undetermined position within the carrier" are used. [TS38.331, UplinkTxDirectCurrentBWP IE] pusch_pdu->uplink_frequency_shift_7p5khz = 0; //Resource Allocation in time domain pusch_pdu->start_symbol_index = start_symbol_index; pusch_pdu->nr_of_symbols = nr_of_symbols; //Optional Data only included if indicated in pduBitmap - pusch_pdu->pusch_data.rv_index = nr_rv_round_map[round]; + pusch_pdu->pusch_data.rv_index = nr_rv_round_map[round%4]; pusch_pdu->pusch_data.harq_process_id = 0; pusch_pdu->pusch_data.new_data_indicator = 1; pusch_pdu->pusch_data.num_cb = 0; @@ -1804,7 +1807,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; - pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[harq->round]; + pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[harq->round%4]; pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; pdsch_pdu_rel15->nrOfLayers = 1; pdsch_pdu_rel15->transmissionScheme = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 828cb2b880..398f19d43a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -437,7 +437,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = gNB_mac->sched_ctrlCommon->sched_pdsch.mcs; pdsch_pdu_rel15->mcsTable[0] = 0; - pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[0]; + pdsch_pdu_rel15->rvIndex[0] = 0; pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; pdsch_pdu_rel15->nrOfLayers = 1; pdsch_pdu_rel15->transmissionScheme = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index d32709e731..c055638bf5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1017,7 +1017,7 @@ void nr_schedule_ue_spec(module_id_t module_id, TBS, current_harq_pid, harq->round, - nr_rv_round_map[harq->round], + nr_rv_round_map[harq->round%4], harq->ndi, pucch->timing_indicator, pucch->frame, @@ -1085,8 +1085,8 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->mcsIndex[0] = sched_pdsch->mcs; pdsch_pdu->mcsTable[0] = ps->mcsTableIdx; AssertFatal(harq!=NULL,"harq is null\n"); - AssertFatal(harq->round<4,"%d",harq->round); - pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round]; + AssertFatal(harq->roundharq_round_max,"%d",harq->round); + pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round%4]; pdsch_pdu->TBSize[0] = TBS; pdsch_pdu->dataScramblingId = *scc->physCellId; pdsch_pdu->nrOfLayers = nrOfLayers; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index f654e8e1a6..def298cad0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1672,7 +1672,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) sched_pusch->tb_size, harq_id, cur_harq->round, - nr_rv_round_map[cur_harq->round], + nr_rv_round_map[cur_harq->round%4], cur_harq->ndi, sched_ctrl->estimated_ul_buffer, sched_ctrl->sched_ul_bytes, @@ -1768,8 +1768,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->nr_of_symbols = ps->nrOfSymbols; /* PUSCH PDU */ - AssertFatal(cur_harq->round < 4, "Indexing nr_rv_round_map[%d] is out of bounds\n", cur_harq->round); - pusch_pdu->pusch_data.rv_index = nr_rv_round_map[cur_harq->round]; + AssertFatal(cur_harq->round < nr_mac->harq_round_max, "Indexing nr_rv_round_map[%d] is out of bounds\n", cur_harq->round%4); + pusch_pdu->pusch_data.rv_index = nr_rv_round_map[cur_harq->round%4]; pusch_pdu->pusch_data.harq_process_id = harq_id; pusch_pdu->pusch_data.new_data_indicator = cur_harq->ndi; pusch_pdu->pusch_data.tb_size = sched_pusch->tb_size; From 4ad4edb8715871ece417dc902b641818ee7cfebd Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 1 Aug 2022 16:03:17 +0200 Subject: [PATCH 68/71] Log arbitrary number of HARQ rounds Contributors francescomani Robert Schmidt --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 12 +++++- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/NR_MAC_gNB/main.c | 42 ++++++++++++-------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 38fa3880bb..c431c6653c 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1476,7 +1476,17 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if ((frame_rx%64 == 0) && (nr_slot_rx==0)) { LOG_I(NR_PHY,"============================================\n"); - LOG_I(NR_PHY,"Harq round stats for Downlink: %d/%d/%d/%d DLSCH errors: %d\n",ue->dl_stats[0],ue->dl_stats[1],ue->dl_stats[2],ue->dl_stats[3],ue->dl_stats[4]); + // fixed text + 8 HARQs rounds à 10 ("999999999/") + NULL + // if we use 999999999 HARQs, that should be sufficient for at least 138 hours + const size_t harq_output_len = 31 + 10 * 8 + 1; + char output[harq_output_len]; + char *p = output; + const char *end = output + harq_output_len; + p += snprintf(p, end - p, "Harq round stats for Downlink: %d", ue->dl_stats[0]); + for (int round = 1; round < 16 && (round < 3 || ue->dl_stats[round] != 0); ++round) + p += snprintf(p, end - p,"/%d", ue->dl_stats[round]); + LOG_I(NR_PHY,"%s/0\n", output); + LOG_I(NR_PHY,"============================================\n"); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index ccb1b4e72a..1759f55995 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -3586,7 +3586,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, #endif */ - LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d\n", frameP, slot, ul_time_alignment->ta_command, ul_time_alignment->tag_id, CC_id); + LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d\n", frameP, slot, ul_time_alignment->ta_command, ul_time_alignment->tag_id, CC_id); break; case DL_SCH_LCID_CON_RES_ID: diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 45df6291f4..50434b26b3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -105,17 +105,21 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset end - output, "UE %04x: CQI %d, RI %d, PMI (%d,%d)\n", UE->rnti, - UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb, - UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.ri+1, - UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1, - UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2); + sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb, + sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.ri+1, + sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1, + sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2); output += snprintf(output, end - output, - "UE %04x: dlsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n", - UE->rnti, - stats->dl.rounds[0], stats->dl.rounds[1], - stats->dl.rounds[2], stats->dl.rounds[3], + "UE %04x: dlsch_rounds ", UE->rnti); + output += snprintf(output, end - output, "%"PRIu64, stats->dl.rounds[0]); + for (int i = 1; i < gNB->harq_round_max; i++) + output += snprintf(output, end - output, "/%"PRIu64, stats->dl.rounds[i]); + + output += snprintf(output, + end - output, + ", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n", stats->dl.errors, stats->pucch0_DTX, sched_ctrl->dl_bler_stats.bler, @@ -127,23 +131,27 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset output += snprintf(output, end - output, "UE %04x: dlsch_total_bytes %"PRIu64"\n", - UE->rnti, - stats->dl.total_bytes); + UE->rnti, stats->dl.total_bytes); output += snprintf(output, end - output, - "UE %04x: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.5f MCS %d\n", - UE->rnti, - stats->ul.rounds[0], stats->ul.rounds[1], - stats->ul.rounds[2], stats->ul.rounds[3], + "UE %04x: ulsch_rounds ", UE->rnti); + output += snprintf(output, end - output, "%"PRIu64, stats->ul.rounds[0]); + for (int i = 1; i < gNB->harq_round_max; i++) + output += snprintf(output, end - output, "/%"PRIu64, stats->ul.rounds[i]); + + output += snprintf(output, + end - output, + ", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.5f MCS %d\n", stats->ulsch_DTX, stats->ul.errors, sched_ctrl->ul_bler_stats.bler, sched_ctrl->ul_bler_stats.mcs); output += snprintf(output, end - output, - "UE %04x: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n", - UE->rnti, - stats->ulsch_total_bytes_scheduled, stats->ul.total_bytes); + "UE %04x: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n", + UE->rnti, + stats->ulsch_total_bytes_scheduled, stats->ul.total_bytes); + for (int lc_id = 0; lc_id < 63; lc_id++) { if (stats->dl.lc_bytes[lc_id] > 0) output += snprintf(output, From 840cf403db721ce4f6c7c68d64e1dd9327f9968c Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 1 Aug 2022 16:06:52 +0200 Subject: [PATCH 69/71] Make max num of HARQ tx configurable per UL/DL Contributors francescomani Robert Schmidt --- openair1/SIMULATION/NR_PHY/dlsim.c | 2 + openair2/GNB_APP/MACRLC_nr_paramdef.h | 53 ++++++++++++++++--- openair2/GNB_APP/gnb_config.c | 7 ++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 7 ++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 8 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 17 +++--- openair2/LAYER2/NR_MAC_gNB/main.c | 4 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 3 +- 8 files changed, 76 insertions(+), 25 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 8500749fe2..6ebdc203c4 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -761,6 +761,8 @@ int main(int argc, char **argv) gNB_RRC_INST rrc; memset((void*)&rrc,0,sizeof(rrc)); + gNB_mac->dl_bler.harq_round_max = num_rounds; + /* // read in SCGroupConfig AssertFatal(scg_fd != NULL,"no reconfig.raw file\n"); diff --git a/openair2/GNB_APP/MACRLC_nr_paramdef.h b/openair2/GNB_APP/MACRLC_nr_paramdef.h index 4359cb0c86..0a50d19e13 100644 --- a/openair2/GNB_APP/MACRLC_nr_paramdef.h +++ b/openair2/GNB_APP/MACRLC_nr_paramdef.h @@ -67,7 +67,8 @@ #define CONFIG_STRING_MACRLC_UL_BLER_TARGET_UPPER "ul_bler_target_upper" #define CONFIG_STRING_MACRLC_UL_BLER_TARGET_LOWER "ul_bler_target_lower" #define CONFIG_STRING_MACRLC_UL_MAX_MCS "ul_max_mcs" -#define CONFIG_STRING_MACRLC_HARQ_ROUND_MAX "harq_round_max" +#define CONFIG_STRING_MACRLC_DL_HARQ_ROUND_MAX "dl_harq_round_max" +#define CONFIG_STRING_MACRLC_UL_HARQ_ROUND_MAX "ul_harq_round_max" #define CONFIG_STRING_MACRLC_MIN_GRANT_PRB "min_grant_prb" #define CONFIG_STRING_MACRLC_MIN_GRANT_MCS "min_grant_mcs" @@ -97,7 +98,7 @@ {CONFIG_STRING_MACRLC_ULSCH_MAX_FRAME_INACTIVITY, NULL, 0, uptr:NULL, defintval:10, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_PUSCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ {CONFIG_STRING_MACRLC_PUCCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:150, TYPE_INT, 0}, \ -{CONFIG_STRING_MACRLC_UL_PRBBLACK_SNR_THRESHOLD, "SNR threshold to decide whether a PRB will be blacklisted or not", 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_UL_PRBBLACK_SNR_THRESHOLD, "SNR threshold to decide whether a PRB will be blacklisted or not", 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ {CONFIG_STRING_MACRLC_PUCCHFAILURETHRES, NULL, 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ {CONFIG_STRING_MACRLC_PUSCHFAILURETHRES, NULL, 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ {CONFIG_STRING_MACRLC_DL_BLER_TARGET_UPPER, "Upper threshold of BLER to decrease DL MCS", 0, dblptr:NULL, defdblval:0.15, TYPE_DOUBLE, 0}, \ @@ -106,9 +107,10 @@ {CONFIG_STRING_MACRLC_UL_BLER_TARGET_UPPER, "Upper threshold of BLER to decrease UL MCS", 0, dblptr:NULL, defdblval:0.15, TYPE_DOUBLE, 0}, \ {CONFIG_STRING_MACRLC_UL_BLER_TARGET_LOWER, "Lower threshold of BLER to increase UL MCS", 0, dblptr:NULL, defdblval:0.05, TYPE_DOUBLE, 0}, \ {CONFIG_STRING_MACRLC_UL_MAX_MCS, "Maximum UL MCS that should be used", 0, u8ptr:NULL, defintval:9, TYPE_UINT8, 0}, \ -{CONFIG_STRING_MACRLC_HARQ_ROUND_MAX, "Maximum number of HARQ rounds", 0, u8ptr:NULL, defintval:4, TYPE_UINT8, 0}, \ +{CONFIG_STRING_MACRLC_DL_HARQ_ROUND_MAX, "Maximum number of DL HARQ rounds", 0, u8ptr:NULL, defintval:4, TYPE_UINT8, 0}, \ +{CONFIG_STRING_MACRLC_UL_HARQ_ROUND_MAX, "Maximum number of UL HARQ rounds", 0, u8ptr:NULL, defintval:4, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_MIN_GRANT_PRB, "Minimal Periodic ULSCH Grant PRBs", 0, u8ptr:NULL, defintval:5, TYPE_UINT8, 0}, \ -{CONFIG_STRING_MACRLC_MIN_GRANT_MCS, "Minimal Periodic ULSCH Grant MCS", 0, u8ptr:NULL, defintval:9, TYPE_UINT8, 0} \ +{CONFIG_STRING_MACRLC_MIN_GRANT_MCS, "Minimal Periodic ULSCH Grant MCS", 0, u8ptr:NULL, defintval:9, TYPE_UINT8, 0}, \ } #define MACRLC_CC_IDX 0 #define MACRLC_TRANSPORT_N_PREFERENCE_IDX 1 @@ -139,9 +141,46 @@ #define MACRLC_UL_BLER_TARGET_UPPER_IDX 26 #define MACRLC_UL_BLER_TARGET_LOWER_IDX 27 #define MACRLC_UL_MAX_MCS_IDX 28 -#define MACRLC_HARQ_ROUND_MAX_IDX 29 -#define MACRLC_MIN_GRANT_PRB_IDX 30 -#define MACRLC_MIN_GRANT_MCS_IDX 31 +#define MACRLC_DL_HARQ_ROUND_MAX_IDX 29 +#define MACRLC_UL_HARQ_ROUND_MAX_IDX 30 +#define MACRLC_MIN_GRANT_PRB_IDX 31 +#define MACRLC_MIN_GRANT_MCS_IDX 32 + +#define MACRLCPARAMS_CHECK { \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ + { .s2 = { config_check_intrange, {1, 8} } }, /* DL max HARQ rounds */ \ + { .s2 = { config_check_intrange, {1, 8} } }, /* UL max HARQ rounds */ \ + { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ +} /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 76b3772307..225daec37b 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -816,6 +816,10 @@ void RCconfig_nr_macrlc() { } paramdef_t MacRLC_Params[] = MACRLCPARAMS_DESC; paramlist_def_t MacRLC_ParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0}; + /* map parameter checking array instances to parameter definition array instances */ + checkedparam_t config_check_MacRLCParams [] = MACRLCPARAMS_CHECK; + for (int i = 0; i < sizeof(MacRLC_Params) / sizeof(paramdef_t); ++i) + MacRLC_Params[i].chkPptr = &(config_check_MacRLCParams[i]); config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL); if ( MacRLC_ParamList.numelt > 0) { @@ -887,11 +891,12 @@ void RCconfig_nr_macrlc() { dl_bler_options->upper = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_UPPER_IDX].dblptr); dl_bler_options->lower = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_LOWER_IDX].dblptr); dl_bler_options->max_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_MAX_MCS_IDX].u8ptr); + dl_bler_options->harq_round_max = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_HARQ_ROUND_MAX_IDX].u8ptr); NR_bler_options_t *ul_bler_options = &RC.nrmac[j]->ul_bler; ul_bler_options->upper = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_BLER_TARGET_UPPER_IDX].dblptr); ul_bler_options->lower = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_BLER_TARGET_LOWER_IDX].dblptr); ul_bler_options->max_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_MAX_MCS_IDX].u8ptr); - RC.nrmac[j]->harq_round_max = *(MacRLC_ParamList.paramarray[j][MACRLC_HARQ_ROUND_MAX_IDX].u8ptr); + ul_bler_options->harq_round_max = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_HARQ_ROUND_MAX_IDX].u8ptr); RC.nrmac[j]->min_grant_prb = *(MacRLC_ParamList.paramarray[j][MACRLC_MIN_GRANT_PRB_IDX].u8ptr); RC.nrmac[j]->min_grant_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_MIN_GRANT_MCS_IDX].u8ptr); RC.nrmac[j]->num_ulprbbl = num_prbbl; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index c055638bf5..5027a77de8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -643,7 +643,10 @@ void pf_dl(module_id_t module_id, const NR_bler_options_t *bo = &mac->dl_bler; const int max_mcs_table = ps->mcsTableIdx == 1 ? 27 : 28; const int max_mcs = min(sched_ctrl->dl_max_mcs, max_mcs_table); - sched_pdsch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->dl_bler_stats, max_mcs, frame); + if (bo->harq_round_max == 1) + sched_pdsch->mcs = max_mcs; + else + sched_pdsch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->dl_bler_stats, max_mcs, frame); UE->layers = set_dl_nrOfLayers(sched_ctrl); const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); @@ -1085,7 +1088,7 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->mcsIndex[0] = sched_pdsch->mcs; pdsch_pdu->mcsTable[0] = ps->mcsTableIdx; AssertFatal(harq!=NULL,"harq is null\n"); - AssertFatal(harq->roundharq_round_max,"%d",harq->round); + AssertFatal(harq->rounddl_bler.harq_round_max,"%d",harq->round); pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round%4]; pdsch_pdu->TBSize[0] = TBS; pdsch_pdu->dataScramblingId = *scc->physCellId; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index a57b04668b..4df0566c66 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1456,7 +1456,7 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, for (int harq_bit = 0; harq_bit < uci_01->harq->num_harq; harq_bit++) { const uint8_t harq_value = uci_01->harq->harq_list[harq_bit].harq_value; const uint8_t harq_confidence = uci_01->harq->harq_confidence_level; - NR_UE_harq_t *harq = find_harq(frame, slot, UE, RC.nrmac[mod_id]->harq_round_max); + NR_UE_harq_t *harq = find_harq(frame, slot, UE, RC.nrmac[mod_id]->dl_bler.harq_round_max); if (!harq) { LOG_E(NR_MAC, "Oh no! Could not find a harq in %s!\n", __FUNCTION__); break; @@ -1465,7 +1465,7 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, const int8_t pid = sched_ctrl->feedback_dl_harq.head; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); LOG_D(NR_MAC,"%4d.%2d bit %d pid %d ack/nack %d\n",frame, slot, harq_bit,pid,harq_value); - handle_dl_harq(UE, pid, harq_value == 0 && harq_confidence == 0, RC.nrmac[mod_id]->harq_round_max); + handle_dl_harq(UE, pid, harq_value == 0 && harq_confidence == 0, RC.nrmac[mod_id]->dl_bler.harq_round_max); if (harq_confidence == 1) UE->mac_stats.pucch0_DTX++; } } @@ -1518,13 +1518,13 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, // iterate over received harq bits for (int harq_bit = 0; harq_bit < uci_234->harq.harq_bit_len; harq_bit++) { const int acknack = ((uci_234->harq.harq_payload[harq_bit >> 3]) >> harq_bit) & 0x01; - NR_UE_harq_t *harq = find_harq(frame, slot, UE, RC.nrmac[mod_id]->harq_round_max); + NR_UE_harq_t *harq = find_harq(frame, slot, UE, RC.nrmac[mod_id]->dl_bler.harq_round_max); if (!harq) break; DevAssert(harq->is_waiting); const int8_t pid = sched_ctrl->feedback_dl_harq.head; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - handle_dl_harq(UE, pid, uci_234->harq.harq_crc != 1 && acknack, RC.nrmac[mod_id]->harq_round_max); + handle_dl_harq(UE, pid, uci_234->harq.harq_crc != 1 && acknack, RC.nrmac[mod_id]->dl_bler.harq_round_max); } } if ((uci_234->pduBitmap >> 2) & 0x01) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index def298cad0..fddfe6e76f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -452,7 +452,7 @@ void handle_nr_ul_harq(const int CC_idP, remove_front_nr_list(&sched_ctrl->feedback_ul_harq); sched_ctrl->ul_harq_processes[harq_pid].is_waiting = false; - if(sched_ctrl->ul_harq_processes[harq_pid].round >= RC.nrmac[mod_id]->harq_round_max - 1) { + if(sched_ctrl->ul_harq_processes[harq_pid].round >= RC.nrmac[mod_id]->ul_bler.harq_round_max - 1) { abort_nr_ul_harq(UE, harq_pid); } else { sched_ctrl->ul_harq_processes[harq_pid].round++; @@ -473,7 +473,7 @@ void handle_nr_ul_harq(const int CC_idP, harq_pid, crc_pdu->rnti); add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); - } else if (harq->round >= RC.nrmac[mod_id]->harq_round_max - 1) { + } else if (harq->round >= RC.nrmac[mod_id]->ul_bler.harq_round_max - 1) { abort_nr_ul_harq(UE, harq_pid); LOG_D(NR_MAC, "RNTI %04x: Ulharq id %d crc failed in all rounds\n", @@ -749,8 +749,8 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, return; } - if (ra->msg3_round >= MAX_HARQ_ROUNDS - 1) { - LOG_D(NR_MAC, "Random Access %i failed at state %i (Reached msg3 max harq rounds)\n", i, ra->state); + if (ra->msg3_round >= gNB_mac->ul_bler.harq_round_max - 1) { + LOG_W(NR_MAC, "Random Access %i failed at state %i (Reached msg3 max harq rounds)\n", i, ra->state); nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); return; @@ -1148,7 +1148,10 @@ void pf_ul(module_id_t module_id, const NR_bler_options_t *bo = &nrmac->ul_bler; const int max_mcs = bo->max_mcs; /* no per-user maximum MCS yet */ - sched_pusch->mcs = get_mcs_from_bler(bo, stats, &UE->UE_sched_ctrl.ul_bler_stats, max_mcs, frame); + if (bo->harq_round_max == 1) + sched_pusch->mcs = max_mcs; + else + sched_pusch->mcs = get_mcs_from_bler(bo, stats, &UE->UE_sched_ctrl.ul_bler_stats, max_mcs, frame); /* Schedule UE on SR or UL inactivity and no data (otherwise, will be scheduled * based on data to transmit) */ @@ -1626,7 +1629,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; /* Statistics */ - AssertFatal(cur_harq->round < 8, "Indexing ulsch_rounds[%d] is out of bounds\n", cur_harq->round); + AssertFatal(cur_harq->round < nr_mac->ul_bler.harq_round_max, "Indexing ulsch_rounds[%d] is out of bounds\n", cur_harq->round); UE->mac_stats.ul.rounds[cur_harq->round]++; if (cur_harq->round == 0) { UE->mac_stats.ulsch_total_bytes_scheduled += sched_pusch->tb_size; @@ -1768,7 +1771,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->nr_of_symbols = ps->nrOfSymbols; /* PUSCH PDU */ - AssertFatal(cur_harq->round < nr_mac->harq_round_max, "Indexing nr_rv_round_map[%d] is out of bounds\n", cur_harq->round%4); + AssertFatal(cur_harq->round < nr_mac->ul_bler.harq_round_max, "Indexing nr_rv_round_map[%d] is out of bounds\n", cur_harq->round%4); pusch_pdu->pusch_data.rv_index = nr_rv_round_map[cur_harq->round%4]; pusch_pdu->pusch_data.harq_process_id = harq_id; pusch_pdu->pusch_data.new_data_indicator = cur_harq->ndi; diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 50434b26b3..12c9846037 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -114,7 +114,7 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset end - output, "UE %04x: dlsch_rounds ", UE->rnti); output += snprintf(output, end - output, "%"PRIu64, stats->dl.rounds[0]); - for (int i = 1; i < gNB->harq_round_max; i++) + for (int i = 1; i < gNB->dl_bler.harq_round_max; i++) output += snprintf(output, end - output, "/%"PRIu64, stats->dl.rounds[i]); output += snprintf(output, @@ -136,7 +136,7 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset end - output, "UE %04x: ulsch_rounds ", UE->rnti); output += snprintf(output, end - output, "%"PRIu64, stats->ul.rounds[0]); - for (int i = 1; i < gNB->harq_round_max; i++) + for (int i = 1; i < gNB->ul_bler.harq_round_max; i++) output += snprintf(output, end - output, "/%"PRIu64, stats->ul.rounds[i]); output += snprintf(output, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 1ae8767d10..d8f2a79b07 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -75,7 +75,6 @@ #define MAX_NUM_BWP 5 #define MAX_NUM_CORESET 12 #define MAX_NUM_CCE 90 -#define MAX_HARQ_ROUNDS 4 /*!\brief Maximum number of random access process */ #define NR_NB_RA_PROC_MAX 4 #define MAX_NUM_OF_SSB 64 @@ -700,6 +699,7 @@ typedef struct NR_bler_options { double upper; double lower; uint8_t max_mcs; + uint8_t harq_round_max; } NR_bler_options_t; /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ @@ -854,7 +854,6 @@ typedef struct gNB_MAC_INST_s { bool first_MIB; NR_bler_options_t dl_bler; NR_bler_options_t ul_bler; - uint8_t harq_round_max; uint8_t min_grant_prb; uint8_t min_grant_mcs; } gNB_MAC_INST; From 7a6f9659bcddfa8b11d5701ca586e50f2c70cd24 Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 29 Jul 2022 14:00:37 +0200 Subject: [PATCH 70/71] gtp-u pdu session extension header implementation, this extension header is mantadory in 5G --- openair1/SIMULATION/NR_PHY/dlsim.c | 14 +- openair1/SIMULATION/NR_PHY/prachsim.c | 14 +- openair1/SIMULATION/NR_PHY/ulsim.c | 14 +- openair2/COMMON/gtpv1_u_messages_types.h | 1 + openair2/F1AP/f1ap_cu_ue_context_management.c | 38 +-- openair2/F1AP/f1ap_du_ue_context_management.c | 36 +-- openair2/RRC/NR/rrc_gNB.c | 43 ++-- openair2/RRC/NR/rrc_gNB_NGAP.c | 6 +- openair3/ocp-gtpu/gtp_itf.cpp | 223 ++++++++++-------- openair3/ocp-gtpu/gtp_itf.h | 12 +- 10 files changed, 238 insertions(+), 163 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 8500749fe2..5abda203f2 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -100,9 +100,17 @@ nfapi_ue_release_request_body_t release_rntis; //Fixme: Uniq dirty DU instance, by global var, datamodel need better management instance_t DUuniqInstance=0; instance_t CUuniqInstance=0; -teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_bearer_id, teid_t outgoing_teid, - transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { -return 0; +teid_t newGtpuCreateTunnel(instance_t instance, + rnti_t rnti, + int incoming_bearer_id, + int outgoing_bearer_id, + teid_t outgoing_teid, + int qfi, + transport_layer_addr_t remoteAddr, + int port, + gtpCallback callBack, + gtpCallbackSDAP callBackSDAP) { + return 0; } int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) { diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 33717c944d..76776ce110 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -92,9 +92,17 @@ int oai_nfapi_nr_rach_indication(nfapi_nr_rach_indication_t *ind) { return(0); //Fixme: Uniq dirty DU instance, by global var, datamodel need better management instance_t DUuniqInstance=0; instance_t CUuniqInstance=0; -teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_bearer_id, teid_t outgoing_teid, - transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { -return 0; +teid_t newGtpuCreateTunnel(instance_t instance, + rnti_t rnti, + int incoming_bearer_id, + int outgoing_bearer_id, + teid_t outgoing_teid, + int qfi, + transport_layer_addr_t remoteAddr, + int port, + gtpCallback callBack, + gtpCallbackSDAP callBackSDAP) { + return 0; } int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) { diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index ffb168fd68..5df89283a8 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -95,9 +95,17 @@ nfapi_ue_release_request_body_t release_rntis; //Fixme: Uniq dirty DU instance, by global var, datamodel need better management instance_t DUuniqInstance=0; instance_t CUuniqInstance=0; -teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_bearer_id, teid_t outgoing_teid, - transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { -return 0; +teid_t newGtpuCreateTunnel(instance_t instance, + rnti_t rnti, + int incoming_bearer_id, + int outgoing_bearer_id, + teid_t outgoing_teid, + int qfi, + transport_layer_addr_t remoteAddr, + int port, + gtpCallback callBack, + gtpCallbackSDAP callBackSDAP) { + return 0; } int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) { diff --git a/openair2/COMMON/gtpv1_u_messages_types.h b/openair2/COMMON/gtpv1_u_messages_types.h index 4111b00024..7758395ee4 100644 --- a/openair2/COMMON/gtpv1_u_messages_types.h +++ b/openair2/COMMON/gtpv1_u_messages_types.h @@ -181,6 +181,7 @@ typedef struct gtpv1u_gnb_create_tunnel_req_s { int num_tunnels; //teid_t upf_NGu_teid[NR_GTPV1U_MAX_BEARERS_PER_UE]; ///< Tunnel Endpoint Identifier teid_t outgoing_teid[NR_GTPV1U_MAX_BEARERS_PER_UE]; + int outgoing_qfi[NR_GTPV1U_MAX_BEARERS_PER_UE]; pdusessionid_t pdusession_id[NR_GTPV1U_MAX_BEARERS_PER_UE]; ebi_t incoming_rb_id[NR_GTPV1U_MAX_BEARERS_PER_UE]; //ebi_t outgoing_rb_id[NR_GTPV1U_MAX_BEARERS_PER_UE]; diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 859a9f5e0d..0f3959d4ad 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -515,15 +515,16 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, int sz=sizeof(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address); memcpy(addr.buffer,&f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address, sz); addr.length = sz*8; - f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].teid= - newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, - f1ap_ue_context_setup_req->rnti, - f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, - f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, - 0xFFFF, // We will set the right value from DU answer - addr, - f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].port, - cu_f1u_data_req); + f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].teid = newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, + f1ap_ue_context_setup_req->rnti, + f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, + f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, + 0xFFFF, // We will set the right value from DU answer + -1, // no qfi + addr, + f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].port, + cu_f1u_data_req, + NULL); /* 12.3.1 ULTunnels_ToBeSetup_Item */ asn1cSequenceAdd(drbs_toBeSetup_item->uLUPTNLInformation_ToBeSetup_List.list, F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); @@ -1491,15 +1492,16 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, f1ap_ue_context memcpy(addr.buffer,&f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address, sz); addr.length = sz*8; - f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].teid= - newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, - f1ap_ue_context_modification_req->rnti, - f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id, - f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id, - 0xFFFF, // We will set the right value from DU answer - addr, - f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].port, - cu_f1u_data_req); + f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_ul_tnl[j].teid = newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, + f1ap_ue_context_modification_req->rnti, + f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id, + f1ap_ue_context_modification_req->drbs_to_be_setup[i].drb_id, + 0xFFFF, // We will set the right value from DU answer + -1, // no qfi + addr, + f1ap_ue_context_modification_req->drbs_to_be_setup[i].up_dl_tnl[0].port, + cu_f1u_data_req, + NULL); /* 12.3.1 ULTunnels_ToBeSetup_Item */ asn1cSequenceAdd(drbs_toBeSetupMod_item->uLUPTNLInformation_ToBeSetup_List.list, F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 74e0200f09..cb15862921 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -187,14 +187,16 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, transport_layer_addr_t addr; memcpy(addr.buffer, &drb_p->up_ul_tnl[0].tl_address, sizeof(drb_p->up_ul_tnl[0].tl_address)); addr.length=sizeof(drb_p->up_ul_tnl[0].tl_address)*8; - drb_p->up_dl_tnl[0].teid=newGtpuCreateTunnel(INSTANCE_DEFAULT, - f1ap_ue_context_setup_req->rnti, - drb_p->drb_id, - drb_p->drb_id, - drb_p->up_ul_tnl[0].teid, - addr, - drb_p->up_ul_tnl[0].port, - lteDURecvCb); + drb_p->up_dl_tnl[0].teid = newGtpuCreateTunnel(INSTANCE_DEFAULT, + f1ap_ue_context_setup_req->rnti, + drb_p->drb_id, + drb_p->drb_id, + drb_p->up_ul_tnl[0].teid, + -1, // no qfi + addr, + drb_p->up_ul_tnl[0].port, + lteDURecvCb, + NULL); drb_p->up_dl_tnl_length++; } } @@ -1171,14 +1173,16 @@ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, transport_layer_addr_t addr; memcpy(addr.buffer, &drb_p->up_ul_tnl[0].tl_address, sizeof(drb_p->up_ul_tnl[0].tl_address)); addr.length=sizeof(drb_p->up_ul_tnl[0].tl_address)*8; - drb_p->up_dl_tnl[0].teid=newGtpuCreateTunnel(INSTANCE_DEFAULT, - f1ap_ue_context_modification_req->rnti, - drb_p->drb_id, - drb_p->drb_id, - drb_p->up_ul_tnl[0].teid, - addr, - drb_p->up_ul_tnl[0].port, - lteDURecvCb); + drb_p->up_dl_tnl[0].teid = newGtpuCreateTunnel(INSTANCE_DEFAULT, + f1ap_ue_context_modification_req->rnti, + drb_p->drb_id, + drb_p->drb_id, + drb_p->up_ul_tnl[0].teid, + -1, // no qfi + addr, + drb_p->up_ul_tnl[0].port, + lteDURecvCb, + NULL); drb_p->up_dl_tnl_length++; } } diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 648df1a306..8c6c583289 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1767,15 +1767,16 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( } } - gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; + gtpv1u_gnb_create_tunnel_req_t create_tunnel_req={0}; /* Save e RAB information for later */ - memset(&create_tunnel_req, 0, sizeof(create_tunnel_req)); for ( j = 0, i = 0; i < NB_RB_MAX; i++) { if (ue_context_pP->ue_context.pduSession[i].status == PDU_SESSION_STATUS_ESTABLISHED || ue_context_pP->ue_context.pduSession[i].status == PDU_SESSION_STATUS_DONE) { create_tunnel_req.pdusession_id[j] = ue_context_pP->ue_context.pduSession[i].param.pdusession_id; create_tunnel_req.incoming_rb_id[j] = i+1; create_tunnel_req.outgoing_teid[j] = ue_context_pP->ue_context.pduSession[i].param.gtp_teid; + // to be developped, use the first QFI only + create_tunnel_req.outgoing_qfi[j] = ue_context_pP->ue_context.pduSession[i].param.qos[0].qfi; memcpy(create_tunnel_req.dst_addr[j].buffer, ue_context_pP->ue_context.pduSession[i].param.upf_addr.buffer, sizeof(uint8_t)*20); @@ -2805,8 +2806,6 @@ rrc_gNB_decode_dcch( SRBs[0].lcid = 2; /*Instruction towards the DU for DRB configuration and tunnel creation*/ - gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; - memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t)); req->drbs_to_be_setup = malloc(1*sizeof(f1ap_drb_to_be_setup_t)); req->drbs_to_be_setup_length = 1; f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup; @@ -3433,14 +3432,16 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha addr.length=sizeof(drb_p.up_ul_tnl[0].tl_address)*8; extern instance_t DUuniqInstance; if (!drb_id_to_setup_start) drb_id_to_setup_start = drb_p.drb_id; - incoming_teid=newGtpuCreateTunnel(DUuniqInstance, - req->rnti, - drb_p.drb_id, - drb_p.drb_id, - drb_p.up_ul_tnl[0].teid, - addr, - drb_p.up_ul_tnl[0].port, - DURecvCb); + incoming_teid = newGtpuCreateTunnel(DUuniqInstance, + req->rnti, + drb_p.drb_id, + drb_p.drb_id, + drb_p.up_ul_tnl[0].teid, + -1, // no qfi + addr, + drb_p.up_ul_tnl[0].port, + DURecvCb, + NULL); } } @@ -3572,14 +3573,16 @@ static void rrc_DU_process_ue_context_modification_request(MessageDef *msg_p, co memcpy(addr.buffer, &drb_p.up_ul_tnl[0].tl_address, sizeof(drb_p.up_ul_tnl[0].tl_address)); addr.length=sizeof(drb_p.up_ul_tnl[0].tl_address)*8; extern instance_t DUuniqInstance; - incoming_teid=newGtpuCreateTunnel(DUuniqInstance, - req->rnti, - drb_p.drb_id, - drb_p.drb_id, - drb_p.up_ul_tnl[0].teid, - addr, - drb_p.up_ul_tnl[0].port, - DURecvCb); + incoming_teid = newGtpuCreateTunnel(DUuniqInstance, + req->rnti, + drb_p.drb_id, + drb_p.drb_id, + drb_p.up_ul_tnl[0].teid, + -1, // no qfi + addr, + drb_p.up_ul_tnl[0].port, + DURecvCb, + NULL); } } diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 6663ddea85..8e1975ea11 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -474,7 +474,6 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ( rrc_gNB_ue_context_t *ue_context_p = NULL; protocol_ctxt_t ctxt={0}; uint8_t pdu_sessions_done = 0; - gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp; uint8_t inde_list[NR_NB_RB_MAX - 3]= {0}; int ret = 0; @@ -503,7 +502,7 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ( uint8_t nb_pdusessions_tosetup = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_pdusessions; if (nb_pdusessions_tosetup != 0) { - memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t)); + gtpv1u_gnb_create_tunnel_req_t create_tunnel_req={0}; for (int i = 0; i < NR_NB_RB_MAX - 3; i++) { if(ue_context_p->ue_context.pduSession[i].status >= PDU_SESSION_STATUS_DONE) continue; @@ -512,6 +511,8 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ( create_tunnel_req.pdusession_id[pdu_sessions_done] = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].pdusession_id; create_tunnel_req.incoming_rb_id[pdu_sessions_done] = i+1; create_tunnel_req.outgoing_teid[pdu_sessions_done] = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].gtp_teid; + // To be developped: hardcoded first flow + create_tunnel_req.outgoing_qfi[pdu_sessions_done] = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].qos[0].qfi; create_tunnel_req.dst_addr[pdu_sessions_done].length = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].upf_addr.length; memcpy(create_tunnel_req.dst_addr[pdu_sessions_done].buffer, NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].upf_addr.buffer, @@ -1003,6 +1004,7 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ( create_tunnel_req.pdusession_id[pdu_sessions_done] = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].pdusession_id; create_tunnel_req.incoming_rb_id[pdu_sessions_done]= i+1; create_tunnel_req.outgoing_teid[pdu_sessions_done] = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].gtp_teid; + create_tunnel_req.outgoing_qfi[pdu_sessions_done] = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].qos[0].qfi; memcpy(create_tunnel_req.dst_addr[pdu_sessions_done].buffer, NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].upf_addr.buffer, sizeof(uint8_t)*20); diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 3626e0b8ed..e318f0cf95 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -21,8 +21,6 @@ extern "C" { #include "openair2/SDAP/nr_sdap/nr_sdap.h" //#include -static bool is_gnb = false; - #pragma pack(1) typedef struct Gtpv1uMsgHeader { @@ -60,18 +58,21 @@ typedef struct Gtpv1uMsgHeaderOptFields { uint8_t NextExtHeaderType; } __attribute__((packed)) Gtpv1uMsgHeaderOptFieldsT; -typedef struct PDUSessionContainer { +#define DL_PDU_SESSION_INFORMATION 0 +#define UL_PDU_SESSION_INFORMATION 1 + + typedef struct PDUSessionContainer { uint8_t spare:4; uint8_t PDU_type:4; uint8_t QFI:6; - uint8_t RQI:1; - uint8_t PPP:1; + uint8_t Reflective_QoS_activation:1; + uint8_t Paging_Policy_Indicator:1; } __attribute__((packed)) PDUSessionContainerT; typedef struct Gtpv1uExtHeader { uint8_t ExtHeaderLen; PDUSessionContainerT pdusession_cntr; - //uint8_t NextExtHeaderType; + uint8_t NextExtHeaderType; }__attribute__((packed)) Gtpv1uExtHeaderT; #pragma pack() @@ -103,6 +104,7 @@ typedef struct gtpv1u_bearer_s { tcp_udp_port_t outgoing_port; uint16_t seqNum; uint8_t npduNum; + int outgoing_qfi; } gtpv1u_bearer_t; typedef struct { @@ -159,75 +161,80 @@ instance_t legacyInstanceMapping=0; #define GTPV1U_HEADER_SIZE (8) - - static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, int msgType, teid_t teid, uint8_t *Msg,int msgLen, - bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType, - uint8_t *extensionHeader_buffer, uint8_t extensionHeader_length) { + #define HDR_MAX 256 // 256 is supposed to be larger than any gtp header +static int gtpv1uCreateAndSendMsg(int h, + uint32_t peerIp, + uint16_t peerPort, + int msgType, + teid_t teid, + uint8_t *Msg, + int msgLen, + bool seqNumFlag, + bool npduNumFlag, + int seqNum, + int npduNum, + int extHdrType, + uint8_t *extensionHeader_buffer, + uint8_t extensionHeader_length) { LOG_D(GTPU, "Peer IP:%u peer port:%u outgoing teid:%u \n", peerIp, peerPort, teid); - int headerAdditional=0; - if ( seqNumFlag || npduNumFlag || extHdrFlag) - headerAdditional=4; - - int fullSize=GTPV1U_HEADER_SIZE+headerAdditional+msgLen+extensionHeader_length; - uint8_t buffer[fullSize]; + uint8_t buffer[msgLen+HDR_MAX]; + uint8_t *curPtr=buffer; Gtpv1uMsgHeaderT *msgHdr = (Gtpv1uMsgHeaderT *)buffer ; // N should be 0 for us (it was used only in 2G and 3G) msgHdr->PN=npduNumFlag; msgHdr->S=seqNumFlag; - msgHdr->E=extHdrFlag; + msgHdr->E = extHdrType; msgHdr->spare=0; //PT=0 is for GTP' TS 32.295 (charging) msgHdr->PT=1; msgHdr->version=1; msgHdr->msgType=msgType; - msgHdr->msgLength=htons(msgLen+extensionHeader_length); - - if ( seqNumFlag || extHdrFlag || npduNumFlag) - msgHdr->msgLength+=htons(4); - + msgHdr->msgLength = htons(msgLen + extensionHeader_length); msgHdr->teid=htonl(teid); - if(seqNumFlag || extHdrFlag || npduNumFlag) { - *((uint16_t *) (buffer+8)) = seqNumFlag ? seqNum : 0x0000; - *((uint8_t *) (buffer+10)) = npduNumFlag ? npduNum : 0x00; - *((uint8_t *) (buffer+11)) = extHdrFlag ? extHdrType : 0x00; + curPtr+=sizeof(Gtpv1uMsgHeaderT); - /**(buffer+8) = seqNumFlag ? htons(seqNum) : 0x0000; - *(buffer+10) = npduNumFlag ? htons(npduNum) : 0x00; - *(buffer+11) = extHdrFlag ? htons(extHdrType) : 0x00; - *(buffer+11) = extHdrType;*/ + if (seqNumFlag || (extHdrType != NO_MORE_EXT_HDRS) || npduNumFlag) { + msgHdr->msgLength += htons(4); + *(uint16_t *)curPtr = seqNumFlag ? seqNum : 0x0000; + curPtr+=sizeof(uint16_t); + *(uint8_t *)curPtr = npduNumFlag ? npduNum : 0x00; + curPtr++; + *(uint8_t *)curPtr = extHdrType; + curPtr++; } - if(extHdrFlag){ - while (extHdrType){ - if (extensionHeader_length > 0 && extHdrType == 0x84){ - memcpy(buffer+GTPV1U_HEADER_SIZE+headerAdditional, extensionHeader_buffer, extensionHeader_length); - LOG_D(GTPU, "Extension Header for DDD added. The length is: %d, extension header type is: %x \n", extensionHeader_length, *((uint8_t *) (buffer+11))); - extHdrType = extensionHeader_buffer[extensionHeader_length -1]; - LOG_D(GTPU, "Next extension header type is: %x \n", *((uint8_t *) (buffer+11))); - } - else { - LOG_W(GTPU, "Extension header type not supported, returning... \n"); - return GTPNOK; - } + // Bug: if there is more than one extension, infinite loop on extensionHeader_buffer + while (extHdrType != NO_MORE_EXT_HDRS) { + if (extensionHeader_length > 0) { + memcpy(curPtr, extensionHeader_buffer, extensionHeader_length); + curPtr += extensionHeader_length; + LOG_D(GTPU, "Extension Header for DDD added. The length is: %d, extension header type is: %x \n", extensionHeader_length, *((uint8_t *)(buffer + 11))); + extHdrType = extensionHeader_buffer[extensionHeader_length - 1]; + LOG_D(GTPU, "Next extension header type is: %x \n", *((uint8_t *)(buffer + 11))); + } else { + LOG_W(GTPU, "Extension header type not supported, returning... \n"); } } + if (Msg!= NULL){ - memcpy(buffer+GTPV1U_HEADER_SIZE+headerAdditional+extensionHeader_length, Msg, msgLen); + memcpy(curPtr, Msg, msgLen); + curPtr+=msgLen; } + AssertFatal(curPtr-(buffer+msgLen) < HDR_MAX, ""); // Fix me: add IPv6 support, using flag ipVersion static struct sockaddr_in to= {0}; to.sin_family = AF_INET; to.sin_port = htons(peerPort); to.sin_addr.s_addr = peerIp ; - LOG_D(GTPU,"sending packet size: %d to %s\n",fullSize, inet_ntoa(to.sin_addr) ); + LOG_D(GTPU,"sending packet size: %ld to %s\n",curPtr-buffer, inet_ntoa(to.sin_addr) ); int ret; - if ((ret=sendto(h, (void *)buffer, (size_t)fullSize, 0,(struct sockaddr *)&to, sizeof(to) )) != fullSize ) { - LOG_E(GTPU, "[SD %d] Failed to send data to " IPV4_ADDR " on port %d, buffer size %u, ret: %d, errno: %d\n", - h, IPV4_ADDR_FORMAT(peerIp), peerPort, fullSize, ret, errno); + if ((ret=sendto(h, (void *)buffer, curPtr-buffer, 0,(struct sockaddr *)&to, sizeof(to) )) != curPtr-buffer ) { + LOG_E(GTPU, "[SD %d] Failed to send data to " IPV4_ADDR " on port %d, buffer size %lu, ret: %d, errno: %d\n", + h, IPV4_ADDR_FORMAT(peerIp), peerPort, curPtr-buffer, ret, errno); return GTPNOK; } @@ -269,12 +276,8 @@ static void gtpv1uSend(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req, b // copy to release the mutex gtpv1u_bearer_t tmp=ptr2->second; pthread_mutex_unlock(&globGtp.gtp_lock); - gtpv1uCreateAndSendMsg(compatInst(instance), - tmp.outgoing_ip_addr, - tmp.outgoing_port, - GTP_GPDU, - tmp.teid_outgoing, - buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0, NULL, 0) ; + gtpv1uCreateAndSendMsg( + compatInst(instance), tmp.outgoing_ip_addr, tmp.outgoing_port, GTP_GPDU, tmp.teid_outgoing, buffer, length, seqNumFlag, npduNumFlag, tmp.seqNum, tmp.npduNum, NO_MORE_EXT_HDRS, NULL, 0); } static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, bool seqNumFlag, bool npduNumFlag) { @@ -312,12 +315,35 @@ static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, // copy to release the mutex gtpv1u_bearer_t tmp=ptr2->second; pthread_mutex_unlock(&globGtp.gtp_lock); - gtpv1uCreateAndSendMsg(compatInst(instance), - tmp.outgoing_ip_addr, - tmp.outgoing_port, - GTP_GPDU, - tmp.teid_outgoing, - buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0, NULL, 0) ; + + if (tmp.outgoing_qfi != -1) { + Gtpv1uExtHeaderT ext = { 0 }; + ext.ExtHeaderLen = 1; // in quad bytes EXT_HDR_LNTH_OCTET_UNITS + ext.pdusession_cntr.spare = 0; + ext.pdusession_cntr.PDU_type = UL_PDU_SESSION_INFORMATION; + ext.pdusession_cntr.QFI = tmp.outgoing_qfi; + ext.pdusession_cntr.Reflective_QoS_activation = false; + ext.pdusession_cntr.Paging_Policy_Indicator = false; + ext.NextExtHeaderType = NO_MORE_EXT_HDRS; + + gtpv1uCreateAndSendMsg(compatInst(instance), + tmp.outgoing_ip_addr, + tmp.outgoing_port, + GTP_GPDU, + tmp.teid_outgoing, + buffer, + length, + seqNumFlag, + npduNumFlag, + tmp.seqNum, + tmp.npduNum, + PDU_SESSION_CONTAINER, + (uint8_t *)&ext, + sizeof(ext)); + } else { + gtpv1uCreateAndSendMsg( + compatInst(instance), tmp.outgoing_ip_addr, tmp.outgoing_port, GTP_GPDU, tmp.teid_outgoing, buffer, length, seqNumFlag, npduNumFlag, tmp.seqNum, tmp.npduNum, NO_MORE_EXT_HDRS, NULL, 0); + } } static void fillDlDeliveryStatusReport(extensionHeader_t *extensionHeader, uint32_t RLC_buffer_availability, uint32_t NR_PDCP_PDU_SN){ @@ -379,13 +405,8 @@ static void gtpv1uSendDlDeliveryStatus(instance_t instance, gtpv1u_DU_buffer_rep // copy to release the mutex gtpv1u_bearer_t tmp=ptr2->second; pthread_mutex_unlock(&globGtp.gtp_lock); - gtpv1uCreateAndSendMsg(compatInst(instance), - tmp.outgoing_ip_addr, - tmp.outgoing_port, - GTP_GPDU, - tmp.teid_outgoing, - NULL, 0, false, false, true, 0, 0, 0x84, extensionHeader->buffer, extensionHeader->length) ; - + gtpv1uCreateAndSendMsg( + compatInst(instance), tmp.outgoing_ip_addr, tmp.outgoing_port, GTP_GPDU, tmp.teid_outgoing, NULL, 0, false, false, 0, 0, NR_RAN_CONTAINER, extensionHeader->buffer, extensionHeader->length); } static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req) { @@ -567,8 +588,16 @@ void GtpuUpdateTunnelOutgoingTeid(instance_t instance, rnti_t rnti, ebi_t bearer return; } -teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_bearer_id, teid_t outgoing_teid, - transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { +teid_t newGtpuCreateTunnel(instance_t instance, + rnti_t rnti, + int incoming_bearer_id, + int outgoing_bearer_id, + teid_t outgoing_teid, + int outgoing_qfi, + transport_layer_addr_t remoteAddr, + int port, + gtpCallback callBack, + gtpCallbackSDAP callBackSDAP) { pthread_mutex_lock(&globGtp.gtp_lock); instance=compatInst(instance); auto inst=&globGtp.instances[instance]; @@ -593,8 +622,8 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer inst->te2ue_mapping[incoming_teid].outgoing_teid= outgoing_teid; inst->te2ue_mapping[incoming_teid].callBack=callBack; - - inst->te2ue_mapping[incoming_teid].callBackSDAP = sdap_data_req; + + inst->te2ue_mapping[incoming_teid].callBackSDAP = callBackSDAP; inst->te2ue_mapping[incoming_teid].pdusession_id = (uint8_t)outgoing_bearer_id; @@ -625,6 +654,7 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer tmp->teid_incoming = incoming_teid; tmp->outgoing_port=port; tmp->teid_outgoing= outgoing_teid; + tmp->outgoing_qfi=outgoing_qfi; pthread_mutex_unlock(&globGtp.gtp_lock); char ip4[INET_ADDRSTRLEN]; char ip6[INET6_ADDRSTRLEN]; @@ -653,12 +683,16 @@ int gtpv1u_create_s1u_tunnel(instance_t instance, "From legacy code not clear, seems impossible (bearer=%d)\n", create_tunnel_req->eps_bearer_id[i]); int incoming_rb_id=create_tunnel_req->eps_bearer_id[i]-4; - teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti, - incoming_rb_id, - create_tunnel_req->eps_bearer_id[i], - create_tunnel_req->sgw_S1u_teid[i], - create_tunnel_req->sgw_addr[i], dstport, - pdcp_data_req); + teid_t teid = newGtpuCreateTunnel(compatInst(instance), + create_tunnel_req->rnti, + incoming_rb_id, + create_tunnel_req->eps_bearer_id[i], + create_tunnel_req->sgw_S1u_teid[i], + -1, // no pdu session in 4G + create_tunnel_req->sgw_addr[i], + dstport, + pdcp_data_req, + NULL); create_tunnel_resp->status=0; create_tunnel_resp->rnti=create_tunnel_req->rnti; create_tunnel_resp->num_tunnels=create_tunnel_req->num_tunnels; @@ -715,15 +749,18 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance, create_tunnel_req->rnti, create_tunnel_req->num_tunnels, create_tunnel_req->outgoing_teid[0]); - tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport(); - is_gnb = true; + tcp_udp_port_t dstport = globGtp.instances[compatInst(instance)].get_dstport(); for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { - teid_t teid=newGtpuCreateTunnel(instance, create_tunnel_req->rnti, - create_tunnel_req->incoming_rb_id[i], - create_tunnel_req->pdusession_id[i], - create_tunnel_req->outgoing_teid[i], - create_tunnel_req->dst_addr[i], dstport, - pdcp_data_req); + teid_t teid = newGtpuCreateTunnel(instance, + create_tunnel_req->rnti, + create_tunnel_req->incoming_rb_id[i], + create_tunnel_req->pdusession_id[i], + create_tunnel_req->outgoing_teid[i], + create_tunnel_req->outgoing_qfi[i], + create_tunnel_req->dst_addr[i], + dstport, + pdcp_data_req, + sdap_data_req); create_tunnel_resp->status=0; create_tunnel_resp->rnti=create_tunnel_req->rnti; create_tunnel_resp->num_tunnels=create_tunnel_req->num_tunnels; @@ -853,9 +890,7 @@ static int Gtpv1uHandleEchoReq(int h, uint16_t seq=ntohs(*(uint16_t *)(msgHdr+1)); LOG_D(GTPU, "[%d] Received a echo request, TEID: %d, seq: %hu\n", h, msgHdr->teid, seq); uint8_t recovery[2]= {14,0}; - return gtpv1uCreateAndSendMsg(h, peerIp, peerPort, GTP_ECHO_RSP, ntohl(msgHdr->teid), - recovery, sizeof recovery, - 1, 0, 0, seq, 0, 0, NULL, 0); + return gtpv1uCreateAndSendMsg(h, peerIp, peerPort, GTP_ECHO_RSP, ntohl(msgHdr->teid), recovery, sizeof recovery, true, false, seq, 0, NO_MORE_EXT_HDRS, NULL, 0); } static int Gtpv1uHandleError(int h, @@ -968,7 +1003,7 @@ static int Gtpv1uHandleGpdu(int h, //Minimum length of GTP-U header if non of the optional fields are present int offset = sizeof(Gtpv1uMsgHeaderT); - uint8_t qfi = 0; + uint8_t qfi = -1; bool rqi = false; uint32_t NR_PDCP_PDU_SN = 0; @@ -986,7 +1021,7 @@ static int Gtpv1uHandleGpdu(int h, case PDU_SESSION_CONTAINER: { PDUSessionContainerT *pdusession_cntr = (PDUSessionContainerT *)(msgBuf + offset + 1); qfi = pdusession_cntr->QFI; - rqi = pdusession_cntr->RQI; + rqi = pdusession_cntr->Reflective_QoS_activation; break; } case NR_RAN_CONTAINER: { @@ -1047,7 +1082,7 @@ static int Gtpv1uHandleGpdu(int h, const uint32_t destinationL2Id=0; pthread_mutex_unlock(&globGtp.gtp_lock); - if(is_gnb && qfi){ + if (qfi != -1 && tunnel->second.callBackSDAP) { if ( !tunnel->second.callBackSDAP(&ctxt, srb_flag, rb_id, @@ -1106,12 +1141,8 @@ static int Gtpv1uHandleGpdu(int h, * 1 octet for padding + 1 octet for next extension header type, * according to TS 38.425: Fig. 5.5.2.2-1 and section 5.5.3.24*/ extensionHeader->length = 1+sizeof(DlDataDeliveryStatus_flagsT)+3+1+1; - gtpv1uCreateAndSendMsg(h, - peerIp, - peerPort, - GTP_GPDU, - inst->te2ue_mapping[ntohl(msgHdr->teid)].outgoing_teid, - NULL, 0, false, false, true, 0, 0, 0x84, extensionHeader->buffer, extensionHeader->length) ; + gtpv1uCreateAndSendMsg( + h, peerIp, peerPort, GTP_GPDU, inst->te2ue_mapping[ntohl(msgHdr->teid)].outgoing_teid, NULL, 0, false, false, 0, 0, NR_RAN_CONTAINER, extensionHeader->buffer, extensionHeader->length); } LOG_D(GTPU,"[%d] Received a %d bytes packet for: teid:%x\n", h, diff --git a/openair3/ocp-gtpu/gtp_itf.h b/openair3/ocp-gtpu/gtp_itf.h index 51a47e8c82..7951c4db09 100644 --- a/openair3/ocp-gtpu/gtp_itf.h +++ b/openair3/ocp-gtpu/gtp_itf.h @@ -66,8 +66,16 @@ int gtpv1u_create_x2u_tunnel( // New API -teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_rb_id, teid_t teid, - transport_layer_addr_t remoteAddr, int port, gtpCallback callBack); +teid_t newGtpuCreateTunnel(instance_t instance, + rnti_t rnti, + int incoming_bearer_id, + int outgoing_rb_id, + teid_t teid, + int outgoing_qfi, + transport_layer_addr_t remoteAddr, + int port, + gtpCallback callBack, + gtpCallbackSDAP callBackSDAP); void GtpuUpdateTunnelOutgoingTeid(instance_t instance, rnti_t rnti, ebi_t bearer_id, teid_t newOutgoingTeid); int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti); int newGtpuDeleteTunnels(instance_t instance, rnti_t rnti, int nbTunnels, pdusessionid_t *pdusession_id); From eb46f216b18e6055502bad7210681a4012dc6cdf Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 29 Jul 2022 18:44:00 +0200 Subject: [PATCH 71/71] Upgrade path to AS lteue after simulator upgrade --- ci-scripts/ci_ueinfra.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-scripts/ci_ueinfra.yaml b/ci-scripts/ci_ueinfra.yaml index 51fc4a264e..76ebaf0f97 100644 --- a/ci-scripts/ci_ueinfra.yaml +++ b/ci-scripts/ci_ueinfra.yaml @@ -50,7 +50,7 @@ amarisoft_ue_1: WakeupScript : none DetachScript : none #end - Cmd : /root/NV17-12-21/ue/lteue + Cmd : /root/NV18-06-2022/ue/lteue Config : /root/NV17-12-21/ue/config/oaicicd-ue-Ping-SATest.cfg Duration : 60 Ping : /tmp/test_ue1.log @@ -71,7 +71,7 @@ amarisoft_ue_2: WakeupScript : none DetachScript : none #end - Cmd : /root/NV17-12-21/ue/lteue + Cmd : /root/NV18-06-2022/ue/lteue Config : /root/NV17-12-21/ue/config/xxxxxxx.cfg #to be updated for an other scenario Duration : 60 Ping :