gnb_config.c 194 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * 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
 */

/*
ChenWeiTai's avatar
ChenWeiTai committed
23
  gnb_config.c
24
  -------------------
ChenWeiTai's avatar
ChenWeiTai committed
25 26 27
  AUTHOR  : Lionel GAUTHIER, navid nikaein, Laurent Winckel, WEI-TAI CHEN
  COMPANY : EURECOM, NTUST
  EMAIL   : Lionel.Gauthier@eurecom.fr, navid.nikaein@eurecom.fr, kroempa@gmail.com
28 29
*/

30 31 32
#include <string.h>
#include <inttypes.h>

knopp's avatar
knopp committed
33 34
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/log_extern.h"
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#include "assertions.h"
#include "gnb_config.h"
#include "UTIL/OTG/otg.h"
#include "UTIL/OTG/otg_externs.h"
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
# if defined(ENABLE_USE_MME)
#   include "s1ap_eNB.h"
#   include "sctp_eNB_task.h"
# endif
#endif
#include "sctp_default_values.h"
// #include "SystemInformationBlockType2.h"
// #include "LAYER2/MAC/extern.h"
// #include "LAYER2/MAC/proto.h"
50 51
#include "PHY/phy_extern.h"
#include "PHY/INIT/phy_init.h"
52 53 54 55 56 57 58 59 60
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
#include "nfapi_vnf.h"
#include "nfapi_pnf.h"

#include "L1_paramdef.h"
#include "MACRLC_paramdef.h"
#include "common/config/config_userapi.h"
#include "RRC_config_tools.h"
#include "gnb_paramdef.h"
ChenWeiTai's avatar
ChenWeiTai committed
61
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
62

knopp's avatar
knopp committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
#include "NR_SCS-SpecificCarrier.h"
#include "NR_TDD-UL-DL-ConfigCommon.h"
#include "NR_FrequencyInfoUL.h"
#include "NR_RACH-ConfigGeneric.h"
#include "NR_RACH-ConfigCommon.h"
#include "NR_PUSCH-TimeDomainResourceAllocation.h"
#include "NR_PUSCH-ConfigCommon.h"
#include "NR_PUCCH-ConfigCommon.h"
#include "NR_PDSCH-TimeDomainResourceAllocation.h"
#include "NR_PDSCH-ConfigCommon.h"
#include "NR_RateMatchPattern.h"
#include "NR_RateMatchPatternLTE-CRS.h"
#include "NR_SearchSpace.h"
#include "NR_ControlResourceSet.h"
#include "NR_EUTRA-MBSFN-SubframeConfig.h"

79
extern uint16_t sf_ahead;
Wang Tsu-Han's avatar
Wang Tsu-Han committed
80 81 82 83
extern void set_parallel_conf(char *parallel_conf);
extern void set_worker_conf(char *worker_conf);
extern PARALLEL_CONF_t get_thread_parallel_conf(void);
extern WORKER_CONF_t   get_thread_worker_conf(void);
84

