enb_config.c 140 KB
Newer Older
1 2 3 4 5
/*
 * 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
Cedric Roux's avatar
Cedric Roux committed
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * 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
 */
nikaeinn's avatar
nikaeinn committed
21

gauthier's avatar
licence  
gauthier committed
22
/*
23 24
  enb_config.c
  -------------------
25
  AUTHOR  : Lionel GAUTHIER, navid nikaein, Laurent Winckel
gauthier's avatar
licence  
gauthier committed
26
  COMPANY : EURECOM
27
  EMAIL   : Lionel.Gauthier@eurecom.fr, navid.nikaein@eurecom.fr
28
*/
29 30

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

33
#include "common/utils/LOG/log.h"
34 35
#include "assertions.h"
#include "enb_config.h"
36 37
#include "UTIL/OTG/otg.h"
#include "UTIL/OTG/otg_externs.h"
38 39 40
#include "intertask_interface.h"
#include "s1ap_eNB.h"
#include "sctp_eNB_task.h"
41
#include "common/ran_context.h"
42
#include "sctp_default_values.h"
43
#include "LTE_SystemInformationBlockType2.h"
44 45 46
#include "LAYER2/MAC/mac_extern.h"
#include "LAYER2/MAC/mac_proto.h"
#include "PHY/phy_extern.h"
knopp's avatar
knopp committed
47
#include "PHY/INIT/phy_init.h"
48
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
49 50
#include "nfapi_vnf.h"
#include "nfapi_pnf.h"
51

52 53
#include "L1_paramdef.h"
#include "MACRLC_paramdef.h"
54
#include "common/config/config_userapi.h"
55 56
#include "RRC_config_tools.h"
#include "enb_paramdef.h"
frtabu's avatar
frtabu committed
57
#include "proto_agent.h"
Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
58
#define RRC_INACTIVITY_THRESH 0
59

60
extern uint16_t sf_ahead;
61 62
extern void set_parallel_conf(char *parallel_conf);
extern void set_worker_conf(char *worker_conf);
63 64
extern PARALLEL_CONF_t get_thread_parallel_conf(void);
extern WORKER_CONF_t   get_thread_worker_conf(void);
65 66
extern uint32_t to_earfcn_DL(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw);
extern uint32_t to_earfcn_UL(int eutra_bandP, uint32_t ul_CarrierFreq, uint32_t bw);
67 68
extern char *parallel_config;
extern char *worker_config;
gauthier's avatar
 
gauthier committed
69

Thomas Laurent's avatar
Thomas Laurent committed
70
void RCconfig_flexran() {
71 72 73
  /* get number of eNBs */
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
  config_get(ENBSParams, sizeof(ENBSParams)/sizeof(paramdef_t), NULL);
74
  uint16_t num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt;
75 76 77 78
  paramdef_t flexranParams[] = FLEXRANPARAMS_DESC;
  config_get(flexranParams, sizeof(flexranParams)/sizeof(paramdef_t), CONFIG_STRING_NETWORK_CONTROLLER_CONFIG);

  if (!RC.flexran) {
Thomas Laurent's avatar
Thomas Laurent committed
79
    RC.flexran = calloc(num_enbs, sizeof(flexran_agent_info_t *));
80
    AssertFatal(RC.flexran,
81
                "can't ALLOCATE %zu Bytes for %d flexran agent info with size %zu\n",
Thomas Laurent's avatar
Thomas Laurent committed
82 83
                num_enbs * sizeof(flexran_agent_info_t *),
                num_enbs, sizeof(flexran_agent_info_t *));
84 85
  }

86
  for (uint16_t i = 0; i < num_enbs; i++) {
87
    RC.flexran[i] = calloc(1, sizeof(flexran_agent_info_t));
88
    AssertFatal(RC.flexran[i],
89
                "can't ALLOCATE %zu Bytes for flexran agent info (iteration %d/%d)\n",
90
                sizeof(flexran_agent_info_t), i + 1, num_enbs);
91
    /* if config says "yes", enable Agent, in all other cases it's like "no" */
92
    RC.flexran[i]->enabled          = strcasecmp(*(flexranParams[FLEXRAN_ENABLED].strptr), "yes") == 0;
Thomas Laurent's avatar
Thomas Laurent committed
93

94 95 96
    /* if not enabled, simply skip the rest, it is not needed anyway */
    if (!RC.flexran[i]->enabled)
      continue;
Thomas Laurent's avatar
Thomas Laurent committed
97

98 99 100 101 102
    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));
103
    RC.flexran[i]->node_ctrl_state  = strcasecmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0 ? ENB_WAIT : ENB_NORMAL_OPERATION;
104
    RC.flexran[i]->mod_id  = i;
105
  }
106 107
}

108

109
void RCconfig_L1(void) {
110 111 112 113
  int               i,j;
  paramdef_t L1_Params[] = L1PARAMS_DESC;
  paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0};

114
  if (RC.eNB == NULL) {
115
    RC.eNB                       = (PHY_VARS_eNB ** *)malloc((1+NUMBER_OF_eNB_MAX)*sizeof(PHY_VARS_eNB **));
116
    LOG_I(PHY,"RC.eNB = %p\n",RC.eNB);
Thomas Laurent's avatar
Thomas Laurent committed
117
    memset(RC.eNB,0,(1+NUMBER_OF_eNB_MAX)*sizeof(PHY_VARS_eNB **));
118 119
    RC.nb_L1_CC = malloc((1+RC.nb_L1_inst)*sizeof(int));
  }
120

Cedric Roux's avatar
Cedric Roux committed
121
  config_getlist( &L1_ParamList,L1_Params,sizeof(L1_Params)/sizeof(paramdef_t), NULL);
Thomas Laurent's avatar
Thomas Laurent committed
122

