config.c 59.3 KB
Newer Older
1

2
3
4
5
6
/*
 * 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
7
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 * 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
 */
22
23

/*! \file config.c
nikaeinn's avatar
nikaeinn committed
24
 * \brief UE and eNB configuration performed by RRC or as a consequence of RRC procedures
25
26
 * \author  Navid Nikaein and Raymond Knopp
 * \date 2010 - 2014
gauthier's avatar
gauthier committed
27
28
29
 * \version 0.1
 * \email: navid.nikaein@eurecom.fr
 * @ingroup _mac
30

gauthier's avatar
gauthier committed
31
 */
32

33
34
#include "COMMON/platform_types.h"
#include "COMMON/platform_constants.h"
Cedric Roux's avatar
Cedric Roux committed
35
#include "SCHED/defs.h"
36
37
38
#include "SystemInformationBlockType2.h"
//#include "RadioResourceConfigCommonSIB.h"
#include "RadioResourceConfigDedicated.h"
39
40
41
#ifdef Rel14
#include "PRACH-ConfigSIB-v1310.h"
#endif
42
43
44
#include "MeasGapConfig.h"
#include "MeasObjectToAddModList.h"
#include "TDD-Config.h"
45
#include "MAC-MainConfig.h"
46
#include "defs.h"
47
#include "proto.h"
48
49
50
#include "extern.h"
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
51

52
#include "common/ran_context.h"
Cedric Roux's avatar
Cedric Roux committed
53
#if defined(Rel10) || defined(Rel14)
54
55
56
57
58
#include "MBSFN-AreaInfoList-r9.h"
#include "MBSFN-AreaInfo-r9.h"
#include "MBSFN-SubframeConfigList.h"
#include "PMCH-InfoList-r9.h"
#endif
59

60
extern RAN_CONTEXT_t RC;
61
extern int l2_init_eNB(void);
62
extern void mac_top_init_eNB(void);
63
extern void mac_init_cell_params(int Mod_idP,int CC_idP);
64
extern void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
65

66
67
extern uint8_t nfapi_mode;

68
/* sec 5.9, 36.321: MAC Reset Procedure */
69
70
void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index)
{
gauthier's avatar
gauthier committed
71

72
  //Resetting Bj
gauthier's avatar
gauthier committed
73
74
75
  UE_mac_inst[module_idP].scheduling_info.Bj[0] = 0;
  UE_mac_inst[module_idP].scheduling_info.Bj[1] = 0;
  UE_mac_inst[module_idP].scheduling_info.Bj[2] = 0;
76

77
  //Stopping all timers
gauthier's avatar
gauthier committed
78

79
  //timeAlignmentTimer expires
gauthier's avatar
gauthier committed
80

81
  // PHY changes for UE MAC reset
82
  phy_reset_ue(module_idP,0,eNB_index);
gauthier's avatar
gauthier committed
83

84
85
  // notify RRC to relase PUCCH/SRS
  // cancel all pending SRs
gauthier's avatar
gauthier committed
86
87
  UE_mac_inst[module_idP].scheduling_info.SR_pending=0;
  UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0;
fnabet's avatar
fnabet committed
88
89
90

//Set BSR Trigger Bmp and remove timer flags
  UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE;
91

92
  // stop ongoing RACH procedure
gauthier's avatar
gauthier committed
93

94
  // discard explicitly signaled ra_PreambleIndex and ra_RACH_MaskIndex, if any
gauthier's avatar
gauthier committed
95
96
97
  UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex  = 0; // check!
  UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0;

knopp's avatar
   
knopp committed
98

gauthier's avatar
gauthier committed
99
100
  ue_init_mac(module_idP); //This will hopefully do the rest of the MAC reset procedure

101
102
}

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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
int32_t **rxdata;
int32_t **txdata;


typedef struct eutra_bandentry_s {
    int16_t band;
    uint32_t ul_min;
    uint32_t ul_max;
    uint32_t dl_min;
    uint32_t dl_max;
    uint32_t N_OFFs_DL;
} eutra_bandentry_t;

typedef struct band_info_s {
    int nbands;
    eutra_bandentry_t band_info[100];
} band_info_t;



static const eutra_bandentry_t eutra_bandtable[] = {
  { 1, 19200, 19800, 21100, 21700, 0},
  { 2, 18500, 19100, 19300, 19900, 6000},
  { 3, 17100, 17850, 18050, 18800, 12000},
  { 4, 17100, 17550, 21100, 21550, 19500},
  { 5,  8240,  8490,  8690,  8940, 24000},
  { 6,  8300,  8400,  8750,  8850, 26500},
  { 7, 25000, 25700, 26200, 26900, 27500},
  { 8,  8800, 9150 ,  9250,  9600, 34500},
  { 9, 17499, 17849, 18449, 18799, 38000},
  {10, 17100, 17700, 21100, 21700, 41500},
  {11, 14279, 14529, 14759, 15009, 47500},
  {12,  6980,  7160,  7280,  7460, 50100},
  {13,  7770,  7870,  7460,  7560, 51800},
  {14,  7880,  7980,  7580,  7680, 52800},
  {17,  7040,  7160,  7340,  7460, 57300},
  {18,  8150,  9650,  8600, 10100, 58500},
  {19,  8300,  8450,  8750,  8900, 60000},
  {20,  8320,  8620,  7910,  8210, 61500},
  {21, 14479, 14629, 14959, 15109, 64500},
  {22, 34100, 34900, 35100, 35900, 66000},
  {23, 20000, 20200, 21800, 22000, 75000},
  {24, 16126, 16605, 15250, 15590, 77000},
  {25, 18500, 19150, 19300, 19950, 80400},
  {26, 8140 ,  8490,  8590,  8940, 86900},
  {27, 8070 ,  8240,  8520,  8690, 90400},
  {28, 7030 ,  7580,  7580,  8130, 92100},
  {29, 0    ,  0   ,  7170,  7280, 96600},
  {30, 23050, 23250, 23500, 23600, 97700},
  {31, 45250, 34900, 46250, 35900, 98700},
  {32, 0    , 0    , 14520, 14960, 99200},
  {33, 19000, 19200, 19000, 19200, 36000},
  {34, 20100, 20250, 20100, 20250, 36200},
  {35, 18500, 19100, 18500, 19100, 36350},
  {36, 19300, 19900, 19300, 19900, 36950},
  {37, 19100, 19300, 19100, 19300, 37550},
  {38, 25700, 26200, 25700, 26300, 37750},
  {39, 18800, 19200, 18800, 19200, 38250},
  {40, 23000, 24000, 23000, 24000, 38650},
  {41, 24960, 26900, 24960, 26900, 39650},
  {42, 34000, 36000, 34000, 36000, 41590},
  {43, 36000, 38000, 36000, 38000, 43590},
  {44, 7030 ,  8030,  7030,  8030, 45590},
  {45, 14470, 14670, 14470, 14670, 46590},
  {46, 51500, 59250, 51500, 59250, 46790},
  {65, 19200, 20100, 21100, 22000, 65536},
  {66, 17100, 18000, 21100, 22000, 66436},
  {67, 0    , 0    ,  7380,  7580, 67336},
  {68, 6980 , 7280 ,  7530,  7830, 67536}};

uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq,uint32_t bw) {

  uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq/100000;
  int bw_by_100                   = bw/100;

  int i;

  AssertFatal(eutra_bandP < 69,"eutra_band %d > 68\n",eutra_bandP);
  for (i=0;i<69 && eutra_bandtable[i].band!=eutra_bandP;i++);

  AssertFatal(dl_CarrierFreq_by_100k>=eutra_bandtable[i].dl_min,
	      "Band %d, bw %u : DL carrier frequency %u Hz < %u\n",
	      eutra_bandP,bw,dl_CarrierFreq,eutra_bandtable[i].dl_min);
  AssertFatal(dl_CarrierFreq_by_100k<=(eutra_bandtable[i].dl_max-bw_by_100),
	      "Band %d, bw %u: DL carrier frequency %u Hz > %d\n",
	      eutra_bandP,bw,dl_CarrierFreq,eutra_bandtable[i].dl_max-bw_by_100);


  return(dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min + (eutra_bandtable[i].N_OFFs_DL/10));
}

uint32_t from_earfcn(int eutra_bandP,uint32_t dl_earfcn) {

  int i;

  AssertFatal(eutra_bandP < 69,"eutra_band %d > 68\n",eutra_bandP);
  for (i=0;i<69 && eutra_bandtable[i].band!=eutra_bandP;i++);

  return(eutra_bandtable[i].dl_min + (dl_earfcn-(eutra_bandtable[i].N_OFFs_DL/10)))*100000;
}


205
206
207
208
209
int32_t get_uldl_offset(int eutra_bandP) {
  int i;

  for (i=0;i<69 && eutra_bandtable[i].band!=eutra_bandP;i++);
  return(eutra_bandtable[i].dl_min - eutra_bandtable[i].ul_min);
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
}

uint32_t bw_table[6] = {6*180,15*180,25*180,50*180,75*180,100*180};

void config_mib(int                 Mod_idP,
		int                 CC_idP,
		int                 eutra_bandP,  
		int                 dl_BandwidthP,
		PHICH_Config_t      *phich_configP,
		int                 Nid_cellP,
		int                 NcpP,
		int                 p_eNBP,
		uint32_t            dl_CarrierFreqP,
		uint32_t            ul_CarrierFreqP,
		uint32_t            pbch_repetitionP) {

  nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP];
227
228

  cfg->num_tlv=0;
229
230
		
  cfg->subframe_config.pcfich_power_offset.value   = 6000;  // 0dB
231
232
233
  cfg->subframe_config.pcfich_power_offset.tl.tag = NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG;
  cfg->num_tlv++;

234
  cfg->subframe_config.dl_cyclic_prefix_type.value = NcpP;
235
236
237
  cfg->subframe_config.dl_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG;
  cfg->num_tlv++;

238
  cfg->subframe_config.ul_cyclic_prefix_type.value = NcpP;
239
240
  cfg->subframe_config.ul_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG;
  cfg->num_tlv++;
241
 
242
243
244
245
246
247
248
249
  cfg->rf_config.dl_channel_bandwidth.value        = to_prb(dl_BandwidthP);
  cfg->rf_config.dl_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG;
  cfg->num_tlv++;
LOG_E(PHY,"%s() dl_BandwidthP:%d\n", __FUNCTION__, dl_BandwidthP);

  cfg->rf_config.ul_channel_bandwidth.value        = to_prb(dl_BandwidthP);
  cfg->rf_config.ul_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG;
  cfg->num_tlv++;
250
251

  cfg->rf_config.tx_antenna_ports.value            = p_eNBP;
252
253
254
  cfg->rf_config.tx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG;
  cfg->num_tlv++;

255
  cfg->rf_config.rx_antenna_ports.value            = 2;
256
257
  cfg->rf_config.rx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG;
  cfg->num_tlv++;
258
259

  cfg->nfapi_config.earfcn.value                   = to_earfcn(eutra_bandP,dl_CarrierFreqP,bw_table[dl_BandwidthP]/100);
260
261
262
  cfg->nfapi_config.earfcn.tl.tag = NFAPI_NFAPI_EARFCN_TAG;
  cfg->num_tlv++;

263
264
  cfg->nfapi_config.rf_bands.number_rf_bands       = 1;
  cfg->nfapi_config.rf_bands.rf_band[0]            = eutra_bandP;  
265
266
267
  cfg->nfapi_config.rf_bands.tl.tag = NFAPI_PHY_RF_BANDS_TAG;
  cfg->num_tlv++;

268
  cfg->phich_config.phich_resource.value           = phich_configP->phich_Resource;