ChenWeiTai's avatar
ChenWeiTai committed
85
void RCconfig_nr_flexran()
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
{
  uint16_t  i;
  uint16_t  num_gnbs;
  char      aprefix[MAX_OPTNAME_SIZE*2 + 8];
  /* this will possibly truncate the cell id (RRC assumes int32_t).
   * Both Nid_cell and gnb_id are signed in RRC case, but we use unsigned for
   * the bitshifting to work properly */
  int32_t   Nid_cell = 0;
  uint16_t  Nid_cell_tr = 0;
  uint32_t  gnb_id = 0;

  /*
   * the only reason for all these variables is, that they are "hard-encoded"
   * into the CCPARAMS_DESC macro and we need it for the Nid_cell variable ...
   */
ChenWeiTai's avatar
ChenWeiTai committed
101 102 103
  char      *frame_type, *DL_prefix_type, *UL_prefix_type, *SIB1_frequencyOffsetSSB,
            *DL_SCS_SubcarrierSpacing, *DL_BWP_SubcarrierSpacing, *DL_BWP_prefix_type,
            *UL_frequencyShift7p5khz, *UL_SCS_SubcarrierSpacing, *UL_BWP_SubcarrierSpacing,
104
            *UL_BWP_prefix_type, *UL_timeAlignmentTimerCommon, 
ChenWeiTai's avatar
ChenWeiTai committed
105
            *ServingCellConfigCommon_n_TimingAdvanceOffset,
ChenWeiTai's avatar
ChenWeiTai committed
106 107 108 109 110 111 112 113 114 115 116 117 118
            *NIA_SubcarrierSpacing, *referenceSubcarrierSpacing, *dl_UL_TransmissionPeriodicity,
            *rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,
            *rach_groupBconfigured, *rach_messagePowerOffsetGroupB, 
            *prach_RootSequenceIndex_choice, *prach_msg1_SubcarrierSpacing,
            *restrictedSetConfig, *msg3_transformPrecoding, *prach_msg1_FDM,
            *powerRampingStep, *groupHoppingEnabledTransformPrecoding,
            *PUSCH_TimeDomainResourceAllocation_mappingType, *pucch_GroupHopping,
            *PDSCH_TimeDomainResourceAllocation_mappingType, *RateMatchPattern_patternType,
            *symbolsInResourceBlock, *RateMatchPattern_subcarrierSpacing, *RateMatchPattern_mode,
            *PDCCH_cce_REG_MappingType, *PDCCH_precoderGranularity,
            *tci_PresentInDCI, *SearchSpace_monitoringSlotPeriodicityAndOffset_choice,
            *SearchSpace_searchSpaceType, *ue_Specific__dci_Formats,
            *RateMatchPatternLTE_CRS_subframeAllocation_choice;
119

120
  uint64_t  downlink_frequency, ServingCellConfigCommon_ssb_PositionsInBurst_PR;
121

122
  int32_t   nr_band, uplink_frequency_offset, N_RB_DL, nb_antenna_ports,
123 124
            MIB_subCarrierSpacingCommon, MIB_ssb_SubcarrierOffset, MIB_dmrs_TypeA_Position,
            pdcch_ConfigSIB1, SIB1_ssb_PeriodicityServingCell, SIB1_ss_PBCH_BlockPower,
125 126
            absoluteFrequencySSB, DL_FreqBandIndicatorNR,
            DL_absoluteFrequencyPointA, DL_offsetToCarrier,
127 128
            DL_carrierBandwidth, DL_locationAndBandwidth, UL_FreqBandIndicatorNR,
            UL_absoluteFrequencyPointA, UL_additionalSpectrumEmission, UL_p_Max,
129
            UL_offsetToCarrier, UL_carrierBandwidth,
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
            UL_locationAndBandwidth, ServingCellConfigCommon_ssb_periodicityServingCell,
            ServingCellConfigCommon_dmrs_TypeA_Position, ServingCellConfigCommon_ss_PBCH_BlockPower,
            nrofDownlinkSlots, nrofDownlinkSymbols, nrofUplinkSlots, nrofUplinkSymbols,
            rach_totalNumberOfRA_Preambles, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth,
            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth,
            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf,
            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one,
            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two,
            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four,
            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight,
            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen,
            rach_ra_Msg3SizeGroupA, rach_numberOfRA_PreamblesGroupA, rach_ra_ContentionResolutionTimer,
            rsrp_ThresholdSSB, rsrp_ThresholdSSB_SUL, prach_RootSequenceIndex_l839,
            prach_RootSequenceIndex_l139, prach_ConfigurationIndex, prach_msg1_FrequencyStart,
            zeroCorrelationZoneConfig, preambleReceivedTargetPower, preambleTransMax,
            ra_ResponseWindow, msg3_DeltaPreamble, p0_NominalWithGrant,
146 147 148
            PUSCH_TimeDomainResourceAllocation_k2,
            PUSCH_TimeDomainResourceAllocation_startSymbolAndLength,
            pucch_ResourceCommon, hoppingId, p0_nominal, PDSCH_TimeDomainResourceAllocation_k0,
ChenWeiTai's avatar
ChenWeiTai committed
149
            PDSCH_TimeDomainResourceAllocation_startSymbolAndLength,
150
            rateMatchPatternId, periodicityAndPattern, RateMatchPattern_controlResourceSet,
151
            controlResourceSetZero, searchSpaceZero,
152
            searchSpaceSIB1, searchSpaceOtherSystemInformation, pagingSearchSpace,
153
            ra_SearchSpace, PDCCH_common_controlResourceSetId,
154
            PDCCH_common_ControlResourceSet_duration, PDCCH_reg_BundleSize, PDCCH_interleaverSize,
155 156 157 158
            PDCCH_shiftIndex, PDCCH_TCI_StateId, PDCCH_DMRS_ScramblingID,
            SearchSpaceId, commonSearchSpaces_controlResourceSetId,
            SearchSpace_monitoringSlotPeriodicityAndOffset_value,
            SearchSpace_duration,
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
            SearchSpace_nrofCandidates_aggregationLevel1,
            SearchSpace_nrofCandidates_aggregationLevel2,
            SearchSpace_nrofCandidates_aggregationLevel4,
            SearchSpace_nrofCandidates_aggregationLevel8,
            SearchSpace_nrofCandidates_aggregationLevel16,
            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1,
            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2,
            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4,
            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8,
            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16,
            Common_dci_Format2_3_monitoringPeriodicity,
            Common_dci_Format2_3_nrofPDCCH_Candidates,
            RateMatchPatternLTE_CRS_carrierFreqDL,
            RateMatchPatternLTE_CRS_carrierBandwidthDL,
            RateMatchPatternLTE_CRS_nrofCRS_Ports,
            RateMatchPatternLTE_CRS_v_Shift,
            RateMatchPatternLTE_CRS_radioframeAllocationPeriod,
            RateMatchPatternLTE_CRS_radioframeAllocationOffset
            ;

  /* get number of gNBs */
  paramdef_t GNBSParams[] = GNBSPARAMS_DESC;
  config_get(GNBSParams, sizeof(GNBSParams)/sizeof(paramdef_t), NULL);
  num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt;

  /* for gNB ID */
  paramdef_t GNBParams[]  = GNBPARAMS_DESC;
  paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST, NULL, 0};

  /* for Nid_cell */
  checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK;
  paramdef_t CCsParams[] = NRCCPARAMS_DESC;
  paramlist_def_t CCsParamList = {GNB_CONFIG_STRING_COMPONENT_CARRIERS, NULL, 0};
  /* map parameter checking array instances to parameter definition array instances */
  for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) {
    CCsParams[I].chkPptr = &(config_check_CCparams[I]);
  }

  paramdef_t flexranParams[] = FLEXRANPARAMS_DESC;
  config_get(flexranParams, sizeof(flexranParams)/sizeof(paramdef_t), CONFIG_STRING_NETWORK_CONTROLLER_CONFIG);

  if (!RC.flexran) {
    RC.flexran = calloc(num_gnbs, sizeof(flexran_agent_info_t*));
    AssertFatal(RC.flexran,
                "can't ALLOCATE %zu Bytes for %d flexran agent info with size %zu\n",
                num_gnbs * sizeof(flexran_agent_info_t*),
                num_gnbs, sizeof(flexran_agent_info_t*));
  }

  for (i = 0; i < num_gnbs; i++) {
    RC.flexran[i] = calloc(1, sizeof(flexran_agent_info_t));
    AssertFatal(RC.flexran[i],
                "can't ALLOCATE %zu Bytes for flexran agent info (iteration %d/%d)\n",
                sizeof(flexran_agent_info_t), i + 1, num_gnbs);
    /* if config says "yes", enable Agent, in all other cases it's like "no" */
    RC.flexran[i]->enabled          = strcasecmp(*(flexranParams[FLEXRAN_ENABLED].strptr), "yes") == 0;
    /* if not enabled, simply skip the rest, it is not needed anyway */
    if (!RC.flexran[i]->enabled)
      continue;
    RC.flexran[i]->interface_name   = strdup(*(flexranParams[FLEXRAN_INTERFACE_NAME_IDX].strptr));
    //inet_ntop(AF_INET, &(enb_properties->properties[mod_id]->flexran_agent_ipv4_address), in_ip, INET_ADDRSTRLEN);
    RC.flexran[i]->remote_ipv4_addr = strdup(*(flexranParams[FLEXRAN_IPV4_ADDRESS_IDX].strptr));
    RC.flexran[i]->remote_port      = *(flexranParams[FLEXRAN_PORT_IDX].uptr);
    RC.flexran[i]->cache_name       = strdup(*(flexranParams[FLEXRAN_CACHE_IDX].strptr));
    RC.flexran[i]->node_ctrl_state  = strcasecmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0 ? ENB_WAIT : ENB_NORMAL_OPERATION;

    config_getlist(&GNBParamList, GNBParams, sizeof(GNBParams)/sizeof(paramdef_t),NULL);
    /* gNB ID from configuration, as read in by RCconfig_RRC() */
    if (!GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr) {
      // Calculate a default gNB ID
# if defined(ENABLE_USE_MME)
      gnb_id = i + (s1ap_generate_eNB_id () & 0xFFFF8);
# else
      gnb_id = i;
# endif
    } else {
        gnb_id = *(GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr);
    }

    /* cell ID */
    sprintf(aprefix, "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, i);
    config_getlist(&CCsParamList, NULL, 0, aprefix);
    if (CCsParamList.numelt > 0) {
      sprintf(aprefix, "%s.[%i].%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, i, GNB_CONFIG_STRING_COMPONENT_CARRIERS, 0);
      config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix);
      Nid_cell_tr = (uint16_t) Nid_cell;
    }

    RC.flexran[i]->mod_id   = i;
    RC.flexran[i]->agent_id = (((uint64_t)i) << 48) | (((uint64_t)gnb_id) << 16) | ((uint64_t)Nid_cell_tr);

    /* assume for the moment the monolithic case, i.e. agent can provide
     * information for all layers */
    RC.flexran[i]->capability_mask = FLEXRAN_CAP_LOPHY | FLEXRAN_CAP_HIPHY
                                   | FLEXRAN_CAP_LOMAC | FLEXRAN_CAP_HIMAC
                                   | FLEXRAN_CAP_RLC   | FLEXRAN_CAP_PDCP
                                   | FLEXRAN_CAP_SDAP  | FLEXRAN_CAP_RRC;
  }
}

259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
void RCconfig_NR_L1(void) {
  int               i,j;
  paramdef_t L1_Params[] = L1PARAMS_DESC;
  paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0};


  if (RC.gNB == NULL) {
    RC.gNB                       = (PHY_VARS_gNB ***)malloc((1+NUMBER_OF_gNB_MAX)*sizeof(PHY_VARS_gNB**));
    LOG_I(NR_PHY,"RC.gNB = %p\n",RC.gNB);
    memset(RC.gNB,0,(1+NUMBER_OF_gNB_MAX)*sizeof(PHY_VARS_gNB**));
    RC.nb_nr_L1_CC = malloc((1+RC.nb_nr_L1_inst)*sizeof(int));
  }

  config_getlist( &L1_ParamList,L1_Params,sizeof(L1_Params)/sizeof(paramdef_t), NULL);

  if (L1_ParamList.numelt > 0) {

    for (j = 0; j < RC.nb_nr_L1_inst; j++) {
      RC.nb_nr_L1_CC[j] = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr);

      if (RC.gNB[j] == NULL) {
        RC.gNB[j]                       = (PHY_VARS_gNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_gNB*));
281
        LOG_I(NR_PHY,"RC.gNB[%d] = %p\n",j,RC.gNB[j]);
282 283 284 285 286 287 288 289 290 291 292 293 294 295
        memset(RC.gNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_gNB*));
      }

      for (i=0;i<RC.nb_nr_L1_CC[j];i++) {
        if (RC.gNB[j][i] == NULL) {
          RC.gNB[j][i] = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB));
          memset((void*)RC.gNB[j][i],0,sizeof(PHY_VARS_gNB));
          LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.gNB[j][i]);
          RC.gNB[j][i]->Mod_id  = j;
          RC.gNB[j][i]->CC_id   = i;
        }
      }

      if(strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
Wang Tsu-Han's avatar
Wang Tsu-Han committed
296
        //sf_ahead = 2; // Need 4 subframe gap between RX and TX
297 298 299 300 301 302 303 304 305 306
      }else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) {
        RC.gNB[j][0]->eth_params_n.local_if_name            = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr));
        RC.gNB[j][0]->eth_params_n.my_addr                  = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr));
        RC.gNB[j][0]->eth_params_n.remote_addr              = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr));
        RC.gNB[j][0]->eth_params_n.my_portc                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr);
        RC.gNB[j][0]->eth_params_n.remote_portc             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr);
        RC.gNB[j][0]->eth_params_n.my_portd                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr);
        RC.gNB[j][0]->eth_params_n.remote_portd             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr);
        RC.gNB[j][0]->eth_params_n.transp_preference        = ETH_UDP_MODE;