123 124 125 126 127
  if (L1_ParamList.numelt > 0) {
    for (j = 0; j < RC.nb_L1_inst; j++) {
      RC.nb_L1_CC[j] = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr);

      if (RC.eNB[j] == NULL) {
Thomas Laurent's avatar
Thomas Laurent committed
128 129 130
        RC.eNB[j]                       = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB *));
        LOG_I(PHY,"RC.eNB[%d] = %p\n",j,RC.eNB[j]);
        memset(RC.eNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB *));
131 132
      }

Thomas Laurent's avatar
Thomas Laurent committed
133
      for (i=0; i<RC.nb_L1_CC[j]; i++) {
134 135
        if (RC.eNB[j][i] == NULL) {
          RC.eNB[j][i] = (PHY_VARS_eNB *)malloc(sizeof(PHY_VARS_eNB));
Thomas Laurent's avatar
Thomas Laurent committed
136
          memset((void *)RC.eNB[j][i],0,sizeof(PHY_VARS_eNB));
137 138 139 140
          LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.eNB[j][i]);
          RC.eNB[j][i]->Mod_id  = j;
          RC.eNB[j][i]->CC_id   = i;
        }
141 142 143
      }

      if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
144
        sf_ahead = 4; // Need 4 subframe gap between RX and TX
Thomas Laurent's avatar
Thomas Laurent committed
145
      } else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) {
146
        RC.eNB[j][0]->eth_params_n.local_if_name            = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr));
Thomas Laurent's avatar
Thomas Laurent committed
147 148 149 150 151 152 153
        RC.eNB[j][0]->eth_params_n.my_addr                  = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr));
        RC.eNB[j][0]->eth_params_n.remote_addr              = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr));
        RC.eNB[j][0]->eth_params_n.my_portc                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr);
        RC.eNB[j][0]->eth_params_n.remote_portc             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr);
        RC.eNB[j][0]->eth_params_n.my_portd                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr);
        RC.eNB[j][0]->eth_params_n.remote_portd             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr);
        RC.eNB[j][0]->eth_params_n.transp_preference        = ETH_UDP_MODE;
154 155 156 157 158 159 160 161 162
        sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2
        RC.nb_macrlc_inst = 1;  // This is used by mac_top_init_eNB()
        // This is used by init_eNB_afterRU()
        RC.nb_CC = (int *)malloc((1+RC.nb_inst)*sizeof(int));
        RC.nb_CC[0]=1;
        RC.nb_inst =1; // DJP - feptx_prec uses num_eNB but phy_init_RU uses nb_inst
        LOG_I(PHY,"%s() NFAPI PNF mode - RC.nb_inst=1 this is because phy_init_RU() uses that to index and not RC.num_eNB - why the 2 similar variables?\n", __FUNCTION__);
        LOG_I(PHY,"%s() NFAPI PNF mode - RC.nb_CC[0]=%d for init_eNB_afterRU()\n", __FUNCTION__, RC.nb_CC[0]);
        LOG_I(PHY,"%s() NFAPI PNF mode - RC.nb_macrlc_inst:%d because used by mac_top_init_eNB()\n", __FUNCTION__, RC.nb_macrlc_inst);
Robert Schmidt's avatar
Robert Schmidt committed
163
        //mac_top_init_eNB();
164 165
        configure_nfapi_pnf(RC.eNB[j][0]->eth_params_n.remote_addr, RC.eNB[j][0]->eth_params_n.remote_portc, RC.eNB[j][0]->eth_params_n.my_addr, RC.eNB[j][0]->eth_params_n.my_portd,
                            RC.eNB[j][0]->eth_params_n     .remote_portd);
Thomas Laurent's avatar
Thomas Laurent committed
166
      } else { // other midhaul
167
      }
168

frtabu's avatar
frtabu committed
169
      // PRACH/PUCCH parameters
170 171 172
      RC.eNB[j][0]->prach_DTX_threshold    = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD_IDX].iptr);
      RC.eNB[j][0]->pucch1_DTX_threshold   = *(L1_ParamList.paramarray[j][L1_PUCCH1_DTX_THRESHOLD_IDX].iptr);
      RC.eNB[j][0]->pucch1ab_DTX_threshold = *(L1_ParamList.paramarray[j][L1_PUCCH1AB_DTX_THRESHOLD_IDX].iptr);
frtabu's avatar
frtabu committed
173 174 175 176 177

      for (int ce_level=0; ce_level<4; ce_level++) {
        RC.eNB[j][0]->prach_DTX_threshold_emtc[ce_level]    = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr);
        RC.eNB[j][0]->pucch1_DTX_threshold_emtc[ce_level]   = *(L1_ParamList.paramarray[j][L1_PUCCH1_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr);
        RC.eNB[j][0]->pucch1ab_DTX_threshold_emtc[ce_level] = *(L1_ParamList.paramarray[j][L1_PUCCH1AB_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr);
178
      }
179
    }// j=0..num_inst
Thomas Laurent's avatar
Thomas Laurent committed
180

181
    LOG_I(ENB_APP,"Initializing northbound interface for L1\n");
182 183
    l1_north_init_eNB();
  } else {
Thomas Laurent's avatar
Thomas Laurent committed
184
    LOG_I(PHY,"No " CONFIG_STRING_L1_LIST " configuration found");
185 186 187 188 189 190
    // DJP need to create some structures for VNF
    j = 0;
    RC.nb_L1_CC = malloc((1+RC.nb_L1_inst)*sizeof(int)); // DJP - 1 lot then???
    RC.nb_L1_CC[j]=1; // DJP - hmmm

    if (RC.eNB[j] == NULL) {
Thomas Laurent's avatar
Thomas Laurent committed
191
      RC.eNB[j]                       = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB **));
192
      LOG_I(PHY,"RC.eNB[%d] = %p\n",j,RC.eNB[j]);
193
      memset(RC.eNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB ** *));
194 195
    }