269
270
271
  cfg->phich_config.phich_resource.tl.tag = NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG;
  cfg->num_tlv++;

272
  cfg->phich_config.phich_duration.value           = phich_configP->phich_Duration;
273
274
275
  cfg->phich_config.phich_duration.tl.tag = NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG;
  cfg->num_tlv++;

276
  cfg->phich_config.phich_power_offset.value       = 6000;  // 0dB
277
278
  cfg->phich_config.phich_power_offset.tl.tag = NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG;
  cfg->num_tlv++;
279
280

  cfg->sch_config.primary_synchronization_signal_epre_eprers.value   = 6000; // 0dB
281
282
283
  cfg->sch_config.primary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG;
  cfg->num_tlv++;

284
  cfg->sch_config.secondary_synchronization_signal_epre_eprers.value = 6000; // 0dB
285
286
287
  cfg->sch_config.secondary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG;
  cfg->num_tlv++;

288
  cfg->sch_config.physical_cell_id.value                             = Nid_cellP;
289
290
  cfg->sch_config.physical_cell_id.tl.tag = NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG;
  cfg->num_tlv++;
291
292
293

#ifdef Rel14
  cfg->emtc_config.pbch_repetitions_enable_r13.value                 = pbch_repetitionP;
294
295
  cfg->emtc_config.pbch_repetitions_enable_r13.tl.tag = NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG;
  cfg->num_tlv++;
296
#endif  
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320

  LOG_I(MAC,
      "%s() NFAPI_CONFIG_REQUEST(num_tlv:%u) DL_BW:%u UL_BW:%u Ncp %d,p_eNB %d,earfcn %d,band %d,phich_resource %u phich_duration %u phich_power_offset %u PSS %d SSS %d PCI %d"
#ifdef Rel14
      " PBCH repetition %d"
#endif  
      "\n"
      ,__FUNCTION__
      ,cfg->num_tlv
      ,cfg->rf_config.dl_channel_bandwidth.value
      ,cfg->rf_config.ul_channel_bandwidth.value
      ,NcpP,p_eNBP
      ,cfg->nfapi_config.earfcn.value
      ,cfg->nfapi_config.rf_bands.rf_band[0]
      ,cfg->phich_config.phich_resource.value
      ,cfg->phich_config.phich_duration.value
      ,cfg->phich_config.phich_power_offset.value
      ,cfg->sch_config.primary_synchronization_signal_epre_eprers.value
      ,cfg->sch_config.secondary_synchronization_signal_epre_eprers.value
      ,cfg->sch_config.physical_cell_id.value
#ifdef Rel14
      ,cfg->emtc_config.pbch_repetitions_enable_r13.value
#endif  
      );
321
322
323
324
325
326
327
328
329
330
}

void config_sib1(int Mod_idP,
		 int CC_idP,
		 TDD_Config_t *tdd_ConfigP) {

  nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP];

  if (tdd_ConfigP)   { //TDD
    cfg->subframe_config.duplex_mode.value                          = 0;
331
332
333
    cfg->subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG;
    cfg->num_tlv++;

334
    cfg->tdd_frame_structure_config.subframe_assignment.value       = tdd_ConfigP->subframeAssignment;
335
336
337
    cfg->tdd_frame_structure_config.subframe_assignment.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG;
    cfg->num_tlv++;

338
    cfg->tdd_frame_structure_config.special_subframe_patterns.value = tdd_ConfigP->specialSubframePatterns;
339
340
    cfg->tdd_frame_structure_config.special_subframe_patterns.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG;
    cfg->num_tlv++;
341
342
343
  }
  else { // FDD
    cfg->subframe_config.duplex_mode.value                          = 1;
344
345
    cfg->subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG;
    cfg->num_tlv++;
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
    // Note no half-duplex here
  }

  
}

int power_off_dB[6] = {78,118,140,170,188,200};

void config_sib2(int Mod_idP, 
		 int CC_idP, 
		 RadioResourceConfigCommonSIB_t   *radioResourceConfigCommonP,
#ifdef Rel14
		 RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon_BRP,
#endif
		 ARFCN_ValueEUTRA_t *ul_CArrierFreqP,
		 long *ul_BandwidthP,
		 AdditionalSpectrumEmission_t *additionalSpectrumEmissionP,
		 struct MBSFN_SubframeConfigList  *mbsfn_SubframeConfigListP) {

  nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP];

  cfg->subframe_config.pb.value               = radioResourceConfigCommonP->pdsch_ConfigCommon.p_b;
368
369
370
  cfg->subframe_config.pb.tl.tag = NFAPI_SUBFRAME_CONFIG_PB_TAG;
  cfg->num_tlv++;

371
  cfg->rf_config.reference_signal_power.value = radioResourceConfigCommonP->pdsch_ConfigCommon.referenceSignalPower;
372
373
374
  cfg->rf_config.reference_signal_power.tl.tag = NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG;
  cfg->num_tlv++;

375
  cfg->nfapi_config.max_transmit_power.value  = cfg->rf_config.reference_signal_power.value + power_off_dB[cfg->rf_config.dl_channel_bandwidth.value];
376
377
  cfg->nfapi_config.max_transmit_power.tl.tag = NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG;
  cfg->num_tlv++;
378
379

  cfg->prach_config.configuration_index.value                 = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.prach_ConfigIndex;
380
381
382
  cfg->prach_config.configuration_index.tl.tag = NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG;
  cfg->num_tlv++;

383
  cfg->prach_config.root_sequence_index.value                 = radioResourceConfigCommonP->prach_Config.rootSequenceIndex;
384
385
386
  cfg->prach_config.root_sequence_index.tl.tag = NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG;
  cfg->num_tlv++;

387
  cfg->prach_config.zero_correlation_zone_configuration.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig;
388
389
390
  cfg->prach_config.zero_correlation_zone_configuration.tl.tag = NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG;
  cfg->num_tlv++;