Wang Tsu-Han's avatar
Wang Tsu-Han committed
307
        //sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368

        RC.nb_nr_macrlc_inst = 1;  // This is used by mac_top_init_gNB()

        // This is used by init_gNB_afterRU()
        RC.nb_nr_CC = (int *)malloc((1+RC.nb_nr_inst)*sizeof(int));
        RC.nb_nr_CC[0]=1;

        RC.nb_nr_inst =1; // DJP - feptx_prec uses num_gNB but phy_init_RU uses nb_nr_inst

        LOG_I(PHY,"%s() NFAPI PNF mode - RC.nb_nr_inst=1 this is because phy_init_RU() uses that to index and not RC.num_gNB - why the 2 similar variables?\n", __FUNCTION__);
        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_nfapi_pnf(RC.gNB[j][0]->eth_params_n.remote_addr, RC.gNB[j][0]->eth_params_n.remote_portc, RC.gNB[j][0]->eth_params_n.my_addr, RC.gNB[j][0]->eth_params_n.my_portd, RC.gNB[j][0]->eth_params_n     .remote_portd);
      }else { // other midhaul
      } 
    }// for (j = 0; j < RC.nb_nr_L1_inst; j++)
    printf("Initializing northbound interface for L1\n");
    l1_north_init_gNB();
  }else{
    LOG_I(PHY,"No " CONFIG_STRING_L1_LIST " configuration found");    

    // DJP need to create some structures for VNF

    j = 0;

    RC.nb_nr_L1_CC = malloc((1+RC.nb_nr_L1_inst)*sizeof(int)); // DJP - 1 lot then???

    RC.nb_nr_L1_CC[j]=1; // DJP - hmmm

    if (RC.gNB[j] == NULL) {
      RC.gNB[j]                       = (PHY_VARS_gNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_gNB**));
      LOG_I(PHY,"RC.gNB[%d] = %p\n",j,RC.gNB[j]);
      memset(RC.gNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_gNB***));
    }

    for (i=0;i<RC.nb_nr_L1_CC[j];i++) {
      if (RC.gNB[j][i] == NULL) {
        RC.gNB[j][i] = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB));
        memset((void*)RC.gNB[j][i],0,sizeof(PHY_VARS_gNB));
        LOG_I(PHY,"RC.gNB[%d][%d] = %p\n",j,i,RC.gNB[j][i]);
        RC.gNB[j][i]->Mod_id  = j;
        RC.gNB[j][i]->CC_id   = i;
      }
    } // END for (i=0;i<RC.nb_nr_L1_CC[j];i++)
  
  }
}

void RCconfig_nr_macrlc() {
  int               j;

  paramdef_t MacRLC_Params[] = MACRLCPARAMS_DESC;
  paramlist_def_t MacRLC_ParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0};

  config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL);    
  
  if ( MacRLC_ParamList.numelt > 0) {

ChenWeiTai's avatar
ChenWeiTai committed
369 370 371
    RC.nb_nr_macrlc_inst=MacRLC_ParamList.numelt; 
    mac_top_init_gNB();   
    RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int));
372

ChenWeiTai's avatar
ChenWeiTai committed
373 374 375 376
    for (j=0;j<RC.nb_nr_macrlc_inst;j++) {
      RC.nb_nr_mac_CC[j] = *(MacRLC_ParamList.paramarray[j][MACRLC_CC_IDX].iptr);
      //RC.nrmac[j]->phy_test = *(MacRLC_ParamList.paramarray[j][MACRLC_PHY_TEST_IDX].iptr);
      //printf("PHY_TEST = %d,%d\n", RC.nrmac[j]->phy_test, j);
377 378 379 380

      if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) {
  // check number of instances is same as RRC/PDCP
  
ChenWeiTai's avatar
ChenWeiTai committed
381 382 383 384 385 386 387 388 389 390 391
      }else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "cudu") == 0) {
        RC.nrmac[j]->eth_params_n.local_if_name            = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_IF_NAME_IDX].strptr));
        RC.nrmac[j]->eth_params_n.my_addr                  = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_ADDRESS_IDX].strptr));
        RC.nrmac[j]->eth_params_n.remote_addr              = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_ADDRESS_IDX].strptr));
        RC.nrmac[j]->eth_params_n.my_portc                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTC_IDX].iptr);
        RC.nrmac[j]->eth_params_n.remote_portc             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTC_IDX].iptr);
        RC.nrmac[j]->eth_params_n.my_portd                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTD_IDX].iptr);
        RC.nrmac[j]->eth_params_n.remote_portd             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTD_IDX].iptr);;
        RC.nrmac[j]->eth_params_n.transp_preference        = ETH_UDP_MODE;
      }else { // other midhaul
        AssertFatal(1==0,"MACRLC %d: %s unknown northbound midhaul\n",j, *(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr));
392 393 394 395
      } 

      if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_L1") == 0) {

ChenWeiTai's avatar
ChenWeiTai committed
396 397 398 399 400 401 402 403 404
      }else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "nfapi") == 0) {
        RC.nrmac[j]->eth_params_s.local_if_name            = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_IF_NAME_IDX].strptr));
        RC.nrmac[j]->eth_params_s.my_addr                  = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_ADDRESS_IDX].strptr));
        RC.nrmac[j]->eth_params_s.remote_addr              = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_ADDRESS_IDX].strptr));
        RC.nrmac[j]->eth_params_s.my_portc                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTC_IDX].iptr);
        RC.nrmac[j]->eth_params_s.remote_portc             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTC_IDX].iptr);
        RC.nrmac[j]->eth_params_s.my_portd                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTD_IDX].iptr);
        RC.nrmac[j]->eth_params_s.remote_portd             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTD_IDX].iptr);
        RC.nrmac[j]->eth_params_s.transp_preference        = ETH_UDP_MODE;
405

Wang Tsu-Han's avatar
Wang Tsu-Han committed
406
        //sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2
407 408

        printf("**************** vnf_port:%d\n", RC.mac[j]->eth_params_s.my_portc);
ChenWeiTai's avatar
ChenWeiTai committed
409 410 411 412
        configure_nfapi_vnf(RC.nrmac[j]->eth_params_s.my_addr, RC.nrmac[j]->eth_params_s.my_portc);
        printf("**************** RETURNED FROM configure_nfapi_vnf() vnf_port:%d\n", RC.nrmac[j]->eth_params_s.my_portc);
      }else { // other midhaul
        AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr));
413
      } 
ChenWeiTai's avatar
ChenWeiTai committed
414 415 416
    }//  for (j=0;j<RC.nb_nr_macrlc_inst;j++)
  }else {// MacRLC_ParamList.numelt > 0
    AssertFatal (0,"No " CONFIG_STRING_MACRLC_LIST " configuration found");     
417
  }
ChenWeiTai's avatar
ChenWeiTai committed
418

419
}
420

ChenWeiTai's avatar
ChenWeiTai committed
421
void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
422

ChenWeiTai's avatar
ChenWeiTai committed
423 424 425 426 427 428 429 430 431 432
  int                    num_gnbs                                                      = 0;
  int                    num_component_carriers                                        = 0;
  int                    j,k                                                           = 0;
  int32_t                gnb_id                                                        = 0;

  int                    nb_cc                                                         = 0;
  char*                  frame_type                                                    = NULL;
  char*                  DL_prefix_type                                                = NULL;
  char*                  UL_prefix_type                                                = NULL;