Thomas Laurent's avatar
Thomas Laurent committed
196
    for (i=0; i<RC.nb_L1_CC[j]; i++) {
197 198
      if (RC.eNB[j][i] == NULL) {
        RC.eNB[j][i] = (PHY_VARS_eNB *)malloc(sizeof(PHY_VARS_eNB));
Thomas Laurent's avatar
Thomas Laurent committed
199
        memset((void *)RC.eNB[j][i],0,sizeof(PHY_VARS_eNB));
200 201 202 203 204
        LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.eNB[j][i]);
        RC.eNB[j][i]->Mod_id  = j;
        RC.eNB[j][i]->CC_id   = i;
      }
    }
205 206 207
  }
}

208
void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]) {
209
  int               j;
210 211
  paramdef_t MacRLC_Params[] = MACRLCPARAMS_DESC;
  paramlist_def_t MacRLC_ParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0};
Thomas Laurent's avatar
Thomas Laurent committed
212
  config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL);
frtabu's avatar
frtabu committed
213
  config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL);
214

215
  if ( MacRLC_ParamList.numelt > 0) {
frtabu's avatar
frtabu committed
216 217
    RC.nb_macrlc_inst=MacRLC_ParamList.numelt;
    mac_top_init_eNB();
Thomas Laurent's avatar
Thomas Laurent committed
218
    RC.nb_mac_CC = (int *)malloc(RC.nb_macrlc_inst*sizeof(int));
219

220
    for (j = 0; j < RC.nb_macrlc_inst; j++) {
Cedric Roux's avatar
Cedric Roux committed
221 222
      RC.mac[j]->puSch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUSCH10xSNR_IDX ].iptr);
      RC.mac[j]->puCch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCH10xSNR_IDX ].iptr);
knopp's avatar
knopp committed
223
      RC.nb_mac_CC[j] = *(MacRLC_ParamList.paramarray[j][MACRLC_CC_IDX].iptr);
knopp's avatar
knopp committed
224 225
      //RC.mac[j]->phy_test = *(MacRLC_ParamList.paramarray[j][MACRLC_PHY_TEST_IDX].iptr);
      //printf("PHY_TEST = %d,%d\n", RC.mac[j]->phy_test, j);
226 227

      if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) {
frtabu's avatar
frtabu committed
228 229
        // check number of instances is same as RRC/PDCP
        printf("Configuring local RRC for MACRLC\n");
230
      } else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "f1") == 0) {
frtabu's avatar
frtabu committed
231 232 233 234 235 236 237 238 239
        printf("Configuring F1 interfaces for MACRLC\n");
        RC.mac[j]->eth_params_n.local_if_name            = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_IF_NAME_IDX].strptr));
        RC.mac[j]->eth_params_n.my_addr                  = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_ADDRESS_IDX].strptr));
        RC.mac[j]->eth_params_n.remote_addr              = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_ADDRESS_IDX].strptr));
        RC.mac[j]->eth_params_n.my_portc                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTC_IDX].iptr);
        RC.mac[j]->eth_params_n.remote_portc             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTC_IDX].iptr);
        RC.mac[j]->eth_params_n.my_portd                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTD_IDX].iptr);
        RC.mac[j]->eth_params_n.remote_portd             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTD_IDX].iptr);;
        RC.mac[j]->eth_params_n.transp_preference        = ETH_UDP_MODE;
240
        macrlc_has_f1[j]                                 = 1;
241
      } else { // other midhaul
Thomas Laurent's avatar
Thomas Laurent committed
242 243
        AssertFatal(1==0,"MACRLC %d: %s unknown northbound midhaul\n",j, *(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr));
      }
244 245 246

      if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_L1") == 0) {
      } else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "nfapi") == 0) {
Thomas Laurent's avatar
Thomas Laurent committed
247 248 249 250 251 252 253 254
        RC.mac[j]->eth_params_s.local_if_name            = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_IF_NAME_IDX].strptr));
        RC.mac[j]->eth_params_s.my_addr                  = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_ADDRESS_IDX].strptr));
        RC.mac[j]->eth_params_s.remote_addr              = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_ADDRESS_IDX].strptr));
        RC.mac[j]->eth_params_s.my_portc                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTC_IDX].iptr);
        RC.mac[j]->eth_params_s.remote_portc             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTC_IDX].iptr);
        RC.mac[j]->eth_params_s.my_portd                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTD_IDX].iptr);
        RC.mac[j]->eth_params_s.remote_portd             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTD_IDX].iptr);
        RC.mac[j]->eth_params_s.transp_preference        = ETH_UDP_MODE;
255
        sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2
256
        LOG_I(ENB_APP,"**************** vnf_port:%d\n", RC.mac[j]->eth_params_s.my_portc);
257
        configure_nfapi_vnf(RC.mac[j]->eth_params_s.my_addr, RC.mac[j]->eth_params_s.my_portc);
258
        LOG_I(ENB_APP,"**************** RETURNED FROM configure_nfapi_vnf() vnf_port:%d\n", RC.mac[j]->eth_params_s.my_portc);
259
      } else { // other midhaul
Thomas Laurent's avatar
Thomas Laurent committed
260
        AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr));
261
      }
Thomas Laurent's avatar
Thomas Laurent committed
262 263 264

      if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr), "default") == 0) {
        global_scheduler_mode=SCHED_MODE_DEFAULT;
265
        LOG_I(ENB_APP,"sched mode = default %d [%s]\n",global_scheduler_mode,*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr));
Thomas Laurent's avatar
Thomas Laurent committed
266 267 268 269 270 271
      } else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr), "fairRR") == 0) {
        global_scheduler_mode=SCHED_MODE_FAIR_RR;
        printf("sched mode = fairRR %d [%s]\n",global_scheduler_mode,*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr));
      } else {
        global_scheduler_mode=SCHED_MODE_DEFAULT;
        printf("sched mode = default %d [%s]\n",global_scheduler_mode,*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr));
