From 1745ffa10fb7c42ed7fe376553684855b9453230 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 12 Apr 2022 17:36:52 +0200 Subject: [PATCH 01/98] adapting nr_rrc_config_dl_tda for multiple BWPs --- openair2/GNB_APP/gnb_config.c | 13 +++++++++---- openair2/RRC/NR/MESSAGES/asn1_msg.c | 16 ++++------------ openair2/RRC/NR/nr_rrc_config.c | 17 ++++++++--------- openair2/RRC/NR/nr_rrc_config.h | 5 ++++- openair2/RRC/NR/rrc_gNB_reconfig.c | 16 ++++------------ 5 files changed, 29 insertions(+), 38 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 8aa6372e34..5486ae9f5a 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -299,7 +299,9 @@ void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap) { int ssbmaplen = (int)scc->ssb_PositionsInBurst->present; uint8_t curr_bit; - AssertFatal(ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap || ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap || ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap, "illegal ssbmaplen %d\n",ssbmaplen); + AssertFatal(ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap || + ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap || + ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap, "illegal ssbmaplen %d\n",ssbmaplen); // changing endianicity of ssbmap and filling the ssb_PositionsInBurst buffers if(ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap){ @@ -343,10 +345,13 @@ void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap) { if (*scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder!=0) scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder = NULL; - // prepare DL Allocation lists - nr_rrc_config_dl_tda(scc); - lte_frame_type_t frame_type = get_frame_type((int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); + + // prepare DL Allocation lists + nr_rrc_config_dl_tda(scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, + frame_type, scc->tdd_UL_DL_ConfigurationCommon, + scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth); + if (frame_type == FDD) { ASN_STRUCT_FREE(asn_DEF_NR_TDD_UL_DL_ConfigCommon, scc->tdd_UL_DL_ConfigurationCommon); scc->tdd_UL_DL_ConfigurationCommon = NULL; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 3226cab656..e4df85a166 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1134,18 +1134,10 @@ void fill_default_downlinkBWP(NR_BWP_Downlink_t *bwp, bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup)); bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList)); - // Copy PDSCH TimeDomainResourceAllocation from InitialBWP - NR_PDSCH_TimeDomainResourceAllocation_t *pdschi; - for (int i=0;idownlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;i++) { - pdschi= calloc(1,sizeof(*pdschi)); - if(scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0){ - pdschi->k0 = calloc(1,sizeof(*pdschi->k0)); - *pdschi->k0 = *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; - } - pdschi->mappingType = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType; - pdschi->startSymbolAndLength = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength; - ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,pdschi); - } + nr_rrc_config_dl_tda(bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, + get_frame_type((int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing), + scc->tdd_UL_DL_ConfigurationCommon, + curr_bwp); /// BWP dedicated configuration bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated)); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index f8f05f2fe5..c4dda67e62 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -75,10 +75,11 @@ void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, } } -void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc){ +void nr_rrc_config_dl_tda(struct NR_PDSCH_TimeDomainResourceAllocationList *pdsch_TimeDomainAllocationList, + lte_frame_type_t frame_type, + NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, + int curr_bwp) { - lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); - int curr_bwp = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; // coreset duration setting to be improved in the framework of RRC harmonization, potentially using a common function int len_coreset = 1; if (curr_bwp < 48) @@ -87,18 +88,16 @@ void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc){ struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); timedomainresourceallocation->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; timedomainresourceallocation->startSymbolAndLength = get_SLIV(len_coreset,14-len_coreset); // basic slot configuration starting in symbol 1 til the end of the slot - ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, - timedomainresourceallocation); + ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation); if(frame_type==TDD) { // TDD - if(scc->tdd_UL_DL_ConfigurationCommon) { - int dl_symb = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols; + if(tdd_UL_DL_ConfigurationCommon) { + int dl_symb = tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols; if(dl_symb > 1) { timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); timedomainresourceallocation->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; timedomainresourceallocation->startSymbolAndLength = get_SLIV(len_coreset,dl_symb-len_coreset); // mixed slot configuration starting in symbol 1 til the end of the dl allocation - ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, - timedomainresourceallocation); + ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation); } } } diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 1a0d091e35..bf12f83a60 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -111,7 +111,10 @@ typedef struct physicalcellgroup_s{ long RNTI_Value[MAX_NUM_CCs]; }physicalcellgroup_t; -void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc); +void nr_rrc_config_dl_tda(struct NR_PDSCH_TimeDomainResourceAllocationList *pdsch_TimeDomainAllocationList, + lte_frame_type_t frame_type, + NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, + int curr_bwp); 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, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 8566990de7..330022cb29 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -196,18 +196,10 @@ void fill_default_nsa_downlinkBWP(NR_BWP_Downlink_t *bwp, bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup)); bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList)); - // copy PDSCH TimeDomainResourceAllocation from InitialBWP - NR_PDSCH_TimeDomainResourceAllocation_t *pdschi; - for (int i=0;idownlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;i++) { - pdschi= calloc(1,sizeof(*pdschi)); - if(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0){ - pdschi->k0 = calloc(1,sizeof(*pdschi->k0)); - *pdschi->k0 = *servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; - } - pdschi->mappingType = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType; - pdschi->startSymbolAndLength = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength; - ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,pdschi); - } + nr_rrc_config_dl_tda(bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, + get_frame_type((int)*servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *servingcellconfigcommon->ssbSubcarrierSpacing), + servingcellconfigcommon->tdd_UL_DL_ConfigurationCommon, + curr_bwp); /// BWP dedicated configuration From 6989d4ecbae4954ea8cbab08f52817ac7bab811e Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 15 Apr 2022 19:21:34 +0200 Subject: [PATCH 02/98] harmonization of coreset configuration --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 36 ++---------------- openair2/RRC/NR/nr_rrc_config.c | 58 +++++++++++++++++++++++++++++ openair2/RRC/NR/nr_rrc_config.h | 4 ++ openair2/RRC/NR/rrc_gNB_reconfig.c | 17 +-------- 4 files changed, 66 insertions(+), 49 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index dc9f9a2f18..389081ab2d 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1768,38 +1768,8 @@ void fill_initial_SpCellConfig(int uid, bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); - coreset->controlResourceSetId=1; - // frequency domain resources depends on BWP size - // options are 24, 48 or 96 - coreset->frequencyDomainResources.buf = calloc(1,6); - if (0) { - int curr_bwp = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; - if (curr_bwp < 48) - coreset->frequencyDomainResources.buf[0] = 0xf0; - else - coreset->frequencyDomainResources.buf[0] = 0xff; - if (curr_bwp < 96) - coreset->frequencyDomainResources.buf[1] = 0; - else - coreset->frequencyDomainResources.buf[1] = 0xff; - } else { - coreset->frequencyDomainResources.buf[0] = 0xf0; - coreset->frequencyDomainResources.buf[1] = 0; - } - coreset->frequencyDomainResources.buf[2] = 0; - coreset->frequencyDomainResources.buf[3] = 0; - coreset->frequencyDomainResources.buf[4] = 0; - coreset->frequencyDomainResources.buf[5] = 0; - coreset->frequencyDomainResources.size = 6; - coreset->frequencyDomainResources.bits_unused = 3; - coreset->duration=1; - coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved; - coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle; - - coreset->tci_StatesPDCCH_ToAddList=NULL; - coreset->tci_StatesPDCCH_ToReleaseList = NULL; - coreset->tci_PresentInDCI = NULL; - coreset->pdcch_DMRS_ScramblingID = NULL; + uint64_t bitmap = get_ssb_bitmap(scc); + rrc_coreset_config(coreset, curr_bwp, bitmap); ASN_SEQUENCE_ADD(&bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset); @@ -1810,7 +1780,7 @@ void fill_initial_SpCellConfig(int uid, ss2->searchSpaceId=2; ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); - *ss2->controlResourceSetId=1; + *ss2->controlResourceSetId=coreset->controlResourceSetId; ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index f66a4c91cc..b52c24e91d 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -34,6 +34,64 @@ const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160}; +void rrc_coreset_config(NR_ControlResourceSet_t *coreset, + int curr_bwp, + uint64_t ssb_bitmap) { + + // frequency domain resources depends on BWP size + coreset->frequencyDomainResources.buf = calloc(1,6); + coreset->frequencyDomainResources.buf[0] = (curr_bwp < 48) ? 0xf0 : 0xff; + coreset->frequencyDomainResources.buf[1] = (curr_bwp < 96) ? 0x00 : 0xff; + coreset->frequencyDomainResources.buf[2] = (curr_bwp < 144) ? 0x00 : 0xff; + coreset->frequencyDomainResources.buf[3] = (curr_bwp < 192) ? 0x00 : 0xff; + coreset->frequencyDomainResources.buf[4] = 0; + coreset->frequencyDomainResources.buf[5] = 0; + coreset->frequencyDomainResources.size = 6; + coreset->frequencyDomainResources.bits_unused = 3; + coreset->duration = (curr_bwp < 48) ? 2 : 1; + coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved; + coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle; + + // The ID space is used across the BWPs of a Serving Cell as per 38.331 + coreset->controlResourceSetId = (coreset->frequencyDomainResources.buf[0] > 0) + + (coreset->frequencyDomainResources.buf[1] > 0) + + (coreset->frequencyDomainResources.buf[2] > 0) + + (coreset->frequencyDomainResources.buf[3] > 0); + + coreset->tci_StatesPDCCH_ToAddList=calloc(1,sizeof(*coreset->tci_StatesPDCCH_ToAddList)); + NR_TCI_StateId_t *tci[64]; + for (int i=0;i<64;i++) { + if ((ssb_bitmap>>(63-i))&0x01){ + tci[i]=calloc(1,sizeof(*tci[i])); + *tci[i] = i; + ASN_SEQUENCE_ADD(&coreset->tci_StatesPDCCH_ToAddList->list,tci[i]); + } + } + coreset->tci_StatesPDCCH_ToReleaseList = NULL; + coreset->tci_PresentInDCI = NULL; + coreset->pdcch_DMRS_ScramblingID = NULL; +} + +uint64_t get_ssb_bitmap(NR_ServingCellConfigCommon_t *scc) { + 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); + } + return bitmap; +} + void set_csirs_periodicity(NR_NZP_CSI_RS_Resource_t *nzpcsi0, int uid, int nb_slots_per_period) { nzpcsi0->periodicityAndOffset = calloc(1,sizeof(*nzpcsi0->periodicityAndOffset)); diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 6586df286f..bc4ac8855f 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -111,6 +111,10 @@ typedef struct physicalcellgroup_s{ long RNTI_Value[MAX_NUM_CCs]; }physicalcellgroup_t; +uint64_t get_ssb_bitmap(NR_ServingCellConfigCommon_t *scc); +void rrc_coreset_config(NR_ControlResourceSet_t *coreset, + int curr_bwp, + uint64_t ssb_bitmap); void nr_rrc_config_dl_tda(struct NR_PDSCH_TimeDomainResourceAllocationList *pdsch_TimeDomainAllocationList, lte_frame_type_t frame_type, NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 4a1f4b4e12..f48e9c093f 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -664,22 +664,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco fix_servingcellconfigdedicated(servingcellconfigdedicated); - uint64_t bitmap=0; - switch (servingcellconfigcommon->ssb_PositionsInBurst->present) { - case 1 : - bitmap = ((uint64_t) servingcellconfigcommon->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; - break; - case 2 : - bitmap = ((uint64_t) servingcellconfigcommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; - break; - case 3 : - for (int i=0; i<8; i++) { - bitmap |= (((uint64_t) servingcellconfigcommon->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", servingcellconfigcommon->ssb_PositionsInBurst->present); - } + uint64_t bitmap = get_ssb_bitmap(servingcellconfigcommon); memset(secondaryCellGroup,0,sizeof(NR_CellGroupConfig_t)); secondaryCellGroup->cellGroupId = scg_id; From b62e7be27603572408f89886a312ecaac021bbff Mon Sep 17 00:00:00 2001 From: francescomani Date: Sat, 16 Apr 2022 10:13:02 +0200 Subject: [PATCH 03/98] adding harmonization of coreset configuration to multiple BWPs --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 94 ++--------------------------- openair2/RRC/NR/rrc_gNB_reconfig.c | 34 +---------- 2 files changed, 6 insertions(+), 122 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 389081ab2d..29e5112dc2 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -197,7 +197,7 @@ int xer_nr_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { asn_enc_rval_t enc_rval; - rrc_gNB_carrier_data_t *carrier = &rrc->carrier; + rrc_gNB_carrier_data_t *carrier = &rrc->carrier; const gNB_RrcConfigurationReq *configuration = &rrc->configuration; NR_BCCH_BCH_Message_t *mib = &carrier->mib; @@ -1036,61 +1036,8 @@ void fill_default_downlinkBWP(NR_BWP_Downlink_t *bwp, int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); - coreset->controlResourceSetId=(bwp->bwp_Id<<1); // To uniquely identify each Coreset lets derive it from the BWPId - // frequency domain resources depends on BWP size - // options are 24, 48 or 96 - coreset->frequencyDomainResources.buf = calloc(1,6); - if (0) { - if (curr_bwp < 48) - coreset->frequencyDomainResources.buf[0] = 0xf0; - else - coreset->frequencyDomainResources.buf[0] = 0xff; - if (curr_bwp < 96) - coreset->frequencyDomainResources.buf[1] = 0; - else - coreset->frequencyDomainResources.buf[1] = 0xff; - } else { - coreset->frequencyDomainResources.buf[0] = 0xf0; - coreset->frequencyDomainResources.buf[1] = 0; - } - coreset->frequencyDomainResources.buf[2] = 0; - coreset->frequencyDomainResources.buf[3] = 0; - coreset->frequencyDomainResources.buf[4] = 0; - coreset->frequencyDomainResources.buf[5] = 0; - coreset->frequencyDomainResources.size = 6; - coreset->frequencyDomainResources.bits_unused = 3; - coreset->duration=1; - coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved; - coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle; - - coreset->tci_StatesPDCCH_ToAddList=calloc(1,sizeof(*coreset->tci_StatesPDCCH_ToAddList)); - 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_TCI_StateId_t *tci[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - tci[i]=calloc(1,sizeof(*tci[i])); - *tci[i] = i; - ASN_SEQUENCE_ADD(&coreset->tci_StatesPDCCH_ToAddList->list,tci[i]); - } - } - coreset->tci_StatesPDCCH_ToReleaseList = NULL; - coreset->tci_PresentInDCI = NULL; - coreset->pdcch_DMRS_ScramblingID = NULL; + uint64_t bitmap = get_ssb_bitmap(scc); + rrc_coreset_config(coreset, curr_bwp, bitmap); bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset; bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL; @@ -1147,44 +1094,13 @@ void fill_default_downlinkBWP(NR_BWP_Downlink_t *bwp, bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); - NR_ControlResourceSet_t *coreset2 = calloc(1,sizeof(*coreset2)); - coreset2->controlResourceSetId=(bwp->bwp_Id<<1)+1; // To uniquely identify each Coreset lets derive it from the BWPId - // frequency domain resources depends on BWP size - // options are 24, 48 or 96 - coreset2->frequencyDomainResources.buf = calloc(1,6); - if (0) { - if (curr_bwp < 48) - coreset2->frequencyDomainResources.buf[0] = 0xf0; - else - coreset2->frequencyDomainResources.buf[0] = 0xff; - if (curr_bwp < 96) - coreset2->frequencyDomainResources.buf[1] = 0; - else - coreset2->frequencyDomainResources.buf[1] = 0xff; - } else { - coreset2->frequencyDomainResources.buf[0] = 0xf0; - coreset2->frequencyDomainResources.buf[1] = 0; - } - coreset2->frequencyDomainResources.buf[2] = 0; - coreset2->frequencyDomainResources.buf[3] = 0; - coreset2->frequencyDomainResources.buf[4] = 0; - coreset2->frequencyDomainResources.buf[5] = 0; - coreset2->frequencyDomainResources.size = 6; - coreset2->frequencyDomainResources.bits_unused = 3; - coreset2->duration=1; - coreset2->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved; - coreset2->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle; - coreset2->tci_StatesPDCCH_ToAddList=NULL; - coreset2->tci_StatesPDCCH_ToReleaseList = NULL; - coreset2->tci_PresentInDCI = NULL; - coreset2->pdcch_DMRS_ScramblingID = NULL; - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset2); + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset); bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2)); ss2->searchSpaceId=(bwp->bwp_Id<<1) + 7; // To uniquely identify each SearchSpace lets derive it from the BWPId ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); - *ss2->controlResourceSetId=coreset2->controlResourceSetId; + *ss2->controlResourceSetId=coreset->controlResourceSetId; ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index f48e9c093f..8e4b3fc8d8 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -119,39 +119,7 @@ void fill_default_nsa_downlinkBWP(NR_BWP_Downlink_t *bwp, int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); - coreset->controlResourceSetId=bwp->bwp_Id+1; // To uniquely identify each Coreset lets derive it from the BWPId - // frequency domain resources depends on BWP size - // options are 24, 48 or 96 - coreset->frequencyDomainResources.buf = calloc(1,6); - if (curr_bwp < 48) - coreset->frequencyDomainResources.buf[0] = 0xf0; - else - coreset->frequencyDomainResources.buf[0] = 0xff; - if (curr_bwp < 96) - coreset->frequencyDomainResources.buf[1] = 0; - else - coreset->frequencyDomainResources.buf[1] = 0xff; - coreset->frequencyDomainResources.buf[2] = 0; - coreset->frequencyDomainResources.buf[3] = 0; - coreset->frequencyDomainResources.buf[4] = 0; - coreset->frequencyDomainResources.buf[5] = 0; - coreset->frequencyDomainResources.size = 6; - coreset->frequencyDomainResources.bits_unused = 3; - coreset->duration=1; - coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved; - coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle; - coreset->tci_StatesPDCCH_ToAddList=calloc(1,sizeof(*coreset->tci_StatesPDCCH_ToAddList)); - NR_TCI_StateId_t *tci[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - tci[i]=calloc(1,sizeof(*tci[i])); - *tci[i] = i; - ASN_SEQUENCE_ADD(&coreset->tci_StatesPDCCH_ToAddList->list,tci[i]); - } - } - coreset->tci_StatesPDCCH_ToReleaseList = NULL; - coreset->tci_PresentInDCI = NULL; - coreset->pdcch_DMRS_ScramblingID = NULL; + rrc_coreset_config(coreset, curr_bwp, bitmap); bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset; bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL; From c791b45adcbeadd801596feb6b3347ee2de8005f Mon Sep 17 00:00:00 2001 From: francescomani Date: Sat, 16 Apr 2022 14:34:00 +0200 Subject: [PATCH 04/98] harmonization of downlink BWPs configuration --- common/utils/nr/nr_common.h | 2 + openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 1 - .../LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c | 3 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 151 +----------- openair2/RRC/NR/nr_rrc_config.c | 179 ++++++++++++++ openair2/RRC/NR/nr_rrc_config.h | 8 +- openair2/RRC/NR/rrc_gNB_reconfig.c | 227 +----------------- 7 files changed, 200 insertions(+), 371 deletions(-) diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index 0150cf59f8..739c8e37f4 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -37,6 +37,8 @@ #include "assertions.h" #include "PHY/defs_common.h" +#define MAX_BWP_SIZE 275 + typedef struct nr_bandentry_s { int16_t band; uint64_t ul_min; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 9dd03ddcf6..3c4b8c4ff9 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -62,7 +62,6 @@ #define NR_BCCH_BCH 5 // MIB #define CCCH_PAYLOAD_SIZE_MAX 512 #define RAR_PAYLOAD_SIZE_MAX 128 -#define MAX_BWP_SIZE 275 typedef enum frequency_range_e { FR1 = 0, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index bf2af3b388..b92d8d8354 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -31,6 +31,7 @@ #include "NR_MAC_gNB/mac_proto.h" #include "common/ran_context.h" #include "nfapi/oai_integration/vendor_ext.h" +#include "common/utils/nr/nr_common.h" extern RAN_CONTEXT_t RC; @@ -185,4 +186,4 @@ void nr_schedule_srs(int module_id, frame_t frame) { } } } -} \ No newline at end of file +} diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 29e5112dc2..b815dc1216 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -75,7 +75,6 @@ #include "NR_UE-CapabilityRequestFilterNR.h" #include "PHY/defs_nr_common.h" #include "common/utils/nr/nr_common.h" -#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac.h" #if defined(NR_Rel16) #include "NR_SCS-SpecificCarrier.h" #include "NR_TDD-UL-DL-ConfigCommon.h" @@ -1006,151 +1005,6 @@ long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS) { return c_srs; } -void fill_default_downlinkBWP(NR_BWP_Downlink_t *bwp, - int bwp_loop, - NR_ServingCellConfig_t *servingcellconfigdedicated, - NR_ServingCellConfigCommon_t *scc, - const gNB_RrcConfigurationReq *configuration) { - - /// BWP common configuration - bwp->bwp_Common = calloc(1,sizeof(*bwp->bwp_Common)); - if(servingcellconfigdedicated->downlinkBWP_ToAddModList && - bwp_loop < servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count) { - bwp->bwp_Id = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; - bwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; - bwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; - bwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; - } else { - bwp->bwp_Id=bwp_loop+1; - bwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); - bwp->bwp_Common->genericParameters.subcarrierSpacing = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; - bwp->bwp_Common->genericParameters.cyclicPrefix = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.cyclicPrefix; - } - - bwp->bwp_Common->pdcch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon)); - bwp->bwp_Common->pdcch_ConfigCommon->present = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup)); - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet)); - - int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); - - NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); - uint64_t bitmap = get_ssb_bitmap(scc); - rrc_coreset_config(coreset, curr_bwp, bitmap); - - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList)); - - NR_SearchSpace_t *ss=calloc(1,sizeof(*ss)); - ss->searchSpaceId = (bwp->bwp_Id<<1)-1 + 7; // To uniquely identify each SearchSpace lets derive it from the BWPId - ss->controlResourceSetId=calloc(1,sizeof(*ss->controlResourceSetId)); - *ss->controlResourceSetId=coreset->controlResourceSetId; - ss->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss->monitoringSlotPeriodicityAndOffset)); - ss->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; - ss->duration=NULL; - ss->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss->monitoringSymbolsWithinSlot)); - ss->monitoringSymbolsWithinSlot->buf = calloc(1,2); - // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed - ss->monitoringSymbolsWithinSlot->buf[1] = 0; - ss->monitoringSymbolsWithinSlot->buf[0] = (1<<7); - ss->monitoringSymbolsWithinSlot->size = 2; - ss->monitoringSymbolsWithinSlot->bits_unused = 2; - ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates)); - ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; - ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n2; - ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; - ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; - ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; - ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType)); - ss->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; - ss->searchSpaceType->choice.common=calloc(1,sizeof(*ss->searchSpaceType->choice.common)); - ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - - ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss); - - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->pagingSearchSpace=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ext1=NULL; - bwp->bwp_Common->pdsch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon)); - bwp->bwp_Common->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup; - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup)); - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList)); - - nr_rrc_config_dl_tda(bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, - get_frame_type((int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing), - scc->tdd_UL_DL_ConfigurationCommon, - curr_bwp); - - /// BWP dedicated configuration - bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated)); - bwp->bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config)); - bwp->bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup; - bwp->bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup)); - bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); - bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); - - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset); - - bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); - NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2)); - ss2->searchSpaceId=(bwp->bwp_Id<<1) + 7; // To uniquely identify each SearchSpace lets derive it from the BWPId - ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); - *ss2->controlResourceSetId=coreset->controlResourceSetId; - ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); - ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; - ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; - ss2->duration=NULL; - ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot)); - ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2); - ss2->monitoringSymbolsWithinSlot->size = 2; - ss2->monitoringSymbolsWithinSlot->buf[0]=0x80; - ss2->monitoringSymbolsWithinSlot->buf[1]=0x0; - ss2->monitoringSymbolsWithinSlot->bits_unused = 2; - ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates)); - ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; - ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n2; - ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; - ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; - ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; - ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType)); - ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific)); - ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1; - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2); - - bwp->bwp_Dedicated->pdsch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config)); - bwp->bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; - bwp->bwp_Dedicated->pdsch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); - *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation = NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = - calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); - *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList)); - NR_TCI_State_t *tcic = calloc(1,sizeof(*tcic)); - tcic->tci_StateId=0; - tcic->qcl_Type1.cell=NULL; - tcic->qcl_Type1.bwp_Id=NULL; - tcic->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; - tcic->qcl_Type1.referenceSignal.choice.ssb = 0; - tcic->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeD; - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcic); -} - void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, int bwp_loop, NR_ServingCellConfig_t *servingcellconfigdedicated, @@ -1778,7 +1632,10 @@ void fill_initial_SpCellConfig(int uid, SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList)); for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) { NR_BWP_Downlink_t *bwp = calloc(1, sizeof(*bwp)); - fill_default_downlinkBWP(bwp, bwp_loop, servingcellconfigdedicated, scc, configuration); + config_downlinkBWP(bwp, scc, + servingcellconfigdedicated, + NULL, 0, + false, bwp_loop, true); ASN_SEQUENCE_ADD(&SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp); } SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id)); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index b52c24e91d..aab525fcd7 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -30,6 +30,7 @@ #include "nr_rrc_config.h" #include "common/utils/nr/nr_common.h" +#include "executables/softmodem-common.h" const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160}; @@ -393,4 +394,182 @@ void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, } +void config_downlinkBWP(NR_BWP_Downlink_t *bwp, + NR_ServingCellConfigCommon_t *scc, + NR_ServingCellConfig_t *servingcellconfigdedicated, + NR_UE_NR_Capability_t *uecap, + int dl_antenna_ports, + bool force_256qam_off, + int bwp_loop, bool is_SA) { + + bwp->bwp_Common = calloc(1,sizeof(*bwp->bwp_Common)); + + if(servingcellconfigdedicated->downlinkBWP_ToAddModList && + bwp_loop < servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count) { + bwp->bwp_Id = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; + bwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; + bwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; + bwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; + } else { + bwp->bwp_Id=bwp_loop+1; + bwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); + bwp->bwp_Common->genericParameters.subcarrierSpacing = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; + bwp->bwp_Common->genericParameters.cyclicPrefix = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.cyclicPrefix; + } + + bwp->bwp_Common->pdcch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon)); + bwp->bwp_Common->pdcch_ConfigCommon->present = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup)); + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet)); + + int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + + NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); + uint64_t ssb_bitmap = get_ssb_bitmap(scc); + rrc_coreset_config(coreset, curr_bwp, ssb_bitmap); + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset; + + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList)); + + NR_SearchSpace_t *ss=calloc(1,sizeof(*ss)); + ss->searchSpaceId = 10+bwp->bwp_Id; + ss->controlResourceSetId=calloc(1,sizeof(*ss->controlResourceSetId)); + *ss->controlResourceSetId=coreset->controlResourceSetId; + ss->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss->monitoringSlotPeriodicityAndOffset)); + ss->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; + ss->duration=NULL; + ss->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss->monitoringSymbolsWithinSlot)); + ss->monitoringSymbolsWithinSlot->buf = calloc(1,2); + // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed + ss->monitoringSymbolsWithinSlot->buf[1] = 0; + ss->monitoringSymbolsWithinSlot->buf[0] = 0xc0; + ss->monitoringSymbolsWithinSlot->size = 2; + ss->monitoringSymbolsWithinSlot->bits_unused = 2; + ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates)); + // TODO write a function to program nr of candidates and aggregation level + ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; + ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; + ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; + ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; + ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; + ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType)); + ss->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; + ss->searchSpaceType->choice.common=calloc(1,sizeof(*ss->searchSpaceType->choice.common)); + ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); + ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss); + + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->pagingSearchSpace=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=NULL; + if(is_SA == false) { + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace)); + *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=ss->searchSpaceId; + } + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ext1=NULL; + bwp->bwp_Common->pdsch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon)); + bwp->bwp_Common->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup; + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup)); + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList)); + + nr_rrc_config_dl_tda(bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, + get_frame_type((int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing), + scc->tdd_UL_DL_ConfigurationCommon, + curr_bwp); + + if (!bwp->bwp_Dedicated) { + bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated)); + } + bwp->bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config)); + bwp->bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup; + bwp->bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup)); + bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); + bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); + + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset); + + bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); + NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2)); + ss2->searchSpaceId= 20+bwp->bwp_Id; + ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); + *ss2->controlResourceSetId=coreset->controlResourceSetId; + ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); + ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; + ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; + ss2->duration=NULL; + ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot)); + ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2); + ss2->monitoringSymbolsWithinSlot->size = 2; + ss2->monitoringSymbolsWithinSlot->buf[0]=0xc0; + ss2->monitoringSymbolsWithinSlot->buf[1]=0x0; + ss2->monitoringSymbolsWithinSlot->bits_unused = 2; + ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates)); + ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; + ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n4; + ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n0; + ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; + ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; + ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType)); + ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific)); + ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1; + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2); + + bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToReleaseList = NULL; + + struct NR_SetupRelease_PDSCH_Config *pdsch_Config = bwp->bwp_Dedicated->pdsch_Config; + if (!pdsch_Config) { + pdsch_Config = calloc(1,sizeof(*pdsch_Config)); + pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; + pdsch_Config->choice.setup = calloc(1,sizeof(*pdsch_Config->choice.setup)); + pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); + pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; + pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); + } + pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; + struct NR_SetupRelease_DMRS_DownlinkConfig *dmrs_DownlinkForPDSCH_MappingTypeA = pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA; + + if ((get_softmodem_params()->do_ra || get_softmodem_params()->phy_test) && dl_antenna_ports > 1) // for MIMO, we use DMRS Config Type 2 but only with OAI UE + dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=calloc(1,sizeof(*dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type)); + else + dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; + dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; + dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL; + dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL; + dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); + *dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; + + pdsch_Config->choice.setup->resourceAllocation = NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; + pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; + pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); + pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = calloc(1,sizeof(*pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); + *pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; + + set_dl_mcs_table(bwp->bwp_Common->genericParameters.subcarrierSpacing, + force_256qam_off ? NULL : uecap, + bwp->bwp_Dedicated, + scc); + + int n_ssb = 0; + NR_TCI_State_t *tcid[64]; + for (int i=0;i<64;i++) { + if ((ssb_bitmap>>(63-i))&0x01){ + tcid[i]=calloc(1,sizeof(*tcid[i])); + tcid[i]->tci_StateId=n_ssb; + tcid[i]->qcl_Type1.cell=NULL; + tcid[i]->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid[i]->qcl_Type1.bwp_Id)); + *tcid[i]->qcl_Type1.bwp_Id=bwp->bwp_Id; + tcid[i]->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; + tcid[i]->qcl_Type1.referenceSignal.choice.ssb = i; + tcid[i]->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC; + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid[i]); + n_ssb++; + } + } +} + + diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index bc4ac8855f..6bbc74263a 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -134,6 +134,12 @@ void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, int numerology, int rbsize, int mcs_table); - +void config_downlinkBWP(NR_BWP_Downlink_t *bwp, + NR_ServingCellConfigCommon_t *scc, + NR_ServingCellConfig_t *servingcellconfigdedicated, + NR_UE_NR_Capability_t *uecap, + int dl_antenna_ports, + bool force_256qam_off, + int bwp_loop, bool is_SA); #endif diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 8e4b3fc8d8..fde4df8b37 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -83,226 +83,6 @@ void fix_servingcellconfigdedicated(NR_ServingCellConfig_t *scd) { } -void fill_default_nsa_downlinkBWP(NR_BWP_Downlink_t *bwp, - long bwp_loop, - NR_CellGroupConfig_t *secondaryCellGroup, - NR_ServingCellConfig_t *servingcellconfigdedicated, - NR_ServingCellConfigCommon_t *servingcellconfigcommon, - const gNB_RrcConfigurationReq *configuration, - NR_UE_NR_Capability_t *uecap, - int dl_antenna_ports, - uint64_t bitmap) { - - /// BWP common configuration - - bwp->bwp_Common = calloc(1,sizeof(*bwp->bwp_Common)); - - if(servingcellconfigdedicated->downlinkBWP_ToAddModList && - bwp_loop < servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count) { - bwp->bwp_Id = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; - bwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; - bwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; - bwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; - } else { - bwp->bwp_Id=bwp_loop+1; - bwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); - bwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; - bwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.cyclicPrefix; - } - - bwp->bwp_Common->pdcch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon)); - bwp->bwp_Common->pdcch_ConfigCommon->present = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup)); - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet)); - - int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); - - NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); - rrc_coreset_config(coreset, curr_bwp, bitmap); - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset; - - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList)); - - NR_SearchSpace_t *ss=calloc(1,sizeof(*ss)); - ss->searchSpaceId = (bwp->bwp_Id<<1)-1; // To uniquely identify each SearchSpace lets derive it from the BWPId - ss->controlResourceSetId=calloc(1,sizeof(*ss->controlResourceSetId)); - *ss->controlResourceSetId=coreset->controlResourceSetId; - ss->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss->monitoringSlotPeriodicityAndOffset)); - ss->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; - ss->duration=NULL; - ss->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss->monitoringSymbolsWithinSlot)); - ss->monitoringSymbolsWithinSlot->buf = calloc(1,2); - // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed - ss->monitoringSymbolsWithinSlot->buf[1] = 0; - ss->monitoringSymbolsWithinSlot->buf[0] = (1<<7) | (1<<6); - ss->monitoringSymbolsWithinSlot->size = 2; - ss->monitoringSymbolsWithinSlot->bits_unused = 2; - ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates)); - ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; - ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; - ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; - ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; - ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; - ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType)); - ss->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; - ss->searchSpaceType->choice.common=calloc(1,sizeof(*ss->searchSpaceType->choice.common)); - ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss); - - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->pagingSearchSpace=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace)); - *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=ss->searchSpaceId; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ext1=NULL; - - bwp->bwp_Common->pdsch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon)); - bwp->bwp_Common->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup; - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup)); - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList)); - - nr_rrc_config_dl_tda(bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, - get_frame_type((int)*servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *servingcellconfigcommon->ssbSubcarrierSpacing), - servingcellconfigcommon->tdd_UL_DL_ConfigurationCommon, - curr_bwp); - - /// BWP dedicated configuration - - if (!bwp->bwp_Dedicated) { - bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated)); - } - bwp->bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config)); - bwp->bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup; - bwp->bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup)); - bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); - - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset); - - bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); - - NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2)); - ss2->searchSpaceId=(bwp->bwp_Id<<1); // To uniquely identify each SearchSpace lets derive it from the BWPId - ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); - *ss2->controlResourceSetId=coreset->controlResourceSetId; - ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); - ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; - ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; - ss2->duration=NULL; - ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot)); - ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2); - ss2->monitoringSymbolsWithinSlot->size = 2; - ss2->monitoringSymbolsWithinSlot->bits_unused = 2; - ss2->monitoringSymbolsWithinSlot->buf[0]=0xc0; - ss2->monitoringSymbolsWithinSlot->buf[1]=0x0; - ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates)); - ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; - ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; - if (curr_bwp < 48) - ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; - else if (curr_bwp < 96) - ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n2; - else - ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n4; - ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; - ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; - ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType)); - ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific)); - ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1; - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2); - - bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToReleaseList = NULL; - - if (!bwp->bwp_Dedicated->pdsch_Config) { - bwp->bwp_Dedicated->pdsch_Config = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config)); - bwp->bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; - bwp->bwp_Dedicated->pdsch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); - } - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; - - if ((get_softmodem_params()->do_ra || get_softmodem_params()->phy_test) && dl_antenna_ports > 1) // for MIMO, we use DMRS Config Type 2 but only with OAI UE - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type)); - else - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL; - if (!bwp->bwp_Dedicated->pdsch_Config) { - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL; - } - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); - *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0; - - bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList)); - - int n_ssb = 0; - NR_TCI_State_t *tcid[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - tcid[i]=calloc(1,sizeof(*tcid[i])); - tcid[i]->tci_StateId=n_ssb; - tcid[i]->qcl_Type1.cell=NULL; - tcid[i]->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid[i]->qcl_Type1.bwp_Id)); - *tcid[i]->qcl_Type1.bwp_Id=1; - tcid[i]->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; - tcid[i]->qcl_Type1.referenceSignal.choice.ssb = i; - tcid[i]->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC; - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid[i]); - n_ssb++; - } - } - - bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1; - set_dl_mcs_table(bwp->bwp_Common->genericParameters.subcarrierSpacing, - configuration->force_256qam_off ? NULL : uecap, - bwp->bwp_Dedicated, - servingcellconfigcommon); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI)); - *bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = - calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); - *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL; - bwp->bwp_Dedicated->sps_Config = NULL; - bwp->bwp_Dedicated->radioLinkMonitoringConfig = NULL; - -#if 0 - bwp->bwp_Dedicated->radioLinkMonitoringConfig = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig)); - bwp->bwp_Dedicated->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup; - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup)); - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL; - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL; - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount)); - *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3; - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer)); - *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2; -#endif - -} - void fill_default_nsa_uplinkBWP(NR_BWP_Uplink_t *ubwp, long bwp_loop, NR_ServingCellConfig_t *servingcellconfigdedicated, @@ -1106,7 +886,12 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList)); for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) { NR_BWP_Downlink_t *bwp = calloc(1,sizeof(*bwp)); - fill_default_nsa_downlinkBWP(bwp, bwp_loop, secondaryCellGroup, servingcellconfigdedicated, servingcellconfigcommon, configuration, uecap, dl_antenna_ports, bitmap); + config_downlinkBWP(bwp, servingcellconfigcommon, + servingcellconfigdedicated, + uecap, + dl_antenna_ports, + configuration->force_256qam_off, + bwp_loop, false); ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp); } secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id)); From 10b8e1b34c717006bc2fea629b9c30179c60719e Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 18 Apr 2022 11:59:40 +0200 Subject: [PATCH 05/98] harmonization of uplink BWPs configuration --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 294 +------------------------- openair2/RRC/NR/nr_rrc_config.c | 175 ++++++++++++++++ openair2/RRC/NR/nr_rrc_config.h | 7 + openair2/RRC/NR/rrc_gNB_reconfig.c | 309 +--------------------------- 4 files changed, 194 insertions(+), 591 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 569170883b..d734e92d95 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1005,293 +1005,6 @@ long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS) { return c_srs; } -void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, - int bwp_loop, - NR_ServingCellConfig_t *servingcellconfigdedicated, - NR_ServingCellConfigCommon_t *scc, - const gNB_RrcConfigurationReq *configuration, - int uid) { - - /// BWP common configuration - ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common)); - if(servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList && - bwp_loop < servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count) { - ubwp->bwp_Id = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; - ubwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; - ubwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; - ubwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; - } else { - ubwp->bwp_Id=bwp_loop+1; - ubwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); - ubwp->bwp_Common->genericParameters.subcarrierSpacing = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - ubwp->bwp_Common->genericParameters.cyclicPrefix = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.cyclicPrefix; - } - - ubwp->bwp_Common->rach_ConfigCommon = NULL; - ubwp->bwp_Common->pusch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; - ubwp->bwp_Common->pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; - - /// BWP dedicated configuration - ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated)); - - // PUCCH config - ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config)); - ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup; - NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config)); - ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config; - pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); - pucch_Config->resourceSetToReleaseList = NULL; - NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); - pucchresset0->pucch_ResourceSetId = 0; - NR_PUCCH_ResourceId_t *pucchres0id0=calloc(1,sizeof(*pucchres0id0)); - *pucchres0id0=ubwp->bwp_Id; // To uniquely identify each pucchresource lets derive it from the BWPId - ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchres0id0); - pucchresset0->maxPayloadSize=NULL; - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); - pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); - pucch_Config->resourceToReleaseList = NULL; - int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); - NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); - pucchres0->pucch_ResourceId=*pucchres0id0; - pucchres0->startingPRB=(8+uid) % curr_bwp; - pucchres0->intraSlotFrequencyHopping=NULL; - pucchres0->secondHopPRB=NULL; - pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; - pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); - pucchres0->format.choice.format0->initialCyclicShift=0; - pucchres0->format.choice.format0->nrofSymbols=1; - pucchres0->format.choice.format0->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); - -/* - pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); - pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; - NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); - pucch_Config->format2->choice.setup = pucchfmt2; - pucchfmt2->interslotFrequencyHopping=NULL; - pucchfmt2->additionalDMRS=NULL; - pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); - *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; - pucchfmt2->nrofSlots=NULL; - pucchfmt2->pi2BPSK=NULL; - pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); - *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; -*/ - - // PUCCH config - Scheduling request configuration - pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); - NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); - schedulingRequestResourceConfig->schedulingRequestResourceId = 1; - schedulingRequestResourceConfig->schedulingRequestID = 0; - schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; // 40 slot period - // note: make sure that there is no issue here. Later choose the RNTI accordingly. - // Here we would be limited to 3 UEs on this resource (1 1/2 Frames 30 kHz SCS, 5 ms TDD periodicity => slots 7,8,9). - // This should be a temporary resource until the first RRCReconfiguration gives new pucch resources. - // Check for above configuration and exit for now if it is not the case - AssertFatal(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing==NR_SubcarrierSpacing_kHz30, - "SCS != 30kHz\n"); - AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity==NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5, - "TDD period != 5ms : %ld\n",scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = 8; - schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); - *schedulingRequestResourceConfig->resource = *pucchres0id0; - ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); - pucch_Config->schedulingRequestResourceToReleaseList=NULL; - - pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; - pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); - long *delay[8]; - for (int i=0;i<8;i++) { - delay[i] = calloc(1,sizeof(*delay[i])); - AssertFatal(configuration->minRXTXTIME >=2 && configuration->minRXTXTIME <7, "check minRXTXTIME %d\n",configuration->minRXTXTIME); - *delay[i] = i+configuration->minRXTXTIME; - ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); - } - pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); - NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); - pucchspatial->pucch_SpatialRelationInfoId = 1; - pucchspatial->servingCellId = NULL; - if(configuration->do_CSIRS) { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - pucchspatial->referenceSignal.choice.csi_RS_Index = 0; - } - else { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; - } - pucchspatial->pucch_PathlossReferenceRS_Id = 0; - pucchspatial->p0_PUCCH_Id = 1; - pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; - ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); - pucch_Config->spatialRelationInfoToReleaseList=NULL; - pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; - pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); - NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); - p00->p0_PUCCH_Id=1; - p00->p0_PUCCH_Value = 0; - ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); - pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; - - // PUSCH config - ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); - ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; - NR_PUSCH_Config_t *pusch_Config = calloc(1,sizeof(*pusch_Config)); - ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config; - pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig)); - *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook; - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL; - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); - NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; - NR_DMRS_UplinkConfig->dmrs_Type = NULL; - NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = calloc(1,sizeof(*NR_DMRS_UplinkConfig->dmrs_AdditionalPosition)); - *NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0; - NR_DMRS_UplinkConfig->phaseTrackingRS=NULL; - NR_DMRS_UplinkConfig->maxLength=NULL; - NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled)); - NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL; - NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL; - NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL; - pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl)); - pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL; - pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha)); - *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1; - pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant)); - *pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = -98; - pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets)); - NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset)); - aset->p0_PUSCH_AlphaSetId=0; - aset->p0=calloc(1,sizeof(*aset->p0)); - *aset->p0 = 0; - aset->alpha=calloc(1,sizeof(*aset->alpha)); - *aset->alpha=NR_Alpha_alpha1; - ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset); - pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList)); - NR_PUSCH_PathlossReferenceRS_t *plrefRS = calloc(1,sizeof(*plrefRS)); - plrefRS->pusch_PathlossReferenceRS_Id=0; - plrefRS->referenceSignal.present = NR_PUSCH_PathlossReferenceRS__referenceSignal_PR_ssb_Index; - plrefRS->referenceSignal.choice.ssb_Index = 0; - ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList->list,plrefRS); - pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL; - pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL; - pusch_Config->pusch_PowerControl->deltaMCS = NULL; - pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList)); - NR_SRI_PUSCH_PowerControl_t *sriPUSCHPC=calloc(1,sizeof(*sriPUSCHPC)); - sriPUSCHPC->sri_PUSCH_PowerControlId=0; - sriPUSCHPC->sri_PUSCH_PathlossReferenceRS_Id=0; - sriPUSCHPC->sri_P0_PUSCH_AlphaSetId=0; - sriPUSCHPC->sri_PUSCH_ClosedLoopIndex=NR_SRI_PUSCH_PowerControl__sri_PUSCH_ClosedLoopIndex_i0; - ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList->list,sriPUSCHPC); - pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL; - pusch_Config->frequencyHopping=NULL; - pusch_Config->frequencyHoppingOffsetLists=NULL; - pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1; - pusch_Config->pusch_TimeDomainAllocationList = NULL; - pusch_Config->pusch_AggregationFactor=NULL; - pusch_Config->mcs_Table=NULL; - pusch_Config->mcs_TableTransformPrecoder=NULL; - pusch_Config->transformPrecoder= NULL; - if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) { - pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder)); - *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; - } - pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset)); - *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent; - pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank)); - *pusch_Config->maxRank= 1; - pusch_Config->rbg_Size=NULL; - pusch_Config->uci_OnPUSCH=NULL; - pusch_Config->tp_pi2BPSK=NULL; - uint8_t transform_precoding = NR_PUSCH_Config__transformPrecoder_disabled; - if (pusch_Config->transformPrecoder == NULL) { - if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder != NULL) - transform_precoding = NR_PUSCH_Config__transformPrecoder_enabled; - } - else { - transform_precoding = *pusch_Config->transformPrecoder; - } - if (transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled) { - // Enable DMRS uplink config for transform precoding enabled - NR_DMRS_UplinkConfig->transformPrecodingEnabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingEnabled)); - NR_DMRS_UplinkConfig->transformPrecodingEnabled->nPUSCH_Identity = NULL; - NR_DMRS_UplinkConfig->transformPrecodingEnabled->sequenceGroupHopping = NULL; - NR_DMRS_UplinkConfig->transformPrecodingEnabled->sequenceHopping = NULL; - NR_DMRS_UplinkConfig->transformPrecodingEnabled->ext1 = NULL; - LOG_I(NR_RRC,"Transform precoding enabled\n"); - } - - // SRS config - ubwp->bwp_Dedicated->configuredGrantConfig = NULL; - ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); - ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); - ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config; - srs_Config->srs_ResourceSetToReleaseList=NULL; - srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); - NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); - srs_resset0->srs_ResourceSetId = 0; - srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); - NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); - *srs_resset0_id=0; - ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); - srs_Config->srs_ResourceToReleaseList=NULL; - srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; - srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); - srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; - srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; - srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); - *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; - srs_resset0->resourceType.choice.aperiodic->ext1=NULL; - srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; - srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); - *srs_resset0->alpha = NR_Alpha_alpha1; - srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); - *srs_resset0->p0=-80; - srs_resset0->pathlossReferenceRS=NULL; - srs_resset0->srs_PowerControlAdjustmentStates=NULL; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); - srs_Config->srs_ResourceToReleaseList=NULL; - srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); - NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); - srs_res0->srs_ResourceId=0; - srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; - srs_res0->ptrs_PortIndex=NULL; - srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; - srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); - srs_res0->transmissionComb.choice.n2->combOffset_n2=0; - srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; - srs_res0->resourceMapping.startPosition=2; - srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; - srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; - srs_res0->freqDomainPosition=0; - srs_res0->freqDomainShift=0; - srs_res0->freqHopping.c_SRS=0; - srs_res0->freqHopping.b_SRS=0; - srs_res0->freqHopping.b_hop=0; - srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; - srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; - srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); - srs_res0->sequenceId=40; - srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); - srs_res0->spatialRelationInfo->servingCellId=NULL; - srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); - - ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; -} void fill_initial_SpCellConfig(int uid, NR_CellGroupConfig_t *cellGroupConfig, @@ -1608,7 +1321,12 @@ void fill_initial_SpCellConfig(int uid, SpCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList)); for (int bwp_loop = 0; bwp_loop < n_ul_bwp; bwp_loop++) { NR_BWP_Uplink_t *ubwp = calloc(1, sizeof(*ubwp)); - fill_default_uplinkBWP(ubwp, bwp_loop, servingcellconfigdedicated, scc, configuration, uid); + config_uplinkBWP(ubwp, bwp_loop, true, uid, + configuration, + servingcellconfigdedicated, + scc, + cellGroupConfig, + NULL); ASN_SEQUENCE_ADD(&SpCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list, ubwp); } SpCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id)); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index e94933416f..2171a45708 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -781,3 +781,178 @@ void config_downlinkBWP(NR_BWP_Downlink_t *bwp, } } +void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, + long bwp_loop, bool is_SA, int uid, + const gNB_RrcConfigurationReq *configuration, + NR_ServingCellConfig_t *servingcellconfigdedicated, + NR_ServingCellConfigCommon_t *scc, + NR_CellGroupConfig_t *cellGroupConfig, + NR_UE_NR_Capability_t *uecap) { + + ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common)); + if(servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList && + bwp_loop < servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count) { + ubwp->bwp_Id = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; + ubwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; + ubwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; + ubwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; + } else { + ubwp->bwp_Id=bwp_loop+1; + ubwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); + ubwp->bwp_Common->genericParameters.subcarrierSpacing = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + ubwp->bwp_Common->genericParameters.cyclicPrefix = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.cyclicPrefix; + } + + int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + + ubwp->bwp_Common->rach_ConfigCommon = is_SA ? NULL : scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon; + ubwp->bwp_Common->pusch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; + ubwp->bwp_Common->pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; + + if (!ubwp->bwp_Dedicated) { + ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated)); + } + + ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config)); + ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup; + NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config)); + ubwp->bwp_Dedicated->pucch_Config->choice.setup = pucch_Config; + pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); + pucch_Config->resourceSetToReleaseList = NULL; + pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); + pucch_Config->resourceToReleaseList = NULL; + config_pucch_resset0(pucch_Config, uid, curr_bwp, uecap); + config_pucch_resset1(pucch_Config, uecap); + set_pucch_power_config(pucch_Config, configuration->do_CSIRS); + scheduling_request_config(scc, cellGroupConfig->mac_CellGroupConfig, pucch_Config); + set_dl_DataToUL_ACK(pucch_Config, configuration->minRXTXTIME); + + ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); + ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; + NR_PUSCH_Config_t *pusch_Config = NULL; + if(servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList && + bwp_loop < servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count) { + pusch_Config = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Dedicated->pusch_Config->choice.setup; + } else { + pusch_Config = calloc(1,sizeof(*pusch_Config)); + } + ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config; + pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig)); + *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL; + if (!pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB) { + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); + } + NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; + NR_DMRS_UplinkConfig->dmrs_Type = NULL; + NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = calloc(1,sizeof(*NR_DMRS_UplinkConfig->dmrs_AdditionalPosition)); + *NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0; + NR_DMRS_UplinkConfig->phaseTrackingRS=NULL; + NR_DMRS_UplinkConfig->maxLength=NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled)); + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL; + pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl)); + pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL; + pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha)); + *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1; + pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = NULL; + pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets)); + NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset)); + aset->p0_PUSCH_AlphaSetId=0; + aset->p0=calloc(1,sizeof(*aset->p0)); + *aset->p0 = 0; + aset->alpha=calloc(1,sizeof(*aset->alpha)); + *aset->alpha=NR_Alpha_alpha1; + ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset); + pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = NULL; + pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL; + pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL; + pusch_Config->pusch_PowerControl->deltaMCS = NULL; + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = NULL; + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL; + pusch_Config->frequencyHopping=NULL; + pusch_Config->frequencyHoppingOffsetLists=NULL; + pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1; + pusch_Config->pusch_TimeDomainAllocationList = NULL; + pusch_Config->pusch_AggregationFactor=NULL; + pusch_Config->mcs_Table=NULL; + pusch_Config->mcs_TableTransformPrecoder=NULL; + pusch_Config->transformPrecoder= NULL; + if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) { + pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder)); + *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; + } + pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset)); + *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent; + pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank)); + *pusch_Config->maxRank= 1; + pusch_Config->rbg_Size=NULL; + pusch_Config->uci_OnPUSCH=NULL; + pusch_Config->tp_pi2BPSK=NULL; + + ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); + ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; + if(configuration->do_SRS) { + NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); + ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config; + srs_Config->srs_ResourceSetToReleaseList=NULL; + srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); + NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); + srs_resset0->srs_ResourceSetId = 0; + srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); + NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); + *srs_resset0_id=0; + ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); + srs_Config->srs_ResourceToReleaseList=NULL; + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; + srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); + srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; + srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; + srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); + *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; + srs_resset0->resourceType.choice.aperiodic->ext1=NULL; + srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; + srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); + *srs_resset0->alpha = NR_Alpha_alpha1; + srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); + *srs_resset0->p0=-80; + srs_resset0->pathlossReferenceRS=NULL; + srs_resset0->srs_PowerControlAdjustmentStates=NULL; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); + srs_Config->srs_ResourceToReleaseList=NULL; + srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); + NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); + srs_res0->srs_ResourceId=0; + srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; + srs_res0->ptrs_PortIndex=NULL; + srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; + srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); + srs_res0->transmissionComb.choice.n2->combOffset_n2=0; + srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; + srs_res0->resourceMapping.startPosition=2; + srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; + srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; + srs_res0->freqDomainPosition=0; + srs_res0->freqDomainShift=0; + srs_res0->freqHopping.c_SRS=0; + srs_res0->freqHopping.b_SRS=0; + srs_res0->freqHopping.b_hop=0; + srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; + srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); + srs_res0->sequenceId=40; + srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); + srs_res0->spatialRelationInfo->servingCellId=NULL; + srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); + } + ubwp->bwp_Dedicated->configuredGrantConfig = NULL; + ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; +} + + diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 2a477e8d14..6b6bb538a0 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -148,5 +148,12 @@ void config_downlinkBWP(NR_BWP_Downlink_t *bwp, int dl_antenna_ports, bool force_256qam_off, int bwp_loop, bool is_SA); +void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, + long bwp_loop, bool is_SA, int uid, + const gNB_RrcConfigurationReq *configuration, + NR_ServingCellConfig_t *servingcellconfigdedicated, + NR_ServingCellConfigCommon_t *scc, + NR_CellGroupConfig_t *cellGroupConfig, + NR_UE_NR_Capability_t *uecap); #endif diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 687d6268d1..c08bd9d006 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -83,308 +83,6 @@ void fix_servingcellconfigdedicated(NR_ServingCellConfig_t *scd) { } -void fill_default_nsa_uplinkBWP(NR_BWP_Uplink_t *ubwp, - long bwp_loop, - NR_ServingCellConfig_t *servingcellconfigdedicated, - NR_ServingCellConfigCommon_t *servingcellconfigcommon, - const gNB_RrcConfigurationReq *configuration, - int uid) { - - /// BWP common configuration - - ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common)); - - if(servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList && - bwp_loop < servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count) { - ubwp->bwp_Id = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; - ubwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; - ubwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; - ubwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; - } else { - ubwp->bwp_Id=bwp_loop+1; - ubwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); - ubwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - ubwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.cyclicPrefix; - } - - ubwp->bwp_Common->rach_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon; - ubwp->bwp_Common->pusch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; - ubwp->bwp_Common->pucch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; - - /// BWP dedicated configuration - - if (!ubwp->bwp_Dedicated) { - ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated)); - } - ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config)); - ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup; - NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config)); - ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config; - pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); - pucch_Config->resourceSetToReleaseList = NULL; - NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); - NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); - pucchresset0->pucch_ResourceSetId = 0; - NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); - *pucchresset0id0=1; - ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0); - pucchresset0->maxPayloadSize=NULL; - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); - - pucchresset1->pucch_ResourceSetId = 1; - NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); - *pucchresset1id0=2; - ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0); - pucchresset1->maxPayloadSize=NULL; - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); - - pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); - pucch_Config->resourceToReleaseList = NULL; - NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); - NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); - - int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275); - - pucchres0->pucch_ResourceId=1; - pucchres0->startingPRB= (8 + uid) % curr_bwp; - pucchres0->intraSlotFrequencyHopping=NULL; - pucchres0->secondHopPRB=NULL; - pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; - pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); - pucchres0->format.choice.format0->initialCyclicShift=0; - pucchres0->format.choice.format0->nrofSymbols=1; - pucchres0->format.choice.format0->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); - - pucchres2->pucch_ResourceId=2; - pucchres2->startingPRB=0; - pucchres2->intraSlotFrequencyHopping=NULL; - pucchres2->secondHopPRB=NULL; - pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2; - pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2)); - pucchres2->format.choice.format2->nrofPRBs=8; - pucchres2->format.choice.format2->nrofSymbols=1; - pucchres2->format.choice.format2->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); - - pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); - pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; - NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); - pucch_Config->format2->choice.setup = pucchfmt2; - pucchfmt2->interslotFrequencyHopping=NULL; - pucchfmt2->additionalDMRS=NULL; - pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); - *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; - pucchfmt2->nrofSlots=NULL; - pucchfmt2->pi2BPSK=NULL; - pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); - *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; - - // for scheduling requestresource - pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); - NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); - schedulingRequestResourceConfig->schedulingRequestResourceId = 1; - schedulingRequestResourceConfig->schedulingRequestID = 0; - schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = 7; - schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); - *schedulingRequestResourceConfig->resource = 1; - ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); - - pucch_Config->schedulingRequestResourceToReleaseList=NULL; - pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; - pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); - long *delay[8]; - for (int i=0;i<8;i++) { - delay[i] = calloc(1,sizeof(*delay[i])); - *delay[i] = i + configuration->minRXTXTIME; - ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); - } - pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); - NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); - pucchspatial->pucch_SpatialRelationInfoId = 1; - pucchspatial->servingCellId = NULL; - if(configuration->do_CSIRS) { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - pucchspatial->referenceSignal.choice.csi_RS_Index = 0; - } - else { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; - } - pucchspatial->pucch_PathlossReferenceRS_Id = 0; - pucchspatial->p0_PUCCH_Id = 1; - pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; - ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); - pucch_Config->spatialRelationInfoToReleaseList=NULL; - pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; - pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); - NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); - p00->p0_PUCCH_Id=1; - p00->p0_PUCCH_Value = 0; - ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); - pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; - - ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); - ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; - NR_PUSCH_Config_t *pusch_Config = NULL; - if(servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList && - bwp_loop < servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count) { - pusch_Config = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Dedicated->pusch_Config->choice.setup; - } else { - pusch_Config = calloc(1,sizeof(*pusch_Config)); - } - ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config; - pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig)); - *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook; - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL; - if (!pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB) { - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); - } - NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; - NR_DMRS_UplinkConfig->dmrs_Type = NULL; - NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = calloc(1,sizeof(*NR_DMRS_UplinkConfig->dmrs_AdditionalPosition)); - *NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0; - if (!servingcellconfigdedicated) { - NR_DMRS_UplinkConfig->phaseTrackingRS=NULL; - } - NR_DMRS_UplinkConfig->maxLength=NULL; - NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled)); - NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL; - NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL; - NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL; - pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl)); - pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL; - pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha)); - *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1; - pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = NULL; - pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets)); - NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset)); - aset->p0_PUSCH_AlphaSetId=0; - aset->p0=calloc(1,sizeof(*aset->p0)); - *aset->p0 = 0; - aset->alpha=calloc(1,sizeof(*aset->alpha)); - *aset->alpha=NR_Alpha_alpha1; - ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset); - pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = NULL; - pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL; - pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL; - pusch_Config->pusch_PowerControl->deltaMCS = NULL; - pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = NULL; - pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL; - pusch_Config->frequencyHopping=NULL; - pusch_Config->frequencyHoppingOffsetLists=NULL; - pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1; - pusch_Config->pusch_TimeDomainAllocationList = NULL; - pusch_Config->pusch_AggregationFactor=NULL; - pusch_Config->mcs_Table=NULL; - pusch_Config->transformPrecoder= NULL; - pusch_Config->mcs_TableTransformPrecoder=NULL; - /* if msg3_transformprecoding is set in conf file - pusch config should not disable it */ - if (servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) { - pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder)); - *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; - } - pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset)); - *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent; - pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank)); - *pusch_Config->maxRank= 1; - pusch_Config->rbg_Size=NULL; - pusch_Config->uci_OnPUSCH=NULL; - pusch_Config->tp_pi2BPSK=NULL; - - ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); - ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); - ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config; - srs_Config->srs_ResourceSetToReleaseList=NULL; - srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); - NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); - srs_resset0->srs_ResourceSetId = 0; - srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); - NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); - *srs_resset0_id=0; - ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); - srs_Config->srs_ResourceToReleaseList=NULL; - - if(configuration->do_SRS) { - srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_periodic; - srs_resset0->resourceType.choice.periodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.periodic)); - srs_resset0->resourceType.choice.periodic->associatedCSI_RS = NULL; - } else { - srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; - srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); - srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; - srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; - srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); - *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; - srs_resset0->resourceType.choice.aperiodic->ext1=NULL; - } - - srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; - srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); - *srs_resset0->alpha = NR_Alpha_alpha1; - srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); - *srs_resset0->p0=-80; - srs_resset0->pathlossReferenceRS=NULL; - srs_resset0->srs_PowerControlAdjustmentStates=NULL; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); - srs_Config->srs_ResourceToReleaseList=NULL; - srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); - NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); - srs_res0->srs_ResourceId=0; - srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; - srs_res0->ptrs_PortIndex=NULL; - srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; - srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); - srs_res0->transmissionComb.choice.n2->combOffset_n2=0; - srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; - srs_res0->resourceMapping.startPosition = 2 + uid%2; - srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; - srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; - srs_res0->freqDomainPosition=0; - srs_res0->freqDomainShift=0; - srs_res0->freqHopping.b_SRS=0; - srs_res0->freqHopping.b_hop=0; - srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs( - NRRIV2BW(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275), - srs_res0->freqHopping.b_SRS); - srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; - - if(configuration->do_SRS) { - srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_periodic; - srs_res0->resourceType.choice.periodic=calloc(1,sizeof(*srs_res0->resourceType.choice.periodic)); - srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.present = NR_SRS_PeriodicityAndOffset_PR_sl160; - srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.choice.sl160 = 17 + (uid>1)*10; // 17/17/.../147/157 are mixed slots - } else { - srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; - srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); - } - - srs_res0->sequenceId=40; - srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); - srs_res0->spatialRelationInfo->servingCellId=NULL; - srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); - - ubwp->bwp_Dedicated->configuredGrantConfig = NULL; - ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; - -} void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_ServingCellConfig_t *servingcellconfigdedicated, @@ -900,7 +598,12 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList)); for (int bwp_loop = 0; bwp_loop < n_ul_bwp; bwp_loop++) { NR_BWP_Uplink_t *ubwp = calloc(1,sizeof(*ubwp)); - fill_default_nsa_uplinkBWP(ubwp, bwp_loop, servingcellconfigdedicated, servingcellconfigcommon, configuration, uid); + config_uplinkBWP(ubwp, bwp_loop, false, uid, + configuration, + servingcellconfigdedicated, + servingcellconfigcommon, + secondaryCellGroup, + uecap); ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list,ubwp); } secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id)); From 9277afe3275eb68b385e21bce0e310a8f9575fa8 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 16 May 2022 11:59:39 +0200 Subject: [PATCH 06/98] measureing RSRP on all SSBs --- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 9 +- .../PHY/NR_UE_ESTIMATION/nr_ue_measurements.c | 66 +++--- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 7 - openair1/PHY/defs_nr_UE.h | 5 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 203 ++++++------------ 5 files changed, 102 insertions(+), 188 deletions(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index ce99f0f9c9..52b3af9a96 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -98,11 +98,10 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t slot); -void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue, - uint8_t gNB_index, - UE_nr_rxtx_proc_t *proc, - uint8_t slot, - uint8_t abstraction_flag); +void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, + uint8_t gNB_index, + UE_nr_rxtx_proc_t *proc, + uint8_t slot); void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index 7f6f0e8ef9..442bee09bf 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -203,18 +203,15 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, // Measurement units: // - RSRP: W (dBW) // - RX Gain dB -void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue, - uint8_t gNB_id, - UE_nr_rxtx_proc_t *proc, - uint8_t slot, - uint8_t abstraction_flag) -{ - int aarx; - int nb_re; +void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, + int ssb_index, + UE_nr_rxtx_proc_t *proc, + uint8_t slot) { + int k_start = 55; int k_end = 183; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; - uint8_t l_sss = ue->symbol_offset + 2; + uint8_t l_sss = ue->symbol_offset + 2; if (ssb_offset>= ue->frame_parms.ofdm_symbol_size){ @@ -222,50 +219,39 @@ void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue, } - ue->measurements.rsrp[gNB_id] = 0; + uint32_t rsrp = 0; - if (abstraction_flag == 0) { + LOG_D(PHY, "In %s: [UE %d] slot %d l_sss %d ssb_offset %d\n", __FUNCTION__, ue->Mod_id, slot, l_sss, ssb_offset); + int nb_re = 0; - LOG_D(PHY, "In %s: [UE %d] slot %d l_sss %d ssb_offset %d\n", __FUNCTION__, ue->Mod_id, slot, l_sss, ssb_offset); + for (int aarx = 0; aarx < ue->frame_parms.nb_antennas_rx; aarx++) { - nb_re = 0; + int16_t *rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aarx][(l_sss*ue->frame_parms.ofdm_symbol_size) + ssb_offset]; - for (aarx = 0; aarx < ue->frame_parms.nb_antennas_rx; aarx++) { + for(int k = k_start; k < k_end; k++){ - int16_t *rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aarx][(l_sss*ue->frame_parms.ofdm_symbol_size) + ssb_offset]; +#ifdef DEBUG_MEAS_UE + LOG_I(PHY, "In %s rxF_sss %d %d\n", __FUNCTION__, rxF_sss[k*2], rxF_sss[k*2 + 1]); +#endif - for(int k = k_start; k < k_end; k++){ + rsrp += (((int32_t)rxF_sss[k*2]*rxF_sss[k*2]) + ((int32_t)rxF_sss[k*2 + 1]*rxF_sss[k*2 + 1])); + nb_re++; - #ifdef DEBUG_MEAS_UE - LOG_I(PHY, "In %s rxF_sss %d %d\n", __FUNCTION__, rxF_sss[k*2], rxF_sss[k*2 + 1]); - #endif - - ue->measurements.rsrp[gNB_id] += (((int32_t)rxF_sss[k*2]*rxF_sss[k*2]) + ((int32_t)rxF_sss[k*2 + 1]*rxF_sss[k*2 + 1])); - - nb_re++; - - } } - - ue->measurements.rsrp[gNB_id] /= nb_re; - - } else { - - ue->measurements.rsrp[gNB_id] = -93; - } - ue->measurements.rsrp_filtered[gNB_id] = ue->measurements.rsrp[gNB_id]; + rsrp /= nb_re; + ue->measurements.ssb_rsrp_dBm[ssb_index] = 10*log10(rsrp) + + 30 - 10*log10(pow(2,30)) - + ((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0]) - + dB_fixed(ue->frame_parms.ofdm_symbol_size); - ue->measurements.rsrp_dBm[gNB_id] = 10*log10(ue->measurements.rsrp[gNB_id]) + 30 - 10*log10(pow(2,30)) - ((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0]) - dB_fixed(ue->frame_parms.ofdm_symbol_size); - - LOG_D(PHY, "In %s: [UE %d] slot %d SS-RSRP: %d dBm/RE (%d)\n", + LOG_D(PHY, "In %s: [UE %d] ssb %d SS-RSRP: %d dBm/RE (%d)\n", __FUNCTION__, ue->Mod_id, - slot, - ue->measurements.rsrp_dBm[gNB_id], - ue->measurements.rsrp[gNB_id]); - + ssb_index, + ue->measurements.ssb_rsrp_dBm[ssb_index], + rsrp); } // This function computes the received noise power diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index e248ce87cb..b38c1ff1d3 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -443,13 +443,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, } - LOG_I(PHY, "[UE %d] RRC Measurements => rssi %3.1f dBm (dig %3.1f dB, gain %d), N0 %d dBm, rsrp %3.1f dBm/RE, rsrq %3.1f dB\n",ue->Mod_id, - 10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB, - 10*log10(ue->measurements.rssi), - ue->rx_total_gain_dB, - ue->measurements.n0_power_tot_dBm, - 10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB, - (10*log10(ue->measurements.rsrq[0]))); /* LOG_I(PHY, "[UE %d] Frame %d MIB Information => %s, %s, NidCell %d, N_RB_DL %d, PHICH DURATION %d, PHICH RESOURCE %s, TX_ANT %d\n", ue->Mod_id, diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 82de7ed96e..fc40e70caf 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -132,12 +132,9 @@ typedef struct { // RRC measurements uint32_t rssi; int n_adj_cells; - unsigned int adj_cell_id[6]; - uint32_t rsrq[7]; uint32_t rsrp[7]; - float rsrp_filtered[7]; // after layer 3 filtering - float rsrq_filtered[7]; short rsrp_dBm[7]; + uint32_t ssb_rsrp_dBm[64]; // common measurements //! estimated noise power (linear) unsigned int n0_power[NB_ANTENNAS_RX]; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 9c4c6a4129..8abe77f93c 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -38,6 +38,7 @@ #include "PHY/defs_nr_UE.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/MODULATION/modulation_UE.h" +#include "PHY/INIT/phy_init.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_UE_TRANSPORT/srs_modulation_nr.h" @@ -361,11 +362,13 @@ void nr_ue_measurement_procedures(uint16_t l, } static void nr_ue_pbch_procedures(uint8_t gNB_id, - PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc,int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], NR_UE_PDCCH_CONFIG *phy_pdcch_config) -{ - int ret = 0; + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + int estimateSz, + struct complex16 dl_ch_estimates[][estimateSz], + NR_UE_PDCCH_CONFIG *phy_pdcch_config) { + int ret = 0; DevAssert(ue); int frame_rx = proc->frame_rx; @@ -1300,97 +1303,18 @@ void *UE_thread_slot1_dl_processing(void *arg) { } #endif -int is_ssb_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp) -{ - int mu = fp->numerology_index; - //uint8_t half_frame_index = fp->half_frame_bit; - //uint8_t i_ssb = fp->ssb_index; - uint8_t Lmax = fp->Lmax; - - if (!(frame%(1<<(config->ssb_table.ssb_period-1)))){ - - if(Lmax <= 8) { - if(slot <=3 && (((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*slot)&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*slot +1))&0x80000000) == 0x80000000)) - return 1; - else return 0; - - } - else if(Lmax == 64) { - if (mu == NR_MU_3){ - - if (slot>=0 && slot <= 7){ - if(((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*slot)&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*slot +1))&0x80000000) == 0x80000000) - return 1; - else return 0; - } - else if (slot>=10 && slot <=17){ - if(((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*(slot-2))&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*(slot-2) +1))&0x80000000) == 0x80000000) - return 1; - else return 0; - } - else if (slot>=20 && slot <=27){ - if(((config->ssb_table.ssb_mask_list[1].ssb_mask << 2*(slot-20))&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[1].ssb_mask << (2*(slot-20) +1))&0x80000000) == 0x80000000) - return 1; - else return 0; - } - else if (slot>=30 && slot <=37){ - if(((config->ssb_table.ssb_mask_list[1].ssb_mask << 2*(slot-22))&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[1].ssb_mask << (2*(slot-22) +1))&0x80000000) == 0x80000000) - return 1; - else return 0; - } - else return 0; - - } - - - else if (mu == NR_MU_4) { - AssertFatal(0==1, "not implemented for mu = %d yet\n", mu); - } - else AssertFatal(0==1, "Invalid numerology index %d for the synchronization block\n", mu); - } - else AssertFatal(0==1, "Invalid Lmax %u for the synchronization block\n", Lmax); - } - else return 0; - -} - -int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp) { - - int ssb_slot_decoded = (fp->ssb_index>>1) + ((fp->ssb_index>>4)<<1); //slot in which the decoded SSB can be found - - if (config->ssb_table.ssb_period == 0) { - // check for pbch in corresponding slot each half frame - if (fp->half_frame_bit) - return(slot == ssb_slot_decoded || slot == ssb_slot_decoded - fp->slots_per_frame/2); - else - return(slot == ssb_slot_decoded || slot == ssb_slot_decoded + fp->slots_per_frame/2); - } - else { - // if the current frame is supposed to contain ssb - if (!(frame%(1<<(config->ssb_table.ssb_period-1)))) - return(slot == ssb_slot_decoded); - else - return 0; - } -} - int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, uint8_t dlsch_parallel, NR_UE_PDCCH_CONFIG *phy_pdcch_config, - notifiedFIFO_t *txFifo - ) -{ + notifiedFIFO_t *txFifo) { + int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; - int slot_pbch; - int slot_ssb; fapi_nr_config_request_t *cfg = &ue->nrUE_config; - uint8_t nb_symb_pdcch = phy_pdcch_config->nb_search_space > 0 ? phy_pdcch_config->pdcch_config[0].coreset.duration : 0; - uint8_t dci_cnt = 0; NR_DL_FRAME_PARMS *fp = &ue->frame_parms; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); @@ -1400,64 +1324,72 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, frame_rx%1024, nr_slot_rx, dB_fixed(signal_energy(ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF[0],2048*14))); - /* - uint8_t next1_thread_id = proc->thread_id== (RX_NB_TH-1) ? 0:(proc->thread_id+1); - uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); - */ + // checking if current frame is compatible with SSB periodicity + if (cfg->ssb_table.ssb_period == 0 || + !(frame_rx%(1<<(cfg->ssb_table.ssb_period-1)))){ - int coreset_nb_rb=0; - int coreset_start_rb=0; + // loop over SSB blocks + for(int ssb_index=0; ssb_indexLmax; ssb_index++) { + uint32_t curr_mask = cfg->ssb_table.ssb_mask_list[ssb_index/32].ssb_mask; + // check if if current SSB is transmitted + if ((curr_mask >> (31-(ssb_index%32))) &0x01) { + int ssb_start_symbol = nr_get_ssb_start_symbol(fp, ssb_index); + int ssb_slot = ssb_start_symbol/fp->symbols_per_slot; + int ssb_slot_2 = (cfg->ssb_table.ssb_period == 0) ? ssb_slot+(fp->slots_per_frame>>1) : -1; - if (phy_pdcch_config->nb_search_space > 0) - get_coreset_rballoc(phy_pdcch_config->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb); + if (ssb_slot == nr_slot_rx || + ssb_slot_2 == nr_slot_rx) { - slot_pbch = is_pbch_in_slot(cfg, frame_rx, nr_slot_rx, fp); - slot_ssb = is_ssb_in_slot(cfg, frame_rx, nr_slot_rx, fp); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); + LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); - // looking for pbch only in slot where it is supposed to be - if (slot_ssb) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); - LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); + const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size]; - const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size; - __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; - __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size]; + for (int i=1; i<4; i++) { + nr_slot_fep(ue, + proc, + (ssb_start_symbol+i)%(fp->symbols_per_slot), + nr_slot_rx); - for (int i=1; i<4; i++) { + start_meas(&ue->dlsch_channel_estimation_stats); + nr_pbch_channel_estimation(ue, estimateSz, dl_ch_estimates, + dl_ch_estimates_time, proc, gNB_id, + nr_slot_rx, (ssb_start_symbol+i)%(fp->symbols_per_slot), + i-1, ssb_index&7, ssb_slot_2 == nr_slot_rx); + stop_meas(&ue->dlsch_channel_estimation_stats); + } - nr_slot_fep(ue, - proc, - (ue->symbol_offset+i)%(fp->symbols_per_slot), - nr_slot_rx); + nr_ue_ssb_rsrp_measurements(ue, ssb_index, proc, nr_slot_rx); - start_meas(&ue->dlsch_channel_estimation_stats); - nr_pbch_channel_estimation(ue, estimateSz, dl_ch_estimates, dl_ch_estimates_time,proc,gNB_id,nr_slot_rx,(ue->symbol_offset+i)%(fp->symbols_per_slot),i-1,(fp->ssb_index)&7,fp->half_frame_bit); - stop_meas(&ue->dlsch_channel_estimation_stats); - } + // resetting ssb index for PBCH detection if there is a stronger SSB index + if(measurements.ssb_rsrp_dBm[ssb_index]>ue->measurements.ssb_rsrp_dBm[fp->ssb_index]) + fp->ssb_index = ssb_index; - nr_ue_rsrp_measurements(ue, gNB_id, proc, nr_slot_rx, 0); + if(ssb_index == fp->ssb_index) { - if ((ue->decode_MIB == 1) && slot_pbch) { + LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); + nr_ue_pbch_procedures(gNB_id, ue, proc, estimateSz, dl_ch_estimates, phy_pdcch_config); - LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); - nr_ue_pbch_procedures(gNB_id, ue, proc, estimateSz, dl_ch_estimates, phy_pdcch_config); - - if (ue->no_timing_correction==0) { - LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); - nr_adjust_synch_ue(fp, - ue, - gNB_id, - fp->ofdm_symbol_size, - dl_ch_estimates_time, - frame_rx, - nr_slot_rx, - 0, - 16384); + if (ue->no_timing_correction==0) { + LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); + nr_adjust_synch_ue(fp, + ue, + gNB_id, + fp->ofdm_symbol_size, + dl_ch_estimates_time, + frame_rx, + nr_slot_rx, + 0, + 16384); + } + } + LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__); + nr_ue_rrc_measurements(ue, proc, nr_slot_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_OUT); + } } - - LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__); - nr_ue_rrc_measurements(ue, proc, nr_slot_rx); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_OUT); } } @@ -1472,6 +1404,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, LOG_D(PHY," ------ --> PDCCH ChannelComp/LLR Frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDCCH, VCD_FUNCTION_IN); + uint8_t nb_symb_pdcch = phy_pdcch_config->nb_search_space > 0 ? phy_pdcch_config->pdcch_config[0].coreset.duration : 0; for (uint16_t l=0; lofdm_demod_stats); @@ -1485,7 +1418,13 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, int32_t pdcch_est_size = ((((fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH))+15)/16)*16); __attribute__ ((aligned(16))) int32_t pdcch_dl_ch_estimates[4*fp->nb_antennas_rx][pdcch_est_size]; - dci_cnt = 0; + int coreset_nb_rb=0; + int coreset_start_rb=0; + + if (phy_pdcch_config->nb_search_space > 0) + get_coreset_rballoc(phy_pdcch_config->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb); + + uint8_t dci_cnt = 0; for(int n_ss = 0; n_ssnb_search_space; n_ss++) { for (uint16_t l=0; l Date: Mon, 16 May 2022 15:11:09 +0200 Subject: [PATCH 07/98] fixes for pbch detection and measurements on multiple SSBs --- openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c | 9 +++------ openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 3 ++- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index 442bee09bf..6e418b3f12 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -211,14 +211,11 @@ void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, int k_start = 55; int k_end = 183; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; - uint8_t l_sss = ue->symbol_offset + 2; - - if (ssb_offset>= ue->frame_parms.ofdm_symbol_size){ + uint8_t l_sss = (ue->symbol_offset + 2) % ue->frame_parms.symbols_per_slot; + if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset -= ue->frame_parms.ofdm_symbol_size; - } - uint32_t rsrp = 0; LOG_D(PHY, "In %s: [UE %d] slot %d l_sss %d ssb_offset %d\n", __FUNCTION__, ue->Mod_id, slot, l_sss, ssb_offset); @@ -267,7 +264,7 @@ void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, uint8_t k_left = 48; uint8_t k_right = 183; uint8_t k_length = 8; - uint8_t l_sss = ue->symbol_offset + 2; + uint8_t l_sss = (ue->symbol_offset + 2) % ue->frame_parms.symbols_per_slot; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; double rx_gain = openair0_cfg[0].rx_gain[0]; double rx_gain_offset = openair0_cfg[0].rx_gain_offset[0]; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 48b08d761e..1c3606d4dc 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -393,6 +393,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, MIMO_mode_t mimo_mode, NR_UE_PDCCH_CONFIG *phy_pdcch_config, fapiPbch_t *result) { + NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; int max_h=0; int symbol; @@ -416,7 +417,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, int symbol_offset=1; if (ue->is_synchronized > 0) - symbol_offset=(ue->symbol_offset)%(frame_parms->symbols_per_slot); + symbol_offset=nr_get_ssb_start_symbol(frame_parms, i_ssb)%(frame_parms->symbols_per_slot); else symbol_offset=0; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 8abe77f93c..deaefa1259 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1364,7 +1364,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_ue_ssb_rsrp_measurements(ue, ssb_index, proc, nr_slot_rx); // resetting ssb index for PBCH detection if there is a stronger SSB index - if(measurements.ssb_rsrp_dBm[ssb_index]>ue->measurements.ssb_rsrp_dBm[fp->ssb_index]) + if(ue->measurements.ssb_rsrp_dBm[ssb_index] > ue->measurements.ssb_rsrp_dBm[fp->ssb_index]) fp->ssb_index = ssb_index; if(ssb_index == fp->ssb_index) { From ef20a5c3b253504345c8c8c3add7eb0062a56172 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 16 May 2022 18:09:29 +0200 Subject: [PATCH 08/98] additional fixes in multi-ssb report at UE --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 3 +-- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 18 +++++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index fa177b98f5..b2ff4f758c 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -1543,9 +1543,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, } // cw loop corr_dB = dB_fixed64((uint64_t)corr); #ifdef DEBUG_NR_PUCCH_RX - printf("cw_ML %d, metric %d dB\n",cw_ML,corr_dB); + LOG_I(PHY,"slot %d PUCCH2 cw_ML %d, metric %d dB\n",slot,cw_ML,corr_dB); #endif - LOG_D(PHY,"slot %d PUCCH2 cw_ML %d, metric %d dB\n",slot,cw_ML,corr_dB); decodedPayload[0]=(uint64_t)cw_ML; } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index deaefa1259..9db3dcafd1 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -175,7 +175,7 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_length = frame_parms->Lmax; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.cell_id = frame_parms->Nid_cell; 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]; + rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.rsrp_dBm = ue->measurements.ssb_rsrp_dBm[frame_parms->ssb_index]; break; default: break; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index aba925800b..22cb2012e5 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2544,27 +2544,31 @@ uint8_t get_ssb_rsrp_payload(NR_UE_MAC_INST_t *mac, } else nb_meas = 2; + struct NR_CSI_SSB_ResourceSet__csi_SSB_ResourceList SSB_resource; for (int csi_ssb_idx = 0; csi_ssb_idx < csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.count; csi_ssb_idx++) { if (csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_ssb_idx]->csi_SSB_ResourceSetId == *(csi_resourceconfig->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list.array[0])){ - + SSB_resource = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_ssb_idx]->csi_SSB_ResourceList; ///only one SSB resource set from spec 38.331 IE CSI-ResourceConfig - nb_ssb = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_ssb_idx]->csi_SSB_ResourceList.list.count; + nb_ssb = SSB_resource.list.count; break; } } AssertFatal(nb_ssb>0,"No SSB found in the resource set\n"); + AssertFatal(nb_meas==1,"PHY currently reports only the strongest SSB to MAC. Can't report more than 1 RSRP\n"); int ssbri_bits = ceil(log2(nb_ssb)); - //TODO measurement of multiple SSBs at PHY and indication to MAC - if(nb_ssb>1) - LOG_E(MAC, "In current implementation only the SSB of synchronization is measured at PHY. This works only for a single SSB scenario\n"); - int ssb_rsrp[2][nb_meas]; // the array contains index and RSRP of each SSB to be reported (nb_meas highest RSRPs) //TODO replace the following 2 lines with a function to order the nb_meas highest SSB RSRPs - ssb_rsrp[0][0] = mac->mib_ssb; + for (int i=0; imib_ssb) { + ssb_rsrp[0][0] = i; + break; + } + } + AssertFatal(*SSB_resource.list.array[ssb_rsrp[0][0]] == mac->mib_ssb, "Couldn't find corresponding SSB in csi_SSB_ResourceList\n"); ssb_rsrp[1][0] = mac->ssb_rsrp_dBm; uint8_t ssbi; From a67791d18e81558d85265ec40737dee047310fb3 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 16 May 2022 19:37:16 +0200 Subject: [PATCH 09/98] init ssb rsrp vector --- openair1/PHY/INIT/nr_init_ue.c | 3 +++ openair1/PHY/defs_nr_UE.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 9927085a92..0ecf925e45 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -171,6 +171,9 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) AssertFatal( nb_connected_gNB <= NUMBER_OF_CONNECTED_gNB_MAX, "n_connected_gNB is too large" ); // init phy_vars_ue + for (i=0; iLmax; i++) + ue->measurements.ssb_rsrp_dBm[i] = INT_MIN; + for (i=0; i<4; i++) { ue->rx_gain_max[i] = 135; ue->rx_gain_med[i] = 128; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index fc40e70caf..79130ee107 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -134,7 +134,7 @@ typedef struct { int n_adj_cells; uint32_t rsrp[7]; short rsrp_dBm[7]; - uint32_t ssb_rsrp_dBm[64]; + int ssb_rsrp_dBm[64]; // common measurements //! estimated noise power (linear) unsigned int n0_power[NB_ANTENNAS_RX]; From 7a26d75634a0466a1e6316f15862012b2658da56 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 17 May 2022 18:18:15 +0200 Subject: [PATCH 10/98] other changes required for multiple BWP CSI config --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 375 ++++++++++++++-------------- openair2/RRC/NR/rrc_gNB_reconfig.c | 292 +++++++++++----------- 2 files changed, 329 insertions(+), 338 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index ec0efc1063..4f02db1bca 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1286,199 +1286,6 @@ void fill_initial_SpCellConfig(int uid, SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup; SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig; - if (configuration->do_CSIRS) { - - SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); - SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; - - NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); - SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig; - int pdsch_AntennaPorts = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP; - - config_csirs(scc, csi_MeasConfig, uid, pdsch_AntennaPorts, curr_bwp, configuration->do_CSIRS, 0); - config_csiim(configuration->do_CSIRS, pdsch_AntennaPorts, curr_bwp, csi_MeasConfig, 0); - - csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); - csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; - - NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); - ssbresset0->csi_SSB_ResourceSetId=0; - - uint64_t bitmap=0; - switch (scc->ssb_PositionsInBurst->present) { - case 1 : - bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; - break; - case 2 : - bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; - break; - case 3 : - for (int i=0; i<8; i++) { - bitmap |= (((uint64_t) scc->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); - } - break; - default: - AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); - } - - NR_SSB_Index_t *ssbresset[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - ssbresset[i]=calloc(1,sizeof(*ssbresset[i])); - *ssbresset[i] = i; - ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset[i]); - } - } - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); - - csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); - - csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; - NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); - csires0->csi_ResourceConfigId=0; - csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; - csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); - csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList)); - NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0)); - *nzp0 = 0; - ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); - csires0->bwp_Id = 0; - csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); - - - NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); - csires1->csi_ResourceConfigId=1; - csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; - csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); - csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); - NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); - *ssbres00 = 0; - ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); - csires1->bwp_Id = 0; - csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); - - if (pdsch_AntennaPorts > 1) { - NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); - csires2->csi_ResourceConfigId=2; - csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList; - csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList)); - NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00)); - *csiim00 = 0; - ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); - csires2->bwp_Id=0; - csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2); - } - - NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); - pucchcsires1->uplinkBandwidthPartId=0; - pucchcsires1->pucch_Resource=1; - csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); - csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; - if (pdsch_AntennaPorts > 1) { - LOG_I(NR_RRC,"Filling CSI Report Config for RI_PMI_CQI\n"); - NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); - csirep1->reportConfigId=0; - csirep1->carrier=NULL; - csirep1->resourcesForChannelMeasurement=0; - csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); - *csirep1->csi_IM_ResourcesForInterference=2; - csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; - csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); - csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (7 + (20 * uid)) % 320; - ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; - csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; - csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); - csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); - *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; - csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); - *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; - csirep1->reportFreqConfiguration->csi_ReportingBand = NULL; - /*calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand)); - csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1; - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1); - csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254;*/ - csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_notConfigured; - csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_notConfigured; - csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig)); - csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1; - csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); - csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= - calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; - csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; - csirep1->dummy = NULL; - csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; - csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); - //csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); - //*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; - csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table)); - *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; - csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value2; - csirep1->non_PMI_PortIndication = NULL; - csirep1->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1); - } - - LOG_I(NR_RRC,"Filling CSI Report Config for CRI_RSRP\n"); - NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); - csirep2->reportConfigId=1; - csirep2->carrier=NULL; - csirep2->resourcesForChannelMeasurement=0; - csirep2->csi_IM_ResourcesForInterference=NULL; - csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; - csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); - csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (27 + (20 * uid)) % 320; - ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; - csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; - csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); - csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL; - csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL; - csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; - csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; - csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; - csirep2->codebookConfig=NULL; - csirep2->dummy = NULL; - csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; - csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); - csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); - *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; - csirep2->cqi_Table = NULL; - csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; - csirep2->non_PMI_PortIndication = NULL; - csirep2->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); - } - pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; - pdsch_servingcellconfig->xOverhead = NULL; - pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH)); - *pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NR_PDSCH_ServingCellConfig__nrofHARQ_ProcessesForPDSCH_n16; - pdsch_servingcellconfig->pucch_Cell= NULL; - pdsch_servingcellconfig->ext1=calloc(1,sizeof(*pdsch_servingcellconfig->ext1)); - pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers)); - *pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2; - // Downlink BWPs int n_dl_bwp = 0; if (servingcellconfigdedicated && @@ -1525,6 +1332,188 @@ void fill_initial_SpCellConfig(int uid, *SpCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id : 1; } + + SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; + + NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig; + + csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); + csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; + csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); + csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; + csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); + csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; + + NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); + ssbresset0->csi_SSB_ResourceSetId=0; + + 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); + + int pdsch_AntennaPorts = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP; + + for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) { + NR_BWP_Downlink_t *bwp = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]; + int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + + config_csirs(scc, csi_MeasConfig, uid, pdsch_AntennaPorts, curr_bwp, configuration->do_CSIRS, bwp_loop); + config_csiim(configuration->do_CSIRS, pdsch_AntennaPorts, curr_bwp, csi_MeasConfig, bwp_loop); + + NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); + csires1->csi_ResourceConfigId = bwp->bwp_Id+20; + 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 = bwp->bwp_Id; + csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); + + if (configuration->do_CSIRS && pdsch_AntennaPorts > 1) { + NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); + csires0->csi_ResourceConfigId = bwp->bwp_Id; + 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 = bwp_loop; + ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); + csires0->bwp_Id = bwp->bwp_Id; + csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); + + NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); + csires2->csi_ResourceConfigId = bwp->bwp_Id+10; + 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 = bwp_loop; + ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); + csires2->bwp_Id = bwp->bwp_Id; + 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=bwp->bwp_Id; + pucchcsires1->pucch_Resource=2; + + if (pdsch_AntennaPorts > 1) { + LOG_I(NR_RRC,"Filling CSI Report Config for RI_PMI_CQI\n"); + NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); + csirep1->reportConfigId=0; + csirep1->carrier=NULL; + csirep1->resourcesForChannelMeasurement=bwp->bwp_Id; + csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); + *csirep1->csi_IM_ResourcesForInterference=bwp->bwp_Id+10; + csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); + csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (7 + (20 * uid)) % 320; + ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; + csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; + csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); + csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); + *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; + csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); + *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; + csirep1->reportFreqConfiguration->csi_ReportingBand = NULL; + /*calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand)); + csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1); + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254;*/ + csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_notConfigured; + csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_notConfigured; + csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig)); + csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1; + csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); + csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= + calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; + csirep1->dummy = NULL; + csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); + //csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + //*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table)); + if(bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table!=NULL) + *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table2; + else + *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=bwp->bwp_Id+10; + csirep2->carrier=NULL; + csirep2->resourcesForChannelMeasurement=bwp->bwp_Id; + csirep2->csi_IM_ResourcesForInterference=NULL; + csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); + csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (27 + (20 * uid)) % 320; + ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; + csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; + csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); + csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL; + csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL; + csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; + csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; + csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; + csirep2->codebookConfig=NULL; + csirep2->dummy = NULL; + csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); + csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep2->cqi_Table = NULL; + csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; + csirep2->non_PMI_PortIndication = NULL; + csirep2->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); + } + } + pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; + pdsch_servingcellconfig->xOverhead = NULL; + pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH)); + *pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NR_PDSCH_ServingCellConfig__nrofHARQ_ProcessesForPDSCH_n16; + pdsch_servingcellconfig->pucch_Cell= NULL; + pdsch_servingcellconfig->ext1=calloc(1,sizeof(*pdsch_servingcellconfig->ext1)); + pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers)); + *pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2; + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_SpCellConfig, (void *)SpCellConfig); } diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index bcbb8e585c..4b396a9da9 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -659,6 +659,9 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; + csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); + csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; + NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); ssbresset0->csi_SSB_ResourceSetId = 0; @@ -716,78 +719,75 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco ssbres->bwp_Id = bwp->bwp_Id; ssbres->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,ssbres); - } - NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); - pucchcsires1->uplinkBandwidthPartId=1; - pucchcsires1->pucch_Resource=2; + NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); + pucchcsires1->uplinkBandwidthPartId = bwp->bwp_Id; + pucchcsires1->pucch_Resource=2; - csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); - csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; - if (do_csirs && dl_antenna_ports > 1) { - NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); - csirep1->reportConfigId=0; - csirep1->carrier=NULL; - csirep1->resourcesForChannelMeasurement=0; - csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); - *csirep1->csi_IM_ResourcesForInterference=2; - csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; - csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); - csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9 + (20 * uid) % 320; - ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; - csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; - csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); - csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); - *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; - csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); - *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; - csirep1->reportFreqConfiguration->csi_ReportingBand = 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_configured; - csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; - 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)); - if (dl_antenna_ports == 2) { - 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; - } else if (dl_antenna_ports < 16) { - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo= - calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo)); - if(dl_antenna_ports == 4) - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction; - else if(dl_antenna_ports == 8) - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction; - else if(dl_antenna_ports == 12) - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction; - else//default + if (do_csirs && dl_antenna_ports > 1) { + NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); + csirep1->reportConfigId=bwp->bwp_Id; + csirep1->carrier=NULL; + csirep1->resourcesForChannelMeasurement=bwp->bwp_Id; + csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); + *csirep1->csi_IM_ResourcesForInterference=bwp->bwp_Id+10; + csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); + csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9 + (20 * uid) % 320; + ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; + csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; + csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); + csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); + *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; + csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); + *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; + csirep1->reportFreqConfiguration->csi_ReportingBand = 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_configured; + csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; + 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)); + if (dl_antenna_ports == 2) { + 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; + } else if (dl_antenna_ports < 16) { + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo= + calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo)); + if(dl_antenna_ports == 4) csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction; + else if(dl_antenna_ports == 8) + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction; + else if(dl_antenna_ports == 12) + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction; + else//default + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction; /*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.size=1; csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.bits_unused=1; @@ -797,86 +797,88 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->bits_unused=1; csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf=malloc(1); csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf[0]=0xc0;*/ - csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; - } else {//32 antennas are Not implemented yet - csirep1->codebookConfig->codebookType.choice.type1->codebookMode=2; + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; + } else {//32 antennas are Not implemented yet + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=2; + } + 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)); + if(bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table!=NULL) + *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table2; + else + *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); } - 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); - } - if (do_csirs) { - NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); - csirep2->reportConfigId=1; - csirep2->carrier=NULL; - csirep2->resourcesForChannelMeasurement=0; - csirep2->csi_IM_ResourcesForInterference=NULL; - csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; - csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); - csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; - ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; - csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; - csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); - csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL; - csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL; - csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; - csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; - csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; - csirep2->codebookConfig=NULL; - csirep2->dummy = NULL; - csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; - csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); - csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); - *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; - csirep2->cqi_Table = NULL; - csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; - csirep2->non_PMI_PortIndication = NULL; - csirep2->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); + if (do_csirs) { + NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); + csirep2->reportConfigId=bwp->bwp_Id+10; + csirep2->carrier=NULL; + csirep2->resourcesForChannelMeasurement=bwp->bwp_Id; + csirep2->csi_IM_ResourcesForInterference=NULL; + csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); + csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; + ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; + csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; + csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); + csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL; + csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL; + csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; + csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; + csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; + csirep2->codebookConfig=NULL; + csirep2->dummy = NULL; + csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); + csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep2->cqi_Table = NULL; + csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; + csirep2->non_PMI_PortIndication = NULL; + csirep2->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); + } + else{ + NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); + csirep2->reportConfigId=bwp->bwp_Id+10; + csirep2->carrier=NULL; + csirep2->resourcesForChannelMeasurement=1; + csirep2->csi_IM_ResourcesForInterference=NULL; + csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); + csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; + ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP; + csirep2->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0; + csirep2->reportFreqConfiguration = 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); + } } - else{ - NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); - csirep2->reportConfigId=1; - csirep2->carrier=NULL; - csirep2->resourcesForChannelMeasurement=1; - csirep2->csi_IM_ResourcesForInterference=NULL; - csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; - csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; - csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); - csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; - ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); - csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP; - csirep2->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0; - csirep2->reportFreqConfiguration = 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 = calloc(1,sizeof(*csirep2->cqi_Table)); - *csirep2->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; - csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; - csirep2->non_PMI_PortIndication = NULL; - csirep2->ext1 = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); - } - secondaryCellGroup->spCellConfig->spCellConfigDedicated->sCellDeactivationTimer=NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig=NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->tag_Id=0; From b57a8622c0e8c97e447ed99191c8918409392ab2 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 19 May 2022 17:41:58 +0200 Subject: [PATCH 11/98] fixes for RRC configuration in SA --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 85 ++++++++++++++++++++++------- openair2/RRC/NR_UE/rrc_UE.c | 7 --- 2 files changed, 65 insertions(+), 27 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 4f02db1bca..5ea04ddbc9 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1019,6 +1019,9 @@ void fill_initial_SpCellConfig(int uid, NR_ServingCellConfig_t *servingcellconfigdedicated, const gNB_RrcConfigurationReq *configuration) { + if (cellGroupConfig->spCellConfig == NULL) { + cellGroupConfig->spCellConfig = calloc(1,sizeof(*cellGroupConfig->spCellConfig)); + } NR_SpCellConfig_t *SpCellConfig = cellGroupConfig->spCellConfig; // This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4. @@ -1361,61 +1364,74 @@ void fill_initial_SpCellConfig(int uid, int pdsch_AntennaPorts = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP; - for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) { - NR_BWP_Downlink_t *bwp = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]; - int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + int bwp_loop_end = n_dl_bwp>0 ? n_dl_bwp : 1; + for (int bwp_loop = 0; bwp_loop < bwp_loop_end; bwp_loop++) { + + int curr_bwp, bwp_id; + struct NR_SetupRelease_PDSCH_Config *pdsch_Config; + if(n_dl_bwp == 0) { + pdsch_Config = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config; + curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + bwp_id = 0; + } + else { + NR_BWP_Downlink_t *bwp = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]; + pdsch_Config = bwp->bwp_Dedicated->pdsch_Config; + curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + bwp_id = bwp->bwp_Id; + } config_csirs(scc, csi_MeasConfig, uid, pdsch_AntennaPorts, curr_bwp, configuration->do_CSIRS, bwp_loop); config_csiim(configuration->do_CSIRS, pdsch_AntennaPorts, curr_bwp, csi_MeasConfig, bwp_loop); NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); - csires1->csi_ResourceConfigId = bwp->bwp_Id+20; + csires1->csi_ResourceConfigId = bwp_id+20; 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 = bwp->bwp_Id; + csires1->bwp_Id = bwp_id; csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); + NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); + pucchcsires1->uplinkBandwidthPartId=bwp_id; + pucchcsires1->pucch_Resource=2; + if (configuration->do_CSIRS && pdsch_AntennaPorts > 1) { NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); - csires0->csi_ResourceConfigId = bwp->bwp_Id; + csires0->csi_ResourceConfigId = bwp_id; 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 = bwp_loop; ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); - csires0->bwp_Id = bwp->bwp_Id; + csires0->bwp_Id = bwp_id; csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); - csires2->csi_ResourceConfigId = bwp->bwp_Id+10; + csires2->csi_ResourceConfigId = bwp_id+10; 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 = bwp_loop; ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); - csires2->bwp_Id = bwp->bwp_Id; + csires2->bwp_Id = bwp_id; 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=bwp->bwp_Id; - pucchcsires1->pucch_Resource=2; - if (pdsch_AntennaPorts > 1) { - LOG_I(NR_RRC,"Filling CSI Report Config for RI_PMI_CQI\n"); + LOG_D(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=bwp->bwp_Id; + csirep1->resourcesForChannelMeasurement=bwp_id; csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); - *csirep1->csi_IM_ResourcesForInterference=bwp->bwp_Id+10; + *csirep1->csi_IM_ResourcesForInterference=bwp_id+10; 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)); @@ -1462,7 +1478,7 @@ void fill_initial_SpCellConfig(int uid, //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)); - if(bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table!=NULL) + if(pdsch_Config->choice.setup->mcs_Table!=NULL) *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table2; else *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; @@ -1472,11 +1488,11 @@ void fill_initial_SpCellConfig(int uid, ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1); } - LOG_I(NR_RRC,"Filling CSI Report Config for CRI_RSRP\n"); + LOG_D(NR_RRC,"Filling CSI Report Config for CRI_RSRP\n"); NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); - csirep2->reportConfigId=bwp->bwp_Id+10; + csirep2->reportConfigId=bwp_id+10; csirep2->carrier=NULL; - csirep2->resourcesForChannelMeasurement=bwp->bwp_Id; + csirep2->resourcesForChannelMeasurement=bwp_id; csirep2->csi_IM_ResourcesForInterference=NULL; csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; @@ -1504,6 +1520,35 @@ void fill_initial_SpCellConfig(int uid, csirep2->ext1 = NULL; ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); } + else{ + NR_CSI_ReportConfig_t *csirep3 = calloc(1,sizeof(*csirep3)); + csirep3->reportConfigId=bwp_id+10; + csirep3->carrier=NULL; + csirep3->resourcesForChannelMeasurement=bwp_id+20; + csirep3->csi_IM_ResourcesForInterference=NULL; + csirep3->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep3->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep3->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep3->reportConfigType.choice.periodic)); + csirep3->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep3->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; + ASN_SEQUENCE_ADD(&csirep3->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep3->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP; + csirep3->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0; + csirep3->reportFreqConfiguration = NULL; + csirep3->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; + csirep3->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; + csirep3->codebookConfig= NULL; + csirep3->dummy = NULL; + csirep3->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep3->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep3->groupBasedBeamReporting.choice.disabled)); + csirep3->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep3->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + *csirep3->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep3->cqi_Table = NULL; + csirep3->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; + csirep3->non_PMI_PortIndication = NULL; + csirep3->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep3); + } } pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; pdsch_servingcellconfig->xOverhead = NULL; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 5c55b4131a..50ec32772d 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1340,13 +1340,6 @@ static void rrc_ue_generate_RRCSetupComplete( uint8_t size; const char *nas_msg; int nas_msg_length; - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig) - AssertFatal(1==0,"2 > csi_MeasConfig is not null\n"); if (AMF_MODE_ENABLED) { #if defined(ITTI_SIM) From f76ec13b8969a6825635ac2b0aafa99257b821ad Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 28 Jun 2022 15:47:18 +0200 Subject: [PATCH 12/98] some fixes --- openair2/RRC/NR/nr_rrc_config.c | 125 ++++++++++++++++------------- openair2/RRC/NR/rrc_gNB_reconfig.c | 2 +- 2 files changed, 71 insertions(+), 56 deletions(-) diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 1e35352d34..d0ed071075 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -171,7 +171,7 @@ void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList)); NR_NZP_CSI_RS_Resource_t *nzpcsi0 = calloc(1,sizeof(*nzpcsi0)); - nzpcsi0->nzp_CSI_RS_ResourceId = 0; + nzpcsi0->nzp_CSI_RS_ResourceId = id; NR_CSI_RS_ResourceMapping_t resourceMapping; switch (num_dl_antenna_ports) { case 1: @@ -829,15 +829,13 @@ void config_downlinkBWP(NR_BWP_Downlink_t *bwp, bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToReleaseList = NULL; - struct NR_SetupRelease_PDSCH_Config *pdsch_Config = bwp->bwp_Dedicated->pdsch_Config; - if (!pdsch_Config) { - pdsch_Config = calloc(1,sizeof(*pdsch_Config)); - pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; - pdsch_Config->choice.setup = calloc(1,sizeof(*pdsch_Config->choice.setup)); - pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); - pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; - pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); - } + struct NR_SetupRelease_PDSCH_Config *pdsch_Config = NULL; + pdsch_Config = calloc(1,sizeof(*pdsch_Config)); + pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; + pdsch_Config->choice.setup = calloc(1,sizeof(*pdsch_Config->choice.setup)); + pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); + pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; + pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; struct NR_SetupRelease_DMRS_DownlinkConfig *dmrs_DownlinkForPDSCH_MappingTypeA = pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA; @@ -857,6 +855,7 @@ void config_downlinkBWP(NR_BWP_Downlink_t *bwp, pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = calloc(1,sizeof(*pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); *pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; + bwp->bwp_Dedicated->pdsch_Config = pdsch_Config; set_dl_mcs_table(bwp->bwp_Common->genericParameters.subcarrierSpacing, force_256qam_off ? NULL : uecap, bwp->bwp_Dedicated, @@ -995,18 +994,23 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - if(configuration->do_SRS) { - NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); - ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config; - srs_Config->srs_ResourceSetToReleaseList=NULL; - srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); - NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); - srs_resset0->srs_ResourceSetId = 0; - srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); - NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); - *srs_resset0_id=0; - ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); - srs_Config->srs_ResourceToReleaseList=NULL; + NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); + ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config; + srs_Config->srs_ResourceSetToReleaseList=NULL; + srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); + NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); + srs_resset0->srs_ResourceSetId = 0; + srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); + NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); + *srs_resset0_id=0; + ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); + srs_Config->srs_ResourceToReleaseList=NULL; + + if (configuration->do_SRS) { + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_periodic; + srs_resset0->resourceType.choice.periodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.periodic)); + srs_resset0->resourceType.choice.periodic->associatedCSI_RS = NULL; + } else { srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; @@ -1014,42 +1018,53 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; srs_resset0->resourceType.choice.aperiodic->ext1=NULL; - srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; - srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); - *srs_resset0->alpha = NR_Alpha_alpha1; - srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); - *srs_resset0->p0=-80; - srs_resset0->pathlossReferenceRS=NULL; - srs_resset0->srs_PowerControlAdjustmentStates=NULL; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); - srs_Config->srs_ResourceToReleaseList=NULL; - srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); - NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); - srs_res0->srs_ResourceId=0; - srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; - srs_res0->ptrs_PortIndex=NULL; - srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; - srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); - srs_res0->transmissionComb.choice.n2->combOffset_n2=0; - srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; - srs_res0->resourceMapping.startPosition=2; - srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; - srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; - srs_res0->freqDomainPosition=0; - srs_res0->freqDomainShift=0; - srs_res0->freqHopping.c_SRS=0; - srs_res0->freqHopping.b_SRS=0; - srs_res0->freqHopping.b_hop=0; - srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; + } + + srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; + srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); + *srs_resset0->alpha = NR_Alpha_alpha1; + srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); + *srs_resset0->p0=-80; + srs_resset0->pathlossReferenceRS=NULL; + srs_resset0->srs_PowerControlAdjustmentStates=NULL; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); + srs_Config->srs_ResourceToReleaseList=NULL; + srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); + NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); + srs_res0->srs_ResourceId=0; + srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; + srs_res0->ptrs_PortIndex=NULL; + srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; + srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); + srs_res0->transmissionComb.choice.n2->combOffset_n2=0; + srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; + srs_res0->resourceMapping.startPosition = 2 + uid%2; + srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; + srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; + srs_res0->freqDomainPosition=0; + srs_res0->freqDomainShift=0; + srs_res0->freqHopping.b_SRS=0; + srs_res0->freqHopping.b_hop=0; + srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs(curr_bwp,srs_res0->freqHopping.b_SRS); + srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; + + if (configuration->do_SRS) { + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_periodic; + srs_res0->resourceType.choice.periodic=calloc(1,sizeof(*srs_res0->resourceType.choice.periodic)); + srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.present = NR_SRS_PeriodicityAndOffset_PR_sl160; + srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.choice.sl160 = 17 + (uid>1)*10; // 17/17/.../147/157 are mixed slots + } else { srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); - srs_res0->sequenceId=40; - srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); - srs_res0->spatialRelationInfo->servingCellId=NULL; - srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); } + + srs_res0->sequenceId=40; + srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); + srs_res0->spatialRelationInfo->servingCellId=NULL; + srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); + ubwp->bwp_Dedicated->configuredGrantConfig = NULL; ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; } diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 39f4d2f88b..1b372b2803 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -861,7 +861,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); csirep2->reportConfigId=bwp->bwp_Id+10; csirep2->carrier=NULL; - csirep2->resourcesForChannelMeasurement=1; + csirep2->resourcesForChannelMeasurement=bwp->bwp_Id+20; csirep2->csi_IM_ResourcesForInterference=NULL; csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; From 605f837eb6d78cc1eecffb82ba575fd06e7d4e35 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 29 Jun 2022 10:00:34 +0200 Subject: [PATCH 13/98] hardcoding the right AL and candidates --- openair1/SIMULATION/NR_PHY/dlsim.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 78b253ca2a..8bb98249bc 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -276,6 +276,13 @@ void nr_dlsim_preprocessor(module_id_t module_id, const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; sched_ctrl->search_space = get_searchspace(NULL, scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); + //TODO better implementation needed + //for now artificially set candidates for the required aggregation levels + sched_ctrl->search_space->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; + sched_ctrl->search_space->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; + sched_ctrl->search_space->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; + sched_ctrl->search_space->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n1; + sched_ctrl->search_space->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; uint8_t nr_of_candidates = 0; if (g_mcsIndex < 4) { find_aggregation_candidates(&sched_ctrl->aggregation_level, From 38dc925e753fc7bd143f063c0a48a533fc15039a Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 29 Jun 2022 16:06:58 +0200 Subject: [PATCH 14/98] temporary workaround for CQI MCS table --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 24b90c5198..efda67a535 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1669,6 +1669,21 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr } } +//TODO temp function (to remove once CSI meas config harmonization is done) +void update_cqitables(struct NR_SetupRelease_PDSCH_Config *pdsch_Config, + NR_CSI_MeasConfig_t *csi_MeasConfig) { + int nb_csi = csi_MeasConfig->csi_ReportConfigToAddModList->list.count; + for (int i = 0; i < nb_csi; i++) { + NR_CSI_ReportConfig_t *csirep = csi_MeasConfig->csi_ReportConfigToAddModList->list.array[i]; + if(csirep->cqi_Table) { + if(pdsch_Config->choice.setup->mcs_Table!=NULL) + *csirep->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table2; + else + *csirep->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; + } + } +} + void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_UE_NR_Capability_t *uecap, const gNB_RrcConfigurationReq* configuration) { @@ -1692,6 +1707,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, set_dl_mcs_table(scs, configuration->force_256qam_off ? NULL : uecap, bwp->bwp_Dedicated, scc); } } + update_cqitables(bwp_Dedicated->pdsch_Config, SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup); } } From 5427ec25b6e292dab97185b207e4f07d4d566b57 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 25 Jul 2022 15:24:58 +0200 Subject: [PATCH 15/98] applying config_srs to all the instances --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 6 +-- openair2/RRC/NR/nr_rrc_config.c | 81 +++-------------------------- openair2/RRC/NR/nr_rrc_config.h | 2 +- openair2/RRC/NR/rrc_gNB_reconfig.c | 77 +-------------------------- 4 files changed, 12 insertions(+), 154 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 487fa1bf38..2f94077261 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1101,7 +1101,7 @@ void fill_initial_SpCellConfig(int uid, // We are using do_srs = 0 here because the periodic SRS will only be enabled in update_cellGroupConfig() if do_srs == 1 initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); - config_srs(initialUplinkBWP->srs_Config, scc, uid, 0); + config_srs(initialUplinkBWP->srs_Config, curr_bwp, uid, 0); scheduling_request_config(scc, pucch_Config); @@ -1596,7 +1596,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc = configuration ? configuration->scc : NULL; if(scc) { - + int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); // SRS configuration if (configuration->do_SRS && SpCellConfig && @@ -1608,7 +1608,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config)); } config_srs(SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config, - scc, + curr_bwp, uid, configuration->do_SRS); } diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index ba12c9554c..d05ae2a8ce 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -350,7 +350,7 @@ long rrc_get_max_nr_csrs(const uint8_t max_rbs, const long b_SRS) { } void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, - const NR_ServingCellConfigCommon_t *servingcellconfigcommon, + const int curr_bwp, const int uid, const int do_srs) { @@ -427,10 +427,7 @@ void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, srs_res0->freqDomainShift = 0; srs_res0->freqHopping.b_SRS = 0; srs_res0->freqHopping.b_hop = 0; - srs_res0->freqHopping.c_SRS = servingcellconfigcommon ? - rrc_get_max_nr_csrs( - NRRIV2BW(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275), - srs_res0->freqHopping.b_SRS) : 0; + srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs(curr_bwp, srs_res0->freqHopping.b_SRS); srs_res0->groupOrSequenceHopping = NR_SRS_Resource__groupOrSequenceHopping_neither; if (do_srs) { srs_res0->resourceType.present = NR_SRS_Resource__resourceType_PR_periodic; @@ -1117,76 +1114,10 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); - ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config; - srs_Config->srs_ResourceSetToReleaseList=NULL; - srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); - NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); - srs_resset0->srs_ResourceSetId = 0; - srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); - NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); - *srs_resset0_id=0; - ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); - srs_Config->srs_ResourceToReleaseList=NULL; - - if (configuration->do_SRS) { - srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_periodic; - srs_resset0->resourceType.choice.periodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.periodic)); - srs_resset0->resourceType.choice.periodic->associatedCSI_RS = NULL; - } else { - srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; - srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); - srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; - srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; - srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); - *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; - srs_resset0->resourceType.choice.aperiodic->ext1=NULL; - } - - srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; - srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); - *srs_resset0->alpha = NR_Alpha_alpha1; - srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); - *srs_resset0->p0=-80; - srs_resset0->pathlossReferenceRS=NULL; - srs_resset0->srs_PowerControlAdjustmentStates=NULL; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); - srs_Config->srs_ResourceToReleaseList=NULL; - srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); - NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); - srs_res0->srs_ResourceId=0; - srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; - srs_res0->ptrs_PortIndex=NULL; - srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; - srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); - srs_res0->transmissionComb.choice.n2->combOffset_n2=0; - srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; - srs_res0->resourceMapping.startPosition = 2 + uid%2; - srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; - srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; - srs_res0->freqDomainPosition=0; - srs_res0->freqDomainShift=0; - srs_res0->freqHopping.b_SRS=0; - srs_res0->freqHopping.b_hop=0; - srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs(curr_bwp,srs_res0->freqHopping.b_SRS); - srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; - - if (configuration->do_SRS) { - srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_periodic; - srs_res0->resourceType.choice.periodic=calloc(1,sizeof(*srs_res0->resourceType.choice.periodic)); - srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.present = NR_SRS_PeriodicityAndOffset_PR_sl160; - srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.choice.sl160 = 17 + (uid>1)*10; // 17/17/.../147/157 are mixed slots - } else { - srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; - srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); - } - - srs_res0->sequenceId=40; - srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); - srs_res0->spatialRelationInfo->servingCellId=NULL; - srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); + config_srs(ubwp->bwp_Dedicated->srs_Config, + curr_bwp, + uid, + 0); ubwp->bwp_Dedicated->configuredGrantConfig = NULL; ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index fe64804616..2b7a84fe33 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -137,7 +137,7 @@ void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, void config_csiim(int do_csirs, int dl_antenna_ports, int curr_bwp, NR_CSI_MeasConfig_t *csi_MeasConfig, int id); void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, - const NR_ServingCellConfigCommon_t *servingcellconfigcommon, + const int curr_bwp, const int uid, const int do_srs); void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 3d83b2ce51..69beb45ce8 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -487,83 +487,10 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco LOG_I(RRC,"TRANSFORM PRECODING ENABLED......\n"); } + int curr_bwp = NRRIV2BW(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); initialUplinkBWP->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - - NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); - initialUplinkBWP->srs_Config->choice.setup=srs_Config; - srs_Config->srs_ResourceSetToReleaseList=NULL; - srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); - NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); - srs_resset0->srs_ResourceSetId = 0; - srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); - NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); - *srs_resset0_id=0; - ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); - srs_Config->srs_ResourceToReleaseList=NULL; - - if (configuration->do_SRS) { - srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_periodic; - srs_resset0->resourceType.choice.periodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.periodic)); - srs_resset0->resourceType.choice.periodic->associatedCSI_RS = NULL; - } else { - srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; - srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); - srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; - srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; - srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); - *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; - srs_resset0->resourceType.choice.aperiodic->ext1=NULL; - } - - srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; - srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); - *srs_resset0->alpha = NR_Alpha_alpha1; - srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); - *srs_resset0->p0=-80; - srs_resset0->pathlossReferenceRS=NULL; - srs_resset0->srs_PowerControlAdjustmentStates=NULL; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); - srs_Config->srs_ResourceToReleaseList=NULL; - srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); - NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); - srs_res0->srs_ResourceId=0; - srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; - srs_res0->ptrs_PortIndex=NULL; - srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; - srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); - srs_res0->transmissionComb.choice.n2->combOffset_n2=0; - srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; - srs_res0->resourceMapping.startPosition = 2 + uid%2; - srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; - srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; - srs_res0->freqDomainPosition=0; - srs_res0->freqDomainShift=0; - srs_res0->freqHopping.b_SRS=0; - srs_res0->freqHopping.b_hop=0; - srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs( - NRRIV2BW(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275), - srs_res0->freqHopping.b_SRS); - srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; - - if (configuration->do_SRS) { - srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_periodic; - srs_res0->resourceType.choice.periodic=calloc(1,sizeof(*srs_res0->resourceType.choice.periodic)); - srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.present = NR_SRS_PeriodicityAndOffset_PR_sl160; - srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.choice.sl160 = 17 + (uid>1)*10; // 17/17/.../147/157 are mixed slots - } else { - srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; - srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); - } - - srs_res0->sequenceId=40; - srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); - srs_res0->spatialRelationInfo->servingCellId=NULL; - srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); - - /// Dedicated BWPs + config_srs(initialUplinkBWP->srs_Config, curr_bwp, uid, configuration->do_SRS); // Downlink BWPs int n_dl_bwp = 1; From 6e2a83856b64a5b38c4f4e355d3f22226aa3153e Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 4 Aug 2022 17:19:15 +0200 Subject: [PATCH 16/98] common function to get sample rate and BW --- common/utils/nr/nr_common.c | 230 ++++++++++++++++++++++++++ common/utils/nr/nr_common.h | 7 + executables/nr-ru.c | 228 +------------------------ openair1/SIMULATION/NR_PHY/dlsim.c | 53 ++---- openair1/SIMULATION/NR_PHY/pucchsim.c | 53 ++---- openair1/SIMULATION/NR_PHY/ulsim.c | 45 ++--- 6 files changed, 279 insertions(+), 337 deletions(-) diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index 6add03c324..0fb4824d42 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -472,6 +472,236 @@ int get_subband_size(int NPRB,int size) { } +void get_samplerate_and_bw(int mu, + int n_rb, + int8_t threequarter_fs, + double *sample_rate, + unsigned int *samples_per_frame, + double *tx_bw, + double *rx_bw) { + + if (mu == 0) { + switch(n_rb) { + case 270: + if (threequarter_fs) { + *sample_rate=92.16e6; + *samples_per_frame = 921600; + *tx_bw = 50e6; + *rx_bw = 50e6; + } else { + *sample_rate=61.44e6; + *samples_per_frame = 614400; + *tx_bw = 50e6; + *rx_bw = 50e6; + } + case 216: + if (threequarter_fs) { + *sample_rate=46.08e6; + *samples_per_frame = 460800; + *tx_bw = 40e6; + *rx_bw = 40e6; + } + else { + *sample_rate=61.44e6; + *samples_per_frame = 614400; + *tx_bw = 40e6; + *rx_bw = 40e6; + } + break; + case 160: //30 MHz + case 133: //25 MHz + if (threequarter_fs) { + AssertFatal(1==0,"N_RB %d cannot use 3/4 sampling\n",n_rb); + } + else { + *sample_rate=30.72e6; + *samples_per_frame = 307200; + *tx_bw = 20e6; + *rx_bw = 20e6; + } + case 106: + if (threequarter_fs) { + *sample_rate=23.04e6; + *samples_per_frame = 230400; + *tx_bw = 20e6; + *rx_bw = 20e6; + } + else { + *sample_rate=30.72e6; + *samples_per_frame = 307200; + *tx_bw = 20e6; + *rx_bw = 20e6; + } + break; + case 52: + if (threequarter_fs) { + *sample_rate=11.52e6; + *samples_per_frame = 115200; + *tx_bw = 10e6; + *rx_bw = 10e6; + } + else { + *sample_rate=15.36e6; + *samples_per_frame = 153600; + *tx_bw = 10e6; + *rx_bw = 10e6; + } + case 25: + if (threequarter_fs) { + *sample_rate=5.76e6; + *samples_per_frame = 57600; + *tx_bw = 5e6; + *rx_bw = 5e6; + } + else { + *sample_rate=7.68e6; + *samples_per_frame = 76800; + *tx_bw = 5e6; + *rx_bw = 5e6; + } + break; + default: + AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",n_rb,mu); + } + } else if (mu == 1) { + switch(n_rb) { + + case 273: + if (threequarter_fs) { + *sample_rate=184.32e6; + *samples_per_frame = 1843200; + *tx_bw = 100e6; + *rx_bw = 100e6; + } else { + *sample_rate=122.88e6; + *samples_per_frame = 1228800; + *tx_bw = 100e6; + *rx_bw = 100e6; + } + break; + case 217: + if (threequarter_fs) { + *sample_rate=92.16e6; + *samples_per_frame = 921600; + *tx_bw = 80e6; + *rx_bw = 80e6; + } else { + *sample_rate=122.88e6; + *samples_per_frame = 1228800; + *tx_bw = 80e6; + *rx_bw = 80e6; + } + break; + case 162 : + if (threequarter_fs) { + AssertFatal(1==0,"N_RB %d cannot use 3/4 sampling\n",n_rb); + } + else { + *sample_rate=61.44e6; + *samples_per_frame = 614400; + *tx_bw = 60e6; + *rx_bw = 60e6; + } + + break; + + case 133 : + if (threequarter_fs) { + AssertFatal(1==0,"N_RB %d cannot use 3/4 sampling\n",n_rb); + } + else { + *sample_rate=61.44e6; + *samples_per_frame = 614400; + *tx_bw = 50e6; + *rx_bw = 50e6; + } + + break; + case 106: + if (threequarter_fs) { + *sample_rate=46.08e6; + *samples_per_frame = 460800; + *tx_bw = 40e6; + *rx_bw = 40e6; + } + else { + *sample_rate=61.44e6; + *samples_per_frame = 614400; + *tx_bw = 40e6; + *rx_bw = 40e6; + } + break; + case 51: + if (threequarter_fs) { + *sample_rate=23.04e6; + *samples_per_frame = 230400; + *tx_bw = 20e6; + *rx_bw = 20e6; + } + else { + *sample_rate=30.72e6; + *samples_per_frame = 307200; + *tx_bw = 20e6; + *rx_bw = 20e6; + } + break; + case 24: + if (threequarter_fs) { + *sample_rate=11.52e6; + *samples_per_frame = 115200; + *tx_bw = 10e6; + *rx_bw = 10e6; + } + else { + *sample_rate=15.36e6; + *samples_per_frame = 153600; + *tx_bw = 10e6; + *rx_bw = 10e6; + } + break; + default: + AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",n_rb,mu); + } + } else if (mu == 3) { + switch(n_rb) { + case 66: + if (threequarter_fs) { + *sample_rate=184.32e6; + *samples_per_frame = 1843200; + *tx_bw = 100e6; + *rx_bw = 100e6; + } else { + *sample_rate = 122.88e6; + *samples_per_frame = 1228800; + *tx_bw = 100e6; + *rx_bw = 100e6; + } + + break; + + case 32: + if (threequarter_fs) { + *sample_rate=92.16e6; + *samples_per_frame = 921600; + *tx_bw = 50e6; + *rx_bw = 50e6; + } else { + *sample_rate=61.44e6; + *samples_per_frame = 614400; + *tx_bw = 50e6; + *rx_bw = 50e6; + } + + break; + + default: + AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",n_rb,mu); + } + } else { + AssertFatal(0 == 1,"Numerology %d not supported for the moment\n",mu); + } +} + // from start symbol index and nb or symbols to symbol occupation bitmap in a slot uint16_t SL_to_bitmap(int startSymbolIndex, int nrOfSymbols) { return ((1<ssb_config.scs_common.value; int N_RB = config->carrier_config.dl_grid_size[config->ssb_config.scs_common.value].value; - if (mu == NR_MU_0) { - switch(N_RB) { - case 270: - if (fp->threequarter_fs) { - cfg->sample_rate=92.16e6; - cfg->samples_per_frame = 921600; - cfg->tx_bw = 50e6; - cfg->rx_bw = 50e6; - } else { - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 614400; - cfg->tx_bw = 50e6; - cfg->rx_bw = 50e6; - } - case 216: - if (fp->threequarter_fs) { - cfg->sample_rate=46.08e6; - cfg->samples_per_frame = 460800; - cfg->tx_bw = 40e6; - cfg->rx_bw = 40e6; - } - else { - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 614400; - cfg->tx_bw = 40e6; - cfg->rx_bw = 40e6; - } - break; - case 160: //30 MHz - case 133: //25 MHz - if (fp->threequarter_fs) { - AssertFatal(1==0,"N_RB %d cannot use 3/4 sampling\n",N_RB); - } - else { - cfg->sample_rate=30.72e6; - cfg->samples_per_frame = 307200; - cfg->tx_bw = 20e6; - cfg->rx_bw = 20e6; - } - case 106: - if (fp->threequarter_fs) { - cfg->sample_rate=23.04e6; - cfg->samples_per_frame = 230400; - cfg->tx_bw = 20e6; - cfg->rx_bw = 20e6; - } - else { - cfg->sample_rate=30.72e6; - cfg->samples_per_frame = 307200; - cfg->tx_bw = 20e6; - cfg->rx_bw = 20e6; - } - break; - case 52: - if (fp->threequarter_fs) { - cfg->sample_rate=11.52e6; - cfg->samples_per_frame = 115200; - cfg->tx_bw = 10e6; - cfg->rx_bw = 10e6; - } - else { - cfg->sample_rate=15.36e6; - cfg->samples_per_frame = 153600; - cfg->tx_bw = 10e6; - cfg->rx_bw = 10e6; - } - case 25: - if (fp->threequarter_fs) { - cfg->sample_rate=5.76e6; - cfg->samples_per_frame = 57600; - cfg->tx_bw = 5e6; - cfg->rx_bw = 5e6; - } - else { - cfg->sample_rate=7.68e6; - cfg->samples_per_frame = 76800; - cfg->tx_bw = 5e6; - cfg->rx_bw = 5e6; - } - break; - default: - AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu); - } - } else if (mu == NR_MU_1) { - switch(N_RB) { - - case 273: - if (fp->threequarter_fs) { - cfg->sample_rate=184.32e6; - cfg->samples_per_frame = 1843200; - cfg->tx_bw = 100e6; - cfg->rx_bw = 100e6; - } else { - cfg->sample_rate=122.88e6; - cfg->samples_per_frame = 1228800; - cfg->tx_bw = 100e6; - cfg->rx_bw = 100e6; - } - break; - case 217: - if (fp->threequarter_fs) { - cfg->sample_rate=92.16e6; - cfg->samples_per_frame = 921600; - cfg->tx_bw = 80e6; - cfg->rx_bw = 80e6; - } else { - cfg->sample_rate=122.88e6; - cfg->samples_per_frame = 1228800; - cfg->tx_bw = 80e6; - cfg->rx_bw = 80e6; - } - break; - case 162 : - if (fp->threequarter_fs) { - AssertFatal(1==0,"N_RB %d cannot use 3/4 sampling\n",N_RB); - } - else { - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 614400; - cfg->tx_bw = 60e6; - cfg->rx_bw = 60e6; - } - - break; - - case 133 : - if (fp->threequarter_fs) { - AssertFatal(1==0,"N_RB %d cannot use 3/4 sampling\n",N_RB); - } - else { - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 614400; - cfg->tx_bw = 50e6; - cfg->rx_bw = 50e6; - } - - break; - case 106: - if (fp->threequarter_fs) { - cfg->sample_rate=46.08e6; - cfg->samples_per_frame = 460800; - cfg->tx_bw = 40e6; - cfg->rx_bw = 40e6; - } - else { - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 614400; - cfg->tx_bw = 40e6; - cfg->rx_bw = 40e6; - } - break; - case 51: - if (fp->threequarter_fs) { - cfg->sample_rate=23.04e6; - cfg->samples_per_frame = 230400; - cfg->tx_bw = 20e6; - cfg->rx_bw = 20e6; - } - else { - cfg->sample_rate=30.72e6; - cfg->samples_per_frame = 307200; - cfg->tx_bw = 20e6; - cfg->rx_bw = 20e6; - } - break; - case 24: - if (fp->threequarter_fs) { - cfg->sample_rate=11.52e6; - cfg->samples_per_frame = 115200; - cfg->tx_bw = 10e6; - cfg->rx_bw = 10e6; - } - else { - cfg->sample_rate=15.36e6; - cfg->samples_per_frame = 153600; - cfg->tx_bw = 10e6; - cfg->rx_bw = 10e6; - } - break; - default: - AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu); - } - } else if (mu == NR_MU_3) { - switch(N_RB) { - case 66: - if (fp->threequarter_fs) { - cfg->sample_rate=184.32e6; - cfg->samples_per_frame = 1843200; - cfg->tx_bw = 100e6; - cfg->rx_bw = 100e6; - } else { - cfg->sample_rate = 122.88e6; - cfg->samples_per_frame = 1228800; - cfg->tx_bw = 100e6; - cfg->rx_bw = 100e6; - } - - break; - - case 32: - if (fp->threequarter_fs) { - cfg->sample_rate=92.16e6; - cfg->samples_per_frame = 921600; - cfg->tx_bw = 50e6; - cfg->rx_bw = 50e6; - } else { - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 614400; - cfg->tx_bw = 50e6; - cfg->rx_bw = 50e6; - } - - break; - - default: - AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu); - } - } else { - AssertFatal(0 == 1,"Numerology %d not supported for the moment\n",mu); - } + get_samplerate_and_bw(mu, + N_RB, + fp->threequarter_fs, + &cfg->sample_rate, + &cfg->samples_per_frame, + &cfg->tx_bw, + &cfg->rx_bw); if (config->cell_config.frame_duplex_type.value==TDD) cfg->duplex_mode = duplex_mode_TDD; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 57c6589ca4..b62559ecfa 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -887,55 +887,22 @@ int main(int argc, char **argv) if (g_rbStart < 0) g_rbStart=0; if (g_rbSize < 0) g_rbSize = N_RB_DL - g_rbStart; - double fs,bw; + double fs,txbw,rxbw; + uint32_t samples; - if (mu == 0 && N_RB_DL == 25) { - fs = 7.68e6; - bw = 5e6; - } - else if (mu == 1 && N_RB_DL == 217) { - fs = 122.88e6; - bw = 80e6; - } - else if (mu == 1 && N_RB_DL == 245) { - fs = 122.88e6; - bw = 90e6; - } - else if (mu == 1 && N_RB_DL == 273) { - fs = 122.88e6; - bw = 100e6; - } - else if (mu == 1 && N_RB_DL == 106) { - fs = 61.44e6; - bw = 40e6; - } - else if (mu == 1 && N_RB_DL == 133) { - fs = 61.44e6; - bw = 50e6; - } - else if (mu == 1 && N_RB_DL == 162) { - fs = 61.44e6; - bw = 60e6; - } - else if (mu == 1 && N_RB_DL == 24) { - fs = 15.36e6; - bw = 10e6; - } - else if (mu == 3 && N_RB_DL == 66) { - fs = 122.88e6; - bw = 100e6; - } - else if (mu == 3 && N_RB_DL == 32) { - fs = 61.44e6; - bw = 50e6; - } - else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL); + get_samplerate_and_bw(mu, + N_RB_DL, + frame_parms->threequarter_fs, + &fs, + &samples, + &txbw, + &rxbw); gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, fs/1e6,//sampling frequency in MHz - bw, + txbw, 30e-9, 0, 0, diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 80a638db73..728023c246 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -27,6 +27,7 @@ #include #include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" +#include "common/utils/nr/nr_common.h" #include "common/utils/LOG/log.h" #include "common/ran_context.h" #include "PHY/types.h" @@ -390,45 +391,18 @@ int main(int argc, char **argv) nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); phy_init_nr_gNB(gNB,0,0); - double fs,bw,scs,eps; + double fs,txbw,rxbw; + uint32_t samples; - if (mu == 1 && N_RB_DL == 217) { - fs = 122.88e6; - bw = 80e6; - scs = 30000; - } - else if (mu == 1 && N_RB_DL == 245) { - fs = 122.88e6; - bw = 90e6; - scs = 30000; - } - else if (mu == 1 && N_RB_DL == 273) { - fs = 122.88e6; - bw = 100e6; - scs = 30000; - } - else if (mu == 1 && N_RB_DL == 106) { - fs = 61.44e6; - bw = 40e6; - scs = 30000; - } - else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL); + get_samplerate_and_bw(mu, + N_RB_DL, + frame_parms->threequarter_fs, + &fs, + &samples, + &txbw, + &rxbw); - // cfo with respect to sub-carrier spacing - eps = cfo/scs; - - // computation of integer and fractional FO to compare with estimation results - int IFO; - if(eps!=0.0){ - printf("Introducing a CFO of %lf relative to SCS of %d kHz\n",eps,(int)(scs/1000)); - if (eps>0) - IFO=(int)(eps+0.5); - else - IFO=(int)(eps-0.5); - printf("FFO = %lf; IFO = %d\n",eps-IFO,IFO); - } - - UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, fs, bw, DS_TDL,0, 0, 0, 0); + UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, fs, txbw, DS_TDL,0, 0, 0, 0); if (UE2gNB==NULL) { printf("Problem generating channel model. Exiting.\n"); @@ -477,9 +451,6 @@ int main(int argc, char **argv) memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS)); UE->frame_parms.nb_antennas_rx=1; - if(eps!=0.0) - UE->UE_fo_compensation = 1; // if a frequency offset is set then perform fo estimation and compensation - if (init_nr_ue_signal(UE, 1) != 0) { printf("Error at UE NR initialisation\n"); @@ -568,7 +539,7 @@ int main(int argc, char **argv) } random_channel(UE2gNB,0); - freq_channel(UE2gNB,N_RB_DL,2*N_RB_DL+1,scs/1000); + freq_channel(UE2gNB,N_RB_DL,2*N_RB_DL+1,15<frame_parms.ofdm_symbol_size; for (int re=0;re Date: Sat, 6 Aug 2022 11:27:49 +0200 Subject: [PATCH 17/98] some fixes in SSB RSRP --- openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index 6e418b3f12..bf7b93b180 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -33,6 +33,7 @@ #include "executables/softmodem-common.h" #include "executables/nr-softmodem-common.h" #include "PHY/defs_nr_UE.h" +#include "PHY/INIT/phy_init.h" #include "PHY/phy_extern_nr_ue.h" #include "common/utils/LOG/log.h" #include "PHY/sse_intrin.h" @@ -208,10 +209,15 @@ void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t slot) { - int k_start = 55; + int k_start = 56; int k_end = 183; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; - uint8_t l_sss = (ue->symbol_offset + 2) % ue->frame_parms.symbols_per_slot; + int symbol_offset = nr_get_ssb_start_symbol(&ue->frame_parms,ssb_index); + + if (ue->frame_parms.half_frame_bit) + symbol_offset += (ue->frame_parms.slots_per_frame>>1)*ue->frame_parms.symbols_per_slot; + + uint8_t l_sss = (symbol_offset + 2) % ue->frame_parms.symbols_per_slot; if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset -= ue->frame_parms.ofdm_symbol_size; From f75cdbcad75eb5e30d93a9ab5dacccde17f2ede3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 25 Mar 2022 11:47:23 +0100 Subject: [PATCH 18/98] Use F1 DL RRC message transfer internally for RRCSetup --- cmake_targets/CMakeLists.txt | 3 + openair2/COMMON/f1ap_messages_types.h | 1 + openair2/F1AP/dummy_enb.c | 4 + openair2/F1AP/f1ap_cu_task.c | 1 + openair2/F1AP/f1ap_du_rrc_message_transfer.c | 11 ++ .../LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c | 131 +++++++++++++ .../LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h | 30 +++ openair2/RRC/NR/mac_rrc_dl.h | 34 ++++ openair2/RRC/NR/mac_rrc_dl_direct.c | 52 +++++ openair2/RRC/NR/mac_rrc_dl_f1ap.c | 44 +++++ openair2/RRC/NR/nr_rrc_defs.h | 8 + openair2/RRC/NR/rrc_gNB.c | 181 ++++-------------- 12 files changed, 357 insertions(+), 143 deletions(-) create mode 100644 openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c create mode 100644 openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h create mode 100644 openair2/RRC/NR/mac_rrc_dl.h create mode 100644 openair2/RRC/NR/mac_rrc_dl_direct.c create mode 100644 openair2/RRC/NR/mac_rrc_dl_f1ap.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 157ac1f6b3..b215e6ca4c 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1872,6 +1872,8 @@ set(L2_NR_SRC ${NR_RRC_DIR}/rrc_gNB.c ${NR_RRC_DIR}/nr_rrc_common.c ${NR_RRC_DIR}/L2_nr_interface.c + ${NR_RRC_DIR}/mac_rrc_dl_direct.c + ${NR_RRC_DIR}/mac_rrc_dl_f1ap.c ${NR_RRC_DIR}/nr_rrc_config.c ${NR_RRC_DIR}/rrc_gNB_nsa.c ${NR_RRC_DIR}/rrc_gNB_internode.c @@ -1950,6 +1952,7 @@ set (MAC_NR_SRC ${NR_GNB_MAC_DIR}/gNB_scheduler_uci.c ${NR_GNB_MAC_DIR}/gNB_scheduler_srs.c ${NR_GNB_MAC_DIR}/gNB_scheduler_RA.c + ${NR_GNB_MAC_DIR}/mac_rrc_dl_handler.c ) diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index ae050e2bc2..c19bdff9a2 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -23,6 +23,7 @@ #define F1AP_MESSAGES_TYPES_H_ #include "rlc.h" +#include "s1ap_messages_types.h" //-------------------------------------------------------------------------------------------// // Defines to access message fields. diff --git a/openair2/F1AP/dummy_enb.c b/openair2/F1AP/dummy_enb.c index 8e185c951d..22627c8d92 100644 --- a/openair2/F1AP/dummy_enb.c +++ b/openair2/F1AP/dummy_enb.c @@ -47,3 +47,7 @@ bool sdap_data_req(protocol_ctxt_t *ctxt_p, const int pdusession_id) { abort(); } + +int dl_rrc_message(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc) { + abort(); +} diff --git a/openair2/F1AP/f1ap_cu_task.c b/openair2/F1AP/f1ap_cu_task.c index efbc9f2c8b..b521d0c83d 100644 --- a/openair2/F1AP/f1ap_cu_task.c +++ b/openair2/F1AP/f1ap_cu_task.c @@ -172,6 +172,7 @@ void *F1AP_CU_task(void *arg) { LOG_I(F1AP, "CU Task Received F1AP_DL_RRC_MESSAGE\n"); CU_send_DL_RRC_MESSAGE_TRANSFER(ITTI_MSG_DESTINATION_INSTANCE(received_msg), &F1AP_DL_RRC_MESSAGE(received_msg)); + free(F1AP_DL_RRC_MESSAGE(received_msg).rrc_container); break; case F1AP_UE_CONTEXT_SETUP_REQ: // from rrc diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c index e158e9519a..d896a2640b 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c @@ -56,6 +56,7 @@ #include "intertask_interface.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" +#include "openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h" int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, uint32_t assoc_id, @@ -986,6 +987,16 @@ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, } } + f1ap_dl_rrc_message_t dl_rrc = { + .rrc_container_length = ie->value.choice.RRCContainer.size, + .rrc_container = ie->value.choice.RRCContainer.buf, + .rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id), + .srb_id = srb_id + }; + int rc = dl_rrc_message(instance, &dl_rrc); + if (rc == 0) + return 0; /* has been handled, otherwise continue below */ + // decode RRC Container and act on the message type AssertFatal(srb_id<3,"illegal srb_id\n"); MessageDef *msg = itti_alloc_new_message(TASK_DU_F1, 0, NR_DU_RRC_DL_INDICATION); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c new file mode 100644 index 0000000000..578e4fb453 --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c @@ -0,0 +1,131 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "mac_rrc_dl_handler.h" + +#include "mac_proto.h" +#include "openair2/RRC/NR/rrc_gNB_UE_context.h" + +#include "NR_RRCSetup.h" +#include "NR_DL-CCCH-Message.h" +#include "NR_CellGroupConfig.h" + +int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc, NR_RRCSetup_t *rrcSetup); + +int dl_rrc_message(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc) +{ + /* dispatch message to dl_rrc_message_rrcSetup() and others, similar to as is + * done in the DU (should be the same here) */ + + if (dl_rrc->srb_id == 0) { + + NR_DL_CCCH_Message_t *dl_ccch_msg = NULL; + asn_dec_rval_t dec_rval = uper_decode(NULL, + &asn_DEF_NR_DL_CCCH_Message, + (void **) &dl_ccch_msg, + dl_rrc->rrc_container, + dl_rrc->rrc_container_length, + 0, + 0); + AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n"); + + switch (dl_ccch_msg->message.choice.c1->present) { + case NR_DL_CCCH_MessageType__c1_PR_NOTHING: + LOG_W(NR_MAC, "Received NOTHING on DL-CCCH-Message\n"); + break; + case NR_DL_CCCH_MessageType__c1_PR_rrcReject: + LOG_D(NR_MAC, "DL-CCCH/SRB0, received rrcReject for RNTI %04x\n", dl_rrc->rnti); + AssertFatal(0, "rrcReject not implemented yet\n"); + break; + case NR_DL_CCCH_MessageType__c1_PR_rrcSetup: + LOG_I(NR_MAC, "DL-CCCH/SRB0, received rrcSetup for RNTI %04x\n", dl_rrc->rnti); + return dl_rrc_message_rrcSetup(module_id, dl_rrc, dl_ccch_msg->message.choice.c1->choice.rrcSetup); + break; + case NR_DL_CCCH_MessageType__c1_PR_spare2: + LOG_W(NR_MAC, "DL-CCCH/SRB0, received spare2\n"); + break; + case NR_DL_CCCH_MessageType__c1_PR_spare1: + LOG_W(NR_MAC, "DL-CCCH/SRB0, received spare1\n"); + break; + default: + AssertFatal(0 == 1, "Unknown DL-CCCH/SRB0 message %d\n", dl_ccch_msg->message.choice.c1->present); + break; + } + return 0; + } + + return -1; /* not handled yet */ +} + +int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc, NR_RRCSetup_t *rrcSetup) +{ + DevAssert(rrcSetup != NULL); + + NR_RRCSetup_IEs_t *rrcSetup_ies = rrcSetup->criticalExtensions.choice.rrcSetup; + AssertFatal(rrcSetup_ies->masterCellGroup.buf != NULL,"masterCellGroup is NULL\n"); + NR_CellGroupConfig_t *cellGroup = NULL; + asn_dec_rval_t dec_rval = uper_decode(NULL, + &asn_DEF_NR_CellGroupConfig, + (void **)&cellGroup, + rrcSetup_ies->masterCellGroup.buf, + rrcSetup_ies->masterCellGroup.size, + 0, + 0); + AssertFatal(dec_rval.code == RC_OK, "could not decode masterCellGroup\n"); + + /* there might be a memory leak for the cell group if we call this multiple + * times. Also, the first parameters of rrc_mac_config_req_gNB() are only + * relevant when setting the scc, which we don't do (and cannot do) here. */ + rrc_pdsch_AntennaPorts_t pap = {0}; + rrc_mac_config_req_gNB(module_id, + pap, /* only when scc != NULL */ + 0, /* only when scc != NULL */ + 0, /* only when scc != NULL */ + 0, /* only when scc != NULL */ + NULL, /* scc */ + NULL, /* mib */ + NULL, /* sib1 */ + 0, /* add_ue */ + dl_rrc->rnti, + cellGroup); + + /* TODO: drop the RRC context */ + gNB_RRC_INST *rrc = RC.nrrrc[module_id]; + struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(rrc, dl_rrc->rnti); + gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; + ue_context_p->ue_context.SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList; + ue_context_p->ue_context.masterCellGroup = cellGroup; + + /* TODO: this should pass through RLC and NOT the RRC with a shared buffer */ + AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n"); + memcpy(ue_p->Srb0.Tx_buffer.Payload, dl_rrc->rrc_container, dl_rrc->rrc_container_length); + ue_p->Srb0.Tx_buffer.payload_size = dl_rrc->rrc_container_length; + + protocol_ctxt_t ctxt = { .module_id = module_id, .rnti = dl_rrc->rnti }; + nr_rrc_rlc_config_asn1_req(&ctxt, + ue_context_p->ue_context.SRB_configList, + NULL, + NULL, + NULL, + cellGroup->rlc_BearerToAddModList); + + return 0; +} diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h new file mode 100644 index 0000000000..ecbc95eef0 --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h @@ -0,0 +1,30 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef MAC_RRC_DL_HANDLER_H +#define MAC_RRC_DL_HANDLER_H + +#include "platform_types.h" +#include "f1ap_messages_types.h" + +int dl_rrc_message(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc); + +#endif /* MAC_RRC_DL_HANDLER_H */ diff --git a/openair2/RRC/NR/mac_rrc_dl.h b/openair2/RRC/NR/mac_rrc_dl.h new file mode 100644 index 0000000000..1943490cd6 --- /dev/null +++ b/openair2/RRC/NR/mac_rrc_dl.h @@ -0,0 +1,34 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * conmnc_digit_lengtht@openairinterface.org + */ + +#ifndef MAC_RRC_DL_H +#define MAC_RRC_DL_H + +#include "platform_types.h" +#include "f1ap_messages_types.h" + +typedef void (*dl_rrc_message_transfer_func_t)(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc); + +struct nr_mac_rrc_dl_if_s; +void mac_rrc_dl_direct_init(struct nr_mac_rrc_dl_if_s *mac_rrc); +void mac_rrc_dl_f1ap_init(struct nr_mac_rrc_dl_if_s *mac_rrc); + +#endif /* MAC_RRC_DL_H */ diff --git a/openair2/RRC/NR/mac_rrc_dl_direct.c b/openair2/RRC/NR/mac_rrc_dl_direct.c new file mode 100644 index 0000000000..b3ba7b9ee5 --- /dev/null +++ b/openair2/RRC/NR/mac_rrc_dl_direct.c @@ -0,0 +1,52 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * conmnc_digit_lengtht@openairinterface.org + */ + +#include "nr_rrc_defs.h" + +#include "mac_rrc_dl.h" +#include "openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h" + +static void dl_rrc_message_transfer_direct(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc) +{ +#ifdef ITTI_SIM + const int len = dl_rrc->rrc_container_length; + LOG_I(NR_RRC, + PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n", + PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), + len); + uint8_t *message_buffer; + message_buffer = itti_malloc(TASK_RRC_GNB, TASK_RRC_UE_SIM, len); + memcpy (message_buffer, dl_rrc->rrc_container, len); + message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_CCCH_DATA_IND); + GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; + GNB_RRC_CCCH_DATA_IND (message_p).size = len; + itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); +#else + /* TODO how to manage inter-thread communication? */ + + dl_rrc_message(module_id, dl_rrc); +#endif +} + +void mac_rrc_dl_direct_init(nr_mac_rrc_dl_if_t *mac_rrc) +{ + mac_rrc->dl_rrc_message_transfer = dl_rrc_message_transfer_direct; +} diff --git a/openair2/RRC/NR/mac_rrc_dl_f1ap.c b/openair2/RRC/NR/mac_rrc_dl_f1ap.c new file mode 100644 index 0000000000..40f3b4b6ea --- /dev/null +++ b/openair2/RRC/NR/mac_rrc_dl_f1ap.c @@ -0,0 +1,44 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * conmnc_digit_lengtht@openairinterface.org + */ + +#include "mac_rrc_dl.h" +#include "nr_rrc_defs.h" + +static void dl_rrc_message_transfer_f1ap(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc) +{ + /* TODO call F1AP function directly? no real-time constraint here */ + + MessageDef *message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_DL_RRC_MESSAGE); + f1ap_dl_rrc_message_t *msg = &F1AP_DL_RRC_MESSAGE(message_p); + *msg = *dl_rrc; + if (dl_rrc->rrc_container) { + msg->rrc_container = malloc(dl_rrc->rrc_container_length); + AssertFatal(msg->rrc_container != NULL, "out of memory\n"); + msg->rrc_container_length = dl_rrc->rrc_container_length; + memcpy(msg->rrc_container, dl_rrc->rrc_container, dl_rrc->rrc_container_length); + } + itti_send_msg_to_task (TASK_CU_F1, module_id, message_p); +} + +void mac_rrc_dl_f1ap_init(nr_mac_rrc_dl_if_t *mac_rrc) +{ + mac_rrc->dl_rrc_message_transfer = dl_rrc_message_transfer_f1ap; +} diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index b6a92db7a8..c709a158da 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -42,6 +42,7 @@ #include "COMMON/platform_types.h" #include "RRC/LTE/rrc_defs.h" //#include "LAYER2/RLC/rlc.h" +#include "mac_rrc_dl.h" //#include "COMMON/mac_rrc_primitives.h" @@ -480,6 +481,11 @@ typedef struct { int do_drb_integrity; } nr_security_configuration_t; +typedef struct nr_mac_rrc_dl_if_s { + /* TODO add other message types as necessary */ + dl_rrc_message_transfer_func_t dl_rrc_message_transfer; +} nr_mac_rrc_dl_if_t; + //---NR---(completely change)--------------------- typedef struct gNB_RRC_INST_s { @@ -529,6 +535,8 @@ typedef struct gNB_RRC_INST_s { // security configuration (preferred algorithms) nr_security_configuration_t security; + + nr_mac_rrc_dl_if_t mac_rrc; } gNB_RRC_INST; #include "nr_rrc_proto.h" //should be put here otherwise compilation error diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 8c6c583289..4340bfa6bd 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -196,6 +196,26 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration } } +static void rrc_gNB_mac_rrc_init(gNB_RRC_INST *rrc) +{ + switch (rrc->node_type) { + case ngran_gNB_CU: + mac_rrc_dl_f1ap_init(&rrc->mac_rrc); + break; + case ngran_gNB_DU: + /* silently drop this, as we currently still need the RRC at the DU. As + * soon as this is not the case anymore, we can add the AssertFatal() */ + //AssertFatal(1==0,"nothing to do for DU\n"); + break; + case ngran_gNB: + mac_rrc_dl_direct_init(&rrc->mac_rrc); + break; + default: + AssertFatal(0 == 1, "Unknown node type %d\n", rrc->node_type); + break; + } +} + char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigurationReq *configuration) { protocol_ctxt_t ctxt = { 0 }; gNB_RRC_INST *rrc=RC.nrrrc[gnb_mod_idP]; @@ -203,13 +223,13 @@ char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigu LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT" Init...\n", PROTOCOL_NR_RRC_CTXT_ARGS(&ctxt)); - AssertFatal(rrc != NULL, "RC.nrrrc not initialized!"); AssertFatal(NUMBER_OF_UE_MAX < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); AssertFatal(configuration!=NULL,"configuration input is null\n"); rrc->module_id = gnb_mod_idP; rrc->Nb_ue = 0; rrc->carrier.Srb0.Active = 0; + rrc_gNB_mac_rrc_init(rrc); nr_uid_linear_allocator_init(&rrc->uid_allocator); RB_INIT(&rrc->rrc_ue_head); rrc->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); @@ -325,14 +345,14 @@ rrc_gNB_generate_RRCSetup( ) //----------------------------------------------------------------------------- { - LOG_D(NR_RRC, "rrc_gNB_generate_RRCSetup \n"); - MessageDef *message_p; + LOG_I(NR_RRC, "rrc_gNB_generate_RRCSetup for RNTI %04x\n", ctxt_pP->rnti); // T(T_GNB_RRC_SETUP, // T_INT(ctxt_pP->module_id), // T_INT(ctxt_pP->frame), // T_INT(ctxt_pP->subframe), // T_INT(ctxt_pP->rnti)); + gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; NR_ServingCellConfig_t *servingcellconfigdedicated = rrc->configuration.scd; @@ -351,87 +371,22 @@ rrc_gNB_generate_RRCSetup( ue_p->Srb0.Tx_buffer.payload_size, "[MSG] RRC Setup\n"); - switch (rrc->node_type) { - case ngran_gNB_CU: - // create an ITTI message - /* TODO: F1 IDs ar missing in RRC */ - nr_rrc_pdcp_config_asn1_req(ctxt_pP, - ue_context_pP->ue_context.SRB_configList, - NULL, - NULL, - 0, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_DL_RRC_MESSAGE); - F1AP_DL_RRC_MESSAGE (message_p).rrc_container = (uint8_t *)ue_p->Srb0.Tx_buffer.Payload; - F1AP_DL_RRC_MESSAGE (message_p).rrc_container_length = ue_p->Srb0.Tx_buffer.payload_size; - F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0; - F1AP_DL_RRC_MESSAGE (message_p).gNB_DU_ue_id = 0; - F1AP_DL_RRC_MESSAGE (message_p).old_gNB_DU_ue_id = 0xFFFFFFFF; // unknown - F1AP_DL_RRC_MESSAGE (message_p).rnti = ue_p->rnti; - F1AP_DL_RRC_MESSAGE (message_p).srb_id = CCCH; - F1AP_DL_RRC_MESSAGE (message_p).execute_duplication = 1; - F1AP_DL_RRC_MESSAGE (message_p).RAT_frequency_priority_information.en_dc = 0; - itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); - LOG_D(NR_RRC, "Send F1AP_DL_RRC_MESSAGE with ITTI\n"); + // activate release timer, if RRCSetupComplete not received after 100 frames, remove UE + ue_context_pP->ue_context.ue_release_timer = 1; + // remove UE after 10 frames after RRCConnectionRelease is triggered + ue_context_pP->ue_context.ue_release_timer_thres = 1000; - break; + /* TODO: this should go through the E1 interface */ + apply_pdcp_config(ue_context_pP,ctxt_pP); - case ngran_gNB_DU: - // nothing to do for DU - AssertFatal(1==0,"nothing to do for DU\n"); - break; - - case ngran_gNB: - { - // rrc_mac_config_req_gNB - -#ifdef ITTI_SIM - LOG_I(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_p->Srb0.Tx_buffer.payload_size); - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, - ue_p->Srb0.Tx_buffer.payload_size); - memcpy (message_buffer, (uint8_t*)ue_p->Srb0.Tx_buffer.Payload, ue_p->Srb0.Tx_buffer.payload_size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_CCCH_DATA_IND); - GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_CCCH_DATA_IND (message_p).size = ue_p->Srb0.Tx_buffer.payload_size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else - LOG_D(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT" RRC_gNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); - LOG_I(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_p->Srb0.Tx_buffer.payload_size); - // activate release timer, if RRCSetupComplete not received after 100 frames, remove UE - ue_context_pP->ue_context.ue_release_timer = 1; - // remove UE after 10 frames after RRCConnectionRelease is triggered - ue_context_pP->ue_context.ue_release_timer_thres = 1000; - /* init timers */ - // ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0; - - // configure MAC - - apply_macrlc_config(rrc,ue_context_pP,ctxt_pP); - - apply_pdcp_config(ue_context_pP,ctxt_pP); -#endif - } - break; - - default: - LOG_W(NR_RRC, "Unknown node type %d\n", rrc->node_type); - break; - } + f1ap_dl_rrc_message_t dl_rrc = { + .old_gNB_DU_ue_id = 0xFFFFFF, + .rrc_container = (uint8_t *)ue_p->Srb0.Tx_buffer.Payload, + .rrc_container_length = ue_p->Srb0.Tx_buffer.payload_size, + .rnti = ue_p->rnti, + .srb_id = CCCH + }; + rrc->mac_rrc.dl_rrc_message_transfer(ctxt_pP->module_id, &dl_rrc); } //----------------------------------------------------------------------------- @@ -3041,67 +2996,7 @@ static int rrc_process_DU_DL(MessageDef *msg_p, const char *msg_name, instance_ rrc_gNB_get_ue_context(rrc, ctxt.rnti); if (req->srb_id == 0) { - NR_DL_CCCH_Message_t *dl_ccch_msg=NULL; - asn_dec_rval_t dec_rval; - dec_rval = uper_decode(NULL, - &asn_DEF_NR_DL_CCCH_Message, - (void **)&dl_ccch_msg, - req->buf->data, - req->buf->size,0,0); - AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n"); - - switch (dl_ccch_msg->message.choice.c1->present) { - case NR_DL_CCCH_MessageType__c1_PR_NOTHING: - LOG_I(F1AP,"Received PR_NOTHING on DL-CCCH-Message\n"); - break; - - case NR_DL_CCCH_MessageType__c1_PR_rrcReject: - LOG_I(F1AP,"Logical Channel DL-CCCH (SRB0), Received RRCReject\n"); - break; - - case NR_DL_CCCH_MessageType__c1_PR_rrcSetup: { - LOG_I(F1AP, "Logical Channel DL-CCCH (SRB0), Received RRCSetup RNTI %x\n", - req->rnti); - // Get configuration - NR_RRCSetup_t *rrcSetup = dl_ccch_msg->message.choice.c1->choice.rrcSetup; - AssertFatal(rrcSetup!=NULL, "rrcSetup is null\n"); - NR_RRCSetup_IEs_t *rrcSetup_ies = rrcSetup->criticalExtensions.choice.rrcSetup; - ue_context_p->ue_context.SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList; - AssertFatal(rrcSetup_ies->masterCellGroup.buf!=NULL,"masterCellGroup is null\n"); - asn_dec_rval_t dec_rval; - dec_rval = uper_decode(NULL, - &asn_DEF_NR_CellGroupConfig, - (void **)&ue_context_p->ue_context.masterCellGroup, - rrcSetup_ies->masterCellGroup.buf, - rrcSetup_ies->masterCellGroup.size,0,0); - AssertFatal(dec_rval.code == RC_OK, "could not decode masterCellGroup\n"); - apply_macrlc_config(rrc,ue_context_p,&ctxt); - gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; - AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n"); - memcpy((void *)ue_p->Srb0.Tx_buffer.Payload, - (void *)req->buf->data, - req->buf->size); // ie->value.choice.RRCContainer.size - ue_p->Srb0.Tx_buffer.payload_size = req->buf->size; - break; - } // case - - case NR_DL_CCCH_MessageType__c1_PR_spare2: - LOG_I(F1AP, - "Logical Channel DL-CCCH (SRB0), Received spare2\n"); - break; - - case NR_DL_CCCH_MessageType__c1_PR_spare1: - LOG_I(F1AP, - "Logical Channel DL-CCCH (SRB0), Received spare1\n"); - break; - - default: - AssertFatal(1==0, - "Unknown message\n"); - break; - }// switch case - - return(0); + AssertFatal(0 == 1, "should pass through dl_rrc_message()\n"); } else if (req->srb_id == 1) { NR_DL_DCCH_Message_t *dl_dcch_msg=NULL; asn_dec_rval_t dec_rval; From f52809a8fbf51ae060cc5e94dd22f5602b5ee101 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 2 May 2022 12:35:58 +0200 Subject: [PATCH 19/98] Add MAC-RRC UL stubs for F1AP and direct --- cmake_targets/CMakeLists.txt | 2 ++ openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulsim.c | 2 +- openair2/GNB_APP/gnb_config.c | 30 +++++++--------- openair2/LAYER2/NR_MAC_gNB/config.c | 1 - openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul.h | 34 ++++++++++++++++++ .../LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c | 35 +++++++++++++++++++ openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c | 35 +++++++++++++++++++ openair2/LAYER2/NR_MAC_gNB/main.c | 21 ++++++++++- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 8 +++++ 11 files changed, 150 insertions(+), 22 deletions(-) create mode 100644 openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul.h create mode 100644 openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c create mode 100644 openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index b215e6ca4c..f8bcb2b548 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1953,6 +1953,8 @@ set (MAC_NR_SRC ${NR_GNB_MAC_DIR}/gNB_scheduler_srs.c ${NR_GNB_MAC_DIR}/gNB_scheduler_RA.c ${NR_GNB_MAC_DIR}/mac_rrc_dl_handler.c + ${NR_GNB_MAC_DIR}/mac_rrc_ul_direct.c + ${NR_GNB_MAC_DIR}/mac_rrc_ul_f1ap.c ) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 0fe5315d4e..b9d7cd460b 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -759,7 +759,7 @@ int main(int argc, char **argv) RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); for (i = 0; i < RC.nb_nr_macrlc_inst; i++) RC.nb_nr_mac_CC[i] = 1; - mac_top_init_gNB(); + mac_top_init_gNB(ngran_gNB); gNB_mac = RC.nrmac[0]; gNB_RRC_INST rrc; memset((void*)&rrc,0,sizeof(rrc)); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 5df89283a8..9b8f7e533a 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -770,7 +770,7 @@ int main(int argc, char **argv) RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); for (i = 0; i < RC.nb_nr_macrlc_inst; i++) RC.nb_nr_mac_CC[i] = 1; - mac_top_init_gNB(); + mac_top_init_gNB(ngran_gNB); //gNB_MAC_INST* gNB_mac = RC.nrmac[0]; gNB_RRC_INST rrc; memset((void*)&rrc,0,sizeof(rrc)); diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 225daec37b..6e22a1e94c 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -85,7 +85,8 @@ extern uint16_t sf_ahead; int macrlc_has_f1 = 0; -extern ngran_node_t node_type; + +static ngran_node_t get_node_type(void); extern int config_check_band_frequencies(int ind, int16_t band, uint64_t downlink_frequency, int32_t uplink_frequency_offset, uint32_t frame_type); @@ -795,6 +796,7 @@ void RCconfig_nr_macrlc() { paramdef_t GNBParams[] = GNBPARAMS_DESC; paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0}; + ngran_node_t node_type = get_node_type(); config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; @@ -825,7 +827,7 @@ void RCconfig_nr_macrlc() { if ( MacRLC_ParamList.numelt > 0) { RC.nb_nr_macrlc_inst=MacRLC_ParamList.numelt; - mac_top_init_gNB(); + mac_top_init_gNB(node_type); RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); for (j=0;j 0) { RC.nb_nr_macrlc_inst = MacRLC_ParamList.numelt; - for (j=0;jinitial_ul_rrc_message_transfer = initial_ul_rrc_message_transfer_direct; +} diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c new file mode 100644 index 0000000000..ed67fb9119 --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c @@ -0,0 +1,35 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * conmnc_digit_lengtht@openairinterface.org + */ + +#include "nr_mac_gNB.h" + +#include "mac_rrc_ul.h" + +static void initial_ul_rrc_message_transfer_f1ap(module_id_t module_id, const f1ap_initial_ul_rrc_message_t *ul_rrc) +{ + AssertFatal(0 == 1, "not implemented\n"); +} + +void mac_rrc_ul_f1ap_init(struct nr_mac_rrc_ul_if_s *mac_rrc) +{ + mac_rrc->initial_ul_rrc_message_transfer = initial_ul_rrc_message_transfer_f1ap; +} + diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 12c9846037..0694f7d757 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -173,8 +173,25 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset return output - begin; } +static void mac_rrc_init(gNB_MAC_INST *mac, ngran_node_t node_type) +{ + switch (node_type) { + case ngran_gNB_CU: + AssertFatal(1 == 0, "nothing to do for CU\n"); + break; + case ngran_gNB_DU: + mac_rrc_ul_f1ap_init(&mac->mac_rrc); + break; + case ngran_gNB: + mac_rrc_ul_direct_init(&mac->mac_rrc); + break; + default: + AssertFatal(0 == 1, "Unknown node type %d\n", node_type); + break; + } +} -void mac_top_init_gNB(void) +void mac_top_init_gNB(ngran_node_t node_type) { module_id_t i; gNB_MAC_INST *nrmac; @@ -221,6 +238,8 @@ void mac_top_init_gNB(void) } if (!IS_SOFTMODEM_NOSTATS_BIT) pthread_create(&RC.nrmac[i]->stats_thread, NULL, nrmac_stats_thread, (void*)RC.nrmac[i]); + + mac_rrc_init(RC.nrmac[i], node_type); }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) AssertFatal(rlc_module_init(1) == 0,"Could not initialize RLC layer\n"); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 67da0035bf..3c3ea4dfc8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -60,6 +60,7 @@ /* Interface */ #include "nfapi_nr_interface_scf.h" #include "NR_PHY_INTERFACE/NR_IF_Module.h" +#include "mac_rrc_ul.h" /* MAC */ #include "LAYER2/MAC/mac.h" @@ -685,6 +686,11 @@ typedef struct NR_bler_options { uint8_t harq_round_max; } NR_bler_options_t; +typedef struct nr_mac_rrc_ul_if_s { + /* TODO add other message types as necessary */ + initial_ul_rrc_message_transfer_func_t initial_ul_rrc_message_transfer; +} nr_mac_rrc_ul_if_t; + /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ typedef struct { rnti_t rnti; @@ -838,6 +844,8 @@ typedef struct gNB_MAC_INST_s { NR_bler_options_t ul_bler; uint8_t min_grant_prb; uint8_t min_grant_mcs; + + nr_mac_rrc_ul_if_t mac_rrc; } gNB_MAC_INST; #endif /*__LAYER2_NR_MAC_GNB_H__ */ From 0c9006ec6697f0cf190106d53352d28160d9e80b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 2 May 2022 12:36:14 +0200 Subject: [PATCH 20/98] Do not initialize MAC multiple times --- openair2/GNB_APP/gnb_config.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 6e22a1e94c..f8a4e495a8 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -759,8 +759,6 @@ void RCconfig_NR_L1(void) { LOG_I(PHY,"%s() NFAPI PNF mode - RC.nb_nr_CC[0]=%d for init_gNB_afterRU()\n", __FUNCTION__, RC.nb_nr_CC[0]); LOG_I(PHY,"%s() NFAPI PNF mode - RC.nb_nr_macrlc_inst:%d because used by mac_top_init_gNB()\n", __FUNCTION__, RC.nb_nr_macrlc_inst); - mac_top_init_gNB(); - configure_nr_nfapi_pnf(RC.gNB[j]->eth_params_n.remote_addr, RC.gNB[j]->eth_params_n.remote_portc, RC.gNB[j]->eth_params_n.my_addr, From 52dbc6fe75e14d2d8c91188f5bd5086bd2884f9a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 3 May 2022 11:45:54 +0200 Subject: [PATCH 21/98] Refactor linear allocator from LTE/NR; separate LTE/NR headers --- common/utils/collection/linear_alloc.h | 71 +++++++++++++++++++++++ openair2/RRC/LTE/rrc_defs.h | 19 +------ openair2/RRC/LTE/rrc_eNB_UE_context.c | 62 +------------------- openair2/RRC/LTE/rrc_eNB_UE_context.h | 21 ------- openair2/RRC/NR/nr_rrc_defs.h | 34 ++++------- openair2/RRC/NR/rrc_gNB.c | 2 +- openair2/RRC/NR/rrc_gNB_UE_context.c | 79 ++++---------------------- openair2/RRC/NR/rrc_gNB_UE_context.h | 21 ------- openair2/RRC/NR_UE/L2_interface_ue.c | 1 + 9 files changed, 100 insertions(+), 210 deletions(-) create mode 100644 common/utils/collection/linear_alloc.h diff --git a/common/utils/collection/linear_alloc.h b/common/utils/collection/linear_alloc.h new file mode 100644 index 0000000000..ac8a305ff6 --- /dev/null +++ b/common/utils/collection/linear_alloc.h @@ -0,0 +1,71 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef LINEAR_ALLOC_H +#define LINEAR_ALLOC_H + +#include + +typedef unsigned int uid_t; +#define UID_LINEAR_ALLOCATOR_SIZE 1024 +#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((UID_LINEAR_ALLOCATOR_SIZE/8)/sizeof(unsigned int)) + 1) +typedef struct uid_linear_allocator_s { + unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE]; +} uid_allocator_t; + +static inline void uid_linear_allocator_init(uid_allocator_t *uia) { + memset(uia, 0, sizeof(uid_allocator_t)); +} + +static inline uid_t uid_linear_allocator_new(uid_allocator_t *uia) { + unsigned int bit_index = 1; + uid_t uid = 0; + + for (unsigned int i = 0; i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE; i++) { + if (uia->bitmap[i] != UINT_MAX) { + bit_index = 1; + uid = 0; + + while ((uia->bitmap[i] & bit_index) == bit_index) { + bit_index = bit_index << 1; + uid += 1; + } + + uia->bitmap[i] |= bit_index; + return uid + (i*sizeof(unsigned int)*8); + } + } + + return UINT_MAX; +} + + +static inline void uid_linear_allocator_free(uid_allocator_t *uia, uid_t uid) { + const unsigned int i = uid/sizeof(unsigned int)/8; + const unsigned int bit = uid % (sizeof(unsigned int) * 8); + const unsigned int value = ~(1 << bit); + + if (i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE) { + uia->bitmap[i] &= value; + } +} + +#endif /* LINEAR_ALLOC_H */ diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index 22c8a14863..f5841b09f8 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -36,11 +36,11 @@ #include #include "collection/tree.h" +#include "collection/linear_alloc.h" #include "common/ngran_types.h" #include "rrc_types.h" //#include "PHY/phy_defs.h" #include "LAYER2/RLC/rlc.h" -#include "RRC/NR/nr_rrc_types.h" #include "NR_UE-MRDC-Capability.h" #include "NR_UE-NR-Capability.h" @@ -219,17 +219,6 @@ void *send_UE_status_notification(void *); #include "commonDef.h" -//-------- -typedef unsigned int uid_t; -#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((MAX_MOBILES_PER_ENB/8)/sizeof(unsigned int)) + 1) -typedef struct uid_linear_allocator_s { - unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE]; -} uid_allocator_t; - -//-------- - - - #define PROTOCOL_RRC_CTXT_UE_FMT PROTOCOL_CTXT_FMT #define PROTOCOL_RRC_CTXT_UE_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp) @@ -668,8 +657,6 @@ typedef struct eNB_RRC_UE_s { int nr_capabilities_requested; } eNB_RRC_UE_t; -typedef uid_t ue_uid_t; - typedef struct rrc_eNB_ue_context_s { /* Tree related data */ RB_ENTRY(rrc_eNB_ue_context_s) entries; @@ -680,7 +667,7 @@ typedef struct rrc_eNB_ue_context_s { rnti_t ue_id_rnti; // another key for protocol layers but should not be used as a key for RB tree - ue_uid_t local_uid; + uid_t local_uid; /* UE id for initial connection to S1AP */ struct eNB_RRC_UE_s ue_context; @@ -762,7 +749,7 @@ typedef struct eNB_RRC_INST_s { char *node_name; uint32_t node_id; rrc_eNB_carrier_data_t carrier[MAX_NUM_CCs]; - uid_allocator_t uid_allocator; // for rrc_ue_head + uid_allocator_t uid_allocator; RB_HEAD(rrc_ue_tree_s, rrc_eNB_ue_context_s) rrc_ue_head; // ue_context tree key search by rnti uint8_t HO_flag; uint8_t Nb_ue; diff --git a/openair2/RRC/LTE/rrc_eNB_UE_context.c b/openair2/RRC/LTE/rrc_eNB_UE_context.c index 0d262064b5..c9077bfb24 100644 --- a/openair2/RRC/LTE/rrc_eNB_UE_context.c +++ b/openair2/RRC/LTE/rrc_eNB_UE_context.c @@ -37,64 +37,6 @@ #include "rrc_eNB_UE_context.h" -//------------------------------------------------------------------------------ -void -uid_linear_allocator_init( - uid_allocator_t *const uid_pP -) -//------------------------------------------------------------------------------ -{ - memset(uid_pP, 0, sizeof(uid_allocator_t)); -} - -//------------------------------------------------------------------------------ -uid_t -uid_linear_allocator_new( - eNB_RRC_INST *const rrc_instance_pP -) -//------------------------------------------------------------------------------ -{ - unsigned int i; - unsigned int bit_index = 1; - uid_t uid = 0; - uid_allocator_t *uia_p = &rrc_instance_pP->uid_allocator; - - for (i=0; i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE; i++) { - if (uia_p->bitmap[i] != UINT_MAX) { - bit_index = 1; - uid = 0; - - while ((uia_p->bitmap[i] & bit_index) == bit_index) { - bit_index = bit_index << 1; - uid += 1; - } - - uia_p->bitmap[i] |= bit_index; - return uid + (i*sizeof(unsigned int)*8); - } - } - - return UINT_MAX; -} - - -//------------------------------------------------------------------------------ -void -uid_linear_allocator_free( - eNB_RRC_INST *rrc_instance_pP, - uid_t uidP -) -//------------------------------------------------------------------------------ -{ - unsigned int i = uidP/sizeof(unsigned int)/8; - unsigned int bit = uidP % (sizeof(unsigned int) * 8); - unsigned int value = ~(0x00000001 << bit); - - if (i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE) { - rrc_instance_pP->uid_allocator.bitmap[i] &= value; - } -} - //------------------------------------------------------------------------------ int rrc_eNB_compare_ue_rnti_id( @@ -134,7 +76,7 @@ rrc_eNB_allocate_new_UE_context( } memset(new_p, 0, sizeof(struct rrc_eNB_ue_context_s)); - new_p->local_uid = uid_linear_allocator_new(rrc_instance_pP); + new_p->local_uid = uid_linear_allocator_new(&rrc_instance_pP->uid_allocator); for(int i = 0; i < NB_RB_MAX; i++) { new_p->ue_context.e_rab[i].xid = -1; @@ -210,7 +152,7 @@ void rrc_eNB_remove_ue_context( RB_REMOVE(rrc_ue_tree_s, &rrc_instance_pP->rrc_ue_head, ue_context_pP); rrc_eNB_free_mem_UE_context(ctxt_pP, ue_context_pP); - uid_linear_allocator_free(rrc_instance_pP, ue_context_pP->local_uid); + uid_linear_allocator_free(&rrc_instance_pP->uid_allocator, ue_context_pP->local_uid); free(ue_context_pP); rrc_instance_pP->Nb_ue --; LOG_I(RRC, diff --git a/openair2/RRC/LTE/rrc_eNB_UE_context.h b/openair2/RRC/LTE/rrc_eNB_UE_context.h index c6420ca936..89469529df 100644 --- a/openair2/RRC/LTE/rrc_eNB_UE_context.h +++ b/openair2/RRC/LTE/rrc_eNB_UE_context.h @@ -34,27 +34,6 @@ #include "COMMON/platform_types.h" #include "rrc_defs.h" - -void -uid_linear_allocator_init( - uid_allocator_t* const uid_pP -); - -uid_t -uid_linear_allocator_new( - eNB_RRC_INST* rrc_instance_pP -); - - -void -uid_linear_allocator_free( - eNB_RRC_INST* rrc_instance_pP, - uid_t uidP -); - - - - int rrc_eNB_compare_ue_rnti_id( struct rrc_eNB_ue_context_s* c1_pP, struct rrc_eNB_ue_context_s* c2_pP diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index c709a158da..e9d9766f41 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -36,12 +36,12 @@ #include #include "collection/tree.h" +#include "collection/linear_alloc.h" #include "nr_rrc_types.h" +#include "common/ngran_types.h" #include "COMMON/platform_constants.h" #include "COMMON/platform_types.h" -#include "RRC/LTE/rrc_defs.h" -//#include "LAYER2/RLC/rlc.h" #include "mac_rrc_dl.h" //#include "COMMON/mac_rrc_primitives.h" @@ -80,17 +80,6 @@ #include "commonDef.h" - -/*I will change the name of the structure for compile purposes--> hope not to undo this process*/ - -typedef unsigned int uid_nr_t; -#define NR_UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((MAX_MOBILES_PER_GNB/8)/sizeof(unsigned int)) + 1) - -typedef struct nr_uid_linear_allocator_s { - unsigned int bitmap[NR_UID_LINEAR_ALLOCATOR_BITMAP_SIZE]; -} nr_uid_allocator_t; - - #define PROTOCOL_NR_RRC_CTXT_UE_FMT PROTOCOL_CTXT_FMT #define PROTOCOL_NR_RRC_CTXT_UE_ARGS(CTXT_Pp) PROTOCOL_NR_CTXT_ARGS(CTXT_Pp) @@ -283,12 +272,11 @@ typedef struct pdu_session_param_s { typedef struct gNB_RRC_UE_s { uint8_t primaryCC_id; - LTE_SCellToAddMod_r10_t sCell_config[2]; NR_SRB_ToAddModList_t *SRB_configList; - NR_SRB_ToAddModList_t *SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + NR_SRB_ToAddModList_t *SRB_configList2[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER]; NR_DRB_ToAddModList_t *DRB_configList; - NR_DRB_ToAddModList_t *DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; - NR_DRB_ToReleaseList_t *DRB_Release_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + NR_DRB_ToAddModList_t *DRB_configList2[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER]; + NR_DRB_ToReleaseList_t *DRB_Release_configList2[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER]; uint8_t DRB_active[8]; NR_SRB_INFO SI; @@ -296,7 +284,7 @@ typedef struct gNB_RRC_UE_s { NR_SRB_INFO_TABLE_ENTRY Srb1; NR_SRB_INFO_TABLE_ENTRY Srb2; NR_MeasConfig_t *measConfig; - HANDOVER_INFO *handover_info; + NR_HANDOVER_INFO *handover_info; NR_MeasResults_t *measResults; @@ -353,7 +341,7 @@ typedef struct gNB_RRC_UE_s { /* Number of e_rab to be modified in the list */ uint8_t nb_of_modify_e_rabs; uint8_t nb_of_failed_e_rabs; - e_rab_param_t modify_e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB]; + nr_e_rab_param_t modify_e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB]; /* Total number of pdu session already setup in the list */ uint8_t setup_pdu_sessions; /* Number of pdu session to be setup in the list */ @@ -364,7 +352,7 @@ typedef struct gNB_RRC_UE_s { pdu_session_param_t modify_pdusession[NR_NB_RB_MAX]; /* list of e_rab to be setup by RRC layers */ /* list of pdu session to be setup by RRC layers */ - e_rab_param_t e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB]; + nr_e_rab_param_t e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB]; pdu_session_param_t pduSession[NR_NB_RB_MAX];//[NGAP_MAX_PDU_SESSION]; //release e_rabs uint8_t nb_release_of_e_rabs; @@ -411,8 +399,6 @@ typedef struct gNB_RRC_UE_s { } gNB_RRC_UE_t; -typedef uid_t ue_uid_t; - typedef struct rrc_gNB_ue_context_s { /* Tree related data */ RB_ENTRY(rrc_gNB_ue_context_s) entries; @@ -423,7 +409,7 @@ typedef struct rrc_gNB_ue_context_s { rnti_t ue_id_rnti; // another key for protocol layers but should not be used as a key for RB tree - ue_uid_t local_uid; + uid_t local_uid; /* UE id for initial connection to S1AP */ struct gNB_RRC_UE_s ue_context; @@ -495,7 +481,7 @@ typedef struct gNB_RRC_INST_s { int module_id; eth_params_t eth_params_s; rrc_gNB_carrier_data_t carrier; - nr_uid_allocator_t uid_allocator; // for rrc_ue_head + uid_allocator_t uid_allocator; RB_HEAD(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s) rrc_ue_head; // ue_context tree key search by rnti int Nb_ue; hash_table_t *initial_id2_s1ap_ids; // key is content is rrc_ue_s1ap_ids_t diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 4340bfa6bd..bf122514ce 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -230,7 +230,7 @@ char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigu rrc->Nb_ue = 0; rrc->carrier.Srb0.Active = 0; rrc_gNB_mac_rrc_init(rrc); - nr_uid_linear_allocator_init(&rrc->uid_allocator); + uid_linear_allocator_init(&rrc->uid_allocator); RB_INIT(&rrc->rrc_ue_head); rrc->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); rrc->s1ap_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); diff --git a/openair2/RRC/NR/rrc_gNB_UE_context.c b/openair2/RRC/NR/rrc_gNB_UE_context.c index b8ff19b749..540ac5d075 100644 --- a/openair2/RRC/NR/rrc_gNB_UE_context.c +++ b/openair2/RRC/NR/rrc_gNB_UE_context.c @@ -37,61 +37,6 @@ #include "rrc_gNB_UE_context.h" -//------------------------------------------------------------------------------ -void nr_uid_linear_allocator_init( - nr_uid_allocator_t *const uid_pP -) -//------------------------------------------------------------------------------ -{ - memset(uid_pP, 0, sizeof(nr_uid_allocator_t)); -} - -//------------------------------------------------------------------------------ -uid_nr_t nr_uid_linear_allocator_new(gNB_RRC_INST *const rrc_instance_pP) -//------------------------------------------------------------------------------ -{ - unsigned int i; - unsigned int bit_index = 1; - uid_nr_t uid = 0; - nr_uid_allocator_t *uia_p = &rrc_instance_pP->uid_allocator; - - for (i=0; i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE; i++) { - if (uia_p->bitmap[i] != UINT_MAX) { - bit_index = 1; - uid = 0; - - while ((uia_p->bitmap[i] & bit_index) == bit_index) { - bit_index = bit_index << 1; - uid += 1; - } - - uia_p->bitmap[i] |= bit_index; - return uid + (i*sizeof(unsigned int)*8); - } - } - - return UINT_MAX; -} - - -//------------------------------------------------------------------------------ -void -nr_uid_linear_allocator_free( - gNB_RRC_INST *rrc_instance_pP, - uid_nr_t uidP -) -//------------------------------------------------------------------------------ -{ - unsigned int i = uidP/sizeof(unsigned int)/8; - unsigned int bit = uidP % (sizeof(unsigned int) * 8); - unsigned int value = ~(0x00000001 << bit); - - if (i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE) { - rrc_instance_pP->uid_allocator.bitmap[i] &= value; - } -} - - //------------------------------------------------------------------------------ int rrc_gNB_compare_ue_rnti_id( struct rrc_gNB_ue_context_s *c1_pP, struct rrc_gNB_ue_context_s *c2_pP) @@ -130,7 +75,7 @@ rrc_gNB_allocate_new_UE_context( } memset(new_p, 0, sizeof(struct rrc_gNB_ue_context_s)); - new_p->local_uid = nr_uid_linear_allocator_new(rrc_instance_pP); + new_p->local_uid = uid_linear_allocator_new(&rrc_instance_pP->uid_allocator); for(int i = 0; i < NB_RB_MAX; i++) { new_p->ue_context.e_rab[i].xid = -1; @@ -177,12 +122,12 @@ void rrc_gNB_free_mem_UE_context( { LOG_T(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Clearing UE context 0x%p (free internal structs)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + PROTOCOL_NR_RRC_CTXT_UE_FMT" Clearing UE context 0x%p (free internal structs)\n", + PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), ue_context_pP); - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_LTE_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[0]); - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_LTE_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[1]); + //ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_LTE_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[0]); + //ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_LTE_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[1]); // empty the internal fields of the UE context here } @@ -195,25 +140,25 @@ void rrc_gNB_remove_ue_context( //------------------------------------------------------------------------------ { if (rrc_instance_pP == NULL) { - LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Bad RRC instance\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + LOG_E(RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Bad RRC instance\n", + PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); return; } if (ue_context_pP == NULL) { - LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Trying to free a NULL UE context\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + LOG_E(RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Trying to free a NULL UE context\n", + PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); return; } RB_REMOVE(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, ue_context_pP); rrc_gNB_free_mem_UE_context(ctxt_pP, ue_context_pP); - nr_uid_linear_allocator_free(rrc_instance_pP, ue_context_pP->local_uid); + uid_linear_allocator_free(&rrc_instance_pP->uid_allocator, ue_context_pP->local_uid); free(ue_context_pP); rrc_instance_pP->Nb_ue --; LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Removed UE context\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + PROTOCOL_NR_RRC_CTXT_UE_FMT" Removed UE context\n", + PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); } //----------------------------------------------------------------------------- diff --git a/openair2/RRC/NR/rrc_gNB_UE_context.h b/openair2/RRC/NR/rrc_gNB_UE_context.h index 73bd93e737..4009f2617f 100644 --- a/openair2/RRC/NR/rrc_gNB_UE_context.h +++ b/openair2/RRC/NR/rrc_gNB_UE_context.h @@ -34,27 +34,6 @@ #include "COMMON/platform_types.h" #include "nr_rrc_defs.h" - -void -nr_uid_linear_allocator_init( - nr_uid_allocator_t* const uid_pP -); - -uid_t -nr_uid_linear_allocator_new( - gNB_RRC_INST* rrc_instance_pP -); - - -void -nr_uid_linear_allocator_free( - gNB_RRC_INST* rrc_instance_pP, - uid_t uidP -); - - - - int rrc_gNB_compare_ue_rnti_id( struct rrc_gNB_ue_context_s* c1_pP, struct rrc_gNB_ue_context_s* c2_pP diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index b4508e2627..8907ff315a 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -34,6 +34,7 @@ #include "rrc_proto.h" #include "assertions.h" #include "rrc_vars.h" +#include "MAC/mac.h" typedef uint32_t channel_t; From a126cd122099fa59bcb93450ea6db0d20a949b09 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 3 May 2022 14:42:49 +0200 Subject: [PATCH 22/98] Delete ITTI-SIM --- cmake_targets/CMakeLists.txt | 47 +- cmake_targets/build_oai | 10 - common/utils/ocp_itti/all_msg.h | 3 - common/utils/ocp_itti/intertask_interface.h | 4 - doc/ITTISIM.md | 48 -- openair2/COMMON/itti_sim_messages_def.h | 36 - openair2/COMMON/itti_sim_messages_types.h | 51 -- openair2/F1AP/f1ap_cu_ue_context_management.c | 3 - openair2/RRC/LTE/defs_NB_IoT.h | 3 - openair2/RRC/NR/mac_rrc_dl_direct.c | 15 - openair2/RRC/NR/rrc_gNB.c | 133 +--- openair2/RRC/NR/rrc_gNB_NGAP.c | 12 - openair2/RRC/NR_UE/rrc_UE.c | 105 --- openair2/SIMULATION/NR_RRC/itti_sim.c | 664 ------------------ openair3/NGAP/ngap_gNB_nas_procedures.c | 9 - 15 files changed, 3 insertions(+), 1140 deletions(-) delete mode 100755 doc/ITTISIM.md delete mode 100644 openair2/COMMON/itti_sim_messages_def.h delete mode 100644 openair2/COMMON/itti_sim_messages_types.h delete mode 100644 openair2/SIMULATION/NR_RRC/itti_sim.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index f8bcb2b548..9914d4abfa 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -845,7 +845,6 @@ add_boolean_option(UE_EXPANSION False "enable UE_EXPANSION w add_boolean_option(PHY_TX_THREAD False "enable UE_EXPANSION with max 256 UE") add_boolean_option(PRE_SCD_THREAD False "enable UE_EXPANSION with max 256 UE") add_boolean_option(UESIM_EXPANSION False "enable UESIM_EXPANSION with max 256 UE") -add_boolean_option(ITTI_SIM False "enable itti simulator") ######################## # Include order @@ -3034,7 +3033,7 @@ if (${T_TRACER}) foreach(i #all "add_executable" definitions (except tests, rb_tool, updatefw) lte-softmodem lte-uesoftmodem nr-softmodem - nr-uesoftmodem dlsim dlsim_tm4 dlsim_tm7 nr-ittisim + nr-uesoftmodem dlsim dlsim_tm4 dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim nr_ulsim nr_dlsim nr_dlschsim nr_pbchsim nr_pucchsim nr_ulschsim ldpctest polartest smallblocktest cu_test du_test @@ -3120,50 +3119,6 @@ add_executable(rb_tool ) target_include_directories(rb_tool PRIVATE ${OPENAIR2_DIR}/NETWORK_DRIVER/MESH/) -# nr-ittisim -################################################### - -add_executable(nr-ittisim - ${rrc_h} - ${nr_rrc_h} - ${OPENAIR2_DIR}/GNB_APP/gnb_app.c - ${OPENAIR2_DIR}/GNB_APP/gnb_config.c - ${OPENAIR_DIR}/executables/nr-gnb.c - ${OPENAIR_DIR}/executables/nr-ru.c - ${OPENAIR2_DIR}/SIMULATION/NR_RRC/itti_sim.c - ${OPENAIR_DIR}/executables/softmodem-common.c - ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c - ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c - ${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c - ${OPENAIR2_DIR}/RRC/NAS/nas_config.c - ${OPENAIR2_DIR}/RRC/NAS/rb_config.c - ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c - ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c - ${OPENAIR_DIR}/common/utils/nr/nr_common.c - ${OPENAIR_DIR}/common/utils/lte/ue_power.c - ${OPENAIR_DIR}/common/utils/lte/prach_utils.c - ${OPENAIR2_DIR}/ENB_APP/flexran_agent_ran_api_to_fix.c - ${XFORMSINTERFACE_SOURCE} - ${T_SOURCE} - ${SHLIB_LOADER_SOURCES} - ) - -target_link_libraries (nr-ittisim - -Wl,--start-group - UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU GTPV1U SECU_CN SECU_OSA - ITTI ${FLPT_MSG_LIB} ${FLEXRAN_AGENT_LIB} ${RAL_LIB} ${NAS_SIM_LIB} RRC_LIB NR_RRC_LIB - NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB - X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${FSPT_MSG_LIB} - PHY_NR_UE SCHED_NR_UE_LIB NR_L2_UE - -Wl,--end-group z dl) - -target_link_libraries (nr-ittisim ${LIBXML2_LIBRARIES}) -target_link_libraries (nr-ittisim pthread m CONFIG_LIB rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) -target_link_libraries (nr-ittisim ${LIB_LMS_LIBRARIES}) -target_link_libraries (nr-ittisim ${T_LIB}) - -add_dependencies( nr-ittisim ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) - # ??? #################### list(APPEND oai_nw_drv_src device.c common.c ioctl.c classifier.c tool.c) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 16a0d559dd..09029c285a 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -177,8 +177,6 @@ Options: Enable the address sanitizer on all targets --sanitize-undefined | -fsanitize=undefined Enable the undefined behavior sanitizer on all targets ---ittiSIM - Makes the itti simulator -h | --help Print this help @@ -465,11 +463,6 @@ function main() { --sanitize-undefined | -fundefined=address) CMAKE_CMD="$CMAKE_CMD -DSANITIZE_UNDEFINED=True" shift;; - --ittiSIM) - ittiSIM=1 - CMAKE_CMD="$CMAKE_CMD -DITTI_SIM=True" - echo_info "Will compile itti simulator" - shift;; -h | --help) print_help exit 1;; @@ -623,9 +616,6 @@ function main() { if [ "$nrUE" = 1 ] ; then execlist="$execlist nr-uesoftmodem" fi - if [ "$ittiSIM" = "1" ] ; then - execlist="$execlist nr-ittisim" - fi if [[ "$execlist" == "" && "$SIMUS_PHY" != "1" ]]; then echo_success "installing dependencies successful" diff --git a/common/utils/ocp_itti/all_msg.h b/common/utils/ocp_itti/all_msg.h index 8f7f48ed5a..c4bedc2cf6 100644 --- a/common/utils/ocp_itti/all_msg.h +++ b/common/utils/ocp_itti/all_msg.h @@ -17,7 +17,4 @@ #include "openair2/COMMON/flexran_messages_def.h" #include "openair2/COMMON/f1ap_messages_def.h" #include "openair2/COMMON/ngap_messages_def.h" -#if ITTI_SIM -#include "openair2/COMMON/itti_sim_messages_def.h" -#endif diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index e595311b26..636d305c13 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -262,10 +262,6 @@ void *rrc_enb_process_itti_msg(void *); #include #include -#ifdef ITTI_SIM - #include -#endif - /* static const char *const messages_definition_xml = { #include diff --git a/doc/ITTISIM.md b/doc/ITTISIM.md deleted file mode 100755 index 13fdd90846..0000000000 --- a/doc/ITTISIM.md +++ /dev/null @@ -1,48 +0,0 @@ - - - - - -
- - - - - - Running L3 ITTI simulator -
- -This page is valid on the following branches: - -- `develop` starting from tag `2020.w48` - -# 1. Building the ITTI simulator. - -The ITTI simulator is available directly from the standard build. - -```bash -$ source oaienv -$ cd cmake_targets -$ sudo ./build_oai -x -w None -c -ittiSIM -``` - -# 2. Running the ITTI simulator. - -The ITTI simulator establishes ITTI-threaded communication between the gNB RRC task and the UE RRC task. - -This allows to test the sequence of NGAP/RRC/NAS messages. - -The main limitations are: - -- NAS is a simple stub that just sends and receives messages -- only initial Attach sequence - -## 2.1. Starting the ITTI simulator - -The ITTI simulator is able to run with a connected 5GC or without any. -The develop branch tag `2020.w48` only works RRC without 5GC connection. - -```bash -$ sudo -E ./ran_build/build/nr-ittisim -O gnb.conf -``` - diff --git a/openair2/COMMON/itti_sim_messages_def.h b/openair2/COMMON/itti_sim_messages_def.h deleted file mode 100644 index 681fc932dd..0000000000 --- a/openair2/COMMON/itti_sim_messages_def.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file itti_sim_messages_def.h - * \brief itti message for itti simulator - * \author Yoshio INOUE, Masayuki HARADA - * \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com - * \date 2020 - * \version 0.1 - */ - - - -MESSAGE_DEF(GNB_RRC_BCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, GNBBCCHind) -MESSAGE_DEF(GNB_RRC_CCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, GNBCCCHind) -MESSAGE_DEF(GNB_RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, GNBDCCHind) -MESSAGE_DEF(UE_RRC_CCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, UECCCHind) -MESSAGE_DEF(UE_RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, UEDCCHind) diff --git a/openair2/COMMON/itti_sim_messages_types.h b/openair2/COMMON/itti_sim_messages_types.h deleted file mode 100644 index 2e29e8f508..0000000000 --- a/openair2/COMMON/itti_sim_messages_types.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file itti_sim_messages_types.h - * \brief itti message for itti simulator - * \author Yoshio INOUE, Masayuki HARADA - * \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com - * \date 2020 - * \version 0.1 - */ - -#ifndef ITTI_SIM_MESSAGES_TYPES_H_ -#define ITTI_SIM_MESSAGES_TYPES_H_ - -#include "LTE_asn_constant.h" - - - -#define GNB_RRC_BCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.GNBBCCHind -#define GNB_RRC_CCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.GNBCCCHind -#define GNB_RRC_DCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.GNBDCCHind -#define UE_RRC_CCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.UECCCHind -#define UE_RRC_DCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.UEDCCHind - - - -typedef struct itti_sim_rrc_ch_s { - rb_id_t rbid; - uint8_t *sdu; - int size; -} itti_sim_rrc_ch_t; - -#endif /* ITTI_SIM_MESSAGES_TYPES_H_ */ diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 0f3959d4ad..cf8d4ce260 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -973,9 +973,6 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti); } -#ifdef ITTI_SIM - return 0; -#endif } else { struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[instance], rnti); diff --git a/openair2/RRC/LTE/defs_NB_IoT.h b/openair2/RRC/LTE/defs_NB_IoT.h index b98dbe22cc..17ef77ff17 100644 --- a/openair2/RRC/LTE/defs_NB_IoT.h +++ b/openair2/RRC/LTE/defs_NB_IoT.h @@ -37,9 +37,6 @@ #include "COMMON/s1ap_messages_types.h" #include "COMMON/rrc_messages_types.h" -#if ITTI_SIM -#include "COMMON/itti_sim_messages_types.h" -#endif #include "collection/tree.h" #include "rrc_types_NB_IoT.h" diff --git a/openair2/RRC/NR/mac_rrc_dl_direct.c b/openair2/RRC/NR/mac_rrc_dl_direct.c index b3ba7b9ee5..5c8d9d9d5b 100644 --- a/openair2/RRC/NR/mac_rrc_dl_direct.c +++ b/openair2/RRC/NR/mac_rrc_dl_direct.c @@ -26,24 +26,9 @@ static void dl_rrc_message_transfer_direct(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc) { -#ifdef ITTI_SIM - const int len = dl_rrc->rrc_container_length; - LOG_I(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - len); - uint8_t *message_buffer; - message_buffer = itti_malloc(TASK_RRC_GNB, TASK_RRC_UE_SIM, len); - memcpy (message_buffer, dl_rrc->rrc_container, len); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_CCCH_DATA_IND); - GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_CCCH_DATA_IND (message_p).size = len; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else /* TODO how to manage inter-thread communication? */ dl_rrc_message(module_id, dl_rrc); -#endif } void mac_rrc_dl_direct_init(nr_mac_rrc_dl_if_t *mac_rrc) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index bf122514ce..1cacc1abb3 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -447,17 +447,6 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( ue_context_pP->ue_context.ue_release_timer_thres = 1000; /* init timers */ // ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0; -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, - ue_p->Srb0.Tx_buffer.payload_size); - memcpy (message_buffer, (uint8_t*)ue_p->Srb0.Tx_buffer.Payload, ue_p->Srb0.Tx_buffer.payload_size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_CCCH_DATA_IND); - GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_CCCH_DATA_IND (message_p).size = ue_p->Srb0.Tx_buffer.payload_size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#endif } void @@ -507,16 +496,8 @@ rrc_gNB_generate_RRCReject( case ngran_gNB: { -#ifdef ITTI_SIM - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, - ue_p->Srb0.Tx_buffer.payload_size); - memcpy (message_buffer, (uint8_t*)ue_p->Srb0.Tx_buffer.Payload, ue_p->Srb0.Tx_buffer.payload_size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_CCCH_DATA_IND); - GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_CCCH_DATA_IND (message_p).size = ue_p->Srb0.Tx_buffer.payload_size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#endif + // NOTE: there was ITTI_SIM which has been removed. This case is maybe + // not necessary anymore // rrc_mac_config_req_gNB } break; @@ -724,17 +705,6 @@ rrc_gNB_generate_defaultRRCReconfiguration( case ngran_gNB: { -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, size); - memcpy (message_buffer, buffer, size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else LOG_D(NR_RRC, "[FRAME %05d][RRC_gNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, @@ -751,7 +721,6 @@ rrc_gNB_generate_defaultRRCReconfiguration( buffer, PDCP_TRANSMISSION_MODE_CONTROL); // rrc_pdcp_config_asn1_req -#endif // rrc_rlc_config_asn1_req } break; @@ -1014,17 +983,6 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( "[FRAME %05d][RRC_gNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_gNB_mui, ctxt_pP->module_id, DCCH); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB_SIM, TASK_RRC_UE_SIM, size); - memcpy (message_buffer, buffer, size); - message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else nr_rrc_data_req( ctxt_pP, DCCH, @@ -1033,7 +991,6 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); -#endif if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { rrc_mac_config_req_gNB(rrc->module_id, @@ -1212,17 +1169,6 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( "[FRAME %05d][RRC_gNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_gNB_mui, ctxt_pP->module_id, DCCH); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB_SIM, TASK_RRC_UE_SIM, size); - memcpy (message_buffer, buffer, size); - message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else nr_rrc_data_req( ctxt_pP, DCCH, @@ -1231,7 +1177,6 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); -#endif if (NODE_IS_DU(RC.nrrrc[ctxt_pP->module_id]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[ctxt_pP->module_id]->node_type)) { uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup && @@ -1325,17 +1270,6 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( LOG_D(NR_RRC, "[FRAME %05d][RRC_gNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_gNB_mui, ctxt_pP->module_id, DCCH); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, size); - memcpy (message_buffer, buffer, size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else nr_rrc_data_req( ctxt_pP, DCCH, @@ -1344,7 +1278,6 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); -#endif if (NODE_IS_DU(RC.nrrrc[ctxt_pP->module_id]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[ctxt_pP->module_id]->node_type)) { uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup && @@ -1402,7 +1335,6 @@ rrc_gNB_process_RRCReconfigurationComplete( &kRRCint); /* Refresh SRBs/DRBs */ -#ifndef ITTI_SIM LOG_D(NR_RRC,"Configuring PDCP DRBs/SRBs for UE %x\n",ue_context_pP->ue_context.rnti); nr_rrc_pdcp_config_asn1_req(ctxt_pP, @@ -1428,7 +1360,6 @@ rrc_gNB_process_RRCReconfigurationComplete( NULL, get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); } -#endif /* Set the SRB active in UE context */ if (SRB_configList != NULL) { @@ -1590,18 +1521,6 @@ rrc_gNB_generate_RRCReestablishment( rnti); } #endif -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, ue_context->Srb0.Tx_buffer.payload_size); - memcpy (message_buffer, (uint8_t *) ue_context->Srb0.Tx_buffer.Payload, ue_context->Srb0.Tx_buffer.payload_size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = ue_context->Srb0.Tx_buffer.payload_size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#endif - } //----------------------------------------------------------------------------- @@ -1839,17 +1758,6 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( LOG_D(NR_RRC, "[FRAME %05d][RRC_gNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_gNB_mui, ctxt_pP->module_id, DCCH); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, size); - memcpy (message_buffer, buffer, size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else nr_rrc_data_req( ctxt_pP, DCCH, @@ -1858,7 +1766,6 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); -#endif } if (NODE_IS_DU(RC.nrrrc[ctxt_pP->module_id]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[ctxt_pP->module_id]->node_type)) { @@ -4210,17 +4117,6 @@ rrc_gNB_generate_SecurityModeCommand( size, rrc_gNB_mui, DCCH); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM,size); - memcpy (message_buffer, buffer, size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else LOG_D(NR_RRC,"calling rrc_data_req :securityModeCommand\n"); nr_rrc_data_req(ctxt_pP, DCCH, @@ -4229,7 +4125,6 @@ rrc_gNB_generate_SecurityModeCommand( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); -#endif break; default : @@ -4282,17 +4177,6 @@ rrc_gNB_generate_UECapabilityEnquiry( size, rrc_gNB_mui, DCCH); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, size); - memcpy (message_buffer, buffer, size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else nr_rrc_data_req(ctxt_pP, DCCH, rrc_gNB_mui++, @@ -4300,7 +4184,6 @@ rrc_gNB_generate_UECapabilityEnquiry( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); -#endif break; default : @@ -4342,17 +4225,6 @@ rrc_gNB_generate_RRCRelease( rrc_gNB_mui, DCCH); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, size); - memcpy (message_buffer, buffer, size); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#else if (NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { uint8_t *message_buffer = itti_malloc (TASK_RRC_GNB, TASK_CU_F1, size); memcpy (message_buffer, buffer, size); @@ -4375,7 +4247,6 @@ rrc_gNB_generate_RRCRelease( rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE(ctxt_pP->instance, ue_context_pP->ue_context.gNB_ue_ngap_id); ue_context_pP->ue_context.ue_release_timer_rrc = 1; } -#endif } void nr_rrc_trigger(protocol_ctxt_t *ctxt, int CC_id, int frame, int subframe) { diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 8e1975ea11..8f391417e0 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -824,17 +824,6 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS( case ngran_gNB: { // rrc_mac_config_req_gNB -#ifdef ITTI_SIM - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, length); - memcpy (message_buffer, buffer, length); - MessageDef *message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = length; - itti_send_msg_to_task (TASK_RRC_UE_SIM, instance, message_p); - LOG_I(NR_RRC, "Send DL NAS message \n"); -#else /* Transfer data to PDCP */ nr_rrc_data_req ( &ctxt, @@ -844,7 +833,6 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS( length, buffer, PDCP_TRANSMISSION_MODE_CONTROL); -#endif } break; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 53817af48e..bf4f053ba6 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1342,12 +1342,6 @@ static void rrc_ue_generate_RRCSetupComplete( int nas_msg_length; if (AMF_MODE_ENABLED) { -#if defined(ITTI_SIM) - as_nas_info_t initialNasMsg; - generateRegistrationRequest(&initialNasMsg, ctxt_pP->module_id); - nas_msg = (char*)initialNasMsg.data; - nas_msg_length = initialNasMsg.length; -#else if (get_softmodem_params()->sa) { as_nas_info_t initialNasMsg; generateRegistrationRequest(&initialNasMsg, ctxt_pP->module_id); @@ -1357,7 +1351,6 @@ static void rrc_ue_generate_RRCSetupComplete( nas_msg = (char *) NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data; nas_msg_length = NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length; } -#endif } else { nas_msg = nr_nas_attach_req_imsi; nas_msg_length = sizeof(nr_nas_attach_req_imsi); @@ -1381,18 +1374,6 @@ static void rrc_ue_generate_RRCSetupComplete( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); - -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_NRUE, TASK_RRC_GNB_SIM, size); - memcpy (message_buffer, buffer, size); - message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_DCCH_DATA_IND); - UE_RRC_DCCH_DATA_IND (message_p).rbid = 1; - UE_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - UE_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); -#endif } int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB_INFO *const Srb_info, const uint8_t gNB_index ){ @@ -1711,19 +1692,6 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB } LOG_T(NR_RRC, "\n"); - #ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM, - (enc_rval.encoded + 7) / 8); - memcpy (message_buffer, buffer, (enc_rval.encoded + 7) / 8); - - message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; - itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); - #else rrc_data_req_nr_ue (ctxt_pP, DCCH, nr_rrc_mui++, @@ -1731,7 +1699,6 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB (enc_rval.encoded + 7) / 8, buffer, PDCP_TRANSMISSION_MODE_CONTROL); - #endif } else LOG_W(NR_RRC,"securityModeCommand->criticalExtensions.present (%d) != NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand\n", securityModeCommand->criticalExtensions.present); @@ -1777,19 +1744,6 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB //printf("\n"); /*UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.Payload[i] = taus()&0xff; UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.payload_size =i; */ - -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM, - NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size); - memcpy (message_buffer, (uint8_t*)NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.Payload, - NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size); - message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_CCCH_DATA_IND); - GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_CCCH_DATA_IND (message_p).size = NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size; - itti_send_msg_to_task (TASK_RRC_GNB_SIM, gNB_index, message_p); -#endif } } @@ -2254,19 +2208,6 @@ nr_rrc_ue_establish_srb2( nr_rrc_mui, UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), DCCH); - #ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM,size); - memcpy (message_buffer, buffer, size); - - message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_DCCH_DATA_IND); - UE_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - UE_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - UE_RRC_DCCH_DATA_IND (message_p).size = size; - itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); - - #else rrc_data_req_nr_ue ( ctxt_pP, DCCH, @@ -2275,8 +2216,6 @@ nr_rrc_ue_establish_srb2( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); - #endif - } // from NR SRB1 @@ -2523,22 +2462,6 @@ nr_rrc_ue_establish_srb2( length = do_NR_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data); /* Transfer data to PDCP */ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NR_UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0,0); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM,length); - memcpy (message_buffer, buffer, length); - - message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_DCCH_DATA_IND); - if(NR_UE_rrc_inst[ue_mod_id].SRB2_config[0] == NULL) - UE_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - else - UE_RRC_DCCH_DATA_IND (message_p).rbid = DCCH1; - UE_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - UE_RRC_DCCH_DATA_IND (message_p).size = length; - itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt.instance, message_p); - -#else // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2) if(NR_UE_rrc_inst[ue_mod_id].SRB2_config[0] == NULL) { rrc_data_req_nr_ue (&ctxt, @@ -2555,7 +2478,6 @@ nr_rrc_ue_establish_srb2( length, buffer, PDCP_TRANSMISSION_MODE_CONTROL); } -#endif break; } @@ -2699,19 +2621,6 @@ nr_rrc_ue_process_ueCapabilityEnquiry( } LOG_I(NR_RRC, "UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM, - (enc_rval.encoded + 7) / 8); - memcpy (message_buffer, buffer, (enc_rval.encoded + 7) / 8); - - message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; - itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); -#else rrc_data_req_nr_ue ( ctxt_pP, DCCH, @@ -2720,7 +2629,6 @@ nr_rrc_ue_process_ueCapabilityEnquiry( (enc_rval.encoded + 7) / 8, buffer, PDCP_TRANSMISSION_MODE_CONTROL); -#endif } } } @@ -2739,19 +2647,6 @@ nr_rrc_ue_generate_rrcReestablishmentComplete( rrcReestablishment->rrc_TransactionIdentifier); LOG_I(NR_RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCReestablishmentComplete (bytes%d, gNB %d)\n", ctxt_pP->module_id,ctxt_pP->frame, length, gNB_index); -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM,length); - memcpy (message_buffer, buffer, length); - - message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_DCCH_DATA_IND); - UE_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - UE_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; - UE_RRC_DCCH_DATA_IND (message_p).size = length; - itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); - -#endif } void *recv_msgs_from_lte_ue(void *args_p) diff --git a/openair2/SIMULATION/NR_RRC/itti_sim.c b/openair2/SIMULATION/NR_RRC/itti_sim.c deleted file mode 100644 index a6ac444e45..0000000000 --- a/openair2/SIMULATION/NR_RRC/itti_sim.c +++ /dev/null @@ -1,664 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file itti_sim.c - * \brief simulator for itti message from node to UE - * \author Yoshio INOUE, Masayuki HARADA - * \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com - * \date 2020 - * \version 0.1 - */ - - -#include - - -#include "T.h" - -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all -#include - -#include "common/ran_context.h" - -#include "common/config/config_userapi.h" -#include "common/utils/load_module_shlib.h" -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all - -#include "PHY/phy_vars.h" -#include "SCHED/sched_common_vars.h" -#include "LAYER2/MAC/mac_vars.h" -#include "RRC/LTE/rrc_vars.h" -#include "gnb_config.h" -#include "SIMULATION/TOOLS/sim.h" - -#ifdef SMBV -#include "PHY/TOOLS/smbv.h" -unsigned short config_frames[4] = {2,9,11,13}; -#endif - -#include "common/utils/LOG/log.h" -#include "common/utils/LOG/vcd_signal_dumper.h" -#include "UTIL/OPT/opt.h" - -#include "intertask_interface.h" - - -#include "system.h" -#include -#include "PHY/TOOLS/phy_scope_interface.h" -#include "PHY/TOOLS/nr_phy_scope.h" -#include "stats.h" -#include "nr-softmodem.h" -#include "executables/softmodem-common.h" -#include "executables/thread-common.h" -#include "NB_IoT_interface.h" -#include "x2ap_eNB.h" -#include "ngap_gNB.h" -#include "RRC/NR_UE/rrc_proto.h" -#include "RRC/NR_UE/rrc_vars.h" -#include "openair3/NAS/UE/nas_ue_task.h" -#include -#include -#if ITTI_SIM -#include "nr_nas_msg_sim.h" -#endif - -pthread_cond_t nfapi_sync_cond; -pthread_mutex_t nfapi_sync_mutex; -int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex - -uint32_t timing_advance = 0; -uint64_t num_missed_slots=0; - -int split73=0; -void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { - AssertFatal(false, "Must not be called in this context\n"); -} -void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask, uint16_t rnti, int32_t stat) { - AssertFatal(false, "Must not be called in this context\n"); -} - -nrUE_params_t nrUE_params; -nrUE_params_t *get_nrUE_params(void) { - return &nrUE_params; -} - -void processSlotTX(void *arg) {} - -THREAD_STRUCT thread_struct; -pthread_cond_t sync_cond; -pthread_mutex_t sync_mutex; -int sync_var=-1; //!< protected by mutex \ref sync_mutex. -int config_sync_var=-1; - -openair0_config_t openair0_cfg[MAX_CARDS]; - -//volatile int start_gNB = 0; -volatile int oai_exit = 0; - -//static int wait_for_sync = 0; - -unsigned int mmapped_dma=0; -int single_thread_flag=1; - -int8_t threequarter_fs=0; - -uint64_t downlink_frequency[MAX_NUM_CCs][4]; -int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; - -//Temp fix for inexistent NR upper layer -unsigned char NB_gNB_INST = 1; - - -int UE_scan = 1; -int UE_scan_carrier = 0; -runmode_t mode = normal_txrx; -static double snr_dB=20; - -FILE *input_fd=NULL; - -int chain_offset=0; - - -uint8_t dci_Format = 0; -uint8_t agregation_Level =0xFF; - -uint8_t nb_antenna_tx = 1; -uint8_t nb_antenna_rx = 1; - -char ref[128] = "internal"; -char channels[128] = "0"; - -int otg_enabled; - -extern void *udp_eNB_task(void *args_p); - -int transmission_mode=1; -int emulate_rf = 0; -int numerology = 0; - - -double cpuf; - -extern char uecap_xer[1024]; -char uecap_xer_in=0; - -/* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed - * this is very hackish - find a proper solution - */ -uint8_t abstraction_flag=0; - -/* forward declarations */ -void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs], NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); - -/*---------------------BMC: timespec helpers -----------------------------*/ - -struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; -struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; - -struct timespec clock_difftime(struct timespec start, struct timespec end) { - struct timespec temp; - - if ((end.tv_nsec-start.tv_nsec)<0) { - temp.tv_sec = end.tv_sec-start.tv_sec-1; - temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; - } else { - temp.tv_sec = end.tv_sec-start.tv_sec; - temp.tv_nsec = end.tv_nsec-start.tv_nsec; - } - - return temp; -} - - - -#define KNRM "\x1B[0m" -#define KRED "\x1B[31m" -#define KGRN "\x1B[32m" -#define KBLU "\x1B[34m" -#define RESET "\033[0m" - - -void exit_function(const char *file, const char *function, const int line, const char *s) { - int ru_id; - - if (s != NULL) { - printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s); - } - - oai_exit = 1; - - if (RC.ru == NULL) - exit(-1); // likely init not completed, prevent crash or hang, exit now... - - for (ru_id=0; ru_idrfdevice.trx_end_func) { - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - RC.ru[ru_id]->rfdevice.trx_end_func = NULL; - } - - if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) { - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); - RC.ru[ru_id]->ifdevice.trx_end_func = NULL; - } - } - - sleep(1); //allow lte-softmodem threads to exit first - exit(1); -} - -void wait_gNBs(void) { - int i; - int waiting=1; - - while (waiting==1) { - printf("Waiting for gNB L1 instances to all get configured ... sleeping 50ms (nb_nr_sL1_inst %d)\n",RC.nb_nr_L1_inst); - usleep(50*1000); - waiting=0; - - for (i=0; iconfigured==0) { - waiting=1; - break; - } - } - } - - printf("gNB L1 are configured\n"); -} - -void wait_RUs(void) { - LOG_I(PHY,"Waiting for RUs to be configured ... RC.ru_mask:%02lx\n", RC.ru_mask); - // wait for all RUs to be configured over fronthaul - pthread_mutex_lock(&RC.ru_mutex); - - while (RC.ru_mask>0) { - pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex); - printf("RC.ru_mask:%02lx\n", RC.ru_mask); - } - - pthread_mutex_unlock(&RC.ru_mutex); - LOG_I(PHY,"RUs configured\n"); -} - - -int stop_L1L2(module_id_t gnb_id) { - return 0; -} - -int restart_L1L2(module_id_t gnb_id) { - return 0; -} - -int create_gNB_tasks(uint32_t gnb_nb) { - LOG_D(GNB_APP, "%s(gnb_nb:%d)\n", __FUNCTION__, gnb_nb); - itti_wait_ready(1); - - - if (gnb_nb > 0) { - if(itti_create_task(TASK_SCTP, sctp_eNB_task, NULL) < 0){ - LOG_E(SCTP, "Create task for SCTP failed\n"); - return -1; - } - if (is_x2ap_enabled()) { - if(itti_create_task(TASK_X2AP, x2ap_task, NULL) < 0){ - LOG_E(X2AP, "Create task for X2AP failed\n"); - } - } - else { - LOG_I(X2AP, "X2AP is disabled.\n"); - } - } - - if (AMF_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==0 && get_softmodem_params()->sa==0)) { - if (gnb_nb > 0) { - if (itti_create_task (TASK_NGAP, ngap_gNB_task, NULL) < 0) { - LOG_E(S1AP, "Create task for NGAP failed\n"); - return -1; - } - - - if(!emulate_rf){ - if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) { - LOG_E(UDP_, "Create task for UDP failed\n"); - return -1; - } - } - - if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) { - LOG_E(GTPU, "Create task for GTPV1U failed\n"); - return -1; - } - } - } - - - if (gnb_nb > 0) { - if (itti_create_task (TASK_GNB_APP, gNB_app_task, NULL) < 0) { - LOG_E(GNB_APP, "Create task for gNB APP failed\n"); - return -1; - } - LOG_I(NR_RRC,"Creating NR RRC gNB Task\n"); - - if (itti_create_task (TASK_RRC_GNB, rrc_gnb_task, NULL) < 0) { - LOG_E(NR_RRC, "Create task for NR RRC gNB failed\n"); - return -1; - } - } - - return 0; -} - - -static void get_options(void) { - - - paramdef_t cmdline_params[] = CMDLINE_PARAMS_DESC_GNB ; - - CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); - get_common_options(SOFTMODEM_GNB_BIT ); - config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); - CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); - - - - - if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) { - memset((void *)&RC,0,sizeof(RC)); - /* Read RC configuration file */ - NRRCConfig(); - NB_gNB_INST = RC.nb_nr_inst; - NB_RU = RC.nb_RU; - printf("Configuration: nb_rrc_inst %d, nb_nr_L1_inst %d, nb_ru %hhu\n",NB_gNB_INST,RC.nb_nr_L1_inst,NB_RU); - } - -} - - -void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs], - NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) -{ - for (int CC_id=0; CC_idssb_config.scs_common.value = 1; - config[CC_id]->cell_config.frame_duplex_type.value = 1; //FDD - config[CC_id]->carrier_config.dl_grid_size[1].value = 106; - config[CC_id]->carrier_config.ul_grid_size[1].value = 106; - config[CC_id]->cell_config.phy_cell_id.value = 0; - } -} - -/* - * helper function to terminate a certain ITTI task - */ -void terminate_task(task_id_t task_id, module_id_t mod_id) { - LOG_I(GNB_APP, "sending TERMINATE_MESSAGE to task %s (%d)\n", itti_get_task_name(task_id), task_id); - MessageDef *msg; - msg = itti_alloc_new_message (ENB_APP, 0, TERMINATE_MESSAGE); - itti_send_msg_to_task (task_id, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg); -} - -//extern void free_transport(PHY_VARS_gNB *); -extern void nr_phy_free_RU(RU_t *); - -statis void init_pdcp(void) { - //if (!NODE_IS_DU(RC.rrc[0]->node_type)) { - pdcp_layer_init(); - uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? - (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; - - if (IS_SOFTMODEM_NOS1) { - printf("IS_SOFTMODEM_NOS1 option enabled \n"); - pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; - } - - pdcp_module_init(pdcp_initmask, 0); - - pdcp_set_rlc_data_req_func(rlc_data_req); - pdcp_set_pdcp_data_ind_func(pdcp_data_ind); -} - - -int create_tasks_nrue(uint32_t ue_nb) { - LOG_D(ENB_APP, "%s(ue_nb:%d)\n", __FUNCTION__, ue_nb); - itti_wait_ready(1); - - if (ue_nb > 0) { - LOG_D(NR_RRC, "create TASK_RRC_NRUE\n"); - if (itti_create_task (TASK_RRC_NRUE, rrc_nrue_task, NULL) < 0) { - LOG_E(NR_RRC, "Create task for RRC UE failed\n"); - return -1; - } - - LOG_D(NR_RRC,"create TASK_NAS_NRUE\n"); - if (itti_create_task (TASK_NAS_NRUE, nas_nrue_task, NULL) < 0) { - LOG_E(NR_RRC, "Create task for NAS UE failed\n"); - return -1; - } - } - - - itti_wait_ready(0); - return 0; -} - - -void *itti_sim_ue_rrc_task( void *args_p) { - MessageDef *msg_p, *message_p; - instance_t instance; - unsigned int ue_mod_id; - int result; - itti_mark_task_ready (TASK_RRC_UE_SIM); - - while(1) { - // Wait for a message - itti_receive_msg (TASK_RRC_UE_SIM, &msg_p); - instance = ITTI_MSG_DESTINATION_INSTANCE (msg_p); - ue_mod_id = UE_INSTANCE_TO_MODULE_ID(instance); - - switch (ITTI_MSG_ID(msg_p)) { - case TERMINATE_MESSAGE: - LOG_W(NR_RRC, " *** Exiting RRC thread\n"); - itti_exit_task (); - break; - - case MESSAGE_TEST: - LOG_D(NR_RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); - break; - case GNB_RRC_BCCH_DATA_IND: - message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, 0, NR_RRC_MAC_BCCH_DATA_IND); - memset (NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu, 0, BCCH_SDU_SIZE); - NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = GNB_RRC_BCCH_DATA_IND(msg_p).size; - memcpy (NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu, GNB_RRC_BCCH_DATA_IND(msg_p).sdu, GNB_RRC_BCCH_DATA_IND(msg_p).size); - itti_send_msg_to_task (TASK_RRC_NRUE, instance, message_p); - break; - case GNB_RRC_CCCH_DATA_IND: - message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, 0, NR_RRC_MAC_CCCH_DATA_IND); - printf("receive GNB_RRC_CCCH_DATA_IND\n"); - memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); - memcpy (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, GNB_RRC_CCCH_DATA_IND(msg_p).sdu, GNB_RRC_CCCH_DATA_IND(msg_p).size); - NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = GNB_RRC_CCCH_DATA_IND(msg_p).size; - itti_send_msg_to_task (TASK_RRC_NRUE, instance, message_p); - break; - case GNB_RRC_DCCH_DATA_IND: - printf("receive GNB_RRC_DCCH_DATA_IND\n"); - message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, 0, NR_RRC_DCCH_DATA_IND); - NR_RRC_DCCH_DATA_IND (message_p).dcch_index = GNB_RRC_DCCH_DATA_IND(msg_p).rbid; - NR_RRC_DCCH_DATA_IND (message_p).sdu_size = GNB_RRC_DCCH_DATA_IND(msg_p).size; - NR_RRC_DCCH_DATA_IND (message_p).sdu_p = GNB_RRC_DCCH_DATA_IND(msg_p).sdu; - itti_send_msg_to_task (TASK_RRC_NRUE, instance, message_p); - break; - default: - LOG_E(NR_RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); - break; - } - - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - msg_p = NULL; - } -} - - -void *itti_sim_gnb_rrc_task( void *args_p) { - MessageDef *msg_p, *message_p; - instance_t instance; - unsigned int ue_mod_id; - int result; - itti_mark_task_ready (TASK_RRC_GNB_SIM); - - while(1) { - // Wait for a message - itti_receive_msg (TASK_RRC_GNB_SIM, &msg_p); - instance = ITTI_MSG_DESTINATION_INSTANCE (msg_p); - ue_mod_id = UE_INSTANCE_TO_MODULE_ID(instance); - - switch (ITTI_MSG_ID(msg_p)) { - case TERMINATE_MESSAGE: - LOG_W(NR_RRC, " *** Exiting RRC thread\n"); - itti_exit_task (); - break; - - case MESSAGE_TEST: - LOG_D(NR_RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); - break; - case UE_RRC_CCCH_DATA_IND: - message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, 0, NR_RRC_MAC_CCCH_DATA_IND); - NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = UE_RRC_CCCH_DATA_IND(msg_p).size; - memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); - memcpy (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, UE_RRC_CCCH_DATA_IND(msg_p).sdu, UE_RRC_CCCH_DATA_IND(msg_p).size); - itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p); - break; - case UE_RRC_DCCH_DATA_IND: - message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, 0, NR_RRC_DCCH_DATA_IND); - NR_RRC_DCCH_DATA_IND (message_p).sdu_size = UE_RRC_DCCH_DATA_IND(msg_p).size; - NR_RRC_DCCH_DATA_IND (message_p).dcch_index = UE_RRC_DCCH_DATA_IND(msg_p).rbid; - NR_RRC_DCCH_DATA_IND (message_p).sdu_p = UE_RRC_DCCH_DATA_IND(msg_p).sdu; - itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p); - break; - - default: - LOG_E(NR_RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); - break; - } - - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - msg_p = NULL; - } -} - - -int main( int argc, char **argv ) -{ - start_background_system(); - - ///static configuration for NR at the moment - if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) { - exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); - } - set_softmodem_sighandler(); -#ifdef DEBUG_CONSOLE - setvbuf(stdout, NULL, _IONBF, 0); - setvbuf(stderr, NULL, _IONBF, 0); -#endif - - logInit(); - //set_latency_target(); - printf("Reading in command-line options\n"); - get_options (); - - if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { - fprintf(stderr,"Getting configuration failed\n"); - exit(-1); - } - - AMF_MODE_ENABLED = !IS_SOFTMODEM_NOS1; -// AMF_MODE_ENABLED = 0; - NGAP_CONF_MODE = !IS_SOFTMODEM_NOS1; //!get_softmodem_params()->phy_test; - -#if T_TRACER - T_Config_Init(); -#endif - //randominit (0); - set_taus_seed (0); - printf("configuring for RAU/RRU\n"); - - if (opp_enabled ==1) { - reset_opp_meas(); - } - - cpuf=get_cpu_freq_GHz(); - itti_init(TASK_MAX, tasks_info); - - init_opt(); - - LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); - - if(IS_SOFTMODEM_NOS1) - init_pdcp(); - - if (RC.nb_nr_inst > 0) { - nr_read_config_and_init(); - // don't create if node doesn't connect to RRC/S1/GTP - AssertFatal(create_gNB_tasks(1) == 0,"cannot create ITTI tasks\n"); - for (int gnb_id = 0; gnb_id < RC.nb_nr_inst; gnb_id++) { - MessageDef *msg_p = itti_alloc_new_message (TASK_GNB_APP, 0, NRRRC_CONFIGURATION_REQ); - NRRRC_CONFIGURATION_REQ(msg_p) = RC.nrrrc[gnb_id]->configuration; - itti_send_msg_to_task (TASK_RRC_GNB, GNB_MODULE_ID_TO_INSTANCE(gnb_id), msg_p); - } - } else { - printf("No ITTI, Initializing L1\n"); - return 0; - } - - if(itti_create_task (TASK_RRC_GNB_SIM, itti_sim_gnb_rrc_task, NULL) < 0){ - printf("cannot create ITTI tasks\n"); - exit(-1); // need a softer mode - } - - openair_rrc_top_init_ue_nr("./"); - - if (create_tasks_nrue(1) < 0) { - printf("cannot create ITTI tasks\n"); - exit(-1); // need a softer mode - } - - if(itti_create_task (TASK_RRC_UE_SIM, itti_sim_ue_rrc_task, NULL) < 0){ - printf("cannot create ITTI tasks\n"); - exit(-1); // need a softer mode - } - - pthread_cond_init(&sync_cond,NULL); - pthread_mutex_init(&sync_mutex, NULL); - - printf("Sending sync to all threads\n"); - pthread_mutex_lock(&sync_mutex); - sync_var=0; - pthread_cond_broadcast(&sync_cond); - pthread_mutex_unlock(&sync_mutex); - // wait for end of program - printf("TYPE TO TERMINATE\n"); - - usleep(100000); - protocol_ctxt_t ctxt; - struct rrc_gNB_ue_context_s *ue_context_p = NULL; - - - ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[0]); - - if(ue_context_p == NULL){ - printf("ue_context_p == NULL"); - } - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, - 0, - ENB_FLAG_YES, - 0, - 0, - 0); - NR_UE_rrc_inst[ctxt.module_id].Info[0].State = RRC_SI_RECEIVED; - - nr_rrc_ue_generate_RRCSetupRequest(ctxt.module_id, 0); - - printf("Entering ITTI signals handler\n"); - itti_wait_tasks_end(); - printf("Returned from ITTI signal handler\n"); - oai_exit=1; - printf("oai_exit=%d\n",oai_exit); - - printf("stopping MODEM threads\n"); - - - /* release memory used by the RU/gNB threads (incomplete), after all - * threads have been stopped (they partially use the same memory) */ - - pthread_cond_destroy(&sync_cond); - pthread_mutex_destroy(&sync_mutex); - - logClean(); - printf("Bye.\n"); - return 0; -} - - - diff --git a/openair3/NGAP/ngap_gNB_nas_procedures.c b/openair3/NGAP/ngap_gNB_nas_procedures.c index d7db2f70b4..976a4220dd 100644 --- a/openair3/NGAP/ngap_gNB_nas_procedures.c +++ b/openair3/NGAP/ngap_gNB_nas_procedures.c @@ -1369,15 +1369,6 @@ int ngap_gNB_pdusession_release_resp(instance_t instance, item->pDUSessionResourceReleaseResponseTransfer.size = 0; item->pDUSessionResourceReleaseResponseTransfer.buf = NULL; NGAP_DEBUG("pdusession_release_resp: transfer_buffer is NULL!\n"); -#ifdef ITTI_SIM - //For testing only - item->pDUSessionResourceReleaseResponseTransfer.buf = malloc(sizeof(uint8_t) * 1); - item->pDUSessionResourceReleaseResponseTransfer.size = 1; - uint8_t temp = 0; - memcpy(item->pDUSessionResourceReleaseResponseTransfer.buf, - &temp, - item->pDUSessionResourceReleaseResponseTransfer.size); -#endif } NGAP_DEBUG("pdusession_release_resp: pdusession ID %ld\n", item->pDUSessionID); ASN_SEQUENCE_ADD(&ie->value.choice.PDUSessionResourceReleasedListRelRes.list, item); From 18a68387c44d658fc90759bba6c1bc03ca640016 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 3 May 2022 12:22:01 +0200 Subject: [PATCH 23/98] Transfer Initial UL RRC Message through internal F1 --- common/utils/ocp_itti/intertask_interface.h | 1 + openair2/COMMON/f1ap_messages_types.h | 3 +- openair2/F1AP/f1ap_cu_rrc_message_transfer.c | 80 ++++---- openair2/F1AP/f1ap_du_rrc_message_transfer.c | 4 +- openair2/F1AP/f1ap_du_rrc_message_transfer.h | 2 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 60 +++++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 16 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 7 + .../LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c | 18 +- openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c | 17 +- openair2/LAYER2/NR_MAC_gNB/main.c | 1 + openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 3 + openair2/RRC/NR/L2_nr_interface.c | 68 ------- openair2/RRC/NR/MESSAGES/asn1_msg.c | 80 +++----- openair2/RRC/NR/MESSAGES/asn1_msg.h | 25 +-- openair2/RRC/NR/nr_rrc_config.c | 16 +- openair2/RRC/NR/nr_rrc_config.h | 10 +- openair2/RRC/NR/nr_rrc_proto.h | 21 +-- openair2/RRC/NR/rrc_gNB.c | 172 ++++++++---------- openair2/RRC/NR/rrc_gNB_reconfig.c | 6 +- 20 files changed, 293 insertions(+), 317 deletions(-) diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 636d305c13..a3f447baa3 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -304,6 +304,7 @@ void *rrc_enb_process_msg(void *); TASK_DEF(TASK_BM, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_PHY_ENB, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_MAC_ENB, TASK_PRIORITY_MED, 200, NULL, NULL) \ + TASK_DEF(TASK_MAC_GNB, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_RLC_ENB, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_RRC_ENB_NB_IoT, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_PDCP_ENB, TASK_PRIORITY_MED, 200, NULL, NULL) \ diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index c19bdff9a2..cbc4d1c6f2 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -62,7 +62,6 @@ #define F1AP_MAX_NO_OF_TNL_ASSOCIATIONS 32 #define F1AP_MAX_NO_UE_ID 1024 -#define F1AP_MAX_DU2CU_RRC_LENGTH 1024 typedef struct f1ap_net_ip_address_s { unsigned ipv4:1; @@ -310,7 +309,7 @@ typedef struct f1ap_initial_ul_rrc_message_s { uint16_t crnti; uint8_t *rrc_container; int rrc_container_length; - char du2cu_rrc_container[F1AP_MAX_DU2CU_RRC_LENGTH]; + uint8_t *du2cu_rrc_container; int du2cu_rrc_container_length; } f1ap_initial_ul_rrc_message_t; diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c index 62a62095b1..3ae30cafb9 100644 --- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c @@ -79,56 +79,60 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance, F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_C_RNTI, true); rnti = ie->value.choice.C_RNTI; - /* RRC Container */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, + F1AP_InitialULRRCMessageTransferIEs_t *rrccont; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, rrccont, container, F1AP_ProtocolIE_ID_id_RRCContainer, true); - AssertFatal(ie!=NULL,"RRCContainer is missing\n"); + AssertFatal(rrccont!=NULL,"RRCContainer is missing\n"); - // create an ITTI message and copy SDU - if (f1ap_req(true, instance)->cell_type==CELL_MACRO_GNB) { - message_p = itti_alloc_new_message (TASK_CU_F1, 0, NR_RRC_MAC_CCCH_DATA_IND); - memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); - ccch_sdu_len = ie->value.choice.RRCContainer.size; - memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, ie->value.choice.RRCContainer.buf, - ccch_sdu_len); - } else { - message_p = itti_alloc_new_message (TASK_CU_F1, 0, RRC_MAC_CCCH_DATA_IND); - memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); - ccch_sdu_len = ie->value.choice.RRCContainer.size; - memcpy(RRC_MAC_CCCH_DATA_IND (message_p).sdu, ie->value.choice.RRCContainer.buf, - ccch_sdu_len); - } - - LOG_I(F1AP, "%s() RRCContainer (CCCH) size %ld: ", __func__, ie->value.choice.RRCContainer.size); - /* DUtoCURRCContainer */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, + F1AP_InitialULRRCMessageTransferIEs_t *du2cu; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, du2cu, container, F1AP_ProtocolIE_ID_id_DUtoCURRCContainer, false); - if (ie) { - NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container = malloc(sizeof(OCTET_STRING_t)); - NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->size = ie->value.choice.DUtoCURRCContainer.size; - NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf = malloc(ie->value.choice.DUtoCURRCContainer.size); - memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf, - ie->value.choice.DUtoCURRCContainer.buf, - ie->value.choice.DUtoCURRCContainer.size); - } - int f1ap_uid = f1ap_add_ue(CUtype, instance, rnti); if (f1ap_uid < 0 ) { LOG_E(F1AP, "Failed to add UE \n"); - itti_free(ITTI_MSG_ORIGIN_ID(message_p), message_p); return -1; } + // create an ITTI message and copy SDU + if (f1ap_req(true, instance)->cell_type==CELL_MACRO_GNB) { + message_p = itti_alloc_new_message (TASK_CU_F1, 0, F1AP_INITIAL_UL_RRC_MESSAGE); + f1ap_initial_ul_rrc_message_t *ul_rrc = &F1AP_INITIAL_UL_RRC_MESSAGE(message_p); + ul_rrc->nr_cellid = nr_cellid; // CU instance + ul_rrc->crnti = rnti; + ul_rrc->rrc_container_length = rrccont->value.choice.RRCContainer.size; + ul_rrc->rrc_container = malloc(ul_rrc->rrc_container_length); + memcpy(ul_rrc->rrc_container, rrccont->value.choice.RRCContainer.buf, ul_rrc->rrc_container_length); + AssertFatal(du2cu != NULL, "no masterCellGroup in initial UL RRC message\n"); + ul_rrc->du2cu_rrc_container_length = du2cu->value.choice.DUtoCURRCContainer.size; + ul_rrc->du2cu_rrc_container = malloc(ul_rrc->du2cu_rrc_container_length); + memcpy(ul_rrc->du2cu_rrc_container, du2cu->value.choice.DUtoCURRCContainer.buf, ul_rrc->du2cu_rrc_container_length); + itti_send_msg_to_task(TASK_RRC_GNB, instance, message_p); + } else { + message_p = itti_alloc_new_message (TASK_CU_F1, 0, RRC_MAC_CCCH_DATA_IND); + memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); + ccch_sdu_len = rrccont->value.choice.RRCContainer.size; + memcpy(RRC_MAC_CCCH_DATA_IND (message_p).sdu, rrccont->value.choice.RRCContainer.buf, + ccch_sdu_len); + NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; + NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0; + NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len; + NR_RRC_MAC_CCCH_DATA_IND (message_p).nr_cellid = nr_cellid; // CU instance + NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; + NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; + if (du2cu) { + NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container = malloc(sizeof(OCTET_STRING_t)); + NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->size = du2cu->value.choice.DUtoCURRCContainer.size; + NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf = malloc(du2cu->value.choice.DUtoCURRCContainer.size); + memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf, + du2cu->value.choice.DUtoCURRCContainer.buf, + du2cu->value.choice.DUtoCURRCContainer.size); + } + itti_send_msg_to_task (TASK_RRC_ENB, instance, message_p); + } + //getCxt(true,ITTI_MSG_DESTINATION_ID(message_p))->f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id; - NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; - NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0; - NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len; - NR_RRC_MAC_CCCH_DATA_IND (message_p).nr_cellid = nr_cellid; // CU instance - NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; - NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; - itti_send_msg_to_task (f1ap_req(true,ITTI_MSG_DESTINATION_ID(message_p))->cell_type==CELL_MACRO_GNB?TASK_RRC_GNB:TASK_RRC_ENB, instance, message_p); return 0; } diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c index d896a2640b..c0f8b79839 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c @@ -749,7 +749,7 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instanceP, rnti_t rntiP, const uint8_t *sduP, sdu_size_t sdu_lenP, - const char *sdu2P, + const uint8_t *sdu2P, sdu_size_t sdu2_lenP) { F1AP_F1AP_PDU_t pdu= {0}; F1AP_InitialULRRCMessageTransfer_t *out; @@ -808,7 +808,7 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instanceP, ie5->criticality = F1AP_Criticality_reject; ie5->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer; OCTET_STRING_fromBuf(&ie5->value.choice.DUtoCURRCContainer, - sdu2P, + (const char *)sdu2P, sdu2_lenP); } /* mandatory */ diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.h b/openair2/F1AP/f1ap_du_rrc_message_transfer.h index d6f196e384..b42d731ac7 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.h +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.h @@ -50,7 +50,7 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instanceP, rnti_t rntiP, const uint8_t *sduP, sdu_size_t sdu_lenP, - const char *sdu2P, + const uint8_t *sdu2P, sdu_size_t sdu2_lenP); #endif /* F1AP_DU_RRC_MESSAGE_TRANSFER_H_ */ diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index a737e66c40..1475abc08a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -44,9 +44,12 @@ #include "OCG.h" #include "OCG_extern.h" +/* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */ #include "RRC/LTE/rrc_extern.h" #include "RRC/NR/nr_rrc_extern.h" +#include "RRC/NR/rrc_gNB_UE_context.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +#include "RRC/NR/MESSAGES/asn1_msg.h" #include "intertask_interface.h" @@ -2136,7 +2139,7 @@ int rnti_to_remove[10]; volatile int rnti_to_remove_count; pthread_mutex_t rnti_to_remove_mutex = PTHREAD_MUTEX_INITIALIZER; -void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) +void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr, uid_allocator_t *uia) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; destroy_nr_list(&sched_ctrl->available_dl_harq); @@ -2145,6 +2148,7 @@ void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) destroy_nr_list(&sched_ctrl->available_ul_harq); destroy_nr_list(&sched_ctrl->feedback_ul_harq); destroy_nr_list(&sched_ctrl->retrans_ul_harq); + uid_linear_allocator_free(uia, UE->uid); LOG_I(NR_MAC, "Remove NR rnti 0x%04x\n", UE->rnti); const rnti_t rnti = UE->rnti; free(UE); @@ -2439,6 +2443,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf } UE->rnti = rntiP; + UE->uid = uid_linear_allocator_new(&UE_info->uid_allocator); UE->CellGroup = CellGroup; if (CellGroup) @@ -2492,7 +2497,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf } if (i == MAX_MOBILES_PER_GNB) { LOG_E(NR_MAC,"Try to add UE %04x but the list is full\n", rntiP); - delete_nr_ue_data(UE, nr_mac->common_channels); + delete_nr_ue_data(UE, nr_mac->common_channels, &UE_info->uid_allocator); pthread_mutex_unlock(&UE_info->mutex); return NULL; } @@ -2596,7 +2601,7 @@ void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti) memcpy(UE_info->list, newUEs, sizeof(UE_info->list)); pthread_mutex_unlock(&UE_info->mutex); - delete_nr_ue_data(UE, nr_mac->common_channels); + delete_nr_ue_data(UE, nr_mac->common_channels, &UE_info->uid_allocator); } void nr_mac_remove_ra_rnti(module_id_t mod_id, rnti_t rnti) { @@ -2979,3 +2984,52 @@ void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCom req->Slot = i; } } + +void send_initial_ul_rrc_message(module_id_t module_id, + int CC_id, + const NR_UE_info_t *UE, + rb_id_t srb_id, + const uint8_t *sdu, + sdu_size_t sdu_len) { + const gNB_MAC_INST *mac = RC.nrmac[module_id]; + const rnti_t rnti = UE->rnti; + LOG_W(MAC, + "[RAPROC] Received SDU for CCCH on SRB %ld length %d for UE %04x\n", + srb_id, sdu_len, rnti); + + /* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */ + if (NODE_IS_DU(RC.nrrrc[module_id]->node_type)) { + struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_id]); + ue_context_p->ue_id_rnti = rnti; + ue_context_p->ue_context.rnti = rnti; + ue_context_p->ue_context.random_ue_identity = rnti; + ue_context_p->ue_context.Srb0.Active = 1; + RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_id]->rrc_ue_head, ue_context_p); + } + + const NR_ServingCellConfigCommon_t *scc = RC.nrrrc[module_id]->carrier.servingcellconfigcommon; + const NR_ServingCellConfig_t *sccd = RC.nrrrc[module_id]->configuration.scd; + NR_CellGroupConfig_t cellGroupConfig = {0}; + fill_initial_cellGroupConfig(UE->uid, &cellGroupConfig, scc, sccd, &RC.nrrrc[module_id]->configuration); + + uint8_t du2cu_rrc_container[1024]; + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, + NULL, + &cellGroupConfig, + du2cu_rrc_container, + sizeof(du2cu_rrc_container)); + AssertFatal(enc_rval.encoded > 0, + "Could not encode cellGroupConfig for UE %04x, failed element %s\n", + rnti, + enc_rval.failed_type->name); + + const f1ap_initial_ul_rrc_message_t ul_rrc_msg = { + /* TODO: add mcc, mnc, cell_id, ..., is not available at MAC yet */ + .crnti = rnti, + .rrc_container = (uint8_t *) sdu, + .rrc_container_length = sdu_len, + .du2cu_rrc_container = (uint8_t *) du2cu_rrc_container, + .du2cu_rrc_container_length = (enc_rval.encoded + 7) / 8 + }; + mac->mac_rrc.initial_ul_rrc_message_transfer(module_id, &ul_rrc_msg); +} diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 27af724c20..43e88eb9a9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -312,16 +312,12 @@ int nr_process_mac_pdu( instance_t module_idP, mac_len = 6; } - nr_mac_rrc_data_ind(module_idP, - CC_id, - frameP, - 0, - 0, - UE->rnti, - CCCH, - pduP + mac_subheader_len, - mac_len, - 0); + send_initial_ul_rrc_message(module_idP, + CC_id, + UE, + CCCH, + pduP + mac_subheader_len, + mac_len); break; case UL_SCH_LCID_DTCH ... (UL_SCH_LCID_DTCH + 28): diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index c61a12de16..674d80a4d4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -502,6 +502,13 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); +void send_initial_ul_rrc_message(module_id_t module_id, + int CC_id, + const NR_UE_info_t *UE, + rb_id_t srb_id, + const uint8_t *sdu, + sdu_size_t sdu_len); + void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid); #endif /*__LAYER2_NR_MAC_PROTO_H__*/ diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c index f290e0d268..25ee7feb14 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c @@ -25,8 +25,22 @@ static void initial_ul_rrc_message_transfer_direct(module_id_t module_id, const f1ap_initial_ul_rrc_message_t *ul_rrc) { - /* TODO ITTI message for NR_RRC_MAC_IND? */ - AssertFatal(0 == 1, "not implemented\n"); + MessageDef *msg = itti_alloc_new_message(TASK_MAC_GNB, 0, F1AP_INITIAL_UL_RRC_MESSAGE); + /* copy all fields, but reallocate rrc_containers! */ + f1ap_initial_ul_rrc_message_t *f1ap_msg = &F1AP_INITIAL_UL_RRC_MESSAGE(msg); + *f1ap_msg = *ul_rrc; + + f1ap_msg->rrc_container = malloc(ul_rrc->rrc_container_length); + DevAssert(f1ap_msg->rrc_container); + memcpy(f1ap_msg->rrc_container, ul_rrc->rrc_container, ul_rrc->rrc_container_length); + f1ap_msg->rrc_container_length = ul_rrc->rrc_container_length; + + f1ap_msg->du2cu_rrc_container = malloc(ul_rrc->du2cu_rrc_container_length); + DevAssert(f1ap_msg->du2cu_rrc_container); + memcpy(f1ap_msg->du2cu_rrc_container, ul_rrc->du2cu_rrc_container, ul_rrc->du2cu_rrc_container_length); + f1ap_msg->du2cu_rrc_container_length = ul_rrc->du2cu_rrc_container_length; + + itti_send_msg_to_task(TASK_RRC_GNB, module_id, msg); } void mac_rrc_ul_direct_init(struct nr_mac_rrc_ul_if_s *mac_rrc) diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c index ed67fb9119..65e7f10405 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c @@ -25,7 +25,22 @@ static void initial_ul_rrc_message_transfer_f1ap(module_id_t module_id, const f1ap_initial_ul_rrc_message_t *ul_rrc) { - AssertFatal(0 == 1, "not implemented\n"); + MessageDef *msg = itti_alloc_new_message(TASK_MAC_GNB, 0, F1AP_INITIAL_UL_RRC_MESSAGE); + /* copy all fields, but reallocate rrc_containers! */ + f1ap_initial_ul_rrc_message_t *f1ap_msg = &F1AP_INITIAL_UL_RRC_MESSAGE(msg); + *f1ap_msg = *ul_rrc; + + f1ap_msg->rrc_container = malloc(ul_rrc->rrc_container_length); + DevAssert(f1ap_msg->rrc_container); + memcpy(f1ap_msg->rrc_container, ul_rrc->rrc_container, ul_rrc->rrc_container_length); + f1ap_msg->rrc_container_length = ul_rrc->rrc_container_length; + + f1ap_msg->du2cu_rrc_container = malloc(ul_rrc->du2cu_rrc_container_length); + DevAssert(f1ap_msg->du2cu_rrc_container); + memcpy(f1ap_msg->du2cu_rrc_container, ul_rrc->du2cu_rrc_container, ul_rrc->du2cu_rrc_container_length); + f1ap_msg->du2cu_rrc_container_length = ul_rrc->du2cu_rrc_container_length; + + itti_send_msg_to_task(TASK_DU_F1, module_id, msg); } void mac_rrc_ul_f1ap_init(struct nr_mac_rrc_ul_if_s *mac_rrc) diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 0694f7d757..8c1abf4561 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -228,6 +228,7 @@ void mac_top_init_gNB(ngran_node_t node_type) RC.nrmac[i]->first_MIB = true; pthread_mutex_init(&RC.nrmac[i]->UE_info.mutex, NULL); + uid_linear_allocator_init(&RC.nrmac[i]->UE_info.uid_allocator); if (get_softmodem_params()->phy_test) { RC.nrmac[i]->pre_processor_dl = nr_preprocessor_phytest; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 3c3ea4dfc8..09f3193790 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -46,6 +46,7 @@ #include "targets/ARCH/COMMON/common_lib.h" #include "COMMON/platform_constants.h" #include "common/ran_context.h" +#include "collection/linear_alloc.h" /* RRC */ #include "NR_BCCH-BCH-Message.h" @@ -694,6 +695,7 @@ typedef struct nr_mac_rrc_ul_if_s { /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ typedef struct { rnti_t rnti; + uid_t uid; // unique ID of this UE /// scheduling control info nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG]; NR_UE_sched_ctrl_t UE_sched_ctrl; @@ -720,6 +722,7 @@ typedef struct { pthread_mutex_t mutex; NR_UE_info_t *list[MAX_MOBILES_PER_GNB+1]; bool sched_csirs; + uid_allocator_t uid_allocator; } NR_UEs_t; #define UE_iterator(BaSe, VaR) NR_UE_info_t ** VaR##pptr=BaSe, *VaR; while ((VaR=*(VaR##pptr++))) diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index ab9e3984d8..67e06914ef 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -202,74 +202,6 @@ int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, return 0; } -int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, - const int CC_id, - const frame_t frameP, - const sub_frame_t sub_frameP, - const int UE_id, - const rnti_t rntiP, - const rb_id_t srb_idP, - const uint8_t *sduP, - const sdu_size_t sdu_lenP, - const bool brOption) { - - if (NODE_IS_DU(RC.nrrrc[module_idP]->node_type)) { - LOG_W(RRC,"[DU %d][RAPROC] Received SDU for CCCH on SRB %ld length %d for UE id %d RNTI %x \n", - module_idP, srb_idP, sdu_lenP, UE_id, rntiP); - - // Generate DUtoCURRCContainer - // call do_RRCSetup like full procedure and extract masterCellGroup - NR_CellGroupConfig_t cellGroupConfig; - NR_ServingCellConfigCommon_t *scc=RC.nrrrc[module_idP]->carrier.servingcellconfigcommon; - NR_ServingCellConfig_t *servingcellconfigdedicated = RC.nrrrc[module_idP]->configuration.scd; - memset(&cellGroupConfig,0,sizeof(cellGroupConfig)); - - struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_idP]); - ue_context_p->ue_id_rnti = rntiP; - ue_context_p->ue_context.rnti = rntiP; - ue_context_p->ue_context.random_ue_identity = rntiP; - ue_context_p->ue_context.Srb0.Active = 1; - RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_idP]->rrc_ue_head, ue_context_p); - - fill_initial_cellGroupConfig(ue_context_p->local_uid,&cellGroupConfig,scc,servingcellconfigdedicated,&RC.nrrrc[module_idP]->configuration); - - MessageDef* tmp=itti_alloc_new_message_sized(TASK_RRC_GNB, 0, F1AP_INITIAL_UL_RRC_MESSAGE, sizeof(f1ap_initial_ul_rrc_message_t) + sdu_lenP); - f1ap_initial_ul_rrc_message_t *msg = &F1AP_INITIAL_UL_RRC_MESSAGE(tmp); - - asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, - NULL, - (void *)&cellGroupConfig, - msg->du2cu_rrc_container, - F1AP_MAX_DU2CU_RRC_LENGTH); - - if (enc_rval.encoded == -1) { - LOG_E(F1AP,"Could not encoded cellGroupConfig, failed element %s\n",enc_rval.failed_type->name); - exit(-1); - } - /* do ITTI message */ - msg->du2cu_rrc_container_length = (enc_rval.encoded+7)/8; - msg->crnti=rntiP; - msg->rrc_container=(uint8_t*) (msg+1); // Made extra room after the struct with itti_alloc_msg_sized() - memcpy(msg->rrc_container, sduP, sdu_lenP); - msg->rrc_container_length=sdu_lenP; - itti_send_msg_to_task(TASK_DU_F1, 0, tmp); - - return 0; - } - - protocol_ctxt_t ctxt; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, GNB_FLAG_YES, rntiP, frameP, sub_frameP,0); - - if((srb_idP & RAB_OFFSET) == CCCH) { - LOG_D(NR_RRC, "[gNB %d] Received SDU for CCCH on SRB %ld\n", module_idP, srb_idP); - ctxt.brOption = brOption; - if (sdu_lenP > 0) { - nr_rrc_gNB_decode_ccch(&ctxt, sduP, sdu_lenP, NULL, CC_id); - } - } - return 0; -} - void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP, const int CC_idP, const frame_t frameP, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 2c620f62a5..6aaa96a8e7 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -986,8 +986,8 @@ uint8_t do_RRCReject(uint8_t Mod_id, void fill_default_downlinkBWP(NR_BWP_Downlink_t *bwp, int bwp_loop, - NR_ServingCellConfig_t *servingcellconfigdedicated, - NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfig_t *servingcellconfigdedicated, + const NR_ServingCellConfigCommon_t *scc, const gNB_RrcConfigurationReq *configuration) { /// BWP common configuration @@ -1133,8 +1133,8 @@ void fill_default_downlinkBWP(NR_BWP_Downlink_t *bwp, void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, int bwp_loop, - NR_ServingCellConfig_t *servingcellconfigdedicated, - NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfig_t *servingcellconfigdedicated, + const NR_ServingCellConfigCommon_t *scc, const gNB_RrcConfigurationReq *configuration, int uid) { @@ -1330,13 +1330,11 @@ void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, } void fill_initial_SpCellConfig(int uid, - NR_CellGroupConfig_t *cellGroupConfig, - NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfig_t *servingcellconfigdedicated, - const gNB_RrcConfigurationReq *configuration) { - - NR_SpCellConfig_t *SpCellConfig = cellGroupConfig->spCellConfig; - + NR_SpCellConfig_t *SpCellConfig, + const NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfig_t *servingcellconfigdedicated, + const gNB_RrcConfigurationReq *configuration) +{ // This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4. // However, if in the future NUMBER_OF_UE_MAX is increased, it will be necessary to improve the allocation of SRS resources, // where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations. @@ -1915,8 +1913,8 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, void fill_initial_cellGroupConfig(int uid, NR_CellGroupConfig_t *cellGroupConfig, - NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfig_t *servingcellconfigdedicated, + const NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfig_t *servingcellconfigdedicated, const gNB_RrcConfigurationReq *configuration) { NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = NULL; @@ -1970,20 +1968,21 @@ void fill_initial_cellGroupConfig(int uid, cellGroupConfig->spCellConfig = calloc(1,sizeof(*cellGroupConfig->spCellConfig)); - fill_initial_SpCellConfig(uid,cellGroupConfig,scc,servingcellconfigdedicated,configuration); + fill_initial_SpCellConfig(uid,cellGroupConfig->spCellConfig,scc,servingcellconfigdedicated,configuration); cellGroupConfig->sCellToAddModList = NULL; cellGroupConfig->sCellToReleaseList = NULL; } //------------------------------------------------------------------------------ -int16_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t *const buffer, - const uint8_t transaction_id, - OCTET_STRING_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfig_t *servingcellconfigdedicated, - const gNB_RrcConfigurationReq *configuration) +int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, + uint8_t *const buffer, + const uint8_t transaction_id, + const uint8_t *masterCellGroup, + int masterCellGroup_len, + const NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfig_t *servingcellconfigdedicated, + const gNB_RrcConfigurationReq *configuration) //------------------------------------------------------------------------------ { asn_enc_rval_t enc_rval; @@ -1993,7 +1992,6 @@ int16_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, NR_SRB_ToAddMod_t *SRB1_config = NULL; NR_PDCP_Config_t *pdcp_Config = NULL; NR_CellGroupConfig_t *cellGroupConfig = NULL; - char masterCellGroup_buf[3000]; AssertFatal(ue_context_pP != NULL,"ue_context_p is null\n"); gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; @@ -2036,38 +2034,14 @@ int16_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, ie->radioBearerConfig.securityConfig = NULL; /****************************** masterCellGroup ******************************/ - /* TODO */ - if (masterCellGroup_from_DU) { - memcpy(&ie->masterCellGroup,masterCellGroup_from_DU,sizeof(*masterCellGroup_from_DU)); - // decode masterCellGroup OCTET_STRING received from DU and place in ue context - uper_decode(NULL, - &asn_DEF_NR_CellGroupConfig, //might be added prefix later - (void **)&cellGroupConfig, - (uint8_t *)masterCellGroup_from_DU->buf, - masterCellGroup_from_DU->size, 0, 0); - } - else { - cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_initial_cellGroupConfig(ue_context_pP->local_uid,cellGroupConfig,scc,servingcellconfigdedicated,configuration); - - enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, - NULL, - (void *)cellGroupConfig, - masterCellGroup_buf, - 3000); - - if(enc_rval.encoded == -1) { - LOG_E(NR_RRC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; - } - - if (OCTET_STRING_fromBuf(&ie->masterCellGroup, masterCellGroup_buf, (enc_rval.encoded+7)/8) == -1) { - LOG_E(NR_RRC, "fatal: OCTET_STRING_fromBuf failed\n"); - return -1; - } - } + DevAssert(masterCellGroup && masterCellGroup_len > 0); + ie->masterCellGroup.buf = malloc(masterCellGroup_len); + AssertFatal(ie->masterCellGroup.buf != NULL, "could not allocate memory for masterCellGroup\n"); + memcpy(ie->masterCellGroup.buf, masterCellGroup, masterCellGroup_len); + ie->masterCellGroup.size = masterCellGroup_len; + // decode masterCellGroup OCTET_STRING received from DU and place in ue context + uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, (void **)&cellGroupConfig, masterCellGroup, masterCellGroup_len, 0, 0); ue_p->masterCellGroup = cellGroupConfig; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index ea4b185f6b..1d6be68f5c 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -100,15 +100,15 @@ uint8_t do_RRCReject(uint8_t Mod_id, uint8_t *const buffer); void fill_initial_SpCellConfig(int uid, - NR_CellGroupConfig_t *cellGroupConfig, - NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfig_t *servingcellconfigdedicated, + NR_SpCellConfig_t *SpCellConfig, + const NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfig_t *servingcellconfigdedicated, const gNB_RrcConfigurationReq *configuration); void fill_initial_cellGroupConfig(int uid, NR_CellGroupConfig_t *cellGroupConfig, - NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfig_t *servingcellconfigdedicated, + const NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfig_t *servingcellconfigdedicated, const gNB_RrcConfigurationReq *configuration); void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, @@ -124,13 +124,14 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, uint8_t nb_bearers_to_setup, long *priority); -int16_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t *const buffer, - const uint8_t transaction_id, - OCTET_STRING_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfig_t *servingcellconfigdedicated, - const gNB_RrcConfigurationReq *configuration); +int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, + uint8_t *const buffer, + const uint8_t transaction_id, + const uint8_t *masterCellGroup, + int masterCellGroup_len, + const NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfig_t *servingcellconfigdedicated, + const gNB_RrcConfigurationReq *configuration); uint8_t do_NR_SecurityModeCommand( const protocol_ctxt_t *const ctxt_pP, diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index f67fb93c23..5d1e3e97d0 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -71,7 +71,7 @@ void rrc_coreset_config(NR_ControlResourceSet_t *coreset, coreset->pdcch_DMRS_ScramblingID = NULL; } -uint64_t get_ssb_bitmap(NR_ServingCellConfigCommon_t *scc) { +uint64_t get_ssb_bitmap(const NR_ServingCellConfigCommon_t *scc) { uint64_t bitmap=0; switch (scc->ssb_PositionsInBurst->present) { case 1 : @@ -138,7 +138,7 @@ void set_csirs_periodicity(NR_NZP_CSI_RS_Resource_t *nzpcsi0, int uid, int nb_sl } } -void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, +void config_csirs(const NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_CSI_MeasConfig_t *csi_MeasConfig, int uid, int num_dl_antenna_ports, @@ -495,7 +495,7 @@ void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, phy_Parameters->phy_ParametersFRX_Diff->pucch_F0_2WithoutFH = NULL; } -void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc, +void nr_rrc_config_dl_tda(const NR_ServingCellConfigCommon_t *scc, NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, int curr_bwp) { @@ -716,9 +716,9 @@ void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs) { ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); } -void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig, - NR_ServingCellConfigCommon_t *scc) { - +static void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig, + const NR_ServingCellConfigCommon_t *scc) +{ const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; int sr_slot = 1; // in FDD SR in slot 1 if(tdd) @@ -760,7 +760,7 @@ void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequ schedulingRequestResourceConfig->periodicityAndOffset->choice.sl640 = sr_slot; } -void scheduling_request_config(NR_ServingCellConfigCommon_t *scc, +void scheduling_request_config(const NR_ServingCellConfigCommon_t *scc, NR_PUCCH_Config_t *pucch_Config) { // format with <=2 bits in pucch resource set 0 @@ -784,7 +784,7 @@ 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) { + const NR_ServingCellConfigCommon_t *scc) { if (cap == NULL){ bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = NULL; diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index b1367a0c8a..27aebcf94b 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -111,12 +111,12 @@ typedef struct physicalcellgroup_s{ long RNTI_Value[MAX_NUM_CCs]; }physicalcellgroup_t; -uint64_t get_ssb_bitmap(NR_ServingCellConfigCommon_t *scc); +uint64_t get_ssb_bitmap(const NR_ServingCellConfigCommon_t *scc); void rrc_coreset_config(NR_ControlResourceSet_t *coreset, int bwp_id, int curr_bwp, uint64_t ssb_bitmap); -void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc, +void nr_rrc_config_dl_tda(const NR_ServingCellConfigCommon_t *scc, NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, int curr_bwp); void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay); @@ -124,9 +124,9 @@ void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap); void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time); void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs); -void scheduling_request_config(NR_ServingCellConfigCommon_t *scc, +void scheduling_request_config(const NR_ServingCellConfigCommon_t *scc, NR_PUCCH_Config_t *pucch_Config); -void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, +void config_csirs(const NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_CSI_MeasConfig_t *csi_MeasConfig, int uid, int num_dl_antenna_ports, @@ -142,7 +142,7 @@ 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); + const NR_ServingCellConfigCommon_t *scc); void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, NR_ServingCellConfigCommon_t *scc, int numerology, diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index dc6e14215f..b90cf4dfa4 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -108,9 +108,9 @@ void rrc_gNB_generate_RRCSetup( const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP, - OCTET_STRING_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc, - const int CC_id); + const uint8_t *masterCellGroup, + int masterCellGroup_len, + NR_ServingCellConfigCommon_t *scc); int parse_CG_ConfigInfo(gNB_RRC_INST *rrc, NR_CG_ConfigInfo_t *CG_ConfigInfo, x2ap_ENDC_sgnb_addition_req_t *m); @@ -174,17 +174,6 @@ int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, const int dl_bwp_id, const int ul_bwp_id); -int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, - const int CC_id, - const frame_t frameP, - const sub_frame_t sub_frameP, - const int UE_id, - const rnti_t rntiP, - const rb_id_t srb_idP, - const uint8_t *sduP, - const sdu_size_t sdu_lenP, - const bool brOption); - int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP, protocol_ctxt_t *const ctxt_pP, const int dl_bwp_id, @@ -193,8 +182,8 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, const uint8_t *buffer, int buffer_length, - OCTET_STRING_t *du_to_cu_rrc_container, - const int CC_id); + const uint8_t *du_to_cu_rrc_container, + int du_to_cu_rrc_container_length); void rrc_gNB_generate_dedicatedRRCReconfiguration_release( diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 1cacc1abb3..208a78d37e 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -339,10 +339,9 @@ void rrc_gNB_generate_RRCSetup( const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP, - OCTET_STRING_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc, - const int CC_id -) + const uint8_t *masterCellGroup, + int masterCellGroup_len, + NR_ServingCellConfigCommon_t *scc) //----------------------------------------------------------------------------- { LOG_I(NR_RRC, "rrc_gNB_generate_RRCSetup for RNTI %04x\n", ctxt_pP->rnti); @@ -355,16 +354,15 @@ rrc_gNB_generate_RRCSetup( gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; - NR_ServingCellConfig_t *servingcellconfigdedicated = rrc->configuration.scd; - int16_t ret = do_RRCSetup(ue_context_pP, - (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, - rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), - masterCellGroup_from_DU, - scc,servingcellconfigdedicated,&rrc->configuration); - - AssertFatal(ret>0,"Error generating RRCSetup for RRCSetupRequest\n"); - - ue_p->Srb0.Tx_buffer.payload_size = ret; + const NR_ServingCellConfig_t *sccd = rrc->configuration.scd; + ue_p->Srb0.Tx_buffer.payload_size = do_RRCSetup(ue_context_pP, + (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, + rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), + masterCellGroup, + masterCellGroup_len, + scc, + sccd, + &rrc->configuration); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)(ue_p->Srb0.Tx_buffer.Payload), @@ -400,8 +398,8 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( LOG_I(NR_RRC, "generate RRCSetup for RRCReestablishmentRequest \n"); rrc_gNB_ue_context_t *ue_context_pP = NULL; gNB_RRC_INST *rrc_instance_p = RC.nrrrc[ctxt_pP->module_id]; - NR_ServingCellConfigCommon_t *scc=rrc_instance_p->carrier.servingcellconfigcommon; - NR_ServingCellConfig_t *servingcellconfigdedicated = rrc_instance_p->configuration.scd; + const NR_ServingCellConfigCommon_t *scc=rrc_instance_p->carrier.servingcellconfigcommon; + const NR_ServingCellConfig_t *sccd = rrc_instance_p->configuration.scd; ue_context_pP = rrc_gNB_get_next_free_ue_context(ctxt_pP, rrc_instance_p, 0); @@ -410,7 +408,10 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), NULL, - scc,servingcellconfigdedicated,&rrc_instance_p->configuration); + 0, + scc, + sccd, + &rrc_instance_p->configuration); AssertFatal(ret>0,"Error generating RRCSetup for RRCReestablishmentRequest\n"); @@ -452,9 +453,7 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( void rrc_gNB_generate_RRCReject( const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - const int CC_id -) + rrc_gNB_ue_context_t *const ue_context_pP) //----------------------------------------------------------------------------- { LOG_I(NR_RRC, "rrc_gNB_generate_RRCReject \n"); @@ -1859,8 +1858,8 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, const uint8_t *buffer, int buffer_length, - OCTET_STRING_t *du_to_cu_rrc_container, - const int CC_id) + const uint8_t *du_to_cu_rrc_container, + int du_to_cu_rrc_container_len) { module_id_t Idx; asn_dec_rval_t dec_rval; @@ -1870,22 +1869,16 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, NR_RRCSetupRequest_IEs_t *rrcSetupRequest = NULL; NR_RRCReestablishmentRequest_IEs_t rrcReestablishmentRequest; uint64_t random_value = 0; - int i; - dec_rval = uper_decode( NULL, - &asn_DEF_NR_UL_CCCH_Message, - (void **)&ul_ccch_msg, - (uint8_t *) buffer, - 100, - 0, - 0); + LOG_I(NR_RRC, "Decoding CCCH: RNTI %04x, inst %ld, payload_size %d\n", ctxt_pP->rnti, ctxt_pP->instance, buffer_length); + dec_rval = uper_decode(NULL, &asn_DEF_NR_UL_CCCH_Message, (void **) &ul_ccch_msg, buffer, buffer_length, 0, 0); - if (dec_rval.consumed == 0) { - /* TODO */ - LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" FATAL Error in receiving CCCH\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); - return -1; - } + if (dec_rval.code != RC_OK || dec_rval.consumed == 0) { + LOG_E(NR_RRC, + PROTOCOL_NR_RRC_CTXT_UE_FMT" FATAL Error in receiving CCCH\n", + PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); + return -1; + } if (ul_ccch_msg->message.present == NR_UL_CCCH_MessageType_PR_c1) { switch (ul_ccch_msg->message.choice.c1->present) { @@ -1991,8 +1984,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, PROTOCOL_NR_RRC_CTXT_UE_FMT" RRCSetupRequest without random UE identity or S-TMSI not supported, let's reject the UE\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); rrc_gNB_generate_RRCReject(ctxt_pP, - rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti), - CC_id); + rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti)); break; } @@ -2001,8 +1993,8 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, rrc_gNB_generate_RRCSetup(ctxt_pP, rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti), du_to_cu_rrc_container, - gnb_rrc_inst->carrier.servingcellconfigcommon, - CC_id); + du_to_cu_rrc_container_len, + gnb_rrc_inst->carrier.servingcellconfigcommon); } break; @@ -2034,13 +2026,13 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), rrcReestablishmentRequest.ue_Identity.physCellId, RC.nrrrc[ctxt_pP->module_id]->carrier.physCellId); - rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, CC_id); + rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0); break; } LOG_D(NR_RRC, "physCellId is %ld\n", rrcReestablishmentRequest.ue_Identity.physCellId); - for (i = 0; i < rrcReestablishmentRequest.ue_Identity.shortMAC_I.size; i++) { + for (int i = 0; i < rrcReestablishmentRequest.ue_Identity.shortMAC_I.size; i++) { LOG_D(NR_RRC, "rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[%d] = %x\n", i, rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[i]); } @@ -2051,7 +2043,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest c_RNTI range error, fallback to RRC establishment\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); - rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, CC_id); + rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0); break; } @@ -2063,7 +2055,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest without UE context, fallback to RRC establishment\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); - rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, CC_id); + rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0); break; } #if(0) @@ -2074,14 +2066,14 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest without UE_id(MAC) rnti %x, fallback to RRC establishment\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),c_rnti); - rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, CC_id); + rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0); break; } //previous rnti rnti_t previous_rnti = 0; - for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { + for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (reestablish_rnti_map[i][1] == c_rnti) { previous_rnti = reestablish_rnti_map[i][0]; break; @@ -2095,7 +2087,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" RRCReestablishmentRequest without UE_id(MAC) previous rnti %x, fallback to RRC establishment\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),previous_rnti); - rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, CC_id); + rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0); break; } } @@ -2149,7 +2141,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ue_context_p->ue_context.reestablishment_xid = -1; // insert C-RNTI to map - for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { + for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (reestablish_rnti_map[i][0] == 0) { reestablish_rnti_map[i][0] = ctxt_pP->rnti; reestablish_rnti_map[i][1] = c_rnti; @@ -2165,7 +2157,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, rrcReestablishmentRequest.ue_Identity.physCellId, ue_context_p->ue_context.reestablishment_cause); - ue_context_p->ue_context.primaryCC_id = CC_id; + ue_context_p->ue_context.primaryCC_id = 0; //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH; Idx = DCCH; // SRB1 @@ -2187,7 +2179,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - rrc_gNB_generate_RRCReestablishment(ctxt_pP, ue_context_p, CC_id); + rrc_gNB_generate_RRCReestablishment(ctxt_pP, ue_context_p, 0); LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), @@ -2877,6 +2869,38 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { }//for (int i=0;inum_cells_available;i++) } +void rrc_gNB_process_initial_ul_rrc_message(const f1ap_initial_ul_rrc_message_t *ul_rrc) +{ + // first get RRC instance (note, no the ITTI instance) + module_id_t i = 0; + for (i=0; i < RC.nb_nr_inst; i++) { + gNB_RRC_INST *rrc = RC.nrrrc[i]; + if (rrc->nr_cellid == ul_rrc->nr_cellid) + break; + } + //AssertFatal(i != RC.nb_nr_inst, "Cell_id not found\n"); + // TODO REMOVE_DU_RRC in monolithic mode, the MAC does not have the + // nr_cellid. Thus, the above check would fail. For the time being, just put + // a warning, as we handle one DU only anyway + if (i == RC.nb_nr_inst) { + i = 0; + LOG_W(RRC, "initial UL RRC message nr_cellid %ld does not match RRC's %ld\n", ul_rrc->nr_cellid, RC.nrrrc[0]->nr_cellid); + } + protocol_ctxt_t ctxt = { 0 }; + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, i, GNB_FLAG_YES, ul_rrc->crnti, 0, 0); + + nr_rrc_gNB_decode_ccch(&ctxt, + ul_rrc->rrc_container, + ul_rrc->rrc_container_length, + ul_rrc->du2cu_rrc_container, + ul_rrc->du2cu_rrc_container_length); + + if (ul_rrc->rrc_container) + free(ul_rrc->rrc_container); + if (ul_rrc->du2cu_rrc_container) + free(ul_rrc->du2cu_rrc_container); +} + void rrc_gNB_process_release_request(const module_id_t gnb_mod_idP, x2ap_ENDC_sgnb_release_request_t *m) { gNB_RRC_INST *rrc = RC.nrrrc[gnb_mod_idP]; @@ -3897,49 +3921,11 @@ void *rrc_gnb_task(void *args_p) { nr_rrc_subframe_process(&RRC_SUBFRAME_PROCESS(msg_p).ctxt, RRC_SUBFRAME_PROCESS(msg_p).CC_id); break; - /* Messages from MAC */ - case NR_RRC_MAC_CCCH_DATA_IND: - { - instance_t i; - for (i=0; inr_cellid == NR_RRC_MAC_CCCH_DATA_IND(msg_p).nr_cellid) - break; - } - AssertFatal(i!=RC.nb_nr_inst, "Cell_id not found\n"); - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, - i, - GNB_FLAG_YES, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).rnti, - msg_p->ittiMsgHeader.lte_time.frame, - msg_p->ittiMsgHeader.lte_time.slot); - LOG_I(NR_RRC,"Decoding CCCH : ue %d, inst %ld, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n", - ctxt.rnti, - i, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id, - &ctxt, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); - - if (NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= CCCH_SDU_SIZE) { - LOG_I(NR_RRC, "CCCH message has size %d > %d\n", - NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,CCCH_SDU_SIZE); - break; - } - - nr_rrc_gNB_decode_ccch(&ctxt, - (uint8_t *)NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id); - - if (NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container) { - free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container->buf); - free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container); - } - } - break; + case F1AP_INITIAL_UL_RRC_MESSAGE: + AssertFatal(NODE_IS_CU(RC.nrrrc[instance]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[instance]->node_type), + "should not receive F1AP_INITIAL_UL_RRC_MESSAGE, need call by CU!\n"); + rrc_gNB_process_initial_ul_rrc_message(&F1AP_INITIAL_UL_RRC_MESSAGE(msg_p)); + break; /* Messages from PDCP */ case NR_RRC_DCCH_DATA_IND: diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 2ee3a26c4b..08baeb3d45 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -82,9 +82,9 @@ void fix_servingcellconfigdedicated(NR_ServingCellConfig_t *scd) { void fill_default_nsa_downlinkBWP(NR_BWP_Downlink_t *bwp, long bwp_loop, - NR_CellGroupConfig_t *secondaryCellGroup, - NR_ServingCellConfig_t *servingcellconfigdedicated, - NR_ServingCellConfigCommon_t *servingcellconfigcommon, + const NR_CellGroupConfig_t *secondaryCellGroup, + const NR_ServingCellConfig_t *servingcellconfigdedicated, + const NR_ServingCellConfigCommon_t *servingcellconfigcommon, const gNB_RrcConfigurationReq *configuration, NR_UE_NR_Capability_t *uecap, int dl_antenna_ports, From 9622a56bf12389a3d1a02f775c9e99bc1499f0ba Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 10 May 2022 13:13:09 +0200 Subject: [PATCH 24/98] gNB RRC: handle F1AP_UL_RRC_MESSAGE --- common/utils/ocp_itti/intertask_interface.h | 1 + openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 45 +++++++++++---------- openair2/RRC/NR/rrc_gNB.c | 26 +++++------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index a3f447baa3..3a03e380a1 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -308,6 +308,7 @@ void *rrc_enb_process_msg(void *); TASK_DEF(TASK_RLC_ENB, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_RRC_ENB_NB_IoT, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_PDCP_ENB, TASK_PRIORITY_MED, 200, NULL, NULL) \ + TASK_DEF(TASK_PDCP_GNB, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_DATA_FORWARDING, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_END_MARKER, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_RRC_ENB, TASK_PRIORITY_MED, 200, NULL,NULL)\ diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 9598bf1ad6..ad73a610e1 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -734,27 +734,30 @@ static void deliver_sdu_srb(void *_ue, nr_pdcp_entity_t *entity, __FILE__, __LINE__, __FUNCTION__, ue->rnti); exit(1); - srb_found: - { - uint8_t *rrc_buffer_p = entity->is_gnb ? - itti_malloc(TASK_PDCP_ENB, TASK_RRC_GNB, size): - itti_malloc(TASK_PDCP_UE, TASK_RRC_NRUE, size); - MessageDef *message_p; - - AssertFatal(rrc_buffer_p != NULL, "OUT OF MEMORY"); - memcpy(rrc_buffer_p, buf, size); - message_p = entity->is_gnb ? - itti_alloc_new_message(TASK_PDCP_ENB, 0, NR_RRC_DCCH_DATA_IND): - itti_alloc_new_message(TASK_PDCP_UE, 0, NR_RRC_DCCH_DATA_IND); - - AssertFatal(message_p != NULL, "OUT OF MEMORY"); - NR_RRC_DCCH_DATA_IND(message_p).dcch_index = srb_id; - NR_RRC_DCCH_DATA_IND(message_p).sdu_p = rrc_buffer_p; - NR_RRC_DCCH_DATA_IND(message_p).sdu_size = size; - NR_RRC_DCCH_DATA_IND(message_p).rnti = ue->rnti; - - itti_send_msg_to_task(entity->is_gnb ? TASK_RRC_GNB : TASK_RRC_NRUE, 0, message_p); - } +srb_found: + if (entity->is_gnb) { + MessageDef *message_p = itti_alloc_new_message(TASK_PDCP_GNB, 0, F1AP_UL_RRC_MESSAGE); + AssertFatal(message_p != NULL, "OUT OF MEMORY\n"); + f1ap_ul_rrc_message_t *ul_rrc = &F1AP_UL_RRC_MESSAGE(message_p); + ul_rrc->rnti = ue->rnti; + ul_rrc->srb_id = srb_id; + ul_rrc->rrc_container = malloc(size); + AssertFatal(ul_rrc->rrc_container != NULL, "OUT OF MEMORY\n"); + memcpy(ul_rrc->rrc_container, buf, size); + ul_rrc->rrc_container_length = size; + itti_send_msg_to_task(TASK_RRC_GNB, 0, message_p); + } else { + uint8_t *rrc_buffer_p = itti_malloc(TASK_PDCP_UE, TASK_RRC_NRUE, size); + AssertFatal(rrc_buffer_p != NULL, "OUT OF MEMORY\n"); + memcpy(rrc_buffer_p, buf, size); + MessageDef *message_p = itti_alloc_new_message(TASK_PDCP_UE, 0, NR_RRC_DCCH_DATA_IND); + AssertFatal(message_p != NULL, "OUT OF MEMORY\n"); + NR_RRC_DCCH_DATA_IND(message_p).dcch_index = srb_id; + NR_RRC_DCCH_DATA_IND(message_p).sdu_p = rrc_buffer_p; + NR_RRC_DCCH_DATA_IND(message_p).sdu_size = size; + NR_RRC_DCCH_DATA_IND(message_p).rnti = ue->rnti; + itti_send_msg_to_task(TASK_RRC_NRUE, 0, message_p); + } } static void deliver_pdu_srb(void *_ue, nr_pdcp_entity_t *entity, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 208a78d37e..8be829f51f 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -3928,28 +3928,24 @@ void *rrc_gnb_task(void *args_p) { break; /* Messages from PDCP */ - case NR_RRC_DCCH_DATA_IND: + case F1AP_UL_RRC_MESSAGE: PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, - NR_RRC_DCCH_DATA_IND(msg_p).rnti, - msg_p->ittiMsgHeader.lte_time.frame, - msg_p->ittiMsgHeader.lte_time.slot); - LOG_D(NR_RRC,"Decoding DCCH : ue %d, inst %ld, ctxt %p, size %d\n", + F1AP_UL_RRC_MESSAGE(msg_p).rnti, + 0, + 0); + LOG_D(NR_RRC,"Decoding DCCH %d: ue %04x, inst %ld, ctxt %p, size %d\n", + F1AP_UL_RRC_MESSAGE(msg_p).srb_id, ctxt.rnti, instance, &ctxt, - NR_RRC_DCCH_DATA_IND(msg_p).sdu_size); - LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Received on DCCH %d %s\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(&ctxt), - NR_RRC_DCCH_DATA_IND(msg_p).dcch_index, - msg_name_p); + F1AP_UL_RRC_MESSAGE(msg_p).rrc_container_length); rrc_gNB_decode_dcch(&ctxt, - NR_RRC_DCCH_DATA_IND(msg_p).dcch_index, - NR_RRC_DCCH_DATA_IND(msg_p).sdu_p, - NR_RRC_DCCH_DATA_IND(msg_p).sdu_size); - result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), NR_RRC_DCCH_DATA_IND(msg_p).sdu_p); - + F1AP_UL_RRC_MESSAGE(msg_p).srb_id, + F1AP_UL_RRC_MESSAGE(msg_p).rrc_container, + F1AP_UL_RRC_MESSAGE(msg_p).rrc_container_length); + free(F1AP_UL_RRC_MESSAGE(msg_p).rrc_container); break; case NGAP_DOWNLINK_NAS: From b749ac12f71c6cf546fc5168d86c155978598f52 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 8 Aug 2022 17:12:12 +0200 Subject: [PATCH 25/98] hotfix for UE NDI init --- openair1/SCHED_NR_UE/harq_nr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index 795cea5dfa..dc62ea646c 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->Ndi = 1; + dl_harq->Ndi = 2; // set to an invalid value dl_harq->ack = DL_ACKNACK_NO_SET; } From 5382227866f0a64f712fd8ebfe6f217f5235c04f Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Mon, 8 Aug 2022 17:18:04 +0200 Subject: [PATCH 26/98] Fix SDAP, get QFI & PDUSession ID from CN --- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 6 +++--- openair2/SDAP/nr_sdap/nr_sdap.c | 9 +++++++++ openair2/SDAP/nr_sdap/nr_sdap.h | 2 ++ openair3/NAS/NR_UE/nr_nas_msg_sim.c | 9 +++++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 9598bf1ad6..4ce570bc12 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -484,12 +484,12 @@ static void *ue_tun_read_thread(void *_) ctxt.rnti = rnti; bool dc = SDAP_HDR_UL_DATA_PDU; - uint8_t qfi = 7; - int pdusession_id = 10; + extern uint8_t nas_qfi; + extern uint8_t nas_pduid; sdap_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, len, (unsigned char *)rx_buf, - PDCP_TRANSMISSION_MODE_DATA, NULL, NULL, qfi, dc, pdusession_id); + PDCP_TRANSMISSION_MODE_DATA, NULL, NULL, nas_qfi, dc, nas_pduid); } return NULL; diff --git a/openair2/SDAP/nr_sdap/nr_sdap.c b/openair2/SDAP/nr_sdap/nr_sdap.c index dd7a76920d..6457843ae0 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap.c +++ b/openair2/SDAP/nr_sdap/nr_sdap.c @@ -21,6 +21,9 @@ #include "nr_sdap.h" +uint8_t nas_qfi; +uint8_t nas_pduid; + bool sdap_data_req(protocol_ctxt_t *ctxt_p, const srb_flag_t srb_flag, const rb_id_t rb_id, @@ -84,3 +87,9 @@ void sdap_data_ind(rb_id_t pdcp_entity, buf, size); } + +void set_qfi_pduid(uint8_t qfi, uint8_t pduid){ + nas_qfi = qfi; + nas_pduid = pduid; + return; +} diff --git a/openair2/SDAP/nr_sdap/nr_sdap.h b/openair2/SDAP/nr_sdap/nr_sdap.h index 5959ca1558..ea4fe7f74d 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap.h +++ b/openair2/SDAP/nr_sdap/nr_sdap.h @@ -62,4 +62,6 @@ void sdap_data_ind(rb_id_t pdcp_entity, int size ); +void set_qfi_pduid(uint8_t qfi, uint8_t pduid); + #endif diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index e151fec9b4..43c3b56aa4 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -44,6 +44,7 @@ #include #include #include +#include "openair2/SDAP/nr_sdap/nr_sdap.h" uint8_t *registration_request_buf; uint32_t registration_request_len; @@ -915,7 +916,7 @@ void *nas_nrue_task(void *args_p) payload_container = pdu_buffer + offset; } offset = 0; - + uint8_t pdu_id = *(pdu_buffer+14); while(offset < payload_container_length) { // Fixme: this is not good 'type' 0x29 searching in TLV like structure // AND fix dirsty code copy hereafter of the same!!! @@ -929,9 +930,13 @@ void *nas_nrue_task(void *args_p) *(payload_container+offset+3), *(payload_container+offset+4), *(payload_container+offset+5), *(payload_container+offset+6)); nas_config(1,third_octet,fourth_octet,"oaitun_ue"); - break; } } + if (*(payload_container + offset) == 0x79) { + uint8_t qfi = *(payload_container+offset+3); + set_qfi_pduid(qfi, pdu_id); + break; + } offset++; } } From 5cfa5ad6f6c81659182a849342f85366ae07dcf2 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 8 Aug 2022 18:32:39 +0200 Subject: [PATCH 27/98] fixes for multiple BWPs --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 11 +++++++++-- openair2/RRC/NR/MESSAGES/asn1_msg.c | 6 +++--- openair2/RRC/NR/nr_rrc_config.c | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 68900cda35..c852c83e71 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -181,6 +181,11 @@ void nr_csi_meas_reporting(int Mod_idP, AssertFatal(csirep->reportConfigType.choice.periodic, "Only periodic CSI reporting is implemented currently\n"); + + const NR_PUCCH_CSI_Resource_t *pucchcsires = csirep->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list.array[0]; + if(pucchcsires->uplinkBandwidthPartId != ul_bwp->bwp_id) + continue; + int period, offset; csi_period_offset(csirep, NULL, &period, &offset); const int sched_slot = (period + offset) % n_slots_frame; @@ -188,9 +193,8 @@ void nr_csi_meas_reporting(int Mod_idP, // preparation is done in first slot of tdd period if (frame % (period / n_slots_frame) != offset / n_slots_frame) continue; - LOG_D(NR_MAC, "CSI reporting in frame %d slot %d\n", frame, sched_slot); + LOG_D(NR_MAC, "CSI reporting in frame %d slot %d CSI report ID %ld\n", frame, sched_slot, csirep->reportConfigId); - const NR_PUCCH_CSI_Resource_t *pucchcsires = csirep->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list.array[0]; const NR_PUCCH_ResourceSet_t *pucchresset = pucch_Config->resourceSetToAddModList->list.array[1]; // set with formats >1 const int n = pucchresset->resourceList.list.count; int res_index = 0; @@ -769,6 +773,9 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, uint8_t li_bitlen = 0; uint8_t pmi_bitlen = 0; NR_CSI_ReportConfig_t *csirep = csi_MeasConfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; + const NR_PUCCH_CSI_Resource_t *pucchcsires = csirep->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list.array[0]; + if(pucchcsires->uplinkBandwidthPartId != ul_bwp->bwp_id) + continue; int period, offset; csi_period_offset(csirep, NULL, &period, &offset); // verify if report with current id has been scheduled for this frame and slot diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 83f85e8f24..4608ce8db8 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -452,7 +452,7 @@ uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss1->monitoringSymbolsWithinSlot->buf = calloc(1,2); // should be '1000 0000 0000 00'B (LSB first!), first symbol in slot, adjust if needed ss1->monitoringSymbolsWithinSlot->buf[1] = 0; - ss1->monitoringSymbolsWithinSlot->buf[0] = (1<<7); + ss1->monitoringSymbolsWithinSlot->buf[0] = 0x80; ss1->monitoringSymbolsWithinSlot->size = 2; ss1->monitoringSymbolsWithinSlot->bits_unused = 2; ss1->nrofCandidates = calloc(1,sizeof(*ss1->nrofCandidates)); @@ -480,7 +480,7 @@ uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss5->monitoringSymbolsWithinSlot->buf = calloc(1,2); // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed ss5->monitoringSymbolsWithinSlot->buf[1] = 0; - ss5->monitoringSymbolsWithinSlot->buf[0] = (1<<7); + ss5->monitoringSymbolsWithinSlot->buf[0] = 0x80; ss5->monitoringSymbolsWithinSlot->size = 2; ss5->monitoringSymbolsWithinSlot->bits_unused = 2; ss5->nrofCandidates = calloc(1,sizeof(*ss5->nrofCandidates)); @@ -505,7 +505,7 @@ uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss7->monitoringSymbolsWithinSlot->buf = calloc(1,2); // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed ss7->monitoringSymbolsWithinSlot->buf[1] = 0; - ss7->monitoringSymbolsWithinSlot->buf[0] = (1<<7); + ss7->monitoringSymbolsWithinSlot->buf[0] = 0x80; ss7->monitoringSymbolsWithinSlot->size = 2; ss7->monitoringSymbolsWithinSlot->bits_unused = 2; ss7->nrofCandidates = calloc(1,sizeof(*ss7->nrofCandidates)); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 2c521dc949..f0763e115a 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -875,7 +875,7 @@ void config_downlinkBWP(NR_BWP_Downlink_t *bwp, ss->monitoringSymbolsWithinSlot->buf = calloc(1,2); // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed ss->monitoringSymbolsWithinSlot->buf[1] = 0; - ss->monitoringSymbolsWithinSlot->buf[0] = 0xc0; + ss->monitoringSymbolsWithinSlot->buf[0] = 0x80; ss->monitoringSymbolsWithinSlot->size = 2; ss->monitoringSymbolsWithinSlot->bits_unused = 2; ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates)); @@ -933,7 +933,7 @@ void config_downlinkBWP(NR_BWP_Downlink_t *bwp, ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot)); ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2); ss2->monitoringSymbolsWithinSlot->size = 2; - ss2->monitoringSymbolsWithinSlot->buf[0]=0xc0; + ss2->monitoringSymbolsWithinSlot->buf[0]=0x80; ss2->monitoringSymbolsWithinSlot->buf[1]=0x0; ss2->monitoringSymbolsWithinSlot->bits_unused = 2; ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates)); From dc531588e93eb5f74612e55117292300de042be1 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 9 Aug 2022 12:01:54 +0200 Subject: [PATCH 28/98] addressing review comments --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 32 +++++++------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 9 ---- openair2/RRC/NR/nr_rrc_config.h | 8 ++++ openair2/RRC/NR/rrc_gNB_reconfig.c | 68 ++++++++++++++--------------- 4 files changed, 55 insertions(+), 62 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 4608ce8db8..e277e61395 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1252,12 +1252,11 @@ void fill_initial_SpCellConfig(int uid, NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); ssbresset0->csi_SSB_ResourceSetId=0; - 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]); + if ((bitmap >> (63 - i)) & 0x01) { + NR_SSB_Index_t *ssbres = NULL; + asn1cCallocOne(ssbres, i); + ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list, ssbres); } } ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); @@ -1359,18 +1358,17 @@ void fill_initial_SpCellConfig(int uid, 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; + struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel *singlePanelConfig = csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel; + singlePanelConfig->nrOfAntennaPorts.present = NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; + singlePanelConfig->nrOfAntennaPorts.choice.two = calloc(1,sizeof(*singlePanelConfig->nrOfAntennaPorts.choice.two)); + singlePanelConfig->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; + singlePanelConfig->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; + singlePanelConfig->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); + singlePanelConfig->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; + singlePanelConfig->typeI_SinglePanel_ri_Restriction.size=1; + singlePanelConfig->typeI_SinglePanel_ri_Restriction.bits_unused=0; + singlePanelConfig->typeI_SinglePanel_ri_Restriction.buf=malloc(1); + singlePanelConfig->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; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index ea4b185f6b..a8638ec16a 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -56,15 +56,6 @@ */ int xer_sprint_NR(char *string, size_t string_size, struct asn_TYPE_descriptor_s *td, void *sptr); - -#define asn1cCallocOne(VaR, VaLue) \ - VaR = calloc(1,sizeof(*VaR)); *VaR=VaLue; -#define asn1cCalloc(VaR, lOcPtr) \ - typeof(VaR) lOcPtr = VaR = calloc(1,sizeof(*VaR)); -#define asn1cSequenceAdd(VaR, TyPe, lOcPtr) \ - TyPe *lOcPtr= calloc(1,sizeof(TyPe)); \ - ASN_SEQUENCE_ADD(&VaR,lOcPtr); - uint8_t do_MIB_NR(gNB_RRC_INST *rrc, uint32_t frame); diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index c47535a3c8..ff576b07d3 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -33,6 +33,14 @@ #include "nr_rrc_defs.h" +#define asn1cCallocOne(VaR, VaLue) \ + VaR = calloc(1,sizeof(*VaR)); *VaR=VaLue; +#define asn1cCalloc(VaR, lOcPtr) \ + typeof(VaR) lOcPtr = VaR = calloc(1,sizeof(*VaR)); +#define asn1cSequenceAdd(VaR, TyPe, lOcPtr) \ + TyPe *lOcPtr= calloc(1,sizeof(TyPe)); \ + ASN_SEQUENCE_ADD(&VaR,lOcPtr); + typedef struct rlc_bearer_config_s{ long LogicalChannelIdentity[MAX_NUM_CCs]; long servedRadioBearer_present[MAX_NUM_CCs]; diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 69beb45ce8..543096f660 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -597,14 +597,13 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); ssbresset0->csi_SSB_ResourceSetId = 0; - 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]); - } - } + for (int i=0;i<64;i++) { + if ((bitmap >> (63 - i)) & 0x01) { + NR_SSB_Index_t *ssbres = NULL; + asn1cCallocOne(ssbres, i); + ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list, ssbres); + } + } ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) { @@ -689,46 +688,43 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco 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)); + struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel *singlePanelConfig = csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel; if (dl_antenna_ports == 2) { - 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; + singlePanelConfig->nrOfAntennaPorts.present = NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; + singlePanelConfig->nrOfAntennaPorts.choice.two = calloc(1,sizeof(*singlePanelConfig->nrOfAntennaPorts.choice.two)); + singlePanelConfig->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; + singlePanelConfig->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; + singlePanelConfig->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); + singlePanelConfig->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; + singlePanelConfig->typeI_SinglePanel_ri_Restriction.size=1; + singlePanelConfig->typeI_SinglePanel_ri_Restriction.bits_unused=0; + singlePanelConfig->typeI_SinglePanel_ri_Restriction.buf=malloc(1); + singlePanelConfig->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; } else if (dl_antenna_ports < 16) { - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo= - calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo)); + singlePanelConfig->nrOfAntennaPorts.present = NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo; + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo = calloc(1,sizeof(*singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo)); if(dl_antenna_ports == 4) - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction; else if(dl_antenna_ports == 8) - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction; else if(dl_antenna_ports == 12) - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction; else//default - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction; - /*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.bits_unused=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.buf[0]=0xc0; //'00000011'B - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->size = 1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->bits_unused=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf[0]=0xc0;*/ + /*singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.size=1; + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.bits_unused=1; + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.buf=malloc(1); + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.buf[0]=0xc0; //'00000011'B + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->size = 1; + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->bits_unused=1; + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf=malloc(1); + singlePanelConfig->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf[0]=0xc0;*/ csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; } else {//32 antennas are Not implemented yet csirep1->codebookConfig->codebookType.choice.type1->codebookMode=2; From ee7aca5d05ca2711690e8f31eb36764c3d2dd70e Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 9 Aug 2022 12:20:05 +0200 Subject: [PATCH 29/98] ngap: minor fix: access the array correctly --- openair3/NGAP/ngap_gNB.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair3/NGAP/ngap_gNB.c b/openair3/NGAP/ngap_gNB.c index 9d6bd7f07f..59e275ad53 100644 --- a/openair3/NGAP/ngap_gNB.c +++ b/openair3/NGAP/ngap_gNB.c @@ -494,7 +494,7 @@ static int ngap_gNB_generate_ng_setup_request( ssi = (NGAP_SliceSupportItem_t *)calloc(1, sizeof(NGAP_SliceSupportItem_t)); INT8_TO_OCTET_STRING(instance_p->s_nssai[i][si].sST, &ssi->s_NSSAI.sST); - if(instance_p->s_nssai[i]->sD_flag) { + if (instance_p->s_nssai[i][si].sD_flag) { ssi->s_NSSAI.sD = calloc(1, sizeof(NGAP_SD_t)); ssi->s_NSSAI.sD->buf = calloc(3, sizeof(uint8_t)); ssi->s_NSSAI.sD->size = 3; From c21f86421eab475cf111f9036838ba358ab8e25c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 9 Aug 2022 15:05:37 +0200 Subject: [PATCH 30/98] Test SDAP in 5G FDD RFsim test --- ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf | 1 + ci-scripts/xml_files/container_5g_fdd_rfsim.xml | 2 +- ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf index 197e1d211c..6b7122341d 100644 --- a/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf @@ -33,6 +33,7 @@ gNBs = ////////// Physical parameters: min_rxtxtime = 6; + enable_sdap = 1; pdcch_ConfigSIB1 = ( { diff --git a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml index b41dafb767..09f3d62e26 100644 --- a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml @@ -22,7 +22,7 @@ --> rfsim-5gnr-fdd - Testing 5G NR RF sim - Monolithic FDD gNB + Testing 5G NR RF sim - Monolithic FDD gNB with SDAP wrench 4 diff --git a/ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml b/ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml index d960949f7d..408348e446 100644 --- a/ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml +++ b/ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml @@ -22,7 +22,7 @@ --> rfsim-5gnr-fdd-down - CleanUp 5G RF - Monolithic FDD gNB + CleanUp 5G RF - Monolithic FDD gNB with SDAP trash 100012 From f1c5378e3b6a38c7a23bf7c41cf16537b529ccb3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 2 Aug 2022 12:44:44 +0200 Subject: [PATCH 31/98] Shorten 5G RFsim tab names --- ci-scripts/xml_files/container_5g_f1_rfsim.xml | 2 +- ci-scripts/xml_files/container_5g_f1_rfsim_down.xml | 2 +- ci-scripts/xml_files/container_5g_fdd_rfsim.xml | 2 +- ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml | 2 +- ci-scripts/xml_files/container_5g_rfsim.xml | 2 +- ci-scripts/xml_files/container_5g_rfsim_down.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ci-scripts/xml_files/container_5g_f1_rfsim.xml b/ci-scripts/xml_files/container_5g_f1_rfsim.xml index 05b20afed3..61157f72df 100644 --- a/ci-scripts/xml_files/container_5g_f1_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_f1_rfsim.xml @@ -22,7 +22,7 @@ --> rfsim-5gnr-f1 - Testing 5G NR RF sim in containers - CU-DU F1 split + CU-DU F1 split wrench 100021 diff --git a/ci-scripts/xml_files/container_5g_f1_rfsim_down.xml b/ci-scripts/xml_files/container_5g_f1_rfsim_down.xml index ac3f7347ba..bb640381cf 100644 --- a/ci-scripts/xml_files/container_5g_f1_rfsim_down.xml +++ b/ci-scripts/xml_files/container_5g_f1_rfsim_down.xml @@ -22,7 +22,7 @@ --> rfsim-5gnr-down-f1 - CleanUp 5G RF - CU-DU F1 split + CleanUp CU-DU F1 split trash 100022 diff --git a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml index 09f3d62e26..9564b24b35 100644 --- a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml @@ -22,7 +22,7 @@ --> rfsim-5gnr-fdd - Testing 5G NR RF sim - Monolithic FDD gNB with SDAP + Monolithic FDD gNB with SDAP wrench 4 diff --git a/ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml b/ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml index 408348e446..12648ca750 100644 --- a/ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml +++ b/ci-scripts/xml_files/container_5g_fdd_rfsim_down.xml @@ -22,7 +22,7 @@ --> rfsim-5gnr-fdd-down - CleanUp 5G RF - Monolithic FDD gNB with SDAP + CleanUp Monolithic FDD gNB with SDAP trash 100012 diff --git a/ci-scripts/xml_files/container_5g_rfsim.xml b/ci-scripts/xml_files/container_5g_rfsim.xml index a1f50948a5..653e1e6513 100644 --- a/ci-scripts/xml_files/container_5g_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_rfsim.xml @@ -22,7 +22,7 @@ --> rfsim-5gnr-tdd - Testing 5G NR RF sim - Monolithic TDD gNB + Monolithic TDD gNB wrench 4 diff --git a/ci-scripts/xml_files/container_5g_rfsim_down.xml b/ci-scripts/xml_files/container_5g_rfsim_down.xml index b369b1fad8..028ff61864 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_down.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_down.xml @@ -22,7 +22,7 @@ --> rfsim-5gnr-down - CleanUp 5G RF - Monolithic TDD gNB + CleanUp Monolithic TDD gNB trash 100002 From 0cb014f463f323bd810558f55f9963e80be325ed Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Tue, 9 Aug 2022 17:11:12 +0100 Subject: [PATCH 32/98] Fix memory alignment in nr_srs_channel_estimation --- .../NR_ESTIMATION/nr_ul_channel_estimation.c | 31 ++++++++++++++----- openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c | 6 ++++ openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h | 2 ++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index e5c1ca37d8..3936135e49 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -990,12 +990,18 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, int16_t ls_estimated[2]; + uint8_t mem_offset = 0; + while(((long)&srs_estimated_channel_freq[0][nr_srs_info->sc_list[0] + mem_offset] & 0xF) != 0) { + mem_offset++; + } + int32_t srs_est[frame_parms->ofdm_symbol_size*(1<num_symbols) + mem_offset] __attribute__ ((aligned(32))); + for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { memset(srs_ls_estimated_channel[ant], 0, frame_parms->ofdm_symbol_size*(1<num_symbols)*sizeof(int32_t)); - memset(srs_estimated_channel_freq[ant], 0, frame_parms->ofdm_symbol_size*(1<num_symbols)*sizeof(int32_t)); + memset(srs_est, 0, (frame_parms->ofdm_symbol_size*(1<num_symbols) + mem_offset)*sizeof(int32_t)); - int16_t *srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[0]]; + int16_t *srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[0] + mem_offset]; for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) { @@ -1018,26 +1024,28 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, multadd_real_vector_complex_scalar(filt8_start, ls_estimated, srs_estimated_channel16, 8); } else if(nr_srs_info->sc_list[sc_idx] < nr_srs_info->sc_list[sc_idx - 1]) { // Start of OFDM symbol case // filt8_start is {12288,8192,4096,0,0,0,0,0} - srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx + 2]] - sizeof(uint64_t); - multadd_real_vector_complex_scalar(filt8_start, ls_estimated, srs_estimated_channel16, 8); + srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[sc_idx]]; + short *filter = mem_offset==0 ? filt8_start:filt8_start_shift2; + multadd_real_vector_complex_scalar(filter, ls_estimated, srs_estimated_channel16, 8); } else if((sc_idx < (nr_srs_info->sc_list_length - 1) && nr_srs_info->sc_list[sc_idx + 1] < nr_srs_info->sc_list[sc_idx]) || (sc_idx == (nr_srs_info->sc_list_length - 1))) { // End of OFDM symbol or last subcarrier cases // filt8_end is {4096,8192,12288,16384,0,0,0,0} - multadd_real_vector_complex_scalar(filt8_end, ls_estimated, srs_estimated_channel16, 8); + short *filter = mem_offset==0 || sc_idx == (nr_srs_info->sc_list_length - 1) ? filt8_end:filt8_end_shift2; + multadd_real_vector_complex_scalar(filter, ls_estimated, srs_estimated_channel16, 8); } else if(sc_idx%2 == 1) { // 1st middle case // filt8_middle2 is {4096,8192,8192,8192,4096,0,0,0} multadd_real_vector_complex_scalar(filt8_middle2, ls_estimated, srs_estimated_channel16, 8); } else if(sc_idx%2 == 0) { // 2nd middle case // filt8_middle4 is {0,0,4096,8192,8192,8192,4096,0} multadd_real_vector_complex_scalar(filt8_middle4, ls_estimated, srs_estimated_channel16, 8); - srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]]; + srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[sc_idx] + mem_offset]; } } else { if(sc_idx == 0) { // First subcarrier case // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); } else if(nr_srs_info->sc_list[sc_idx] < nr_srs_info->sc_list[sc_idx - 1]) { // Start of OFDM symbol case - srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx + 1]] - sizeof(uint64_t); + srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[sc_idx] + mem_offset]; // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); } else if((sc_idx < (nr_srs_info->sc_list_length - 1) && nr_srs_info->sc_list[sc_idx + 1] < nr_srs_info->sc_list[sc_idx]) @@ -1047,7 +1055,7 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, } else { // Middle case // filt16_middle4 is {4096,8192,8192,8192,8192,8192,8192,8192,4096,0,0,0,0,0,0,0} multadd_real_vector_complex_scalar(filt16_middle4, ls_estimated, srs_estimated_channel16, 16); - srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]]; + srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[sc_idx] + mem_offset]; } } @@ -1072,6 +1080,10 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, #endif } + memcpy(&srs_estimated_channel_freq[ant][0], + &srs_est[mem_offset], + (frame_parms->ofdm_symbol_size*(1<num_symbols))*sizeof(int32_t)); + // Compute noise for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) { ch_real[ant*nr_srs_info->sc_list_length + sc_idx] = ((c16_t*)srs_estimated_channel_freq[ant])[nr_srs_info->sc_list[sc_idx]].r; @@ -1177,6 +1189,9 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, LOG_I(NR_PHY,"\t __lsRe__________lsIm__|____intRe_______intIm__|____noiRe_______noiIm_\n"); } for(int r = 0; rsc_list[sc_idx]+r>=frame_parms->ofdm_symbol_size) { + continue; + } LOG_I(NR_PHY,"(%4i) %6i\t%6i | %6i\t%6i | %6i\t%6i\n", subcarrier_log+r, (int16_t)(srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]+r]&0xFFFF), diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c index 6c9173c48f..809cc4dd3b 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c @@ -265,6 +265,9 @@ short filt8_avlip6[8] = { short filt8_start[8] = { 12288,8192,4096,0,0,0,0,0}; +short filt8_start_shift2[8] = { + 0, 0, 12288,8192,4096,0,0,0}; + short filt8_middle2[8] = { 4096,8192,8192,8192,4096,0,0,0}; @@ -274,6 +277,9 @@ short filt8_middle4[8] = { short filt8_end[8] = { 4096,8192,12288,16384,0,0,0,0}; +short filt8_end_shift2[8] = { + 0, 0, 4096,8192,12288,16384,0,0}; + // Comb size 4 short filt16_start[16] = { 12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0}; diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h index 41109cb7bb..4e987e5ae4 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h @@ -185,9 +185,11 @@ extern short filt8_avlip6[8]; /*Comb size 2*/ extern short filt8_start[8]; +extern short filt8_start_shift2[8]; extern short filt8_middle2[8]; extern short filt8_middle4[8]; extern short filt8_end[8]; +extern short filt8_end_shift2[8]; /*Comb size 4*/ extern short filt16_start[16]; From 5d39d8125c4f09e21befcb2eae0727d6b0426c50 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 10 Aug 2022 09:38:21 +0200 Subject: [PATCH 33/98] addressing review comment --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 98a225ac85..725cdb5173 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1342,6 +1342,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if (cfg->ssb_table.ssb_period == 0 || !(frame_rx%(1<<(cfg->ssb_table.ssb_period-1)))){ + const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size; // loop over SSB blocks for(int ssb_index=0; ssb_indexLmax; ssb_index++) { uint32_t curr_mask = cfg->ssb_table.ssb_mask_list[ssb_index/32].ssb_mask; @@ -1357,7 +1358,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); - const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size]; From 888c4ead0fe7a87f39bdc50571731b906d138e31 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Thu, 4 Aug 2022 15:58:40 +0200 Subject: [PATCH 34/98] fix(ci): Fixes for the legacy LTE bench - Problem with escaping chars - Killing properly tshark process on EPC - standalone Terminate eNB was failing Signed-off-by: Raphael Defosseux --- ci-scripts/cls_oaicitest.py | 25 ++++++++++++++----------- ci-scripts/ran.py | 14 ++++++-------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index 9d5ae84038..32d9c48966 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -1329,7 +1329,7 @@ class OaiCiTest(): SSH.open(self.ADBIPAddress, self.ADBUserName, self.ADBPassword) if self.ADBCentralized: SSH.command('adb devices', '\$', 15) - self.UEDevices = re.findall("\\\\r\\\\n([A-Za-z0-9]+)\\\\tdevice",SSH.getBefore()) + self.UEDevices = re.findall('\r\n([A-Za-z0-9]+)\tdevice',SSH.getBefore()) #report number and id of devices found msg = "UEDevices found by GetAllUEDevices : " + " ".join(self.UEDevices) logging.debug(msg) @@ -1379,8 +1379,7 @@ class OaiCiTest(): SSH.open(self.ADBIPAddress, self.ADBUserName, self.ADBPassword) if self.ADBCentralized: SSH.command('lsusb | egrep --colour=never "Future Technology Devices International, Ltd FT2232C" | sed -e "s#:.*##" -e "s# #_#g"', '\$', 15) - #self.CatMDevices = re.findall("\\\\r\\\\n([A-Za-z0-9_]+)",SSH.getBefore()) - self.CatMDevices = re.findall("\\\\r\\\\n([A-Za-z0-9_]+)",SSH.getBefore()) + self.CatMDevices = re.findall('\r\n([A-Za-z0-9_]+)',SSH.getBefore()) else: if (os.path.isfile('./modules_list.txt')): os.remove('./modules_list.txt') @@ -2046,7 +2045,7 @@ class OaiCiTest(): req_bandwidth = '%.1f Gbits/sec' % req_bw req_bw = req_bw * 1000000000 - result = re.search('Server Report:\\\\r\\\\n(?:|\[ *\d+\].*) (?P[0-9\.]+ [KMG]bits\/sec) +(?P[0-9\.]+ ms) +(\d+\/..\d+) +(\((?P[0-9\.]+)%\))', SSH.getBefore()) + result = re.search('Server Report:\r\n(?:|\[ *\d+\].*) (?P[0-9\.]+ [KMG]bits\/sec) +(?P[0-9\.]+ ms) +(\d+\/..\d+) +(\((?P[0-9\.]+)%\))', SSH.getBefore()) if result is not None: bitrate = result.group('bitrate') packetloss = result.group('packetloss') @@ -2262,7 +2261,7 @@ class OaiCiTest(): def Iperf_analyzeV3Output(self, lock, UE_IPAddress, device_id, statusQueue,SSH): - result = re.search('(?P[0-9\.]+ [KMG]bits\/sec) +(?:|[0-9\.]+ ms +\d+\/\d+ \((?P[0-9\.]+)%\)) +(?:|receiver)\\\\r\\\\n(?:|\[ *\d+\] Sent \d+ datagrams)\\\\r\\\\niperf Done\.', SSH.getBefore()) + result = re.search('(?P[0-9\.]+ [KMG]bits\/sec) +(?:|[0-9\.]+ ms +\d+\/\d+ \((?P[0-9\.]+)%\)) +(?:|receiver)\r\n(?:|\[ *\d+\] Sent \d+ datagrams)\r\niperf Done\.', SSH.getBefore()) if result is None: result = re.search('(?Piperf: error - [a-zA-Z0-9 :]+)', SSH.getBefore()) lock.acquire() @@ -3865,7 +3864,7 @@ class OaiCiTest(): SSH = sshconnection.SSHConnection() SSH.open(IPAddress, UserName, Password) SSH.command('lsb_release -a', '\$', 5) - result = re.search('Description:\\\\t(?P[a-zA-Z0-9\-\_\.\ ]+)', SSH.getBefore()) + result = re.search('Description:\t(?P[a-zA-Z0-9\-\_\.\ ]+)', SSH.getBefore()) if result is not None: OsVersion = result.group('os_type') logging.debug('OS is: ' + OsVersion) @@ -3883,13 +3882,13 @@ class OaiCiTest(): logging.debug('OS is: ' + OsVersion) HTML.OsVersion[idx]=OsVersion SSH.command('uname -r', '\$', 5) - result = re.search('uname -r\\\\r\\\\n(?P[a-zA-Z0-9\-\_\.]+)', SSH.getBefore()) + result = re.search('uname -r\r\n(?P[a-zA-Z0-9\-\_\.]+)', SSH.getBefore()) if result is not None: KernelVersion = result.group('kernel_version') logging.debug('Kernel Version is: ' + KernelVersion) HTML.KernelVersion[idx]=KernelVersion - SSH.command('dpkg --list | egrep --color=never libuhd003', '\$', 5) - result = re.search('libuhd003:amd64 *(?P[0-9\.]+)', SSH.getBefore()) + SSH.command('dpkg --list | egrep --color=never libuhd', '\$', 5) + result = re.search('libuhd.*:amd64 *(?P[0-9\.]+)', SSH.getBefore()) if result is not None: UhdVersion = result.group('uhd_version') logging.debug('UHD Version is: ' + UhdVersion) @@ -3902,7 +3901,7 @@ class OaiCiTest(): logging.debug('UHD Version is: ' + UhdVersion) HTML.UhdVersion[idx]=UhdVersion SSH.command('echo ' + Password + ' | sudo -S uhd_find_devices', '\$', 180) - usrp_boards = re.findall('product: ([0-9A-Za-z]+)\\\\r\\\\n', SSH.getBefore()) + usrp_boards = re.findall('product: ([0-9A-Za-z]+)', SSH.getBefore()) count = 0 for board in usrp_boards: if count == 0: @@ -3914,14 +3913,18 @@ class OaiCiTest(): logging.debug('USRP Board(s) : ' + UsrpBoard) HTML.UsrpBoard[idx]=UsrpBoard SSH.command('lscpu', '\$', 5) - result = re.search('CPU\(s\): *(?P[0-9]+).*Model name: *(?P[a-zA-Z0-9\-\_\.\ \(\)]+).*CPU MHz: *(?P[0-9\.]+)', SSH.getBefore()) + result = re.search('CPU\(s\): *(?P[0-9]+)', SSH.getBefore()) if result is not None: CpuNb = result.group('nb_cpus') logging.debug('nb_cpus: ' + CpuNb) HTML.CpuNb[idx]=CpuNb + result = re.search('Model name: *(?P[a-zA-Z0-9\-\_\.\ \(\)]+)', SSH.getBefore()) + if result is not None: CpuModel = result.group('model') logging.debug('model: ' + CpuModel) HTML.CpuModel[idx]=CpuModel + result = re.search('CPU MHz: *(?P[0-9\.]+)', SSH.getBefore()) + if result is not None: CpuMHz = result.group('cpu_mhz') + ' MHz' logging.debug('cpu_mhz: ' + CpuMHz) HTML.CpuMHz[idx]=CpuMHz diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index 680763d247..a576054370 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -374,7 +374,7 @@ class RANManagement(): mySSH.open(lIpAddr, lUserName, lPassWord) eth_interface = 'any' fltr = 'sctp' - logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') + logging.debug('\u001B[1m Launching tshark on xNB on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') pcapfile = pcapfile_prefix + self.testCase_id + '_log.pcap' mySSH.command('echo ' + lPassWord + ' | sudo -S rm -f /tmp/' + pcapfile , '\$', 5) mySSH.command('echo $USER; nohup sudo -E tshark -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + pcapfile + ' > /dev/null 2>&1 &','\$', 5) @@ -390,7 +390,7 @@ class RANManagement(): mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword) eth_interface = 'any' fltr = 'sctp' - logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') + logging.debug('\u001B[1m Launching tshark on EPC on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') self.epcPcapFile = 'enb_' + self.testCase_id + '_s1log.pcap' mySSH.command('echo ' + localEpcPassword + ' | sudo -S rm -f /tmp/' + self.epcPcapFile , '\$', 5) mySSH.command('echo $USER; nohup sudo tshark -f "host ' + lIpAddr +'" -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + self.epcPcapFile + ' > /tmp/tshark.log 2>&1 &', localEpcUserName, 5) @@ -517,7 +517,7 @@ class RANManagement(): localEpcUserName = EPC.UserName localEpcPassword = EPC.Password mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword) - logging.debug('\u001B[1m Stopping tshark \u001B[0m') + logging.debug('\u001B[1m Stopping tshark on EPC \u001B[0m') mySSH.command('echo ' + localEpcPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5) if self.epcPcapFile != '': mySSH.command('echo ' + localEpcPassword + ' | sudo -S chmod 666 /tmp/' + self.epcPcapFile, '\$', 5) @@ -644,18 +644,16 @@ class RANManagement(): time.sleep(5) mySSH.command('rm -f my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) #stopping tshark (valid if eNB and enabled in xml, will not harm otherwise) - logging.debug('\u001B[1m Stopping tshark \u001B[0m') + logging.debug('\u001B[1m Stopping tshark on xNB \u001B[0m') mySSH.command('echo ' + lPassWord + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5) time.sleep(1) mySSH.close() - # If tracer options is on, stopping tshark on EPC side - result = re.search('T_stdout', str(self.Initialize_eNB_args)) - if (result is not None): + if EPC.IPAddress != "none" and EPC.IPAddress != '': localEpcIpAddr = EPC.IPAddress localEpcUserName = EPC.UserName localEpcPassword = EPC.Password + logging.debug('\u001B[1m Stopping tshark on EPC (' + localEpcIpAddr + ') \u001B[0m') mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword) - logging.debug('\u001B[1m Stopping tshark \u001B[0m') mySSH.command('echo ' + localEpcPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5) time.sleep(1) if self.epcPcapFile != '': From c0244ee68ee98d2730c35d514c9a9ca13c9facc8 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 10 Aug 2022 16:51:03 +0200 Subject: [PATCH 35/98] fix for conflicting csi resources for multiple ues --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 4 ++-- openair2/RRC/NR/rrc_gNB_reconfig.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index e277e61395..ded7d97d62 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1396,7 +1396,7 @@ void fill_initial_SpCellConfig(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 = (27 + (20 * uid)) % 320; + csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (37 + (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; @@ -1428,7 +1428,7 @@ void fill_initial_SpCellConfig(int uid, csirep3->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; csirep3->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep3->reportConfigType.choice.periodic)); csirep3->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep3->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320; + csirep3->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 37 + (20 * uid) % 320; ASN_SEQUENCE_ADD(&csirep3->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); csirep3->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP; csirep3->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0; diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 543096f660..acaa67282d 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -755,7 +755,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco 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 = 39 + (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; @@ -787,7 +787,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco 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 = 39 + (20 * uid) % 320; ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP; csirep2->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0; From 17aef213a1f5d016d1c8e58be5af101ecbd271e4 Mon Sep 17 00:00:00 2001 From: Angelo Athanassopoulos Date: Wed, 10 Aug 2022 17:08:28 +0200 Subject: [PATCH 36/98] Fix: noS1 with SDAP --- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 4ce570bc12..f0d3db314b 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -591,8 +591,10 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1; netlink_init_tun(ifsuffix_ue, num_if, id); //Add --nr-ip-over-lte option check for next line - if (IS_SOFTMODEM_NOS1) - nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifsuffix_ue); + if (IS_SOFTMODEM_NOS1){ + nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifsuffix_ue); + set_qfi_pduid(7, 10); + } LOG_I(PDCP, "UE pdcp will use tun interface\n"); start_pdcp_tun_ue(); } else if(ENB_NAS_USE_TUN) { From eba7dc5c76236024c6ea1e2a4444e20505b6f460 Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 4 Aug 2022 13:26:59 +0200 Subject: [PATCH 37/98] Print asn1c encoding logs using OAI logging system --- cmake_targets/CMakeLists.txt | 12 ++++--- common/utils/config.h | 56 ++++++++++++++++++++++++++++++++ openair2/F1AP/f1ap_common.c | 21 ------------ openair2/F1AP/f1ap_common.h | 9 ----- openair2/M2AP/m2ap_common.c | 21 ------------ openair2/M2AP/m2ap_common.h | 9 ++--- openair2/X2AP/x2ap_common.c | 21 ------------ openair2/X2AP/x2ap_common.h | 9 ++--- openair3/COMMON/security_types.h | 8 ++--- openair3/M3AP/m3ap_common.c | 21 ------------ openair3/M3AP/m3ap_common.h | 8 ++--- openair3/NGAP/ngap_common.h | 12 ------- openair3/S1AP/s1ap_common.h | 15 --------- openair3/TEST/test_kdf.c | 4 --- 14 files changed, 71 insertions(+), 155 deletions(-) create mode 100644 common/utils/config.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 157ac1f6b3..f85e994db0 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -334,13 +334,9 @@ add_definitions("-DPACKAGE_BUGREPORT=\"openair4g-devel@lists.eurecom.fr\"") # Debug related options ######################################### -add_boolean_option(ASN_EMIT_DEBUG False "ASN1 coder/decoder Debug") -add_boolean_option(ASN_THREAD_SAFE True "ASN1 coder/decoder Debug") -add_boolean_option(MSG_PRINT True "print debug messages") +add_boolean_option(DEBUG_ASN1C False "ASN1 coder/decoder Debug traces, see common/utils/config.h, the logs are regular OAI logs, in the log group 'ASN'") add_boolean_option(DISABLE_XER_PRINT False "print XER Format") add_boolean_option(XER_PRINT False "print XER Format") -add_boolean_option(RRC_MSG_PRINT False "print RRC messages") -add_boolean_option(PDCP_MSG_PRINT False "print PDCP messages to /tmp/pdcp.log") add_boolean_option(DEBUG_PDCP_PAYLOAD False "print PDCP PDU to stdout") # if true, make sure that global and PDCP log levels are trace add_boolean_option(DEBUG_MAC_INTERFACE False "print MAC-RLC PDU exchange to stdout") # if true, make sure that global and PDCP log levels are trace add_boolean_option(TRACE_RLC_PAYLOAD False "print RLC PDU to stdout") # if true, make sure that global and PDCP log levels are trace @@ -358,6 +354,12 @@ add_library(ITTI ) add_dependencies(ITTI rrc_flag) +# asn1c skeletons have hardcoded this flag to make customized debug logs +# OAI uses this feature to re-use OAI LOG_I(ASN, ...) +if (DEBUG_ASN1C) + add_definitions(-DHAVE_CONFIG_H) +endif() + ################################################## # ASN.1 grammar C code generation & dependencies # ################################################## diff --git a/common/utils/config.h b/common/utils/config.h new file mode 100644 index 0000000000..597ead7ed6 --- /dev/null +++ b/common/utils/config.h @@ -0,0 +1,56 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef UTILS_CONFIG_H_ASN1 +#define UTILS_CONFIG_H_ASN1 + +// This is hard coded file name "config.h" and HAVE_CONFIG_H_ in asn1c skeletons + +/* + * This file "config.h" will be used by asn1c if HAVE_CONFIG_H_ is defined and + * included. This logs asn1c encoder and decoder traces at execution time using + * the regular OAI logging system, i.e., LOG_I(ASN...); + * + * As it is very verbose, note that you can change the log level per module in + * source or in gdb, e.g., to only activate it for a short time. + * + * In code: + * ``` + * set_log(ASN, OAI_INFO); // enable logging + * // do your encoding here + * set_log(ASN, OAI_ERR); // disable logging + * ``` + * + * in gdb: + * ``` + * gdb> p set_log(ASN, 1) // disable log, 1 == OAI_ERR + * gdb> p set_log(ASN, 5) // enable log, 5 == OAI_INFO + * ``` + */ + +#include "common/utils/LOG/log.h" +#if DEBUG_ASN1C +#define ASN_DEBUG(x...) do{ LOG_I(ASN,x);LOG_I(ASN,"\n"); } while(false) +#else +#define ASN_DEBUG(x...) +#endif + +#endif /* UTILS_CONFIG_H_ASN1 */ diff --git a/openair2/F1AP/f1ap_common.c b/openair2/F1AP/f1ap_common.c index 338b5f0c2b..efcb1d161b 100644 --- a/openair2/F1AP/f1ap_common.c +++ b/openair2/F1AP/f1ap_common.c @@ -35,27 +35,6 @@ static f1ap_cudu_inst_t *f1_du_inst[NUMBER_OF_eNB_MAX]= {0}; static f1ap_cudu_inst_t *f1_cu_inst[NUMBER_OF_eNB_MAX]= {0}; -#if defined(EMIT_ASN_DEBUG_EXTERN) -int asn_debug = 0; -int asn1_xer_print = 0; - -inline void ASN_DEBUG(const char *fmt, ...) { - if (asn_debug) { - int adi = asn_debug_indent; - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "[ASN1]"); - - while(adi--) - fprintf(stderr, " "); - - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - } -} -#endif - uint8_t F1AP_get_next_transaction_identifier(instance_t enb_mod_idP, instance_t cu_mod_idP) { static uint8_t transaction_identifier[NUMBER_OF_eNB_MAX]; transaction_identifier[enb_mod_idP+cu_mod_idP] = diff --git a/openair2/F1AP/f1ap_common.h b/openair2/F1AP/f1ap_common.h index 6b64e1b59e..e89e8a70cc 100644 --- a/openair2/F1AP/f1ap_common.h +++ b/openair2/F1AP/f1ap_common.h @@ -29,11 +29,6 @@ * \note * \warning */ - -#if HAVE_CONFIG_H_ - #include "config.h" -#endif - #ifndef F1AP_COMMON_H_ #define F1AP_COMMON_H_ @@ -43,10 +38,6 @@ #define F1AP_UE_IDENTIFIER_NUMBER 3 #define F1AP_TRANSACTION_IDENTIFIER_NUMBER 3 -#if defined(EMIT_ASN_DEBUG_EXTERN) - inline void ASN_DEBUG(const char *fmt, ...); -#endif - #include "F1AP_RAT-FrequencyPriorityInformation.h" #include "F1AP_DLUPTNLInformation-ToBeSetup-Item.h" #include "F1AP_PrivateMessage.h" diff --git a/openair2/M2AP/m2ap_common.c b/openair2/M2AP/m2ap_common.c index d288a0a114..aa090d124d 100644 --- a/openair2/M2AP/m2ap_common.c +++ b/openair2/M2AP/m2ap_common.c @@ -31,27 +31,6 @@ #include "m2ap_common.h" #include "M2AP_M2AP-PDU.h" -int asn_debug = 0; -int asn1_xer_print = 0; - -#if defined(EMIT_ASN_DEBUG_EXTERN) -inline void ASN_DEBUG(const char *fmt, ...) -{ - if (asn_debug) { - int adi = asn_debug_indent; - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "[ASN1]"); - - while(adi--) fprintf(stderr, " "); - - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - } -} -#endif - ssize_t m2ap_generate_initiating_message( uint8_t **buffer, uint32_t *length, diff --git a/openair2/M2AP/m2ap_common.h b/openair2/M2AP/m2ap_common.h index 0a6895fcb7..2e84c51938 100644 --- a/openair2/M2AP/m2ap_common.h +++ b/openair2/M2AP/m2ap_common.h @@ -18,10 +18,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - -#if HAVE_CONFIG_H_ -# include "config.h" -#endif +#ifndef M2AP_COMMON_H_ +#define M2AP_COMMON_H_ #include "M2AP_ProtocolIE-Field.h" #include "M2AP_M2AP-PDU.h" @@ -38,9 +36,6 @@ #include "common/ran_context.h" -#ifndef M2AP_COMMON_H_ -#define M2AP_COMMON_H_ - /** @defgroup _m2ap_impl_ M2AP Layer Reference Implementation * @ingroup _ref_implementation_ * @{ diff --git a/openair2/X2AP/x2ap_common.c b/openair2/X2AP/x2ap_common.c index 93a8c32513..a687b90666 100644 --- a/openair2/X2AP/x2ap_common.c +++ b/openair2/X2AP/x2ap_common.c @@ -31,27 +31,6 @@ #include "x2ap_common.h" #include "X2AP_X2AP-PDU.h" -int asn_debug = 0; -int asn1_xer_print = 0; - -#if defined(EMIT_ASN_DEBUG_EXTERN) -inline void ASN_DEBUG(const char *fmt, ...) -{ - if (asn_debug) { - int adi = asn_debug_indent; - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "[ASN1]"); - - while(adi--) fprintf(stderr, " "); - - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - } -} -#endif - ssize_t x2ap_generate_initiating_message( uint8_t **buffer, uint32_t *length, diff --git a/openair2/X2AP/x2ap_common.h b/openair2/X2AP/x2ap_common.h index 7dd88ffa21..e7b86c77b9 100644 --- a/openair2/X2AP/x2ap_common.h +++ b/openair2/X2AP/x2ap_common.h @@ -18,10 +18,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - -#if HAVE_CONFIG_H_ -# include "config.h" -#endif +#ifndef X2AP_COMMON_H_ +#define X2AP_COMMON_H_ #include "X2AP_ProtocolIE-Field.h" #include "X2AP_X2AP-PDU.h" @@ -35,9 +33,6 @@ #include "X2AP_asn_constant.h" #include "intertask_interface.h" -#ifndef X2AP_COMMON_H_ -#define X2AP_COMMON_H_ - /** @defgroup _x2ap_impl_ X2AP Layer Reference Implementation * @ingroup _ref_implementation_ * @{ diff --git a/openair3/COMMON/security_types.h b/openair3/COMMON/security_types.h index eb55e44d77..5494ffd994 100644 --- a/openair3/COMMON/security_types.h +++ b/openair3/COMMON/security_types.h @@ -18,10 +18,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - -#if HAVE_CONFIG_H -# include "config.h" -#endif +#ifndef SECURITY_TYPES_H_ +#define SECURITY_TYPES_H_ #if !defined(HAVE_UINT128_T) # include @@ -31,8 +29,6 @@ #include #include -#ifndef SECURITY_TYPES_H_ -#define SECURITY_TYPES_H_ #define RAND_LENGTH_BITS (128) #define RAND_LENGTH_OCTETS (RAND_LENGTH_BITS/8) diff --git a/openair3/M3AP/m3ap_common.c b/openair3/M3AP/m3ap_common.c index 5501997638..e43275d96c 100644 --- a/openair3/M3AP/m3ap_common.c +++ b/openair3/M3AP/m3ap_common.c @@ -31,27 +31,6 @@ #include "m3ap_common.h" #include "M3AP_M3AP-PDU.h" -int asn_debug = 0; -int asn1_xer_print = 0; - -#if defined(EMIT_ASN_DEBUG_EXTERN) -inline void ASN_DEBUG(const char *fmt, ...) -{ - if (asn_debug) { - int adi = asn_debug_indent; - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "[ASN1]"); - - while(adi--) fprintf(stderr, " "); - - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - } -} -#endif - ssize_t m3ap_generate_initiating_message( uint8_t **buffer, uint32_t *length, diff --git a/openair3/M3AP/m3ap_common.h b/openair3/M3AP/m3ap_common.h index c5f55bc70a..75c60db71a 100644 --- a/openair3/M3AP/m3ap_common.h +++ b/openair3/M3AP/m3ap_common.h @@ -18,10 +18,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - -#if HAVE_CONFIG_H_ -# include "config.h" -#endif +#ifndef M3AP_COMMON_H_ +#define M3AP_COMMON_H_ #include "M3AP_ProtocolIE-Field.h" #include "M3AP_M3AP-PDU.h" @@ -35,8 +33,6 @@ #include "M3AP_asn_constant.h" #include "intertask_interface.h" -#ifndef M3AP_COMMON_H_ -#define M3AP_COMMON_H_ /** @defgroup _m3ap_impl_ M3AP Layer Reference Implementation * @ingroup _ref_implementation_ diff --git a/openair3/NGAP/ngap_common.h b/openair3/NGAP/ngap_common.h index a550b6e436..cfb9d63e59 100644 --- a/openair3/NGAP/ngap_common.h +++ b/openair3/NGAP/ngap_common.h @@ -33,23 +33,11 @@ */ -#if HAVE_CONFIG_H_ -# include "config.h" -#endif - #ifndef NGAP_COMMON_H_ #define NGAP_COMMON_H_ #include "common/utils/LOG/log.h" -/* replace ASN_DEBUG defined in asn_internal.h by oai tracing system - Would be cleaner to modify asn_internal.h but it seems to come - from non oai source, with BSD license, so prefer to do that here.. -*/ -#ifdef ASN_DEBUG -# undef ASN_DEBUG -#endif -#define ASN_DEBUG( x... ) LOG_I(ASN, x) #include "NGAP_ProtocolIE-Field.h" #include "NGAP_NGAP-PDU.h" diff --git a/openair3/S1AP/s1ap_common.h b/openair3/S1AP/s1ap_common.h index d383b622b6..9eee0d8dff 100644 --- a/openair3/S1AP/s1ap_common.h +++ b/openair3/S1AP/s1ap_common.h @@ -23,24 +23,10 @@ * @ingroup _ref_implementation_ * @{ */ - -#if HAVE_CONFIG_H_ -# include "config.h" -#endif - #ifndef S1AP_COMMON_H_ #define S1AP_COMMON_H_ - #include "common/utils/LOG/log.h" -/* replace ASN_DEBUG defined in asn_internal.h by oai tracing system - Would be cleaner to modify asn_internal.h but it seems to come - from non oai source, with BSD license, so prefer to do that here.. -*/ -#ifdef ASN_DEBUG -# undef ASN_DEBUG -#endif -#define ASN_DEBUG( x... ) LOG_I(ASN, x) #include "S1AP_ProtocolIE-Field.h" #include "S1AP_S1AP-PDU.h" @@ -63,7 +49,6 @@ #define S1AP_UE_ID_FMT "0x%06"PRIX32 -extern int asn_debug; extern int asn1_xer_print; #if defined(ENB_MODE) diff --git a/openair3/TEST/test_kdf.c b/openair3/TEST/test_kdf.c index 50a2ad347a..7e1b623e5e 100644 --- a/openair3/TEST/test_kdf.c +++ b/openair3/TEST/test_kdf.c @@ -24,10 +24,6 @@ #include #include -#if HAVE_CONFIG_H -# include "config.h" -#endif - #include "test_util.h" #include "secu_defs.h" From 63a9cbcc66652e0a3488e3f423af0289a29e30a2 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 11 Aug 2022 15:41:46 +0200 Subject: [PATCH 38/98] fixes to correctly configure and schedule CSI-RS in case of multiple BWPs --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 20 +++++++++++++++++-- openair2/RRC/NR/nr_rrc_config.c | 6 ++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index a737e66c40..7a775b79da 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2672,7 +2672,19 @@ void nr_csirs_scheduling(int Mod_idP, NR_CSI_MeasConfig_t *csi_measconfig = ul_bwp->csi_MeasConfig; - if (csi_measconfig->nzp_CSI_RS_ResourceToAddModList != NULL) { + // looking for the correct CSI-RS resource in current BWP + NR_NZP_CSI_RS_ResourceSetId_t *nzp = NULL; + for (int csi_list=0; csi_listcsi_ResourceConfigToAddModList->list.count; csi_list++) { + NR_CSI_ResourceConfig_t *csires = csi_measconfig->csi_ResourceConfigToAddModList->list.array[csi_list]; + if(csires->bwp_Id == dl_bwp->bwp_id && + csires->csi_RS_ResourceSetList.present == NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB && + csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList) { + nzp = csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list.array[0]; + } + } + + if (csi_measconfig->nzp_CSI_RS_ResourceToAddModList != NULL && + nzp != NULL) { NR_NZP_CSI_RS_Resource_t *nzpcsi; int period, offset; @@ -2681,12 +2693,16 @@ void nr_csirs_scheduling(int Mod_idP, for (int id = 0; id < csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.count; id++){ nzpcsi = csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.array[id]; + // transmitting CSI-RS only for current BWP + if (nzpcsi->nzp_CSI_RS_ResourceId != *nzp) + continue; + NR_CSI_RS_ResourceMapping_t resourceMapping = nzpcsi->resourceMapping; csi_period_offset(NULL,nzpcsi->periodicityAndOffset,&period,&offset); if((frame*n_slots_frame+slot-offset)%period == 0) { - LOG_D(NR_MAC,"Scheduling CSI-RS in frame %d slot %d\n",frame,slot); + LOG_D(NR_MAC,"Scheduling CSI-RS in frame %d slot %d Resource ID %ld\n",frame,slot,nzpcsi->nzp_CSI_RS_ResourceId); UE_info->sched_csirs = true; nfapi_nr_dl_tti_request_pdu_t *dl_tti_csirs_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index f0763e115a..cd8ee15368 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -148,7 +148,8 @@ void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, if (do_csirs) { - csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)); + if(!csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList) + csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)); NR_NZP_CSI_RS_ResourceSet_t *nzpcsirs0 = calloc(1,sizeof(*nzpcsirs0)); nzpcsirs0->nzp_CSI_ResourceSetId = id; NR_NZP_CSI_RS_ResourceId_t *nzpid0 = calloc(1,sizeof(*nzpid0)); @@ -168,7 +169,8 @@ void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, if (tdd) nb_slots_per_period = n_slots_frame/get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); - csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList)); + if(!csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList) + csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList)); NR_NZP_CSI_RS_Resource_t *nzpcsi0 = calloc(1,sizeof(*nzpcsi0)); nzpcsi0->nzp_CSI_RS_ResourceId = id; NR_CSI_RS_ResourceMapping_t resourceMapping; From 0289bb57915764c6de83243214d7e8b48ff47a4a Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 12 Aug 2022 15:39:48 +0200 Subject: [PATCH 39/98] SRS for multiple BWPs --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 15 ++++++++++++++- openair2/RRC/NR/nr_rrc_config.c | 11 ++++++----- openair2/RRC/NR/nr_rrc_config.h | 1 + openair2/RRC/NR/rrc_gNB_reconfig.c | 3 +-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index e9743cd54c..4c5d11df5a 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1092,7 +1092,7 @@ void fill_initial_SpCellConfig(int uid, // We are using do_srs = 0 here because the periodic SRS will only be enabled in update_cellGroupConfig() if do_srs == 1 initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); - config_srs(initialUplinkBWP->srs_Config, curr_bwp, uid, 0); + config_srs(initialUplinkBWP->srs_Config, curr_bwp, uid, 0, 0); scheduling_request_config(scc, pucch_Config); @@ -1598,6 +1598,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, config_srs(SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config, curr_bwp, uid, + 0, configuration->do_SRS); } @@ -1606,6 +1607,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, set_dl_mcs_table(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing, configuration->force_256qam_off ? NULL : uecap, bwp_Dedicated, scc); struct NR_ServingCellConfig__downlinkBWP_ToAddModList *DL_BWP_list = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; + struct NR_UplinkConfig__uplinkBWP_ToAddModList *UL_BWP_list = SpCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList; if (DL_BWP_list) { for (int i=0; ilist.count; i++){ NR_BWP_Downlink_t *bwp = DL_BWP_list->list.array[i]; @@ -1613,6 +1615,17 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, set_dl_mcs_table(scs, configuration->force_256qam_off ? NULL : uecap, bwp->bwp_Dedicated, scc); } } + if (UL_BWP_list) { + for (int i=0; ilist.count; i++) { + NR_BWP_Uplink_t *ul_bwp = UL_BWP_list->list.array[i]; + int bwp_size = NRRIV2BW(ul_bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + config_srs(ul_bwp->bwp_Dedicated->srs_Config, + bwp_size, + uid, + i+1, + configuration->do_SRS); + } + } update_cqitables(bwp_Dedicated->pdsch_Config, SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup); } } diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 4e4897a960..7e123f6872 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -354,6 +354,7 @@ long rrc_get_max_nr_csrs(const uint8_t max_rbs, const long b_SRS) { void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, const int curr_bwp, const int uid, + const int res_id, const int do_srs) { setup_release_srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; @@ -383,10 +384,10 @@ void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, srs_Config->srs_ResourceSetToAddModList = calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); NR_SRS_ResourceSet_t *srs_resset0 = calloc(1,sizeof(*srs_resset0)); - srs_resset0->srs_ResourceSetId = 0; + srs_resset0->srs_ResourceSetId = res_id; srs_resset0->srs_ResourceIdList = calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); NR_SRS_ResourceId_t *srs_resset0_id = calloc(1,sizeof(*srs_resset0_id)); - *srs_resset0_id = 0; + *srs_resset0_id = res_id; ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list, srs_resset0_id); srs_Config->srs_ResourceToReleaseList=NULL; if (do_srs) { @@ -415,7 +416,7 @@ void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, srs_Config->srs_ResourceToAddModList = calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); - srs_res0->srs_ResourceId = 0; + srs_res0->srs_ResourceId = res_id; srs_res0->nrofSRS_Ports = NR_SRS_Resource__nrofSRS_Ports_port1; srs_res0->ptrs_PortIndex = NULL; srs_res0->transmissionComb.present = NR_SRS_Resource__transmissionComb_PR_n2; @@ -1114,11 +1115,11 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, pusch_Config->tp_pi2BPSK=NULL; ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); - ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; config_srs(ubwp->bwp_Dedicated->srs_Config, curr_bwp, uid, - 0); + bwp_loop+1, + configuration->do_SRS); ubwp->bwp_Dedicated->configuredGrantConfig = NULL; ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 001734ba6b..58caa50b80 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -147,6 +147,7 @@ void config_csiim(int do_csirs, int dl_antenna_ports, int curr_bwp, void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, const int curr_bwp, const int uid, + const int res_id, const int do_srs); void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 2a79af598e..85aa5e24a9 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -489,8 +489,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco int curr_bwp = NRRIV2BW(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); - initialUplinkBWP->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - config_srs(initialUplinkBWP->srs_Config, curr_bwp, uid, configuration->do_SRS); + config_srs(initialUplinkBWP->srs_Config, curr_bwp, uid, 0, configuration->do_SRS); // Downlink BWPs int n_dl_bwp = 1; From df05475b6b9946b70731a89fd9f2d3580550d1ac Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 2 Aug 2022 13:44:57 +0200 Subject: [PATCH 40/98] Add eNB L2sim config file for enb container image --- docker/scripts/enb_entrypoint.sh | 1 + docker/scripts/enb_parameters.yaml | 42 ++++++++++++++++++++++++++++++ docker/scripts/generateTemplate.py | 1 + 3 files changed, 44 insertions(+) diff --git a/docker/scripts/enb_entrypoint.sh b/docker/scripts/enb_entrypoint.sh index 06e94b1e7a..825dfd73c1 100755 --- a/docker/scripts/enb_entrypoint.sh +++ b/docker/scripts/enb_entrypoint.sh @@ -18,6 +18,7 @@ if [[ -v USE_FDD_IF4P5_RCC ]]; then cp $PREFIX/etc/rcc.if4p5.fdd.conf $PREFIX/et if [[ -v USE_TDD_IF4P5_RCC ]]; then cp $PREFIX/etc/rcc.if4p5.tdd.conf $PREFIX/etc/enb.conf; fi if [[ -v USE_FDD_RRU ]]; then cp $PREFIX/etc/rru.fdd.conf $PREFIX/etc/enb.conf; fi if [[ -v USE_TDD_RRU ]]; then cp $PREFIX/etc/rru.tdd.conf $PREFIX/etc/enb.conf; fi +if [[ -v USE_NFAPI_VNF ]]; then cp $PREFIX/etc/enb.nfapi.vnf.conf $PREFIX/etc/enb.conf; fi # Sometimes, the templates are not enough. We mount a conf file on $PREFIX/etc. It can be a template itself. if [[ -v USE_VOLUMED_CONF ]]; then cp $PREFIX/etc/mounted.conf $PREFIX/etc/enb.conf; fi diff --git a/docker/scripts/enb_parameters.yaml b/docker/scripts/enb_parameters.yaml index 07bba4479b..69baaebb3d 100644 --- a/docker/scripts/enb_parameters.yaml +++ b/docker/scripts/enb_parameters.yaml @@ -354,3 +354,45 @@ - key: parallel_config env: "@THREAD_PARALLEL_CONFIG@" + - filePrefix: "proxy_rcc.band7.tm1.nfapi.conf" + outputfilename: "enb.nfapi.vnf.conf" + config: + - key: Active_eNBs + env: "@ENB_NAME@" + - key: eNB_name + env: "@ENB_NAME@" + - key: plmn_list + env: + mcc: "@MCC@" + mnc: "@MNC@" + mnc_length: "@MNC_LENGTH@" + - key: tracking_area_code + env: "@TAC@" + - key: eutra_band + env: "@UTRA_BAND_ID@" + - key: downlink_frequency + env: "@DL_FREQUENCY_IN_MHZ@000000" + - key: uplink_frequency_offset + env: "@UL_FREQUENCY_OFFSET_IN_MHZ@000000" + - key: Nid_cell + env: "@NID_CELL@" + - key: N_RB_DL + env: "@NB_PRB@" + - key: ipv4 + env: "@MME_S1C_IP_ADDRESS@" + - key: ENB_INTERFACE_NAME_FOR_S1_MME + env: "@ENB_INTERFACE_NAME_FOR_S1_MME@" + - key: ENB_IPV4_ADDRESS_FOR_S1_MME + env: "@ENB_IPV4_ADDRESS_FOR_S1_MME@" + - key: ENB_INTERFACE_NAME_FOR_S1U + env: "@ENB_INTERFACE_NAME_FOR_S1U@" + - key: ENB_IPV4_ADDRESS_FOR_S1U + env: "@ENB_IPV4_ADDRESS_FOR_S1U@" + - key: ENB_IPV4_ADDRESS_FOR_X2C + env: "@ENB_IPV4_ADDRESS_FOR_X2C@" + - key: LOCAL_S_IF_NAME + env: "@LOCAL_S_IF_NAME@" + - key: REMOTE_S_ADDRESS + env: "@REMOTE_S_ADDRESS@" + - key: LOCAL_S_ADDRESS + env: "@LOCAL_S_ADDRESS@" diff --git a/docker/scripts/generateTemplate.py b/docker/scripts/generateTemplate.py index ec8f32ec6e..723bf86070 100644 --- a/docker/scripts/generateTemplate.py +++ b/docker/scripts/generateTemplate.py @@ -65,6 +65,7 @@ def main(): "gNB_SA_CU.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "gNB_SA_DU.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "proxy_rcc.band7.tm1.nfapi.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "proxy_nr-ue.nfapi.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "ue.nfapi": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "ue_sim_ci": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}' From c7f79e71e7b18ffe22c69acd823fc38aadca7926 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 4 Aug 2022 09:52:26 +0200 Subject: [PATCH 41/98] Add more users for dummy CI 4G UE sim configuration --- openair3/NAS/TOOLS/ue_sim_ci.conf | 108 ++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/openair3/NAS/TOOLS/ue_sim_ci.conf b/openair3/NAS/TOOLS/ue_sim_ci.conf index 5d95c9ba3f..e9b02e9b1f 100644 --- a/openair3/NAS/TOOLS/ue_sim_ci.conf +++ b/openair3/NAS/TOOLS/ue_sim_ci.conf @@ -43,3 +43,111 @@ UE0: EHPLMN_LIST = (); }; + +UE1: +{ + USER: { + IMEI="356113022094149"; + MANUFACTURER="OAI"; + MODEL="LTE SoftModem"; + PIN="0000"; + }; + + SIM: { + MSIN="0100001111"; + USIM_API_K="8baf473f2f8fd09487cccbd7097c6862"; + OPC="e734f8734007d6c5ce7a0508809e7e9c"; + MSISDN="33611123456"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "20896"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("20896"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = (); + + # Forbidden plmns + FPLMN_LIST = (); + + # Equivalent home plmns + EHPLMN_LIST = (); + +}; + +UE2: +{ + USER: { + IMEI="356113022094149"; + MANUFACTURER="OAI"; + MODEL="LTE SoftModem"; + PIN="0000"; + }; + + SIM: { + MSIN="0100001111"; + USIM_API_K="8baf473f2f8fd09487cccbd7097c6862"; + OPC="e734f8734007d6c5ce7a0508809e7e9c"; + MSISDN="33611123456"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "20896"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("20896"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = (); + + # Forbidden plmns + FPLMN_LIST = (); + + # Equivalent home plmns + EHPLMN_LIST = (); + +}; + +UE3: +{ + USER: { + IMEI="356113022094149"; + MANUFACTURER="OAI"; + MODEL="LTE SoftModem"; + PIN="0000"; + }; + + SIM: { + MSIN="0100001111"; + USIM_API_K="8baf473f2f8fd09487cccbd7097c6862"; + OPC="e734f8734007d6c5ce7a0508809e7e9c"; + MSISDN="33611123456"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "20896"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("20896"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = (); + + # Forbidden plmns + FPLMN_LIST = (); + + # Equivalent home plmns + EHPLMN_LIST = (); + +}; From 7f8031f69a4daf920b9044430640bc2bee0883a7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 3 Aug 2022 20:09:12 +0200 Subject: [PATCH 42/98] Add docker-compose.yml for l2sim-4g --- .../4g_l2sim_fdd/docker-compose.yml | 305 ++++++++++++++++++ .../yaml_files/4g_l2sim_fdd/entrypoint.sh | 36 +++ ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf | 134 ++++++++ .../4g_l2sim_fdd/mme_fd.sprint.conf | 169 ++++++++++ ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql | 93 ++++++ .../yaml_files/4g_l2sim_fdd/redis_extern.conf | 33 ++ 6 files changed, 770 insertions(+) create mode 100644 ci-scripts/yaml_files/4g_l2sim_fdd/docker-compose.yml create mode 100755 ci-scripts/yaml_files/4g_l2sim_fdd/entrypoint.sh create mode 100644 ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf create mode 100644 ci-scripts/yaml_files/4g_l2sim_fdd/mme_fd.sprint.conf create mode 100644 ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql create mode 100644 ci-scripts/yaml_files/4g_l2sim_fdd/redis_extern.conf diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/docker-compose.yml b/ci-scripts/yaml_files/4g_l2sim_fdd/docker-compose.yml new file mode 100644 index 0000000000..03cb45310d --- /dev/null +++ b/ci-scripts/yaml_files/4g_l2sim_fdd/docker-compose.yml @@ -0,0 +1,305 @@ +version: '3.8' + +services: + cassandra: + image: cassandra:2.1 + container_name: l2sim4g-cassandra + networks: + private_net: + ipv4_address: 192.168.68.2 + environment: + CASSANDRA_CLUSTER_NAME: "OAI HSS Cluster" + CASSANDRA_ENDPOINT_SNITCH: GossipingPropertyFileSnitch + healthcheck: + test: /bin/bash -c "nodetool status" + interval: 10s + timeout: 5s + retries: 5 + + db_init: + image: cassandra:2.1 + container_name: l2sim4g-db-init + depends_on: [cassandra] + deploy: + restart_policy: + condition: on-failure + max_attempts: 10 + networks: + private_net: + ipv4_address: 192.168.68.4 + volumes: + - ./oai_db.cql:/home/oai_db.cql + entrypoint: /bin/bash -c "cqlsh --file /home/oai_db.cql 192.168.68.2 && echo 'OK'" + + oai_hss: + image: oai-hss:latest + container_name: l2sim4g-oai-hss + privileged: true + depends_on: [cassandra] + networks: + private_net: + ipv4_address: 192.168.68.3 + public_net: + ipv4_address: 192.168.61.2 + environment: + REALM: openairinterface.org + HSS_FQDN: hss.openairinterface.org + PREFIX: /openair-hss/etc + cassandra_Server_IP: 192.168.68.2 + OP_KEY: 1006020f0a478bf6b699f15c062e42b3 + LTE_K: fec86ba6eb707ed08905757b1bb44b8f + APN1: oai.ipv4 + APN2: internet + FIRST_IMSI: 208960100000001 + NB_USERS: 10 + healthcheck: + test: /bin/bash -c "pgrep oai_hss" + interval: 10s + timeout: 5s + retries: 5 + + redis: + image: redis:6.0.5 + container_name: l2sim4g-redis + privileged: true + networks: + public_net: + ipv4_address: 192.168.61.6 + volumes: + - ./redis_extern.conf:/usr/local/etc/redis/redis.conf + entrypoint: /bin/bash -c "redis-server /usr/local/etc/redis/redis.conf" + healthcheck: + test: /bin/bash -c "redis-cli -h 192.168.61.6 -p 6380 ping" + interval: 10s + timeout: 5s + retries: 5 + + magma_mme: + image: magma-mme:latest + container_name: l2sim4g-magma-mme + hostname: mme + privileged: true + depends_on: [oai_hss, redis] + networks: + public_net: + ipv4_address: 192.168.61.3 + environment: + TZ: Europe/Paris + REALM: openairinterface.org + PREFIX: /openair-mme/etc + HSS_HOSTNAME: hss + HSS_FQDN: hss.openairinterface.org + HSS_REALM: openairinterface.org + MME_FQDN: mme.openairinterface.org + FEATURES: mme_oai + volumes: + - ./mme_fd.sprint.conf:/magma-mme/etc/mme_fd.conf.tmplt + - ./mme.conf:/magma-mme/etc/mme.conf + - ./entrypoint.sh:/magma-mme/bin/entrypoint.sh + entrypoint: /bin/bash -c "/magma-mme/bin/entrypoint.sh" + healthcheck: + test: /bin/bash -c "pgrep oai_mme" + interval: 10s + timeout: 5s + retries: 5 + + oai_spgwc: + image: oai-spgwc:latest + privileged: true + depends_on: [magma_mme] + container_name: l2sim4g-oai-spgwc + networks: + public_net: + ipv4_address: 192.168.61.4 + environment: + TZ: Europe/Paris + SGW_INTERFACE_NAME_FOR_S11: eth0 + PGW_INTERFACE_NAME_FOR_SX: eth0 + DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100 + DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 + PUSH_PROTOCOL_OPTION: 'true' + APN_NI_1: oai.ipv4 + APN_NI_2: oai.ipv4_2 + DEFAULT_APN_NI_1: oai.ipv4 + UE_IP_ADDRESS_POOL_1: '12.0.0.2 - 12.0.0.254' + UE_IP_ADDRESS_POOL_2: '12.1.1.2 - 12.1.1.254' + MCC: '208' + MNC: '96' + MNC03: '096' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org + healthcheck: + test: /bin/bash -c "pgrep oai_spgwc" + interval: 10s + timeout: 5s + retries: 5 + + oai_spgwu: + image: oai-spgwu-tiny:latest + privileged: true + container_name: l2sim4g-oai-spgwu-tiny + depends_on: [oai_spgwc] + networks: + public_net: + ipv4_address: 192.168.61.5 + environment: + TZ: Europe/Paris + PID_DIRECTORY: /var/run + INSTANCE: 1 + SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP: eth0 + PGW_INTERFACE_NAME_FOR_SGI: eth0 + SGW_INTERFACE_NAME_FOR_SX: eth0 + SPGWC0_IP_ADDRESS: 192.168.61.4 + NETWORK_UE_IP: '12.0.0.0/24' + NETWORK_UE_NAT_OPTION: 'yes' + MCC: '208' + MNC: '96' + MNC03: '096' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org + healthcheck: + test: /bin/bash -c "pgrep oai_spgwu" + interval: 10s + timeout: 5s + retries: 5 + + trf_gen: + image: trf-gen:production + privileged: true + container_name: l2sim4g-trf-gen + networks: + public_net: + ipv4_address: 192.168.61.11 + entrypoint: /bin/bash -c "ip route add 12.0.0.0/24 via 192.168.61.5 dev eth0; sleep infinity" + healthcheck: + test: /bin/bash -c "ping -c 2 192.168.61.5" + interval: 10s + timeout: 5s + retries: 5 + + oai_enb: + image: oai-enb:develop + privileged: true + container_name: l2sim4g-oai-enb + network_mode: "host" + environment: + TZ: Europe/Paris + USE_NFAPI_VNF: 'yes' + ENB_NAME: enb-l2sim-vnf + MCC: '208' + MNC: '96' + MNC_LENGTH: 2 + TAC: 1 + UTRA_BAND_ID: 7 + DL_FREQUENCY_IN_MHZ: 2680 + UL_FREQUENCY_OFFSET_IN_MHZ: 120 + NID_CELL: 10 + NB_PRB: 25 + MME_S1C_IP_ADDRESS: 192.168.61.3 + ENB_INTERFACE_NAME_FOR_S1_MME: eth0 + ENB_IPV4_ADDRESS_FOR_S1_MME: 192.168.61.1 + ENB_INTERFACE_NAME_FOR_S1U: eth0 + ENB_IPV4_ADDRESS_FOR_S1U: 192.168.61.1 + ENB_IPV4_ADDRESS_FOR_X2C: 192.168.61.1 + FLEXRAN_ENABLED: 'no' + FLEXRAN_INTERFACE_NAME: eth0 + FLEXRAN_IPV4_ADDRESS: 192.168.61.1 + LOCAL_S_IF_NAME: 'lo:' + REMOTE_S_ADDRESS: 127.0.0.1 + LOCAL_S_ADDRESS: 127.0.0.2 + USE_ADDITIONAL_OPTIONS: --MACRLCs.[0].scheduler_mode "default" --log_config.global_log_options level,nocolor,time + healthcheck: + test: /bin/bash -c "pgrep lte-softmodem" + interval: 10s + timeout: 5s + retries: 5 + + proxy: + image: oai-lte-multi-ue-proxy:latest + privileged: true + container_name: "l2sim4g-proxy" + network_mode: "host" + environment: + TZ: Europe/Paris + command: "/oai-lte-multi-ue-proxy/bin/proxy 1" + depends_on: + - oai_enb + healthcheck: + test: /bin/bash -c "pgrep proxy" + interval: 10s + timeout: 5s + retries: 5 + + oai_ue1: + image: oai-lte-ue:develop + privileged: true + container_name: l2sim4g-oai-lte-ue1 + network_mode: "host" + environment: + TZ: Europe/Paris + USE_NFAPI: 'yes' + OPENAIR_DIR: /opt/oai-nr-ue + MCC: '208' + MNC: '96' + SHORT_IMSI: '0100000001' + LTE_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + OPC: 'c42449363bbad02b66d16bc975d77cc1' + MSISDN: '001011234561010' + HPLMN: 20896 + UE_NFAPI_IF_NAME: eno1 + ENB_IP_ADDRESS: 127.0.0.1 + LTE_UE_IP_ADDRESS: 127.0.0.1 + USE_ADDITIONAL_OPTIONS: --L2-emul 5 --nokrnmod 1 --num-ues 1 --node-number 2 --log_config.global_log_options level,nocolor,time + volumes: + - ../../../openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results:/opt/oai-nr-ue/openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results + healthcheck: + test: /bin/bash -c "pgrep lte-uesoftmodem" + interval: 10s + timeout: 5s + retries: 5 + + oai_ue2: + image: oai-lte-ue:develop + privileged: true + container_name: l2sim4g-oai-lte-ue2 + network_mode: "host" + environment: + TZ: Europe/Paris + USE_NFAPI: 'yes' + OPENAIR_DIR: /opt/oai-nr-ue + MCC: '208' + MNC: '96' + SHORT_IMSI: '0100000002' + LTE_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + OPC: 'c42449363bbad02b66d16bc975d77cc1' + MSISDN: '001011234561010' + HPLMN: 20896 + UE_NFAPI_IF_NAME: eno1 + ENB_IP_ADDRESS: 127.0.0.1 + LTE_UE_IP_ADDRESS: 127.0.0.1 + USE_ADDITIONAL_OPTIONS: --L2-emul 5 --nokrnmod 1 --num-ues 1 --node-number 3 --log_config.global_log_options level,nocolor,time + volumes: + - ../../../openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results:/opt/oai-nr-ue/openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results + healthcheck: + test: /bin/bash -c "pgrep lte-uesoftmodem" + interval: 10s + timeout: 5s + retries: 5 + +networks: + private_net: + name: l2sim4g-oai-private-net + ipam: + config: + - subnet: 192.168.68.0/26 + driver_opts: + com.docker.network.bridge.name: "l2sim4g-private" + public_net: + name: l2sim4g-oai-public-net + ipam: + config: + - subnet: 192.168.61.0/26 + driver_opts: + com.docker.network.bridge.name: "l2sim4g-public" diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/entrypoint.sh b/ci-scripts/yaml_files/4g_l2sim_fdd/entrypoint.sh new file mode 100755 index 0000000000..24960e215d --- /dev/null +++ b/ci-scripts/yaml_files/4g_l2sim_fdd/entrypoint.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +INSTANCE=1 +PREFIX='/magma-mme/etc' +MY_REALM='openairinterface.org' + +declare -A MME_CONF + +pushd $PREFIX +MME_CONF[@MME_S6A_IP_ADDR@]="192.168.61.3" +MME_CONF[@INSTANCE@]=$INSTANCE +MME_CONF[@PREFIX@]=$PREFIX +MME_CONF[@REALM@]=$MY_REALM +MME_CONF[@MME_FQDN@]="mme.${MME_CONF[@REALM@]}" +MME_CONF[@HSS_HOSTNAME@]='hss' +MME_CONF[@HSS_FQDN@]="${MME_CONF[@HSS_HOSTNAME@]}.${MME_CONF[@REALM@]}" +MME_CONF[@HSS_IP_ADDR@]="192.168.61.2" + +cp mme_fd.conf.tmplt $PREFIX/mme_fd.conf + +for K in "${!MME_CONF[@]}"; do + egrep -lRZ "$K" $PREFIX/mme_fd.conf | xargs -0 -l sed -i -e "s|$K|${MME_CONF[$K]}|g" + ret=$?;[[ ret -ne 0 ]] && echo "Could not replace $K with ${MME_CONF[$K]}" +done + +sed -i -e "s@etc/freeDiameter@etc@" /magma-mme/etc/mme_fd.conf +sed -i -e "s@bind: 127.0.0.1@bind: 192.168.61.6@" /etc/magma/redis.yml +# Generate freeDiameter certificate +popd +cd /magma-mme/scripts +./check_mme_s6a_certificate $PREFIX mme.${MME_CONF[@REALM@]} + +cd /magma-mme +nohup /magma-mme/bin/sctpd > /var/log/sctpd.log 2>&1 & +sleep 5 +/magma-mme/bin/oai_mme -c /magma-mme/etc/mme.conf diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf b/ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf new file mode 100644 index 0000000000..4f491cc63d --- /dev/null +++ b/ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf @@ -0,0 +1,134 @@ +# generated by generate_mme_config_script.py +MME : +{ + REALM = "openairinterface.org" + PID_DIRECTORY = "/var/run"; + MAXENB = 8; # power of 2 + MAXUE = 16; # power of 2 + RELATIVE_CAPACITY = 10; + + EMERGENCY_ATTACH_SUPPORTED = "no"; + UNAUTHENTICATED_IMSI_SUPPORTED = "no"; + + # EPS network feature support + EPS_NETWORK_FEATURE_SUPPORT_IMS_VOICE_OVER_PS_SESSION_IN_S1 = "no"; # DO NOT CHANGE + EPS_NETWORK_FEATURE_SUPPORT_EMERGENCY_BEARER_SERVICES_IN_S1_MODE = "no"; # DO NOT CHANGE + EPS_NETWORK_FEATURE_SUPPORT_LOCATION_SERVICES_VIA_EPC = "no"; # DO NOT CHANGE + EPS_NETWORK_FEATURE_SUPPORT_EXTENDED_SERVICE_REQUEST = "no"; # DO NOT CHANGE + + # Display statistics about whole system (expressed in seconds) + MME_STATISTIC_TIMER = 10; + IP_CAPABILITY = "IPV4"; # UE PDN_TYPE + USE_STATELESS = ""; + + INTERTASK_INTERFACE : + { + # max queue size per task + ITTI_QUEUE_SIZE = 2000000; + }; + + S6A : + { + S6A_CONF = "/magma-mme/etc/mme_fd.conf"; # YOUR MME freeDiameter config file path + HSS_HOSTNAME = "hss.openairinterface.org"; + HSS_REALM = "openairinterface.org"; + }; + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 8; + SCTP_OUTSTREAMS = 8; + }; + + # ------- S1AP definitions + S1AP : + { + # outcome drop timer value (seconds) + S1AP_OUTCOME_TIMER = 10; + }; + + # ------- MME served GUMMEIs + GUMMEI_LIST = ( + { MCC="208" ; MNC="96"; MME_GID="32768" ; MME_CODE="3"; } + ); + + # ------- MME served TAIs + TAI_LIST = ( + {MCC="208" ; MNC="96"; TAC = "1"; } + ); + + TAC_LIST = ( + {MCC="208" ; MNC="96"; TAC = "1"; } + ); + + CSFB : + { + NON_EPS_SERVICE_CONTROL = "OFF"; + CSFB_MCC = "208"; + CSFB_MNC = "96"; + LAC = "1"; + }; + NAS : + { + ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST = [ "EIA2" , "EIA1" , "EIA0" ]; + ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST = [ "EEA0" , "EEA1" , "EEA2" ]; + T3402 = 1 # in minutes (default is 12 minutes) + T3412 = 54 # in minutes (default is 54 minutes, network dependent) + T3422 = 6 # in seconds (default is 6s) + T3450 = 6 # in seconds (default is 6s) + T3460 = 6 # in seconds (default is 6s) + T3470 = 6 # in seconds (default is 6s) + T3485 = 8 # UNUSED in seconds (default is 8s) + T3486 = 8 # UNUSED in seconds (default is 8s) + T3489 = 4 # UNUSED in seconds (default is 4s) + T3495 = 8 # UNUSED in seconds (default is 8s) + }; + + SGS : + { + TS6_1 = 10 # in seconds (default is 10s) + TS8 = 4 # in seconds (default is 4s) + TS9 = 2 # in seconds (default is 4s) + TS10 = 4 # in seconds (default is 4s) + TS13 = 4 # in seconds (default is 4s) + }; + + NETWORK_INTERFACES : + { + MME_INTERFACE_NAME_FOR_S1_MME = "eth0"; + MME_IPV4_ADDRESS_FOR_S1_MME = "192.168.61.3/24"; + MME_INTERFACE_NAME_FOR_S11_MME = "eth0"; + MME_IPV4_ADDRESS_FOR_S11_MME = "192.168.61.3/24"; + MME_PORT_FOR_S11_MME = 2123; + }; + + LOGGING : + { + OUTPUT = "CONSOLE"; + THREAD_SAFE = "no"; + COLOR = "no"; + + SCTP_LOG_LEVEL = "ERROR"; + GTPV1U_LOG_LEVEL = "INFO"; + SPGW_APP_LOG_LEVEL = "INFO"; + UDP_LOG_LEVEL = "INFO"; + S1AP_LOG_LEVEL = "DEBUG"; + NAS_LOG_LEVEL = "INFO"; + MME_APP_LOG_LEVEL = "DEBUG"; + GTPV2C_LOG_LEVEL = "INFO"; + S11_LOG_LEVEL = "DEBUG"; + S6A_LOG_LEVEL = "DEBUG"; + UTIL_LOG_LEVEL = "INFO"; + MSC_LOG_LEVEL = "ERROR"; + ITTI_LOG_LEVEL = "ERROR"; + MME_SCENARIO_PLAYER_LOG_LEVEL = "ERROR"; + ASN1_VERBOSITY = "INFO"; + }; + + S-GW : + { + SGW_IPV4_ADDRESS_FOR_S11 = "192.168.61.4"; + }; +}; diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/mme_fd.sprint.conf b/ci-scripts/yaml_files/4g_l2sim_fdd/mme_fd.sprint.conf new file mode 100644 index 0000000000..6f87ed8c2b --- /dev/null +++ b/ci-scripts/yaml_files/4g_l2sim_fdd/mme_fd.sprint.conf @@ -0,0 +1,169 @@ +# -------- Local --------- + +# Uncomment if the framework cannot resolv it. +Identity = "@MME_FQDN@"; +Realm = "@REALM@"; + +# TLS configuration (see previous section) +TLS_Cred = "@PREFIX@/freeDiameter/mme.cert.pem", + "@PREFIX@/freeDiameter/mme.key.pem"; +TLS_CA = "@PREFIX@/freeDiameter/mme.cacert.pem"; + +# Disable use of TCP protocol (only listen and connect in SCTP) +# Default : TCP enabled +No_SCTP; + +# This option is ignored if freeDiameter is compiled with DISABLE_SCTP option. +# Prefer TCP instead of SCTP for establishing new connections. +# This setting may be overwritten per peer in peer configuration blocs. +# Default : SCTP is attempted first. +Prefer_TCP; + + +No_IPv6; + +# Overwrite the number of SCTP streams. This value should be kept low, +# especially if you are using TLS over SCTP, because it consumes a lot of +# resources in that case. See tickets 19 and 27 for some additional details on +# this. +# Limit the number of SCTP streams +SCTP_streams = 3; + + +# By default, freeDiameter acts as a Diameter Relay Agent by forwarding all +# messages it cannot handle locally. This parameter disables this behavior. +NoRelay; + +# Use RFC3588 method for TLS protection, where TLS is negociated after CER/CEA exchange is completed +# on the unsecure connection. The alternative is RFC6733 mechanism, where TLS protects also the +# CER/CEA exchange on a dedicated secure port. +# This parameter only affects outgoing connections. +# The setting can be also defined per-peer (see Peers configuration section). +# Default: use RFC6733 method with separate port for TLS. + +#TLS_old_method; + +AppServThreads = 4; + +# Specify the addresses on which to bind the listening server. This must be +# specified if the framework is unable to auto-detect these addresses, or if the +# auto-detected values are incorrect. Note that the list of addresses is sent +# in CER or CEA message, so one should pay attention to this parameter if some +# adresses should be kept hidden. +ListenOn = "@MME_S6A_IP_ADDR@"; + +Port = 3870; +SecPort = 5870; + +# -------- Extensions --------- + +# Uncomment (and create rtd.conf) to specify routing table for this peer. +#LoadExtension = "/usr/local/lib/freeDiameter/rt_default.fdx" : "rtd.conf"; + +#LoadExtension = "/usr/local/lib/freeDiameter/_sample.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_acct.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_diameap.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_radgw.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_redirect.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/app_sip.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_interactive.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_monitor.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_msg_dumps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_msg_timings.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dbg_rt.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_3gpp2_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_CreditControl.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_CxDx.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Gx.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_NAS.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Ro.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Rx.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_S6mS6n.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_SGd.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_SLh.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Sd.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Sh.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_T4.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_T6aT6bT7.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Tsp.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_dcca.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_dcca_3gpp.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_dcca_starent.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_draftload_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_eap.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_etsi283034_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_legacy_xml.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_mip6a.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_mip6i.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_nas_mipv6.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_nasreq.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4004_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4006bis_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4072_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4590_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5447_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5580_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5777_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5778_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc6734_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc6942_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7155_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7683_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7944_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_sip.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29061_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29128_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29154_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29173_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29212_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29214_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29215_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29217_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29229_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29272_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29273_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29329_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29336_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29337_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29338_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29343_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29344_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29345_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29368_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29468_avps.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_ts32299_avps.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_busypeers.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_default.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_ereg.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_ignore_dh.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_load_balance.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_randomize.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/rt_redirect.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_acct.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_app.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_hss.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_netemul.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_rt_any.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/test_sip.fdx"; +#LoadExtension = "/usr/local/lib/freeDiameter/dict_Rf.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_S6as6d.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_S6t.fdx"; +LoadExtension = "/usr/local/lib/freeDiameter/dict_S6c.fdx"; + + +# -------- Peers --------- + +# The framework will actively attempt to establish and maintain a connection +# with the peers listed here. +# For only accepting incoming connections, see the acl_wl.fx extension. + +# ConnectPeer +# Declare a remote peer to which this peer must maintain a connection. +# In addition, this allows specifying non-default parameters for this peer only +# (for example disable SCTP with this peer, or use RFC3588-flavour TLS). +# Note that by default, if a peer is not listed as a ConnectPeer entry, an +# incoming connection from this peer will be rejected. If you want to accept +# incoming connections from other peers, see the acl_wl.fdx? extension which +# allows exactly this. + +ConnectPeer= "@HSS_FQDN@" { ConnectTo = "@HSS_IP_ADDR@"; No_SCTP ; No_IPv6; Prefer_TCP; No_TLS; port = 3868;}; diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql b/ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql new file mode 100644 index 0000000000..2be0a8e2e9 --- /dev/null +++ b/ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql @@ -0,0 +1,93 @@ +CREATE KEYSPACE IF NOT EXISTS vhss WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': '1'}; + +CREATE TABLE IF NOT EXISTS vhss.users_imsi ( + imsi text PRIMARY KEY, + access_restriction int, + idmmeidentity int, + imei text, + imei_sv text, + key text, + lipa_permissions text, + mme_cap int, + mmehost text, + mmeidentity_idmmeidentity int, + mmerealm text, + ms_ps_status text, + msisdn bigint, + niddvalidity text, + nir_dest_host text, + nir_dest_realm text, + opc text, + pgw_id int, + rand text, + rfsp_index varint, + sqn bigint, + subscription_data text, + ue_reachability varint, + urrp_mme varint, + user_identifier text, + visited_plmnid text); + +CREATE TABLE IF NOT EXISTS vhss.msisdn_imsi ( + msisdn bigint PRIMARY KEY, + imsi text +); + +CREATE TABLE IF NOT EXISTS vhss.global_ids ( + table_name text PRIMARY KEY, + id counter); + +CREATE TABLE IF NOT EXISTS vhss.mmeidentity_host ( + mmehost text PRIMARY KEY, + idmmeidentity int, + mmerealm text, + ue_reachability varint, + mmeisdn text); + +CREATE TABLE IF NOT EXISTS vhss.mmeidentity ( + idmmeidentity int PRIMARY KEY, + mmehost text, + mmerealm text, + ue_reachability varint, + mmeisdn text); + +CREATE TABLE IF NOT EXISTS vhss.events ( + scef_id text, + scef_ref_id bigint, + extid text, + monitoring_event_configuration text, + monitoring_type int, + msisdn bigint, + user_identifier text, + primary key (scef_id, scef_ref_id) +); + +CREATE TABLE IF NOT EXISTS vhss.events_msisdn ( + msisdn bigint, + scef_id text, + scef_ref_id bigint, + primary key (msisdn, scef_id, scef_ref_id) +); + +CREATE TABLE IF NOT EXISTS vhss.events_extid ( + extid text, + scef_id text, + scef_ref_id bigint, + primary key (extid, scef_id, scef_ref_id) +); + +CREATE TABLE IF NOT EXISTS vhss.extid ( + extid text primary key +); + +CREATE TABLE IF NOT EXISTS vhss.extid_imsi ( + extid text, + imsi text, + primary key (extid, imsi) +); + +CREATE TABLE IF NOT EXISTS vhss.extid_imsi_xref ( + imsi text, + extid text, + primary key (imsi, extid) +); diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/redis_extern.conf b/ci-scripts/yaml_files/4g_l2sim_fdd/redis_extern.conf new file mode 100644 index 0000000000..1ee9dd9a78 --- /dev/null +++ b/ci-scripts/yaml_files/4g_l2sim_fdd/redis_extern.conf @@ -0,0 +1,33 @@ +# +# Copyright (c) 2016-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +# Jinja template for Redis configuration +# See the default config file for options and explanations: +# https://github.com/antirez/redis/blob/unstable/redis.conf + +# TODO: make sensible, production-aware config decisions + +bind 192.168.61.6 +port 6380 + +daemonize no +loglevel notice + +timeout 0 +databases 1 + +dbfilename redis_dump.rdb +dir /data + +# Save the DB on disk + +save 900 1 + +save 300 10 + +save 60 1000 From 71c13d85fccbfecc8008d331741e7efc333a9e9e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 4 Aug 2022 16:01:12 +0200 Subject: [PATCH 43/98] Add 4G L2sim XML scenario files --- .../xml_files/container_4g_l2sim_proxy.xml | 42 +++++++ .../xml_files/container_4g_l2sim_tdd.xml | 115 ++++++++++++++++++ .../xml_files/container_4g_l2sim_tdd_down.xml | 38 ++++++ 3 files changed, 195 insertions(+) create mode 100644 ci-scripts/xml_files/container_4g_l2sim_proxy.xml create mode 100644 ci-scripts/xml_files/container_4g_l2sim_tdd.xml create mode 100644 ci-scripts/xml_files/container_4g_l2sim_tdd_down.xml diff --git a/ci-scripts/xml_files/container_4g_l2sim_proxy.xml b/ci-scripts/xml_files/container_4g_l2sim_proxy.xml new file mode 100644 index 0000000000..c378ce8905 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_l2sim_proxy.xml @@ -0,0 +1,42 @@ + + + l2sim-4glte-proxy-build + Build L2sim proxy image + wrench + 1 + + 000001 + + + + + Build_Proxy + Build L2sim Proxy Image + 1 + 1 + True + 56cfdc0 + + + diff --git a/ci-scripts/xml_files/container_4g_l2sim_tdd.xml b/ci-scripts/xml_files/container_4g_l2sim_tdd.xml new file mode 100644 index 0000000000..f6dd08f325 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_l2sim_tdd.xml @@ -0,0 +1,115 @@ + + + l2sim-4glte-tdd + Testing 4G LTE L2 sim - FDD eNB + wrench + 2 + + 100001 + 000000 + 000001 + 000002 + 000003 + 000011 + 200000 + 020001 + 020002 + 200001 + 100001 + + + + + DeployGenObject + Deploy Cassandra Database + yaml_files/4g_l2sim_fdd + cassandra db_init + 1 + + + + DeployGenObject + Deploy OAI 4G CoreNetwork + yaml_files/4g_l2sim_fdd + oai_hss redis magma_mme oai_spgwc oai_spgwu trf_gen + 7 + + + + DeployGenObject + Deploy OAI 4G eNB L2 sim + yaml_files/4g_l2sim_fdd + oai_enb + 8 + + + + DeployGenObject + Deploy OAI L2 sim 4G LTE-UE 1 and Proxy + yaml_files/4g_l2sim_fdd + proxy oai_ue1 + 10 + + + + IdleSleep + Sleep + 10 + + + + PingFromContainer + Ping trf-gen from LTE-UE 1 + l2sim4g-oai-lte-ue1 + -I oaitun_ue1 -c 20 192.168.61.11 + 0 + + + + PingFromContainer + Ping LTE-UE 1 from trf-gen + l2sim4g-trf-gen + -c 20 12.0.0.2 + 0 + + + + UndeployGenObject + Undeploy all OAI 4G stack + yaml_files/4g_l2sim_fdd + + + + StatsFromGenObject + Statistics before Traffic Test + yaml_files/4g_l2sim_fdd + + + + StatsFromGenObject + Statistics after Traffic Test + yaml_files/4g_l2sim_fdd + + + diff --git a/ci-scripts/xml_files/container_4g_l2sim_tdd_down.xml b/ci-scripts/xml_files/container_4g_l2sim_tdd_down.xml new file mode 100644 index 0000000000..ec0f2523e2 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_l2sim_tdd_down.xml @@ -0,0 +1,38 @@ + + + l2sim-4glte-down + CleanUp 4G L2 sim - FDD eNB + trash + + 100002 + + + + + UndeployGenObject + Undeploy all OAI 4G stack + yaml_files/4g_l2sim_fdd + + + From 793c8de2ae218ab6ec2e500286d6e0747fec9cb5 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 9 Aug 2022 12:01:51 +0200 Subject: [PATCH 44/98] CI: Add L2sim-4G iperf DL&UL test --- .../xml_files/container_4g_l2sim_tdd.xml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ci-scripts/xml_files/container_4g_l2sim_tdd.xml b/ci-scripts/xml_files/container_4g_l2sim_tdd.xml index f6dd08f325..5298d01ef3 100644 --- a/ci-scripts/xml_files/container_4g_l2sim_tdd.xml +++ b/ci-scripts/xml_files/container_4g_l2sim_tdd.xml @@ -35,6 +35,8 @@ 200000 020001 020002 + 030011 + 030012 200001 100001 @@ -94,6 +96,24 @@ 0 + + IperfFromContainer + Iperf UDP Downlink + l2sim4g-oai-lte-ue1 + l2sim4g-trf-gen + -B 12.0.0.2 -u -i 1 -s + -c 12.0.0.2 -u -i 1 -t 30 -b 1M + + + + IperfFromContainer + Iperf UDP Uplink + l2sim4g-trf-gen + l2sim4g-oai-lte-ue1 + -u -i 1 -s + -B 12.0.0.2 -c 192.168.61.11 -u -i 1 -t 30 -b 3M + + UndeployGenObject Undeploy all OAI 4G stack From d46a7e40a867f9d4f36fd53477d24328a0685947 Mon Sep 17 00:00:00 2001 From: laurent Date: Tue, 16 Aug 2022 08:51:37 +0200 Subject: [PATCH 45/98] fix a bug: multi ues in rfsimulator 4G --- targets/RT/USER/lte-ue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 0658b8b9d0..73520dd918 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -1986,13 +1986,13 @@ void *UE_thread(void *arg) { for(int sf=0; sf<10; sf++) { for (int i=0; iframe_parms.nb_antennas_rx; i++) rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf]; + write_dummy(UE, timestamp); AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice, ×tamp, rxp, UE->frame_parms.samples_per_tti, UE->frame_parms.nb_antennas_rx), ""); - write_dummy(UE, timestamp); } } else { for (int i=0; iframe_parms.nb_antennas_rx; i++) From 65b399fcd719a35011a5914e428d9b9fc6b2fbed Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 12 Aug 2022 22:31:10 +0200 Subject: [PATCH 46/98] fix bugs in config module and config usage fix bug from this MR fix bug from this MR stupid-mistake --- common/config/config_cmdline.c | 31 +++-- common/config/config_load_configmodule.c | 9 +- common/config/config_load_configmodule.h | 14 +- common/config/config_paramdesc.h | 4 +- common/config/config_userapi.c | 154 +++++++++++++-------- common/config/config_userapi.h | 4 +- common/config/libconfig/config_libconfig.c | 68 +++------ common/utils/LOG/log.c | 1 + common/utils/LOG/log.h | 2 +- common/utils/load_module_shlib.h | 4 +- doc/TESTING_5GSA_setup.md | 15 -- executables/nr-softmodem.h | 2 +- executables/nr-uesoftmodem.h | 6 +- executables/softmodem-common.h | 18 +-- openair1/SIMULATION/TOOLS/random_channel.c | 2 +- openair1/SIMULATION/TOOLS/sim.h | 2 +- openair2/ENB_APP/enb_config.c | 8 +- openair2/ENB_APP/enb_paramdef_emtc.h | 2 +- openair2/ENB_APP/enb_paramdef_sidelink.h | 84 +++++------ openair2/LAYER2/NR_MAC_gNB/main.c | 2 +- openair2/RRC/NAS/nas_config.c | 4 +- openair2/UTIL/OPT/opt.h | 6 +- openair2/UTIL/OPT/probe.c | 3 - openair3/UICC/usim_interface.c | 20 +-- targets/ARCH/COMMON/record_player.h | 4 +- targets/ARCH/rfsimulator/simulator.c | 6 +- targets/RT/USER/lte-softmodem.h | 2 +- 27 files changed, 244 insertions(+), 233 deletions(-) diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index f5dfae06b6..5ba6db8547 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -53,13 +53,15 @@ int parse_stringlist(paramdef_t *cfgoptions, char *val) { } free(tmpval); - config_check_valptr(cfgoptions,(char **)&(cfgoptions->strlistptr), sizeof(char *) * numelt); + + AssertFatal(MAX_LIST_SIZE > numelt, ""); + config_check_valptr(cfgoptions, sizeof(char*), numelt); + cfgoptions->numelt=numelt; atoken=strtok_r(val, ",",&tokctx); for( int i=0; inumelt && atoken != NULL ; i++) { - config_check_valptr(cfgoptions,&(cfgoptions->strlistptr[i]),strlen(atoken)+1); - sprintf(cfgoptions->strlistptr[i],"%s",atoken); + snprintf(cfgoptions->strlistptr[i],DEFAULT_EXTRA_SZ,"%s",atoken); printf_params("[LIBCONFIG] %s[%i]: %s\n", cfgoptions->optname,i,cfgoptions->strlistptr[i]); atoken=strtok_r(NULL, ",",&tokctx); } @@ -84,13 +86,14 @@ int processoption(paramdef_t *cfgoptions, char *value) { char *charptr; case TYPE_STRING: - if (cfgoptions->numelt == 0 ) { - config_check_valptr(cfgoptions, cfgoptions->strptr, strlen(tmpval)+1); - sprintf(*(cfgoptions->strptr), "%s",tmpval); - } else { - sprintf( (char *)(cfgoptions->strptr), "%s",tmpval); + if (cfgoptions->numelt == 0 ) + config_check_valptr(cfgoptions, 1, + strlen(tmpval)+1); + if (cfgoptions->numelt < (strlen(tmpval)+1)) { + CONFIG_PRINTF_ERROR("[CONFIG] command line option %s value too long\n", + cfgoptions->optname); } - + snprintf(*cfgoptions->strptr, cfgoptions->numelt ,"%s",tmpval); printf_cmdl("[CONFIG] %s set to %s from command line\n", cfgoptions->optname, tmpval); optisset=1; break; @@ -105,7 +108,7 @@ int processoption(paramdef_t *cfgoptions, char *value) { case TYPE_INT16: case TYPE_UINT8: case TYPE_INT8: - config_check_valptr(cfgoptions, (char **)&(cfgoptions->iptr),sizeof(int32_t)); + config_check_valptr(cfgoptions, sizeof(*cfgoptions->iptr), 1); config_assign_int(cfgoptions,cfgoptions->optname,(int32_t)strtol(tmpval,&charptr,0)); if( *charptr != 0) { @@ -117,14 +120,14 @@ int processoption(paramdef_t *cfgoptions, char *value) { case TYPE_UINT64: case TYPE_INT64: - config_check_valptr(cfgoptions, (char **)&(cfgoptions->i64ptr),sizeof(uint64_t)); + config_check_valptr(cfgoptions, sizeof(*cfgoptions->i64ptr), 1); *(cfgoptions->i64ptr)=strtoll(tmpval,&charptr,0); if( *charptr != 0) { CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires an integer argument\n",cfgoptions->optname); } - printf_cmdl("[CONFIG] %s set to %lli from command line\n", cfgoptions->optname, (long long)*(cfgoptions->i64ptr)); + printf_cmdl("[CONFIG] %s set to %lli from command line\n", cfgoptions->optname, (long long)*cfgoptions->i64ptr); optisset=1; break; @@ -133,8 +136,8 @@ int processoption(paramdef_t *cfgoptions, char *value) { break; case TYPE_DOUBLE: - config_check_valptr(cfgoptions, (char **)&(cfgoptions->dblptr),sizeof(double)); - *(cfgoptions->dblptr) = strtof(tmpval,&charptr); + config_check_valptr(cfgoptions, sizeof(*cfgoptions->dblptr), 1); + *cfgoptions->dblptr = strtof(tmpval,&charptr); if( *charptr != 0) { CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires a double argument\n",cfgoptions->optname); diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 773692a82a..fbc44c3363 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -336,17 +336,18 @@ void end_configmodule(void) { cfgptr->end(); } + pthread_mutex_lock(&cfgptr->memBlocks_mutex); printf ("[CONFIG] free %u config value pointers\n",cfgptr->numptrs); for(int i=0; inumptrs ; i++) { - if (cfgptr->ptrs[i] != NULL && cfgptr->ptrsAllocated[i] == true) { - free(cfgptr->ptrs[i]); - cfgptr->ptrs[i]=NULL; - cfgptr->ptrsAllocated[i] = false; + if (cfgptr->oneBlock[i].ptrs != NULL && cfgptr->oneBlock[i].ptrsAllocated== true && cfgptr->oneBlock[i].toFree) { + free(cfgptr->oneBlock[i].ptrs); + memset(&cfgptr->oneBlock[i], 0, sizeof(cfgptr->oneBlock[i])); } } cfgptr->numptrs=0; + pthread_mutex_unlock(&cfgptr->memBlocks_mutex); } } diff --git a/common/config/config_load_configmodule.h b/common/config/config_load_configmodule.h index 0688f6531f..e3814994ad 100644 --- a/common/config/config_load_configmodule.h +++ b/common/config/config_load_configmodule.h @@ -41,7 +41,7 @@ #include "common/config/config_paramdesc.h" #include "common/utils/T/T.h" #define CONFIG_MAX_OOPT_PARAMS 10 // maximum number of parameters in the -O option (-O :P1:P2... -#define CONFIG_MAX_ALLOCATEDPTRS 1024 // maximum number of parameters that can be dynamicaly allocated in the config module +#define CONFIG_MAX_ALLOCATEDPTRS 2048 // maximum number of parameters that can be dynamicaly allocated in the config module /* default values for configuration module parameters */ #define CONFIG_LIBCONFIGFILE "libconfig" // use libconfig file @@ -62,6 +62,14 @@ typedef int(*configmodule_initfunc_t)(char *cfgP[],int numP); typedef int(*configmodule_getfunc_t)(paramdef_t *,int numparams, char *prefix); typedef int(*configmodule_getlistfunc_t)(paramlist_def_t *, paramdef_t *,int numparams, char *prefix); typedef void(*configmodule_endfunc_t)(void); + +typedef struct oneBlock_s{ + void *ptrs; + int sz; + bool toFree; + bool ptrsAllocated; +} oneBlock_t; + typedef struct configmodule_interface { int argc; char **argv; @@ -73,10 +81,10 @@ typedef struct configmodule_interface { configmodule_getfunc_t get; configmodule_getlistfunc_t getlist; configmodule_endfunc_t end; + pthread_mutex_t memBlocks_mutex; uint32_t numptrs; uint32_t rtflags; - char *ptrs[CONFIG_MAX_ALLOCATEDPTRS]; - bool ptrsAllocated[CONFIG_MAX_ALLOCATEDPTRS]; + oneBlock_t oneBlock[CONFIG_MAX_ALLOCATEDPTRS]; } configmodule_interface_t; #ifdef CONFIG_LOADCONFIG_MAIN diff --git a/common/config/config_paramdesc.h b/common/config/config_paramdesc.h index 86fc993a08..dc65bcb299 100644 --- a/common/config/config_paramdesc.h +++ b/common/config/config_paramdesc.h @@ -96,11 +96,13 @@ typedef union checkedparam { /* paramdef is used to describe a parameter, array of paramdef_t strustures is used as the main parameter in */ /* config apis used to retrieve parameters values */ +#define MAX_LIST_SIZE 32 +#define DEFAULT_EXTRA_SZ 256 typedef struct paramdef { char optname[MAX_OPTNAME_SIZE]; /* parameter name, can be used as long command line option */ char *helpstr; /* help string */ unsigned int paramflags; /* value is a "ored" combination of above PARAMFLAG_XXXX values */ - union { /* pointer to the parameter value, completed by the config module */ + union { /* pointer to the parameter value, completed by the config module */ char **strptr; char **strlistptr; uint8_t *u8ptr; diff --git a/common/config/config_userapi.c b/common/config/config_userapi.c index 462299b893..cebc59a95d 100644 --- a/common/config/config_userapi.c +++ b/common/config/config_userapi.c @@ -52,59 +52,95 @@ configmodule_interface_t *config_get_if(void) { return cfgptr; } -char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) { - if (ptr == NULL ) { - ptr = malloc(sizeof(char *)); +static int managed_ptr_sz(void* ptr) { + configmodule_interface_t * cfg=config_get_if(); + AssertFatal(cfg->numptrs < CONFIG_MAX_ALLOCATEDPTRS,""); + int i; + pthread_mutex_lock(&cfg->memBlocks_mutex); + int numptrs=cfg->numptrs; + for (i=0; ioneBlock[i].ptrs == ptr) + break; + pthread_mutex_unlock(&cfg->memBlocks_mutex); + if ( i == numptrs ) + return -1; + else + return cfg->oneBlock[i].sz; +} - if (ptr != NULL) { - *ptr=NULL; - cfgoptions->strptr=ptr; +void *config_allocate_new(int sz, bool autoFree) { + void *ptr = calloc(sz,1); + if (ptr != NULL) { + configmodule_interface_t * cfg=config_get_if(); + // add the memory piece in the managed memory pieces list + pthread_mutex_lock(&cfg->memBlocks_mutex); + int newBlockIdx=cfg->numptrs++; + oneBlock_t* tmp=&cfg->oneBlock[newBlockIdx]; + tmp->ptrs = (char *)ptr; + tmp->ptrsAllocated = true; + tmp->sz=sz; + tmp->toFree=autoFree; + pthread_mutex_unlock(&cfg->memBlocks_mutex); + } else + AssertFatal(false, "calloc fails\n"); + return ptr; +} - if ( (cfgoptions->paramflags & PARAMFLAG_NOFREE) == 0) { - config_get_if()->ptrs[config_get_if()->numptrs] = (char *)ptr; - config_get_if()->ptrsAllocated[config_get_if()->numptrs] = true; - config_get_if()->numptrs++; - } - } else { - CONFIG_PRINTF_ERROR("[CONFIG] %s %d option %s, cannot allocate pointer: %s \n", - __FILE__, __LINE__, cfgoptions->optname, strerror(errno)); +void config_check_valptr(paramdef_t *cfgoptions, int elt_sz, int nb_elt) { + + const bool toFree=!(cfgoptions->paramflags & PARAMFLAG_NOFREE); + + // let's see if the value has been read + // the datamodel is more difficult than it should be + // and it is not thread safe + if (cfgoptions->voidptr) { + int sz; + if ( cfgoptions-> type == TYPE_STRING) + sz=managed_ptr_sz(*cfgoptions->strptr); + else + sz=managed_ptr_sz(cfgoptions->voidptr); + if ( sz != -1 ) // the same variable pointer has been used! + cfgoptions->numelt=sz; + } + + if (cfgoptions->voidptr != NULL + && (cfgoptions->type == TYPE_INTARRAY + || cfgoptions->type == TYPE_UINTARRAY + || cfgoptions->type == TYPE_STRINGLIST )) { + int sz; + if ( cfgoptions->type == TYPE_STRING || + cfgoptions->type == TYPE_STRINGLIST ) + sz=managed_ptr_sz(*cfgoptions->strptr); + else + sz=managed_ptr_sz(cfgoptions->voidptr); + if ( sz != -1) { + CONFIG_PRINTF_ERROR("[CONFIG] %s NOT SUPPORTED not NULL pointer with array types", cfgoptions->optname); + return ; } } - printf_ptrs("[CONFIG] %s ptr: 0x%08lx requested size: %i\n",cfgoptions->optname,(uintptr_t)(ptr),length); - - if(cfgoptions->numelt > 0 && PARAM_ISSCALAR(cfgoptions) ) { /* already allocated */ - if (*ptr != NULL) { - return *ptr; + if (cfgoptions->voidptr == NULL ) { + if (cfgoptions->type == TYPE_STRING) { + // difficult datamodel + cfgoptions->strptr = config_allocate_new(sizeof(*cfgoptions->strptr), toFree); + } else if ( cfgoptions->type == TYPE_STRINGLIST) { + AssertFatal(nb_eltstrlistptr= config_allocate_new(sizeof(char*)*MAX_LIST_SIZE, toFree); + for (int i=0; istrlistptr[i]= config_allocate_new(DEFAULT_EXTRA_SZ, toFree); } else { - CONFIG_PRINTF_ERROR("[CONFIG] %s %d option %s, definition error: value pointer is NULL, declared as %i bytes allocated\n", - __FILE__, __LINE__,cfgoptions->optname, cfgoptions->numelt); + if ( cfgoptions->type == TYPE_INTARRAY || cfgoptions->type == TYPE_UINTARRAY ) + nb_elt=max(nb_elt, MAX_LIST_SIZE); // make room if the list is larger than the default one + cfgoptions->voidptr = config_allocate_new(elt_sz*nb_elt, toFree); } } - if (*ptr == NULL) { - // LTS: dummy fix, waiting Francois full fix in 4G branch - // the issue is we don't know at this point the size we will get - // for parmeters on the command line, - // The length sould probably managed, in a later version - // 100 is a very large value for a string parameter of today OAI - if (length<100) - length=100; - *ptr = malloc(length); - - if ( *ptr != NULL) { - memset(*ptr,0,length); - - if ( (cfgoptions->paramflags & PARAMFLAG_NOFREE) == 0) { - config_get_if()->ptrs[config_get_if()->numptrs] = *ptr; - config_get_if()->numptrs++; - } - } else { - CONFIG_PRINTF_ERROR("[CONFIG] %s %d malloc error\n",__FILE__, __LINE__); - } + if (cfgoptions->type == TYPE_STRING && *cfgoptions->strptr == NULL) { + *cfgoptions->strptr = config_allocate_new(nb_elt+DEFAULT_EXTRA_SZ, toFree); + cfgoptions->numelt=nb_elt+DEFAULT_EXTRA_SZ; } - return *ptr; + printf_ptrs("[CONFIG] %s ptr: %p requested size: elt_sz: %d, nb_elt: %d\n",cfgoptions->optname, cfgoptions->voidptr, elt_sz, nb_elt); } void config_assign_int(paramdef_t *cfgoptions, char *fullname, int val) { @@ -156,7 +192,7 @@ void config_assign_int(paramdef_t *cfgoptions, char *fullname, int val) { } } void config_assign_processedint(paramdef_t *cfgoption, int val) { - cfgoption->processedvalue = malloc(sizeof(int)); + cfgoption->processedvalue = config_allocate_new(sizeof(int),!(cfgoption->paramflags & PARAMFLAG_NOFREE)); if ( cfgoption->processedvalue != NULL) { *(cfgoption->processedvalue) = val; @@ -172,7 +208,7 @@ int config_get_processedint(paramdef_t *cfgoption) { ret=*(cfgoption->processedvalue); free( cfgoption->processedvalue); cfgoption->processedvalue=NULL; - printf_params("[CONFIG] %s: set from %s to %i\n",cfgoption->optname, *(cfgoption->strptr), ret); + printf_params("[CONFIG] %s: set from %s to %i\n",cfgoption->optname, *cfgoption->strptr, ret); } else { fprintf (stderr,"[CONFIG] %s %d %s has no processed integer availablle\n",__FILE__, __LINE__, cfgoption->optname); ret=0; @@ -344,7 +380,7 @@ int config_check_intrange(paramdef_t *param) { void print_strvalueerror(paramdef_t *param, char *fname, char **okval, int numokval) { fprintf(stderr,"[CONFIG] %s: %s: %s invalid value, authorized values:\n ", - fname,param->optname, *(param->strptr)); + fname,param->optname, *param->strptr); for ( int i=0; ichkPptr->s3.num_okstrval ; i++) { - if( strcasecmp(*(param->strptr),param->chkPptr->s3.okstrval[i] ) == 0) { + if( strcasecmp(*param->strptr,param->chkPptr->s3.okstrval[i] ) == 0) { return 0; } } @@ -371,7 +407,7 @@ int config_check_strval(paramdef_t *param) { int config_checkstr_assign_integer(paramdef_t *param) { for (int i=0; i < param->chkPptr->s3a.num_okstrval ; i++) { - if (strcasecmp(*(param->strptr),param->chkPptr->s3a.okstrval[i] ) == 0) { + if (strcasecmp(*param->strptr,param->chkPptr->s3a.okstrval[i] ) == 0) { config_assign_processedint(param, param->chkPptr->s3a.setintval[i]); return 0; } @@ -393,14 +429,14 @@ int config_setdefault_string(paramdef_t *cfgoptions, char *prefix) { if( cfgoptions->defstrval != NULL) { status=1; - if (cfgoptions->numelt == 0 ) { - config_check_valptr(cfgoptions, cfgoptions->strptr, strlen(cfgoptions->defstrval)+1); - sprintf(*(cfgoptions->strptr), "%s",cfgoptions->defstrval); - printf_params("[CONFIG] %s.%s set to default value \"%s\"\n", ((prefix == NULL) ? "" : prefix), cfgoptions->optname, *(cfgoptions->strptr)); - } else { - sprintf((char *)(cfgoptions->strptr), "%s",cfgoptions->defstrval); - printf_params("[CONFIG] %s.%s set to default value \"%s\"\n", ((prefix == NULL) ? "" : prefix), cfgoptions->optname, (char *)(cfgoptions->strptr)); + if (cfgoptions->numelt == 0 ) + config_check_valptr(cfgoptions, 1, strlen(cfgoptions->defstrval)+1); + if ( cfgoptions->numelt < strlen(cfgoptions->defstrval)+1 ) { + CONFIG_PRINTF_ERROR("[CONFIG] %s size too small\n", cfgoptions->optname); } + snprintf(*cfgoptions->strptr, cfgoptions->numelt, "%s",cfgoptions->defstrval); + printf_params("[CONFIG] %s.%s set to default value \"%s\"\n", ((prefix == NULL) ? "" : prefix), cfgoptions->optname, *cfgoptions->strptr); + } return status; @@ -422,7 +458,7 @@ int config_setdefault_stringlist(paramdef_t *cfgoptions, char *prefix) { int config_setdefault_int(paramdef_t *cfgoptions, char *prefix) { int status = 0; - config_check_valptr(cfgoptions, (char **)(&(cfgoptions->iptr)),sizeof(int32_t)); + config_check_valptr(cfgoptions, sizeof(*cfgoptions->iptr), 1); if( ((cfgoptions->paramflags & PARAMFLAG_MANDATORY) == 0)) { config_assign_int(cfgoptions,cfgoptions->optname,cfgoptions->defintval); @@ -435,7 +471,7 @@ int config_setdefault_int(paramdef_t *cfgoptions, char *prefix) { int config_setdefault_int64(paramdef_t *cfgoptions, char *prefix) { int status = 0; - config_check_valptr(cfgoptions, (char **)&(cfgoptions->i64ptr),sizeof(long long)); + config_check_valptr(cfgoptions, sizeof(*cfgoptions->i64ptr), 1); if( ((cfgoptions->paramflags & PARAMFLAG_MANDATORY) == 0)) { *(cfgoptions->u64ptr)=cfgoptions->defuintval; @@ -450,7 +486,7 @@ int config_setdefault_intlist(paramdef_t *cfgoptions, char *prefix) { int status = 0; if( cfgoptions->defintarrayval != NULL) { - config_check_valptr(cfgoptions,(char **)&(cfgoptions->iptr), sizeof(int32_t *)); + config_check_valptr(cfgoptions, sizeof(cfgoptions->iptr), cfgoptions->numelt); cfgoptions->iptr=cfgoptions->defintarrayval; status=1; @@ -464,7 +500,7 @@ int config_setdefault_intlist(paramdef_t *cfgoptions, char *prefix) { int config_setdefault_double(paramdef_t *cfgoptions, char *prefix) { int status = 0; - config_check_valptr(cfgoptions, (char **)&(cfgoptions->dblptr),sizeof(double)); + config_check_valptr(cfgoptions, sizeof(*cfgoptions->dblptr), 1); if( ((cfgoptions->paramflags & PARAMFLAG_MANDATORY) == 0)) { *(cfgoptions->dblptr)=cfgoptions->defdblval; @@ -476,7 +512,7 @@ int config_setdefault_double(paramdef_t *cfgoptions, char *prefix) { } int config_assign_ipv4addr(paramdef_t *cfgoptions, char *ipv4addr) { - config_check_valptr(cfgoptions,(char **)&(cfgoptions->uptr), sizeof(int)); + config_check_valptr(cfgoptions, sizeof(*cfgoptions->uptr), 1); int rst=inet_pton(AF_INET, ipv4addr,cfgoptions->uptr ); if (rst == 1 && *(cfgoptions->uptr) > 0) { diff --git a/common/config/config_userapi.h b/common/config/config_userapi.h index c00526aa4c..c5005e4e25 100644 --- a/common/config/config_userapi.h +++ b/common/config/config_userapi.h @@ -51,7 +51,7 @@ extern int config_paramidx_fromname(paramdef_t *params,int numparams, char *name /* utility functions, to be used by configuration module and/or configuration libraries */ extern configmodule_interface_t *config_get_if(void); -extern char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) ; + void config_check_valptr(paramdef_t *cfgoptions, int elt_sz, int nb_elt); extern void config_printhelp(paramdef_t *,int numparams, char *prefix); extern int config_process_cmdline(paramdef_t *params,int numparams, char *prefix); extern void config_assign_processedint(paramdef_t *cfgoption, int val); @@ -86,7 +86,7 @@ extern int config_setdefault_int64(paramdef_t *cfgoptions, char *prefix); extern int config_setdefault_intlist(paramdef_t *cfgoptions, char *prefix); extern int config_setdefault_double(paramdef_t *cfgoptions, char *prefix); extern int config_setdefault_ipv4addr(paramdef_t *cfgoptions, char *prefix); - + void *config_allocate_new(int sz, bool autoFree); #define CONFIG_GETCONFFILE (config_get_if()->cfgP[0]) #ifdef __cplusplus diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index 48893fb5be..52faaaeb46 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -29,6 +29,7 @@ * \warning */ #define _GNU_SOURCE +#include #include #include @@ -41,6 +42,7 @@ #include "config_libconfig_private.h" #include "../config_userapi.h" #include "errno.h" +#include "assertions.h" #if ( LIBCONFIG_VER_MAJOR == 1 && LIBCONFIG_VER_MINOR < 5) #define config_setting_lookup config_lookup_from @@ -53,17 +55,16 @@ int read_strlist(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpath int st; int numelt; numelt=config_setting_length(setting); - config_check_valptr(cfgoptions,(char **)&(cfgoptions->strlistptr), sizeof(char *) * numelt); + config_check_valptr(cfgoptions, sizeof(char *), numelt); st=0; - + AssertFatal(MAX_LIST_SIZE > numelt, ""); for (int i=0; i< numelt ; i++) { str=config_setting_get_string_elem(setting,i); if (str==NULL) { printf("[LIBCONFIG] %s%i not found in config file\n", cfgoptions->optname,i); } else { - config_check_valptr(cfgoptions,&(cfgoptions->strlistptr[i]),strlen(str)+1); - sprintf(cfgoptions->strlistptr[i],"%s",str); + snprintf(cfgoptions->strlistptr[i], DEFAULT_EXTRA_SZ, "%s",str); st++; printf_params("[LIBCONFIG] %s%i: %s\n", cfgpath,i,cfgoptions->strlistptr[i]); } @@ -77,7 +78,8 @@ int read_intarray(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpat cfgoptions->numelt=config_setting_length(setting); if (cfgoptions->numelt > 0) { - cfgoptions->iptr=malloc(sizeof(int) * (cfgoptions->numelt)); + cfgoptions->iptr=config_allocate_new(cfgoptions->numelt*sizeof(*cfgoptions->iptr), + !(cfgoptions->paramflags & PARAMFLAG_NOFREE) ); for (int i=0; i< cfgoptions->numelt && cfgoptions->iptr != NULL; i++) { cfgoptions->iptr[i]=config_setting_get_int_elem(setting,i); @@ -123,23 +125,14 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { switch(cfgoptions[i].type) { case TYPE_STRING: if ( config_lookup_string(&(libconfig_privdata.cfg), cfgpath, (const char**)&str)) { - if ( cfgoptions[i].numelt > 0 && str != NULL && strlen(str) >= cfgoptions[i].numelt ) { + config_check_valptr(&(cfgoptions[i]), 1, strlen(str)+1); + if ( strlen(str)+1 > cfgoptions[i].numelt ) fprintf(stderr,"[LIBCONFIG] %s: %s exceeds maximum length of %i bytes, value truncated\n", cfgpath,str,cfgoptions[i].numelt); - str[strlen(str)-1] = 0; - } - - if (cfgoptions[i].numelt == 0 ) { - // config_check_valptr(&(cfgoptions[i]), (char **)(&(cfgoptions[i].strptr)), sizeof(char *)); - config_check_valptr(&(cfgoptions[i]), cfgoptions[i].strptr, strlen(str)+1); - sprintf( *(cfgoptions[i].strptr) , "%s", str); - printf_params("[LIBCONFIG] %s: \"%s\"\n", cfgpath,*(cfgoptions[i].strptr) ); - } else { - sprintf( (char *)(cfgoptions[i].strptr) , "%s", str); - printf_params("[LIBCONFIG] %s: \"%s\"\n", cfgpath,(char *)cfgoptions[i].strptr ); - } + snprintf( *cfgoptions[i].strptr , cfgoptions[i].numelt, "%s", str); + printf_params("[LIBCONFIG] %s: \"%s\"\n", cfgpath, *cfgoptions[i].strptr); } else { - defval=config_setdefault_string(&(cfgoptions[i]),prefix); + defval=config_setdefault_string(&cfgoptions[i],prefix); } break; @@ -163,7 +156,7 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { case TYPE_INT32: case TYPE_MASK: if ( config_lookup_int(&(libconfig_privdata.cfg),cfgpath, &u)) { - config_check_valptr(&(cfgoptions[i]), (char **)(&(cfgoptions[i].iptr)),sizeof(int32_t)); + config_check_valptr(&(cfgoptions[i]), sizeof(*cfgoptions[i].iptr), 1); config_assign_int(&(cfgoptions[i]),cfgpath,u); } else { defval=config_setdefault_int(&(cfgoptions[i]),prefix); @@ -174,14 +167,14 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { case TYPE_UINT64: case TYPE_INT64: if ( config_lookup_int64(&(libconfig_privdata.cfg),cfgpath, &llu)) { - config_check_valptr(&(cfgoptions[i]), (char **)&(cfgoptions[i].i64ptr),sizeof(long long)); + config_check_valptr(&cfgoptions[i], sizeof(*cfgoptions[i].i64ptr), 1); if(cfgoptions[i].type==TYPE_UINT64) { *(cfgoptions[i].u64ptr) = (uint64_t)llu; - printf_params("[LIBCONFIG] %s: %llu\n", cfgpath,(long long unsigned)(*(cfgoptions[i].u64ptr)) ); + printf_params("[LIBCONFIG] %s: %lu\n", cfgpath,*cfgoptions[i].u64ptr); } else { *(cfgoptions[i].i64ptr) = llu; - printf_params("[LIBCONFIG] %s: %lld\n", cfgpath,(long long)(*(cfgoptions[i].i64ptr)) ); + printf_params("[LIBCONFIG] %s: %ld\n", cfgpath,*cfgoptions[i].i64ptr); } } else { defval=config_setdefault_int64(&(cfgoptions[i]),prefix); @@ -203,8 +196,8 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { case TYPE_DOUBLE: if ( config_lookup_float(&(libconfig_privdata.cfg),cfgpath, &dbl)) { - config_check_valptr(&(cfgoptions[i]), (char **)&(cfgoptions[i].dblptr),sizeof(double)); - *(cfgoptions[i].dblptr) = dbl; + config_check_valptr(&cfgoptions[i],sizeof(*cfgoptions[i].dblptr), 1); + *cfgoptions[i].dblptr = dbl; printf_params("[LIBCONFIG] %s: %lf\n", cfgpath,*(cfgoptions[i].dblptr) ); } else { defval=config_setdefault_double(&(cfgoptions[i]),prefix); @@ -304,27 +297,10 @@ int config_libconfig_getlist(paramlist_def_t *ParamList, } if (ParamList->numelt > 0 && params != NULL) { - ParamList->paramarray = malloc(ParamList->numelt * sizeof(paramdef_t *)); - - if ( ParamList->paramarray != NULL) { - config_get_if()->ptrs[config_get_if()->numptrs] = (char *)(ParamList->paramarray); - config_get_if()->numptrs++; - } else { - fprintf (stderr,"[LIBCONFIG] %s %d malloc error\n",__FILE__, __LINE__); - exit(-1); - } + ParamList->paramarray = config_allocate_new(ParamList->numelt * sizeof(paramdef_t *), true); for (i=0 ; i < ParamList->numelt ; i++) { - ParamList->paramarray[i] = malloc(numparams * sizeof(paramdef_t)); - - if ( ParamList->paramarray[i] != NULL) { - config_get_if()->ptrs[config_get_if()->numptrs] = (char *)(ParamList->paramarray[i]); - config_get_if()->numptrs++; - } else { - fprintf (stderr,"[LIBCONFIG] %s %d malloc error\n",__FILE__, __LINE__); - exit(-1); - } - + ParamList->paramarray[i] = config_allocate_new(numparams * sizeof(paramdef_t), true); memcpy(ParamList->paramarray[i], params, sizeof(paramdef_t)*numparams); for (j=0; jnumptrs=0; - memset(config_get_if()->ptrs,0,sizeof(void *) * CONFIG_MAX_ALLOCATEDPTRS); - memset(config_get_if()->ptrsAllocated, 0, sizeof(config_get_if()->ptrsAllocated)); + pthread_mutex_init(&config_get_if()->memBlocks_mutex, NULL); + memset(config_get_if()->oneBlock,0,sizeof(config_get_if()->oneBlock)); /* search for include path parameter and set config file include path accordingly */ for (int i=0; iimsiStr), defstrval:"2089900007487", TYPE_STRING, 0 },\ - {"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\ - {"key", "USIM Ki\n", 0, strptr:&(uicc->keyStr), defstrval:"fec86ba6eb707ed08905757b1bb44b8f", TYPE_STRING, 0 },\ - {"opc", "USIM OPc\n", 0, strptr:&(uicc->opcStr), defstrval:"c42449363bbad02b66d16bc975d77cc1", TYPE_STRING, 0 },\ - {"amf", "USIM amf\n", 0, strptr:&(uicc->amfStr), defstrval:"8000", TYPE_STRING, 0 },\ - {"sqn", "USIM sqn\n", 0, strptr:&(uicc->sqnStr), defstrval:"000000", TYPE_STRING, 0 },\ - {"dnn", "UE dnn (apn)\n", 0, strptr:&(uicc->dnnStr), defstrval:"oai", TYPE_STRING, 0 },\ - {"nssai_sst", "UE nssai\n", 0, iptr:&(uicc->nssai_sst), defintval:1, TYPE_INT, 0 }, \ - {"nssai_sd", "UE nssai\n", 0, iptr:&(uicc->nssai_sd), defintval:1, TYPE_INT, 0 }, \ - }; -``` - For interoperability with OAI or other CNs, it should be ensured that the configuration of the aforementioned parameters match the configuration of the corresponding subscribed user at the core network. diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index 98087ea2bb..fa51b62b35 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -29,7 +29,7 @@ {"D" , CONFIG_HLP_DLBM_PHYTEST,0, u64ptr:&dlsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \ {"U" , CONFIG_HLP_ULBM_PHYTEST,0, u64ptr:&ulsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \ {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \ - {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:(char **)&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ + {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ } diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 995d81f19c..c118db5483 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -29,15 +29,15 @@ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*------------------------------------------------------------------------------------------------------------------------------------------*/ #define CMDLINE_NRUEPARAMS_DESC { \ - {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200", TYPE_STRING, 0}, \ + {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:&usrp_args, defstrval:"type=b200", TYPE_STRING, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, u8ptr:&nrUE_params.nr_dlsch_parallel, defintval:0, TYPE_UINT8, 0}, \ {"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, uptr:&nrUE_params.ofdm_offset_divisor, defuintval:8, TYPE_UINT32, 0}, \ {"max-ldpc-iterations", CONFIG_HLP_MAX_LDPC_ITERATIONS, 0, u8ptr:&nrUE_params.max_ldpc_iterations, defuintval:5, TYPE_UINT8, 0}, \ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ - {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:(char **)&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ - {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0}, \ + {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ + {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:&rrc_config_path, defstrval:"./", TYPE_STRING, 0}, \ {"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0} \ } diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index a2ba680234..591eee9c56 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -137,9 +137,9 @@ extern "C" extern int usrp_tx_thread; #define CMDLINE_PARAMS_DESC { \ - {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, sizeof(RF_CONFIG_FILE)},\ - {"split73", CONFIG_HLP_SPLIT73, 0, strptr:(char **)&SPLIT73, defstrval:NULL, TYPE_STRING, sizeof(SPLIT73)}, \ - {"thread-pool", CONFIG_HLP_TPOOL, 0, strptr:(char **)&TP_CONFIG, defstrval:"n", TYPE_STRING, sizeof(TP_CONFIG)}, \ + {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, 0},\ + {"split73", CONFIG_HLP_SPLIT73, 0, strptr:&SPLIT73, defstrval:NULL, TYPE_STRING, 0}, \ + {"thread-pool", CONFIG_HLP_TPOOL, 0, strptr:&TP_CONFIG, defstrval:"n", TYPE_STRING, 0}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&PHY_TEST, defintval:0, TYPE_INT, 0}, \ {"do-ra", CONFIG_HLP_DORA, PARAMFLAG_BOOL, iptr:&DO_RA, defintval:0, TYPE_INT, 0}, \ {"sa", CONFIG_HLP_SA, PARAMFLAG_BOOL, iptr:&SA, defintval:0, TYPE_INT, 0}, \ @@ -157,8 +157,8 @@ extern int usrp_tx_thread; {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&NUMEROLOGY, defintval:1, TYPE_INT, 0}, \ {"band" , CONFIG_HLP_BAND, PARAMFLAG_BOOL, iptr:&BAND, defintval:78, TYPE_INT, 0}, \ {"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&EMULATE_RF, defintval:0, TYPE_INT, 0}, \ - {"parallel-config", CONFIG_HLP_PARALLEL_CMD, 0, strptr:(char **)¶llel_config, defstrval:NULL, TYPE_STRING, 0}, \ - {"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:(char **)&worker_config, defstrval:NULL, TYPE_STRING, 0}, \ + {"parallel-config", CONFIG_HLP_PARALLEL_CMD, 0, strptr:¶llel_config, defstrval:NULL, TYPE_STRING, 0}, \ + {"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:&worker_config, defstrval:NULL, TYPE_STRING, 0}, \ {"noS1", CONFIG_HLP_NOS1, PARAMFLAG_BOOL, uptr:&noS1, defintval:0, TYPE_INT, 0}, \ {"rfsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, uptr:&rfsim, defintval:0, TYPE_INT, 0}, \ {"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0}, \ @@ -189,7 +189,7 @@ extern int usrp_tx_thread; {CONFIG_FLOG_OPT , CONFIG_HLP_FLOG, 0, uptr:&online_log_messages, defintval:1, TYPE_INT, 0}, \ {CONFIG_LOGL_OPT , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \ {"telnetsrv", CONFIG_HLP_TELN, PARAMFLAG_BOOL, uptr:&start_telnetsrv, defintval:0, TYPE_UINT, 0}, \ - {"log-mem", NULL, 0, strptr:(char **)&logmem_filename, defstrval:NULL, TYPE_STRING, 0}, \ + {"log-mem", NULL, 0, strptr:&logmem_filename, defstrval:NULL, TYPE_STRING, 0}, \ {"telnetclt", NULL, 0, uptr:&start_telnetclt, defstrval:NULL, TYPE_UINT, 0}, \ } @@ -242,9 +242,9 @@ extern int usrp_tx_thread; typedef struct { uint64_t optmask; //THREAD_STRUCT thread_struct; - char rf_config_file[1024]; - char split73[1024]; - char threadPoolConfig[1024]; + char *rf_config_file; + char *split73; + char *threadPoolConfig; int phy_test; int do_ra; int sa; diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index 0f6b8fb1bc..5884348a78 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -62,7 +62,7 @@ static double snr_dB=25; static double sinr_dB=0; static unsigned int max_chan; static channel_desc_t **defined_channels; -static char modellist_name[MAX_OPTNAME_SIZE]= {0}; +static char *modellist_name; void fill_channel_desc(channel_desc_t *chan_desc, diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index f12483d70a..64842cfa63 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -253,7 +253,7 @@ typedef enum { {"s" , CONFIG_HLP_SNR, PARAMFLAG_CMDLINE_NOPREFIXENABLED, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0},\ {"sinr_dB", NULL, 0, dblptr:&sinr_dB, defdblval:0 , TYPE_DOUBLE, 0},\ {"max_chan", "Max number of runtime models", 0, uptr:&max_chan, defintval:10, TYPE_UINT, 0},\ - {CHANNELMOD_MODELLIST_PARANAME, CHANNELMOD_HELP_MODELLIST, 0, strptr:(char **)&modellist_name, defstrval:"DefaultChannelList", TYPE_STRING, 60 },\ + {CHANNELMOD_MODELLIST_PARANAME, CHANNELMOD_HELP_MODELLIST, 0, strptr:&modellist_name, defstrval:"DefaultChannelList", TYPE_STRING, 0},\ } /* parameters for one model */ diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 00ffd4cc13..bce15f9050 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -323,7 +323,7 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { srb1_params_t srb1_params; memset((void *)&srb1_params,0,sizeof(srb1_params_t)); paramdef_t SRB1Params[] = SRB1PARAMS_DESC(srb1_params); - paramdef_t SLParams[] = CCPARAMS_SIDELINK_DESC(SLconfig); + paramdef_t SLParams[] = CCPARAMS_SIDELINK_DESC(SLconfig); /* map parameter checking array instances to parameter definition array instances */ for (int I=0; I< ( sizeof(CCsParams)/ sizeof(paramdef_t) ) ; I++) { @@ -2860,9 +2860,9 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[ENB_PORT_FOR_X2C_IDX].uptr); if ((NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) { - LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n"); - exit(1); - } + LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n"); + exit(1); + } cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr); address = strtok(cidr, "/"); diff --git a/openair2/ENB_APP/enb_paramdef_emtc.h b/openair2/ENB_APP/enb_paramdef_emtc.h index 928c9d22e3..d805737340 100644 --- a/openair2/ENB_APP/enb_paramdef_emtc.h +++ b/openair2/ENB_APP/enb_paramdef_emtc.h @@ -220,7 +220,7 @@ typedef struct ccparams_eMTC_s { {ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE, NULL, 0, iptr:&eMTCconfig->ccparams.pcch_defaultPagingCycle, defintval:128, TYPE_INT, 0}, \ {ENB_CONFIG_STRING_PCCH_NB, NULL, 0, strptr:&eMTCconfig->ccparams.pcch_nB, defstrval:"oneT", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF, NULL, 0, iptr:&eMTCconfig->ccparams.bcch_modificationPeriodCoeff, defintval:2, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG, NULL, 0, strptr:&eMTCconfig->ccparams.rach_preamblesGroupAConfig, defstrval:"", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG, NULL, 0, strptr:&eMTCconfig->ccparams.rach_preamblesGroupAConfig, defstrval:"DISABLE", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_UETIMERS_T300, NULL, 0, iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t300, defintval:1000, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_UETIMERS_T301, NULL, 0, iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t301, defintval:1000, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_UETIMERS_T310, NULL, 0, iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t310, defintval:1000, TYPE_UINT, 0}, \ diff --git a/openair2/ENB_APP/enb_paramdef_sidelink.h b/openair2/ENB_APP/enb_paramdef_sidelink.h index dd3aa5f0fb..98a3a56eaa 100644 --- a/openair2/ENB_APP/enb_paramdef_sidelink.h +++ b/openair2/ENB_APP/enb_paramdef_sidelink.h @@ -119,15 +119,15 @@ typedef struct ccparams_sidelink_s { libconfig_int discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused; //For discRxPoolPS char *discRxPoolPS_cp_Len; - const char *discRxPoolPS_discPeriod; + char *discRxPoolPS_discPeriod; libconfig_int discRxPoolPS_numRetx; libconfig_int discRxPoolPS_numRepetition; libconfig_int discRxPoolPS_ResourceConfig_prb_Num; libconfig_int discRxPoolPS_ResourceConfig_prb_Start; libconfig_int discRxPoolPS_ResourceConfig_prb_End; - const char *discRxPoolPS_ResourceConfig_offsetIndicator_present; + char *discRxPoolPS_ResourceConfig_offsetIndicator_present; libconfig_int discRxPoolPS_ResourceConfig_offsetIndicator_choice; - const char *discRxPoolPS_ResourceConfig_subframeBitmap_present; + char *discRxPoolPS_ResourceConfig_subframeBitmap_present; char *discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf; libconfig_int discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size; libconfig_int discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused; @@ -139,44 +139,44 @@ typedef struct ccparams_sidelink_s { /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CCPARAMS_SIDELINK_DESC(SLparams) { \ -{"sidelink_configured", NULL, 0, iptr:(int*)&SLparams.sidelink_configured, defintval:0, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_SC_CP_LEN, NULL, 0, strptr:(char **)&SLparams.rxPool_sc_CP_Len, defstrval:"normal", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_SC_PRIOD, NULL, 0, strptr:(char **)&SLparams.rxPool_sc_Period, defstrval:"sf40", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_DATA_CP_LEN, NULL, 0, strptr:(char **)&SLparams.rxPool_data_CP_Len, defstrval:"normal", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_RC_PRB_NUM, NULL, 0, iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_prb_Num, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_RC_PRB_START, NULL, 0, iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_prb_Start, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_RC_PRB_END, NULL, 0, iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_prb_End, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_PRESENT, NULL, 0, strptr:(char **)&SLparams.rxPool_ResourceConfig_offsetIndicator_present, defstrval:"prNothing", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_CHOICE, NULL, 0, iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_offsetIndicator_choice, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_PRESENT, NULL, 0, strptr:(char **)&SLparams.rxPool_ResourceConfig_subframeBitmap_present, defstrval:"prNothing", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_BUF, NULL, 0, strptr:(char **)&SLparams.rxPool_ResourceConfig_subframeBitmap_choice_bs_buf, defstrval:"001001", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE, NULL, 0, iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_subframeBitmap_choice_bs_size, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED, NULL, 0, iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_CP_LEN, NULL, 0, strptr:(char **)&SLparams.discRxPool_cp_Len, defstrval:"normal", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_DISCPERIOD, NULL, 0, strptr:(char **)&SLparams.discRxPool_discPeriod, defstrval:"rf32", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_NUMRETX, NULL, 0, iptr:(int32_t *)&SLparams.discRxPool_numRetx, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_NUMREPETITION, NULL, 0, iptr:(int32_t *)&SLparams.discRxPool_numRepetition, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_NUM, NULL, 0, iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_prb_Num, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_START, NULL, 0, iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_prb_Start, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_END, NULL, 0, iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_prb_End, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_PRESENT, NULL, 0, strptr:(char **)&SLparams.discRxPool_ResourceConfig_offsetIndicator_present, defstrval:"prNothing", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_CHOICE, NULL, 0, iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_offsetIndicator_choice, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_PRESENT, NULL, 0, strptr:(char **)&SLparams.discRxPool_ResourceConfig_subframeBitmap_present, defstrval:"prNothing", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_BUF, NULL, 0, strptr:(char **)&SLparams.discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf, defstrval:"001001", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE, NULL, 0, iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_subframeBitmap_choice_bs_size, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL, 0, iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_CP_LEN, NULL, 0, strptr:(char **)&SLparams.discRxPoolPS_cp_Len, defstrval:"normal", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_DISCPERIOD, NULL, 0, strptr:(char **)&SLparams.discRxPoolPS_discPeriod, defstrval:"rf32", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMRETX, NULL, 0, iptr:(int32_t *)&SLparams.discRxPoolPS_numRetx, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMREPETITION, NULL, 0, iptr:(int32_t *)&SLparams.discRxPoolPS_numRepetition, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_NUM, NULL, 0, iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_prb_Num, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_START, NULL, 0, iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_prb_Start, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_END, NULL, 0, iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_prb_End, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_PRESENT, NULL, 0, strptr:(char **)&SLparams.discRxPoolPS_ResourceConfig_offsetIndicator_present, defstrval:"prNothing", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_CHOICE, NULL, 0, iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_offsetIndicator_choice, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_PRESENT, NULL, 0, strptr:(char **)&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_present, defstrval:"prNothing", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_BUF, NULL, 0, strptr:(char **)&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf, defstrval:"001001", TYPE_STRING, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_SIZE, NULL, 0, iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL, 0, iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused, defintval:1, TYPE_UINT, 0} \ +{"sidelink_configured", NULL, 0, iptr:&SLparams.sidelink_configured, defintval:0, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_SC_CP_LEN, NULL, 0, strptr:&SLparams.rxPool_sc_CP_Len, defstrval:"normal", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_SC_PRIOD, NULL, 0, strptr:&SLparams.rxPool_sc_Period, defstrval:"sf40", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_DATA_CP_LEN, NULL, 0, strptr:&SLparams.rxPool_data_CP_Len, defstrval:"normal", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_PRB_NUM, NULL, 0, iptr:&SLparams.rxPool_ResourceConfig_prb_Num, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_PRB_START, NULL, 0, iptr:&SLparams.rxPool_ResourceConfig_prb_Start, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_PRB_END, NULL, 0, iptr:&SLparams.rxPool_ResourceConfig_prb_End, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_PRESENT, NULL, 0, strptr:&SLparams.rxPool_ResourceConfig_offsetIndicator_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_CHOICE, NULL, 0, iptr:&SLparams.rxPool_ResourceConfig_offsetIndicator_choice, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_PRESENT, NULL, 0, strptr:&SLparams.rxPool_ResourceConfig_subframeBitmap_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_BUF, NULL, 0, strptr:&SLparams.rxPool_ResourceConfig_subframeBitmap_choice_bs_buf, defstrval:"001001", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE, NULL, 0, iptr:&SLparams.rxPool_ResourceConfig_subframeBitmap_choice_bs_size, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED, NULL, 0, iptr:&SLparams.rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_CP_LEN, NULL, 0, strptr:&SLparams.discRxPool_cp_Len, defstrval:"normal", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_DISCPERIOD, NULL, 0, strptr:&SLparams.discRxPool_discPeriod, defstrval:"rf32", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_NUMRETX, NULL, 0, iptr:&SLparams.discRxPool_numRetx, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_NUMREPETITION, NULL, 0, iptr:&SLparams.discRxPool_numRepetition, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_NUM, NULL, 0, iptr:&SLparams.discRxPool_ResourceConfig_prb_Num, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_START, NULL, 0, iptr:&SLparams.discRxPool_ResourceConfig_prb_Start, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_END, NULL, 0, iptr:&SLparams.discRxPool_ResourceConfig_prb_End, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_PRESENT, NULL, 0, strptr:&SLparams.discRxPool_ResourceConfig_offsetIndicator_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_CHOICE, NULL, 0, iptr:&SLparams.discRxPool_ResourceConfig_offsetIndicator_choice, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_PRESENT, NULL, 0, strptr:&SLparams.discRxPool_ResourceConfig_subframeBitmap_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_BUF, NULL, 0, strptr:&SLparams.discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf, defstrval:"001001", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE, NULL, 0, iptr:&SLparams.discRxPool_ResourceConfig_subframeBitmap_choice_bs_size, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL, 0, iptr:&SLparams.discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_CP_LEN, NULL, 0, strptr:&SLparams.discRxPoolPS_cp_Len, defstrval:"normal", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_DISCPERIOD, NULL, 0, strptr:&SLparams.discRxPoolPS_discPeriod, defstrval:"rf32", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMRETX, NULL, 0, iptr:&SLparams.discRxPoolPS_numRetx, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMREPETITION, NULL, 0, iptr:&SLparams.discRxPoolPS_numRepetition, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_NUM, NULL, 0, iptr:&SLparams.discRxPoolPS_ResourceConfig_prb_Num, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_START, NULL, 0, iptr:&SLparams.discRxPoolPS_ResourceConfig_prb_Start, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_END, NULL, 0, iptr:&SLparams.discRxPoolPS_ResourceConfig_prb_End, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_PRESENT, NULL, 0, strptr:&SLparams.discRxPoolPS_ResourceConfig_offsetIndicator_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_CHOICE, NULL, 0, iptr:&SLparams.discRxPoolPS_ResourceConfig_offsetIndicator_choice, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_PRESENT, NULL, 0, strptr:&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_BUF, NULL, 0, strptr:&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf, defstrval:"001001", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_SIZE, NULL, 0, iptr:&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL, 0, iptr:&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused, defintval:1, TYPE_UINT, 0} \ } #endif diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 8c1abf4561..9948df1eff 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -238,8 +238,8 @@ void mac_top_init_gNB(ngran_node_t node_type) RC.nrmac[i]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(i, 0); } if (!IS_SOFTMODEM_NOSTATS_BIT) - pthread_create(&RC.nrmac[i]->stats_thread, NULL, nrmac_stats_thread, (void*)RC.nrmac[i]); + threadCreate(&RC.nrmac[i]->stats_thread, nrmac_stats_thread, (void*)RC.nrmac[i], "MAC_STATS", -1, sched_get_priority_min(SCHED_OAI)+1 ); mac_rrc_init(RC.nrmac[i], node_type); }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 31ca8f9eb8..3bd30d2670 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -56,7 +56,9 @@ char *broadcastAddr ; #define NASHLP_NETMASK "\n" #define NASHLP_BROADCASTADDR "\n" void nas_getparams(void) { - paramdef_t nasoptions[] = { + // this datamodel require this static because we partially keep data like baseNetAddress (malloc on a global) + // but we loose the opther attributes in nasoptions between two calls if is is not static ! + static paramdef_t nasoptions[] = { /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* configuration parameters for netlink, includes network parameters when running in noS1 mode */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ diff --git a/openair2/UTIL/OPT/opt.h b/openair2/UTIL/OPT/opt.h index d08790a058..40b704b6c5 100644 --- a/openair2/UTIL/OPT/opt.h +++ b/openair2/UTIL/OPT/opt.h @@ -74,9 +74,9 @@ typedef guint8 gboolean; /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*---------------------------------------------------------------------------------------------------------------------------------------------*/ #define OPT_PARAMS_DESC { \ - {"type" , CONFIG_HLP_TYPEMON, 0, strptr:(char**)&in_type, defstrval:"none", TYPE_STRING, 0}, \ - {"ip" , CONFIG_HLP_L2MONIP, 0, strptr:(char**)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ - {"path" , CONFIG_HLP_L2MONPATH, 0, strptr:(char**)&in_path,defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, 0}, \ + {"type" , CONFIG_HLP_TYPEMON, 0, strptr:&in_type, defstrval:"none", TYPE_STRING, 0}, \ + {"ip" , CONFIG_HLP_L2MONIP, 0, strptr:&in_ip, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ + {"path" , CONFIG_HLP_L2MONPATH, 0, strptr:&in_path,defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, 0}, \ } #define OPTTYPE_IDX 0 diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index 9359c48e95..e682dc0484 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -540,9 +540,6 @@ void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsign /*---------------------------------------------------*/ int init_opt(void) { - in_type=malloc(200); - in_ip=malloc(200); - in_path=malloc(200); paramdef_t opt_params[] = OPT_PARAMS_DESC ; checkedparam_t opt_checkParams[] = OPTPARAMS_CHECK_DESC; config_set_checkfunctions(opt_params, opt_checkParams, diff --git a/openair3/UICC/usim_interface.c b/openair3/UICC/usim_interface.c index 5d04f88285..9d6e7c6ccb 100644 --- a/openair3/UICC/usim_interface.c +++ b/openair3/UICC/usim_interface.c @@ -35,16 +35,16 @@ extern uint16_t NB_UE_INST; /* configuration parameters for the rfsimulator device */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define UICC_PARAMS_DESC {\ - {"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsiStr), defstrval:"2089900007487", TYPE_STRING, 0 },\ - {"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\ - {"key", "USIM Ki\n", 0, strptr:&(uicc->keyStr), defstrval:"fec86ba6eb707ed08905757b1bb44b8f", TYPE_STRING, 0 },\ - {"opc", "USIM OPc\n", 0, strptr:&(uicc->opcStr), defstrval:"c42449363bbad02b66d16bc975d77cc1", TYPE_STRING, 0 },\ - {"amf", "USIM amf\n", 0, strptr:&(uicc->amfStr), defstrval:"8000", TYPE_STRING, 0 },\ - {"sqn", "USIM sqn\n", 0, strptr:&(uicc->sqnStr), defstrval:"000000", TYPE_STRING, 0 },\ - {"dnn", "UE dnn (apn)\n", 0, strptr:&(uicc->dnnStr), defstrval:"oai", TYPE_STRING, 0 },\ - {"nssai_sst", "UE nssai\n", 0, iptr:&(uicc->nssai_sst), defintval:1, TYPE_INT, 0 }, \ - {"nssai_sd", "UE nssai\n", 0, iptr:&(uicc->nssai_sd), defintval:1, TYPE_INT, 0 }, \ +#define UICC_PARAMS_DESC { \ + {"imsi", "USIM IMSI\n", 0, strptr:&uicc->imsiStr, defstrval:"2089900007487", TYPE_STRING, 0 }, \ + {"nmc_size" "number of digits in NMC", 0, iptr:&uicc->nmc_size, defintval:2, TYPE_INT, 0 }, \ + {"key", "USIM Ki\n", 0, strptr:&uicc->keyStr, defstrval:"fec86ba6eb707ed08905757b1bb44b8f", TYPE_STRING, 0 }, \ + {"opc", "USIM OPc\n", 0, strptr:&uicc->opcStr, defstrval:"c42449363bbad02b66d16bc975d77cc1", TYPE_STRING, 0 }, \ + {"amf", "USIM amf\n", 0, strptr:&uicc->amfStr, defstrval:"8000", TYPE_STRING, 0 }, \ + {"sqn", "USIM sqn\n", 0, strptr:&uicc->sqnStr, defstrval:"000000", TYPE_STRING, 0 }, \ + {"dnn", "UE dnn (apn)\n", 0, strptr:&uicc->dnnStr, defstrval:"oai", TYPE_STRING, 0 }, \ + {"nssai_sst", "UE nssai\n", 0, iptr:&uicc->nssai_sst, defintval:1, TYPE_INT, 0 }, \ + {"nssai_sd", "UE nssai\n", 0, iptr:&uicc->nssai_sd, defintval:1, TYPE_INT, 0 }, \ }; static uicc_t** uiccArray=NULL; diff --git a/targets/ARCH/COMMON/record_player.h b/targets/ARCH/COMMON/record_player.h index 9310355e5b..f4f17c6ee6 100644 --- a/targets/ARCH/COMMON/record_player.h +++ b/targets/ARCH/COMMON/record_player.h @@ -95,7 +95,7 @@ typedef struct { /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define DEVICE_RECPLAY_PARAMS_DESC { \ - {CONFIG_OPT_SF_FILE, CONFIG_HLP_SF_FILE, 0, strptr:(char **)((*recplay_conf)->u_sf_filename), defstrval:DEF_SF_FILE, TYPE_STRING, 1024}, \ + {CONFIG_OPT_SF_FILE, CONFIG_HLP_SF_FILE, 0, strptr:&((*recplay_conf)->u_sf_filename), defstrval:DEF_SF_FILE, TYPE_STRING, 0}, \ {CONFIG_OPT_SF_REC, CONFIG_HLP_SF_REC, PARAMFLAG_BOOL, uptr:&(u_sf_record), defuintval:0, TYPE_UINT, 0}, \ {CONFIG_OPT_SF_REP, CONFIG_HLP_SF_REP, PARAMFLAG_BOOL, uptr:&(u_sf_replay), defuintval:0, TYPE_UINT, 0}, \ {CONFIG_OPT_SF_MAX, CONFIG_HLP_SF_MAX, 0, uptr:&((*recplay_conf)->u_sf_max), defintval:DEF_NB_SF, TYPE_UINT, 0}, \ @@ -105,7 +105,7 @@ typedef struct { {CONFIG_OPT_USE_MMAP, CONFIG_HLP_USE_MMAP, PARAMFLAG_BOOL, uptr:&((*recplay_conf)->use_mmap), defuintval:1, TYPE_UINT, 0}, \ }/*! \brief Record Player Configuration and state */ typedef struct { - char u_sf_filename[1024]; // subframes file path + char *u_sf_filename; // subframes file path unsigned int u_sf_max ; // max number of recorded subframes unsigned int u_sf_loops ; // number of loops in replay mode unsigned int u_sf_read_delay; // read delay in replay mode diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index 127b2975d5..2cb0036804 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -77,11 +77,11 @@ /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define simOpt PARAMFLAG_NOFREE|PARAMFLAG_CMDLINE_NOPREFIXENABLED #define RFSIMULATOR_PARAMS_DESC { \ - {"serveraddr", "\n", simOpt, strptr:&(rfsimulator->ip), defstrval:"127.0.0.1", TYPE_STRING, 0 },\ + {"serveraddr", "\n", simOpt, strptr:&rfsimulator->ip, defstrval:"127.0.0.1", TYPE_STRING, 0 },\ {"serverport", "\n", simOpt, u16ptr:&(rfsimulator->port), defuintval:PORT, TYPE_UINT16, 0 },\ {RFSIMU_OPTIONS_PARAMNAME, RFSIM_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST,0 },\ - {"IQfile", "\n",simOpt, strptr:&(saveF), defstrval:"/tmp/rfsimulator.iqs",TYPE_STRING, 0 },\ - {"modelname", "\n", simOpt, strptr:&(modelname), defstrval:"AWGN", TYPE_STRING, 0 },\ + {"IQfile", "\n",simOpt, strptr:&saveF, defstrval:"/tmp/rfsimulator.iqs",TYPE_STRING, 0 },\ + {"modelname", "\n", simOpt, strptr:&modelname, defstrval:"AWGN", TYPE_STRING, 0 },\ {"ploss", "\n", simOpt, dblptr:&(rfsimulator->chan_pathloss), defdblval:0, TYPE_DOUBLE, 0 },\ {"forgetfact", "\n", simOpt, dblptr:&(rfsimulator->chan_forgetfact), defdblval:0, TYPE_DOUBLE, 0 },\ {"offset", "\n", simOpt, iptr:&(rfsimulator->chan_offset), defintval:0, TYPE_INT, 0 }\ diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 38b71238b8..9493d2cda3 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -107,7 +107,7 @@ {"nums_ue_thread", NULL, 0, u16ptr:&(NB_THREAD_INST), defuintval:1, TYPE_UINT16, 0}, \ {"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0}, \ {"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ - {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200",TYPE_STRING, 0}, \ + {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:&usrp_args, defstrval:"type=b200",TYPE_STRING, 0}, \ {"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ {"A", CONFIG_HLP_TADV, 0, iptr:&(timingadv), defintval:0, TYPE_INT, 0}, \ From 70bb1a385877bcf8ea7520062f26330c757a4ef4 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 16 Aug 2022 09:59:36 +0200 Subject: [PATCH 47/98] Add L2sim-4G to RAN-Container-Parent and documentation --- ci-scripts/Jenkinsfile-GitLab-Container | 20 ++++++++++++++++++++ doc/TESTBenches.md | 3 +++ 2 files changed, 23 insertions(+) diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index b37c9d4f4b..7c872e7b22 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -238,6 +238,26 @@ pipeline { } } } + stage ("4G L2 Simulators") { + when { expression {doMandatoryTests} } + steps { + script { + triggerSlaveJob ('RAN-L2-Sim-Test-4G', 'Test-L2-Sim-Container-4G') + } + } + post { + always { + script { + finalizeSlaveJob('RAN-L2-Sim-Test-4G') + } + } + failure { + script { + currentBuild.result = 'FAILURE' + } + } + } + } stage ("5G L2 Simulators") { when { expression {doMandatoryTests} } steps { diff --git a/doc/TESTBenches.md b/doc/TESTBenches.md index c6a01f278d..c9a9870953 100644 --- a/doc/TESTBenches.md +++ b/doc/TESTBenches.md @@ -83,6 +83,9 @@ Webhook - caracal + N310 - pure performance test through phy-test scheduler, see command line for more details +- [RAN-L2-Sim-Test-5G](https://jenkins-oai.eurecom.fr/job/RAN-L2-Sim-Test-4G/) + - obelix (eNB, 1x UE, OAI EPC) + - L2simulator: skips physical layer and uses proxy between eNB and UE - [RAN-L2-Sim-Test-5G](https://jenkins-oai.eurecom.fr/job/RAN-L2-Sim-Test-5G/) - obelix (gNB, 1x UE, OAI 5GC) - L2simulator: skips physical layer and uses proxy between gNB and UE, From 166aae35ab50918b1ff394cb3864e944bf468ca8 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 10 Aug 2022 17:25:48 +0200 Subject: [PATCH 48/98] fixes to get 100MHz working with 2 layers --- .../nfapi/public_inc/nfapi_nr_interface_scf.h | 2 +- openair1/PHY/MODULATION/nr_modulation.c | 4 ++-- openair1/PHY/MODULATION/nr_modulation.h | 4 ++-- openair1/PHY/NR_TRANSPORT/nr_dlsch.c | 4 ++-- .../NR_MAC_COMMON/nr_compute_tbs_common.c | 20 +++++++++---------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index 3a7dd8d523..5f64d0f006 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -40,7 +40,7 @@ typedef struct { uint16_t length; union { uint32_t *ptr; - uint32_t direct[16384]; + uint32_t direct[38016]; } value; } nfapi_nr_tx_data_request_tlv_t; diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c index 979a31c504..2522e146e2 100644 --- a/openair1/PHY/MODULATION/nr_modulation.c +++ b/openair1/PHY/MODULATION/nr_modulation.c @@ -251,7 +251,7 @@ void nr_modulation(uint32_t *in, void nr_layer_mapping(int16_t **mod_symbs, uint8_t n_layers, - uint16_t n_symbs, + uint32_t n_symbs, int16_t **tx_layers) { LOG_D(PHY,"Doing layer mapping for %d layers, %d symbols\n",n_layers,n_symbs); @@ -323,7 +323,7 @@ void nr_layer_mapping(int16_t **mod_symbs, void nr_ue_layer_mapping(int16_t *mod_symbs, uint8_t n_layers, - uint16_t n_symbs, + uint32_t n_symbs, int16_t **tx_layers) { for (int i=0; inr_gold_pdsch_dmrs[slot]; uint16_t dmrs_symbol_map = rel15->dlDmrsSymbPos;//single DMRS: 010000100 Double DMRS 110001100 uint8_t dmrs_len = get_num_dmrs(rel15->dlDmrsSymbPos); - uint16_t nb_re = ((12*rel15->NrOfSymbols)-nb_re_dmrs*dmrs_len-xOverhead)*rel15->rbSize*rel15->nrOfLayers; + uint32_t nb_re = ((12*rel15->NrOfSymbols)-nb_re_dmrs*dmrs_len-xOverhead)*rel15->rbSize*rel15->nrOfLayers; uint8_t Qm = rel15->qamModOrder[0]; uint32_t encoded_length = nb_re*Qm; int16_t mod_dmrs[n_dmrs<<1] __attribute__ ((aligned(16))); @@ -254,7 +254,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, 1+dmrs_Type,nl, Wt[0], Wt[1], Wf[0], Wf[1], delta, l_prime, l0, dmrs_symbol); #endif - uint16_t m=0, dmrs_idx=0; + uint32_t m=0, dmrs_idx=0; // Loop Over OFDM symbols: for (int l=rel15->StartSymbolIndex; lStartSymbolIndex+rel15->NrOfSymbols; l++) { diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c index 1acf23197c..4d7335713a 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c @@ -46,18 +46,18 @@ uint32_t nr_compute_tbs(uint16_t Qm, uint8_t Nl) { - uint16_t nbp_re, nb_re; - uint32_t nr_tbs=0; - uint32_t Ninfo, Np_info, C; - uint8_t n; - LOG_D(NR_MAC, "In %s: nb_symb_sch %d, nb_dmrs_prb %d, nb_rb %d, nb_rb_oh %d, tb_scaling %d Nl %d\n", __FUNCTION__, nb_symb_sch, nb_dmrs_prb, nb_rb, nb_rb_oh, tb_scaling, Nl); - nbp_re = NR_NB_SC_PER_RB * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; - nb_re = min(156, nbp_re) * nb_rb; + const uint32_t nbp_re = NR_NB_SC_PER_RB * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; + const uint32_t nb_re = min(156, nbp_re) * nb_rb; // Intermediate number of information bits - // R is tabulated as 10 times the actual code rate - Ninfo = ((nb_re * R * Qm * Nl / 10)>>10)>>tb_scaling; + // Rx1024 is tabulated as 10 times the actual code rate + const uint32_t R_5 = R/5; // R can be fractional so we can't divide by 10 + // So we ned to right shift by 11 (10 for x1024 and 1 additional as above) + const uint32_t Ninfo = ((nb_re * R_5 * Qm * Nl)>>11)>>tb_scaling; + + uint32_t nr_tbs=0; + uint32_t Np_info, C, n; if (Ninfo <=3824) { n = max(3, floor(log2(Ninfo)) - 6); @@ -85,7 +85,7 @@ uint32_t nr_compute_tbs(uint16_t Qm, } } - LOG_D(NR_MAC, "In %s: Ninfo %d nbp_re %d nb_re %d Qm %d, R %d, tbs %d bits\n", __FUNCTION__, Ninfo, nbp_re, nb_re, Qm, R, nr_tbs); + LOG_D(NR_MAC, "In %s: Ninfo %u nbp_re %d nb_re %d Qm %d, R %d, tbs %d bits\n", __FUNCTION__, Ninfo, nbp_re, nb_re, Qm, R, nr_tbs); return nr_tbs; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index a531a1c71c..af7cbc92d3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -610,7 +610,7 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[ntx_req]; // Data to be transmitted - bzero(tx_req->TLVs[0].value.direct,MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*1056); + bzero(tx_req->TLVs[0].value.direct, sizeof(tx_req->TLVs[0].value.direct)); memcpy(tx_req->TLVs[0].value.direct, sib1_payload, sib1_sdu_length); tx_req->PDU_length = TBS; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 09f3193790..0543b09e9e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -475,7 +475,7 @@ typedef struct NR_UE_harq { /* Transport block to be sent using this HARQ process, its size is in * sched_pdsch */ - uint32_t transportBlock[16384]; + uint32_t transportBlock[38016]; // valid up to 4 layers uint32_t tb_size; /// sched_pdsch keeps information on MCS etc used for the initial transmission From df1f4381a2c2f6417e3daee462f9f7a0d8c19dc7 Mon Sep 17 00:00:00 2001 From: francescomani Date: Sat, 13 Aug 2022 14:05:49 +0200 Subject: [PATCH 49/98] fix in sib1 memcpy size --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index af7cbc92d3..90d0af946a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -610,8 +610,7 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[ntx_req]; // Data to be transmitted - bzero(tx_req->TLVs[0].value.direct, sizeof(tx_req->TLVs[0].value.direct)); - memcpy(tx_req->TLVs[0].value.direct, sib1_payload, sib1_sdu_length); + memcpy(tx_req->TLVs[0].value.direct, sib1_payload, TBS); tx_req->PDU_length = TBS; tx_req->PDU_index = pdu_index; From 31d5bb6ffd83b1a6288c7d74829cc6d44343184e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 16 May 2022 11:46:54 +0200 Subject: [PATCH 50/98] Rename abortTpool() to abortTpoolJob(), fix doc --- common/utils/threadPool/thread-pool.c | 2 +- common/utils/threadPool/thread-pool.h | 2 +- common/utils/threadPool/thread-pool.md | 167 +++++++----------- executables/nr-ue.c | 2 +- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 2 +- openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 2 +- 8 files changed, 71 insertions(+), 110 deletions(-) diff --git a/common/utils/threadPool/thread-pool.c b/common/utils/threadPool/thread-pool.c index de9091de79..5398fe2e7e 100644 --- a/common/utils/threadPool/thread-pool.c +++ b/common/utils/threadPool/thread-pool.c @@ -265,7 +265,7 @@ int main() { } else printf("Empty list \n"); - abortTpool(&pool,510); + abortTpoolJob(&pool,510); } while(tmp); */ return 0; diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index e448117385..17bc87f701 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -281,7 +281,7 @@ static inline notifiedFIFO_elt_t *tryPullTpool(notifiedFIFO_t *responseFifo, tpo return msg; } -static inline int abortTpool(tpool_t *t, uint64_t key) { +static inline int abortTpoolJob(tpool_t *t, uint64_t key) { int nbRemoved=0; notifiedFIFO_t *nf=&t->incomingFifo; mutexlock(nf->lockF); diff --git a/common/utils/threadPool/thread-pool.md b/common/utils/threadPool/thread-pool.md index f2422d9822..50c9214d84 100644 --- a/common/utils/threadPool/thread-pool.md +++ b/common/utils/threadPool/thread-pool.md @@ -17,70 +17,51 @@ All the thread pool functions are thread safe, nevertheless the working function # jobs -A job is a message (notifiedFIFO_elt_t): +A job is a message (`notifiedFIFO_elt_t`): -* next: +* `next`: internal FIFO chain, do not set it -* key: +* `key`: a long int that the client can use to identify a message or a group of messages -* ResponseFifo: +* `ResponseFifo`: if the client defines a response FIFO, the message will be posted back after processing -* processingFunc: - any funtion (type void processingFunc(void *)) that the worker will launch -* msgData: +* `processingFunc`: + any funtion (type `void processingFunc(void *)`) that the worker will launch +* `msgData`: the data passed to processingFunc. It can be added automatically, or you can set it to a buffer you are managing -* malloced: +* `malloced`: a boolean that enable internal free in these cases: no return Fifo or Abort feature -The job messages can be created with newNotifiedFIFO_elt() and delNotifiedFIFO_elt() or managed by the client. +The job messages can be created with `newNotifiedFIFO_elt()` and `delNotifiedFIFO_elt()` or managed by the client. # Queues of jobs Queues are type of: -* notifiedFIFO_t that must be initialized by init_notifiedFIFO() -* No delete function is required, the creator has only to free the data of type notifiedFIFO_t -* push_notifiedFIFO() add a job in the queue -* pull_notifiedFIFO() is blocking, poll_notifiedFIFO() is non blocking -* abort_notifiedFIFO() allows the customer to delete all waiting jobs that match with the key (see key in jobs definition) +* `notifiedFIFO_t` that must be initialized by `init_notifiedFIFO()` +* No delete function is required, the creator has only to free the data of type `notifiedFIFO_t` +* `push_notifiedFIFO()` add a job in the queue +* `pull_notifiedFIFO()` is blocking, `poll_notifiedFIFO()` is non blocking +* `abort_notifiedFIFO()` allows the customer to delete all waiting jobs that match with the key (see key in jobs definition) -These queues details hereafter +## Thread-safe functions -## Common +* `newNotifiedFIFO_elt()`: creates a message, that will later be used in queues/FIFO +* `delNotifiedFIFO_elt()`: deletes it +* `NotifiedFifoData()`: gives a pointer to the beginning of free usage memory in a message (you can put any data there, up to 'size' parameter you passed to `newNotifiedFIFO_elt()`) -newNotifiedFIFO_elt() +These 3 calls are not mandatory, you can also use your own memory to save the `malloc()`/`free()` that are behind these calls -creates a message, that will later be used in queues/FIFO +# Low level: fast and simple, but not thread-safe -delNotifiedFIFO_elt() +* `initNotifiedFIFO_nothreadSafe()`: Create a queue +* `pushNotifiedFIFO_nothreadSafe()`: Add a element in a queue +* `pullNotifiedFIFO_nothreadSafe()`: Pull a element from a queue -deletes it +As these queues are not thread safe, there is NO blocking mechanism, neither `pull()` versus `poll()` calls -NotifiedFifoData() - -gives a pointer to the beginning of free usage memory in a message (you can put any data there, up to 'size' parameter you passed to newNotifiedFIFO_elt() - -These 3 calls are not mandatory, you can also use your own memory to save the malloc()/free() that are behind these calls -iFirst level: non thread safe FIFO (or queues) - -# low level: fast and simple - -initNotifiedFIFO_nothreadSafe() - -to create a queue - -pushNotifiedFIFO_nothreadSafe() - -Add a element in a queue - -pullNotifiedFIFO_nothreadSafe() - -pull a element from a queue - -As these queues are not thread safe, there is NO blocking mechanism, neither pull() versus poll() calls - -There is no delete for a message queue: you only have to abandon the memory you allocated to call iinitNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf) +There is no delete for a message queue: you only have to abandon the memory you allocated to call `initNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf)` So if you malloced the memory under 'nf' parameter you have to free it, if it is automatic variable (local variable) or global variable, nothing is to be done. @@ -89,58 +70,50 @@ So if you malloced the memory under 'nf' parameter you have to free it, if it is These queues are built on not thread safe queues when we need thread to thread protection -initNotifiedFIFO() +* `initNotifiedFIFO()`: Create a queue +* `pushNotifiedFIFO()`: Add a element in a queue +* `pullNotifiedFIFO()`: Pull a element from a queue, this call is blocking until a message arrived +* `pollNotifiedFIFO()`: Pull a element from a queue, this call is not blocking, so it returns always very shortly -to create a queue +Note that in 99.9% cases, `pull()` is better than `poll()` -pushNotifiedFIFO() - -Add a element in a queue - -pullNotifiedFIFO() - -pull a element from a queue, this call is blocking until a message arrived - -pollNotifiedFIFO() - -pull a element from a queue, this call is not blocking, so it returns always very shortly - -in 99.9% cases, pull() is better than poll() - -No delete() call, same principle as not thread safe queues +No `delete()` call, same principle as not thread safe queues # Thread pools ## initialization + The clients can create one or more thread pools with `initTpool(char *params,tpool_t *pool, bool performanceMeas )` or `initNamedTpool(char *params,tpool_t *pool, bool performanceMeas , char *name)` -the params string structure: describes a list of cores, separated by "," that run a worker thread +the `params` string structure: describes a list of cores, separated by "," that run a worker thread If the core exists on the CPU, the thread pool initialization sets the affinity between this thread and the related code (use negative values is allowed, so the thread will never be mapped on a specific core). The threads are all Linux real time scheduler, their name is set automatically to `Tpool_` if initTpool is used or to `_` when initNamedTpool is used. ## adding jobs -The client create their jobs messages as a notifiedFIFO_elt_t, then they push it with pushTpool() (that internally calls push_notifiedFIFO()) +The client create their jobs messages as a `notifiedFIFO_elt_t`, then they push it with `pushTpool()` (that internally calls `push_notifiedFIFO()`) -If they need a return, they have to create response queues with init_notifiedFIFO() and set this FIFO pointer in the notifiedFIFO_elt_t before pushing the job. +If they need a return, they have to create response queues with `init_notifiedFIFO()` and set this FIFO pointer in the `notifiedFIFO_elt_t` before pushing the job. ## abort -A abort service abortTpool() allows to abort all jobs that match a key (see jobs "key"). When the abort returns, it garanties no job (matching the key) response will be posted on response queues. +A abort service `abortTpoolJob()` allows to abort all jobs that match a key (see jobs "key"). When the abort returns, it garanties no job (matching the key) response will be posted on response queues. -Nevertheless, jobs already performed before the return of abortTpool() are pushed in the response Fifo queue. +Nevertheless, jobs already performed before the return of `abortTpoolJob()` are pushed in the response Fifo queue. + +`abortTpool()` kills all jobs in the Tpool. ## API details Each thread pool (there can be several in the same process) should be initialized once using one of the two API's: -### initNamedTpool(char *params,tpool_t *pool, bool performanceMeas,char *name) +### `initNamedTpool(char *params,tpool_t *pool, bool performanceMeas,char *name)` -### initTpool(char *params,tpool_t *pool, bool performanceMeas) +### `initTpool(char *params,tpool_t *pool, bool performanceMeas)` `params`: the configuration parameter is a string, elements separator is a comma ",". An element can be: -* N: if a N is in the parameter list, no threads are created +* `N`: if a N is in the parameter list, no threads are created The purpose is to keep the same API in any case * a CPU with a little number of cores, or in debugging sessions to simplify the human work @@ -149,7 +122,7 @@ Each thread pool (there can be several in the same process) should be initialize * a number that is not a valid CPU core a floating thread is created (Linux is responsible of the real time core allocation) -example: "-1,-1,-1" +example: `"-1,-1,-1"` as there is no core number -1, the thread pool is made of 3 floating threads be careful with fix allocation: it is hard to be more clever than Linux kernel @@ -159,35 +132,27 @@ be careful with fix allocation: it is hard to be more clever than Linux kernel `name` is used to build the thread names. -### pushTpool(tpool_t *t, notifiedFIFO_elt_t *msg) +### `pushTpool(tpool_t *t, notifiedFIFO_elt_t *msg)` adds a job to do in the thread pool The msg data you can set are: -* key: - a value for you that you will find back in the response - it is also the key for abortTpool() -* reponseFifo - if you set it, the message will be sent back on this queue when the job is done - if you don't set it, no return is performed, the thread pool frees the message 'msg' when the job is done -* processingFunc - the function the job will run. the function prototype is void (void *memory) - the data part (the pointer returned by NotifiedFifoData(msg)) is passed to the function - it is used to send data to the processing function and also to write back results - of course, writing back results will lead you to use also a return queue (the parameter reponseFifo) +* `key`: a value for you that you will find back in the response it is also the key for `abortTpoolJob()` +* `reponseFifo`: if you set it, the message will be sent back on this queue when the job is done if you don't set it, no return is performed, the thread pool frees the message 'msg' when the job is done +* `processingFunc`: the function the job will run. the function prototype is `void (void *memory)` the data part (the pointer returned by `NotifiedFifoData(msg)`) is passed to the function it is used to send data to the processing function and also to write back results of course, writing back results will lead you to use also a return queue (the parameter `reponseFifo`) -### pullTpool() collects job result in a return queue +### `pullTpool()` collects job result in a return queue -you collect results in one result queue: the message you gave to pushTpool(), nevertheless it has been updated by processingFunc() +you collect results in one result queue: the message you gave to `pushTpool()`, nevertheless it has been updated by `processingFunc()` An example of multiple return queues, in eNB: I created one single thread pool (because it depends mainly on CPU hardware), but i use two return queues: one for turbo encode, one for turbo decode. -### tryPullTpool() +### `tryPullTpool()` -is the same, but not blocking (pollTpool() would have been a better name) +is the same, but not blocking (`pollTpool()` would have been a better name) -### abortTpool() +### `abortTpoolJob()` Is a facility to cancel work you pushed to a thread pool @@ -197,21 +162,17 @@ But when I get back the decoding results, if one segment can't be decoded, I don ## Performance measurements -A performance measurement is integrated: -the pool will automacillay fill timestamps: +A performance measurement is integrated: the pool will automacillay fill timestamps if you set the environement variable `threadPoolMeasurements` to a valid file name. The following measurements will be written to Linux pipe. -* creationTime: -time the request is push to the pool; -* startProcessingTime: -time a worker start to run on the job -* endProcessingTime: -time the worker finished the job -* returnTime: -time the client reads the result +* `creationTime`: time the request is push to the pool; +* `startProcessingTime`: time a worker start to run on the job +* `endProcessingTime`: time the worker finished the job +* `returnTime`: time the client reads the result -if you set the environement variable: -threadPoolMeasurements to a valid file name -These measurements will be wrote to this Linux pipe. - -A tool to read the linux fifo and display it in ascii is provided; compute the binay: -in cmake building directory: make/ninja measurement_display +The `measurement_display` tool to read the Linux pipe and display it in ascii is provided. +In the cmake build directory, type `make/ninja measurement_display`. Use as +follows: +``` +sudo threadPoolMeasurements=tpool.meas ./nr-softmodem ... +./measurement_display tpool.meas +``` diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 7b39dfdcaa..616312a21a 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -860,7 +860,7 @@ void *UE_thread(void *arg) { while (!oai_exit) { if (UE->lost_sync) { - int nb = abortTpool(&(get_nrUE_params()->Tpool),RX_JOB_ID); + int nb = abortTpoolJob(&(get_nrUE_params()->Tpool),RX_JOB_ID); nb += abortNotifiedFIFO(&nf, RX_JOB_ID); LOG_I(PHY,"Number of aborted slots %d\n",nb); for (int i=0; ikey); + int nb=abortTpoolJob(&(pool_dl), req->key); nb+=abortNotifiedFIFO(nf_p, req->key); LOG_D(PHY,"downlink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); LOG_D(PHY, "DLSCH %d in error\n",rdata->dlsch_id); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 1a35f6ee68..5cf3634958 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1328,7 +1328,7 @@ void postDecode(L1_rxtx_proc_t *proc, notifiedFIFO_elt_t *req) { sz); } else { if ( rdata->nbSegments != ulsch_harq->processedSegments ) { - int nb=abortTpool(proc->threadPool, req->key); + int nb=abortTpoolJob(proc->threadPool, req->key); nb+=abortNotifiedFIFO(proc->respDecode, req->key); proc->nbDecode-=nb; LOG_D(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 978c1d1be9..390545e7f2 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -206,7 +206,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { } else { if ( rdata->nbSegments != ulsch_harq->processedSegments ) { - int nb=abortTpool(gNB->threadPool, req->key); + int nb=abortTpoolJob(gNB->threadPool, req->key); nb+=abortNotifiedFIFO(gNB->respDecode, req->key); gNB->nbDecode-=nb; LOG_D(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 5392424285..ea6ffe5dad 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -87,7 +87,7 @@ int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { rdata->Kr_bytes - (ulsch_harq->F>>3) -((ulsch_harq->C>1)?3:0)); } else { if ( rdata->nbSegments != ulsch_harq->processedSegments ) { - int nb=abortTpool(gNB->threadPool, req->key); + int nb=abortTpoolJob(gNB->threadPool, req->key); nb+=abortNotifiedFIFO(gNB->respDecode, req->key); gNB->nbDecode-=nb; AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", From c4a657cc33f50a95a55be3de8e2609bf7809d7aa Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 16 May 2022 15:59:45 +0200 Subject: [PATCH 51/98] Avoid additional malloc() for queues and Tpool --- executables/nr-gnb.c | 53 ++++++++----------- executables/nr-ru.c | 10 ++-- nfapi/oai_integration/nfapi_pnf.c | 6 +-- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 4 +- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 4 +- openair1/PHY/defs_gNB.h | 14 ++--- openair1/SCHED_NR/fapi_nr_l1.c | 4 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 6 +-- openair1/SIMULATION/NR_PHY/dlschsim.c | 4 +- openair1/SIMULATION/NR_PHY/dlsim.c | 16 +++--- openair1/SIMULATION/NR_PHY/ulschsim.c | 14 ++--- openair1/SIMULATION/NR_PHY/ulsim.c | 20 +++---- 12 files changed, 66 insertions(+), 89 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index bc3dccf4fa..8d9c6b1a7e 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -247,21 +247,21 @@ void rx_func(void *param) { processingData_L1tx_t *syncMsg; // Its a FIFO so it maitains the order in which the MAC fills the messages // so no need for checking for right slot - res = pullTpool(gNB->L1_tx_filled, gNB->threadPool); + res = pullTpool(&gNB->L1_tx_filled, &gNB->threadPool); syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; syncMsg->timestamp_tx = info->timestamp_tx; res->key = slot_tx; - pushTpool(gNB->threadPool, res); + pushTpool(&gNB->threadPool, res); } else if (get_softmodem_params()->continuous_tx) { - notifiedFIFO_elt_t *res = pullTpool(gNB->L1_tx_free, gNB->threadPool); + notifiedFIFO_elt_t *res = pullTpool(&gNB->L1_tx_free, &gNB->threadPool); processingData_L1tx_t *syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; syncMsg->timestamp_tx = info->timestamp_tx; syncMsg->frame = frame_tx; syncMsg->slot = slot_tx; res->key = slot_tx; - pushNotifiedFIFO(gNB->L1_tx_out, res); + pushNotifiedFIFO(&gNB->L1_tx_out, res); } #if 0 @@ -376,7 +376,7 @@ void *tx_reorder_thread(void* param) { notifiedFIFO_elt_t *resL1Reserve = NULL; - resL1Reserve=pullTpool(gNB->L1_tx_out, gNB->threadPool); + resL1Reserve = pullTpool(&gNB->L1_tx_out, &gNB->threadPool); int next_tx_slot=((processingData_L1tx_t *)NotifiedFifoData(resL1Reserve))->slot; while (!oai_exit) { @@ -385,18 +385,18 @@ void *tx_reorder_thread(void* param) { resL1=resL1Reserve; if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { LOG_E(PHY,"order mistake\n"); - resL1Reserve=NULL; - resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + resL1Reserve = NULL; + resL1 = pullTpool(&gNB->L1_tx_out, &gNB->threadPool); } } else { - resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + resL1 = pullTpool(&gNB->L1_tx_out, &gNB->threadPool); if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { if (resL1Reserve) LOG_E(PHY,"error, have a stored packet, then a second one\n"); - resL1Reserve=resL1; - resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + resL1Reserve = resL1; + resL1 = pullTpool(&gNB->L1_tx_out, &gNB->threadPool); if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) - LOG_E(PHY,"error, pull two msg, none is good\n"); + LOG_E(PHY,"error, pull two msg, none is good\n"); } } processingData_L1tx_t *syncMsgL1= (processingData_L1tx_t *)NotifiedFifoData(resL1); @@ -410,7 +410,7 @@ void *tx_reorder_thread(void* param) { next_tx_slot = (syncMsgRU.slot_tx + 1) % slots_per_frame; } else next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, syncMsgRU.frame_tx, syncMsgRU.slot_tx); - pushNotifiedFIFO(gNB->L1_tx_free, resL1); + pushNotifiedFIFO(&gNB->L1_tx_free, resL1); if (resL1==resL1Reserve) resL1Reserve=NULL; ru_tx_func((void*)&syncMsgRU); @@ -423,8 +423,6 @@ void init_gNB_Tpool(int inst) { gNB = RC.gNB[inst]; gNB_L1_proc_t *proc = &gNB->proc; - // ULSCH decoding threadpool - gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); int numCPU = sysconf(_SC_NPROCESSORS_ONLN); LOG_I(PHY,"Number of threads requested in config file: %d, Number of threads available on this machine: %d\n",gNB->thread_pool_size,numCPU); int threadCnt = min(numCPU, gNB->thread_pool_size); @@ -437,33 +435,28 @@ void init_gNB_Tpool(int inst) { s_offset += 3; } if (getenv("noThreads")) strcpy(pool, "n"); - initTpool(pool, gNB->threadPool, cpumeas(CPUMEAS_GETSTATE)); + initTpool(pool, &gNB->threadPool, cpumeas(CPUMEAS_GETSTATE)); // ULSCH decoder result FIFO - gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->respDecode); + initNotifiedFIFO(&gNB->respDecode); // L1 RX result FIFO - gNB->resp_L1 = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1); - notifiedFIFO_elt_t *msg = newNotifiedFIFO_elt(sizeof(processingData_L1_t),0,gNB->resp_L1,rx_func); - pushNotifiedFIFO(gNB->resp_L1,msg); // to unblock the process in the beginning + initNotifiedFIFO(&gNB->resp_L1); + notifiedFIFO_elt_t *msg = newNotifiedFIFO_elt(sizeof(processingData_L1_t), 0, &gNB->resp_L1, rx_func); + pushNotifiedFIFO(&gNB->resp_L1, msg); // to unblock the process in the beginning // L1 TX result FIFO - gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->L1_tx_free); - initNotifiedFIFO(gNB->L1_tx_filled); - initNotifiedFIFO(gNB->L1_tx_out); + initNotifiedFIFO(&gNB->L1_tx_free); + initNotifiedFIFO(&gNB->L1_tx_filled); + initNotifiedFIFO(&gNB->L1_tx_out); // we create 2 threads for L1 tx processing for (int i=0; i < 2; i++) { - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func); + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t), 0, &gNB->L1_tx_out, tx_func); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); - memset(msgDataTx,0, sizeof(processingData_L1tx_t)); + memset(msgDataTx, 0, sizeof(processingData_L1tx_t)); init_DLSCH_struct(gNB, msgDataTx); memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); - pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning + pushNotifiedFIFO(&gNB->L1_tx_free, msgL1Tx); // to unblock the process in the beginning } if ((!get_softmodem_params()->emulate_l1) && (!IS_SOFTMODEM_NOSTATS_BIT)) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 3ddca74194..fe0f9fc783 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1251,7 +1251,7 @@ void *ru_thread( void *param ) { } // At this point, all information for subframe has been received on FH interface - res = pullTpool(gNB->resp_L1, gNB->threadPool); + res = pullTpool(&gNB->resp_L1, &gNB->threadPool); syncMsg = (processingData_L1_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; syncMsg->frame_rx = proc->frame_rx; @@ -1260,7 +1260,7 @@ void *ru_thread( void *param ) { syncMsg->slot_tx = proc->tti_tx; syncMsg->timestamp_tx = proc->timestamp_tx; res->key = proc->tti_rx; - pushTpool(gNB->threadPool, res); + pushTpool(&gNB->threadPool, res); } printf( "Exiting ru_thread \n"); @@ -1271,11 +1271,11 @@ void *ru_thread( void *param ) { else LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); } - res = pullNotifiedFIFO(gNB->resp_L1); + res = pullNotifiedFIFO(&gNB->resp_L1); delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(gNB->L1_tx_free); + res = pullNotifiedFIFO(&gNB->L1_tx_free); delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(gNB->L1_tx_free); + res = pullNotifiedFIFO(&gNB->L1_tx_free); delNotifiedFIFO_elt(res); ru_thread_status = 0; diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 205f879964..4f07e79a78 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -1103,7 +1103,7 @@ notifiedFIFO_elt_t *l1tx_message_extract(PHY_VARS_gNB *gNB, int frame, int slot) notifiedFIFO_elt_t *res; //TODO: This needs to be reworked for nfapi to work - res = pullTpool(gNB->L1_tx_free, gNB->threadPool); + res = pullTpool(&gNB->L1_tx_free, &gNB->threadPool); return res; } @@ -1130,7 +1130,7 @@ int pnf_phy_ul_dci_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, } } - pushNotifiedFIFO(gNB->L1_tx_filled,res); + pushNotifiedFIFO(&gNB->L1_tx_filled, res); return 0; } @@ -1237,7 +1237,7 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_tti_pdu_list[i].PDUType); } - pushNotifiedFIFO(gNB->L1_tx_filled,res); + pushNotifiedFIFO(&gNB->L1_tx_filled, res); } if(req->vendor_extension) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 8672f3ae29..5b57cd125f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -425,11 +425,11 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, encoder_implemparams_t* perJobImpp=(encoder_implemparams_t*)NotifiedFifoData(req); *perJobImpp=impp; perJobImpp->macro_num=j; - pushTpool(gNB->threadPool,req); + pushTpool(&gNB->threadPool, req); nbJobs++; } while(nbJobs) { - notifiedFIFO_elt_t *req=pullTpool(&nf, gNB->threadPool); + notifiedFIFO_elt_t *req=pullTpool(&nf, &gNB->threadPool); delNotifiedFIFO_elt(req); nbJobs--; diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 6f49bcd053..57b0602c7e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -553,7 +553,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, E = nr_get_E(G, harq_process->C, Qm, n_layers, r); union ldpcReqUnion id = {.s={ulsch->rnti,frame,nr_tti_rx,0,0}}; - notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), id.p, phy_vars_gNB->respDecode, nr_processULSegment_ptr); + notifiedFIFO_elt_t *req = newNotifiedFIFO_elt(sizeof(ldpcDecode_t), id.p, &phy_vars_gNB->respDecode, nr_processULSegment_ptr); ldpcDecode_t * rdata=(ldpcDecode_t *) NotifiedFifoData(req); rdata->gNB = phy_vars_gNB; @@ -574,7 +574,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, rdata->ulsch = ulsch; rdata->ulsch_id = ULSCH_id; rdata->tbslbrm = pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes; - pushTpool(phy_vars_gNB->threadPool,req); + pushTpool(&phy_vars_gNB->threadPool, req); phy_vars_gNB->nbDecode++; LOG_D(PHY,"Added a block to decode, in pipe: %d\n",phy_vars_gNB->nbDecode); r_offset += E; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index f4387a372b..2235521bb1 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -890,13 +890,13 @@ typedef struct PHY_VARS_gNB_s { time_stats_t rx_dft_stats; time_stats_t ulsch_freq_offset_estimation_stats; */ - notifiedFIFO_t *respDecode; - notifiedFIFO_t *resp_L1; - notifiedFIFO_t *L1_tx_free; - notifiedFIFO_t *L1_tx_filled; - notifiedFIFO_t *L1_tx_out; - notifiedFIFO_t *resp_RU_tx; - tpool_t *threadPool; + notifiedFIFO_t respDecode; + notifiedFIFO_t resp_L1; + notifiedFIFO_t L1_tx_free; + notifiedFIFO_t L1_tx_filled; + notifiedFIFO_t L1_tx_out; + notifiedFIFO_t resp_RU_tx; + tpool_t threadPool; int nbDecode; uint8_t thread_pool_size; int number_of_nr_dlsch_max; diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 5c08a0f479..2c61704508 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -163,7 +163,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ if (slot_type == NR_DOWNLINK_SLOT || slot_type == NR_MIXED_SLOT) { notifiedFIFO_elt_t *res; - res = pullTpool(gNB->L1_tx_free, gNB->threadPool); + res = pullTpool(&gNB->L1_tx_free, &gNB->threadPool); processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); const time_stats_t ts = exec_time_stats_NotifiedFIFO(res); merge_meas(&gNB->phy_proc_tx, &ts); @@ -210,7 +210,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ for (int i=0; iul_pdcch_pdu[i] = UL_dci_req->ul_dci_pdu_list[i]; - pushNotifiedFIFO(gNB->L1_tx_filled,res); + pushNotifiedFIFO(&gNB->L1_tx_filled,res); } for (int i = 0; i < number_ul_tti_pdu; i++) { diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 390545e7f2..1298ce3d49 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -206,8 +206,8 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { } else { if ( rdata->nbSegments != ulsch_harq->processedSegments ) { - int nb=abortTpoolJob(gNB->threadPool, req->key); - nb+=abortNotifiedFIFO(gNB->respDecode, req->key); + int nb = abortTpoolJob(&gNB->threadPool, req->key); + nb += abortNotifiedFIFO(&gNB->respDecode, req->key); gNB->nbDecode-=nb; LOG_D(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id); @@ -363,7 +363,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH G); while (gNB->nbDecode > 0) { - notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool); + notifiedFIFO_elt_t *req = pullTpool(&gNB->respDecode, &gNB->threadPool); nr_postDecode(gNB, req); delNotifiedFIFO_elt(req); } diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 39cd540795..fa44cf7880 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -363,8 +363,7 @@ int main(int argc, char **argv) RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB[0] = calloc(1, sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; - gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); - initTpool(gNBthreads, gNB->threadPool, true); + initTpool(gNBthreads, &gNB->threadPool, true); //gNB_config = &gNB->gNB_config; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->nb_antennas_tx = n_tx; @@ -625,7 +624,6 @@ int main(int argc, char **argv) reset_DLSCH_struct(gNB, &msgDataTx); phy_free_nr_gNB(gNB); - free(gNB->threadPool); free(RC.gNB[0]); free(RC.gNB); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 3ff3fe66cd..a4e308f06b 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -1034,16 +1034,12 @@ int main(int argc, char **argv) snrRun = 0; int n_errs = 0; - gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); - initTpool(gNBthreads, gNB->threadPool, true); - gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->L1_tx_free); - initNotifiedFIFO(gNB->L1_tx_filled); - initNotifiedFIFO(gNB->L1_tx_out); + initTpool(gNBthreads, &gNB->threadPool, true); + initNotifiedFIFO(&gNB->L1_tx_free); + initNotifiedFIFO(&gNB->L1_tx_filled); + initNotifiedFIFO(&gNB->L1_tx_out); // we create 2 threads for L1 tx processing - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_free,processSlotTX); + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,&gNB->L1_tx_free,processSlotTX); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); init_DLSCH_struct(gNB, msgDataTx); msgDataTx->slot = slot; @@ -1119,7 +1115,7 @@ int main(int argc, char **argv) Sched_INFO.UL_tti_req = gNB_mac->UL_tti_req_ahead[0]; Sched_INFO.UL_dci_req = NULL; Sched_INFO.TX_req = &gNB_mac->TX_req[0]; - pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); + pushNotifiedFIFO(&gNB->L1_tx_free,msgL1Tx); nr_schedule_response(&Sched_INFO); /* PTRS values for DLSIM calculations */ diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index ea6ffe5dad..828456adbe 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -87,8 +87,8 @@ int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { rdata->Kr_bytes - (ulsch_harq->F>>3) -((ulsch_harq->C>1)?3:0)); } else { if ( rdata->nbSegments != ulsch_harq->processedSegments ) { - int nb=abortTpoolJob(gNB->threadPool, req->key); - nb+=abortNotifiedFIFO(gNB->respDecode, req->key); + int nb=abortTpoolJob(&gNB->threadPool, req->key); + nb+=abortNotifiedFIFO(&gNB->respDecode, req->key); gNB->nbDecode-=nb; AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", ulsch_harq->processedSegments, nb, rdata->nbSegments); @@ -387,11 +387,9 @@ int main(int argc, char **argv) gNB = RC.gNB[0]; //gNB_config = &gNB->gNB_config; - gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); - gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); char tp_param[] = "n"; - initTpool(tp_param, gNB->threadPool, true); - initNotifiedFIFO(gNB->respDecode); + initTpool(tp_param, &gNB->threadPool, true); + initNotifiedFIFO(&gNB->respDecode); frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_UL = N_RB_UL; @@ -586,7 +584,7 @@ int main(int argc, char **argv) nr_ulsch_decoding(gNB, UE_id, channel_output_fixed, frame_parms, rel15_ul, frame, subframe, harq_pid, G); while (gNB->nbDecode > 0) { - notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool); + notifiedFIFO_elt_t *req=pullTpool(&gNB->respDecode, &gNB->threadPool); ret = nr_postDecode_sim(gNB, req); delNotifiedFIFO_elt(req); } @@ -636,8 +634,6 @@ int main(int argc, char **argv) free(UE); phy_free_nr_gNB(gNB); - free(gNB->threadPool); - free(gNB->respDecode); free(RC.gNB[0]); free(RC.gNB); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 3ac1ec3439..4bee028a6d 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -700,9 +700,6 @@ int main(int argc, char **argv) RC.gNB[0] = calloc(1,sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; gNB->ofdm_offset_divisor = UINT_MAX; - gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); - gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->respDecode); char tp_param[80]; if (threadCnt>0) sprintf(tp_param,"-1"); @@ -714,15 +711,12 @@ int main(int argc, char **argv) s_offset += 3; } - initTpool(tp_param, gNB->threadPool, false); - initNotifiedFIFO(gNB->respDecode); - gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->L1_tx_free); - initNotifiedFIFO(gNB->L1_tx_filled); - initNotifiedFIFO(gNB->L1_tx_out); - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_free,NULL); + initTpool(tp_param, &gNB->threadPool, false); + initNotifiedFIFO(&gNB->respDecode); + initNotifiedFIFO(&gNB->L1_tx_free); + initNotifiedFIFO(&gNB->L1_tx_filled); + initNotifiedFIFO(&gNB->L1_tx_out); + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t), 0, &gNB->L1_tx_free, NULL); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); msgDataTx->slot = -1; //gNB_config = &gNB->gNB_config; @@ -1168,7 +1162,7 @@ int main(int argc, char **argv) } // prepare ULSCH/PUSCH reception - pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning + pushNotifiedFIFO(&gNB->L1_tx_free, msgL1Tx); // to unblock the process in the beginning nr_schedule_response(Sched_INFO); // --------- setting parameters for UE -------- From 604d52a431b6752ce8c3607c28b062e91a99ec78 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Mon, 16 May 2022 16:12:21 +0200 Subject: [PATCH 52/98] Replace sleep by mutex in itti_wait_tasks_end() --- common/utils/ocp_itti/intertask_interface.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index 43001ec95b..4613cd5c1b 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -438,23 +438,24 @@ extern "C" { void itti_send_terminate_message(task_id_t task_id) { } - static volatile bool shutting_down; + pthread_mutex_t signal_mutex; static void catch_sigterm(int) { static const char msg[] = "\n** Caught SIGTERM, shutting down\n"; __attribute__((unused)) int unused = write(STDOUT_FILENO, msg, sizeof(msg) - 1); - shutting_down = true; + pthread_mutex_unlock(&signal_mutex); } void itti_wait_tasks_end(void) { - shutting_down = false; + + pthread_mutex_init(&signal_mutex, NULL); + pthread_mutex_lock(&signal_mutex); + signal(SIGTERM, catch_sigterm); - //signal(SIGINT, catch_sigterm); - while (! shutting_down) - { - sleep(24 * 3600); - } + signal(SIGINT, catch_sigterm); + + pthread_mutex_lock(&signal_mutex); } void itti_update_lte_time(uint32_t frame, uint8_t slot) {} From 76f399cdd64f2aa7c825a2d5453cc6738358ca58 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 17 May 2022 11:19:11 +0200 Subject: [PATCH 53/98] Threading/memory improvements at nr-softmodem end - First stop threads then free memory - Don't call kill_NR_RU_proc() twice (is called in stop_RU()) - Memory allocation optimizations --- executables/nr-softmodem.c | 10 ++++------ openair1/PHY/INIT/nr_init.c | 4 ---- openair1/PHY/INIT/nr_init_ru.c | 13 +++++++++---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 54345dc6b0..3a47a6bc79 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -833,14 +833,12 @@ int main( int argc, char **argv ) { /* release memory used by the RU/gNB threads (incomplete), after all * threads have been stopped (they partially use the same memory) */ - for (int inst = 0; inst < NB_gNB_INST; inst++) { - //free_transport(RC.gNB[inst]); - phy_free_nr_gNB(RC.gNB[inst]); + for (int inst = 0; inst < NB_RU; inst++) { + nr_phy_free_RU(RC.ru[inst]); } - for (int inst = 0; inst < NB_RU; inst++) { - kill_NR_RU_proc(inst); - nr_phy_free_RU(RC.ru[inst]); + for (int inst = 0; inst < NB_gNB_INST; inst++) { + phy_free_nr_gNB(RC.gNB[inst]); } pthread_cond_destroy(&sync_cond); diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index c3baa06da6..fec343ccfb 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -625,7 +625,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, gNB->first_run_I0_measurements = 1; - common_vars->rxdata = (int32_t **)malloc16(Prx*sizeof(int32_t*)); common_vars->txdataF = (int32_t **)malloc16(Ptx*sizeof(int32_t*)); common_vars->rxdataF = (int32_t **)malloc16(Prx*sizeof(int32_t*)); common_vars->beam_id = (uint8_t **)malloc16(Ptx*sizeof(uint8_t*)); @@ -640,7 +639,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, } for (i=0;irxdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); - common_vars->rxdata[i] = (int32_t*)malloc16_clear(fp->samples_per_frame*sizeof(int32_t)); } common_vars->debugBuff = (int32_t*)malloc16_clear(fp->samples_per_frame*sizeof(int32_t)*100); common_vars->debugBuff_sample_offset = 0; @@ -786,11 +784,9 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) for (int i = 0; i < Prx; ++i) { free_and_zero(common_vars->rxdataF[i]); - free_and_zero(common_vars->rxdata[i]); } free_and_zero(common_vars->txdataF); - free_and_zero(common_vars->rxdata); free_and_zero(common_vars->rxdataF); free_and_zero(common_vars->beam_id); diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index 75d78738fc..d12834d620 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -176,8 +176,11 @@ void nr_phy_free_RU(RU_t *ru) LOG_I(PHY, "Feeing RU signal buffers (if_south %s) nb_tx %d\n", ru_if_types[ru->if_south], ru->nb_tx); if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so free memory for time-domain signals - for (i = 0; i < ru->nb_tx; i++) - free_and_zero(ru->common.txdata[i]); + // Hack: undo what is done at allocation + for (i = 0; i < ru->nb_tx; i++) { + int32_t *p = &ru->common.txdata[i][-ru->sf_extension]; + free_and_zero(p); + } free_and_zero(ru->common.txdata); for (i = 0; i < ru->nb_rx; i++) @@ -198,8 +201,10 @@ void nr_phy_free_RU(RU_t *ru) free_and_zero(ru->common.txdataF_BF); // free FFT output buffers (RX) - for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdataF[i]); - free_and_zero(ru->common.rxdataF); + // HACK: cannot free here, or the gNB code in phy_free_nr_gNB() will + // segfault. The rxdataF memory between RU and gNB is not properly handled! + //for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdataF[i]); + //free_and_zero(ru->common.rxdataF); for (j=0;jnb_rx; i++) From fc298b77b5383ef48305c2630382d3d7bb4233bf Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 17 May 2022 11:20:29 +0200 Subject: [PATCH 54/98] Don't stop nr-softmodem on FEP thread exit cond --- openair1/SCHED_NR/nr_ru_procedures.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index 3d5e4a0ce4..fa9ff4564a 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -617,8 +617,7 @@ void nr_fep_full_2thread(RU_t *ru, int slot) { } if (proc->instance_cnt_fep==0) { - printf("[RU] FEP thread busy\n"); - exit_fun("FEP thread busy"); + LOG_E(PHY, "RU FEP thread busy, exiting %s\n", __func__); pthread_mutex_unlock( &proc->mutex_fep ); return; } From 078d6fa15bc34551a79b5ad74d2a50af80a5fdb7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 19 Jan 2022 14:42:01 +0100 Subject: [PATCH 55/98] threadCreate(): don't create detached threads A detached thread cannot be joined with pthread_join(). However, this is crucial for correct resetting of the nr-softmodem. Therefore, do not create threads in detached state. --- common/utils/system.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/utils/system.c b/common/utils/system.c index 00839b485c..f13fd84289 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -231,8 +231,6 @@ void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int settingPriority = 1; ret=pthread_attr_init(&attr); AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); - ret=pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); if (checkIfFedoraDistribution()) if (checkIfGenericKernelOnFedora()) From e63cc03c9d3571c07f53b00ccd881e31c4dfbcee Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 17 May 2022 11:18:25 +0200 Subject: [PATCH 56/98] Implement abortTpool() This stops all ongoing threads (using pthread_join()), and marks FIFOs to not block anymore. In this case, returned messages will be NULL. --- common/utils/threadPool/thread-pool.c | 20 ++++++-- common/utils/threadPool/thread-pool.h | 73 +++++++++++++++++++++++---- executables/nr-gnb.c | 6 +++ executables/nr-ru.c | 7 --- 4 files changed, 85 insertions(+), 21 deletions(-) diff --git a/common/utils/threadPool/thread-pool.c b/common/utils/threadPool/thread-pool.c index 5398fe2e7e..aa80fae829 100644 --- a/common/utils/threadPool/thread-pool.c +++ b/common/utils/threadPool/thread-pool.c @@ -48,9 +48,14 @@ void displayList(notifiedFIFO_t *nf) { static inline notifiedFIFO_elt_t *pullNotifiedFifoRemember( notifiedFIFO_t *nf, struct one_thread *thr) { mutexlock(nf->lockF); - while(!nf->outF) + while(!nf->outF && !thr->terminate) condwait(nf->notifF, nf->lockF); + if (thr->terminate) { + mutexunlock(nf->lockF); + return NULL; + } + notifiedFIFO_elt_t *ret=nf->outF; nf->outF=nf->outF->next; @@ -59,7 +64,7 @@ static inline notifiedFIFO_elt_t *pullNotifiedFifoRemember( notifiedFIFO_t *nf, // For abort feature thr->runningOnKey=ret->key; - thr->abortFlag=false; + thr->dropJob = false; mutexunlock(nf->lockF); return ret; } @@ -71,6 +76,10 @@ void *one_thread(void *arg) { // Infinite loop to process requests do { notifiedFIFO_elt_t *elt=pullNotifiedFifoRemember(&tp->incomingFifo, myThread); + if (elt == NULL) { + AssertFatal(myThread->terminate, "pullNotifiedFifoRemember() returned NULL although thread not aborted\n"); + break; + } if (tp->measurePerf) elt->startProcessingTime=rdtsc_oai(); @@ -82,14 +91,15 @@ void *one_thread(void *arg) { // Check if the job is still alive, else it has been aborted mutexlock(tp->incomingFifo.lockF); - if (myThread->abortFlag) + if (myThread->dropJob) delNotifiedFIFO_elt(elt); else pushNotifiedFIFO(elt->reponseFifo, elt); myThread->runningOnKey=-1; mutexunlock(tp->incomingFifo.lockF); } - } while (true); + } while (!myThread->terminate); + return NULL; } void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name) { @@ -137,6 +147,8 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name pool->allthreads->coreID=atoi(curptr); pool->allthreads->id=pool->nbThreads; pool->allthreads->pool=pool; + pool->allthreads->dropJob = false; + pool->allthreads->terminate = false; //Configure the thread scheduler policy for Linux // set the thread name for debugging sprintf(pool->allthreads->name,"%s%d_%d",tname,pool->nbThreads,pool->allthreads->coreID); diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index 17bc87f701..c07a6a073f 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -72,6 +72,7 @@ typedef struct notifiedFIFO_s { notifiedFIFO_elt_t *inF; pthread_mutex_t lockF; pthread_cond_t notifF; + bool abortFIFO; // if set, the FIFO always returns NULL -> abort condition } notifiedFIFO_t; // You can use this allocator or use any piece of memory @@ -107,6 +108,7 @@ static inline void delNotifiedFIFO_elt(notifiedFIFO_elt_t *elt) { static inline void initNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf) { nf->inF=NULL; nf->outF=NULL; + nf->abortFIFO = false; } static inline void initNotifiedFIFO(notifiedFIFO_t *nf) { mutexinit(nf->lockF); @@ -152,9 +154,9 @@ static inline notifiedFIFO_elt_t *pullNotifiedFIFO_nothreadSafe(notifiedFIFO_t static inline notifiedFIFO_elt_t *pullNotifiedFIFO(notifiedFIFO_t *nf) { mutexlock(nf->lockF); - notifiedFIFO_elt_t *ret; + notifiedFIFO_elt_t *ret = NULL; - while((ret=pullNotifiedFIFO_nothreadSafe(nf)) == NULL) + while((ret=pullNotifiedFIFO_nothreadSafe(nf)) == NULL && !nf->abortFIFO) condwait(nf->notifF, nf->lockF); mutexunlock(nf->lockF); @@ -167,6 +169,11 @@ static inline notifiedFIFO_elt_t *pollNotifiedFIFO(notifiedFIFO_t *nf) { if (tmp != 0 ) return NULL; + if (nf->abortFIFO) { + mutexunlock(nf->lockF); + return NULL; + } + notifiedFIFO_elt_t *ret=pullNotifiedFIFO_nothreadSafe(nf); mutexunlock(nf->lockF); return ret; @@ -217,13 +224,14 @@ struct one_thread { int coreID; char name[256]; uint64_t runningOnKey; - bool abortFlag; + bool dropJob; + bool terminate; struct thread_pool *pool; struct one_thread *next; }; typedef struct thread_pool { - int activated; + bool activated; bool measurePerf; int traceFd; int dummyTraceFd; @@ -256,6 +264,8 @@ static inline void pushTpool(tpool_t *t, notifiedFIFO_elt_t *msg) { static inline notifiedFIFO_elt_t *pullTpool(notifiedFIFO_t *responseFifo, tpool_t *t) { notifiedFIFO_elt_t *msg= pullNotifiedFIFO(responseFifo); + if (msg == NULL) + return NULL; AssertFatal(t->traceFd, "Thread pool used while not initialized"); if (t->measurePerf) msg->returnTime=rdtsc_oai(); @@ -284,6 +294,7 @@ static inline notifiedFIFO_elt_t *tryPullTpool(notifiedFIFO_t *responseFifo, tpo static inline int abortTpoolJob(tpool_t *t, uint64_t key) { int nbRemoved=0; notifiedFIFO_t *nf=&t->incomingFifo; + mutexlock(nf->lockF); notifiedFIFO_elt_t **start=&nf->outF; @@ -300,20 +311,62 @@ static inline int abortTpoolJob(tpool_t *t, uint64_t key) { if (t->incomingFifo.outF==NULL) t->incomingFifo.inF=NULL; - struct one_thread *ptr=t->allthreads; - - while(ptr!=NULL) { - if (ptr->runningOnKey==key) { - ptr->abortFlag=true; + struct one_thread *thread = t->allthreads; + while (thread != NULL) { + if (thread->runningOnKey == key) { + thread->dropJob = true; nbRemoved++; } - ptr=ptr->next; + thread = thread->next; } mutexunlock(nf->lockF); return nbRemoved; } +static inline int abortTpool(tpool_t *t) { + int nbRemoved=0; + /* disables threading: if a message comes in now, we cannot have a race below + * as each thread will simply execute the message itself */ + t->activated = false; + notifiedFIFO_t *nf=&t->incomingFifo; + mutexlock(nf->lockF); + nf->abortFIFO = true; + notifiedFIFO_elt_t **start=&nf->outF; + + /* mark threads to abort them */ + struct one_thread *thread = t->allthreads; + while (thread != NULL) { + thread->dropJob = true; + thread->terminate = true; + nbRemoved++; + thread = thread->next; + } + + /* clear FIFOs */ + while(*start!=NULL) { + notifiedFIFO_elt_t **request=start; + *start=(*start)->next; + delNotifiedFIFO_elt(*request); + *request = NULL; + nbRemoved++; + } + + if (t->incomingFifo.outF==NULL) + t->incomingFifo.inF=NULL; + + condbroadcast(t->incomingFifo.notifF); + mutexunlock(nf->lockF); + + /* join threads that are still runing */ + thread = t->allthreads; + while (thread != NULL) { + pthread_cancel(thread->threadID); + thread = thread->next; + } + + return nbRemoved; +} void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name); #define initTpool(PARAMPTR,TPOOLPTR, MEASURFLAG) initNamedTpool(PARAMPTR,TPOOLPTR, MEASURFLAG, NULL) #endif diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 8d9c6b1a7e..3e195e0046 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -467,6 +467,11 @@ void init_gNB_Tpool(int inst) { } +void term_gNB_Tpool(int inst) { + PHY_VARS_gNB *gNB = RC.gNB[inst]; + abortTpool(&gNB->threadPool); +} + /*! * \brief Terminate gNB TX and RX threads. */ @@ -609,6 +614,7 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { void stop_gNB(int nb_inst) { for (int inst=0; instidx); } - res = pullNotifiedFIFO(&gNB->resp_L1); - delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(&gNB->L1_tx_free); - delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(&gNB->L1_tx_free); - delNotifiedFIFO_elt(res); - ru_thread_status = 0; return &ru_thread_status; } From 178e2773ed28854f5074473ff3c358e8c6ab8a07 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 11:43:22 +0200 Subject: [PATCH 57/98] Handle abortFIFO in FIFO functions --- common/utils/threadPool/thread-pool.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index c07a6a073f..9b08bed8b8 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -131,14 +131,18 @@ static inline void pushNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf, notifiedFIF static inline void pushNotifiedFIFO(notifiedFIFO_t *nf, notifiedFIFO_elt_t *msg) { mutexlock(nf->lockF); - pushNotifiedFIFO_nothreadSafe(nf,msg); - condsignal(nf->notifF); + if (!nf->abortFIFO) { + pushNotifiedFIFO_nothreadSafe(nf,msg); + condsignal(nf->notifF); + } mutexunlock(nf->lockF); } static inline notifiedFIFO_elt_t *pullNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf) { if (nf->outF == NULL) return NULL; + if (nf->abortFIFO) + return NULL; notifiedFIFO_elt_t *ret=nf->outF; From d73e1a41335a12efdf662bb2e37c90800c277c3c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 11:44:11 +0200 Subject: [PATCH 58/98] Handle NULL return of pullTpool() --- executables/main-fs6.c | 2 ++ executables/nr-gnb.c | 9 ++++++++- executables/nr-ru.c | 2 ++ executables/nr-ue.c | 4 ++++ openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 2 ++ openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 2 ++ openair1/SCHED/phy_procedures_lte_eNb.c | 7 ++++++- openair1/SCHED_NR/fapi_nr_l1.c | 2 ++ openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 ++ 9 files changed, 30 insertions(+), 2 deletions(-) diff --git a/executables/main-fs6.c b/executables/main-fs6.c index fff4c51155..01dfc526e9 100644 --- a/executables/main-fs6.c +++ b/executables/main-fs6.c @@ -740,6 +740,8 @@ void pusch_procedures_fromsplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB * while (proc->nbDecode > 0) { notifiedFIFO_elt_t *req=pullTpool(proc->respDecode, proc->threadPool); + if (req == NULL) + break; // Tpool has been stopped postDecode(proc, req); delNotifiedFIFO_elt(req); } diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 3e195e0046..0db095c148 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -248,6 +248,8 @@ void rx_func(void *param) { // Its a FIFO so it maitains the order in which the MAC fills the messages // so no need for checking for right slot res = pullTpool(&gNB->L1_tx_filled, &gNB->threadPool); + if (res == NULL) + return; // Tpool has been stopped syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; syncMsg->timestamp_tx = info->timestamp_tx; @@ -255,6 +257,8 @@ void rx_func(void *param) { pushTpool(&gNB->threadPool, res); } else if (get_softmodem_params()->continuous_tx) { notifiedFIFO_elt_t *res = pullTpool(&gNB->L1_tx_free, &gNB->threadPool); + if (res == NULL) + return; // Tpool has been stopped processingData_L1tx_t *syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; syncMsg->timestamp_tx = info->timestamp_tx; @@ -377,6 +381,7 @@ void *tx_reorder_thread(void* param) { resL1Reserve = pullTpool(&gNB->L1_tx_out, &gNB->threadPool); + AssertFatal(resL1Reserve != NULL, "pullTpool() did not return start message in %s\n", __func__); int next_tx_slot=((processingData_L1tx_t *)NotifiedFifoData(resL1Reserve))->slot; while (!oai_exit) { @@ -390,7 +395,7 @@ void *tx_reorder_thread(void* param) { } } else { resL1 = pullTpool(&gNB->L1_tx_out, &gNB->threadPool); - if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { + if (resL1 != NULL && ((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { if (resL1Reserve) LOG_E(PHY,"error, have a stored packet, then a second one\n"); resL1Reserve = resL1; @@ -399,6 +404,8 @@ void *tx_reorder_thread(void* param) { LOG_E(PHY,"error, pull two msg, none is good\n"); } } + if (resL1 == NULL) + break; // Tpool has been stopped processingData_L1tx_t *syncMsgL1= (processingData_L1tx_t *)NotifiedFifoData(resL1); processingData_RU_t syncMsgRU; syncMsgRU.frame_tx = syncMsgL1->frame; diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 31c555e61d..b29947c9be 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1252,6 +1252,8 @@ void *ru_thread( void *param ) { // At this point, all information for subframe has been received on FH interface res = pullTpool(&gNB->resp_L1, &gNB->threadPool); + if (res == NULL) + break; // Tpool has been stopped syncMsg = (processingData_L1_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; syncMsg->frame_rx = proc->frame_rx; diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 616312a21a..7a981e9a58 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -692,6 +692,8 @@ void processSlotRX(void *arg) { // Wait for PUSCH processing to finish notifiedFIFO_elt_t *res; res = pullTpool(&rxtxD->txFifo,&(get_nrUE_params()->Tpool)); + if (res == NULL) + return; // Tpool has been stopped delNotifiedFIFO_elt(res); // calling UL_indication to schedule things other than PUSCH (eg, PUCCH) @@ -1008,6 +1010,8 @@ void *UE_thread(void *arg) { while (nbSlotProcessing >= NR_RX_NB_TH) { res=pullTpool(&nf, &(get_nrUE_params()->Tpool)); + if (res == NULL) + break; // Tpool has been stopped nbSlotProcessing--; nr_rxtx_thread_data_t *tmp=(nr_rxtx_thread_data_t *)res->msgData; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 5b57cd125f..af00abddc5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -430,6 +430,8 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, } while(nbJobs) { notifiedFIFO_elt_t *req=pullTpool(&nf, &gNB->threadPool); + if (req == NULL) + break; // Tpool has been stopped delNotifiedFIFO_elt(req); nbJobs--; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 5aa792fb19..7bfc2203dc 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -615,6 +615,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } for (r=0; rthreadPool->activated ) { // Wait all other threads finish to process while (proc->nbEncode) { - delNotifiedFIFO_elt(pullTpool(proc->respEncode, proc->threadPool)); + notifiedFIFO_elt_t *res = pullTpool(proc->respEncode, proc->threadPool); + if (res == NULL) + break; // Tpool has been stopped + delNotifiedFIFO_elt(res); proc->nbEncode--; } } @@ -1502,6 +1505,8 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { while (proc->nbDecode > 0) { notifiedFIFO_elt_t *req=pullTpool(proc->respDecode, proc->threadPool); + if (req == NULL) + break; // Tpool has been stopped postDecode(proc, req); delNotifiedFIFO_elt(req); } diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 2c61704508..49e6edd54e 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -164,6 +164,8 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ if (slot_type == NR_DOWNLINK_SLOT || slot_type == NR_MIXED_SLOT) { notifiedFIFO_elt_t *res; res = pullTpool(&gNB->L1_tx_free, &gNB->threadPool); + if (res == NULL) + return; // Tpool has been stopped, nothing to process processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); const time_stats_t ts = exec_time_stats_NotifiedFIFO(res); merge_meas(&gNB->phy_proc_tx, &ts); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 1298ce3d49..684869dbd9 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -364,6 +364,8 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH while (gNB->nbDecode > 0) { notifiedFIFO_elt_t *req = pullTpool(&gNB->respDecode, &gNB->threadPool); + if (req == NULL) + break; // Tpool has been stopped nr_postDecode(gNB, req); delNotifiedFIFO_elt(req); } From dfd9a91b5035f98b611328efba6f4f5c7c0328a1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 16:04:54 +0200 Subject: [PATCH 59/98] Rename abortNotifiedFIFO() to abortNotifiedFIFOJob() --- common/utils/threadPool/thread-pool.c | 4 ++-- common/utils/threadPool/thread-pool.h | 2 +- executables/nr-ue.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 2 +- openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/utils/threadPool/thread-pool.c b/common/utils/threadPool/thread-pool.c index aa80fae829..3e0cf9feb9 100644 --- a/common/utils/threadPool/thread-pool.c +++ b/common/utils/threadPool/thread-pool.c @@ -203,12 +203,12 @@ int main() { tmp=pullNotifiedFIFO(&myFifo); printf("pulled: %lu\n", tmp->key); displayList(&myFifo); - abortNotifiedFIFO(&myFifo,1005); + abortNotifiedFIFOJob(&myFifo,1005); printf("aborted 1005\n"); displayList(&myFifo); pushNotifiedFIFO(&myFifo,newNotifiedFIFO_elt(sizeof(struct testData), 12345678, NULL, NULL)); displayList(&myFifo); - abortNotifiedFIFO(&myFifo,12345678); + abortNotifiedFIFOJob(&myFifo,12345678); printf("aborted 12345678\n"); displayList(&myFifo); diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index 9b08bed8b8..6dc8d6ae8c 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -200,7 +200,7 @@ static inline time_stats_t exec_time_stats_NotifiedFIFO(const notifiedFIFO_elt_t // This function aborts all messages matching the key // If the queue is used in thread pools, it doesn't cancels already running processing // because the message has already been picked -static inline int abortNotifiedFIFO(notifiedFIFO_t *nf, uint64_t key) { +static inline int abortNotifiedFIFOJob(notifiedFIFO_t *nf, uint64_t key) { mutexlock(nf->lockF); int nbDeleted=0; notifiedFIFO_elt_t **start=&nf->outF; diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 7a981e9a58..821325f5f1 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -863,7 +863,7 @@ void *UE_thread(void *arg) { while (!oai_exit) { if (UE->lost_sync) { int nb = abortTpoolJob(&(get_nrUE_params()->Tpool),RX_JOB_ID); - nb += abortNotifiedFIFO(&nf, RX_JOB_ID); + nb += abortNotifiedFIFOJob(&nf, RX_JOB_ID); LOG_I(PHY,"Number of aborted slots %d\n",nb); for (int i=0; ikey); - nb+=abortNotifiedFIFO(nf_p, req->key); + nb+=abortNotifiedFIFOJob(nf_p, req->key); LOG_D(PHY,"downlink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); LOG_D(PHY, "DLSCH %d in error\n",rdata->dlsch_id); last = true; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 71946e73da..db03a9dc43 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1332,7 +1332,7 @@ void postDecode(L1_rxtx_proc_t *proc, notifiedFIFO_elt_t *req) { } else { if ( rdata->nbSegments != ulsch_harq->processedSegments ) { int nb=abortTpoolJob(proc->threadPool, req->key); - nb+=abortNotifiedFIFO(proc->respDecode, req->key); + nb+=abortNotifiedFIFOJob(proc->respDecode, req->key); proc->nbDecode-=nb; LOG_D(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 684869dbd9..650af0bf34 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -207,7 +207,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { } else { if ( rdata->nbSegments != ulsch_harq->processedSegments ) { int nb = abortTpoolJob(&gNB->threadPool, req->key); - nb += abortNotifiedFIFO(&gNB->respDecode, req->key); + nb += abortNotifiedFIFOJob(&gNB->respDecode, req->key); gNB->nbDecode-=nb; LOG_D(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 828456adbe..222cd1da7d 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -88,7 +88,7 @@ int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { } else { if ( rdata->nbSegments != ulsch_harq->processedSegments ) { int nb=abortTpoolJob(&gNB->threadPool, req->key); - nb+=abortNotifiedFIFO(&gNB->respDecode, req->key); + nb+=abortNotifiedFIFOJob(&gNB->respDecode, req->key); gNB->nbDecode-=nb; AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", ulsch_harq->processedSegments, nb, rdata->nbSegments); From 31dcdf2152c91d61ba968a7a7f21f47c75181a0e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 16:05:14 +0200 Subject: [PATCH 60/98] Implement abortNotifiedFIFO() to unlock FIFO waits --- common/utils/threadPool/thread-pool.h | 18 ++++++++++++++++++ executables/nr-gnb.c | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index 6dc8d6ae8c..1a06e4c655 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -222,6 +222,24 @@ static inline int abortNotifiedFIFOJob(notifiedFIFO_t *nf, uint64_t key) { return nbDeleted; } +// This functions aborts all messages in the queue, and marks the queue as +// "aborted", such that every call to it will return NULL +static inline void abortNotifiedFIFO(notifiedFIFO_t *nf) { + mutexlock(nf->lockF); + nf->abortFIFO = true; + notifiedFIFO_elt_t **elt = &nf->outF; + while(*elt != NULL) { + notifiedFIFO_elt_t *p = *elt; + *elt = (*elt)->next; + delNotifiedFIFO_elt(p); + } + + if (nf->outF == NULL) + nf->inF = NULL; + mutexunlock(nf->lockF); + condsignal(nf->notifF); +} + struct one_thread { pthread_t threadID; int id; diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 0db095c148..388d701b83 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -477,6 +477,11 @@ void init_gNB_Tpool(int inst) { void term_gNB_Tpool(int inst) { PHY_VARS_gNB *gNB = RC.gNB[inst]; abortTpool(&gNB->threadPool); + abortNotifiedFIFO(&gNB->respDecode); + abortNotifiedFIFO(&gNB->resp_L1); + abortNotifiedFIFO(&gNB->L1_tx_free); + abortNotifiedFIFO(&gNB->L1_tx_filled); + abortNotifiedFIFO(&gNB->L1_tx_out); } /*! From fafed7d18170076e35ea34fc8bcb5575c30acdf1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 16:55:12 +0200 Subject: [PATCH 61/98] Remove unused restrictRNTI variable in Tpool --- common/utils/threadPool/thread-pool.c | 5 ----- common/utils/threadPool/thread-pool.h | 1 - 2 files changed, 6 deletions(-) diff --git a/common/utils/threadPool/thread-pool.c b/common/utils/threadPool/thread-pool.c index 3e0cf9feb9..d1af56b477 100644 --- a/common/utils/threadPool/thread-pool.c +++ b/common/utils/threadPool/thread-pool.c @@ -123,7 +123,6 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name char *saveptr, * curptr; char *parms_cpy=strdup(params); pool->nbThreads=0; - pool->restrictRNTI=false; curptr=strtok_r(parms_cpy,",",&saveptr); struct one_thread * ptr; char *tname = (name == NULL ? "Tpool" : name); @@ -131,10 +130,6 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name int c=toupper(curptr[0]); switch (c) { - case 'U': - pool->restrictRNTI=true; - break; - case 'N': pool->activated=false; break; diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index 1a06e4c655..0e4630117d 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -260,7 +260,6 @@ typedef struct thread_pool { uint64_t cpuCyclesMicroSec; uint64_t startProcessingUE; int nbThreads; - bool restrictRNTI; notifiedFIFO_t incomingFifo; struct one_thread *allthreads; } tpool_t; From 9ec3deb5bd7e22d6e6cf57a203fffd3c26d108c8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 18:31:05 +0200 Subject: [PATCH 62/98] Improve thread pool documentation --- common/utils/threadPool/thread-pool.md | 219 +++++++++++++++---------- 1 file changed, 130 insertions(+), 89 deletions(-) diff --git a/common/utils/threadPool/thread-pool.md b/common/utils/threadPool/thread-pool.md index 50c9214d84..249951666c 100644 --- a/common/utils/threadPool/thread-pool.md +++ b/common/utils/threadPool/thread-pool.md @@ -1,59 +1,69 @@ # Thread pool -The thread pool is a working server, made of a set of worker threads that can be mapped on CPU cores. +The **thread pool** is a working server, made of a set of worker threads that can be mapped on CPU cores. Each thread pool has an **input queue** ("**FIFO**"), from which its workers pick **jobs** (FIFO element) to execute. When a job is done, the worker sends a message to an output queue, if it has been defined. -Each worker loop on pick from the same input queue jobs to do. +A selective abort allows to cancel parallel jobs. This can be useful, e.g., if a client pushed jobs, but from a response of one job, the other linked jobs become useless. -When a job is done, the worker sends a return if a return is defined. - -A selective abort allows to cancel parallel jobs (usage: a client pushed jobs, but from a response of one job, the other linked jobs becomes useless). - -All the thread pool functions are thread safe, nevertheless the working functions are implemented by the thread pool client, so the client has to tackle the parallel execution of his functions called "processingFunc" hereafter. +All the thread pool functions are thread safe. The functions executed by worker threads are provided by the thread pool client, so the client has to handle the concurrency/parallel execution of his functions. ## license Author: Laurent Thomas, Open cells project The owner share this piece code to Openairsoftware alliance as per OSA license terms + With contributions from Robert Schmidt, OSA -# jobs +# Jobs -A job is a message (`notifiedFIFO_elt_t`): +A job is a message of type `notifiedFIFO_elt_t`: -* `next`: - internal FIFO chain, do not set it -* `key`: - a long int that the client can use to identify a message or a group of messages -* `ResponseFifo`: - if the client defines a response FIFO, the message will be posted back after processing -* `processingFunc`: - any funtion (type `void processingFunc(void *)`) that the worker will launch -* `msgData`: - the data passed to processingFunc. It can be added automatically, or you can set it to a buffer you are managing -* `malloced`: - a boolean that enable internal free in these cases: - no return Fifo or Abort feature +* `next`: internal FIFO chain, do not set it +* `key`: a `long int` that the client can use to identify a job or a group of messages +* `ResponseFifo`: if the client defines a response FIFO, the job will be posted back after processing +* `processingFunc`: any function (of type `void processingFunc(void *)`) that a worker will process +* `msgData`: the data passed to `processingFunc`. It can be added automatically, or you can set it to a buffer you are managing +* `malloced`: a boolean that enables internal free in the case of no return FIFO or abort feature -The job messages can be created with `newNotifiedFIFO_elt()` and `delNotifiedFIFO_elt()` or managed by the client. +The job messages can be created and destroyed with `newNotifiedFIFO_elt()` and `delNotifiedFIFO_elt()`, or managed by the client: -# Queues of jobs +* `newNotifiedFIFO_elt()`: Creates a job, that will later be used in queues/FIFO +* `delNotifiedFIFO_elt()`: Deletes a job +* `NotifiedFifoData()`: gives a pointer to the beginning of free usage memory in a job (you can put any data there, up to 'size' parameter you passed to `newNotifiedFIFO_elt()`) -Queues are type of: +These 3 calls are not mandatory, you can also use your own memory to save the `malloc()`/`free()` that are behind these calls. -* `notifiedFIFO_t` that must be initialized by `init_notifiedFIFO()` +## API details + +### `notifiedFIFO_elt_t *newNotifiedFIFO_elt(int size, uint64_t key, notifiedFIFO_t *reponseFifo, void (*processingFunc)(void *))` + +Creates a new job. The data part of the job will have size `size`, the job can be identified via `key`. `reponseFifo` is a FIFO queue to which the job should be pushed after being processed by a thread pool (see below for details) using function `processingFunc()`. + +The function returns a pointer to an allocated job. + +### `void delNotifiedFIFO_elt(notifiedFIFO_elt_t *elt)` + +Free the memory allocated for a job `elt`. + +### `void *NotifiedFifoData(notifiedFIFO_elt_t *elt)` + +Returns a pointer (`void *`) to the data segment of an allocated job. + +# Queues of jobs (`FIFO`) + +Queues can be used to enqueue messages/jobs, of type `notifiedFIFO_t`. + +* `initNotifiedFIFO()`: Create a queue * No delete function is required, the creator has only to free the data of type `notifiedFIFO_t` -* `push_notifiedFIFO()` add a job in the queue -* `pull_notifiedFIFO()` is blocking, `poll_notifiedFIFO()` is non blocking -* `abort_notifiedFIFO()` allows the customer to delete all waiting jobs that match with the key (see key in jobs definition) +* `pushNotifiedFIFO()`: Add a job to a queue +* `pullNotifiedFIFO()`: Pull a job from a queue. This call is blocking until a job arrived. +* `pollNotifiedFIFO()`: Pull a job from a queue. This call is not blocking, so it returns always very shortly +* `abortNotifiedFIFOJob()`: Allows to delete all waiting jobs that match a key (see `key` in jobs definition) +* `abortNotifiedFIFO()`: Aborts a FIFO, such that it will always return `NULL` -## Thread-safe functions +Note that in 99.9% of cases, `pull()` is better than `poll()`. -* `newNotifiedFIFO_elt()`: creates a message, that will later be used in queues/FIFO -* `delNotifiedFIFO_elt()`: deletes it -* `NotifiedFifoData()`: gives a pointer to the beginning of free usage memory in a message (you can put any data there, up to 'size' parameter you passed to `newNotifiedFIFO_elt()`) +The above push/pull/poll functions are built on not-thread-safe versions of these functions that are described below. -These 3 calls are not mandatory, you can also use your own memory to save the `malloc()`/`free()` that are behind these calls - -# Low level: fast and simple, but not thread-safe +## Low level: fast and simple, but not thread-safe * `initNotifiedFIFO_nothreadSafe()`: Create a queue * `pushNotifiedFIFO_nothreadSafe()`: Add a element in a queue @@ -63,113 +73,144 @@ As these queues are not thread safe, there is NO blocking mechanism, neither `pu There is no delete for a message queue: you only have to abandon the memory you allocated to call `initNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf)` -So if you malloced the memory under 'nf' parameter you have to free it, if it is automatic variable (local variable) or global variable, nothing is to be done. +If you malloced the memory under `nf` parameter, you have to free it. +## FIFO queue abort -## thread safe queues +It is possible to *abort* the FIFO queue. In this case, any pulling/polling of jobs in the queue will return `NULL`. This can be used when stopping a program, to release multiple queues that might depend on each other (a proper design would try to avoid such dependencies, though). -These queues are built on not thread safe queues when we need thread to thread protection +## API details -* `initNotifiedFIFO()`: Create a queue -* `pushNotifiedFIFO()`: Add a element in a queue -* `pullNotifiedFIFO()`: Pull a element from a queue, this call is blocking until a message arrived -* `pollNotifiedFIFO()`: Pull a element from a queue, this call is not blocking, so it returns always very shortly +### `void initNotifiedFIFO(notifiedFIFO_t *nf)` +### `void initNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf)` -Note that in 99.9% cases, `pull()` is better than `poll()` +Initializes a FIFO queue pointed to by `nf` ("notified FIFO"). -No `delete()` call, same principle as not thread safe queues +### `void pushNotifiedFIFO(notifiedFIFO_t *nf, notifiedFIFO_elt_t *msg)` +### `void pushNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf, notifiedFIFO_elt_t *msg)` + +Pushes a job `msg` to the FIFO queue `nf`. + +### `notifiedFIFO_elt_t *pullNotifiedFIFO(notifiedFIFO_t *nf)` + +Pulls a job from a FIFO queue `nf`. The returned pointer points to the job. This call is blocking, i.e., a caller will be blocked until there is a message. + +If the FIFO has been aborted, the returned pointer will be `NULL`. In other words, if the call to this functions returns `NULL`, the FIFO has been deactivated. + +### `notifiedFIFO_elt_t *pollNotifiedFIFO(notifiedFIFO_t *nf)` +### `notifiedFIFO_elt_t *pullNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf)` + +Like `pullNotifiedFIFO()`, but non-blocking: they check if the queue `nf` contains a job, and return it. Otherwise, they return `NULL`. Note the slight difference in naming: the thread-safe function is called *poll*, not *pull*. + +Note that unlike for `pullNotifiedFIFO()`, returning `NULL` does not inform whether the queue has been aborted; the caller should manually check the `abortFIFO` flag of `nf` in this case. + +### `int abortNotifiedFIFOJob(notifiedFIFO_t *nf, uint64_t key)` + +Aborts all jobs in FIFO queue `nf` with key `key`. Jobs already under execution will be silently dropped and not put in the FIFO return queue, if any. + +Returns the number of aborted jobs. + +### `void abortNotifiedFIFO(notifiedFIFO_t *nf)` + +Aborts the entire FIFO queue `nf`: all jobs will be dropped, and the FIFO is marked as aborted, such that a call to `pullNotifiedFIFO()` returns `NULL`. + +Returns the total number of jobs that were waiting or under execution. # Thread pools -## initialization +## Initialization -The clients can create one or more thread pools with `initTpool(char *params,tpool_t *pool, bool performanceMeas )` or `initNamedTpool(char *params,tpool_t *pool, bool performanceMeas , char *name)` +The clients can create one or more thread pools with -the `params` string structure: describes a list of cores, separated by "," that run a worker thread +* `initTpool(char *params, tpool_t *pool, bool performanceMeas)` or +* `initNamedTpool(char *params,tpool_t *pool, bool performanceMeas , char *name)` -If the core exists on the CPU, the thread pool initialization sets the affinity between this thread and the related code (use negative values is allowed, so the thread will never be mapped on a specific core). +The threads are governed by the Linux real time scheduler, and their name is set automatically to `Tpool_` if `initTpool()` is used or to `_` when `initNamedTpool()` is used. -The threads are all Linux real time scheduler, their name is set automatically to `Tpool_` if initTpool is used or to `_` when initNamedTpool is used. +## Adding jobs -## adding jobs -The client create their jobs messages as a `notifiedFIFO_elt_t`, then they push it with `pushTpool()` (that internally calls `push_notifiedFIFO()`) +The client create their jobs messages as a `notifiedFIFO_elt_t`. They then push it with `pushTpool()` which internally calls `push_notifiedFIFO()`. -If they need a return, they have to create response queues with `init_notifiedFIFO()` and set this FIFO pointer in the `notifiedFIFO_elt_t` before pushing the job. +If they need a return value (e.g., result of a computation), they have to create response queues with `init_notifiedFIFO()` and set this FIFO pointer in the `notifiedFIFO_elt_t` before pushing the job. This way, multiple result queues can be used in one thread pool. -## abort +## Abort -A abort service `abortTpoolJob()` allows to abort all jobs that match a key (see jobs "key"). When the abort returns, it garanties no job (matching the key) response will be posted on response queues. +A abort service `abortTpoolJob()` allows to abort all jobs that match a key (see a job's `key`). When the abort returns, it garanties that no job (matching the key) response will be posted on response queues. Nevertheless, jobs already performed before the return of `abortTpoolJob()` are pushed in the response Fifo queue. -`abortTpool()` kills all jobs in the Tpool. +`abortTpool()` kills all jobs in the Tpool, and terminates the pool. ## API details + Each thread pool (there can be several in the same process) should be initialized once using one of the two API's: -### `initNamedTpool(char *params,tpool_t *pool, bool performanceMeas,char *name)` +### `void initNamedTpool(char *params, tpool_t *pool, bool performanceMeas, char *name)` -### `initTpool(char *params,tpool_t *pool, bool performanceMeas)` +### `void initTpool(char *params, tpool_t *pool, bool performanceMeas)` -`params`: the configuration parameter is a string, elements separator is a comma ",". An element can be: -* `N`: if a N is in the parameter list, no threads are created - The purpose is to keep the same API in any case -* a CPU with a little number of cores, - or in debugging sessions to simplify the human work -* a number that represent a valid CPU core on the target CPU - A thread is created and stick on the core (with set affinity) -* a number that is not a valid CPU core - a floating thread is created (Linux is responsible of the real time core allocation) +The `params` string describes a list of cores, separated by "," that run a worker thread. If the core exists on the CPU, the thread pool initialization sets the affinity between this thread and the related core. The following options are available: -example: `"-1,-1,-1"` -as there is no core number -1, the thread pool is made of 3 floating threads -be careful with fix allocation: it is hard to be more clever than Linux kernel +* `N`: if an `N` is in the parameter list, no threads are created, and the threadpool will be disabled (jobs will be treated by each calling thread independently). +* A number that represent a valid CPU core on the target CPU, i.e., if there are `M` cores, a number within `[0,M-1]`: A thread is created and pinned to the core (with set affinity) +* `-1`: The thread will not be mapped onto a specific core (a "floating" thread) -`pool` is the memory you allocated before to store the thread pool internal state (same concept as above queues) +Example: `-1,-1,-1`: the thread pool is made of 3 floating threads. +Be careful with a fixed allocation: it is hard to be more clever than Linux kernel! -`performanceMeas` is a flag to enable measurements (well described in documentation) +`pool` is a pointer to the thread pool object. + +`performanceMeas` is a flag to enable measurements (see also below). `name` is used to build the thread names. -### `pushTpool(tpool_t *t, notifiedFIFO_elt_t *msg)` +### `void pushTpool(tpool_t *t, notifiedFIFO_elt_t *msg)` -adds a job to do in the thread pool +Adds a job for processing in the thread pool. -The msg data you can set are: +The job data you can set are, inside `msg`: -* `key`: a value for you that you will find back in the response it is also the key for `abortTpoolJob()` -* `reponseFifo`: if you set it, the message will be sent back on this queue when the job is done if you don't set it, no return is performed, the thread pool frees the message 'msg' when the job is done -* `processingFunc`: the function the job will run. the function prototype is `void (void *memory)` the data part (the pointer returned by `NotifiedFifoData(msg)`) is passed to the function it is used to send data to the processing function and also to write back results of course, writing back results will lead you to use also a return queue (the parameter `reponseFifo`) +* `key`: an arbitrary key to find a job in a response queue, and which can be used to abort jobs using `abortTpoolJob()`. +* `reponseFifo`: if non-`NULL`, the message will be sent back on this queue when the job is done. If `NULL`, the thread pool automatically frees the job when it is done. +* `processingFunc`: the function to execute for this job. -### `pullTpool()` collects job result in a return queue +The `processingFunc` prototype is `void (void *memory)`. The data part of the job (the pointer returned by `NotifiedFifoData(msg)`) is passed to the function. The job data will be updated by `processingFunc`, and the job will be pushed into return queue (the parameter `reponseFifo`). -you collect results in one result queue: the message you gave to `pushTpool()`, nevertheless it has been updated by `processingFunc()` +### `notifiedFIFO_elt_t *pullTpool(notifiedFIFO_t *responseFifo, tpool_t *t)` -An example of multiple return queues, in eNB: I created one single thread pool (because it depends mainly on CPU hardware), but i use two return queues: one for turbo encode, one for turbo decode. +Collects a job result in a return queue that has been defined in `msg` when calling `pushTpool()`, and that has been updated by `processingFunc()`. Returns the corresponding job pointer of type `notifiedFIFO_elt_t *`. -### `tryPullTpool()` +Multiple return queues might be useful. Consider the following example in the eNB: I created one single thread pool (because it depends mainly on CPU hardware), but i use two return queues: one for turbo encode, one for turbo decode. Thus, when performing Turbo encoding/decoding, jobs are pushed into a single thread pool, but will end up in different result queues, such that DL/UL processing can be separated more easily. -is the same, but not blocking (`pollTpool()` would have been a better name) +### `notifiedFIFO_elt_t *tryPullTpool(notifiedFIFO_t *responseFifo, tpool_t *t)` -### `abortTpoolJob()` +The same as `pullTpool()` in a non-blocking fashion (an alternative name would have been `pollTpool()`). -Is a facility to cancel work you pushed to a thread pool +### `int abortTpoolJob(tpool_t *t, uint64_t key)` -I used it once: when eNB performs turbo decode, I push all segments in the thread pool. +Is a facility to cancel work you pushed to a thread pool: every job with a given `key` will be deleted, and results of jobs with such `key` under execution will be dropped. -But when I get back the decoding results, if one segment can't be decoded, I don't need the results of the other segments of the same UE. +It returns the number of aborted jobs, including the ones that are currently being executed. + +I used it once: when eNB performs turbo decode, I push all segments in the thread pool. But when I get back the decoding results, if one segment can't be decoded, I don't need the results of the other segments of the same UE. + +### `int abortTpool(tpool_t *t)` + +Aborts the complete Tpool: cancel every work in the input queue, marks to drop existing jobs in processing, and terminates all worker threads. It is afterwards still possible to call functions such as `pushTpool()`, but each calling thread will execute the job itself. + +Returns the total number of jobs that were aborted, i.e., waiting for execution or being executed. ## Performance measurements -A performance measurement is integrated: the pool will automacillay fill timestamps if you set the environement variable `threadPoolMeasurements` to a valid file name. The following measurements will be written to Linux pipe. +A performance measurement is integrated: the pool will automacillay fill timestamps if you set the environement variable `threadPoolMeasurements` to a valid file name. The following measurements will be written to Linux pipe on a per-job basis: * `creationTime`: time the request is push to the pool; * `startProcessingTime`: time a worker start to run on the job * `endProcessingTime`: time the worker finished the job * `returnTime`: time the client reads the result -The `measurement_display` tool to read the Linux pipe and display it in ascii is provided. +The `measurement_display` tool to read the Linux pipe and display it in ASCII is provided. In the cmake build directory, type `make/ninja measurement_display`. Use as follows: ``` From 1512e39e4e6f8e869d9ae2a1912be34278f64d77 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 17 May 2022 11:18:37 +0200 Subject: [PATCH 63/98] Rewrite kill_NR_RU_proc() and reuse functions --- executables/nr-ru.c | 42 ++++++++++------------------ openair1/SCHED_NR/nr_ru_procedures.c | 31 ++++++++++++++++++++ openair1/SCHED_NR/sched_nr.h | 2 ++ 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index b29947c9be..2f75c2d295 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1331,40 +1331,26 @@ void init_RU_proc(RU_t *ru) { } + void kill_NR_RU_proc(int inst) { RU_t *ru = RC.ru[inst]; RU_proc_t *proc = &ru->proc; - LOG_D(PHY, "Joining pthread_FH\n"); + + /* Note: it seems pthread_FH and and FEP thread below both use + * mutex_fep/cond_fep. Thus, we unlocked above for pthread_FH above and do + * the same for FEP thread below again (using broadcast() to ensure both + * threads get the signal). This one will also destroy the mutex and cond. */ + pthread_mutex_lock(&proc->mutex_fep); + proc->instance_cnt_fep = 0; + pthread_cond_broadcast(&proc->cond_fep); + pthread_mutex_unlock( &proc->mutex_fep ); pthread_join(proc->pthread_FH, NULL); - if (get_nprocs() >= 2) { - if (ru->feprx) { - pthread_mutex_lock(&proc->mutex_fep); - proc->instance_cnt_fep = 0; - pthread_mutex_unlock(&proc->mutex_fep); - pthread_cond_signal(&proc->cond_fep); - LOG_D(PHY, "Joining pthread_fep\n"); - pthread_join(proc->pthread_fep, NULL); - pthread_mutex_destroy(&proc->mutex_fep); - pthread_cond_destroy(&proc->cond_fep); - } + if (ru->feprx) + nr_kill_feprx_thread(ru); - if (ru->feptx_ofdm) { - pthread_mutex_lock(&proc->mutex_feptx); - proc->instance_cnt_feptx = 0; - pthread_mutex_unlock(&proc->mutex_feptx); - pthread_cond_signal(&proc->cond_feptx); - LOG_D(PHY, "Joining pthread_feptx\n"); - pthread_join(proc->pthread_feptx, NULL); - pthread_mutex_destroy(&proc->mutex_feptx); - pthread_cond_destroy(&proc->cond_feptx); - } - } - - if (opp_enabled) { - LOG_D(PHY, "Joining ru_stats_thread\n"); - pthread_join(ru->ru_stats_thread, NULL); - } + if (ru->feptx_ofdm) + nr_kill_feptx_thread(ru); } int check_capabilities(RU_t *ru,RRU_capabilities_t *cap) { diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index fa9ff4564a..a93ac0ded2 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -453,6 +453,24 @@ void nr_init_feptx_thread(RU_t *ru) { } +void nr_kill_feptx_thread(RU_t *ru) { + RU_proc_t *proc = &ru->proc; + + for (int i = 0; i < ru->nb_tx * 2; i++) { + RU_feptx_t *feptx = &proc->feptx[i]; + if (feptx->pthread_feptx == 0) + continue; + + pthread_mutex_lock(&feptx->mutex_feptx); + feptx->instance_cnt_feptx = 0; + pthread_mutex_unlock(&feptx->mutex_feptx); + pthread_cond_signal(&feptx->cond_feptx); + LOG_I(PHY, "Joining pthread_feptx %d\n", i); + pthread_join(feptx->pthread_feptx, NULL); + pthread_mutex_destroy(&feptx->mutex_feptx); + pthread_cond_destroy(&feptx->cond_feptx); + } +} void nr_feptx_prec(RU_t *ru,int frame_tx,int tti_tx) { @@ -590,6 +608,19 @@ void nr_init_feprx_thread(RU_t *ru) { threadCreate(&proc->pthread_fep, nr_feprx_thread, (void*)ru, "feprx", -1, OAI_PRIORITY_RT); } +void nr_kill_feprx_thread(RU_t *ru) { + RU_proc_t *proc = &ru->proc; + if (proc->pthread_fep == 0) + return; + LOG_I(PHY, "Joining pthread_feprx\n"); + pthread_mutex_lock(&proc->mutex_fep); + proc->instance_cnt_fep = 0; + pthread_mutex_unlock(&proc->mutex_fep); + pthread_cond_signal(&proc->cond_fep); + pthread_join(proc->pthread_fep, NULL); + pthread_mutex_destroy(&proc->mutex_fep); + pthread_cond_destroy(&proc->cond_fep); +} void nr_fep_full_2thread(RU_t *ru, int slot) { diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index 2124397c47..22b341623e 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -45,11 +45,13 @@ void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx); void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx); void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols, int aa); void nr_init_feptx_thread(RU_t *ru); +void nr_kill_feptx_thread(RU_t *ru); void fep_full(RU_t *ru,int slot); void nr_feptx_prec(RU_t *ru,int frame_tx,int tti_tx); void nr_init_feptx_prec_thread(RU_t *ru); void nr_feptx_prec_control(RU_t *ru,int frame,int tti_tx); void nr_init_feprx_thread(RU_t *ru); +void nr_kill_feprx_thread(RU_t *ru); void nr_fep_full(RU_t *ru, int slot); void nr_fep_full_2thread(RU_t *ru, int slot); void feptx_prec(RU_t *ru,int frame_tx,int tti_tx); From 004d6d3bab05dc124134f26c639f52bc037e3735 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 12:17:15 +0200 Subject: [PATCH 64/98] Correctly stop tx_reorder and L1_stats threads --- executables/nr-gnb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 388d701b83..0bac9ce3eb 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -482,6 +482,11 @@ void term_gNB_Tpool(int inst) { abortNotifiedFIFO(&gNB->L1_tx_free); abortNotifiedFIFO(&gNB->L1_tx_filled); abortNotifiedFIFO(&gNB->L1_tx_out); + + gNB_L1_proc_t *proc = &gNB->proc; + if (!get_softmodem_params()->emulate_l1) + pthread_join(proc->L1_stats_thread, NULL); + pthread_join(proc->pthread_tx_reorder, NULL); } /*! From 0ae3d3027d4223180c6fde061664ce994a8d5d7f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 18 Jan 2022 14:23:54 +0100 Subject: [PATCH 65/98] Don't call trx_end_func() at nr-softmodem, is done in ru_thread() --- executables/nr-softmodem.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 3a47a6bc79..5a4ce42941 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -850,9 +850,6 @@ int main( int argc, char **argv ) { // *** Handle per CC_id openair0 for(ru_id=0; ru_idrfdevice.trx_end_func) - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - if (RC.ru[ru_id]->ifdevice.trx_end_func) RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); } From e28bd9ff2af93acb4e078f12a6dc122d88c349bc Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 18 May 2022 13:56:51 +0200 Subject: [PATCH 66/98] Free USRP objects in trx_usrp_end() --- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 7c0180e5e7..281066a881 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -318,11 +318,24 @@ static void trx_usrp_end(openair0_device *device) { usrp_state_t *s = (usrp_state_t *)device->priv; - if (s == NULL) - return; + AssertFatal(s != NULL, "%s() called on uninitialized USRP\n", __func__); iqrecorder_end(device); + LOG_I(HW, "releasing USRP\n"); + s->tx_stream->~tx_streamer(); + s->rx_stream->~rx_streamer(); + s->usrp->~multi_usrp(); + free(s); + device->priv = NULL; + device->trx_start_func = NULL; + device->trx_get_stats_func = NULL; + device->trx_reset_stats_func = NULL; + device->trx_end_func = NULL; + device->trx_stop_func = NULL; + device->trx_set_freq_func = NULL; + device->trx_set_gains_func = NULL; + device->trx_write_init = NULL; } /*! \brief Called to send samples to the USRP RF target From 69cf59f32dd8edf10b11ba98816e3d8bdffcee45 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 19 Jul 2022 11:13:15 +0200 Subject: [PATCH 67/98] Stop USRP write thread if necessary --- targets/ARCH/COMMON/common_lib.h | 2 ++ targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 0f11447bf4..3434e40c87 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -310,6 +310,8 @@ typedef struct { pthread_cond_t cond_write; /// mutex for trx write thread pthread_mutex_t mutex_write; + /// to inform the thread to exit + bool write_thread_exit; } openair0_thread_t; /*!\brief structure holds the parameters to configure USRP devices */ diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 281066a881..93b3c72189 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -309,6 +309,9 @@ static int trx_usrp_start(openair0_device *device) { return 0; } + +static void trx_usrp_write_reset(openair0_thread_t *wt); + /*! \brief Terminate operation of the USRP transceiver -- free all associated resources * \param device the hardware to use */ @@ -322,6 +325,8 @@ static void trx_usrp_end(openair0_device *device) { iqrecorder_end(device); LOG_I(HW, "releasing USRP\n"); + if (usrp_tx_thread != 0) + trx_usrp_write_reset(&device->write_thread); s->tx_stream->~tx_streamer(); s->rx_stream->~rx_streamer(); @@ -518,6 +523,8 @@ void *trx_usrp_write_thread(void * arg){ while (write_thread->count_write == 0) { pthread_cond_wait(&write_thread->cond_write,&write_thread->mutex_write); // this unlocks mutex_rxtx while waiting and then locks it again } + if (write_thread->write_thread_exit) + break; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_THREAD, 1 ); s = (usrp_state_t *)device->priv; start = write_thread->start; @@ -612,6 +619,7 @@ int trx_usrp_write_init(openair0_device *device){ write_thread->start = 0; write_thread->end = 0; write_thread->count_write = 0; + write_thread->write_thread_exit = false; printf("end of tx write thread\n"); pthread_mutex_init(&write_thread->mutex_write, NULL); pthread_cond_init(&write_thread->cond_write, NULL); @@ -620,6 +628,17 @@ int trx_usrp_write_init(openair0_device *device){ return(0); } +static void trx_usrp_write_reset(openair0_thread_t *wt) { + pthread_mutex_lock(&wt->mutex_write); + wt->count_write = 1; + wt->write_thread_exit = true; + pthread_mutex_unlock(&wt->mutex_write); + pthread_cond_signal(&wt->cond_write); + void *retval = NULL; + pthread_join(wt->pthread_write, &retval); + LOG_I(HW, "stopped USRP write thread\n"); +} + //---------------------end------------------------- /*! \brief Receive samples from hardware. From 7e82f2f4e87ee96914cce7b81f9849e9b62e0a36 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Sun, 2 May 2021 21:15:11 +0200 Subject: [PATCH 68/98] sending small end-of-burst TX packet when exiting softmodem --- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 93b3c72189..f9cc4a111a 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -310,6 +310,23 @@ static int trx_usrp_start(openair0_device *device) { return 0; } +static void trx_usrp_send_end_of_burst(usrp_state_t *s) { + // if last packet sent was end of burst no need to do anything. otherwise send end of burst packet + if (s->tx_md.end_of_burst) + return; + + s->tx_md.end_of_burst = true; + s->tx_md.start_of_burst = false; + s->tx_md.has_time_spec = false; + + int32_t dummy = 0; + std::vector buffs; + for (size_t ch = 0; ch < s->tx_stream->get_num_channels(); ch++) + buffs.push_back(&dummy); // same buffer for each channel + + s->tx_stream->send(buffs, 0, s->tx_md); +} + static void trx_usrp_write_reset(openair0_thread_t *wt); /*! \brief Terminate operation of the USRP transceiver -- free all associated resources @@ -328,6 +345,7 @@ static void trx_usrp_end(openair0_device *device) { if (usrp_tx_thread != 0) trx_usrp_write_reset(&device->write_thread); + trx_usrp_send_end_of_burst(s); s->tx_stream->~tx_streamer(); s->rx_stream->~rx_streamer(); s->usrp->~multi_usrp(); From 649e059f9070493b4ff56c4d9618452b2c7cec3e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 29 Jun 2022 15:40:49 +0200 Subject: [PATCH 69/98] RFsim: Mark FD non-blocking once; show errno on problem --- targets/ARCH/rfsimulator/simulator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index 127b2975d5..e8992637eb 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -225,15 +225,16 @@ enum blocking_t { }; static void setblocking(int sock, enum blocking_t active) { - int opts; - AssertFatal( (opts = fcntl(sock, F_GETFL)) >= 0,""); + int opts = fcntl(sock, F_GETFL); + AssertFatal(opts >= 0, "fcntl(): errno %d, %s\n", errno, strerror(errno)); if (active==blocking) opts = opts & ~O_NONBLOCK; else opts = opts | O_NONBLOCK; - AssertFatal(fcntl(sock, F_SETFL, opts) >= 0, ""); + opts = fcntl(sock, F_SETFL, opts); + AssertFatal(opts >= 0, "fcntl(): errno %d, %s\n", errno, strerror(errno)); } static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps); @@ -248,7 +249,6 @@ static void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t) "Bug: %d/%p/%zd/%p", fd, _buf, count, t); char *buf = _buf; ssize_t l; - setblocking(fd, notBlocking); while (count) { l = write(fd, buf, count); From fffb2d14de4bfbbdf314f32f4cd4ed383f213b45 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 19 Jan 2022 16:14:59 +0100 Subject: [PATCH 70/98] Close rfsimulator sockets --- targets/ARCH/rfsimulator/simulator.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index e8992637eb..a74a9b8679 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -740,7 +740,15 @@ static int rfsimulator_get_stats(openair0_device *device) { static int rfsimulator_reset_stats(openair0_device *device) { return 0; } -static void rfsimulator_end(openair0_device *device) {} +static void rfsimulator_end(openair0_device *device) { + rfsimulator_state_t* s = device->priv; + for (int i = 0; i < FD_SETSIZE; i++) { + buffer_t *b = &s->buf[i]; + if (b->conn_sock >= 0 ) + close(b->conn_sock); + } + close(s->epollfd); +} static int rfsimulator_stop(openair0_device *device) { return 0; } From 61ead59d136547b3df3e5a4c950d14585e52b138 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 18 May 2022 15:36:52 +0200 Subject: [PATCH 71/98] Check oai_exit in wait_on_condition() and friends, no volatile --- common/utils/LOG/log.c | 2 +- executables/main-ocp.c | 2 +- executables/main_ru.c | 2 +- executables/nr-ru.c | 2 +- executables/nr-softmodem-common.h | 2 +- executables/nr-softmodem.c | 2 +- executables/nr-uesoftmodem.c | 2 +- executables/softmodem-common.h | 2 +- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 2 +- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 2 +- openair1/PHY/defs_common.h | 11 ++++++----- openair1/SIMULATION/LTE_PHY/unitary_defs.h | 2 +- openair1/SIMULATION/NR_PHY/nr_unitary_defs.h | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 2 +- targets/RT/USER/lte-enb.c | 2 +- targets/RT/USER/lte-ru.c | 2 +- targets/RT/USER/lte-softmodem.c | 2 +- targets/RT/USER/lte-softmodem.h | 2 +- targets/RT/USER/lte-uesoftmodem.c | 2 +- 19 files changed, 24 insertions(+), 23 deletions(-) diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 8be3568034..9953bf2933 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -808,7 +808,7 @@ void logClean (void) } } -extern volatile int oai_exit;//extern int oai_exit; +extern int oai_exit; void flush_mem_to_file(void) { int fp; diff --git a/executables/main-ocp.c b/executables/main-ocp.c index 5d949d5a28..3a1ad6ec19 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -71,7 +71,7 @@ pthread_cond_t sync_cond; pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. int config_sync_var=-1; -volatile int oai_exit = 0; +int oai_exit = 0; double cpuf; THREAD_STRUCT thread_struct; diff --git a/executables/main_ru.c b/executables/main_ru.c index 93a580560e..3b1ce1116b 100644 --- a/executables/main_ru.c +++ b/executables/main_ru.c @@ -73,7 +73,7 @@ pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. int config_sync_var=-1; -volatile int oai_exit = 0; +int oai_exit = 0; uint16_t sf_ahead = 4; RU_t ru_m; diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 2f75c2d295..baff757312 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -80,7 +80,7 @@ static int DEFBFW[] = {0x00007fff}; #include "nfapi_interface.h" #include -extern volatile int oai_exit; +extern int oai_exit; extern struct timespec timespec_sub(struct timespec lhs, struct timespec rhs); extern struct timespec timespec_add(struct timespec lhs, struct timespec rhs); diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index 1e6c556acf..e4e4eee8ce 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -138,7 +138,7 @@ extern int rx_input_level_dBm; extern uint64_t num_missed_slots; // counter for the number of missed slots extern int oaisim_flag; -extern volatile int oai_exit; +extern int oai_exit; extern openair0_config_t openair0_cfg[MAX_CARDS]; extern pthread_cond_t sync_cond; diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 5a4ce42941..b8b2d7b038 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -93,7 +93,7 @@ int sync_var=-1; //!< protected by mutex \ref sync_mutex. int config_sync_var=-1; volatile int start_gNB = 0; -volatile int oai_exit = 0; +int oai_exit = 0; static int wait_for_sync = 0; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index de3c108841..92dab90014 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -105,7 +105,7 @@ instance_t CUuniqInstance=0; instance_t DUuniqInstance=0; RAN_CONTEXT_t RC; -volatile int oai_exit = 0; +int oai_exit = 0; extern int16_t nr_dlsch_demod_shift; diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index a2ba680234..9c7108151e 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -283,7 +283,7 @@ extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; extern int usrp_tx_thread; extern uint16_t sl_ahead; extern uint16_t sf_ahead; -extern volatile int oai_exit; +extern int oai_exit; void tx_func(void *param); void rx_func(void *param); diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 13109d8f5a..a5aff0974e 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -59,7 +59,7 @@ uint64_t deadline, uint64_t period);*/ -extern volatile int oai_exit; +extern int oai_exit; void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { int i, r, aa, layer; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index fceff580a3..a6dde08a2c 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -44,7 +44,7 @@ #include extern WORKER_CONF_t get_thread_worker_conf(void); -extern volatile int oai_exit; +extern int oai_exit; diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index c93e3a7de9..892fb7c864 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -982,13 +982,14 @@ typedef uint8_t(encoder_if_t)(uint8_t *input, uint8_t *output, uint8_t F); +extern int oai_exit; static inline void wait_sync(char *thread_name) { int rc; printf( "waiting for sync (%s,%d/%p,%p,%p)\n",thread_name,sync_var,&sync_var,&sync_cond,&sync_mutex); AssertFatal((rc = pthread_mutex_lock( &sync_mutex ))==0,"sync mutex lock error"); - while (sync_var<0) + while (sync_var<0 && !oai_exit) pthread_cond_wait( &sync_cond, &sync_mutex ); AssertFatal((rc = pthread_mutex_unlock( &sync_mutex ))==0,"sync mutex unlock error"); @@ -1011,7 +1012,7 @@ static inline int wakeup_thread(pthread_mutex_t *mutex, int sleep_cnt=0; AssertFatal((rc = pthread_mutex_lock(mutex))==0,"wakeup_thread(): error locking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); - while (*instance_cnt == 0) { + while (*instance_cnt == 0 && !oai_exit) { AssertFatal((rc = pthread_mutex_unlock(mutex))==0,"wakeup_thread(): error unlocking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); sleep_cnt++; @@ -1046,7 +1047,7 @@ static inline int timedwait_on_condition(pthread_mutex_t *mutex, struct timespec now, abstime; AssertFatal((rc = pthread_mutex_lock(mutex))==0,"[SCHED][eNB] timedwait_on_condition(): error locking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); - while (*instance_cnt < 0) { + while (*instance_cnt < 0 && !oai_exit) { clock_gettime(CLOCK_REALTIME, &now); // most of the time the thread is waiting here // proc->instance_cnt_rxtx is -1 @@ -1073,7 +1074,7 @@ static inline int wait_on_condition(pthread_mutex_t *mutex, int rc; AssertFatal((rc = pthread_mutex_lock(mutex))==0,"[SCHED][eNB] wait_on_condition(): error locking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); - while (*instance_cnt < 0) { + while (*instance_cnt < 0 && !oai_exit) { // most of the time the thread is waiting here // proc->instance_cnt_rxtx is -1 pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again @@ -1091,7 +1092,7 @@ static inline int wait_on_busy_condition(pthread_mutex_t *mutex, int rc; AssertFatal((rc = pthread_mutex_lock(mutex))==0,"[SCHED][eNB] wait_on_busy_condition(): error locking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); - while (*instance_cnt == 0) { + while (*instance_cnt == 0 && !oai_exit) { // most of the time the thread will skip this // waits only if proc->instance_cnt_rxtx is 0 pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again diff --git a/openair1/SIMULATION/LTE_PHY/unitary_defs.h b/openair1/SIMULATION/LTE_PHY/unitary_defs.h index 10a5366082..342fa18fb9 100644 --- a/openair1/SIMULATION/LTE_PHY/unitary_defs.h +++ b/openair1/SIMULATION/LTE_PHY/unitary_defs.h @@ -20,7 +20,7 @@ */ openair0_device openair0; -volatile int oai_exit=0; +int oai_exit=0; void exit_function(const char* file, const char* function, const int line,const char *s) { const char * msg= s==NULL ? "no comment": s; diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h index 805913d055..d3af2acd77 100644 --- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h +++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h @@ -33,7 +33,7 @@ #ifndef __NR_UNITARY_DEFS__H__ #define __NR_UNITARY_DEFS__H__ -volatile int oai_exit=0; +int oai_exit=0; void exit_function(const char* file, const char* function, const int line, const char *s) { const char * msg= s==NULL ? "no comment": s; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 9adc6ecb5d..14a16f572b 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -134,7 +134,7 @@ notifiedFIFO_t pdcp_sdu_list; pdcp_enb_t pdcp_enb[MAX_NUM_CCs]; -extern volatile int oai_exit; +extern int oai_exit; pthread_t pdcp_stats_thread_desc; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 3d62d5c19a..b99d97a180 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -106,7 +106,7 @@ struct timing_info_t { // Fix per CC openair rf/if device update // extern openair0_device openair0; -extern volatile int oai_exit; +extern int oai_exit; extern int transmission_mode; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 1d464cb90c..859a5c40a2 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -78,7 +78,7 @@ static int DEFBFW[] = {0x00007fff}; #define MBMS_EXPERIMENTAL -extern volatile int oai_exit; +extern int oai_exit; extern clock_source_t clock_source; #include "executables/thread-common.h" //extern PARALLEL_CONF_t get_thread_parallel_conf(void); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 5d17cc17bb..b1275e5dd5 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -106,7 +106,7 @@ uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] -volatile int oai_exit = 0; +int oai_exit = 0; uint64_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 38b71238b8..851c983290 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -146,7 +146,7 @@ extern int rx_input_level_dBm; extern uint64_t num_missed_slots; // counter for the number of missed slots extern int oaisim_flag; -extern volatile int oai_exit; +extern int oai_exit; extern openair0_config_t openair0_cfg[MAX_CARDS]; extern pthread_cond_t sync_cond; diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 05602b63da..963044a506 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -99,7 +99,7 @@ int config_sync_var=-1; uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] -volatile int oai_exit = 0; +int oai_exit = 0; unsigned int mmapped_dma=0; From 9957056f383b7b4db416f3e3525cef1849df60b9 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 19 May 2022 17:54:53 +0200 Subject: [PATCH 72/98] Drop empty logging statement --- common/utils/LOG/log.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 9953bf2933..8aad1475ef 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -800,8 +800,6 @@ void logClean (void) int i; if(isLogInitDone()) { - LOG_UI(PHY,"\n"); - for (i=MIN_LOG_COMPONENTS; i < MAX_LOG_COMPONENTS; i++) { close_component_filelog(i); } From 2465f1fb51da80922fc7168ac3e55ca56d60bf8d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 29 Jun 2022 12:44:33 +0200 Subject: [PATCH 73/98] Don't allocate gNB rxdataF, it is managed at the RU Removes phy_procedures_gNB_common_RX() (only used in nr_ulsim) + fixes in pucchsim --- doc/SW_archi.md | 1 - executables/nr-gnb.c | 12 ++--- openair1/PHY/INIT/nr_init.c | 11 ++--- openair1/PHY/INIT/nr_init_ru.c | 6 +-- openair1/PHY/defs_gNB.h | 4 -- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 27 ----------- openair1/SCHED_NR/sched_nr.h | 1 - openair1/SIMULATION/NR_PHY/pucchsim.c | 6 +++ openair1/SIMULATION/NR_PHY/ulsim.c | 57 ++++++++++++++++------- 9 files changed, 55 insertions(+), 70 deletions(-) diff --git a/doc/SW_archi.md b/doc/SW_archi.md index 0a53bf3793..01d3c377d4 100644 --- a/doc/SW_archi.md +++ b/doc/SW_archi.md @@ -101,7 +101,6 @@ raw incoming data is in buffer called "rxdata" ## nr_fep_full() "front end processing" of uplink signal performs DFT on the signal -same function (duplicates): phy_procedures_gNB_common_RX() it computes the buffer rxdataF (for frequency) from rxdata (samples over time) rxdataF is the rxdata in frequency domain, phase aligned {: .func3} diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 0bac9ce3eb..14eefa1e32 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -555,15 +555,9 @@ void init_eNB_afterRU(void) { gNB->RU_list[ru_id]->idx); for (i=0; iRU_list[ru_id]->nb_rx; aa++,i++) { - LOG_I(PHY,"Attaching RU %d antenna %d to gNB antenna %d\n",gNB->RU_list[ru_id]->idx,i,aa); - gNB->prach_vars.rxsigF[aa] = gNB->RU_list[ru_id]->prach_rxsigF[0][i]; -#if 0 -printf("before %p\n", gNB->common_vars.rxdataF[aa]); -#endif - gNB->common_vars.rxdataF[aa] = gNB->RU_list[ru_id]->common.rxdataF[i]; -#if 0 -printf("after %p\n", gNB->common_vars.rxdataF[aa]); -#endif + LOG_I(PHY,"Attaching RU %d antenna %d to gNB antenna %d\n",gNB->RU_list[ru_id]->idx,i,aa); + gNB->prach_vars.rxsigF[aa] = gNB->RU_list[ru_id]->prach_rxsigF[0][i]; + gNB->common_vars.rxdataF[aa] = gNB->RU_list[ru_id]->common.rxdataF[i]; } } diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index fec343ccfb..6b984f53db 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -627,6 +627,8 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, common_vars->txdataF = (int32_t **)malloc16(Ptx*sizeof(int32_t*)); common_vars->rxdataF = (int32_t **)malloc16(Prx*sizeof(int32_t*)); + /* Do NOT allocate per-antenna txdataF/rxdataF: the gNB gets a pointer to the + * RU to copy/recover freq-domain memory from there */ common_vars->beam_id = (uint8_t **)malloc16(Ptx*sizeof(uint8_t*)); for (i=0;ibeam_id[i] = (uint8_t*)malloc16_clear(fp->symbols_per_slot*fp->slots_per_frame*sizeof(uint8_t)); memset(common_vars->beam_id[i],255,fp->symbols_per_slot*fp->slots_per_frame); } - for (i=0;irxdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); - } common_vars->debugBuff = (int32_t*)malloc16_clear(fp->samples_per_frame*sizeof(int32_t)*100); common_vars->debugBuff_sample_offset = 0; @@ -782,10 +781,8 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(common_vars->beam_id[i]); } - for (int i = 0; i < Prx; ++i) { - free_and_zero(common_vars->rxdataF[i]); - } - + /* Do NOT free per-antenna txdataF/rxdataF: the gNB gets a pointer to the + * RU's txdataF/rxdataF, and the RU will free that */ free_and_zero(common_vars->txdataF); free_and_zero(common_vars->rxdataF); free_and_zero(common_vars->beam_id); diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index d12834d620..0a357a5255 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -201,10 +201,8 @@ void nr_phy_free_RU(RU_t *ru) free_and_zero(ru->common.txdataF_BF); // free FFT output buffers (RX) - // HACK: cannot free here, or the gNB code in phy_free_nr_gNB() will - // segfault. The rxdataF memory between RU and gNB is not properly handled! - //for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdataF[i]); - //free_and_zero(ru->common.rxdataF); + for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdataF[i]); + free_and_zero(ru->common.rxdataF); for (j=0;jnb_rx; i++) diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 2235521bb1..ef66bf5fef 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -396,10 +396,6 @@ typedef struct { } NR_gNB_SRS_t; typedef struct { - /// \brief Pointers (dynamic) to the received data in the time domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ - int32_t **rxdata; /// \brief Pointers (dynamic) to the received data in the frequency domain. /// - first index: rx antenna [0..nb_antennas_rx[ /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 650af0bf34..7c6a2eb998 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -582,33 +582,6 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { } -void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { - - uint8_t symbol; - unsigned char aa; - - for(symbol = 0; symbol < (gNB->frame_parms.Ncp==EXTENDED?12:14); symbol++) { - for (aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) { - nr_slot_fep_ul(&gNB->frame_parms, - gNB->common_vars.rxdata[aa], - gNB->common_vars.rxdataF[aa], - symbol, - slot_rx, - 0); - } - } - - for (aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) { - apply_nr_rotation_ul(&gNB->frame_parms, - gNB->common_vars.rxdataF[aa], - slot_rx, - 0, - gNB->frame_parms.Ncp==EXTENDED?12:14, - gNB->frame_parms.ofdm_symbol_size); - } - -} - int fill_srs_reported_symbol_list(nfapi_nr_srs_indication_reported_symbol_t *reported_symbol_list, const nfapi_nr_srs_pdu_t *srs_pdu, const int N_RB_UL, diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index 22b341623e..eff8a9fbcd 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -37,7 +37,6 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_scf_t *cfg, NR_DL_FRAME_PARMS *fp); void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, int frame_tx, int slot_tx, int do_meas); -void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot); void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_dl_tti_ssb_pdu ssb_pdu); diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index df83a818c0..1d1d2f8fa5 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -390,6 +390,10 @@ int main(int argc, char **argv) cfg->carrier_config.num_rx_ant.value = n_rx; nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); phy_init_nr_gNB(gNB,0,0); + /* RU handles rxdataF, and gNB just has a pointer. Here, we don't have an RU, + * so we need to allocate that memory as well. */ + for (i = 0; i < n_rx; i++) + gNB->common_vars.rxdataF[i] = malloc16_clear(gNB->frame_parms.samples_per_frame_wCP*sizeof(int32_t)); double fs,txbw,rxbw; uint32_t samples; @@ -702,6 +706,8 @@ int main(int argc, char **argv) free_channel_desc_scm(UE2gNB); term_freq_channel(); + for (i = 0; i < n_rx; i++) + free(gNB->common_vars.rxdataF[i]); phy_free_nr_gNB(gNB); free(RC.gNB[0]); free(RC.gNB); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 4bee028a6d..f4dece26ff 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -794,8 +794,17 @@ int main(int argc, char **argv) gNB->chest_freq = chest_type[0]; gNB->chest_time = chest_type[1]; phy_init_nr_gNB(gNB,0,1); + /* RU handles rxdataF, and gNB just has a pointer. Here, we don't have an RU, + * so we need to allocate that memory as well. */ + for (i = 0; i < n_rx; i++) + gNB->common_vars.rxdataF[i] = malloc16_clear(gNB->frame_parms.samples_per_frame_wCP*sizeof(int32_t)); N_RB_DL = gNB->frame_parms.N_RB_DL; + /* no RU: need to have rxdata */ + c16_t **rxdata; + rxdata = malloc(n_rx * sizeof(*rxdata)); + for (int i = 0; i < n_rx; ++i) + rxdata[i] = malloc(gNB->frame_parms.samples_per_frame * sizeof(**rxdata)); NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]; @@ -1025,18 +1034,16 @@ int main(int argc, char **argv) fseek(input_fd,file_offset*sizeof(int16_t)*2,SEEK_SET); for (int irx=0; irxnb_antennas_rx; irx++) { fseek(input_fd,irx*(slot_length+15)*sizeof(int16_t)*2,SEEK_SET); // matlab adds samlples to the end to emulate channel delay - read_errors+=fread((void*)&gNB->common_vars.rxdata[irx][slot_offset-delay], - sizeof(int16_t), - slot_length<<1, - input_fd); + read_errors += fread((void *)&rxdata[irx][slot_offset-delay], sizeof(int16_t), slot_length<<1, input_fd); if (read_errors==0) { printf("error reading file\n"); exit(1); } - for (int i=0;i<16;i+=2) printf("slot_offset %d : %d,%d\n", - slot_offset, - ((int16_t*)&gNB->common_vars.rxdata[irx][slot_offset])[i], - ((int16_t*)&gNB->common_vars.rxdata[irx][slot_offset])[1+i]); + for (int i=0;i<16;i+=2) + printf("slot_offset %d : %d,%d\n", + slot_offset, + rxdata[irx][slot_offset].r, + rxdata[irx][slot_offset].i); } mod_order = nr_get_Qm_ul(Imcs, mcs_table); @@ -1325,12 +1332,11 @@ int main(int argc, char **argv) for (i=0; inb_antennas_rx; ap++) { - ((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i) + (delay*2)] = (int16_t)((r_re[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); // convert to fixed point - ((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i)+1 + (delay*2)] = (int16_t)((r_im[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); + rxdata[ap][slot_offset+i+delay].r = (int16_t)((r_re[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); // convert to fixed point + rxdata[ap][slot_offset+i+delay].i = (int16_t)((r_im[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); /* Add phase noise if enabled */ if (pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { - phase_noise(ts, &((int16_t*)&gNB->common_vars.rxdata[ap][slot_offset])[(2*i)], - &((int16_t*)&gNB->common_vars.rxdata[ap][slot_offset])[(2*i)+1]); + phase_noise(ts, &rxdata[ap][slot_offset].r, &rxdata[ap][slot_offset].i); } } } @@ -1356,19 +1362,36 @@ int main(int argc, char **argv) gNB->UL_INFO.rx_ind.number_of_pdus = 0; gNB->UL_INFO.crc_ind.number_crcs = 0; - phy_procedures_gNB_common_RX(gNB, frame, slot); + for(uint8_t symbol = 0; symbol < (gNB->frame_parms.Ncp == EXTENDED ? 12 : 14); symbol++) { + for (int aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) + nr_slot_fep_ul(&gNB->frame_parms, + (int32_t*) rxdata[aa], + gNB->common_vars.rxdataF[aa], + symbol, + slot, + 0); + } + + for (int aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) { + apply_nr_rotation_ul(&gNB->frame_parms, + gNB->common_vars.rxdataF[aa], + slot, + 0, + gNB->frame_parms.Ncp == EXTENDED ? 12 : 14, + gNB->frame_parms.ofdm_symbol_size); + } ul_proc_error = phy_procedures_gNB_uespec_RX(gNB, frame, slot); if (n_trials==1 && round==0) { - LOG_M("rxsig0.m","rx0",&gNB->common_vars.rxdata[0][slot_offset],slot_length,1,1); + LOG_M("rxsig0.m","rx0",&rxdata[0][slot_offset],slot_length,1,1); LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0],14*frame_parms->ofdm_symbol_size,1,1); if (precod_nbr_layers > 1) { - LOG_M("rxsig1.m","rx1",&gNB->common_vars.rxdata[1][slot_offset],slot_length,1,1); + LOG_M("rxsig1.m","rx1",&rxdata[1][slot_offset],slot_length,1,1); LOG_M("rxsigF1.m","rxsF1",gNB->common_vars.rxdataF[1],14*frame_parms->ofdm_symbol_size,1,1); if (precod_nbr_layers==4) { - LOG_M("rxsig2.m","rx2",&gNB->common_vars.rxdata[2][slot_offset],slot_length,1,1); - LOG_M("rxsig3.m","rx3",&gNB->common_vars.rxdata[3][slot_offset],slot_length,1,1); + LOG_M("rxsig2.m","rx2",&rxdata[2][slot_offset],slot_length,1,1); + LOG_M("rxsig3.m","rx3",&rxdata[3][slot_offset],slot_length,1,1); LOG_M("rxsigF2.m","rxsF2",gNB->common_vars.rxdataF[2],14*frame_parms->ofdm_symbol_size,1,1); LOG_M("rxsigF3.m","rxsF3",gNB->common_vars.rxdataF[3],14*frame_parms->ofdm_symbol_size,1,1); } From 51a7b7bd6e9666aad8667559befbb525c7d2db8d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 12:50:02 +0200 Subject: [PATCH 74/98] Remove memory leaks in FAPI PUCCH 0-4 PDU handling --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 37 +++++++++++++------ openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 19 +--------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 68900cda35..e1d8c47544 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -909,21 +909,26 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, 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++; } + + // tpc (power control) only if we received AckNack + if (uci_01->harq->harq_confidence_level==0) + sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, uci_01->ul_cqi, 30); + else + sched_ctrl->tpc1 = 3; + sched_ctrl->pucch_snrx10 = uci_01->ul_cqi * 5 - 640; + + free(uci_01->harq->harq_list); + free(uci_01->harq); } // check scheduling request result, confidence_level == 0 is good - if (uci_01->pduBitmap & 0x1 && uci_01->sr->sr_indication && uci_01->sr->sr_confidence_level == 0 && uci_01->ul_cqi >= 148) { - // SR detected with SNR >= 10dB - sched_ctrl->SR |= true; - LOG_D(NR_MAC, "SR UE %04x ul_cqi %d\n", uci_01->rnti, uci_01->ul_cqi); - } - - // tpc (power control) only if we received AckNack or positive SR. For a - // negative SR, the UE won't have sent anything, and the SNR is not valid - if (((uci_01->pduBitmap >> 1) & 0x1) ) { - if ((uci_01->harq) && (uci_01->harq->harq_confidence_level==0)) sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, uci_01->ul_cqi, 30); - else sched_ctrl->tpc1 = 3; - sched_ctrl->pucch_snrx10 = uci_01->ul_cqi * 5 - 640; + if (uci_01->pduBitmap & 0x1) { + if (uci_01->sr->sr_indication && uci_01->sr->sr_confidence_level == 0 && uci_01->ul_cqi >= 148) { + // SR detected with SNR >= 10dB + sched_ctrl->SR |= true; + LOG_D(NR_MAC, "SR UE %04x ul_cqi %d\n", uci_01->rnti, uci_01->ul_cqi); + } + free(uci_01->sr); } } @@ -950,6 +955,11 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, // 30); //sched_ctrl->pucch_snrx10 = uci_234->ul_cqi * 5 - 640; + // TODO: handle SR + if (uci_234->pduBitmap & 0x1) { + free(uci_234->sr.sr_payload); + } + if ((uci_234->pduBitmap >> 1) & 0x01) { // iterate over received harq bits for (int harq_bit = 0; harq_bit < uci_234->harq.harq_bit_len; harq_bit++) { @@ -962,15 +972,18 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, 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]->dl_bler.harq_round_max); } + free(uci_234->harq.harq_payload); } if ((uci_234->pduBitmap >> 2) & 0x01) { //API to parse the csi report and store it into sched_ctrl extract_pucch_csi_report(csi_MeasConfig, uci_234, frame, slot, UE, RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon); //TCI handling function tci_handling(UE,frame, slot); + free(uci_234->csi_part1.csi_part1_payload); } if ((uci_234->pduBitmap >> 3) & 0x01) { //@TODO:Handle CSI Report 2 + // nothing to free (yet) } } diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 47705082d1..f295d95184 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -265,23 +265,8 @@ static void free_unqueued_nfapi_indications(nfapi_nr_rach_indication_t *rach_ind } if (uci_ind && uci_ind->num_ucis > 0) { - for (int i = 0; i < uci_ind->num_ucis; i++) { - switch (uci_ind->uci_list[i].pdu_type) { - case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: - if (uci_ind->uci_list[i].pucch_pdu_format_0_1.harq) { - free_and_zero(uci_ind->uci_list[i].pucch_pdu_format_0_1.harq->harq_list); - } - free_and_zero(uci_ind->uci_list[i].pucch_pdu_format_0_1.harq); - free_and_zero(uci_ind->uci_list[i].pucch_pdu_format_0_1.sr); - break; - - case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: - free_and_zero(uci_ind->uci_list[i].pucch_pdu_format_2_3_4.harq.harq_payload); - free_and_zero(uci_ind->uci_list[i].pucch_pdu_format_2_3_4.csi_part1.csi_part1_payload); - free_and_zero(uci_ind->uci_list[i].pucch_pdu_format_2_3_4.csi_part2.csi_part2_payload); - break; - } - } + /* PUCCH fields (HARQ, SR) are freed in handle_nr_uci_pucch_0_1() and + * handle_nr_uci_pucch_2_3_4() */ free_and_zero(uci_ind->uci_list); free_and_zero(uci_ind); } From 19d83ad21e0f2b8bfee26eea74bcd8bcb0082f8d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 1 Jul 2022 18:12:53 +0200 Subject: [PATCH 75/98] Make GTPV1U REQ in one allocation to avoid mem leak at GTP --- openair2/SDAP/nr_sdap/nr_sdap_entity.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.c b/openair2/SDAP/nr_sdap/nr_sdap_entity.c index 5e3627296c..c1fcdced79 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap_entity.c +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.c @@ -197,18 +197,20 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity, } // Pushing SDAP SDU to GTP-U Layer - MessageDef *message_p; - uint8_t *gtpu_buffer_p; - gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U, size + GTPU_HEADER_OVERHEAD_MAX - offset); - AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY"); - memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], buf+offset, size-offset); - message_p = itti_alloc_new_message(TASK_PDCP_ENB, 0 , GTPV1U_GNB_TUNNEL_DATA_REQ); + MessageDef *message_p = itti_alloc_new_message_sized(TASK_PDCP_ENB, + 0, + GTPV1U_GNB_TUNNEL_DATA_REQ, + sizeof(gtpv1u_gnb_tunnel_data_req_t) + + size + GTPU_HEADER_OVERHEAD_MAX - offset); AssertFatal(message_p != NULL, "OUT OF MEMORY"); - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p; - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).length = size-offset; - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX; - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).rnti = rnti; - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).pdusession_id = pdusession_id; + gtpv1u_gnb_tunnel_data_req_t *req = >PV1U_GNB_TUNNEL_DATA_REQ(message_p); + uint8_t *gtpu_buffer_p = (uint8_t *) (req + 1); + memcpy(gtpu_buffer_p + GTPU_HEADER_OVERHEAD_MAX, buf + offset, size - offset); + req->buffer = gtpu_buffer_p; + req->length = size - offset; + req->offset = GTPU_HEADER_OVERHEAD_MAX; + req->rnti = rnti; + req->pdusession_id = pdusession_id; LOG_D(SDAP, "%s() sending message to gtp size %d\n", __func__, size-offset); itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); } else { //nrUE From 1df60139e27ec58eb59812043e46339b15d707e6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 14:43:15 +0200 Subject: [PATCH 76/98] Automatically close GTP sockets at program end --- openair3/ocp-gtpu/gtp_itf.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index dc93960e5e..afef8ea435 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -142,6 +142,12 @@ class gtpEndPoints { pthread_mutex_t gtp_lock=PTHREAD_MUTEX_INITIALIZER; // the instance id will be the Linux socket handler, as this is uniq map instances; + + ~gtpEndPoints() { + // automatically close all sockets on quit + for (const auto p : instances) + close(p.first); + } }; gtpEndPoints globGtp; From d08ef0490dacbe60a1dcca948c848a477c231af7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 1 Jul 2022 18:08:10 +0200 Subject: [PATCH 77/98] Correctly call stop functions in nr-softmodem main --- executables/nr-softmodem.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index b8b2d7b038..616a712f38 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -823,21 +823,21 @@ int main( int argc, char **argv ) { } #endif*/ - printf("stopping MODEM threads\n"); - // cleanup - stop_gNB(NB_gNB_INST); - if (RC.nb_nr_L1_inst > 0) { - stop_RU(NB_RU); - } + // cleanup + if (RC.nb_nr_L1_inst > 0) + stop_gNB(RC.nb_nr_L1_inst); + + if (RC.nb_RU > 0) + stop_RU(RC.nb_RU); /* release memory used by the RU/gNB threads (incomplete), after all * threads have been stopped (they partially use the same memory) */ - for (int inst = 0; inst < NB_RU; inst++) { + for (int inst = 0; inst < RC.nb_RU; inst++) { nr_phy_free_RU(RC.ru[inst]); } - for (int inst = 0; inst < NB_gNB_INST; inst++) { + for (int inst = 0; inst < RC.nb_nr_L1_inst; inst++) { phy_free_nr_gNB(RC.gNB[inst]); } @@ -849,7 +849,7 @@ int main( int argc, char **argv ) { // *** Handle per CC_id openair0 - for(ru_id=0; ru_idifdevice.trx_end_func) RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); } From 6f40b6190ca5586b57fdfd3aa254a23d61c5179d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 4 Jul 2022 09:57:27 +0200 Subject: [PATCH 78/98] Stop containers before undeploying --- ci-scripts/cls_containerize.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 8f992689e2..4e84699f3a 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -914,12 +914,26 @@ class Containerize(): logging.debug(cmd) subprocess.run(cmd, shell=True) - # if the containers are running, recover the logs! + # check which containers are running for log recovery later cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml ps --all' logging.debug(cmd) - deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) + deployStatusLogs = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) + + # Stop the containers to shut down objects + logging.debug('\u001B[1m Stopping containers \u001B[0m') + cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml stop' + logging.debug(cmd) + try: + deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=100) + except Exception as e: + self.exitStatus = 1 + logging.error('Could not stop containers') + HTML.CreateHtmlTestRow('Could not stop', 'KO', CONST.ALL_PROCESSES_OK) + logging.error('\u001B[1m Undeploying OAI Object(s) FAILED\u001B[0m') + return + anyLogs = False - for state in deployStatus.split('\n'): + for state in deployStatusLogs.split('\n'): res = re.search('Name|----------', state) if res is not None: continue From 5cadafc1546fb5f2262d55e209f38eabde7c35a0 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 4 Jul 2022 14:02:27 +0200 Subject: [PATCH 79/98] CI: check for final 'Bye.' message --- ci-scripts/constants.py | 1 + ci-scripts/ran.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/ci-scripts/constants.py b/ci-scripts/constants.py index 4f82811ac1..a7ce01615e 100644 --- a/ci-scripts/constants.py +++ b/ci-scripts/constants.py @@ -46,6 +46,7 @@ ENB_PROCESS_NOLOGFILE_TO_ANALYZE = -14 ENB_PROCESS_SLAVE_RRU_NOT_SYNCED = -15 ENB_REAL_TIME_PROCESSING_ISSUE = -16 ENB_RETX_ISSUE = -17 +ENB_SHUTDOWN_NO_BYE = -18 HSS_PROCESS_FAILED = -2 HSS_PROCESS_OK = +2 MME_PROCESS_FAILED = -3 diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index a576054370..b9e7eb476e 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -812,6 +812,7 @@ class RANManagement(): ULRetxIssue = False nrRrcRcfgComplete = 0 harqFeedbackPast = 0 + showedByeMsg = False # last line is Bye. -> stopped properly line_cnt=0 #log file line counter for line in enb_log_file.readlines(): @@ -1024,6 +1025,12 @@ class RANManagement(): if result is not None: gnb_markers[k].append(line_cnt) + # check whether e/gNB log finishes with "Bye." message + # Note that it is "=" not "|=" so not only is the regex + # asking for EOF (\Z) but we also only retain the last + # line's result + showedByeMsg = re.search(r'^Bye.\n\Z', str(line), re.MULTILINE) is not None + enb_log_file.close() @@ -1208,6 +1215,13 @@ class RANManagement(): logging.debug('No real time stats found in the log file') htmleNBFailureMsg += statMsg + if not showedByeMsg: + logging.debug('\u001B[1;37;41m ' + nodeB_prefix + 'NB did not show "Bye." message at end, it likely did not stop properly! \u001B[0m') + htmleNBFailureMsg += 'No Bye. message found, did not stop properly\n' + global_status = CONST.ENB_SHUTDOWN_NO_BYE + else: + logging.debug('"Bye." message found at end.') + else: #Removing UE log statMsg = '[MAC] Removing UE msg count = '+str(removing_ue) From 061881255450e798abf887b4e8843a497ce33793 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 16 Aug 2022 12:01:52 +0200 Subject: [PATCH 80/98] T tracer: simplify - don't call exit() if get_message() fails, simply terminate the thread and disable the T tracer - T_dont_fork disappears, monitor_and_kill() as well, so now it's only 2 processes: the main (enb/gnb/ue) and the local tracer --- common/utils/T/T.c | 119 ++++++++++++++++++++------------------------- common/utils/T/T.h | 14 ++---- 2 files changed, 59 insertions(+), 74 deletions(-) diff --git a/common/utils/T/T.c b/common/utils/T/T.c index 2d724ffd00..6ba1962d1f 100644 --- a/common/utils/T/T.c +++ b/common/utils/T/T.c @@ -8,22 +8,19 @@ #include #include #include +#include +#include #include "common/config/config_userapi.h" -#define QUIT(x) do { \ - printf("T tracer: QUIT: %s\n", x); \ - exit(1); \ - } while (0) - /* array used to activate/disactivate a log */ static int T_IDs[T_NUMBER_OF_IDS]; int *T_active = T_IDs; int T_stdout = 1; - static int T_socket; +static int local_tracer_pid; /* T_cache * - the T macro picks up the head of freelist and marks it busy @@ -33,63 +30,78 @@ volatile int _T_freelist_head; volatile int *T_freelist_head = &_T_freelist_head; T_cache_t *T_cache; -static void get_message(int s) { +#define GET_MESSAGE_FAIL do { \ + printf("T tracer: get_message failed\n"); \ + return -1; \ + } while (0) + +/* return -1 if error, 0 if no error */ +static int get_message(int s) +{ char t; int l; int id; int is_on; - if (read(s, &t, 1) != 1) QUIT("get_message fails"); + if (read(s, &t, 1) != 1) GET_MESSAGE_FAIL; printf("T tracer: got mess %d\n", t); switch (t) { case 0: - /* toggle all those IDs */ /* optimze? (too much syscalls) */ - if (read(s, &l, sizeof(int)) != sizeof(int)) QUIT("get_message fails"); + if (read(s, &l, sizeof(int)) != sizeof(int)) GET_MESSAGE_FAIL; while (l) { - if (read(s, &id, sizeof(int)) != sizeof(int)) QUIT("get_message fails"); + if (read(s, &id, sizeof(int)) != sizeof(int)) GET_MESSAGE_FAIL; T_IDs[id] = 1 - T_IDs[id]; l--; } - break; - case 1: - /* set IDs as given */ /* optimize? */ - if (read(s, &l, sizeof(int)) != sizeof(int)) QUIT("get_message fails"); + if (read(s, &l, sizeof(int)) != sizeof(int)) GET_MESSAGE_FAIL; id = 0; while (l) { if (read(s, &is_on, sizeof(int)) != sizeof(int)) - QUIT("get_message fails"); + GET_MESSAGE_FAIL; T_IDs[id] = is_on; id++; l--; } - break; - case 2: break; /* do nothing, this message is to wait for local tracer */ } + + return 0; } -static void *T_receive_thread(void *_) { - while (1) get_message(T_socket); +static void *T_receive_thread(void *_) +{ + int err = 0; + while (!err) err = get_message(T_socket); + + printf("T tracer: fatal: T tracer disabled\n"); + + shutdown(T_socket, SHUT_RDWR); + close(T_socket); + kill(local_tracer_pid, SIGKILL); + + /* disable all traces */ + memset(T_IDs, 0, sizeof(T_IDs)); return NULL; } -static void new_thread(void *(*f)(void *), void *data) { +static void new_thread(void *(*f)(void *), void *data) +{ pthread_t t; pthread_attr_t att; @@ -118,27 +130,11 @@ static void new_thread(void *(*f)(void *), void *data) { void T_local_tracer_main(int remote_port, int wait_for_tracer, int local_socket, void *shm_array); -/* We monitor the tracee and the local tracer processes. - * When one dies we forcefully kill the other. - */ -#include -#include -static void monitor_and_kill(int child1, int child2) { - int child; - int status; - child = wait(&status); - - if (child == -1) perror("wait"); - - kill(child1, SIGKILL); - kill(child2, SIGKILL); - exit(0); -} - -void T_init(int remote_port, int wait_for_tracer, int dont_fork) { +void T_init(int remote_port, int wait_for_tracer) +{ int socket_pair[2]; int s; - int child1, child2; + int child; int i; if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair)) { @@ -162,47 +158,40 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) { for (i = 0; i < T_CACHE_SIZE; i++) T_cache[i].busy = 0; - /* child1 runs the local tracer and child2 (or main) runs the tracee */ - child1 = fork(); + /* child runs the local tracer and main runs the tracee */ + child = fork(); - if (child1 == -1) abort(); + if (child == -1) abort(); - if (child1 == 0) { + if (child == 0) { close(socket_pair[1]); T_local_tracer_main(remote_port, wait_for_tracer, socket_pair[0], T_cache); exit(0); } + local_tracer_pid = child; + close(socket_pair[0]); - if (dont_fork == 0) { - child2 = fork(); + s = socket_pair[1]; + T_socket = s; - if (child2 == -1) abort(); - - if (child2 != 0) { - close(socket_pair[1]); - munmap(T_cache, T_CACHE_SIZE * sizeof(T_cache_t)); - monitor_and_kill(child1, child2); - } + /* wait for first message - initial list of active T events */ + if (get_message(s) == -1) { + kill(local_tracer_pid, SIGKILL); + return; } - s = socket_pair[1]; - /* wait for first message - initial list of active T events */ - get_message(s); - T_socket = s; new_thread(T_receive_thread, NULL); } -void T_Config_Init(void) { - int T_port=TTRACER_DEFAULT_PORTNUM; /* by default we wait for the tracer */ - int T_nowait=0; /* default port to listen to to wait for the tracer */ - int T_dont_fork=0; /* default is to fork, see 'T_init' to understand */ +void T_Config_Init(void) +{ + int T_port = TTRACER_DEFAULT_PORTNUM; + int T_nowait = 0; paramdef_t ttraceparams[] = CMDLINE_TTRACEPARAMS_DESC; - /* for a cleaner config file, TTracer params should be defined in a - * specific section... - */ + config_get(ttraceparams, sizeof(ttraceparams) / sizeof(paramdef_t), TTRACER_CONFIG_PREFIX); @@ -217,5 +206,5 @@ void T_Config_Init(void) { } if (T_stdout == 0 || T_stdout == 2) - T_init(T_port, 1-T_nowait, T_dont_fork); + T_init(T_port, 1-T_nowait); } diff --git a/common/utils/T/T.h b/common/utils/T/T.h index df1e95d2df..dd698906c8 100644 --- a/common/utils/T/T.h +++ b/common/utils/T/T.h @@ -15,8 +15,8 @@ #include "T_IDs.h" #define T_ACTIVE_STDOUT 2 -/* known type - this is where you add new types */ +/* known type - this is where you add new types */ #define T_INT(x) int, (x) #define T_FLOAT(x) float, (x) #define T_BUFFER(x, len) buffer, ((T_buffer){addr:(x), length:(len)}) @@ -111,6 +111,7 @@ typedef struct { extern volatile int *T_freelist_head; extern T_cache_t *T_cache; extern int *T_active; + #define T_GET_SLOT \ T_LOCAL_busy = __sync_fetch_and_or(&T_cache[T_LOCAL_slot].busy, 0x01); @@ -559,14 +560,12 @@ extern int *T_active; } \ } while (0) - #define CONFIG_HLP_TPORT "tracer port\n" #define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n" -#define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n" #define CONFIG_HLP_STDOUT "print log messges on console\n" - #define TTRACER_CONFIG_PREFIX "TTracer" + /*-------------------------------------------------------------------------------------------------------------------------------------------------*/ /* configuration parameters for TTRACE utility */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ @@ -575,15 +574,12 @@ extern int *T_active; #define CMDLINE_TTRACEPARAMS_DESC { \ {"T_port", CONFIG_HLP_TPORT, 0, iptr:&T_port, defintval:TTRACER_DEFAULT_PORTNUM, TYPE_INT, 0},\ {"T_nowait", CONFIG_HLP_NOTWAIT, PARAMFLAG_BOOL, iptr:&T_nowait, defintval:0, TYPE_INT, 0},\ - {"T_dont_fork", CONFIG_HLP_TNOFORK, PARAMFLAG_BOOL, iptr:&T_dont_fork, defintval:0, TYPE_INT, 0},\ {"T_stdout", CONFIG_HLP_STDOUT, 0, iptr:&T_stdout, defintval:1, TYPE_INT, 0},\ } - - -/* log on stdout */ -void T_init(int remote_port, int wait_for_tracer, int dont_fork); +void T_init(int remote_port, int wait_for_tracer); void T_Config_Init(void); + #else /* T_TRACER */ /* if T_TRACER is not defined or is 0, the T is deactivated */ From 983c956b77fb5bfa6a68307fc993be325c7d825f Mon Sep 17 00:00:00 2001 From: frtabu Date: Fri, 4 Mar 2022 18:03:13 +0100 Subject: [PATCH 81/98] Fix config module memory leaks --- common/config/DOC/config/devusage/api.md | 10 ++- common/config/config_load_configmodule.c | 79 ++++++++++++++---------- common/config/config_load_configmodule.h | 8 +++ openair1/SIMULATION/NR_PHY/dlschsim.c | 13 ++-- 4 files changed, 70 insertions(+), 40 deletions(-) diff --git a/common/config/DOC/config/devusage/api.md b/common/config/DOC/config/devusage/api.md index 376e59abaf..170e9b61f8 100644 --- a/common/config/DOC/config/devusage/api.md +++ b/common/config/DOC/config/devusage/api.md @@ -11,10 +11,16 @@ configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t init * if the bit CONFIG_ENABLECMDLINEONLY is set in `initflags` then the module allows parameters to be set only via the command line. This is used for the oai UE. ```c -void End_configmodule(void) +void end_configmodule(void) ``` -* Free memory which has been allocated by the configuration module since its initialization. +* Free memory which has been allocated by the configuration module for storing parameters values, when `PARAMFLAG_NOFREE` flag is not specified in the parameter definition. * Possibly calls the `config__end` function +This call should be used when all configurations have been read. The program will still be able to use parameter values allocated by the config module WHEN THE `PARAMFLAG_NOFREE` flag has been specified in the parameter definition. The config module can be reloaded later in the program (not fully tested as not used today) + +```c +void free_configmodule(void) +``` +This call should be used to definitely free all resources allocated by the config module. All parameters values allocated by the config module become unavailable and no further reload of the config module are allowed. ## Retrieving parameter's values diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index fbc44c3363..922126b688 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -250,46 +250,46 @@ configmodule_interface_t *load_configmodule(int argc, modeparams=cfgmode; cfgmode=strdup(CONFIG_LIBCONFIGFILE); } - - cfgptr = calloc(sizeof(configmodule_interface_t),1); + if (cfgptr == NULL) { + cfgptr = calloc(sizeof(configmodule_interface_t),1); /* argv_info is used to memorize command line options which have been recognized */ /* and to detect unrecognized command line options which might have been specified */ - cfgptr->argv_info = calloc(sizeof(int32_t), argc+10); + cfgptr->argv_info = calloc(sizeof(int32_t), argc+10); /* argv[0] is the exec name, always Ok */ - cfgptr->argv_info[0] |= CONFIG_CMDLINEOPT_PROCESSED; + cfgptr->argv_info[0] |= CONFIG_CMDLINEOPT_PROCESSED; /* when OoptIdx is >0, -O option has been detected at position OoptIdx * we must memorize arv[OoptIdx is Ok */ - if (OoptIdx >= 0) { - cfgptr->argv_info[OoptIdx] |= CONFIG_CMDLINEOPT_PROCESSED; - cfgptr->argv_info[OoptIdx+1] |= CONFIG_CMDLINEOPT_PROCESSED; - } - - cfgptr->rtflags = cfgptr->rtflags | tmpflags; - cfgptr->argc = argc; - cfgptr->argv = argv; - cfgptr->cfgmode=strdup(cfgmode); - cfgptr->num_cfgP=0; - atoken=strtok_r(modeparams,":",&strtokctx); - - while ( cfgptr->num_cfgP< CONFIG_MAX_OOPT_PARAMS && atoken != NULL) { - /* look for debug level in the config parameters, it is common to all config mode - and will be removed from the parameter array passed to the shared module */ - char *aptr; - aptr=strcasestr(atoken,"dbgl"); - - if (aptr != NULL) { - cfgptr->rtflags = cfgptr->rtflags | strtol(aptr+4,NULL,0); - } else { - cfgptr->cfgP[cfgptr->num_cfgP] = strdup(atoken); - cfgptr->num_cfgP++; + if (OoptIdx >= 0) { + cfgptr->argv_info[OoptIdx] |= CONFIG_CMDLINEOPT_PROCESSED; + cfgptr->argv_info[OoptIdx+1] |= CONFIG_CMDLINEOPT_PROCESSED; } - atoken = strtok_r(NULL,":",&strtokctx); + cfgptr->rtflags = cfgptr->rtflags | tmpflags; + cfgptr->argc = argc; + cfgptr->argv = argv; + cfgptr->cfgmode=strdup(cfgmode); + cfgptr->num_cfgP=0; + atoken=strtok_r(modeparams,":",&strtokctx); + + while ( cfgptr->num_cfgP< CONFIG_MAX_OOPT_PARAMS && atoken != NULL) { + /* look for debug level in the config parameters, it is common to all config mode + and will be removed from the parameter array passed to the shared module */ + char *aptr; + aptr=strcasestr(atoken,"dbgl"); + + if (aptr != NULL) { + cfgptr->rtflags = cfgptr->rtflags | strtol(aptr+4,NULL,0); + } else { + cfgptr->cfgP[cfgptr->num_cfgP] = strdup(atoken); + cfgptr->num_cfgP++; + } + + atoken = strtok_r(NULL,":",&strtokctx); + } + + printf("[CONFIG] get parameters from %s ",cfgmode); } - - printf("[CONFIG] get parameters from %s ",cfgmode); - for (i=0; inum_cfgP; i++) { printf("%s ",cfgptr->cfgP[i]); } @@ -339,6 +339,7 @@ void end_configmodule(void) { pthread_mutex_lock(&cfgptr->memBlocks_mutex); printf ("[CONFIG] free %u config value pointers\n",cfgptr->numptrs); + int n=0; for(int i=0; inumptrs ; i++) { if (cfgptr->oneBlock[i].ptrs != NULL && cfgptr->oneBlock[i].ptrsAllocated== true && cfgptr->oneBlock[i].toFree) { free(cfgptr->oneBlock[i].ptrs); @@ -358,13 +359,23 @@ void free_configmodule(void) { end_configmodule(); if( cfgptr->cfgmode != NULL) free(cfgptr->cfgmode); - - printf ("[CONFIG] free %i config parameter pointers\n",cfgptr->num_cfgP); + int n=0; + for(int i=0; inumptrs ; i++) { + if (cfgptr->ptrs[i] != NULL) { + free(cfgptr->ptrs[i]); + cfgptr->ptrs[i]=NULL; + cfgptr->ptrsAllocated[i] = false; + n++; + } + } + printf ("[CONFIG] %u/%u persistent config value pointers have been released\n",n,cfgptr->numptrs); + cfgptr->numptrs=0; + printf ("[CONFIG] free %i config module parameter pointers\n",cfgptr->num_cfgP); for (int i=0; inum_cfgP; i++) { if ( cfgptr->cfgP[i] != NULL) free(cfgptr->cfgP[i]); } - + free(cfgptr->argv_info); free(cfgptr); cfgptr=NULL; } diff --git a/common/config/config_load_configmodule.h b/common/config/config_load_configmodule.h index e3814994ad..249ef6be5b 100644 --- a/common/config/config_load_configmodule.h +++ b/common/config/config_load_configmodule.h @@ -120,7 +120,15 @@ extern configmodule_interface_t *cfgptr; #define CONFIG_ENABLECMDLINEONLY (1<<1) extern configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags); +/* free ressources used to read parameters, keep memory + * allocated for parameters values which has been defined with the PARAMFLAG_NOFREE flag + * should be used as soon as there is no need to read parameters but doesn't prevent + * a new config module init +*/ extern void end_configmodule(void); +/* free all config module memory, to be used at end of program as + * it will free parameters values even those specified with the PARAMFLAG_NOFREE flag */ +extern void free_configmodule(void); #define CONFIG_PRINTF_ERROR(f, x... ) if (isLogInitDone ()) { LOG_E(ENB_APP,f,x);} else {printf(f,x);}; if ( !CONFIG_ISFLAGSET(CONFIG_NOABORTONCHKF) ) exit_fun("exit because configuration failed\n"); diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 39cd540795..9632c48208 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -658,10 +658,15 @@ int main(int argc, char **argv) if (ouput_vcd) vcd_signal_dumper_close(); + end_configmodule(); + if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) { + exit_fun("[NR_DLSCHSIM] Error, configuration module init 2 failed\n"); + } + logInit(); + loader_reset(); + logTerm(); + free_configmodule(); - loader_reset(); - logTerm(); - - return (n_errors); + return (n_errors); } From ab5a67463a69602ac80e1fc9f7e387cd2eee4005 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 17 Aug 2022 17:35:44 +0200 Subject: [PATCH 82/98] Reuse existing files from 4g_rfsimulator_fdd_05MHz --- .../4g_l2sim_fdd/docker-compose.yml | 10 +- .../yaml_files/4g_l2sim_fdd/entrypoint.sh | 36 ---- ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf | 134 -------------- .../4g_l2sim_fdd/mme_fd.sprint.conf | 169 ------------------ ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql | 93 ---------- .../yaml_files/4g_l2sim_fdd/redis_extern.conf | 33 ---- 6 files changed, 5 insertions(+), 470 deletions(-) delete mode 100755 ci-scripts/yaml_files/4g_l2sim_fdd/entrypoint.sh delete mode 100644 ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf delete mode 100644 ci-scripts/yaml_files/4g_l2sim_fdd/mme_fd.sprint.conf delete mode 100644 ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql delete mode 100644 ci-scripts/yaml_files/4g_l2sim_fdd/redis_extern.conf diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/docker-compose.yml b/ci-scripts/yaml_files/4g_l2sim_fdd/docker-compose.yml index 03cb45310d..0562adab4b 100644 --- a/ci-scripts/yaml_files/4g_l2sim_fdd/docker-compose.yml +++ b/ci-scripts/yaml_files/4g_l2sim_fdd/docker-compose.yml @@ -28,7 +28,7 @@ services: private_net: ipv4_address: 192.168.68.4 volumes: - - ./oai_db.cql:/home/oai_db.cql + - ../4g_rfsimulator_fdd_05MHz/oai_db.cql:/home/oai_db.cql entrypoint: /bin/bash -c "cqlsh --file /home/oai_db.cql 192.168.68.2 && echo 'OK'" oai_hss: @@ -66,7 +66,7 @@ services: public_net: ipv4_address: 192.168.61.6 volumes: - - ./redis_extern.conf:/usr/local/etc/redis/redis.conf + - ../4g_rfsimulator_fdd_05MHz/redis_extern.conf:/usr/local/etc/redis/redis.conf entrypoint: /bin/bash -c "redis-server /usr/local/etc/redis/redis.conf" healthcheck: test: /bin/bash -c "redis-cli -h 192.168.61.6 -p 6380 ping" @@ -93,9 +93,9 @@ services: MME_FQDN: mme.openairinterface.org FEATURES: mme_oai volumes: - - ./mme_fd.sprint.conf:/magma-mme/etc/mme_fd.conf.tmplt - - ./mme.conf:/magma-mme/etc/mme.conf - - ./entrypoint.sh:/magma-mme/bin/entrypoint.sh + - ../4g_rfsimulator_fdd_05MHz/mme_fd.sprint.conf:/magma-mme/etc/mme_fd.conf.tmplt + - ../4g_rfsimulator_fdd_05MHz/mme.conf:/magma-mme/etc/mme.conf + - ../4g_rfsimulator_fdd_05MHz/entrypoint.sh:/magma-mme/bin/entrypoint.sh entrypoint: /bin/bash -c "/magma-mme/bin/entrypoint.sh" healthcheck: test: /bin/bash -c "pgrep oai_mme" diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/entrypoint.sh b/ci-scripts/yaml_files/4g_l2sim_fdd/entrypoint.sh deleted file mode 100755 index 24960e215d..0000000000 --- a/ci-scripts/yaml_files/4g_l2sim_fdd/entrypoint.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -INSTANCE=1 -PREFIX='/magma-mme/etc' -MY_REALM='openairinterface.org' - -declare -A MME_CONF - -pushd $PREFIX -MME_CONF[@MME_S6A_IP_ADDR@]="192.168.61.3" -MME_CONF[@INSTANCE@]=$INSTANCE -MME_CONF[@PREFIX@]=$PREFIX -MME_CONF[@REALM@]=$MY_REALM -MME_CONF[@MME_FQDN@]="mme.${MME_CONF[@REALM@]}" -MME_CONF[@HSS_HOSTNAME@]='hss' -MME_CONF[@HSS_FQDN@]="${MME_CONF[@HSS_HOSTNAME@]}.${MME_CONF[@REALM@]}" -MME_CONF[@HSS_IP_ADDR@]="192.168.61.2" - -cp mme_fd.conf.tmplt $PREFIX/mme_fd.conf - -for K in "${!MME_CONF[@]}"; do - egrep -lRZ "$K" $PREFIX/mme_fd.conf | xargs -0 -l sed -i -e "s|$K|${MME_CONF[$K]}|g" - ret=$?;[[ ret -ne 0 ]] && echo "Could not replace $K with ${MME_CONF[$K]}" -done - -sed -i -e "s@etc/freeDiameter@etc@" /magma-mme/etc/mme_fd.conf -sed -i -e "s@bind: 127.0.0.1@bind: 192.168.61.6@" /etc/magma/redis.yml -# Generate freeDiameter certificate -popd -cd /magma-mme/scripts -./check_mme_s6a_certificate $PREFIX mme.${MME_CONF[@REALM@]} - -cd /magma-mme -nohup /magma-mme/bin/sctpd > /var/log/sctpd.log 2>&1 & -sleep 5 -/magma-mme/bin/oai_mme -c /magma-mme/etc/mme.conf diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf b/ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf deleted file mode 100644 index 4f491cc63d..0000000000 --- a/ci-scripts/yaml_files/4g_l2sim_fdd/mme.conf +++ /dev/null @@ -1,134 +0,0 @@ -# generated by generate_mme_config_script.py -MME : -{ - REALM = "openairinterface.org" - PID_DIRECTORY = "/var/run"; - MAXENB = 8; # power of 2 - MAXUE = 16; # power of 2 - RELATIVE_CAPACITY = 10; - - EMERGENCY_ATTACH_SUPPORTED = "no"; - UNAUTHENTICATED_IMSI_SUPPORTED = "no"; - - # EPS network feature support - EPS_NETWORK_FEATURE_SUPPORT_IMS_VOICE_OVER_PS_SESSION_IN_S1 = "no"; # DO NOT CHANGE - EPS_NETWORK_FEATURE_SUPPORT_EMERGENCY_BEARER_SERVICES_IN_S1_MODE = "no"; # DO NOT CHANGE - EPS_NETWORK_FEATURE_SUPPORT_LOCATION_SERVICES_VIA_EPC = "no"; # DO NOT CHANGE - EPS_NETWORK_FEATURE_SUPPORT_EXTENDED_SERVICE_REQUEST = "no"; # DO NOT CHANGE - - # Display statistics about whole system (expressed in seconds) - MME_STATISTIC_TIMER = 10; - IP_CAPABILITY = "IPV4"; # UE PDN_TYPE - USE_STATELESS = ""; - - INTERTASK_INTERFACE : - { - # max queue size per task - ITTI_QUEUE_SIZE = 2000000; - }; - - S6A : - { - S6A_CONF = "/magma-mme/etc/mme_fd.conf"; # YOUR MME freeDiameter config file path - HSS_HOSTNAME = "hss.openairinterface.org"; - HSS_REALM = "openairinterface.org"; - }; - - # ------- SCTP definitions - SCTP : - { - # Number of streams to use in input/output - SCTP_INSTREAMS = 8; - SCTP_OUTSTREAMS = 8; - }; - - # ------- S1AP definitions - S1AP : - { - # outcome drop timer value (seconds) - S1AP_OUTCOME_TIMER = 10; - }; - - # ------- MME served GUMMEIs - GUMMEI_LIST = ( - { MCC="208" ; MNC="96"; MME_GID="32768" ; MME_CODE="3"; } - ); - - # ------- MME served TAIs - TAI_LIST = ( - {MCC="208" ; MNC="96"; TAC = "1"; } - ); - - TAC_LIST = ( - {MCC="208" ; MNC="96"; TAC = "1"; } - ); - - CSFB : - { - NON_EPS_SERVICE_CONTROL = "OFF"; - CSFB_MCC = "208"; - CSFB_MNC = "96"; - LAC = "1"; - }; - NAS : - { - ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST = [ "EIA2" , "EIA1" , "EIA0" ]; - ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST = [ "EEA0" , "EEA1" , "EEA2" ]; - T3402 = 1 # in minutes (default is 12 minutes) - T3412 = 54 # in minutes (default is 54 minutes, network dependent) - T3422 = 6 # in seconds (default is 6s) - T3450 = 6 # in seconds (default is 6s) - T3460 = 6 # in seconds (default is 6s) - T3470 = 6 # in seconds (default is 6s) - T3485 = 8 # UNUSED in seconds (default is 8s) - T3486 = 8 # UNUSED in seconds (default is 8s) - T3489 = 4 # UNUSED in seconds (default is 4s) - T3495 = 8 # UNUSED in seconds (default is 8s) - }; - - SGS : - { - TS6_1 = 10 # in seconds (default is 10s) - TS8 = 4 # in seconds (default is 4s) - TS9 = 2 # in seconds (default is 4s) - TS10 = 4 # in seconds (default is 4s) - TS13 = 4 # in seconds (default is 4s) - }; - - NETWORK_INTERFACES : - { - MME_INTERFACE_NAME_FOR_S1_MME = "eth0"; - MME_IPV4_ADDRESS_FOR_S1_MME = "192.168.61.3/24"; - MME_INTERFACE_NAME_FOR_S11_MME = "eth0"; - MME_IPV4_ADDRESS_FOR_S11_MME = "192.168.61.3/24"; - MME_PORT_FOR_S11_MME = 2123; - }; - - LOGGING : - { - OUTPUT = "CONSOLE"; - THREAD_SAFE = "no"; - COLOR = "no"; - - SCTP_LOG_LEVEL = "ERROR"; - GTPV1U_LOG_LEVEL = "INFO"; - SPGW_APP_LOG_LEVEL = "INFO"; - UDP_LOG_LEVEL = "INFO"; - S1AP_LOG_LEVEL = "DEBUG"; - NAS_LOG_LEVEL = "INFO"; - MME_APP_LOG_LEVEL = "DEBUG"; - GTPV2C_LOG_LEVEL = "INFO"; - S11_LOG_LEVEL = "DEBUG"; - S6A_LOG_LEVEL = "DEBUG"; - UTIL_LOG_LEVEL = "INFO"; - MSC_LOG_LEVEL = "ERROR"; - ITTI_LOG_LEVEL = "ERROR"; - MME_SCENARIO_PLAYER_LOG_LEVEL = "ERROR"; - ASN1_VERBOSITY = "INFO"; - }; - - S-GW : - { - SGW_IPV4_ADDRESS_FOR_S11 = "192.168.61.4"; - }; -}; diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/mme_fd.sprint.conf b/ci-scripts/yaml_files/4g_l2sim_fdd/mme_fd.sprint.conf deleted file mode 100644 index 6f87ed8c2b..0000000000 --- a/ci-scripts/yaml_files/4g_l2sim_fdd/mme_fd.sprint.conf +++ /dev/null @@ -1,169 +0,0 @@ -# -------- Local --------- - -# Uncomment if the framework cannot resolv it. -Identity = "@MME_FQDN@"; -Realm = "@REALM@"; - -# TLS configuration (see previous section) -TLS_Cred = "@PREFIX@/freeDiameter/mme.cert.pem", - "@PREFIX@/freeDiameter/mme.key.pem"; -TLS_CA = "@PREFIX@/freeDiameter/mme.cacert.pem"; - -# Disable use of TCP protocol (only listen and connect in SCTP) -# Default : TCP enabled -No_SCTP; - -# This option is ignored if freeDiameter is compiled with DISABLE_SCTP option. -# Prefer TCP instead of SCTP for establishing new connections. -# This setting may be overwritten per peer in peer configuration blocs. -# Default : SCTP is attempted first. -Prefer_TCP; - - -No_IPv6; - -# Overwrite the number of SCTP streams. This value should be kept low, -# especially if you are using TLS over SCTP, because it consumes a lot of -# resources in that case. See tickets 19 and 27 for some additional details on -# this. -# Limit the number of SCTP streams -SCTP_streams = 3; - - -# By default, freeDiameter acts as a Diameter Relay Agent by forwarding all -# messages it cannot handle locally. This parameter disables this behavior. -NoRelay; - -# Use RFC3588 method for TLS protection, where TLS is negociated after CER/CEA exchange is completed -# on the unsecure connection. The alternative is RFC6733 mechanism, where TLS protects also the -# CER/CEA exchange on a dedicated secure port. -# This parameter only affects outgoing connections. -# The setting can be also defined per-peer (see Peers configuration section). -# Default: use RFC6733 method with separate port for TLS. - -#TLS_old_method; - -AppServThreads = 4; - -# Specify the addresses on which to bind the listening server. This must be -# specified if the framework is unable to auto-detect these addresses, or if the -# auto-detected values are incorrect. Note that the list of addresses is sent -# in CER or CEA message, so one should pay attention to this parameter if some -# adresses should be kept hidden. -ListenOn = "@MME_S6A_IP_ADDR@"; - -Port = 3870; -SecPort = 5870; - -# -------- Extensions --------- - -# Uncomment (and create rtd.conf) to specify routing table for this peer. -#LoadExtension = "/usr/local/lib/freeDiameter/rt_default.fdx" : "rtd.conf"; - -#LoadExtension = "/usr/local/lib/freeDiameter/_sample.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/app_acct.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/app_diameap.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/app_radgw.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/app_redirect.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/app_sip.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dbg_interactive.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dbg_monitor.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dbg_msg_dumps.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dbg_msg_timings.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dbg_rt.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_3gpp2_avps.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_CreditControl.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_CxDx.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_Gx.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_NAS.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_Ro.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_Rx.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_S6mS6n.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_SGd.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_SLh.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_Sd.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_Sh.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_T4.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_T6aT6bT7.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_Tsp.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_dcca.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_dcca_3gpp.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_dcca_starent.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_draftload_avps.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_eap.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_etsi283034_avps.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_legacy_xml.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_mip6a.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_mip6i.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_nas_mipv6.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_nasreq.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4004_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4006bis_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4072_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4590_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5447_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5580_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5777_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5778_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc6734_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc6942_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7155_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7683_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7944_avps.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_sip.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29061_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29128_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29154_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29173_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29212_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29214_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29215_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29217_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29229_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29272_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29273_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29329_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29336_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29337_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29338_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29343_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29344_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29345_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29368_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29468_avps.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_ts32299_avps.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/rt_busypeers.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/rt_default.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/rt_ereg.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/rt_ignore_dh.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/rt_load_balance.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/rt_randomize.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/rt_redirect.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/test_acct.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/test_app.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/test_hss.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/test_netemul.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/test_rt_any.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/test_sip.fdx"; -#LoadExtension = "/usr/local/lib/freeDiameter/dict_Rf.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_S6as6d.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_S6t.fdx"; -LoadExtension = "/usr/local/lib/freeDiameter/dict_S6c.fdx"; - - -# -------- Peers --------- - -# The framework will actively attempt to establish and maintain a connection -# with the peers listed here. -# For only accepting incoming connections, see the acl_wl.fx extension. - -# ConnectPeer -# Declare a remote peer to which this peer must maintain a connection. -# In addition, this allows specifying non-default parameters for this peer only -# (for example disable SCTP with this peer, or use RFC3588-flavour TLS). -# Note that by default, if a peer is not listed as a ConnectPeer entry, an -# incoming connection from this peer will be rejected. If you want to accept -# incoming connections from other peers, see the acl_wl.fdx? extension which -# allows exactly this. - -ConnectPeer= "@HSS_FQDN@" { ConnectTo = "@HSS_IP_ADDR@"; No_SCTP ; No_IPv6; Prefer_TCP; No_TLS; port = 3868;}; diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql b/ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql deleted file mode 100644 index 2be0a8e2e9..0000000000 --- a/ci-scripts/yaml_files/4g_l2sim_fdd/oai_db.cql +++ /dev/null @@ -1,93 +0,0 @@ -CREATE KEYSPACE IF NOT EXISTS vhss WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': '1'}; - -CREATE TABLE IF NOT EXISTS vhss.users_imsi ( - imsi text PRIMARY KEY, - access_restriction int, - idmmeidentity int, - imei text, - imei_sv text, - key text, - lipa_permissions text, - mme_cap int, - mmehost text, - mmeidentity_idmmeidentity int, - mmerealm text, - ms_ps_status text, - msisdn bigint, - niddvalidity text, - nir_dest_host text, - nir_dest_realm text, - opc text, - pgw_id int, - rand text, - rfsp_index varint, - sqn bigint, - subscription_data text, - ue_reachability varint, - urrp_mme varint, - user_identifier text, - visited_plmnid text); - -CREATE TABLE IF NOT EXISTS vhss.msisdn_imsi ( - msisdn bigint PRIMARY KEY, - imsi text -); - -CREATE TABLE IF NOT EXISTS vhss.global_ids ( - table_name text PRIMARY KEY, - id counter); - -CREATE TABLE IF NOT EXISTS vhss.mmeidentity_host ( - mmehost text PRIMARY KEY, - idmmeidentity int, - mmerealm text, - ue_reachability varint, - mmeisdn text); - -CREATE TABLE IF NOT EXISTS vhss.mmeidentity ( - idmmeidentity int PRIMARY KEY, - mmehost text, - mmerealm text, - ue_reachability varint, - mmeisdn text); - -CREATE TABLE IF NOT EXISTS vhss.events ( - scef_id text, - scef_ref_id bigint, - extid text, - monitoring_event_configuration text, - monitoring_type int, - msisdn bigint, - user_identifier text, - primary key (scef_id, scef_ref_id) -); - -CREATE TABLE IF NOT EXISTS vhss.events_msisdn ( - msisdn bigint, - scef_id text, - scef_ref_id bigint, - primary key (msisdn, scef_id, scef_ref_id) -); - -CREATE TABLE IF NOT EXISTS vhss.events_extid ( - extid text, - scef_id text, - scef_ref_id bigint, - primary key (extid, scef_id, scef_ref_id) -); - -CREATE TABLE IF NOT EXISTS vhss.extid ( - extid text primary key -); - -CREATE TABLE IF NOT EXISTS vhss.extid_imsi ( - extid text, - imsi text, - primary key (extid, imsi) -); - -CREATE TABLE IF NOT EXISTS vhss.extid_imsi_xref ( - imsi text, - extid text, - primary key (imsi, extid) -); diff --git a/ci-scripts/yaml_files/4g_l2sim_fdd/redis_extern.conf b/ci-scripts/yaml_files/4g_l2sim_fdd/redis_extern.conf deleted file mode 100644 index 1ee9dd9a78..0000000000 --- a/ci-scripts/yaml_files/4g_l2sim_fdd/redis_extern.conf +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 2016-present, Facebook, Inc. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. An additional grant -# of patent rights can be found in the PATENTS file in the same directory. - -# Jinja template for Redis configuration -# See the default config file for options and explanations: -# https://github.com/antirez/redis/blob/unstable/redis.conf - -# TODO: make sensible, production-aware config decisions - -bind 192.168.61.6 -port 6380 - -daemonize no -loglevel notice - -timeout 0 -databases 1 - -dbfilename redis_dump.rdb -dir /data - -# Save the DB on disk - -save 900 1 - -save 300 10 - -save 60 1000 From c139204ce0f0da469c3e30a0009e40b1e7a68d71 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 17 Aug 2022 17:42:45 +0200 Subject: [PATCH 83/98] Make one L2sim proxy build scenario file --- .../{container_5g_l2sim_proxy.xml => container_l2sim_proxy.xml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename ci-scripts/xml_files/{container_5g_l2sim_proxy.xml => container_l2sim_proxy.xml} (96%) diff --git a/ci-scripts/xml_files/container_5g_l2sim_proxy.xml b/ci-scripts/xml_files/container_l2sim_proxy.xml similarity index 96% rename from ci-scripts/xml_files/container_5g_l2sim_proxy.xml rename to ci-scripts/xml_files/container_l2sim_proxy.xml index af1715d793..f32658daca 100644 --- a/ci-scripts/xml_files/container_5g_l2sim_proxy.xml +++ b/ci-scripts/xml_files/container_l2sim_proxy.xml @@ -21,7 +21,7 @@ --> - l2sim-5gnr-proxy-build + l2sim-4glte-5gnr-proxy-build Build L2sim proxy image wrench 1 From a08d78d79daaf3846b6cb233e0fb4705f121cdd0 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 17 Aug 2022 18:08:44 +0200 Subject: [PATCH 84/98] Correctly show proxy build info --- ci-scripts/cls_containerize.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 8f992689e2..1d2de33d97 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -532,6 +532,25 @@ class Containerize(): # don't delete such that we might recover the zips #mySSH.command('rm -f build_log_' + self.testCase_id + '.zip','\$', 5) + # we do not analyze the logs (we assume the proxy builds fine at this stage), + # but need to have the following information to correctly display the HTML + files = {} + errorandwarnings = {} + errorandwarnings['errors'] = 0 + errorandwarnings['warnings'] = 0 + errorandwarnings['status'] = True + files['Target Image Creation'] = errorandwarnings + self.collectInfo['proxy'] = files + mySSH.command('docker image inspect --format=\'Size = {{.Size}} bytes\' proxy:' + tag, '\$', 5) + result = re.search('Size *= *(?P[0-9\-]+) *bytes', mySSH.getBefore()) + if result is not None: + imageSize = float(result.group('size')) / 1000000 + logging.debug('\u001B[1m proxy size is ' + ('%.0f' % imageSize) + ' Mbytes\u001B[0m') + self.allImagesSize['proxy'] = str(round(imageSize,1)) + ' Mbytes' + else: + logging.debug('proxy size is unknown') + self.allImagesSize['proxy'] = 'unknown' + # Cleaning any created tmp volume mySSH.command(self.cli + ' volume prune --force || true','\$', 15) mySSH.close() From 8b159d6ddce4d4c59adf7ea4c55de10d60c21df4 Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 18 Aug 2022 09:47:44 +0200 Subject: [PATCH 85/98] remove unclear function free_configmodule(), as we have end_configmodule() that do the same --- common/config/DOC/config/devusage/api.md | 5 ----- common/config/config_load_configmodule.c | 28 ------------------------ openair1/SIMULATION/NR_PHY/dlschsim.c | 1 - 3 files changed, 34 deletions(-) diff --git a/common/config/DOC/config/devusage/api.md b/common/config/DOC/config/devusage/api.md index 170e9b61f8..5bac70bcd1 100644 --- a/common/config/DOC/config/devusage/api.md +++ b/common/config/DOC/config/devusage/api.md @@ -17,11 +17,6 @@ void end_configmodule(void) * Possibly calls the `config__end` function This call should be used when all configurations have been read. The program will still be able to use parameter values allocated by the config module WHEN THE `PARAMFLAG_NOFREE` flag has been specified in the parameter definition. The config module can be reloaded later in the program (not fully tested as not used today) -```c -void free_configmodule(void) -``` -This call should be used to definitely free all resources allocated by the config module. All parameters values allocated by the config module become unavailable and no further reload of the config module are allowed. - ## Retrieving parameter's values ```c diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 922126b688..3fedf3f0f9 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -352,34 +352,6 @@ void end_configmodule(void) { } } -/* free all memory used by config module */ -/* should be called only at program exit */ -void free_configmodule(void) { - if (cfgptr != NULL) { - end_configmodule(); - - if( cfgptr->cfgmode != NULL) free(cfgptr->cfgmode); - int n=0; - for(int i=0; inumptrs ; i++) { - if (cfgptr->ptrs[i] != NULL) { - free(cfgptr->ptrs[i]); - cfgptr->ptrs[i]=NULL; - cfgptr->ptrsAllocated[i] = false; - n++; - } - } - printf ("[CONFIG] %u/%u persistent config value pointers have been released\n",n,cfgptr->numptrs); - cfgptr->numptrs=0; - printf ("[CONFIG] free %i config module parameter pointers\n",cfgptr->num_cfgP); - - for (int i=0; inum_cfgP; i++) { - if ( cfgptr->cfgP[i] != NULL) free(cfgptr->cfgP[i]); - } - free(cfgptr->argv_info); - free(cfgptr); - cfgptr=NULL; - } -} diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 9632c48208..21dadc1291 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -665,7 +665,6 @@ int main(int argc, char **argv) logInit(); loader_reset(); logTerm(); - free_configmodule(); return (n_errors); } From d6d4d87e0bd90a0bc14fb76e5a2f680d616f766c Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 18 Aug 2022 16:43:26 +0200 Subject: [PATCH 86/98] code review comments --- common/config/config_cmdline.c | 4 ++- common/config/config_load_configmodule.c | 11 ++++++-- common/config/config_userapi.c | 32 ++++++++++++---------- common/config/libconfig/config_libconfig.c | 4 ++- common/utils/LOG/log.c | 4 +-- common/utils/load_module_shlib.c | 4 +++ common/utils/load_module_shlib.h | 10 +++---- openair1/SIMULATION/NR_PHY/dlschsim.c | 4 --- openair2/LAYER2/NR_MAC_gNB/main.c | 3 +- 9 files changed, 44 insertions(+), 32 deletions(-) diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index 5ba6db8547..bd5f835a51 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -54,7 +54,9 @@ int parse_stringlist(paramdef_t *cfgoptions, char *val) { free(tmpval); - AssertFatal(MAX_LIST_SIZE > numelt, ""); + AssertFatal(MAX_LIST_SIZE > numelt, + "This piece of code use fixed size arry of constant #define MAX_LIST_SIZE %d\n", + MAX_LIST_SIZE ); config_check_valptr(cfgoptions, sizeof(char*), numelt); cfgoptions->numelt=numelt; diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 3fedf3f0f9..0e3ffc1309 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -339,16 +339,23 @@ void end_configmodule(void) { pthread_mutex_lock(&cfgptr->memBlocks_mutex); printf ("[CONFIG] free %u config value pointers\n",cfgptr->numptrs); - int n=0; for(int i=0; inumptrs ; i++) { if (cfgptr->oneBlock[i].ptrs != NULL && cfgptr->oneBlock[i].ptrsAllocated== true && cfgptr->oneBlock[i].toFree) { free(cfgptr->oneBlock[i].ptrs); memset(&cfgptr->oneBlock[i], 0, sizeof(cfgptr->oneBlock[i])); } } - + cfgptr->numptrs=0; pthread_mutex_unlock(&cfgptr->memBlocks_mutex); + if ( cfgptr->cfgmode ) + free(cfgptr->cfgmode); + + if ( cfgptr->argv_info ) + free( cfgptr->argv_info ); + + free(cfgptr); + cfgptr=NULL; } } diff --git a/common/config/config_userapi.c b/common/config/config_userapi.c index cebc59a95d..9725c15845 100644 --- a/common/config/config_userapi.c +++ b/common/config/config_userapi.c @@ -54,7 +54,9 @@ configmodule_interface_t *config_get_if(void) { static int managed_ptr_sz(void* ptr) { configmodule_interface_t * cfg=config_get_if(); - AssertFatal(cfg->numptrs < CONFIG_MAX_ALLOCATEDPTRS,""); + AssertFatal(cfg->numptrs < CONFIG_MAX_ALLOCATEDPTRS, + "This code use fixed size array as #define CONFIG_MAX_ALLOCATEDPTRS %d\n", + CONFIG_MAX_ALLOCATEDPTRS); int i; pthread_mutex_lock(&cfg->memBlocks_mutex); int numptrs=cfg->numptrs; @@ -70,19 +72,17 @@ static int managed_ptr_sz(void* ptr) { void *config_allocate_new(int sz, bool autoFree) { void *ptr = calloc(sz,1); - if (ptr != NULL) { - configmodule_interface_t * cfg=config_get_if(); - // add the memory piece in the managed memory pieces list - pthread_mutex_lock(&cfg->memBlocks_mutex); - int newBlockIdx=cfg->numptrs++; - oneBlock_t* tmp=&cfg->oneBlock[newBlockIdx]; - tmp->ptrs = (char *)ptr; - tmp->ptrsAllocated = true; - tmp->sz=sz; - tmp->toFree=autoFree; - pthread_mutex_unlock(&cfg->memBlocks_mutex); - } else - AssertFatal(false, "calloc fails\n"); + AssertFatal(ptr, "calloc fails\n"); + configmodule_interface_t * cfg=config_get_if(); + // add the memory piece in the managed memory pieces list + pthread_mutex_lock(&cfg->memBlocks_mutex); + int newBlockIdx=cfg->numptrs++; + oneBlock_t* tmp=&cfg->oneBlock[newBlockIdx]; + tmp->ptrs = (char *)ptr; + tmp->ptrsAllocated = true; + tmp->sz=sz; + tmp->toFree=autoFree; + pthread_mutex_unlock(&cfg->memBlocks_mutex); return ptr; } @@ -124,7 +124,9 @@ void config_check_valptr(paramdef_t *cfgoptions, int elt_sz, int nb_elt) { // difficult datamodel cfgoptions->strptr = config_allocate_new(sizeof(*cfgoptions->strptr), toFree); } else if ( cfgoptions->type == TYPE_STRINGLIST) { - AssertFatal(nb_eltstrlistptr= config_allocate_new(sizeof(char*)*MAX_LIST_SIZE, toFree); for (int i=0; istrlistptr[i]= config_allocate_new(DEFAULT_EXTRA_SZ, toFree); diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index 52faaaeb46..59e958470e 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -57,7 +57,9 @@ int read_strlist(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpath numelt=config_setting_length(setting); config_check_valptr(cfgoptions, sizeof(char *), numelt); st=0; - AssertFatal(MAX_LIST_SIZE > numelt, ""); + AssertFatal(MAX_LIST_SIZE > numelt, + "This piece of code use fixed size arry of constant #define MAX_LIST_SIZE %d\n", + MAX_LIST_SIZE ); for (int i=0; i< numelt ; i++) { str=config_setting_get_string_elem(setting,i); diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index e10e288737..9e8e17a3a4 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -381,8 +381,8 @@ void log_getconfig(log_t *g_log) } int register_log_component(char *name, - char *fext, - int compidx) + char *fext, + int compidx) { int computed_compidx=compidx; diff --git a/common/utils/load_module_shlib.c b/common/utils/load_module_shlib.c index 1c9aa8cab9..15b42577e6 100644 --- a/common/utils/load_module_shlib.c +++ b/common/utils/load_module_shlib.c @@ -281,5 +281,9 @@ void loader_reset() shlib->numfunc = 0; shlib->len_funcarray = 0; } + if(loader_data.shlibpath){ + free(loader_data.shlibpath); + loader_data.shlibpath=NULL; + } free(loader_data.shlibs); } diff --git a/common/utils/load_module_shlib.h b/common/utils/load_module_shlib.h index 7c54403f4d..e804edbfe7 100644 --- a/common/utils/load_module_shlib.h +++ b/common/utils/load_module_shlib.h @@ -51,11 +51,11 @@ typedef struct { }loader_shlibdesc_t; typedef struct { - char *mainexec_buildversion; - char *shlibpath; - uint32_t maxshlibs; - uint32_t numshlibs; - loader_shlibdesc_t *shlibs; + char *mainexec_buildversion; + char *shlibpath; + uint32_t maxshlibs; + uint32_t numshlibs; + loader_shlibdesc_t *shlibs; }loader_data_t; /* function type of functions which may be implemented by a module */ diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 21dadc1291..72a4774f05 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -659,10 +659,6 @@ int main(int argc, char **argv) if (ouput_vcd) vcd_signal_dumper_close(); end_configmodule(); - if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) { - exit_fun("[NR_DLSCHSIM] Error, configuration module init 2 failed\n"); - } - logInit(); loader_reset(); logTerm(); diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 9948df1eff..b272561a2d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -238,8 +238,7 @@ void mac_top_init_gNB(ngran_node_t node_type) RC.nrmac[i]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(i, 0); } if (!IS_SOFTMODEM_NOSTATS_BIT) - - threadCreate(&RC.nrmac[i]->stats_thread, nrmac_stats_thread, (void*)RC.nrmac[i], "MAC_STATS", -1, sched_get_priority_min(SCHED_OAI)+1 ); + threadCreate(&RC.nrmac[i]->stats_thread, nrmac_stats_thread, (void*)RC.nrmac[i], "MAC_STATS", -1, sched_get_priority_min(SCHED_OAI)+1 ); mac_rrc_init(RC.nrmac[i], node_type); }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) From 1638bbba8a5f70b542c22502dff9fe32336c96b3 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Thu, 18 Aug 2022 17:00:21 +0100 Subject: [PATCH 87/98] Add intermediate variable --- openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 3936135e49..2dc368fdb0 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -1017,6 +1017,8 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, ls_estimated[1] = (int16_t)(((int32_t)generated_real*received_imag - (int32_t)generated_imag*received_real)>>nr_srs_info->srs_generated_signal_bits); srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]] = ls_estimated[0] + (((int32_t)ls_estimated[1] << 16) & 0xFFFF0000); + const uint16_t sc_idx_offset = nr_srs_info->sc_list[sc_idx] + mem_offset; + // Channel interpolation if(srs_pdu->comb_size == 0) { if(sc_idx == 0) { // First subcarrier case @@ -1038,14 +1040,14 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, } else if(sc_idx%2 == 0) { // 2nd middle case // filt8_middle4 is {0,0,4096,8192,8192,8192,4096,0} multadd_real_vector_complex_scalar(filt8_middle4, ls_estimated, srs_estimated_channel16, 8); - srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[sc_idx] + mem_offset]; + srs_estimated_channel16 = (int16_t *)&srs_est[sc_idx_offset]; } } else { if(sc_idx == 0) { // First subcarrier case // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); } else if(nr_srs_info->sc_list[sc_idx] < nr_srs_info->sc_list[sc_idx - 1]) { // Start of OFDM symbol case - srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[sc_idx] + mem_offset]; + srs_estimated_channel16 = (int16_t *)&srs_est[sc_idx_offset]; // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); } else if((sc_idx < (nr_srs_info->sc_list_length - 1) && nr_srs_info->sc_list[sc_idx + 1] < nr_srs_info->sc_list[sc_idx]) @@ -1055,7 +1057,7 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, } else { // Middle case // filt16_middle4 is {4096,8192,8192,8192,8192,8192,8192,8192,4096,0,0,0,0,0,0,0} multadd_real_vector_complex_scalar(filt16_middle4, ls_estimated, srs_estimated_channel16, 16); - srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[sc_idx] + mem_offset]; + srs_estimated_channel16 = (int16_t *)&srs_est[sc_idx_offset]; } } @@ -1189,9 +1191,8 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, LOG_I(NR_PHY,"\t __lsRe__________lsIm__|____intRe_______intIm__|____noiRe_______noiIm_\n"); } for(int r = 0; rsc_list[sc_idx]+r>=frame_parms->ofdm_symbol_size) { + if (nr_srs_info->sc_list[sc_idx] + r >= frame_parms->ofdm_symbol_size) continue; - } LOG_I(NR_PHY,"(%4i) %6i\t%6i | %6i\t%6i | %6i\t%6i\n", subcarrier_log+r, (int16_t)(srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]+r]&0xFFFF), From 6bf0f98e7fb0c3217fb06b761e3896d8a6716e9e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Aug 2022 19:59:50 +0200 Subject: [PATCH 88/98] Skip scheduling of UEs if there are no free HARQs --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 8 ++++++++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 6aee81fa67..a35c80b95a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -613,6 +613,14 @@ void pf_dl(module_id_t module_id, return; } else { + /* skip this UE if there are no free HARQ processes. This can happen e.g. + * if the UE disconnected in L2sim, in which case the gNB is not notified + * (this can be considered a design flaw) */ + if (sched_ctrl->available_dl_harq.head < 0) { + LOG_D(NR_MAC, "RNTI %04x has no free DL HARQ process, skipping\n", UE->rnti); + continue; + } + /* Check DL buffer and skip this UE if no bytes and no TA necessary */ if (sched_ctrl->num_total_bytes == 0 && frame != (sched_ctrl->ta_frame + 10) % 1024) continue; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 43e88eb9a9..1ca9fa067e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1085,6 +1085,15 @@ void pf_ul(module_id_t module_id, continue; } + + /* skip this UE if there are no free HARQ processes. This can happen e.g. + * if the UE disconnected in L2sim, in which case the gNB is not notified + * (this can be considered a design flaw) */ + if (sched_ctrl->available_ul_harq.head < 0) { + LOG_D(NR_MAC, "RNTI %04x has no free UL HARQ process, skipping\n", UE->rnti); + continue; + } + const int B = max(0, sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes); /* preprocessor computed sched_frame/sched_slot */ const bool do_sched = nr_UE_is_to_be_scheduled(scc, 0, UE, sched_pusch->frame, sched_pusch->slot, nrmac->ulsch_max_frame_inactivity); From 238c8a62b48f4725e7cef0cf0f8f64cd953676fa Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Aug 2022 20:02:44 +0200 Subject: [PATCH 89/98] Delete dead code in nr-softmodem main() --- executables/nr-softmodem.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 616a712f38..b18bf129f7 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -787,42 +787,13 @@ int main( int argc, char **argv ) { pthread_mutex_unlock(&sync_mutex); } - printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); - - // We have to set PARAMFLAG_NOFREE on right paramters before re-enabling end_configmodule() - - //end_configmodule(); - printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); // wait for end of program - printf("TYPE TO TERMINATE\n"); - //getchar(); printf("Entering ITTI signals handler\n"); + printf("TYPE TO TERMINATE\n"); itti_wait_tasks_end(); printf("Returned from ITTI signal handler\n"); oai_exit=1; printf("oai_exit=%d\n",oai_exit); - // stop threads - /*#ifdef XFORMS - - printf("waiting for XFORMS thread\n"); - - if (do_forms==1) { - pthread_join(forms_thread,&status); - fl_hide_form(form_stats->stats_form); - fl_free_form(form_stats->stats_form); - - fl_hide_form(form_stats_l2->stats_form); - fl_free_form(form_stats_l2->stats_form); - - for(UE_id=0; UE_idphy_scope_gNB); - fl_free_form(form_enb[CC_id][UE_id]->phy_scope_gNB); - } - } - } - - #endif*/ // cleanup if (RC.nb_nr_L1_inst > 0) From b712e775279d04eb18f87ea24bef9b282d4a04c6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Aug 2022 20:03:24 +0200 Subject: [PATCH 90/98] Don't block nr-softmodem in nFAPI mode, not needed --- executables/nr-softmodem.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index b18bf129f7..5da5fe42f5 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -716,9 +716,6 @@ int main( int argc, char **argv ) { printf("NFAPI MODE:%s\n", nfapi_mode_str); - if (NFAPI_MODE==NFAPI_MODE_VNF) - wait_nfapi_init("main?"); - printf("START MAIN THREADS\n"); // start the main threads number_of_cards = 1; From 6c31639522440a07f4c92ed97c9b83107f79c7d1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Aug 2022 20:37:06 +0200 Subject: [PATCH 91/98] Only call NR_PHY_config_req when no (n)FAPI --- nfapi/oai_integration/nfapi_vnf.c | 1 - openair2/LAYER2/NR_MAC_gNB/config.c | 28 +++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 8cc1bda782..eabadc6193 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -1687,7 +1687,6 @@ int nr_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_config_re nfapi_nr_start_request_scf_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Calling oai_enb_init()\n"); - oai_enb_init(); // TODO: change to gnb memset(&req, 0, sizeof(req)); req.header.message_id = NFAPI_NR_PHY_MSG_TYPE_START_REQUEST; req.header.phy_id = resp->header.phy_id; diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 0f4e0539f2..770bae5b5d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -489,23 +489,21 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, scc); LOG_D(NR_MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req); - // if in nFAPI mode - if ( (NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) && (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) ){ - while(RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) { - // DJP AssertFatal(RC.nrmac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n"); - usleep(100 * 1000); - printf("Waiting for PHY_config_req\n"); - } + if (NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) { + // fake that the gNB is configured in nFAPI mode, which would normally be + // done in a NR_PHY_config_req, but in this mode, there is no PHY + RC.gNB[Mod_idP]->configured = 1; + } else { + NR_PHY_Config_t phycfg = { + .Mod_id = Mod_idP, + .CC_id = 0, + .cfg = &RC.nrmac[Mod_idP]->config[0] + }; + DevAssert(RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req); + RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req(&phycfg); } + RC.nrmac[Mod_idP]->minRXTXTIMEpdsch = minRXTXTIMEpdsch; - - NR_PHY_Config_t phycfg; - phycfg.Mod_id = Mod_idP; - phycfg.CC_id = 0; - phycfg.cfg = &RC.nrmac[Mod_idP]->config[0]; - - if (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req) RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req(&phycfg); - find_SSB_and_RO_available(Mod_idP); const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; From e0a802df16996a08cef2a794f3fbab889019d65e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Aug 2022 20:39:31 +0200 Subject: [PATCH 92/98] Remove irrelevant RU/L1/RFsim config from L2sim gNB config --- ...sci_gnb.band78.sa.fr1.106PRB.usrpn310.conf | 46 ------------------- .../episci_rcc.band78.tm1.106PRB.nfapi.conf | 10 ---- ...oxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf | 46 ------------------- .../proxy_rcc.band78.tm1.106PRB.nfapi.conf | 10 ---- 4 files changed, 112 deletions(-) diff --git a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf index a648db0efe..e92585b5fe 100644 --- a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -214,52 +214,6 @@ MACRLCs = ( } ); -L1s = ( -{ - num_cc = 1; - tr_n_preference = "local_mac"; - thread_pool_size = 8; - prach_dtx_threshold = 120; - pucch0_dtx_threshold = 150; -} -); - -RUs = ( - { - local_rf = "yes" - nb_tx = 1 - nb_rx = 1 - att_tx = 0 - att_rx = 0; - bands = [78]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 75; - eNB_instances = [0]; - #beamforming 1x4 matrix: - bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; - #clock_src = "external"; - sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" - } -); - -THREAD_STRUCT = ( - { - #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_SINGLE_THREAD"; - #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" - worker_config = "WORKER_ENABLE"; - } -); - -rfsimulator : -{ - serveraddr = "server"; - serverport = "4043"; - options = (); #("saviq"); or/and "chanmod" - modelname = "AWGN"; - IQfile = "/tmp/rfsimulator.iqs"; -}; - security = { # preferred ciphering algorithms # the first one of the list that an UE supports in chosen diff --git a/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf b/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf index 0db6ac9036..354a1eb076 100644 --- a/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf +++ b/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf @@ -218,16 +218,6 @@ MACRLCs = ( } ) - -THREAD_STRUCT = ( - { - #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; - #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" - worker_config = "WORKER_ENABLE"; - } -); - log_config = { global_log_level ="info"; diff --git a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf index 84cb18d435..7b6e045ffc 100644 --- a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -215,52 +215,6 @@ MACRLCs = ( } ); -L1s = ( -{ - num_cc = 1; - tr_n_preference = "local_mac"; - thread_pool_size = 8; - prach_dtx_threshold = 120; - pucch0_dtx_threshold = 150; -} -); - -RUs = ( - { - local_rf = "yes" - nb_tx = 1 - nb_rx = 1 - att_tx = 0 - att_rx = 0; - bands = [78]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 75; - eNB_instances = [0]; - #beamforming 1x4 matrix: - bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; - #clock_src = "external"; - sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" - } -); - -THREAD_STRUCT = ( - { - #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_SINGLE_THREAD"; - #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" - worker_config = "WORKER_ENABLE"; - } -); - -rfsimulator : -{ - serveraddr = "server"; - serverport = "4043"; - options = (); #("saviq"); or/and "chanmod" - modelname = "AWGN"; - IQfile = "/tmp/rfsimulator.iqs"; -}; - security = { # preferred ciphering algorithms # the first one of the list that an UE supports in chosen diff --git a/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf b/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf index 270ad75845..41be848ef5 100644 --- a/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf +++ b/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf @@ -235,16 +235,6 @@ MACRLCs = ( } ) - -THREAD_STRUCT = ( - { - #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; - #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" - worker_config = "WORKER_ENABLE"; - } -); - log_config = { global_log_level ="info"; From a0d800917008044cee022a3742882920edcdcde4 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Fri, 19 Aug 2022 14:31:13 +0100 Subject: [PATCH 93/98] Address review comments --- openair1/PHY/INIT/nr_init.c | 4 +-- .../NR_ESTIMATION/nr_ul_channel_estimation.c | 8 ++--- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 14 ++++---- openair1/PHY/NR_TRANSPORT/srs_rx.c | 32 +++++++++---------- .../PHY/NR_UE_TRANSPORT/srs_modulation_nr.c | 16 +++++----- .../PHY/NR_UE_TRANSPORT/srs_modulation_nr.h | 4 +-- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index d516ef3f10..4a053f2142 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -614,8 +614,8 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, for (int id=0; idnr_srs_info[id] = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); gNB->nr_srs_info[id]->srs_generated_signal = (int32_t**)malloc16_clear(MAX_NUM_NR_SRS_AP*sizeof(int32_t*)); - for(i=0; inr_srs_info[id]->srs_generated_signal[i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + for(int ap=0; apnr_srs_info[id]->srs_generated_signal[ap] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); } } diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index bc29298f0a..7016f05866 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -984,10 +984,10 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, const NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; const uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*NR_NB_SC_PER_RB; - uint8_t N_ap = 1<num_ant_ports; - uint8_t K_TC = 2<comb_size; - uint16_t m_SRS_b = srs_bandwidth_config[srs_pdu->config_index][srs_pdu->bandwidth_index][0]; - uint16_t M_sc_b_SRS = m_SRS_b * NR_NB_SC_PER_RB/K_TC; + const uint8_t N_ap = 1<num_ant_ports; + const uint8_t K_TC = 2<comb_size; + const uint16_t m_SRS_b = srs_bandwidth_config[srs_pdu->config_index][srs_pdu->bandwidth_index][0]; + const uint16_t M_sc_b_SRS = m_SRS_b * NR_NB_SC_PER_RB/K_TC; uint8_t fd_cdm = N_ap; if (N_ap == 4 && ((K_TC == 2 && srs_pdu->cyclic_shift >= 4) || (K_TC == 4 && srs_pdu->cyclic_shift >= 6))) { fd_cdm = 2; diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 5437a9bb81..e5b043c395 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -315,19 +315,19 @@ int nr_find_pucch(uint16_t rnti, NR_gNB_SRS_t *new_gNB_srs(void); void free_gNB_srs(NR_gNB_SRS_t *srs); -int nr_find_srs(uint16_t rnti, - int frame, - int slot, +int nr_find_srs(rnti_t rnti, + frame_t frame, + slot_t slot, PHY_VARS_gNB *gNB); void nr_fill_srs(PHY_VARS_gNB *gNB, - int frame, - int slot, + frame_t frame, + slot_t slot, nfapi_nr_srs_pdu_t *srs_pdu); int nr_get_srs_signal(PHY_VARS_gNB *gNB, - int frame, - int slot, + frame_t frame, + slot_t slot, nfapi_nr_srs_pdu_t *srs_pdu, nr_srs_info_t *nr_srs_info, int32_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)]); diff --git a/openair1/PHY/NR_TRANSPORT/srs_rx.c b/openair1/PHY/NR_TRANSPORT/srs_rx.c index 1362cebffd..54264b70e0 100644 --- a/openair1/PHY/NR_TRANSPORT/srs_rx.c +++ b/openair1/PHY/NR_TRANSPORT/srs_rx.c @@ -56,9 +56,9 @@ void free_gNB_srs(NR_gNB_SRS_t *srs) free_and_zero(srs); } -int nr_find_srs(uint16_t rnti, - int frame, - int slot, +int nr_find_srs(rnti_t rnti, + frame_t frame, + slot_t slot, PHY_VARS_gNB *gNB) { AssertFatal(gNB!=NULL,"gNB is null\n"); @@ -80,8 +80,8 @@ int nr_find_srs(uint16_t rnti, } void nr_fill_srs(PHY_VARS_gNB *gNB, - int frame, - int slot, + frame_t frame, + slot_t slot, nfapi_nr_srs_pdu_t *srs_pdu) { int id = nr_find_srs(srs_pdu->rnti,frame,slot,gNB); @@ -96,8 +96,8 @@ void nr_fill_srs(PHY_VARS_gNB *gNB, } int nr_get_srs_signal(PHY_VARS_gNB *gNB, - int frame, - int slot, + frame_t frame, + slot_t slot, nfapi_nr_srs_pdu_t *srs_pdu, nr_srs_info_t *nr_srs_info, int32_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)]) { @@ -107,17 +107,17 @@ int nr_get_srs_signal(PHY_VARS_gNB *gNB, #endif int32_t **rxdataF = gNB->common_vars.rxdataF; - NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; + const NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; - uint16_t n_symbols = (slot&3)*frame_parms->symbols_per_slot; // number of symbols until this slot - uint8_t l0 = frame_parms->symbols_per_slot - 1 - srs_pdu->time_start_position; // starting symbol in this slot - uint64_t symbol_offset = (n_symbols+l0)*frame_parms->ofdm_symbol_size; - uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*NR_NB_SC_PER_RB; + const uint16_t n_symbols = (slot&3)*frame_parms->symbols_per_slot; // number of symbols until this slot + const uint8_t l0 = frame_parms->symbols_per_slot - 1 - srs_pdu->time_start_position; // starting symbol in this slot + const uint64_t symbol_offset = (n_symbols+l0)*frame_parms->ofdm_symbol_size; + const uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*NR_NB_SC_PER_RB; - uint8_t N_ap = 1<num_ant_ports; - uint8_t N_symb_SRS = 1<num_symbols; - uint8_t K_TC = 2<comb_size; - uint16_t M_sc_b_SRS = srs_bandwidth_config[srs_pdu->config_index][srs_pdu->bandwidth_index][0] * NR_NB_SC_PER_RB/K_TC; + const uint8_t N_ap = 1<num_ant_ports; + const uint8_t N_symb_SRS = 1<num_symbols; + const uint8_t K_TC = 2<comb_size; + const uint16_t M_sc_b_SRS = srs_bandwidth_config[srs_pdu->config_index][srs_pdu->bandwidth_index][0] * NR_NB_SC_PER_RB/K_TC; int32_t *rx_signal; bool no_srs_signal = true; diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c index 604b24fbf7..55669ba322 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c @@ -91,8 +91,8 @@ uint16_t sequence_number_hopping(int slot_number, return v; } -uint16_t compute_F_b(int frame_number, - int slot_number, +uint16_t compute_F_b(frame_t frame_number, + slot_t slot_number, uint16_t slots_per_frame, uint8_t N_symb_SRS, uint8_t B_SRS, @@ -101,7 +101,7 @@ uint16_t compute_F_b(int frame_number, uint8_t R, uint16_t T_offset, uint16_t T_SRS, - uint8_t resource_type, + resourceType_t resource_type, uint8_t l_line, uint8_t b) { @@ -133,8 +133,8 @@ uint16_t compute_F_b(int frame_number, return F_b; } -uint16_t compute_n_b(int frame_number, - int slot_number, +uint16_t compute_n_b(frame_t frame_number, + slot_t slot_number, uint16_t slots_per_frame, uint8_t N_symb_SRS, uint8_t B_SRS, @@ -144,7 +144,7 @@ uint16_t compute_n_b(int frame_number, uint8_t R, uint16_t T_offset, uint16_t T_SRS, - uint8_t resource_type, + resourceType_t resource_type, uint8_t l_line, uint8_t b) { @@ -189,8 +189,8 @@ int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu, uint16_t symbol_offset, nr_srs_info_t *nr_srs_info, int16_t amp, - int frame_number, - int slot_number) { + frame_t frame_number, + slot_t slot_number) { #ifdef SRS_DEBUG LOG_I(NR_PHY,"Calling %s function\n", __FUNCTION__); diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h index e52338a01a..2c3d6d266c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h @@ -156,8 +156,8 @@ int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu, uint16_t symbol_offset, nr_srs_info_t *nr_srs_info, int16_t amp, - int frame_number, - int slot_number); + frame_t frame_number, + slot_t slot_number); /** \brief This function checks for periodic srs if srs should be transmitted in this slot * @param p_SRS_Resource pointer to active resource From 84f76348749600b33810c5d53c453e466dc6e56a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Aug 2022 20:54:01 +0200 Subject: [PATCH 94/98] Disable legacy 4G F1 test and XML scenario files --- ci-scripts/Jenkinsfile-gitlab | 23 ---- .../xml_files/f1_usrp210_band7_test_05mhz.xml | 111 ------------------ .../xml_files/f1_usrp210_band7_test_10mhz.xml | 111 ------------------ .../xml_files/f1_usrp210_band7_test_20mhz.xml | 111 ------------------ 4 files changed, 356 deletions(-) delete mode 100644 ci-scripts/xml_files/f1_usrp210_band7_test_05mhz.xml delete mode 100644 ci-scripts/xml_files/f1_usrp210_band7_test_10mhz.xml delete mode 100644 ci-scripts/xml_files/f1_usrp210_band7_test_20mhz.xml diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab index 54be9b653d..784588357d 100644 --- a/ci-scripts/Jenkinsfile-gitlab +++ b/ci-scripts/Jenkinsfile-gitlab @@ -416,29 +416,6 @@ pipeline { } } } - stage ("Test F1 - FDD - Band 7 - B210") { - when { - expression {doFullTestsuite} - } - steps { - script { - sh "sleep 60" - triggerSlaveJob ('eNB-CI-F1-FDD-Band7-B210', 'Test-F1-FDD-Band7') - } - } - post { - always { - script { - finalizeSlaveJob('eNB-CI-F1-FDD-Band7-B210') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } stage ("Test IF4p5 - TDD - Band 40 - B210") { when { expression {doFullTestsuite} diff --git a/ci-scripts/xml_files/f1_usrp210_band7_test_05mhz.xml b/ci-scripts/xml_files/f1_usrp210_band7_test_05mhz.xml deleted file mode 100644 index 68aca3a26d..0000000000 --- a/ci-scripts/xml_files/f1_usrp210_band7_test_05mhz.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - test-f1-05 - Test-F1-CU-DU-05MHz - tasks - 2 - - 030201 - 040101 - 030142 030141 000002 040301 000002 040541 040601 040641 040401 040201 030201 030202 - - - - - - IdleSleep - Sleep - 5 - - - - Initialize_eNB - Initialize DU (FDD/Band7/5MHz) - -O ci-scripts/conf_files/du.band7.tm1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time - 1 - - - - Initialize_eNB - Initialize CU (FDD/Band7/5MHz) - -O ci-scripts/conf_files/cu.band7.tm1.25PRB.conf --log_config.global_log_options level,nocolor,time - 0 - - - - Terminate_eNB - Terminate CU - 0 - - - - Terminate_eNB - Terminate DU - 1 - - - - Initialize_UE - Initialize UE - - - - Terminate_UE - Terminate UE - - - - Attach_UE - Attach UE - - - - Detach_UE - Detach UE - - - - Ping - ping (5MHz - 20 sec) - -c 20 - 5 - - - - Iperf - iperf (5MHz - DL/15Mbps/UDP)(30 sec)(single-ue profile) - -u -b 15M -t 30 -i 1 - 50 - single-ue - - - - Iperf - iperf (5MHz - UL/9Mbps/UDP)(30 sec)(single-ue profile) - -u -b 9M -t 30 -i 1 -R - 60 - single-ue - - - diff --git a/ci-scripts/xml_files/f1_usrp210_band7_test_10mhz.xml b/ci-scripts/xml_files/f1_usrp210_band7_test_10mhz.xml deleted file mode 100644 index 4e8fe45c36..0000000000 --- a/ci-scripts/xml_files/f1_usrp210_band7_test_10mhz.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - test-f1-10 - Test-F1-CU-DU-10MHz - tasks - 4 - - 030201 - 040101 - 030152 030151 000002 040301 000002 040551 040611 040651 040401 040201 030201 030202 - - - - - - IdleSleep - Sleep - 5 - - - - Initialize_eNB - Initialize DU (FDD/Band7/10MHz) - -O ci-scripts/conf_files/du.band7.tm1.50PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time - 1 - - - - Initialize_eNB - Initialize CU (FDD/Band7/10MHz) - -O ci-scripts/conf_files/cu.band7.tm1.50PRB.conf --log_config.global_log_options level,nocolor,time - 0 - - - - Terminate_eNB - Terminate CU - 0 - - - - Terminate_eNB - Terminate DU - 1 - - - - Initialize_UE - Initialize UE - - - - Terminate_UE - Terminate UE - - - - Attach_UE - Attach UE - - - - Detach_UE - Detach UE - - - - Ping - ping (10MHz - 20 sec) - -c 20 - 5 - - - - Iperf - iperf (10MHz - DL/32Mbps/UDP)(30 sec)(single-ue profile) - -u -b 32M -t 30 -i 1 - 50 - single-ue - - - - Iperf - iperf (10MHz - UL/15Mbps/UDP)(30 sec)(single-ue profile) - -u -b 15M -t 30 -i 1 -R - 60 - single-ue - - - diff --git a/ci-scripts/xml_files/f1_usrp210_band7_test_20mhz.xml b/ci-scripts/xml_files/f1_usrp210_band7_test_20mhz.xml deleted file mode 100644 index 22e2aed34c..0000000000 --- a/ci-scripts/xml_files/f1_usrp210_band7_test_20mhz.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - test-f1-20 - Test-F1-CU-DU-20MHz - tasks - 4 - - 030201 - 040101 - 030162 030161 000002 040301 000002 040561 040621 040661 040401 040201 030201 030202 - - - - - - IdleSleep - Sleep - 5 - - - - Initialize_eNB - Initialize DU (FDD/Band7/20MHz) - -O ci-scripts/conf_files/du.band7.tm1.100PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time - 1 - - - - Initialize_eNB - Initialize CU (FDD/Band7/20MHz) - -O ci-scripts/conf_files/cu.band7.tm1.100PRB.conf --log_config.global_log_options level,nocolor,time - 0 - - - - Terminate_eNB - Terminate CU - 0 - - - - Terminate_eNB - Terminate DU - 1 - - - - Initialize_UE - Initialize UE - - - - Terminate_UE - Terminate UE - - - - Attach_UE - Attach UE - - - - Detach_UE - Detach UE - - - - Ping - ping (20MHz - 20 sec) - -c 20 - 5 - - - - Iperf - iperf (20MHz - DL/70Mbps/UDP)(30 sec)(single-ue profile) - -u -b 70M -t 30 -i 1 - 50 - single-ue - - - - Iperf - iperf (20MHz - UL/15Mbps/UDP)(30 sec)(single-ue profile) - -u -b 15M -t 30 -i 1 -R - 60 - single-ue - - - From 8aaede906d5cad3ac9640d52f74b14dae6708cd6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 19 Aug 2022 14:56:43 +0200 Subject: [PATCH 95/98] Do not hard-code default global log level --- common/utils/LOG/log.c | 1 - 1 file changed, 1 deletion(-) diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 2098a33c20..2c9d444dbb 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -325,7 +325,6 @@ void log_getconfig(log_t *g_log) logparams_logfile[i].numelt = 0; logparams_level[i].numelt = 0; logparams_level[i].type = TYPE_STRING; - logparams_level[i].defstrval= "error"; logparams_logfile[i].type = TYPE_UINT; logparams_logfile[i].paramflags = logparams_logfile[i].paramflags|PARAMFLAG_BOOL; } From 2ea9618a8dc01a3ad8598ae99871946d0a05e4a0 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 19 Aug 2022 15:24:38 +0200 Subject: [PATCH 96/98] Limit function name string length for logging output --- common/utils/LOG/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 2c9d444dbb..4605df06e0 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -542,11 +542,11 @@ static inline int log_header(log_component_t *c, char l[32]; if (flag & FLAG_FILE_LINE && flag & FLAG_FUNCT ) - snprintf(l, sizeof l, "(%s:%d) ", func, line); + snprintf(l, sizeof l, "(%.23s:%d) ", func, line); else if (flag & FLAG_FILE_LINE) snprintf(l, sizeof l, "(%d) ", line); else if (flag & FLAG_FUNCT) - snprintf(l, sizeof l, "(%s) ", func); + snprintf(l, sizeof l, "(%.28s) ", func); else l[0] = 0; From df0f756c8730b63fc096b26ee508304c9c5152b1 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Mon, 22 Aug 2022 11:30:06 +0100 Subject: [PATCH 97/98] Fix build after merge --- openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c | 5 +---- openair2/RRC/NR/MESSAGES/asn1_msg.c | 5 +++-- openair2/RRC/NR/nr_rrc_config.c | 3 ++- openair2/RRC/NR/nr_rrc_config.h | 2 +- openair2/RRC/NR/rrc_gNB_reconfig.c | 2 +- 5 files changed, 8 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 d3f67cd881..369527e5cd 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -1000,10 +1000,7 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, int16_t ls_estimated[2]; - uint8_t mem_offset = 0; - while(((long)&srs_estimated_channel_freq[0][nr_srs_info->sc_list[0] + mem_offset] & 0xF) != 0) { - mem_offset++; - } + uint8_t mem_offset = ((long)&srs_estimated_channel_freq[0][0][subcarrier_offset + nr_srs_info->k_0_p[0][0]]) & 0xF; int32_t srs_est[frame_parms->ofdm_symbol_size*(1<num_symbols) + mem_offset] __attribute__ ((aligned(32))); for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index e13abbfe0c..04b0bb2d3c 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1092,7 +1092,7 @@ void fill_initial_SpCellConfig(int uid, // We are using do_srs = 0 here because the periodic SRS will only be enabled in update_cellGroupConfig() if do_srs == 1 initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); - config_srs(initialUplinkBWP->srs_Config, curr_bwp, NULL, uid, 0, 0); + config_srs(initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, 0); scheduling_request_config(scc, pucch_Config); @@ -1596,8 +1596,8 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config)); } config_srs(SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config, - curr_bwp, uecap, + curr_bwp, uid, 0, configuration->do_SRS); @@ -1621,6 +1621,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_BWP_Uplink_t *ul_bwp = UL_BWP_list->list.array[i]; int bwp_size = NRRIV2BW(ul_bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); config_srs(ul_bwp->bwp_Dedicated->srs_Config, + uecap, bwp_size, uid, i+1, diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 23d6f9a894..9a1d137a8c 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -352,8 +352,8 @@ long rrc_get_max_nr_csrs(const uint8_t max_rbs, const long b_SRS) { } void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, - const int curr_bwp, const NR_UE_NR_Capability_t *uecap, + const int curr_bwp, const int uid, const int res_id, const int do_srs) { @@ -1137,6 +1137,7 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); config_srs(ubwp->bwp_Dedicated->srs_Config, + NULL, curr_bwp, uid, bwp_loop+1, diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index acd25e5575..49922aed6b 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -145,8 +145,8 @@ void config_csirs(const NR_ServingCellConfigCommon_t *servingcellconfigcommon, void config_csiim(int do_csirs, int dl_antenna_ports, int curr_bwp, NR_CSI_MeasConfig_t *csi_MeasConfig, int id); void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, - const int curr_bwp, const NR_UE_NR_Capability_t *uecap, + const int curr_bwp, const int uid, const int res_id, const int do_srs); diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 85aa5e24a9..0f1da63510 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -489,7 +489,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco int curr_bwp = NRRIV2BW(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); - config_srs(initialUplinkBWP->srs_Config, curr_bwp, uid, 0, configuration->do_SRS); + config_srs(initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, configuration->do_SRS); // Downlink BWPs int n_dl_bwp = 1; From c6fda387e0d62b2dcd6806b2a80aae90a681178e Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Mon, 22 Aug 2022 14:23:12 +0100 Subject: [PATCH 98/98] Fix mem_offset after merge --- openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 369527e5cd..6b10ed19cc 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -1000,7 +1000,7 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, int16_t ls_estimated[2]; - uint8_t mem_offset = ((long)&srs_estimated_channel_freq[0][0][subcarrier_offset + nr_srs_info->k_0_p[0][0]]) & 0xF; + uint8_t mem_offset = ((16 - ((long)&srs_estimated_channel_freq[0][0][subcarrier_offset + nr_srs_info->k_0_p[0][0]])) & 0xF) >> 2; // >> 2 <=> /sizeof(int32_t) int32_t srs_est[frame_parms->ofdm_symbol_size*(1<num_symbols) + mem_offset] __attribute__ ((aligned(32))); for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) {