391
  cfg->prach_config.high_speed_flag.value                     = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.highSpeedFlag;
392
393
394
  cfg->prach_config.high_speed_flag.tl.tag = NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG;
  cfg->num_tlv++;

395
  cfg->prach_config.frequency_offset.value                    = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.prach_FreqOffset;
396
397
398
  cfg->prach_config.frequency_offset.tl.tag = NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG;
  cfg->num_tlv++;

399
400

  cfg->pusch_config.hopping_mode.value                        = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode;
401
402
403
  cfg->pusch_config.hopping_mode.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG;
  cfg->num_tlv++;

404
  cfg->pusch_config.number_of_subbands.value                  = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.n_SB;
405
406
407
  cfg->pusch_config.number_of_subbands.tl.tag = NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG;
  cfg->num_tlv++;

408
  cfg->pusch_config.hopping_offset.value                      = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset;
409
410
411
  cfg->pusch_config.hopping_offset.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG;
  cfg->num_tlv++;

412
413
414
415


		
  cfg->pucch_config.delta_pucch_shift.value                         = radioResourceConfigCommonP->pucch_ConfigCommon.deltaPUCCH_Shift;
416
417
418
  cfg->pucch_config.delta_pucch_shift.tl.tag = NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG;
  cfg->num_tlv++;

419
  cfg->pucch_config.n_cqi_rb.value                                  = radioResourceConfigCommonP->pucch_ConfigCommon.nRB_CQI;
420
421
422
  cfg->pucch_config.n_cqi_rb.tl.tag = NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG;
  cfg->num_tlv++;

423
  cfg->pucch_config.n_an_cs.value                                   = radioResourceConfigCommonP->pucch_ConfigCommon.nCS_AN;
424
425
426
  cfg->pucch_config.n_an_cs.tl.tag = NFAPI_PUCCH_CONFIG_N_AN_CS_TAG;
  cfg->num_tlv++;

427
  cfg->pucch_config.n1_pucch_an.value                               = radioResourceConfigCommonP->pucch_ConfigCommon.n1PUCCH_AN;
428
429
430
  cfg->pucch_config.n1_pucch_an.tl.tag = NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG;
  cfg->num_tlv++;

431
432

  if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled == true)
433
  {
434
    cfg->uplink_reference_signal_config.uplink_rs_hopping.value     = 1;
435
  }
436
  else if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled == true)
437
  {
438
    cfg->uplink_reference_signal_config.uplink_rs_hopping.value     = 2;
439
  }
440
  else // No hopping
441
  {
442
    cfg->uplink_reference_signal_config.uplink_rs_hopping.value     = 0;
443
444
445
  }
  cfg->uplink_reference_signal_config.uplink_rs_hopping.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG;
  cfg->num_tlv++;
446
447

  cfg->uplink_reference_signal_config.group_assignment.value        = radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH;
448
449
450
  cfg->uplink_reference_signal_config.group_assignment.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG;
  cfg->num_tlv++;

451
  cfg->uplink_reference_signal_config.cyclic_shift_1_for_drms.value = radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift;
452
453
454
  cfg->uplink_reference_signal_config.cyclic_shift_1_for_drms.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG;
  cfg->num_tlv++;

455
456
457
458

  // how to enable/disable SRS?
  if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.present==SoundingRS_UL_ConfigCommon_PR_setup) {
    cfg->srs_config.bandwidth_configuration.value                       = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig;
459
460
461
    cfg->srs_config.bandwidth_configuration.tl.tag = NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG;
    cfg->num_tlv++;

462
    cfg->srs_config.srs_subframe_configuration.value                    = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig;
463
464
465
    cfg->srs_config.srs_subframe_configuration.tl.tag = NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG;
    cfg->num_tlv++;

466
    cfg->srs_config.srs_acknack_srs_simultaneous_transmission.value     = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission;
467
468
469
    cfg->srs_config.srs_acknack_srs_simultaneous_transmission.tl.tag = NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG;
    cfg->num_tlv++;

470

471
    if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts) {
472
       cfg->srs_config.max_up_pts.value                                 = 1;
473
474
    }
    else {
475
       cfg->srs_config.max_up_pts.value                                 = 0;
476
477
478
    }
    cfg->srs_config.max_up_pts.tl.tag = NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG;
    cfg->num_tlv++;
479
480
481
482
483
484
485
  }