433 434
  int32_t                nr_band                                                       = 0;
  uint64_t               downlink_frequency                                            = 0;
ChenWeiTai's avatar
ChenWeiTai committed
435 436 437 438
  int32_t                uplink_frequency_offset                                       = 0;
  int32_t                Nid_cell                                                      = 0;
  int32_t                N_RB_DL                                                       = 0;
  int32_t                nb_antenna_ports                                              = 0;
439 440

  ///NR
ChenWeiTai's avatar
ChenWeiTai committed
441 442
  //MIB
  int32_t                MIB_subCarrierSpacingCommon                                   = 0;
443
  int32_t                MIB_ssb_SubcarrierOffset                                      = 0;
ChenWeiTai's avatar
ChenWeiTai committed
444
  int32_t                MIB_dmrs_TypeA_Position                                       = 0;
445
  int32_t                pdcch_ConfigSIB1                                              = 0;
ChenWeiTai's avatar
ChenWeiTai committed
446 447

  //SIB1
448
  char*                  SIB1_frequencyOffsetSSB                                       = NULL; 
ChenWeiTai's avatar
ChenWeiTai committed
449 450
  int32_t                SIB1_ssb_PeriodicityServingCell                               = 0;
  int32_t                SIB1_ss_PBCH_BlockPower                                       = 0;
451
  //DownlinkConfigCommon
452
  //NR FrequencyInfoDL
ChenWeiTai's avatar
ChenWeiTai committed
453 454 455
  int32_t                absoluteFrequencySSB                                          = 0;
  int32_t                DL_FreqBandIndicatorNR                                        = 0;
  int32_t                DL_absoluteFrequencyPointA                                    = 0;
456 457

  //NR DL SCS-SpecificCarrier
458 459 460
  int32_t                DL_offsetToCarrier                                            = 0;
  char*                  DL_SCS_SubcarrierSpacing                                      = 0;
  int32_t                DL_carrierBandwidth                                           = 0;
461 462

  // NR BWP-DownlinkCommon
463 464
  int32_t                DL_locationAndBandwidth                                       = 0;
  char*                  DL_BWP_SubcarrierSpacing                                      = 0;
465
  char*                  DL_BWP_prefix_type                                            = NULL;  
466
  
467
  //NR FrequencyInfoUL
ChenWeiTai's avatar
ChenWeiTai committed
468 469
  int32_t                UL_FreqBandIndicatorNR                                        = 0;
  int32_t                UL_absoluteFrequencyPointA                                    = 0;
470
  int32_t                UL_additionalSpectrumEmission                                 = 0;
471
  int32_t                UL_p_Max                                                      = 0;
472
  char*                  UL_frequencyShift7p5khz                                       = 0;
473 474

  //NR UL SCS-SpecificCarrier
475 476 477
  int32_t                UL_offsetToCarrier                                            = 0;
  char*                  UL_SCS_SubcarrierSpacing                                      = 0;
  int32_t                UL_carrierBandwidth                                           = 0;
478 479

  // NR BWP-UplinkCommon
480 481
  int32_t                UL_locationAndBandwidth                                       = 0;
  char*                  UL_BWP_SubcarrierSpacing                                      = 0;
482
  char*                  UL_BWP_prefix_type                                            = NULL; 
483
  char*                  UL_timeAlignmentTimerCommon                                   = 0;
484
  
ChenWeiTai's avatar
ChenWeiTai committed
485
  char*                  ServingCellConfigCommon_n_TimingAdvanceOffset                 = 0;
486
  uint64_t               ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0;
ChenWeiTai's avatar
ChenWeiTai committed
487 488
  int32_t                ServingCellConfigCommon_ssb_periodicityServingCell            = 0;
  int32_t                ServingCellConfigCommon_dmrs_TypeA_Position                   = 0;
489
  char*                  NIA_SubcarrierSpacing                                         = 0; 
ChenWeiTai's avatar
ChenWeiTai committed
490
  int32_t                ServingCellConfigCommon_ss_PBCH_BlockPower                    = 0;
491 492

  //NR TDD-UL-DL-ConfigCommon
493 494
  char*                  referenceSubcarrierSpacing                                    = 0;
  char*                  dl_UL_TransmissionPeriodicity                                 = 0;
ChenWeiTai's avatar
ChenWeiTai committed
495 496 497 498
  int32_t                nrofDownlinkSlots                                             = 0;
  int32_t                nrofDownlinkSymbols                                           = 0;
  int32_t                nrofUplinkSlots                                               = 0;
  int32_t                nrofUplinkSymbols                                             = 0;
499 500

  //NR RACH-ConfigCommon
ChenWeiTai's avatar
ChenWeiTai committed
501
  int32_t                rach_totalNumberOfRA_Preambles                                = 0;
502
  char*                  rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = 0;
ChenWeiTai's avatar
ChenWeiTai committed
503 504 505 506 507
  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 0;
  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 0;
  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 0;
  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 0;
  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 0;
508 509 510
  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 0;
  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 0;
  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 0;
ChenWeiTai's avatar
ChenWeiTai committed
511 512
  char*                  rach_groupBconfigured                                         = NULL;
  int32_t                rach_ra_Msg3SizeGroupA                                        = 0;
513
  char*                  rach_messagePowerOffsetGroupB                                 = NULL;
ChenWeiTai's avatar
ChenWeiTai committed
514 515 516 517
  int32_t                rach_numberOfRA_PreamblesGroupA                               = 0;
  int32_t                rach_ra_ContentionResolutionTimer                             = 0;
  int32_t                rsrp_ThresholdSSB                                             = 0;
  int32_t                rsrp_ThresholdSSB_SUL                                         = 0;
518 519 520 521 522 523
  char*                  prach_RootSequenceIndex_choice                                = NULL;
  int32_t                prach_RootSequenceIndex_l839                                  = 0;
  int32_t                prach_RootSequenceIndex_l139                                  = 0;
  char*                  prach_msg1_SubcarrierSpacing                                  = NULL;
  char*                  restrictedSetConfig                                           = NULL;
  char*                  msg3_transformPrecoding                                       = NULL;
524 525 526
  //ssb-perRACH-OccasionAndCB-PreamblesPerSSB not sure

  //NR RACH-ConfigGeneric
ChenWeiTai's avatar
ChenWeiTai committed
527
  int32_t                prach_ConfigurationIndex                                      = 0;
528
  char*                  prach_msg1_FDM                                                = NULL;
ChenWeiTai's avatar
ChenWeiTai committed
529 530 531 532
  int32_t                prach_msg1_FrequencyStart                                     = 0;
  int32_t                zeroCorrelationZoneConfig                                     = 0;
  int32_t                preambleReceivedTargetPower                                   = 0;
  int32_t                preambleTransMax                                              = 0;
533
  char*                  powerRampingStep                                              = NULL;
ChenWeiTai's avatar
ChenWeiTai committed
534
  int32_t                ra_ResponseWindow                                             = 0;
535 536

  //PUSCH-ConfigCommon
ChenWeiTai's avatar
ChenWeiTai committed
537 538 539
  char*                  groupHoppingEnabledTransformPrecoding                         = NULL;
  int32_t                msg3_DeltaPreamble                                            = 0;
  int32_t                p0_NominalWithGrant                                           = 0;
540 541

  ///PUSCH-TimeDomainResourceAllocation
ChenWeiTai's avatar
ChenWeiTai committed
542
  int32_t                PUSCH_TimeDomainResourceAllocation_k2                         = 0;
543
  char*                  PUSCH_TimeDomainResourceAllocation_mappingType                = NULL;
544
  int32_t                PUSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
545 546

  //PUCCH-ConfigCommon
547
  int32_t                pucch_ResourceCommon                                          = 0;
548
  char*                  pucch_GroupHopping                                            = NULL;
549
  int32_t                hoppingId                                                     = 0;
ChenWeiTai's avatar
ChenWeiTai committed
550
  int32_t                p0_nominal                                                    = 0;
551 552 553

  //PDSCH-ConfigCOmmon
  //PDSCH-TimeDomainResourceAllocation