272
      }
273
    }// j=0..num_inst
Robert Schmidt's avatar
Robert Schmidt committed
274
  } /*else {// MacRLC_ParamList.numelt > 0 // ignore it
frtabu's avatar
frtabu committed
275

Thomas Laurent's avatar
Thomas Laurent committed
276 277
    AssertFatal (0,
                 "No " CONFIG_STRING_MACRLC_LIST " configuration found");
Robert Schmidt's avatar
Robert Schmidt committed
278
  }*/
279
}
280

281
int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) {
282
  int               num_enbs                      = 0;
283
  int               j,k                           = 0;
knopp's avatar
knopp committed
284
  int32_t           enb_id                        = 0;
285
  int               nb_cc                         = 0;
286
  MessageDef *msg_p = itti_alloc_new_message(TASK_RRC_ENB, RRC_CONFIGURATION_REQ);
knopp's avatar
knopp committed
287 288 289
  ccparams_lte_t ccparams_lte;
  ccparams_sidelink_t SLconfig;
  ccparams_eMTC_t eMTCconfig;
290 291 292
  memset((void *)&ccparams_lte,0,sizeof(ccparams_lte_t));
  memset((void *)&SLconfig,0,sizeof(ccparams_sidelink_t));
  memset((void *)&eMTCconfig,0,sizeof(ccparams_eMTC_t));
293 294
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
  paramdef_t ENBParams[]  = ENBPARAMS_DESC;
Thomas Laurent's avatar
Thomas Laurent committed
295
  paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0};
296
  checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
knopp's avatar
knopp committed
297
  paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte);
298
  paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0};
299 300
  paramdef_t eMTCParams[]              = EMTCPARAMS_DESC((&eMTCconfig));
  checkedparam_t config_check_eMTCparams[] = EMTCPARAMS_CHECK;
knopp's avatar
knopp committed
301
  srb1_params_t srb1_params;
302
  memset((void *)&srb1_params,0,sizeof(srb1_params_t));
knopp's avatar
knopp committed
303 304 305
  paramdef_t SRB1Params[] = SRB1PARAMS_DESC(srb1_params);
  paramdef_t SLParams[]              = CCPARAMS_SIDELINK_DESC(SLconfig);

Thomas Laurent's avatar
Thomas Laurent committed
306
  /* map parameter checking array instances to parameter definition array instances */
307
  for (int I=0; I< ( sizeof(CCsParams)/ sizeof(paramdef_t)  ) ; I++) {
Thomas Laurent's avatar
Thomas Laurent committed
308
    CCsParams[I].chkPptr = &(config_check_CCparams[I]);
309
  }
310

311 312 313 314
  for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) {
    eMTCParams[I].chkPptr = &(config_check_eMTCparams[I]);
  }

Thomas Laurent's avatar
Thomas Laurent committed
315 316
  /* get global parameters, defined outside any section in the config file */
  config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL);
317 318
  num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt;
  AssertFatal (i<num_enbs,
Thomas Laurent's avatar
Thomas Laurent committed
319
               "Failed to parse config file no %ith element in %s \n",i, ENB_CONFIG_STRING_ACTIVE_ENBS);
320

321 322
  if (num_enbs>0) {
    // Output a list of all eNBs.
Thomas Laurent's avatar
Thomas Laurent committed
323 324 325 326 327 328 329 330
    config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL);

    if (ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr == NULL) {
      // Calculate a default eNB ID
      if (EPC_MODE_ENABLED) {
        uint32_t hash;
        hash = s1ap_generate_eNB_id ();
        enb_id = i + (hash & 0xFFFF8);
331
      } else {
Thomas Laurent's avatar
Thomas Laurent committed
332
        enb_id = i;
333
      }
Thomas Laurent's avatar
Thomas Laurent committed
334 335 336
    } else {
      enb_id = *(ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr);
    }
337

frtabu's avatar
frtabu committed
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
    LOG_I(RRC,"Instance %d: Southbound Transport %s\n",i,*(ENBParamList.paramarray[i][ENB_TRANSPORT_S_PREFERENCE_IDX].strptr));

    if (strcmp(*(ENBParamList.paramarray[i][ENB_TRANSPORT_S_PREFERENCE_IDX].strptr), "f1") == 0) {
      paramdef_t SCTPParams[]  = SCTPPARAMS_DESC;
      char aprefix[MAX_OPTNAME_SIZE*2 + 8];
      sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,i,ENB_CONFIG_STRING_SCTP_CONFIG);
      config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix);
      rrc->node_id        = *(ENBParamList.paramarray[0][ENB_ENB_ID_IDX].uptr);
      LOG_I(ENB_APP,"F1AP: gNB_CU_id[%d] %d\n",k,rrc->node_id);
      rrc->node_name = strdup(*(ENBParamList.paramarray[0][ENB_ENB_NAME_IDX].strptr));
      LOG_I(ENB_APP,"F1AP: gNB_CU_name[%d] %s\n",k,rrc->node_name);
      rrc->eth_params_s.local_if_name            = strdup(*(ENBParamList.paramarray[i][ENB_LOCAL_S_IF_NAME_IDX].strptr));
      rrc->eth_params_s.my_addr                  = strdup(*(ENBParamList.paramarray[i][ENB_LOCAL_S_ADDRESS_IDX].strptr));
      rrc->eth_params_s.remote_addr              = strdup(*(ENBParamList.paramarray[i][ENB_REMOTE_S_ADDRESS_IDX].strptr));
      rrc->eth_params_s.my_portc                 = *(ENBParamList.paramarray[i][ENB_LOCAL_S_PORTC_IDX].uptr);
      rrc->eth_params_s.remote_portc             = *(ENBParamList.paramarray[i][ENB_REMOTE_S_PORTC_IDX].uptr);
      rrc->eth_params_s.my_portd                 = *(ENBParamList.paramarray[i][ENB_LOCAL_S_PORTD_IDX].uptr);
      rrc->eth_params_s.remote_portd             = *(ENBParamList.paramarray[i][ENB_REMOTE_S_PORTD_IDX].uptr);
      rrc->eth_params_s.transp_preference        = ETH_UDP_MODE;
      rrc->node_type                             = ngran_eNB_CU;
      rrc->sctp_in_streams                       = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr);
      rrc->sctp_out_streams                      = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr);
    } else {
      // set to ngran_eNB for now, it will get set to ngran_eNB_DU if macrlc entity which uses F1 is present
      // Note: we will have to handle the case of ngran_ng_eNB_DU
      if (macrlc_has_f1 == 0) {
        rrc->node_type = ngran_eNB;
        LOG_I(RRC,"Setting node_type to ngran_eNB\n");
      } else {
        rrc->node_type = ngran_eNB_DU;
        LOG_I(RRC,"Setting node_type to ngran_eNB_DU\n");
369
      }
frtabu's avatar
frtabu committed
370
    }