#ifdef Rel14
  if (RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.schedulingInfoSIB1_BR_r13>0) {
    AssertFatal(radioResourceConfigCommon_BRP!=NULL,"radioResource rou is missing\n");
    AssertFatal(radioResourceConfigCommon_BRP->ext4!=NULL,"ext4 is missing\n");
    cfg->emtc_config.prach_catm_root_sequence_index.value                 = radioResourceConfigCommon_BRP->prach_Config.rootSequenceIndex;
486
487
488
    cfg->emtc_config.prach_catm_root_sequence_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG;
    cfg->num_tlv++;

489
    cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.value = radioResourceConfigCommon_BRP->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig;
490
491
492
    cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG;
    cfg->num_tlv++;

493
    cfg->emtc_config.prach_catm_high_speed_flag.value                     = radioResourceConfigCommon_BRP->prach_Config.prach_ConfigInfo.highSpeedFlag;
494
495
    cfg->emtc_config.prach_catm_high_speed_flag.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG;
    cfg->num_tlv++;
496
 
497
    struct PRACH_ConfigSIB_v1310 *ext4_prach=radioResourceConfigCommon_BRP->ext4->prach_ConfigCommon_v1310; 
498
499

    PRACH_ParametersListCE_r13_t	 *prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
knopp's avatar
knopp committed
500

501
502
    PRACH_ParametersCE_r13_t *p;
    cfg->emtc_config.prach_ce_level_0_enable.value=0;
503
504
505
    cfg->emtc_config.prach_ce_level_0_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG;
    cfg->num_tlv++;
 
506
    cfg->emtc_config.prach_ce_level_1_enable.value=0;
507
508
509
    cfg->emtc_config.prach_ce_level_1_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG;
    cfg->num_tlv++;
 
510
    cfg->emtc_config.prach_ce_level_2_enable.value=0;
511
512
513
    cfg->emtc_config.prach_ce_level_2_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG;
    cfg->num_tlv++;
 
514
    cfg->emtc_config.prach_ce_level_3_enable.value=0;
515
516
517
    cfg->emtc_config.prach_ce_level_3_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG;
    cfg->num_tlv++;
 
518
519
520
    switch (prach_ParametersListCE_r13->list.count) {
    case 4:
      p=prach_ParametersListCE_r13->list.array[3];
521
      cfg->emtc_config.prach_ce_level_3_enable.value                            = 1;
522
523
524
      cfg->emtc_config.prach_ce_level_3_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG;
      cfg->num_tlv++;

525
      cfg->emtc_config.prach_ce_level_3_configuration_index.value               = p->prach_ConfigIndex_r13;
526
527
528
      cfg->emtc_config.prach_ce_level_3_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG;
      cfg->num_tlv++;

529
      cfg->emtc_config.prach_ce_level_3_frequency_offset.value                  = p->prach_FreqOffset_r13;
530
531
532
      cfg->emtc_config.prach_ce_level_3_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG;
      cfg->num_tlv++;

533
      cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13;
534
535
536
537
      cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
      cfg->num_tlv++;

      if (p->prach_StartingSubframe_r13) {
538
	cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.value   = *p->prach_StartingSubframe_r13;
539
540
541
542
	cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.tl.tag  = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG;
        cfg->num_tlv++;
      }

543
      cfg->emtc_config.prach_ce_level_3_hopping_enable.value                    = p->prach_HoppingConfig_r13;
544
545
546
      cfg->emtc_config.prach_ce_level_3_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG;
      cfg->num_tlv++;

547
      cfg->emtc_config.prach_ce_level_3_hopping_offset.value                    = cfg->rf_config.ul_channel_bandwidth.value-6;
548
549
550
      cfg->emtc_config.prach_ce_level_3_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG;
      cfg->num_tlv++;

551
552
    case 3:
      p=prach_ParametersListCE_r13->list.array[2];
553
      cfg->emtc_config.prach_ce_level_2_enable.value                            = 1;
554
555
556
      cfg->emtc_config.prach_ce_level_2_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG;
      cfg->num_tlv++;

557
      cfg->emtc_config.prach_ce_level_2_configuration_index.value               = p->prach_ConfigIndex_r13;
558
559
560
      cfg->emtc_config.prach_ce_level_2_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG;
      cfg->num_tlv++;

561
      cfg->emtc_config.prach_ce_level_2_frequency_offset.value                  = p->prach_FreqOffset_r13;
562
563
564
      cfg->emtc_config.prach_ce_level_2_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG;
      cfg->num_tlv++;

565
      cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13;
566
567
568
569
      cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
      cfg->num_tlv++;

      if (p->prach_StartingSubframe_r13) {
570
	cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.value   = *p->prach_StartingSubframe_r13;
571
572
573
574
	cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.tl.tag  = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG;
        cfg->num_tlv++;
      }

575
      cfg->emtc_config.prach_ce_level_2_hopping_enable.value                    = p->prach_HoppingConfig_r13;
576
577
578
      cfg->emtc_config.prach_ce_level_2_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG;
      cfg->num_tlv++;

579
      cfg->emtc_config.prach_ce_level_2_hopping_offset.value                    = cfg->rf_config.ul_channel_bandwidth.value-6;
580
581
582
      cfg->emtc_config.prach_ce_level_2_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG;
      cfg->num_tlv++;

583
584
    case 2:
      p=prach_ParametersListCE_r13->list.array[1];
585
      cfg->emtc_config.prach_ce_level_1_enable.value                            = 1;
586
587
588
      cfg->emtc_config.prach_ce_level_1_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG;
      cfg->num_tlv++;

589
      cfg->emtc_config.prach_ce_level_1_configuration_index.value               = p->prach_ConfigIndex_r13;
590
591
592
      cfg->emtc_config.prach_ce_level_1_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG;
      cfg->num_tlv++;

593
      cfg->emtc_config.prach_ce_level_1_frequency_offset.value                  = p->prach_FreqOffset_r13;
594
595
596
      cfg->emtc_config.prach_ce_level_1_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG;
      cfg->num_tlv++;

597
      cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13;
598
599
600
601
      cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
      cfg->num_tlv++;

      if (p->prach_StartingSubframe_r13) {
602
	cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.value   = *p->prach_StartingSubframe_r13;
603
604
605
606
	cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.tl.tag  = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG;
        cfg->num_tlv++;
      }
 
607
      cfg->emtc_config.prach_ce_level_1_hopping_enable.value                    = p->prach_HoppingConfig_r13;
608
609
610
      cfg->emtc_config.prach_ce_level_1_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG;
      cfg->num_tlv++;
 
611
      cfg->emtc_config.prach_ce_level_1_hopping_offset.value                    = cfg->rf_config.ul_channel_bandwidth.value-6;
612
613
614
      cfg->emtc_config.prach_ce_level_1_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG;
      cfg->num_tlv++;
 
615
616
    case 1:
      p=prach_ParametersListCE_r13->list.array[0];
617
      cfg->emtc_config.prach_ce_level_0_enable.value                            = 1;
618
619
620
      cfg->emtc_config.prach_ce_level_0_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG;
      cfg->num_tlv++;
 
621
      cfg->emtc_config.prach_ce_level_0_configuration_index.value               = p->prach_ConfigIndex_r13;
622
623
624
      cfg->emtc_config.prach_ce_level_0_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG;
      cfg->num_tlv++;
 
625
      cfg->emtc_config.prach_ce_level_0_frequency_offset.value                  = p->prach_FreqOffset_r13;
626
627
628
      cfg->emtc_config.prach_ce_level_0_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG;
      cfg->num_tlv++;
 
629
      cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13;
630
631
632
633
      cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
      cfg->num_tlv++;
 
      if (p->prach_StartingSubframe_r13) {
634
	cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.value   = *p->prach_StartingSubframe_r13;
635
636
637
638
	cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.tl.tag  = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG;
        cfg->num_tlv++;
      }
 
639
      cfg->emtc_config.prach_ce_level_0_hopping_enable.value                    = p->prach_HoppingConfig_r13;
640
641
642
      cfg->emtc_config.prach_ce_level_0_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG;
      cfg->num_tlv++;
 
643
      cfg->emtc_config.prach_ce_level_0_hopping_offset.value                    = cfg->rf_config.ul_channel_bandwidth.value-6;
644
645
      cfg->emtc_config.prach_ce_level_0_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG;
      cfg->num_tlv++;
646
647
648
649
650
651
652
653
654
655
    }

    struct FreqHoppingParameters_r13 *ext4_freqHoppingParameters = radioResourceConfigCommonP->ext4->freqHoppingParameters_r13;
    if ((ext4_freqHoppingParameters) && 
	(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13)){
      switch(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->present) {
      case 	FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_NOTHING:	/* No components present */
	break;
      case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_FDD_r13:
	cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_FDD_r13;
656
657
	cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG;
        cfg->num_tlv++;
658
659
660
	break;
      case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_TDD_r13:
	cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_TDD_r13;
661
662
	cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG;
        cfg->num_tlv++;
663
664
665
666
667
668
669
670
671
672
	break;
      }
    }
    if ((ext4_freqHoppingParameters) && 
	(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13)){
      switch(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->present) {
      case 	FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_NOTHING:	/* No components present */
	break;
      case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_FDD_r13:
	cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_FDD_r13;
673
674
	cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG;
        cfg->num_tlv++;
675
676
677
	break;
      case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_TDD_r13:
	cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_TDD_r13;
678
679
	cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG;
        cfg->num_tlv++;
680
681
682
683
684
685
686
687
688
689
690
691
692
693
	break;
      }
    }
  }