ChenWeiTai's avatar
ChenWeiTai committed
554
  int32_t                PDSCH_TimeDomainResourceAllocation_k0                         = 0;
555
  char*                  PDSCH_TimeDomainResourceAllocation_mappingType                = NULL;
556
  int32_t                PDSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
557 558

  //RateMatchPattern  is used to configure one rate matching pattern for PDSCH
ChenWeiTai's avatar
ChenWeiTai committed
559
  int32_t                rateMatchPatternId                                            = 0;
560 561
  char*                  RateMatchPattern_patternType                                  = NULL;
  char*                  symbolsInResourceBlock                                        = NULL;
ChenWeiTai's avatar
ChenWeiTai committed
562 563
  int32_t                periodicityAndPattern                                         = 0;
  int32_t                RateMatchPattern_controlResourceSet                           = 0;
564 565
  char*                  RateMatchPattern_subcarrierSpacing                            = NULL;
  char*                  RateMatchPattern_mode                                         = NULL;
566 567

  //PDCCH-ConfigCommon
568 569
  int32_t                controlResourceSetZero                                        = 0;
  int32_t                searchSpaceZero                                               = 0;
ChenWeiTai's avatar
ChenWeiTai committed
570 571 572 573
  int32_t                searchSpaceSIB1                                               = 0;
  int32_t                searchSpaceOtherSystemInformation                             = 0;
  int32_t                pagingSearchSpace                                             = 0;
  int32_t                ra_SearchSpace                                                = 0;
574
  
575
  //NR PDCCH-ConfigCommon commonControlResourcesSets
ChenWeiTai's avatar
ChenWeiTai committed
576 577
  int32_t                PDCCH_common_controlResourceSetId                             = 0;
  int32_t                PDCCH_common_ControlResourceSet_duration                      = 0;
578
  char*                  PDCCH_cce_REG_MappingType                                     = NULL;
ChenWeiTai's avatar
ChenWeiTai committed
579 580 581
  int32_t                PDCCH_reg_BundleSize                                          = 0;
  int32_t                PDCCH_interleaverSize                                         = 0;
  int32_t                PDCCH_shiftIndex                                              = 0;  
582
  char*                  PDCCH_precoderGranularity                                     = NULL;
583
  int32_t                PDCCH_TCI_StateId                                             = 0;
ChenWeiTai's avatar
ChenWeiTai committed
584
  char*                  tci_PresentInDCI                                              = NULL;
585
  int32_t                PDCCH_DMRS_ScramblingID                                       = 0;
586 587

  //NR PDCCH-ConfigCommon commonSearchSpaces
ChenWeiTai's avatar
ChenWeiTai committed
588 589
  int32_t                SearchSpaceId                                                 = 0;
  int32_t                commonSearchSpaces_controlResourceSetId                       = 0;
590
  char*                  SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = NULL;
591 592
  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_value          = 0;
  int32_t                SearchSpace_duration                                          = 0;
ChenWeiTai's avatar
ChenWeiTai committed
593 594 595 596 597
  int32_t                SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
  int32_t                SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
  int32_t                SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
  int32_t                SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
  int32_t                SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
598
  char*                  SearchSpace_searchSpaceType                                   = NULL;
ChenWeiTai's avatar
ChenWeiTai committed
599 600 601 602 603 604 605
  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 0;
  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 0;
  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 0;
  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 0;
  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 0; 
  int32_t                Common_dci_Format2_3_monitoringPeriodicity                    = 0;
  int32_t                Common_dci_Format2_3_nrofPDCCH_Candidates                     = 0;
606
  char*                  ue_Specific__dci_Formats                                      = NULL;
ChenWeiTai's avatar
ChenWeiTai committed
607
  //NR  RateMatchPatternLTE-CRS
608
  int32_t                RateMatchPatternLTE_CRS_carrierFreqDL                         = 0;
ChenWeiTai's avatar
ChenWeiTai committed
609 610 611 612
  int32_t                RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 0;
  int32_t                RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 0;
  int32_t                RateMatchPatternLTE_CRS_v_Shift                               = 0;
  int32_t                RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 0;
613 614
  int32_t                RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
  char*                  RateMatchPatternLTE_CRS_subframeAllocation_choice             = NULL;
ChenWeiTai's avatar
ChenWeiTai committed
615

616

yilmazt's avatar
yilmazt committed
617
  /*int32_t                srb1_timer_poll_retransmit    = 0;
618 619 620 621
  int32_t                srb1_timer_reordering         = 0;
  int32_t                srb1_timer_status_prohibit    = 0;
  int32_t                srb1_poll_pdu                 = 0;
  int32_t                srb1_poll_byte                = 0;
yilmazt's avatar
yilmazt committed
622
  int32_t                srb1_max_retx_threshold       = 0;*/
623

ChenWeiTai's avatar
ChenWeiTai committed
624
  //int32_t             my_int;
625 626

  paramdef_t GNBSParams[] = GNBSPARAMS_DESC;
ChenWeiTai's avatar
ChenWeiTai committed
627
  ////////// Identification parameters
628 629
  paramdef_t GNBParams[]  = GNBPARAMS_DESC;
  paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0};
ChenWeiTai's avatar
ChenWeiTai committed
630
  ////////// Physical parameters
ChenWeiTai's avatar
ChenWeiTai committed
631
  checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK;
632
  paramdef_t CCsParams[] = NRCCPARAMS_DESC;
633 634
  paramlist_def_t CCsParamList = {GNB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0};
  
yilmazt's avatar
yilmazt committed
635
  //paramdef_t SRB1Params[] = SRB1PARAMS_DESC;
636 637

  /* get global parameters, defined outside any section in the config file */
ChenWeiTai's avatar
ChenWeiTai committed
638
 
639 640 641 642
  config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); 
  num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt;
  AssertFatal (i<num_gnbs,"Failed to parse config file no %ith element in %s \n",i, GNB_CONFIG_STRING_ACTIVE_GNBS);

643 644
  /*
  #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
645 646 647 648 649 650 651 652 653 654 655 656 657 658
    if (strcasecmp( *(GNBSParams[GNB_ASN1_VERBOSITY_IDX].strptr), GNB_CONFIG_STRING_ASN1_VERBOSITY_NONE) == 0) {
      asn_debug      = 0;
      asn1_xer_print = 0;
    } else if (strcasecmp( *(GNBSParams[GNB_ASN1_VERBOSITY_IDX].strptr), GNB_CONFIG_STRING_ASN1_VERBOSITY_INFO) == 0) {
      asn_debug      = 1;
      asn1_xer_print = 1;
    } else if (strcasecmp(*(GNBSParams[GNB_ASN1_VERBOSITY_IDX].strptr) , GNB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING) == 0) {
      asn_debug      = 1;
      asn1_xer_print = 2;
    } else {
      asn_debug      = 0;
      asn1_xer_print = 0;
    }
  #endif
659
  */
