diff --git a/openair2/GNB_APP/RRC_nr_paramsvalues.h b/openair2/GNB_APP/RRC_nr_paramsvalues.h index 5b77da80b4..be2fd03542 100644 --- a/openair2/GNB_APP/RRC_nr_paramsvalues.h +++ b/openair2/GNB_APP/RRC_nr_paramsvalues.h @@ -116,6 +116,7 @@ #define GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS "nrofDownlinkSymbols" #define GNB_CONFIG_STRING_NROFUPLINKSLOTS "nrofUplinkSlots" #define GNB_CONFIG_STRING_NROFUPLINKSYMBOLS "nrofUplinkSymbols" +#define GNB_CONFIG_STRING_PATTERN2 "pattern2" #define GNB_CONFIG_STRING_DLULTRANSMISSIONPERIODICITY2 "dl_UL_TransmissionPeriodicity2" #define GNB_CONFIG_STRING_NROFDOWNLINKSLOTS2 "nrofDownlinkSlots2" #define GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS2 "nrofDownlinkSymbols2" @@ -247,11 +248,6 @@ {GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS,NULL,0,.i64ptr=&scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols,.defint64val=6,TYPE_INT64,0},\ {GNB_CONFIG_STRING_NROFUPLINKSLOTS,NULL,0,.i64ptr=&scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots,.defint64val=2,TYPE_INT64,0},\ {GNB_CONFIG_STRING_NROFUPLINKSYMBOLS,NULL,0,.i64ptr=&scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols,.defint64val=4,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_DLULTRANSMISSIONPERIODICITY2,NULL,0,.i64ptr=&scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity,.defintval=-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_NROFDOWNLINKSLOTS2,NULL,0,.i64ptr=&scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots,.defint64val=-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS2,NULL,0,.i64ptr=&scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSymbols,.defint64val=-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_NROFUPLINKSLOTS2,NULL,0,.i64ptr=&scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSlots,.defint64val=-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_NROFUPLINKSYMBOLS2,NULL,0,.i64ptr=&scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSymbols,.defint64val=-1,TYPE_INT64,0},\ {GNB_CONFIG_STRING_SSPBCHBLOCKPOWER,NULL,0,.i64ptr=&scc->ss_PBCH_BlockPower,.defint64val=20,TYPE_INT64,0}, \ {GNB_CONFIG_STRING_CELLSPECIFICKOFFSET,NULL,0,.i64ptr=scc->ext2->ntn_Config_r17->cellSpecificKoffset_r17,.defint64val=0,TYPE_INT64,0}, \ {GNB_CONFIG_STRING_EPHEMERIS_POSITION_X,NULL,0,.i64ptr=&scc->ext2->ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17->positionX_r17,.defint64val=LONG_MAX,TYPE_INT64,0}, \ @@ -263,6 +259,15 @@ {GNB_CONFIG_STRING_TA_COMMON,NULL,0,.i64ptr=&scc->ext2->ntn_Config_r17->ta_Info_r17->ta_Common_r17,.defint64val=-1,TYPE_INT64,0}, \ {GNB_CONFIG_STRING_MSG1SUBCARRIERSPACING,NULL,0,.i64ptr=scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing,.defintval=-1,TYPE_INT64,0}} +#define SCC_PATTERN2_STRING_CONFIG "pattern2" + +#define SCC_PATTERN2_PARAMS_DESC(pattern2) { \ +{GNB_CONFIG_STRING_DLULTRANSMISSIONPERIODICITY2, NULL,0,.i64ptr=&pattern2.dl_UL_TransmissionPeriodicity,.defint64val=-1,TYPE_INT64,0},\ +{GNB_CONFIG_STRING_NROFDOWNLINKSLOTS2, NULL,0,.i64ptr=&pattern2.nrofDownlinkSlots,.defint64val=-1,TYPE_INT64,0},\ +{GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS2, NULL,0,.i64ptr=&pattern2.nrofDownlinkSymbols,.defint64val=-1,TYPE_INT64,0},\ +{GNB_CONFIG_STRING_NROFUPLINKSLOTS2,NULL, 0,.i64ptr=&pattern2.nrofUplinkSlots,.defint64val=-1,TYPE_INT64,0},\ +{GNB_CONFIG_STRING_NROFUPLINKSYMBOLS2,NULL, 0,.i64ptr=&pattern2.nrofUplinkSymbols,.defint64val=-1,TYPE_INT64,0}} + /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* Serving Cell Config Dedicated configuration parameters */ /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 39c8014adc..a57d2e0287 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -113,7 +113,10 @@ void prepare_scc(NR_ServingCellConfigCommon_t *scc) scc->ssb_periodicityServingCell = calloc_or_fail(1, sizeof(*scc->ssb_periodicityServingCell)); scc->ssbSubcarrierSpacing = calloc_or_fail(1, sizeof(*scc->ssbSubcarrierSpacing)); scc->tdd_UL_DL_ConfigurationCommon = calloc_or_fail(1, sizeof(*scc->tdd_UL_DL_ConfigurationCommon)); - scc->tdd_UL_DL_ConfigurationCommon->pattern2 = calloc_or_fail(1, sizeof(*scc->tdd_UL_DL_ConfigurationCommon->pattern2)); + struct NR_TDD_UL_DL_ConfigCommon *tdd = scc->tdd_UL_DL_ConfigurationCommon; + tdd->pattern1.ext1 = calloc_or_fail(1, sizeof(*tdd->pattern1.ext1)); + tdd->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530 = + calloc_or_fail(1, sizeof(*tdd->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530)); scc->downlinkConfigCommon = calloc_or_fail(1, sizeof(*scc->downlinkConfigCommon)); scc->downlinkConfigCommon->frequencyInfoDL = calloc_or_fail(1, sizeof(*scc->downlinkConfigCommon->frequencyInfoDL)); scc->downlinkConfigCommon->initialDownlinkBWP = calloc_or_fail(1, sizeof(*scc->downlinkConfigCommon->initialDownlinkBWP)); @@ -357,15 +360,52 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc, uint64_t *ssb_bitmap, int N p1->nrofUplinkSymbols = 4; struct NR_TDD_UL_DL_Pattern *p2 = tdd_UL_DL_ConfigurationCommon->pattern2; - p2->dl_UL_TransmissionPeriodicity = 321; - p2->nrofDownlinkSlots = -1; - p2->nrofDownlinkSymbols = -1; - p2->nrofUplinkSlots = -1; - p2->nrofUplinkSymbols = -1; + if (p2) { + p2->dl_UL_TransmissionPeriodicity = 321; + p2->nrofDownlinkSlots = -1; + p2->nrofDownlinkSymbols = -1; + p2->nrofUplinkSlots = -1; + p2->nrofUplinkSymbols = -1; + } scc->ss_PBCH_BlockPower = 20; } +static void fix_tdd_pattern(NR_ServingCellConfigCommon_t *scc) +{ + NR_TDD_UL_DL_Pattern_t *pattern1 = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + int pattern_ext = pattern1->dl_UL_TransmissionPeriodicity - 8; + // Check if the pattern1 extension is configured and set the value accordingly + if (pattern_ext >= 0) { + pattern1->ext1 = calloc_or_fail(1, sizeof(struct NR_TDD_UL_DL_Pattern__ext1)); + pattern1->ext1->dl_UL_TransmissionPeriodicity_v1530 = + calloc_or_fail(1, sizeof(*pattern1->ext1->dl_UL_TransmissionPeriodicity_v1530)); + *pattern1->ext1->dl_UL_TransmissionPeriodicity_v1530 = pattern_ext; + pattern1->dl_UL_TransmissionPeriodicity = 5; + } else { + pattern1->ext1 = NULL; + } + struct NR_TDD_UL_DL_Pattern *pattern2 = scc->tdd_UL_DL_ConfigurationCommon->pattern2; + if (pattern2 != NULL) { + /* The pattern2 is not configured free the memory these shall not be encoded with default values in SIB1 */ + if (pattern2->dl_UL_TransmissionPeriodicity == -1) { + free(pattern2); + pattern2 = NULL; + } else { + // Check if the pattern2 extension is configured and set the value accordingly + pattern_ext = pattern2->dl_UL_TransmissionPeriodicity - 8; + if (pattern_ext >= 0) { + pattern2->ext1 = calloc_or_fail(1, sizeof(*pattern2->ext1)); + pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530 = + CALLOC(1, sizeof(*pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530)); + *pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530 = pattern_ext; + pattern2->dl_UL_TransmissionPeriodicity = 5; + } else { + pattern2->ext1 = NULL; + } + } + } +} void fix_scc(NR_ServingCellConfigCommon_t *scc, uint64_t ssbmap) { @@ -436,11 +476,7 @@ void fix_scc(NR_ServingCellConfigCommon_t *scc, uint64_t ssbmap) ASN_STRUCT_FREE(asn_DEF_NR_TDD_UL_DL_ConfigCommon, scc->tdd_UL_DL_ConfigurationCommon); scc->tdd_UL_DL_ConfigurationCommon = NULL; } else { // TDD - if (scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity > 320 ) { - free(scc->tdd_UL_DL_ConfigurationCommon->pattern2); - scc->tdd_UL_DL_ConfigurationCommon->pattern2 = NULL; - } - + fix_tdd_pattern(scc); } if ((int)*scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing == -1) { @@ -982,6 +1018,16 @@ void RCconfig_NR_L1(void) } } +/** + * @brief Returns true when pattern2 is filled in + */ +bool is_pattern2_config(paramdef_t *param) +{ + if (param == NULL || param->i64ptr == NULL || *(param->i64ptr) == -1) + return false; + return true; +} + static NR_ServingCellConfigCommon_t *get_scc_config(configmodule_interface_t *cfg, int minRXTXTIME) { NR_ServingCellConfigCommon_t *scc = calloc_or_fail(1, sizeof(*scc)); @@ -1002,6 +1048,33 @@ static NR_ServingCellConfigCommon_t *get_scc_config(configmodule_interface_t *cf sprintf(aprefix, "%s.[%i].%s.[%i]", GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON, 0); config_get(cfg, SCCsParams, sizeofArray(SCCsParams), aprefix); config_get(cfg, MsgASCCsParams, sizeofArray(MsgASCCsParams), aprefix); + // NR_TDD-UL-DL-ConfigCommon pattern2 (optional IE) + // fetch params + struct NR_TDD_UL_DL_Pattern p2; + paramdef_t pattern2Params[] = SCC_PATTERN2_PARAMS_DESC(p2); + char aprefix[MAX_OPTNAME_SIZE * 2 + 8]; + sprintf(aprefix, "%s.[%i].%s.[%i].%s", GNB_CONFIG_STRING_GNB_LIST, 0, GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON, 0, SCC_PATTERN2_STRING_CONFIG); + config_get(config_get_if(), pattern2Params, sizeofArray(pattern2Params), aprefix); + // check validity + bool is_pattern2 = false; + for (int i = 0; i < sizeofArray(pattern2Params); i++) { + is_pattern2 |= is_pattern2_config(pattern2Params); + } + + if (is_pattern2) { + LOG_I(GNB_APP, "tdd->pattern2 present\n"); + // allocate memory + struct NR_TDD_UL_DL_ConfigCommon *tdd = scc->tdd_UL_DL_ConfigurationCommon; + tdd->pattern2 = calloc_or_fail(1, sizeof(*tdd->pattern2)); + tdd->pattern2->ext1 = calloc_or_fail(1, sizeof(struct NR_TDD_UL_DL_Pattern__ext1)); + tdd->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530 = calloc_or_fail(1, sizeof(*tdd->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530)); + // fill in scc + *scc->tdd_UL_DL_ConfigurationCommon->pattern2 = p2; + AssertFatal(p2.nrofUplinkSlots ^ scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots, + "UL slots in pattern1 (%ld) and pattern2 (%ld) are mutually exclusive (e.g. DDDFUU DDDD, DDDD DDDFUU)\n", + scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots, + p2.nrofUplinkSlots); + } struct NR_FrequencyInfoDL *frequencyInfoDL = scc->downlinkConfigCommon->frequencyInfoDL; LOG_I(RRC, "Read in ServingCellConfigCommon (PhysCellId %d, ABSFREQSSB %d, DLBand %d, ABSFREQPOINTA %d, DLBW "