#endif

}

void config_dedicated(int Mod_idP, 
		      int CC_idP, 
		      uint16_t rnti, 
		      struct PhysicalConfigDedicated  *physicalConfigDedicated) {

}
694

695
696
697
698
699
700
void config_dedicated_scell(int Mod_idP, 
			    uint16_t rnti, 
			    SCellToAddMod_r10_t *sCellToAddMod_r10) {

}

701
702
703
704
705
706
707
int rrc_mac_config_req_eNB(module_id_t                      Mod_idP,
			   int                              CC_idP,
			   int                              physCellId,
			   int                              p_eNB,
			   int                              Ncp,
			   int                              eutra_band,
			   uint32_t                         dl_CarrierFreq,
708
709
710
#ifdef Rel14
                           int                              pbch_repetition,
#endif
711
			   rnti_t                           rntiP,
712
713
			   BCCH_BCH_Message_t               *mib,
			   RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon,
714
715
716
#ifdef Rel14
			   RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon_BR,
#endif
717
			   struct PhysicalConfigDedicated  *physicalConfigDedicated,
Cedric Roux's avatar
Cedric Roux committed
718
#if defined(Rel10) || defined(Rel14)
719
720
			   SCellToAddMod_r10_t *sCellToAddMod_r10,
			   //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
knopp's avatar
   
knopp committed
721
#endif
722
723
724
725
726
727
728
729
730
731
732
733
			   MeasObjectToAddMod_t                    **measObj,
			   MAC_MainConfig_t                        *mac_MainConfig,
			   long                                    logicalChannelIdentity,
			   LogicalChannelConfig_t                  *logicalChannelConfig,
			   MeasGapConfig_t                         *measGapConfig,
			   TDD_Config_t                            *tdd_Config,
			   MobilityControlInfo_t                   *mobilityControlInfo,
			   SchedulingInfoList_t                    *schedulingInfoList,
			   uint32_t                                ul_CarrierFreq,
			   long                                    *ul_Bandwidth,
			   AdditionalSpectrumEmission_t            *additionalSpectrumEmission,
			   struct MBSFN_SubframeConfigList         *mbsfn_SubframeConfigList
Cedric Roux's avatar
Cedric Roux committed
734
#if defined(Rel10) || defined(Rel14)
735
736
737
738
739
740
741
			   ,uint8_t                                MBMS_Flag,
			   MBSFN_AreaInfoList_r9_t                 *mbsfn_AreaInfoList,
			   PMCH_InfoList_r9_t                      *pmch_InfoList
#endif
#ifdef Rel14
			   ,
			   SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext
742
#endif
743
744
			   ) {
			   
745
  int i;
746

747
  int UE_id = -1;
748
  eNB_MAC_INST *eNB = RC.mac[Mod_idP];
749
750
  UE_list_t *UE_list= &eNB->UE_list;

gauthier's avatar
gauthier committed
751
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN);
752

753
  LOG_E(MAC, "RC.mac:%p mib:%p\n", RC.mac, mib);
754
755

  if (RC.mac == NULL) {
756
757
    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);

758
    l2_init_eNB();
759

760
    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
761
    mac_top_init_eNB();
762
    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
763
  }
764