371

frtabu's avatar
frtabu committed
372
    rrc->nr_cellid        = (uint64_t)*(ENBParamList.paramarray[i][ENB_NRCELLID_IDX].u64ptr);
373

Thomas Laurent's avatar
Thomas Laurent committed
374
    // search if in active list
375

Thomas Laurent's avatar
Thomas Laurent committed
376
    for (k=0; k <num_enbs ; k++) {
377
      if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[k], *(ENBParamList.paramarray[i][ENB_ENB_NAME_IDX].strptr)) == 0) {
Thomas Laurent's avatar
Thomas Laurent committed
378
        char enbpath[MAX_OPTNAME_SIZE + 8];
Raphael Defosseux's avatar
Raphael Defosseux committed
379 380 381 382 383 384 385 386 387
        sprintf(enbpath,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
        paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
        paramlist_def_t PLMNParamList = {ENB_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]);

Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
388
        RRC_CONFIGURATION_REQ (msg_p).rrc_inactivity_timer_thres = RRC_INACTIVITY_THRESH; // set to 0 to deactivate
Thomas Laurent's avatar
Thomas Laurent committed
389
        RRC_CONFIGURATION_REQ (msg_p).cell_identity = enb_id;
390
        RRC_CONFIGURATION_REQ (msg_p).tac = *ENBParamList.paramarray[i][ENB_TRACKING_AREA_CODE_IDX].uptr;
Raphael Defosseux's avatar
Raphael Defosseux committed
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
        AssertFatal(!ENBParamList.paramarray[i][ENB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr
                    && !ENBParamList.paramarray[i][ENB_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), enbpath);

        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) {
          RRC_CONFIGURATION_REQ(msg_p).mcc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_COUNTRY_CODE_IDX].uptr;
          RRC_CONFIGURATION_REQ(msg_p).mnc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_NETWORK_CODE_IDX].uptr;
          RRC_CONFIGURATION_REQ(msg_p).mnc_digit_length[l] = *PLMNParamList.paramarray[l][ENB_MNC_DIGIT_LENGTH].u8ptr;
          AssertFatal(RRC_CONFIGURATION_REQ(msg_p).mnc_digit_length[l] == 3
                      || RRC_CONFIGURATION_REQ(msg_p).mnc[l] < 100,
                      "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n",
                      RRC_CONFIGURATION_REQ(msg_p).mnc[l]);
        }
417

Thomas Laurent's avatar
Thomas Laurent committed
418
        // Parse optional physical parameters
Raphael Defosseux's avatar
Raphael Defosseux committed
419
        config_getlist( &CCsParamList,NULL,0,enbpath);
Thomas Laurent's avatar
Thomas Laurent committed
420
        LOG_I(RRC,"num component carriers %d \n",CCsParamList.numelt);
421

Thomas Laurent's avatar
Thomas Laurent committed
422 423 424 425 426 427 428 429 430
        if ( CCsParamList.numelt> 0) {
          char ccspath[MAX_OPTNAME_SIZE*2 + 16];

          for (j = 0; j < CCsParamList.numelt ; j++) {
            sprintf(ccspath,"%s.%s.[%i]",enbpath,ENB_CONFIG_STRING_COMPONENT_CARRIERS,j);
            LOG_I(RRC, "enb_config::RCconfig_RRC() parameter number: %d, total number of parameters: %zd, ccspath: %s \n \n", j, sizeof(CCsParams)/sizeof(paramdef_t), ccspath);
            config_get( CCsParams,sizeof(CCsParams)/sizeof(paramdef_t),ccspath);
            //printf("Component carrier %d\n",component_carrier);
            nb_cc++;
431

432
            if (!NODE_IS_CU(rrc->node_type)) {
433
              // Cell params, MIB/SIB1 in DU
434 435 436 437 438 439 440 441
              RRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = ccparams_lte.tdd_config;
              AssertFatal (ccparams_lte.tdd_config <= LTE_TDD_Config__subframeAssignment_sa6,
                           "Failed to parse eNB configuration file %s, enb %d illegal tdd_config %d (should be 0-%d)!",
                           RC.config_file_name, i, ccparams_lte.tdd_config, LTE_TDD_Config__subframeAssignment_sa6);
              RRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = ccparams_lte.tdd_config_s;
              AssertFatal (ccparams_lte.tdd_config_s <= LTE_TDD_Config__specialSubframePatterns_ssp8,
                           "Failed to parse eNB configuration file %s, enb %d illegal tdd_config_s %d (should be 0-%d)!",
                           RC.config_file_name, i, ccparams_lte.tdd_config_s, LTE_TDD_Config__specialSubframePatterns_ssp8);
442

443 444 445 446 447 448 449 450 451 452 453 454 455
              if (!ccparams_lte.prefix_type)
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d define %s: NORMAL,EXTENDED!\n",
                             RC.config_file_name, i, ENB_CONFIG_STRING_PREFIX_TYPE);
              else if (strcmp(ccparams_lte.prefix_type, "NORMAL") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = NORMAL;
              } else  if (strcmp(ccparams_lte.prefix_type, "EXTENDED") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = EXTENDED;
              } else {
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
                             RC.config_file_name, i, ccparams_lte.prefix_type);
              }
456

457
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
Thomas Laurent's avatar
Thomas Laurent committed
458

459 460 461 462 463 464 465 466 467 468 469 470 471
              if (!ccparams_lte.pbch_repetition)
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d define %s: TRUE,FALSE!\n",
                             RC.config_file_name, i, ENB_CONFIG_STRING_PBCH_REPETITION);
              else if (strcmp(ccparams_lte.pbch_repetition, "TRUE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).pbch_repetition[j] = 1;
              } else  if (strcmp(ccparams_lte.pbch_repetition, "FALSE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).pbch_repetition[j] = 0;
              } else {
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pbch_repetition choice: TRUE or FALSE !\n",
                             RC.config_file_name, i, ccparams_lte.pbch_repetition);
              }
472 473

#endif
474 475 476 477
              RRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = ccparams_lte.eutra_band;
              RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) ccparams_lte.downlink_frequency;
              RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) ccparams_lte.uplink_frequency_offset;
              RRC_CONFIGURATION_REQ (msg_p).Nid_cell[j]= ccparams_lte.Nid_cell;