660 661

  if (num_gnbs>0) {
ChenWeiTai's avatar
ChenWeiTai committed
662
    // Output a list of all gNBs. ////////// Identification parameters
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
    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 defined(ENABLE_USE_MME)
        uint32_t hash;
        hash = s1ap_generate_eNB_id ();
        gnb_id = i + (hash & 0xFFFF8);
      # else
        gnb_id = i;
      # endif
    } else {
        gnb_id = *(GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr);
    }

    printf("NRRRC %d: Southbound Transport %s\n",i,*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr));

    if (strcmp(*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_mac") == 0) {
  
    } else if (strcmp(*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "cudu") == 0) {
      rrc->eth_params_s.local_if_name            = strdup(*(GNBParamList.paramarray[i][GNB_LOCAL_S_IF_NAME_IDX].strptr));
      rrc->eth_params_s.my_addr                  = strdup(*(GNBParamList.paramarray[i][GNB_LOCAL_S_ADDRESS_IDX].strptr));
      rrc->eth_params_s.remote_addr              = strdup(*(GNBParamList.paramarray[i][GNB_REMOTE_S_ADDRESS_IDX].strptr));
      rrc->eth_params_s.my_portc                 = *(GNBParamList.paramarray[i][GNB_LOCAL_S_PORTC_IDX].uptr);
      rrc->eth_params_s.remote_portc             = *(GNBParamList.paramarray[i][GNB_REMOTE_S_PORTC_IDX].uptr);
      rrc->eth_params_s.my_portd                 = *(GNBParamList.paramarray[i][GNB_LOCAL_S_PORTD_IDX].uptr);
      rrc->eth_params_s.remote_portd             = *(GNBParamList.paramarray[i][GNB_REMOTE_S_PORTD_IDX].uptr);
      rrc->eth_params_s.transp_preference        = ETH_UDP_MODE;
    } else { // other midhaul
    }       

    // search if in active list

    for (k=0; k <num_gnbs ; k++) {
      if (strcmp(GNBSParams[GNB_ACTIVE_GNBS_IDX].strlistptr[k], *(GNBParamList.paramarray[i][GNB_GNB_NAME_IDX].strptr) )== 0) {
        
        char gnbpath[MAX_OPTNAME_SIZE + 8];
700
        sprintf(gnbpath,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,k);
701

702 703 704 705 706 707 708
        paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
        paramlist_def_t PLMNParamList = {GNB_CONFIG_STRING_PLMN_LIST, NULL, 0};
        /* map parameter checking array instances to parameter definition array instances */
        checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;

        for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I)
          PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]);
709

710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738
        NRRRC_CONFIGURATION_REQ (msg_p).cell_identity     = gnb_id;
        NRRRC_CONFIGURATION_REQ (msg_p).tac               = *GNBParamList.paramarray[i][GNB_TRACKING_AREA_CODE_IDX].uptr;
        AssertFatal(!GNBParamList.paramarray[i][GNB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr
                    && !GNBParamList.paramarray[i][GNB_MOBILE_NETWORK_CODE_IDX_OLD].strptr,
                    "It seems that you use an old configuration file. Please change the existing\n"
                    "    tracking_area_code  =  \"1\";\n"
                    "    mobile_country_code =  \"208\";\n"
                    "    mobile_network_code =  \"93\";\n"
                    "to\n"
                    "    tracking_area_code  =  1; // no string!!\n"
                    "    plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n");
        config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), gnbpath);

        if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6)
          AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n",
                      PLMNParamList.numelt);

        RRC_CONFIGURATION_REQ(msg_p).num_plmn = PLMNParamList.numelt;

        for (int l = 0; l < PLMNParamList.numelt; ++l) {
	
	  NRRRC_CONFIGURATION_REQ (msg_p).mcc[l]               = *PLMNParamList.paramarray[l][GNB_MOBILE_COUNTRY_CODE_IDX].uptr;
	  NRRRC_CONFIGURATION_REQ (msg_p).mnc[l]               = *PLMNParamList.paramarray[l][GNB_MOBILE_NETWORK_CODE_IDX].uptr;
	  NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length[l]  = *PLMNParamList.paramarray[l][GNB_MNC_DIGIT_LENGTH].u8ptr;
	  AssertFatal((NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length[l] == 2) ||
		      (NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length[l] == 3),"BAD MNC DIGIT LENGTH %d",
		      NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length[l]);
	}
	
739 740 741 742
        // Parse optional physical parameters
        sprintf(gnbpath,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,k),
        config_getlist( &CCsParamList,NULL,0,gnbpath); 
    
743
        LOG_I(NR_RRC,"num component carriers %d \n", num_component_carriers); 
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765

        if ( CCsParamList.numelt> 0) {
          
          char ccspath[MAX_OPTNAME_SIZE*2 + 16];

          for (j = 0; j < CCsParamList.numelt ;j++) {
            
            sprintf(ccspath,"%s.%s.[%i]",gnbpath,GNB_CONFIG_STRING_COMPONENT_CARRIERS,j);
            config_get( CCsParams,sizeof(CCsParams)/sizeof(paramdef_t),ccspath);        
 
            nb_cc++;

            // NRRRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = tdd_config;
            // AssertFatal (tdd_config <= TDD_Config__subframeAssignment_sa6,
            //             "Failed to parse gNB configuration file %s, gnb %d illegal tdd_config %d (should be 0-%d)!",
            //             RC.config_file_name, i, tdd_config, TDD_Config__subframeAssignment_sa6);
        
            // NRRRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = tdd_config_s;
            // AssertFatal (tdd_config_s <= TDD_Config__specialSubframePatterns_ssp8,
            //             "Failed to parse gNB configuration file %s, gnb %d illegal tdd_config_s %d (should be 0-%d)!",
            //             RC.config_file_name, i, tdd_config_s, TDD_Config__specialSubframePatterns_ssp8);

ChenWeiTai's avatar
ChenWeiTai committed
766
            if (!DL_prefix_type){
767
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
ChenWeiTai's avatar
ChenWeiTai committed
768 769 770 771 772
                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
            }else if (strcmp(DL_prefix_type, "NORMAL") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = NORMAL;
            }else if (strcmp(DL_prefix_type, "EXTENDED") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = EXTENDED;
773
            }else {
ChenWeiTai's avatar
ChenWeiTai committed
774 775
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_prefix_type choice: NORMAL or EXTENDED !\n",
                           RC.config_file_name, i, DL_prefix_type);
776 777
            }

ChenWeiTai's avatar
ChenWeiTai committed
778 779 780 781 782 783 784 785 786 787 788 789
            if (!UL_prefix_type){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
                           RC.config_file_name, i, GNB_CONFIG_STRING_UL_PREFIX_TYPE);
            }else if (strcmp(UL_prefix_type, "NORMAL") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = NORMAL;
            }else if (strcmp(UL_prefix_type, "EXTENDED") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = EXTENDED;
            }else {
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_prefix_type choice: NORMAL or EXTENDED !\n",
                           RC.config_file_name, i, UL_prefix_type);
            }            

790 791
            NRRRC_CONFIGURATION_REQ (msg_p).nr_band[j] = nr_band;
            NRRRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint64_t) downlink_frequency;
792 793 794 795 796 797 798 799 800
            NRRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
            NRRRC_CONFIGURATION_REQ (msg_p).Nid_cell[j]= Nid_cell;

            if (Nid_cell>503) {
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
                           RC.config_file_name, i, Nid_cell);
            }
        
            NRRRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= N_RB_DL;
Wang Tsu-Han's avatar
Wang Tsu-Han committed
801 802 803 804
            if(N_RB_DL == 217)      sf_ahead = 2;
            else if(N_RB_DL == 106) sf_ahead = 4;
            else                    AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for N_RB_DL choice: 106, 217 !\n",
                                                 RC.config_file_name, i, N_RB_DL);
805 806
            
            /*
807 808 809 810
            if ((N_RB_DL!=6) && (N_RB_DL!=15) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=75) && (N_RB_DL!=100)) {
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
                           RC.config_file_name, i, N_RB_DL);
            }
811
            */
812 813 814 815 816 817 818 819 820 821
        
            if (strcmp(frame_type, "FDD") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).frame_type[j] = FDD;
            }else  if (strcmp(frame_type, "TDD") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).frame_type[j] = TDD;
            }else {
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
                           RC.config_file_name, i, frame_type);
            }

822 823 824 825 826 827 828 829 830 831 832 833 834
            if (!DL_prefix_type){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
            }else if (strcmp(DL_prefix_type, "NORMAL") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = NORMAL;
            }else  if (strcmp(DL_prefix_type, "EXTENDED") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = EXTENDED;
            }else {
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_prefix_type choice: NORMAL or EXTENDED !\n",
                           RC.config_file_name, i, DL_prefix_type);
            }

            if (!UL_prefix_type){
835
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
836 837 838 839 840
                           RC.config_file_name, i, GNB_CONFIG_STRING_UL_PREFIX_TYPE);
            }else if (strcmp(UL_prefix_type, "NORMAL") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = NORMAL;
            }else  if (strcmp(UL_prefix_type, "EXTENDED") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = EXTENDED;
841
            }else {
842 843
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_prefix_type choice: NORMAL or EXTENDED !\n",
                           RC.config_file_name, i, UL_prefix_type);
844 845
            }