765
  if (mib!=NULL) {
766
    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
767
768
769
770
771
772
      RC.mac[Mod_idP]->common_channels[CC_idP].mib             = mib;
      RC.mac[Mod_idP]->common_channels[CC_idP].physCellId      = physCellId;
      RC.mac[Mod_idP]->common_channels[CC_idP].p_eNB           = p_eNB;
      RC.mac[Mod_idP]->common_channels[CC_idP].Ncp             = Ncp;
      RC.mac[Mod_idP]->common_channels[CC_idP].eutra_band      = eutra_band;
      RC.mac[Mod_idP]->common_channels[CC_idP].dl_CarrierFreq  = dl_CarrierFreq;
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799

    LOG_I(MAC,
	  "Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d,Nid_cell %d,p %d,DL freq %u,phich_config.resource %d, phich_config.duration %d)\n",
	  Mod_idP, 
	  CC_idP, 
	  eutra_band, 
	  to_prb((int)mib->message.dl_Bandwidth), 
	  physCellId, 
	  p_eNB,
	  dl_CarrierFreq,
	  (int)mib->message.phich_Config.phich_Resource,
	  (int)mib->message.phich_Config.phich_Duration);

    config_mib(Mod_idP,CC_idP,
	       eutra_band,
	       mib->message.dl_Bandwidth,
	       &mib->message.phich_Config,
	       physCellId,
	       Ncp,
	       p_eNB,
	       dl_CarrierFreq,
	       ul_CarrierFreq
#ifdef Rel14
	       ,pbch_repetition
#endif
	       );

800
    mac_init_cell_params(Mod_idP,CC_idP);
801
802
803
  if (schedulingInfoList!=NULL)  {
    RC.mac[Mod_idP]->common_channels[CC_idP].tdd_Config         = tdd_Config;    
    RC.mac[Mod_idP]->common_channels[CC_idP].schedulingInfoList = schedulingInfoList;    
804
    config_sib1(Mod_idP,CC_idP,tdd_Config);
805
  }
806
807
808
809
810
#ifdef Rel14
  if (sib1_v13ext != NULL) {
    RC.mac[Mod_idP]->common_channels[CC_idP].sib1_v13ext        = sib1_v13ext;    
  }
#endif
811
  if (radioResourceConfigCommon!=NULL) {
812
813
814
815
816
817
818
819
820
      LOG_I(MAC,"[CONFIG]SIB2/3 Contents (partial)\n");
      LOG_I(MAC,"[CONFIG]pusch_config_common.n_SB = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB);
      LOG_I(MAC,"[CONFIG]pusch_config_common.hoppingMode = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode);
      LOG_I(MAC,"[CONFIG]pusch_config_common.pusch_HoppingOffset = %ld\n",  radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset);
      LOG_I(MAC,"[CONFIG]pusch_config_common.enable64QAM = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM);
      LOG_I(MAC,"[CONFIG]pusch_config_common.groupHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled);
      LOG_I(MAC,"[CONFIG]pusch_config_common.groupAssignmentPUSCH = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH);
      LOG_I(MAC,"[CONFIG]pusch_config_common.sequenceHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled);
      LOG_I(MAC,"[CONFIG]pusch_config_common.cyclicShift  = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift);
821

822
823
      AssertFatal(radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx > 0,
		  "radioResourceconfigCommon %d == 0\n",
824
		  (int)radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx);
825

826
827
828
      RC.mac[Mod_idP]->common_channels[CC_idP].radioResourceConfigCommon = radioResourceConfigCommon;
      if (ul_CarrierFreq>0) RC.mac[Mod_idP]->common_channels[CC_idP].ul_CarrierFreq          = ul_CarrierFreq;
      if (ul_Bandwidth) RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth                = *ul_Bandwidth;
829
830
      else RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth                             = RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.dl_Bandwidth;

831
832
833
834
835
836
      config_sib2(Mod_idP, CC_idP, 
		  radioResourceConfigCommon, 
#ifdef Rel14
		  radioResourceConfigCommon_BR, 
#endif
		  NULL, ul_Bandwidth, additionalSpectrumEmission, mbsfn_SubframeConfigList);
837
838


839
  }
840
  } // mib != NULL
841

842

843
  // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup
844
  if (logicalChannelConfig!= NULL) { // check for eMTC specific things
845
846
    UE_id = find_UE_id(Mod_idP, rntiP);

847
848
849
850
851
852
853
    if (UE_id == -1) {
      LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
    } else {
      if (logicalChannelConfig)
	UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup;
      else
	UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = 0;
854
    }
855
  }
856
857
858
  

  if (physicalConfigDedicated != NULL) {
859
860
    UE_id = find_UE_id(Mod_idP, rntiP);

861
862
863
    if (UE_id == -1)
      LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
    else
864
      UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated=physicalConfigDedicated;
865
  } 
866

867
868


fnabet's avatar
fnabet committed
869

870
#if defined(Rel10) || defined(Rel14)
871

872
  if (sCellToAddMod_r10 != NULL) {
873
    UE_id = find_UE_id(Mod_idP, rntiP);
874
875
876
    if (UE_id == -1)
      LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
    else
877
      config_dedicated_scell(Mod_idP,rntiP,sCellToAddMod_r10);
878
879
    
  }
fnabet's avatar
fnabet committed
880

881
#endif
882

fnabet's avatar
fnabet committed
883

884
885


886
887
888
889
890
891
892
893
  if (mbsfn_SubframeConfigList != NULL) {
    LOG_I(MAC,"[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_idP, mbsfn_SubframeConfigList->list.count);
    RC.mac[Mod_idP]->common_channels[0].num_sf_allocation_pattern= mbsfn_SubframeConfigList->list.count;
    
    for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) {
      RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i];
      LOG_I(MAC, "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is  %x\n", Mod_idP, i,
	    RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]);
894
    }
895
896
897
898
    
#ifdef Rel10
    RC.mac[Mod_idP]->common_channels[0].MBMS_flag = MBMS_Flag;
#endif
899
  }
900

Cedric Roux's avatar
Cedric Roux committed
901
#if defined(Rel10) || defined(Rel14)
902

903
904
905
906
907
908
909
910
911
  if (mbsfn_AreaInfoList != NULL) {
      // One eNB could be part of multiple mbsfn syc area, this could change over time so reset each time
    LOG_I(MAC,"[eNB %d][CONFIG] Received %d MBSFN Area Info\n", Mod_idP, mbsfn_AreaInfoList->list.count);
    RC.mac[Mod_idP]->common_channels[0].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count;
    
    for (i =0; i< mbsfn_AreaInfoList->list.count; i++) {
      RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i];
      LOG_I(MAC,"[eNB %d][CONFIG] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n", Mod_idP,i,
	    RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
912
      //      config_sib13(Mod_idP,0,i,RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i]->mbsfn_AreaId_r9);
913
914
    }
  } 
915

916
    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
917
  if (pmch_InfoList != NULL) {
918

919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
    //    LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9));

    LOG_I(MAC, "[CONFIG] Number of PMCH in this MBSFN Area %d\n", pmch_InfoList->list.count);
    
    for (i =0; i< pmch_InfoList->list.count; i++) {
      RC.mac[Mod_idP]->common_channels[0].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9;
      
      LOG_I(MAC, "[CONFIG] PMCH[%d]: This PMCH stop (sf_AllocEnd_r9) at subframe  %ldth\n", i,
	    RC.mac[Mod_idP]->common_channels[0].pmch_Config[i]->sf_AllocEnd_r9);
      LOG_I(MAC, "[CONFIG] PMCH[%d]: mch_Scheduling_Period = %ld\n", i,
	    RC.mac[Mod_idP]->common_channels[0].pmch_Config[i]->mch_SchedulingPeriod_r9);
      LOG_I(MAC, "[CONFIG] PMCH[%d]: dataMCS = %ld\n", i,
	    RC.mac[Mod_idP]->common_channels[0].pmch_Config[i]->dataMCS_r9);
      
      // MBMS session info list in each MCH
      RC.mac[Mod_idP]->common_channels[0].mbms_SessionList[i] = &pmch_InfoList->list.array[i]->mbms_SessionInfoList_r9;
      LOG_I(MAC, "PMCH[%d] Number of session (MTCH) is: %d\n",i, RC.mac[Mod_idP]->common_channels[0].mbms_SessionList[i]->list.count);
knopp's avatar
   
knopp committed
936
937
    }
  }
938

knopp's avatar
   
knopp committed
939
#endif
940

941
  LOG_E(MAC, "%s() %s:%d RC.mac[Mod_idP]->if_inst->PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.mac[Mod_idP]->if_inst->PHY_config_req);
942

943
944
945
946
947
  // if in nFAPI mode 
  if (
      (nfapi_mode == 1 || nfapi_mode == 2) &&
      (RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL)
    )
948
949
950
951
952
953
954
  {
    while(RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) {
      // DJP AssertFatal(RC.mac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n");
      usleep(100 * 1000);
      printf("Waiting for PHY_config_req\n");
    }
  }
955
956
957
958
959
960
961
962
963
964

  PHY_Config_t phycfg;
  phycfg.Mod_id = Mod_idP;
  phycfg.CC_id  = CC_idP;
  phycfg.cfg    = &RC.mac[Mod_idP]->config[CC_idP];

  LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
  if (RC.mac[Mod_idP]->if_inst->PHY_config_req) RC.mac[Mod_idP]->if_inst->PHY_config_req(&phycfg); 
  LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);

965
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
966

967
968
969
  return(0);			   

}
970

971
972
973
974
975
976
977
int
rrc_mac_config_req_ue(
  module_id_t                      Mod_idP,
  int                              CC_idP,
  uint8_t                          eNB_index,
  RadioResourceConfigCommonSIB_t  *radioResourceConfigCommon,
  struct PhysicalConfigDedicated  *physicalConfigDedicated,
978
#if defined(Rel10) || defined(Rel14)
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
  SCellToAddMod_r10_t *sCellToAddMod_r10,
  //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
#endif
  MeasObjectToAddMod_t           **measObj,
  MAC_MainConfig_t                *mac_MainConfig,
  long                             logicalChannelIdentity,
  LogicalChannelConfig_t          *logicalChannelConfig,
  MeasGapConfig_t                 *measGapConfig,
  TDD_Config_t                    *tdd_Config,
  MobilityControlInfo_t           *mobilityControlInfo,
  uint8_t                              *SIwindowsize,
  uint16_t                             *SIperiod,
  ARFCN_ValueEUTRA_t              *ul_CarrierFreq,
  long                            *ul_Bandwidth,
  AdditionalSpectrumEmission_t    *additionalSpectrumEmission,
  struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList
995
#if defined(Rel10) || defined(Rel14)
996
997
998
999
1000
1001
1002
1003
1004
1005
  ,uint8_t                              MBMS_Flag,
  MBSFN_AreaInfoList_r9_t         *mbsfn_AreaInfoList,
  PMCH_InfoList_r9_t              *pmch_InfoList
#endif
#ifdef CBA
  ,uint8_t                              num_active_cba_groups,
  uint16_t                              cba_rnti
#endif
                      )
{
1006

1007
  int i;
1008

1009
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN);
1010

1011
1012
1013
1014
1015
1016
  LOG_I(MAC,"[CONFIG][UE %d] Configuring MAC/PHY from eNB %d\n",Mod_idP,eNB_index);
  
  if (tdd_Config != NULL) {
    UE_mac_inst[Mod_idP].tdd_Config = tdd_Config;
  }
 
1017

1018
  if (tdd_Config && SIwindowsize && SIperiod) {
1019
    phy_config_sib1_ue(Mod_idP,0,eNB_index,tdd_Config,*SIwindowsize,*SIperiod);
1020
  }
1021

1022
1023
  if (radioResourceConfigCommon!=NULL) {
    UE_mac_inst[Mod_idP].radioResourceConfigCommon = radioResourceConfigCommon;
1024
    phy_config_sib2_ue(Mod_idP,0,eNB_index,radioResourceConfigCommon,ul_CarrierFreq,ul_Bandwidth,additionalSpectrumEmission,mbsfn_SubframeConfigList);
1025
  }
1026

1027
1028
1029
1030
1031
1032