478

479 480 481 482 483
              if (ccparams_lte.Nid_cell>503) {
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
                             RC.config_file_name, i, ccparams_lte.Nid_cell);
              }
484

485
              RRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= ccparams_lte.N_RB_DL;
486

487 488 489 490 491 492 493 494 495 496
              if ((ccparams_lte.N_RB_DL!=6) &&
                  (ccparams_lte.N_RB_DL!=15) &&
                  (ccparams_lte.N_RB_DL!=25) &&
                  (ccparams_lte.N_RB_DL!=50) &&
                  (ccparams_lte.N_RB_DL!=75) &&
                  (ccparams_lte.N_RB_DL!=100)) {
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
                             RC.config_file_name, i, ccparams_lte.N_RB_DL);
              }
497

498 499 500 501 502 503 504 505 506
              if (strcmp(ccparams_lte.frame_type, "FDD") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).frame_type[j] = FDD;
              } else  if (strcmp(ccparams_lte.frame_type, "TDD") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).frame_type[j] = TDD;
              } else {
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
                             RC.config_file_name, i, ccparams_lte.frame_type);
              }
507

508 509 510 511 512 513 514
              if (config_check_band_frequencies(j,
                                                RRC_CONFIGURATION_REQ (msg_p).eutra_band[j],
                                                RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j],
                                                RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j],
                                                RRC_CONFIGURATION_REQ (msg_p).frame_type[j])) {
                AssertFatal(0, "error calling enb_check_band_frequencies\n");
              }
515

516 517 518 519
              if ((ccparams_lte.nb_antenna_ports <1) || (ccparams_lte.nb_antenna_ports > 2))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for nb_antenna_ports choice: 1..2 !\n",
                             RC.config_file_name, i, ccparams_lte.nb_antenna_ports);
Thomas Laurent's avatar
Thomas Laurent committed
520

521 522
              RRC_CONFIGURATION_REQ (msg_p).nb_antenna_ports[j] = ccparams_lte.nb_antenna_ports;
            }
523

524
            if (!NODE_IS_DU(rrc->node_type)) { //this is CU or eNB, SIB2-20 in CU
525 526
              // Radio Resource Configuration (SIB2)
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_root =  ccparams_lte.prach_root;
Thomas Laurent's avatar
Thomas Laurent committed
527

528 529 530 531
              if ((ccparams_lte.prach_root <0) || (ccparams_lte.prach_root > 1023))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_root choice: 0..1023 !\n",
                             RC.config_file_name, i, ccparams_lte.prach_root);
532

533
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_config_index = ccparams_lte.prach_config_index;
534

535 536 537 538
              if ((ccparams_lte.prach_config_index <0) || (ccparams_lte.prach_config_index > 63))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_config_index choice: 0..1023 !\n",
                             RC.config_file_name, i, ccparams_lte.prach_config_index);
539

540 541 542 543 544 545 546 547 548 549 550 551
              if (!ccparams_lte.prach_high_speed)
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
                             RC.config_file_name, i, ENB_CONFIG_STRING_PRACH_HIGH_SPEED);
              else if (strcmp(ccparams_lte.prach_high_speed, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_high_speed = TRUE;
              } else if (strcmp(ccparams_lte.prach_high_speed, "DISABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_high_speed = FALSE;
              } else
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prach_config choice: ENABLE,DISABLE !\n",
                             RC.config_file_name, i, ccparams_lte.prach_high_speed);
552

553
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_zero_correlation = ccparams_lte.prach_zero_correlation;
554

555 556 557 558 559
              if ((ccparams_lte.prach_zero_correlation <0) ||
                  (ccparams_lte.prach_zero_correlation > 15))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_zero_correlation choice: 0..15!\n",
                             RC.config_file_name, i, ccparams_lte.prach_zero_correlation);
560

561
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_freq_offset = ccparams_lte.prach_freq_offset;
562

563 564 565 566 567
              if ((ccparams_lte.prach_freq_offset <0) ||
                  (ccparams_lte.prach_freq_offset > 94))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 0..94!\n",
                             RC.config_file_name, i, ccparams_lte.prach_freq_offset);
568

569
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_delta_shift = ccparams_lte.pucch_delta_shift-1;
570

571 572 573 574 575
              if ((ccparams_lte.pucch_delta_shift <1) ||
                  (ccparams_lte.pucch_delta_shift > 3))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_delta_shift choice: 1..3!\n",
                             RC.config_file_name, i, ccparams_lte.pucch_delta_shift);