846 847
            NRRRC_CONFIGURATION_REQ (msg_p).nr_band[j] = nr_band;
            NRRRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint64_t) downlink_frequency;
848 849 850
            NRRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
        
            if (config_check_band_frequencies(j,
851
              NRRRC_CONFIGURATION_REQ (msg_p).nr_band[j],
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867
              NRRRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j],
              NRRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j],
              NRRRC_CONFIGURATION_REQ (msg_p).frame_type[j])) {
               AssertFatal(0, "error calling enb_check_band_frequencies\n");
            }

            if ((nb_antenna_ports <1) || (nb_antenna_ports > 2)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, enb %d unknown value \"%d\" for nb_antenna_ports choice: 1..2 !\n",
                           RC.config_file_name, i, nb_antenna_ports);
            }
            NRRRC_CONFIGURATION_REQ (msg_p).nb_antenna_ports[j] = nb_antenna_ports;


            ////////////////////////////////////////////////////////////////////////////////
            //---------------------------NR--------Configuration--------------------------//
            ////////////////////////////////////////////////////////////////////////////////
ChenWeiTai's avatar
ChenWeiTai committed
868 869 870 871 872 873 874
            /////////////////////////////////MIB///////////////////////////////
            NRRRC_CONFIGURATION_REQ (msg_p).MIB_subCarrierSpacingCommon[j] = MIB_subCarrierSpacingCommon;
            if ((MIB_subCarrierSpacingCommon !=15) && (MIB_subCarrierSpacingCommon !=30) && (MIB_subCarrierSpacingCommon !=60) && (MIB_subCarrierSpacingCommon !=120)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for MIB_subCarrierSpacingCommon choice: 15,30,60,120 !\n",
                           RC.config_file_name, i, MIB_subCarrierSpacingCommon);
            }

ChenWeiTai's avatar
ChenWeiTai committed
875 876 877 878 879 880
            NRRRC_CONFIGURATION_REQ (msg_p).MIB_ssb_SubcarrierOffset[j] = MIB_ssb_SubcarrierOffset;
            if ((MIB_ssb_SubcarrierOffset <0) || (MIB_ssb_SubcarrierOffset > 15)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for MIB_ssb_SubcarrierOffset choice: 1..23 !\n",
                           RC.config_file_name, i, MIB_ssb_SubcarrierOffset);
            }

ChenWeiTai's avatar
ChenWeiTai committed
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899
            NRRRC_CONFIGURATION_REQ (msg_p).MIB_dmrs_TypeA_Position[j] = MIB_dmrs_TypeA_Position;
            if ((MIB_dmrs_TypeA_Position !=2) && (MIB_dmrs_TypeA_Position !=3)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for MIB_dmrs_TypeA_Position choice:2,3 !\n",
                           RC.config_file_name, i, MIB_dmrs_TypeA_Position);
            }          

            NRRRC_CONFIGURATION_REQ (msg_p).pdcch_ConfigSIB1[j] = pdcch_ConfigSIB1;
            if ((pdcch_ConfigSIB1 <0) || (pdcch_ConfigSIB1 > 255)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for pdcch_ConfigSIB1 choice: 0..3279165 !\n",
                           RC.config_file_name, i, pdcch_ConfigSIB1);
            }
            
            ////////////////////////////////SIB1//////////////////////////////

            if (strcmp(SIB1_frequencyOffsetSSB , "khz-5") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).SIB1_frequencyOffsetSSB[j] = -5;                    
            }else if (strcmp(SIB1_frequencyOffsetSSB , "khz5") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).SIB1_frequencyOffsetSSB[j] = 5;
            }else {
ChenWeiTai's avatar
ChenWeiTai committed
900
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for SIB1_frequencyOffsetSSB !\n",
ChenWeiTai's avatar
ChenWeiTai committed
901 902 903 904 905 906 907 908 909
                           RC.config_file_name, i, SIB1_frequencyOffsetSSB);
            }

            NRRRC_CONFIGURATION_REQ (msg_p).SIB1_ssb_PeriodicityServingCell[j] = SIB1_ssb_PeriodicityServingCell;
            if ((SIB1_ssb_PeriodicityServingCell !=5)  && 
                (SIB1_ssb_PeriodicityServingCell !=10) && 
                (SIB1_ssb_PeriodicityServingCell !=20) && 
                (SIB1_ssb_PeriodicityServingCell !=40) &&
                (SIB1_ssb_PeriodicityServingCell !=80) &&
910
                (SIB1_ssb_PeriodicityServingCell !=160)  ){
ChenWeiTai's avatar
ChenWeiTai committed
911 912 913 914 915 916 917 918 919
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SIB1_ssb_PeriodicityServingCell choice: 5,10,20,40,80,160 !\n",
                           RC.config_file_name, i, SIB1_ssb_PeriodicityServingCell);
            }            

            NRRRC_CONFIGURATION_REQ (msg_p).SIB1_ss_PBCH_BlockPower[j] = SIB1_ss_PBCH_BlockPower;
            if ((SIB1_ss_PBCH_BlockPower < -60) || (SIB1_ss_PBCH_BlockPower > 50)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SIB1_ss_PBCH_BlockPower choice: -60..50 !\n",
              RC.config_file_name, i, SIB1_ss_PBCH_BlockPower);
            }
920 921 922 923

            ////////////////////////////////NR FrequencyInfoDL//////////////////////////////
            NRRRC_CONFIGURATION_REQ (msg_p).absoluteFrequencySSB[j] = absoluteFrequencySSB;
            if ((absoluteFrequencySSB <0) || (absoluteFrequencySSB > 3279165)){
ChenWeiTai's avatar
ChenWeiTai committed
924
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for absoluteFrequencySSB choice: 0..3279165 !\n",
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947
                           RC.config_file_name, i, absoluteFrequencySSB);
            }

            NRRRC_CONFIGURATION_REQ (msg_p).DL_FreqBandIndicatorNR[j] = DL_FreqBandIndicatorNR;
            if ((DL_FreqBandIndicatorNR <1) || (DL_FreqBandIndicatorNR > 1024)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_FreqBandIndicatorNR choice: 1..1024 !\n",
                           RC.config_file_name, i, DL_FreqBandIndicatorNR);
            }

            NRRRC_CONFIGURATION_REQ (msg_p).DL_absoluteFrequencyPointA[j] = DL_absoluteFrequencyPointA;
            if ((DL_absoluteFrequencyPointA <0) || (DL_absoluteFrequencyPointA > 3279165)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_absoluteFrequencyPointA choice: 0..3279165 !\n",
                           RC.config_file_name, i, DL_absoluteFrequencyPointA);
            }            
            

            /////////////////////////////////NR DL SCS-SpecificCarrier///////////////////////////
            NRRRC_CONFIGURATION_REQ (msg_p).DL_offsetToCarrier[j] = DL_offsetToCarrier;
            if ((DL_offsetToCarrier <0) || (DL_offsetToCarrier > 2199)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_offsetToCarrier choice: 0..11 !\n",
                           RC.config_file_name, i, DL_offsetToCarrier);
            }

948
            if (strcmp(DL_SCS_SubcarrierSpacing,"kHz15")==0) {
949
              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
950
            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz30")==0) {
951
              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
952
            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz60")==0) {
953
              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
954
            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz120")==0) {
955
              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
956
            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz240")==0) {
957
              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
958
            }else { 
959 960
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_SCS_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
                           RC.config_file_name, i, DL_SCS_SubcarrierSpacing);
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975
            }

            NRRRC_CONFIGURATION_REQ (msg_p).DL_carrierBandwidth[j] = DL_carrierBandwidth;
            if ((DL_carrierBandwidth <1) || (DL_carrierBandwidth > 275)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_carrierBandwidth choice: 1..275 !\n",
              RC.config_file_name, i, DL_carrierBandwidth);
            }

            /////////////////////////////////NR BWP-DownlinkCommon///////////////////////////
            NRRRC_CONFIGURATION_REQ (msg_p).DL_locationAndBandwidth[j] = DL_locationAndBandwidth;
            if ((DL_locationAndBandwidth <0) || (DL_locationAndBandwidth > 37949)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_locationAndBandwidth choice: 0..11 !\n",
              RC.config_file_name, i, DL_locationAndBandwidth);
            }

