From 3e7a0820341b0670cbabf2aa8c74f7d2427fca4b Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 31 May 2023 14:52:08 +0200 Subject: [PATCH] check if SSB is on the sync raster for SA --- openair2/GNB_APP/gnb_config.c | 117 +++++++++++++++++++++++++++++++--- 1 file changed, 108 insertions(+), 9 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 9db7cc5067..c2c0796c98 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -94,6 +94,49 @@ extern uint16_t sf_ahead; int macrlc_has_f1 = 0; +// synchronization raster per band tables +// (38.101-1 Table 5.4.3.3-1 and 38.101-2 Table 5.4.3.3-1) +// band nb, sub-carrier spacing index, Range of GSCN (First, Step size, Last) +const uint32_t sync_raster[37][5] = { + {1, 0, 5279, 1, 5419}, + {2, 0, 4829, 1, 4969}, + {3, 0, 4517, 1, 4693}, + {5, 0, 2177, 1, 2230}, + {5, 1, 2183, 1, 2224}, + {7, 0, 6554, 1, 6718}, + {8, 0, 2318, 1, 2395}, + {12, 0, 1828, 1, 1858}, + {20, 0, 1982, 1, 2047}, + {25, 0, 4829, 1, 4981}, + {28, 0, 1901, 1, 2002}, + {34, 0, 5030, 1, 5056}, + {38, 0, 6431, 1, 6544}, + {39, 0, 4706, 1, 4795}, + {40, 0, 5756, 1, 5995}, + {41, 0, 6246, 3, 6717}, + {41, 1, 6254, 3, 6714}, + {50, 0, 3584, 1, 3787}, + {51, 0, 3572, 1, 3574}, + {66, 0, 5279, 1, 5494}, + {66, 1, 5285, 1, 5488}, + {70, 0, 4993, 1, 5044}, + {71, 0, 1547, 1, 1624}, + {74, 0, 3692, 1, 3790}, + {75, 0, 3584, 1, 3787}, + {76, 0, 3572, 1, 3574}, + {77, 1, 7711, 1, 8329}, + {78, 1, 7711, 1, 8051}, + {79, 1, 8480, 16, 8880}, + {257, 3, 22388, 1, 22558}, + {257, 4, 22390, 2, 22556}, + {258, 3, 22257, 1, 22443}, + {258, 4, 22258, 2, 22442}, + {260, 3, 22995, 1, 23166}, + {260, 4, 22996, 2, 23164}, + {261, 3, 22446, 1, 22492}, + {261, 4, 22446, 2, 22490}, +}; + extern int config_check_band_frequencies(int ind, int16_t band, uint64_t downlink_frequency, int32_t uplink_frequency_offset, uint32_t frame_type); @@ -1073,12 +1116,64 @@ void config_security(gNB_RRC_INST *rrc) } } -void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { +// Section 5.4.3 of 38.101-1 and -2 +void check_ssb_raster(long absolutefreqssb, int band, int scs) +{ + int start_GSCN = 0, step_GSCN = 0, end_GSCN = 0; + for (int i = 0; i < sizeof(sync_raster) / 20; i++) { + if (sync_raster[i][0] == band && + sync_raster[i][1] == scs) { + start_GSCN = sync_raster[i][2]; + step_GSCN = sync_raster[i][3]; + end_GSCN = sync_raster[i][4]; + break; + } + } + AssertFatal(start_GSCN != 0, "Couldn't find band %d with SCS %d\n", band, scs); + uint64_t freq = from_nrarfcn(band, scs, absolutefreqssb); + int GSCN; + if (freq <= 3000000000) { + int N = 0; + int M = 0; + for (int k = 0; k < 3; k++) { + M = (k << 1) + 1; + if ((freq - M * 50000) % 1200000) { + N = (freq - M * 50000) / 1200000; + break; + } + } + AssertFatal(N != 0, "absoluteFrequencySSB %ld (%lu) not on the synchronization raster (N * 1200kHz + M * 50 kHz)\n", + absolutefreqssb, freq); + GSCN = (3 * N) + (M - 3) / 2; + } + else if (freq <= 24250000000) { + AssertFatal((freq - 3000000000) % 1440000 == 0, + "absoluteFrequencySSB %ld (%lu) not on the synchronization raster (3000 MHz + N * 1.44 MHz)\n", + absolutefreqssb, freq); + GSCN = ((freq - 3000000000) / 1440000) + 7499; + } + else { + AssertFatal((freq - 24250080000) % 17280000 == 0, + "absoluteFrequencySSB %ld (%lu) not on the synchronization raster (24250.08 MHz + N * 17.28 MHz)\n", + absolutefreqssb, freq); + GSCN = ((freq - 24250080000) / 17280000) + 22256; + } + AssertFatal(GSCN >= start_GSCN && GSCN <= end_GSCN, + "GSCN %d corresponding to absoluteFrequencySSB %ld does not belong to GSCN range for band %d\n", + GSCN, absolutefreqssb, band); + int rel_GSCN = GSCN - start_GSCN; + AssertFatal(rel_GSCN % step_GSCN == 0, + "GSCN %d corresponding to absoluteFrequencySSB %ld not in accordance with GSCN step for band %d\n", + GSCN, absolutefreqssb, band); +} - int num_gnbs = 0; +void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) +{ + + int num_gnbs = 0; char aprefix[MAX_OPTNAME_SIZE*2 + 8]; - int32_t gnb_id = 0; - int k = 0; + int32_t gnb_id = 0; + int k = 0; paramdef_t GNBSParams[] = GNBSPARAMS_DESC; ////////// Identification parameters @@ -1098,7 +1193,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { paramdef_t SCDsParams[] = SCDPARAMS_DESC(scd); paramlist_def_t SCDsParamList = {GNB_CONFIG_STRING_SERVINGCELLCONFIGDEDICATED, NULL, 0}; - ////////// Physical parameters + ////////// Physical parameters /* get global parameters, defined outside any section in the config file */ @@ -1106,11 +1201,10 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; AssertFatal (i0) { + if (num_gnbs > 0) { // Output a list of all gNBs. ////////// Identification parameters config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); - if (GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr == NULL) { // Calculate a default gNB ID if (get_softmodem_params()->sa) { @@ -1129,7 +1223,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { config_getlist(&SCCsParamList, NULL, 0, aprefix); if (SCCsParamList.numelt > 0) { sprintf(aprefix, "%s.[%i].%s.[%i]", GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON, 0); - config_get( SCCsParams,sizeof(SCCsParams)/sizeof(paramdef_t),aprefix); + config_get(SCCsParams,sizeof(SCCsParams) / sizeof(paramdef_t), aprefix); LOG_I(RRC,"Read in ServingCellConfigCommon (PhysCellId %d, ABSFREQSSB %d, DLBand %d, ABSFREQPOINTA %d, DLBW %d,RACH_TargetReceivedPower %d\n", (int)*scc->physCellId, (int)*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB, @@ -1137,7 +1231,12 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { (int)scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA, (int)scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth, (int)scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleReceivedTargetPower); - fix_scc(scc,ssb_bitmap); + // SSB of the PCell is always on the sync raster + if (get_softmodem_params()->sa) + check_ssb_raster(*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB, + *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], + *scc->ssbSubcarrierSpacing); + fix_scc(scc, ssb_bitmap); } sprintf(aprefix, "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, 0);