576

577
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_nRB_CQI = ccparams_lte.pucch_nRB_CQI;
578

579 580 581 582 583
              if ((ccparams_lte.pucch_nRB_CQI <0) ||
                  (ccparams_lte.pucch_nRB_CQI > 98))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nRB_CQI choice: 0..98!\n",
                             RC.config_file_name, i, ccparams_lte.pucch_nRB_CQI);
584

585
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_nCS_AN = ccparams_lte.pucch_nCS_AN;
586

587 588 589 590 591
              if ((ccparams_lte.pucch_nCS_AN <0) ||
                  (ccparams_lte.pucch_nCS_AN > 7))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nCS_AN choice: 0..7!\n",
                             RC.config_file_name, i, ccparams_lte.pucch_nCS_AN);
Thomas Laurent's avatar
Thomas Laurent committed
592

593 594
              //#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0))
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_n1_AN = ccparams_lte.pucch_n1_AN;
595

596 597 598 599 600
              if ((ccparams_lte.pucch_n1_AN <0) ||
                  (ccparams_lte.pucch_n1_AN > 2047))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_n1_AN choice: 0..2047!\n",
                             RC.config_file_name, i, ccparams_lte.pucch_n1_AN);
601

602 603
              //#endif
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pdsch_referenceSignalPower = ccparams_lte.pdsch_referenceSignalPower;
604

605 606 607 608 609
              if ((ccparams_lte.pdsch_referenceSignalPower <-60) ||
                  (ccparams_lte.pdsch_referenceSignalPower > 50))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_referenceSignalPower choice:-60..50!\n",
                             RC.config_file_name, i, ccparams_lte.pdsch_referenceSignalPower);
610

611
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pdsch_p_b = ccparams_lte.pdsch_p_b;
612

613 614 615 616 617
              if ((ccparams_lte.pdsch_p_b <0) ||
                  (ccparams_lte.pdsch_p_b > 3))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_p_b choice: 0..3!\n",
                             RC.config_file_name, i, ccparams_lte.pdsch_p_b);
618

619
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_n_SB = ccparams_lte.pusch_n_SB;
620

621 622 623 624 625
              if ((ccparams_lte.pusch_n_SB <1) ||
                  (ccparams_lte.pusch_n_SB > 4))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_n_SB choice: 1..4!\n",
                             RC.config_file_name, i, ccparams_lte.pusch_n_SB);
626

627 628 629 630 631 632
              if (!ccparams_lte.pusch_hoppingMode)
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d define %s: interSubframe,intraAndInterSubframe!\n",
                             RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE);
              else if (strcmp(ccparams_lte.pusch_hoppingMode,"interSubFrame")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
frtabu's avatar
frtabu committed
633
              } else if (strcmp(ccparams_lte.pusch_hoppingMode,"intraAndInterSubFrame")==0) {
634 635 636 637 638
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame;
              } else
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingMode choice: interSubframe,intraAndInterSubframe!\n",
                             RC.config_file_name, i, ccparams_lte.pusch_hoppingMode);
639

640
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingOffset = ccparams_lte.pusch_hoppingOffset;
641

642 643 644 645 646
              if ((ccparams_lte.pusch_hoppingOffset<0) ||
                  (ccparams_lte.pusch_hoppingOffset>98))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingOffset choice: 0..98!\n",
                             RC.config_file_name, i, ccparams_lte.pusch_hoppingMode);
647

648 649 650 651 652 653
              if (!ccparams_lte.pusch_enable64QAM)
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
                             RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM);
              else if (strcmp(ccparams_lte.pusch_enable64QAM, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = TRUE;
frtabu's avatar
frtabu committed
654
              } else if (strcmp(ccparams_lte.pusch_enable64QAM, "DISABLE") == 0) {
655
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = FALSE;
frtabu's avatar
frtabu committed
656
              } else
657 658 659
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_enable64QAM choice: ENABLE,DISABLE!\n",
                             RC.config_file_name, i, ccparams_lte.pusch_enable64QAM);
660

661 662 663 664 665 666
              if (!ccparams_lte.pusch_groupHoppingEnabled)
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
                             RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN);
              else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled = TRUE;
frtabu's avatar
frtabu committed
667
              } else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "DISABLE") == 0) {
668
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled= FALSE;
frtabu's avatar
frtabu committed
669
              } else
670 671 672
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_groupHoppingEnabled choice: ENABLE,DISABLE!\n",
                             RC.config_file_name, i, ccparams_lte.pusch_groupHoppingEnabled);
oai's avatar
oai committed
673

674
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupAssignment = ccparams_lte.pusch_groupAssignment;
675

676 677 678 679 680
              if ((ccparams_lte.pusch_groupAssignment<0)||
                  (ccparams_lte.pusch_groupAssignment>29))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_groupAssignment choice: 0..29!\n",
                             RC.config_file_name, i, ccparams_lte.pusch_groupAssignment);
681

682 683 684 685 686 687
              if (!ccparams_lte.pusch_sequenceHoppingEnabled)
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
                             RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN);
              else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = TRUE;
frtabu's avatar
frtabu committed
688
              } else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "DISABLE") == 0) {
689 690 691 692 693
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = FALSE;
              } else
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_sequenceHoppingEnabled choice: ENABLE,DISABLE!\n",
                             RC.config_file_name, i, ccparams_lte.pusch_sequenceHoppingEnabled);
694

695
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_nDMRS1= ccparams_lte.pusch_nDMRS1;  //cyclic_shift in RRC!
Thomas Laurent's avatar
Thomas Laurent committed
696

697 698 699 700 701
              if ((ccparams_lte.pusch_nDMRS1 <0) ||
                  (ccparams_lte.pusch_nDMRS1>7))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_nDMRS1 choice: 0..7!\n",
                             RC.config_file_name, i, ccparams_lte.pusch_nDMRS1);