976
            if (strcmp(DL_BWP_SubcarrierSpacing,"kHz15")==0) {
977
              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
978
            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz30")==0) {
979
              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
980
            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz60")==0) {
981
              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
982
            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz120")==0) {
983
              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
984
            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz240")==0) {
985
              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002
            }else { 
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_BWP_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
                           RC.config_file_name, i, DL_BWP_SubcarrierSpacing);
            }

            if (!DL_BWP_prefix_type){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
            }else if (strcmp(DL_BWP_prefix_type, "NORMAL") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_prefix_type[j] = NORMAL;
            }else if (strcmp(DL_BWP_prefix_type, "EXTENDED") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_prefix_type[j] = EXTENDED;
            }else {
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_BWP_prefix_type choice: NORMAL or EXTENDED !\n",
                           RC.config_file_name, i, DL_BWP_prefix_type);
            }                        

1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
            /////////////////////////////////NR FrequencyInfoUL//////////////////////////////
            NRRRC_CONFIGURATION_REQ (msg_p).UL_FreqBandIndicatorNR[j] = UL_FreqBandIndicatorNR;
            if ((UL_FreqBandIndicatorNR <1) || (UL_FreqBandIndicatorNR > 1024)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_FreqBandIndicatorNR choice: 1..1024 !\n",
                           RC.config_file_name, i, UL_FreqBandIndicatorNR);
            }

            NRRRC_CONFIGURATION_REQ (msg_p).UL_absoluteFrequencyPointA[j] = UL_absoluteFrequencyPointA;
            if ((UL_absoluteFrequencyPointA <0) || (UL_absoluteFrequencyPointA > 3279165)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_absoluteFrequencyPointA choice: 0..3279165 !\n",
                           RC.config_file_name, i, UL_absoluteFrequencyPointA);
            }       

1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
            NRRRC_CONFIGURATION_REQ (msg_p).UL_additionalSpectrumEmission[j] = UL_additionalSpectrumEmission;
            if ((UL_additionalSpectrumEmission <0) || (UL_additionalSpectrumEmission > 7)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_additionalSpectrumEmission choice: 0..7 !\n",
                           RC.config_file_name, i, UL_additionalSpectrumEmission);
            }            

            NRRRC_CONFIGURATION_REQ (msg_p).UL_p_Max[j] = UL_p_Max;
            if ((UL_p_Max <-30) || (UL_p_Max > 33)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_p_Max choice: -30..33 !\n",
              RC.config_file_name, i, UL_p_Max);
1026 1027
            }

1028 1029 1030 1031
            if (strcmp(UL_frequencyShift7p5khz,"TRUE") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_frequencyShift7p5khz[j] = NR_FrequencyInfoUL__frequencyShift7p5khz_true; //enum true = 0
            }else{
              NRRRC_CONFIGURATION_REQ (msg_p).UL_frequencyShift7p5khz[j] = 1;//false               
1032 1033 1034 1035 1036 1037 1038 1039 1040
            } 

            /////////////////////////////////NR UL SCS-SpecificCarrier///////////////////////////
            NRRRC_CONFIGURATION_REQ (msg_p).UL_offsetToCarrier[j] = UL_offsetToCarrier;
            if ((UL_offsetToCarrier <0) || (UL_offsetToCarrier > 2199)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_offsetToCarrier choice: 0..11 !\n",
              RC.config_file_name, i, UL_offsetToCarrier);
            }

1041
            if (strcmp(UL_SCS_SubcarrierSpacing,"kHz15")==0) {
1042
              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
1043
            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz30")==0) {
1044
              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
1045
            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz60")==0) {
1046
              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
1047
            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz120")==0) {
1048
              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
1049
            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz240")==0) {
1050
              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
1051 1052
            }else { AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_SCS_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
              RC.config_file_name, i, UL_SCS_SubcarrierSpacing);
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067
            }

            NRRRC_CONFIGURATION_REQ (msg_p).UL_carrierBandwidth[j] = UL_carrierBandwidth;
            if ((UL_carrierBandwidth <1) || (UL_carrierBandwidth > 275)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_carrierBandwidth choice: 1..275 !\n",
              RC.config_file_name, i, UL_carrierBandwidth);
            }

            /////////////////////////////////NR BWP-UplinkCommon///////////////////////////
            NRRRC_CONFIGURATION_REQ (msg_p).UL_locationAndBandwidth[j] = UL_locationAndBandwidth;
            if ((UL_locationAndBandwidth <0) || (UL_locationAndBandwidth > 37949)){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_locationAndBandwidth choice: 0..11 !\n",
              RC.config_file_name, i, UL_locationAndBandwidth);
            }

1068
            if (strcmp(UL_BWP_SubcarrierSpacing,"kHz15")==0) {
1069
              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
1070
            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz30")==0) {
1071
              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
1072
            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz60")==0) {
1073
              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
1074
            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz120")==0) {
1075
              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
1076
            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz240")==0) {
1077
              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094
            }else { 
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_BWP_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
                           RC.config_file_name, i, UL_BWP_SubcarrierSpacing);
            }

            if (!UL_BWP_prefix_type){
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
            }else if (strcmp(UL_BWP_prefix_type, "NORMAL") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_prefix_type[j] = NORMAL;
            }else if (strcmp(UL_BWP_prefix_type, "EXTENDED") == 0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_prefix_type[j] = EXTENDED;
            }else {
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_BWP_prefix_type choice: NORMAL or EXTENDED !\n",
                           RC.config_file_name, i, UL_BWP_prefix_type);
            }  

1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115
            if (strcmp(UL_timeAlignmentTimerCommon,"ms500")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms500;
            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms750")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms750;
            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms1280")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms1280;
            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms1920")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms1920;
            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms2560")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms2560;
            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms5120")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms5120;
            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms10240")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms10240;
            }else if (strcmp(UL_timeAlignmentTimerCommon,"infinity")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_infinity;
            }else { 
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_timeAlignmentTimerCommon choice: ms500,ms750,ms1280,ms1920,ms2560,ms5120,ms10240,infinity!\n",
                           RC.config_file_name, i, UL_timeAlignmentTimerCommon);
            }

ChenWeiTai's avatar
ChenWeiTai committed
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
            if (strcmp(ServingCellConfigCommon_n_TimingAdvanceOffset,"n0")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_n_TimingAdvanceOffset[j] = NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n0;
            }else if (strcmp(ServingCellConfigCommon_n_TimingAdvanceOffset,"n25600")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_n_TimingAdvanceOffset[j] = NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n25600;
            }else if (strcmp(ServingCellConfigCommon_n_TimingAdvanceOffset,"n39936")==0) {
              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_n_TimingAdvanceOffset[j] = NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n39936;
            }else { 
              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for ServingCellConfigCommon_n_TimingAdvanceOffset choice n0,n25600,n39936!\n",
                           RC.config_file_name, i, ServingCellConfigCommon_n_TimingAdvanceOffset);
            }        

1127

1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143
	    uint64_t t_freq;
	    if(nr_band == 41 || (nr_band > 76 && nr_band < 80))
		t_freq = 2400000000;
	    else
		t_freq = 3000000000;
		
            if (downlink_frequency<t_freq && (ServingCellConfigCommon_ssb_PositionsInBurst_PR > 15))
		AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unvalid value \"%ld\" for ssb_PositionsInBurst at DL frequency %ld !\n",
                           RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR, downlink_frequency);
	    else {
		if(downlink_frequency<6000000000 && (ServingCellConfigCommon_ssb_PositionsInBurst_PR > 255))
			AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unvalid value \"%ld\" for ssb_PositionsInBurst at DL frequency %ld !\n",
                           RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR, downlink_frequency);
		else
			NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = ServingCellConfigCommon_ssb_PositionsInBurst_PR;
	    }
1144

ChenWeiTai's avatar
ChenWeiTai committed
1145
            switch (ServingCellConfigCommon_ssb_periodicityServingCell) {
1146
              case 5:
1147
                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms5;
1148 1149 1150
                break;

              case 10:
1151
                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms10;
1152 1153 1154
                break;