702

703 704 705 706 707 708 709 710
              if (strcmp(ccparams_lte.phich_duration,"NORMAL")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration= LTE_PHICH_Config__phich_Duration_normal;
              } else if (strcmp(ccparams_lte.phich_duration,"EXTENDED")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration= LTE_PHICH_Config__phich_Duration_extended;
              } else
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_duration choice: NORMAL,EXTENDED!\n",
                             RC.config_file_name, i, ccparams_lte.phich_duration);
Thomas Laurent's avatar
Thomas Laurent committed
711

712 713
              if (strcmp(ccparams_lte.phich_resource,"ONESIXTH")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_oneSixth ;
frtabu's avatar
frtabu committed
714
              } else if (strcmp(ccparams_lte.phich_resource,"HALF")==0) {
715
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_half;
frtabu's avatar
frtabu committed
716
              } else if (strcmp(ccparams_lte.phich_resource,"ONE")==0) {
717
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_one;
frtabu's avatar
frtabu committed
718
              } else if (strcmp(ccparams_lte.phich_resource,"TWO")==0) {
719
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_two;
frtabu's avatar
frtabu committed
720
              } else
721 722 723
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_resource choice: ONESIXTH,HALF,ONE,TWO!\n",
                             RC.config_file_name, i, ccparams_lte.phich_resource);
Thomas Laurent's avatar
Thomas Laurent committed
724

725 726 727
              printf("phich.resource %ld (%s), phich.duration %ld (%s)\n",
                     RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource,ccparams_lte.phich_resource,
                     RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration,ccparams_lte.phich_duration);
Thomas Laurent's avatar
Thomas Laurent committed
728

729 730
              if (strcmp(ccparams_lte.srs_enable, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= TRUE;
frtabu's avatar
frtabu committed
731
              } else if (strcmp(ccparams_lte.srs_enable, "DISABLE") == 0) {
732
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= FALSE;
frtabu's avatar
frtabu committed
733
              } else
Thomas Laurent's avatar
Thomas Laurent committed
734 735
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
736
                             RC.config_file_name, i, ccparams_lte.srs_enable);
737

738 739
              if (RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable== TRUE) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_BandwidthConfig= ccparams_lte.srs_BandwidthConfig;
740

741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
                if ((ccparams_lte.srs_BandwidthConfig < 0) ||
                    (ccparams_lte.srs_BandwidthConfig >7))
                  AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value %d for srs_BandwidthConfig choice: 0...7\n",
                               RC.config_file_name, i, ccparams_lte.srs_BandwidthConfig);

                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_SubframeConfig= ccparams_lte.srs_SubframeConfig;

                if ((ccparams_lte.srs_SubframeConfig<0) ||
                    (ccparams_lte.srs_SubframeConfig>15))
                  AssertFatal (0,
                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for srs_SubframeConfig choice: 0..15 !\n",
                               RC.config_file_name, i, ccparams_lte.srs_SubframeConfig);

                if (strcmp(ccparams_lte.srs_ackNackST, "ENABLE") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= TRUE;
frtabu's avatar
frtabu committed
756
                } else if (strcmp(ccparams_lte.srs_ackNackST, "DISABLE") == 0) {
757 758 759 760 761 762 763 764
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= FALSE;
                } else
                  AssertFatal (0,
                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
                               RC.config_file_name, i, ccparams_lte.srs_ackNackST);

                if (strcmp(ccparams_lte.srs_MaxUpPts, "ENABLE") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= TRUE;
frtabu's avatar
frtabu committed
765
                } else if (strcmp(ccparams_lte.srs_MaxUpPts, "DISABLE") == 0) {
766
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= FALSE;
frtabu's avatar
frtabu committed
767
                } else
768 769 770 771 772 773 774 775 776 777 778 779
                  AssertFatal (0,
                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_MaxUpPts choice: ENABLE,DISABLE !\n",
                               RC.config_file_name, i, ccparams_lte.srs_MaxUpPts);
              }

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_p0_Nominal= ccparams_lte.pusch_p0_Nominal;

              if ((ccparams_lte.pusch_p0_Nominal<-126) ||
                  (ccparams_lte.pusch_p0_Nominal>24))
                AssertFatal (0,
                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_p0_Nominal choice: -126..24 !\n",
                             RC.config_file_name, i, ccparams_lte.pusch_p0_Nominal);
780

781
#if (LTE_RRC_VERSION <= MAKE_VERSION(12, 0, 0))
782

783 784
              if (strcmp(ccparams_lte.pusch_alpha,"AL0")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al0;
frtabu's avatar
frtabu committed
785
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) {
786
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al04;
frtabu's avatar
frtabu committed
787
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) {
788
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al05;
frtabu's avatar
frtabu committed
789
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) {
790
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al06;
frtabu's avatar
frtabu committed
791
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) {
792
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al07;
frtabu's avatar
frtabu committed
793
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) {
794
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al08;
frtabu's avatar
frtabu committed
795
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) {
796
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al09;
frtabu's avatar
frtabu committed
797
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) {
798 799
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al1;
              }
800 801

#endif
802
#if (LTE_RRC_VERSION >= MAKE_VERSION(12, 0, 0))
Thomas Laurent's avatar
Thomas Laurent committed
803

804 805
              if (strcmp(ccparams_lte.pusch_alpha,"AL0")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al0;
frtabu's avatar
frtabu committed
806
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) {
807
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al04;
frtabu's avatar
frtabu committed
808
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) {
809
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al05;
frtabu's avatar
frtabu committed
810
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) {
811
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al06;
frtabu's avatar
frtabu committed
812
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) {
813
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al07;
frtabu's avatar
frtabu committed
814
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) {
815
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al08;
frtabu's avatar
frtabu committed
816
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) {
817
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al09;
frtabu's avatar
frtabu committed
818
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) {
819 820
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al1;
              }
821