emu_transport.c 17.3 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
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
/*! \file phy_emulation.c
Cedric Roux's avatar
Cedric Roux committed
23
24
 *  \brief implements the underlying protocol for emulated data exchange over Ethernet using IP multicast
 *  \author Navid Nikaein
25
 *  \date 2011 - 2014
Cedric Roux's avatar
Cedric Roux committed
26
27
28
29
 *  \version 1.1
 *  \company Eurecom
 *  \email: navid.nikaein@eurecom.fr
 */
30
31
32
33


#include "PHY/defs.h"
#include "PHY/extern.h"
34
#include "common/ran_context.h"
35
36
#include "defs.h"
#include "extern.h"
Cedric Roux's avatar
Cedric Roux committed
37
#include "proto.h"
38
39
40
41
42
#include "UTIL/OCG/OCG.h"
#include "UTIL/OCG/OCG_extern.h"
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"

Cedric Roux's avatar
Cedric Roux committed
43
44
45
extern unsigned int Master_list_rx;

extern unsigned char NB_INST;
46
47
48
//#define DEBUG_CONTROL 1
//#define DEBUG_EMU   1

Cedric Roux's avatar
Cedric Roux committed
49
50
void emu_transport_sync(void)
{
51
52
  LOG_D(EMU, "Entering EMU transport SYNC is primary master %d\n",
        oai_emulation.info.is_primary_master);
Cedric Roux's avatar
Cedric Roux committed
53

54
  if (oai_emulation.info.is_primary_master == 0) {
Cedric Roux's avatar
Cedric Roux committed
55
retry:
56
57
58
59
60
61
62
63
    bypass_tx_data(WAIT_SM_TRANSPORT,0,0);
    // just wait to recieve the  master 0 msg
    Master_list_rx = oai_emulation.info.master_list - 1;

    if (bypass_rx_data(0,0,0,1) == -1) {
      /* In case the master is not ready at time we send the first message */
      sleep(1);
      goto retry;
Cedric Roux's avatar
Cedric Roux committed
64
    }
65
66
67
68
  } else {
    bypass_rx_data(0,0,0,0);
    bypass_tx_data(WAIT_PM_TRANSPORT,0,0);
  }
69

70
  if (oai_emulation.info.master_list!=0) {
Cedric Roux's avatar
Cedric Roux committed
71
retry2:
72
    bypass_tx_data(SYNC_TRANSPORT,0,0);
73

74
75
76
    if (bypass_rx_data(0,0,0,0) == -1) {
      goto retry2;
    }
77

78
79
80
    // i received the sync from all secondary masters
    if (emu_rx_status == SYNCED_TRANSPORT) {
      emu_tx_status = SYNCED_TRANSPORT;
81
    }
82
83
84
85
86
87

    LOG_D(EMU,"TX secondary master SYNC_TRANSPORT state \n");
  }

  LOG_D(EMU, "Leaving EMU transport SYNC is primary master %d\n",
        oai_emulation.info.is_primary_master);
88
89
}

Cedric Roux's avatar
Cedric Roux committed
90
91
92
93
94
void emu_transport(unsigned int frame, unsigned int last_slot,
                   unsigned int next_slot,lte_subframe_t direction,
                   unsigned char frame_type,
                   int ethernet_flag )
{
95
96
97
  if (ethernet_flag == 0) {
    return;
  }
Cedric Roux's avatar
Cedric Roux committed
98

gauthier's avatar
gauthier committed
99
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(
100
    VCD_SIGNAL_DUMPER_FUNCTIONS_EMU_TRANSPORT, VCD_FUNCTION_IN);
Cedric Roux's avatar
Cedric Roux committed
101

102
103
104
  if ((frame_type == 1) &&  (direction == SF_S)) {
    if ((next_slot % 2) == 0) {
      emu_transport_DL(frame, last_slot, next_slot);
Cedric Roux's avatar
Cedric Roux committed
105
    } else {
106
107
108
109
110
111
112
113
114
115
116
117
118
119
      emu_transport_UL(frame, last_slot , next_slot);
    }

    //DL
  } else {
    if ((next_slot % 2) == 0) {
      if (((frame_type == 1) && (direction == SF_DL )) || (frame_type == 0) ) {
        emu_transport_DL(frame, last_slot, next_slot);
      }
    }

    // UL
    if (((frame_type == 1) && (direction == SF_UL)) || (frame_type == 0) ) {
      emu_transport_UL(frame, last_slot, next_slot);
120
    }
121
122
  }

gauthier's avatar
gauthier committed
123
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(
124
    VCD_SIGNAL_DUMPER_FUNCTIONS_EMU_TRANSPORT, VCD_FUNCTION_OUT);
125
126
127
}


Cedric Roux's avatar
Cedric Roux committed
128
129
130
void emu_transport_DL(unsigned int frame, unsigned int last_slot,
                      unsigned int next_slot)
{
131
132
133
134
135
136
137
138
139
140
  LOG_D(EMU, "Entering EMU transport DL, is primary master %d\n",
        oai_emulation.info.is_primary_master);

  if (oai_emulation.info.is_primary_master == 0) {
    if (oai_emulation.info.nb_enb_local > 0) { // send in DL if
      bypass_tx_data(ENB_TRANSPORT, frame, next_slot);
      bypass_rx_data(frame, last_slot, next_slot, 1);
    } else {
      bypass_tx_data(WAIT_SM_TRANSPORT,frame,next_slot);
      bypass_rx_data(frame, last_slot, next_slot, 0);
Cedric Roux's avatar
Cedric Roux committed
141
    }
142
143
144
145
146
147
148
149
150
  } else { // PM
    if (oai_emulation.info.nb_enb_local>0) { // send in DL if
      bypass_rx_data(frame, last_slot, next_slot, 1);
      bypass_tx_data(ENB_TRANSPORT, frame, next_slot);
    } else {
      bypass_rx_data(frame, last_slot, next_slot, 0);
      bypass_tx_data(WAIT_SM_TRANSPORT,frame,next_slot);
    }
  }
151

152
153
  LOG_D(EMU, "Leaving EMU transport DL, is primary master %d\n",
        oai_emulation.info.is_primary_master);
Cedric Roux's avatar
Cedric Roux committed
154
}
155

Cedric Roux's avatar
Cedric Roux committed
156
157
158
void emu_transport_UL(unsigned int frame, unsigned int last_slot,
                      unsigned int next_slot)
{
159
160
161
162
163
164
165
  LOG_D(EMU, "Entering EMU transport UL, is primary master %d\n",
        oai_emulation.info.is_primary_master);

  if (oai_emulation.info.is_primary_master == 0) {
    if (oai_emulation.info.nb_ue_local > 0) {
      bypass_tx_data(UE_TRANSPORT, frame, next_slot);
      bypass_rx_data(frame, last_slot, next_slot, 1);
Cedric Roux's avatar
Cedric Roux committed
166
    } else {
167
168
169
170
171
172
173
174
175
176
      bypass_tx_data(WAIT_SM_TRANSPORT, frame, next_slot);
      bypass_rx_data(frame,last_slot, next_slot, 0);
    }
  } else {
    if (oai_emulation.info.nb_ue_local > 0) {
      bypass_rx_data(frame, last_slot, next_slot, 1);
      bypass_tx_data(UE_TRANSPORT, frame, next_slot);
    } else {
      bypass_rx_data(frame,last_slot, next_slot, 0);
      bypass_tx_data(WAIT_SM_TRANSPORT, frame, next_slot);
Cedric Roux's avatar
Cedric Roux committed
177
    }
178
  }
179

180
181
  LOG_D(EMU, "Leaving EMU transport UL, is primary master %d\n",
        oai_emulation.info.is_primary_master);
Cedric Roux's avatar
Cedric Roux committed
182
}
183

Cedric Roux's avatar
Cedric Roux committed
184
185
void emu_transport_release(void)
{
186
187
  bypass_tx_data(RELEASE_TRANSPORT,0,0);
  LOG_E(EMU," tx RELEASE_TRANSPORT  \n");
Cedric Roux's avatar
Cedric Roux committed
188
}
189

Cedric Roux's avatar
Cedric Roux committed
190
191
192
unsigned int emul_tx_handler(unsigned char Mode,char *Tx_buffer,
                             unsigned int *Nbytes,unsigned int *Nb_flows)
{
193

194
  return *Nbytes;
195
196
}

Cedric Roux's avatar
Cedric Roux committed
197
198
unsigned int emul_rx_data(void)
{
199
  return(0);
200
201
}

Cedric Roux's avatar
Cedric Roux committed
202
203
204
unsigned int emul_rx_handler(unsigned char Mode,char *rx_buffer,
                             unsigned int Nbytes)
{
205
206
  unsigned short Rx_size=0;
  return (Rx_size+2);
207
208
}

gauthier's avatar
gauthier committed
209
void clear_eNB_transport_info(uint8_t nb_eNB)
Cedric Roux's avatar
Cedric Roux committed
210
{
211
212
213
214
215
216
217
218
219
  uint8_t eNB_id;
  uint8_t CC_id;

  for (eNB_id=0; eNB_id<nb_eNB; eNB_id++) {
    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
      eNB_transport_info_TB_index[eNB_id][CC_id]=0;
      memset((void *)&eNB_transport_info[eNB_id][CC_id].cntl,0,sizeof(eNB_cntl));
      eNB_transport_info[eNB_id][CC_id].num_common_dci=0;
      eNB_transport_info[eNB_id][CC_id].num_ue_spec_dci=0;
Cedric Roux's avatar
Cedric Roux committed
220
    }
221
222
  }

223
#ifdef DEBUG_EMU
224
  LOG_D(EMU, "EMUL clear_eNB_transport_info\n");
225
#endif
226
227
}

gauthier's avatar
gauthier committed
228
void clear_UE_transport_info(uint8_t nb_UE)
Cedric Roux's avatar
Cedric Roux committed
229
{
knopp's avatar
   
knopp committed
230
  uint8_t UE_id,CC_id;
231

232
233
234
  for (UE_id=0; UE_id<nb_UE; UE_id++)
    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
      memset((void *)&UE_transport_info[UE_id][CC_id].cntl,0,sizeof(UE_cntl));
Cedric Roux's avatar
Cedric Roux committed
235
    }
236

237
#ifdef DEBUG_EMU
238
239
  LOG_D(EMU, "EMUL clear_UE_transport_info\n");
#endif
240
241
}

knopp's avatar
   
knopp committed
242
void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot)
Cedric Roux's avatar
Cedric Roux committed
243
{
244
245
246
247
248
249
250
251
252
253
  int n_dci = 0, n_dci_dl;
  int payload_offset = 0;
  unsigned int harq_pid;
  LTE_eNB_DLSCH_t *dlsch_eNB;
  unsigned short ue_id;
  uint8_t nb_total_dci;

  // eNB
  // PBCH : copy payload

254
  *(uint32_t *)RC.eNB[enb_id][CC_id]->pbch_pdu =
255
256
257
258
    eNB_transport_info[enb_id][CC_id].cntl.pbch_payload;
  /*  LOG_I(EMU," RX slot %d ENB TRANSPORT pbch payload %d pdu[0] %d  pdu[0] %d \n",
    next_slot ,
    eNB_transport_info[enb_id][CC_id].cntl.pbch_payload,
259
260
    ((uint8_t*)RC.eNB[enb_id]->pbch_pdu)[0],
    ((uint8_t*)RC.eNB[enb_id]->pbch_pdu)[1]);
261
262
263
264
265
266
267
268
269
270
271
272
273
  */
  //  }
  //CFI
  // not needed yet

  //PHICH
  // to be added later

  //DCI
  nb_total_dci= eNB_transport_info[enb_id][CC_id].num_pmch +
                eNB_transport_info[enb_id][CC_id].num_ue_spec_dci +
                eNB_transport_info[enb_id][CC_id].num_common_dci;

274
  RC.eNB[enb_id][CC_id]->num_ue_spec_dci[(next_slot>>1)&1] =
275
    eNB_transport_info[enb_id][CC_id].num_ue_spec_dci;
276
  RC.eNB[enb_id][CC_id]->num_common_dci[(next_slot>>1)&1]  =
277
    eNB_transport_info[enb_id][CC_id].num_common_dci;
278
#ifdef DEBUG_EMU
279
280
  LOG_D(EMU, "Fill phy vars eNB %d for slot %d, DCI found %d  \n",
        enb_id, next_slot, nb_total_dci);
281
#endif
Cedric Roux's avatar
Cedric Roux committed
282

283
  if (nb_total_dci >0) {
Cedric Roux's avatar
Cedric Roux committed
284

285
    memcpy(RC.eNB[enb_id][CC_id]->dci_alloc[(next_slot>>1)&1],
286
287
           eNB_transport_info[enb_id][CC_id].dci_alloc,
           (nb_total_dci) * sizeof(DCI_ALLOC_t));
Cedric Roux's avatar
Cedric Roux committed
288

289
290
291
292
293
294
295
    n_dci_dl=0;

    // fill dlsch_eNB structure from DCI
    for (n_dci = 0; n_dci < nb_total_dci; n_dci++) {

      //exclude ul dci
      if ((eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].format > 0) || (eNB_transport_info[enb_id][CC_id].num_pmch > 0 )) {
296
#ifdef DEBUG_EMU
297
298
299
300
301
302
        LOG_D(EMU, "dci spec %d common %d pmch %d tbs is %d payload offset %d\n",
              eNB_transport_info[enb_id][CC_id].num_ue_spec_dci,
              eNB_transport_info[enb_id][CC_id].num_common_dci,
              eNB_transport_info[enb_id][CC_id].num_pmch,
              eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl],
              payload_offset);
303
#endif
304
305
306

        switch (eNB_transport_info[enb_id][CC_id].dlsch_type[n_dci_dl]) {
        case 0: //SI:
307
          memcpy(RC.eNB[enb_id][CC_id]->dlsch_SI->harq_processes[0]->b,
308
309
                 &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset],
                 eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
310
#ifdef DEBUG_EMU
311
312
          LOG_D(EMU, "SI eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]%d \n",
                eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
313
#endif
314
315
316
          break;

        case 1: //RA:
317
          memcpy(RC.eNB[enb_id][CC_id]->dlsch_ra->harq_processes[0]->b,
318
319
                 &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset],
                 eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
320
#ifdef DEBUG_EMU
321
322
          LOG_D(EMU, "RA eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]%d \n",
                eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
Cedric Roux's avatar
Cedric Roux committed
323
#endif
324
325
326
327
328
          break;

        case 2://TB0:
          harq_pid  = eNB_transport_info[enb_id][CC_id].harq_pid[n_dci_dl];
          ue_id = eNB_transport_info[enb_id][CC_id].ue_id[n_dci_dl];
329
          RC.eNB[enb_id][CC_id]->dlsch[ue_id][0]->rnti=
330
            eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].rnti;
331
          dlsch_eNB = RC.eNB[enb_id][CC_id]->dlsch[ue_id][0];
Cedric Roux's avatar
Cedric Roux committed
332
#ifdef DEBUG_EMU
333
334
335
336
337
338
339
340
341
342
          LOG_D(EMU,
                " enb_id %d ue id is %d rnti is %x dci index %d, harq_pid %d tbs %d \n",
                enb_id, ue_id, eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].rnti,
                n_dci_dl, harq_pid, eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);

          for (i=0; i<eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]; i++) {
            LOG_T(EMU, "%x.",
                  (unsigned char) eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset+i]);
          }

Cedric Roux's avatar
Cedric Roux committed
343
#endif
344
345
346
347
348
349
350
351
          memcpy(dlsch_eNB->harq_processes[harq_pid]->b,
                 &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset],
                 eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
          break;

        case 3://TB1:
          harq_pid = eNB_transport_info[enb_id][CC_id].harq_pid[n_dci_dl];
          ue_id = eNB_transport_info[enb_id][CC_id].ue_id[n_dci_dl];
352
          RC.eNB[enb_id][CC_id]->dlsch[ue_id][1]->rnti=
353
            eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].rnti;
354
          dlsch_eNB = RC.eNB[enb_id][CC_id]->dlsch[ue_id][1];
355
356
357
358
359
360
361

          memcpy(dlsch_eNB->harq_processes[harq_pid]->b,
                 &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset],
                 eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
          break;

        case 5:
362
          memcpy(RC.eNB[enb_id][CC_id]->dlsch_MCH->harq_processes[0]->b,
363
364
                 &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset],
                 eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
365
#ifdef DEBUG_EMU
366
367
368
369
370
371
372
373
          LOG_D(EMU, "PMCH eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl] %d \n",
                eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
#endif
          break;

        default:
          LOG_W(EMU,"not supported dlsch type %d \n", eNB_transport_info[enb_id][CC_id].dlsch_type[n_dci_dl]);
          break;
Cedric Roux's avatar
Cedric Roux committed
374
        }
375
376
377
378
379
380
381

        payload_offset += eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl];
      }

      n_dci_dl++;
    }

382
#ifdef DEBUG_EMU
383
    LOG_D(EMU, "Fill phy eNB vars done next slot %d !\n", next_slot);
Cedric Roux's avatar
Cedric Roux committed
384
#endif
385
  }
386
387
}

knopp's avatar
   
knopp committed
388
void fill_phy_ue_vars(unsigned int ue_id, uint8_t CC_id,unsigned int last_slot)
Cedric Roux's avatar
Cedric Roux committed
389
{
390
391
392
393
394
395
396
397
398
399
400
401
402
  int n_enb;//index
  int enb_id;
  //  int harq_id;
  //  int payload_offset = 0;
  unsigned short rnti;
  unsigned int harq_pid;
  LTE_UE_ULSCH_t *ulsch;
  PUCCH_FMT_t pucch_format;
  //  uint8_t ue_transport_info_index[NUMBER_OF_eNB_MAX];
  uint8_t subframe = (last_slot+1)>>1;

  memcpy(&ue_cntl_delay[ue_id][CC_id][(last_slot+1)%2], &UE_transport_info[ue_id][CC_id].cntl,
         sizeof(UE_cntl));
403
404

#ifdef DEBUG_EMU
405
406
407
408
409
410
411
412
413
414
415
416
  LOG_D(EMU,
        "Last slot %d subframe %d CC_id %d: Fill phy vars UE %d : PRACH is (%d,%d) preamble (%d,%d) SR (%d,%d), pucch_sel (%d, %d)\n",

        last_slot,subframe,CC_id, ue_id,
        UE_transport_info[ue_id][CC_id].cntl.prach_flag,
        ue_cntl_delay[ue_id][CC_id][last_slot%2].prach_flag,
        UE_transport_info[ue_id][CC_id].cntl.prach_id,
        ue_cntl_delay[ue_id][CC_id][last_slot%2].prach_id,
        UE_transport_info[ue_id][CC_id].cntl.sr,
        ue_cntl_delay[ue_id][CC_id][last_slot%2].sr,
        UE_transport_info[ue_id][CC_id].cntl.pucch_sel,
        ue_cntl_delay[ue_id][CC_id][last_slot%2].pucch_sel);
417
#endif
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
  //ue_cntl_delay[subframe%2].prach_flag ;
  PHY_vars_UE_g[ue_id][CC_id]->generate_prach = ue_cntl_delay[ue_id][CC_id][last_slot%2].prach_flag;//UE_transport_info[ue_id][CC_id].cntl.prach_flag;

  if (PHY_vars_UE_g[ue_id][CC_id]->generate_prach == 1) {
    //     if (PHY_vars_UE_g[ue_id][CC_id]->prach_resources[enb_id] == NULL)
    //  PHY_vars_UE_g[ue_id][CC_id]->prach_resources[enb_id] = malloc(sizeof(PRACH_RESOURCES_t));
    //ue_cntl_delay[subframe%2].prach_id;
    PHY_vars_UE_g[ue_id][CC_id]->prach_PreambleIndex =
      ue_cntl_delay[ue_id][CC_id][last_slot%2].prach_id;
  }

  pucch_format= ue_cntl_delay[ue_id][CC_id][last_slot%2].pucch_flag;// UE_transport_info[ue_id][CC_id].cntl.pucch_flag;

  if ((last_slot + 1) % 2 == 0) {
    if (pucch_format == pucch_format1) { // UE_transport_info[ue_id][CC_id].cntl.sr;
      PHY_vars_UE_g[ue_id][CC_id]->sr[subframe] = ue_cntl_delay[ue_id][CC_id][last_slot%2].sr;
    } else if ((pucch_format == pucch_format1a) ||
               (pucch_format == pucch_format1b)) {
      PHY_vars_UE_g[ue_id][CC_id]->pucch_payload[0] = ue_cntl_delay[ue_id][CC_id][last_slot%2].pucch_payload;
      //UE_transport_info[ue_id][CC_id].cntl.pucch_payload;
Cedric Roux's avatar
Cedric Roux committed
438
439
    }

440
441
442
443
    PHY_vars_UE_g[ue_id][CC_id]->pucch_sel[subframe] =
      ue_cntl_delay[ue_id][CC_id][last_slot%2].pucch_sel;
  }

Cedric Roux's avatar
Cedric Roux committed
444
#ifdef DEBUG_EMU
445
446
  LOG_D(EMU,"subframe %d trying to copy the payload from num eNB %d to UE %d \n",
        subframe, UE_transport_info[ue_id][CC_id].num_eNB, ue_id);
Cedric Roux's avatar
Cedric Roux committed
447
#endif
448
449

  for (n_enb = 0; n_enb < UE_transport_info[ue_id][CC_id].num_eNB; n_enb++) {
450

451
452
453
    rnti = UE_transport_info[ue_id][CC_id].rnti[n_enb];
    enb_id = UE_transport_info[ue_id][CC_id].eNB_id[n_enb];

Bilel's avatar
Bilel committed
454
455
    PHY_vars_UE_g[ue_id][CC_id]->pdcch_vars[0][enb_id]->crnti=rnti;
    PHY_vars_UE_g[ue_id][CC_id]->pdcch_vars[1][enb_id]->crnti=rnti;
456
457
458

    harq_pid = UE_transport_info[ue_id][CC_id].harq_pid[n_enb];

459
    PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o_RI[0] =
460
      ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_ri & 0x1;
461
    PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o_RI[1] =
462
463
      (ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_ri>>1) & 0x1;

464
    PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o_ACK[0]=
465
      ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_ack & 0x1;
466
    PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o_ACK[1]=
467
468
469
470
      (ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_ack>>1) & 0x1;
    //*(uint32_t *)ulsch->o                        = ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_uci;

    if ((last_slot % 2) == 1) {
471
      PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->O =
472
        ue_cntl_delay[ue_id][CC_id][last_slot%2].length_uci;
473
      PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->uci_format =
474
475
        ue_cntl_delay[ue_id][CC_id][last_slot%2].uci_format;

476
      memcpy(PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o,
477
478
479
             ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_uci,
             MAX_CQI_BYTES);

480
      ulsch = PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id];
481
482
483
484
485
      // if (((HLC_subband_cqi_rank1_2A_5MHz *)ulsch->o)->cqi1)
      LOG_D(EMU,
            "[UE %d] subframe %d last slot %d copy the payload from eNB %d to UE %d with harq id %d cqi (val %d, length %d) \n",
            ue_id, subframe, last_slot, enb_id, ue_id, harq_pid,
            ((HLC_subband_cqi_rank1_2A_5MHz *)ulsch->o)->cqi1,
486
            PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->O);
487
    }
Cedric Roux's avatar
Cedric Roux committed
488

489
    memcpy(PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->harq_processes[harq_pid]->b,
490
491
           UE_transport_info[ue_id][CC_id].transport_blocks,
           UE_transport_info[ue_id][CC_id].tbs[enb_id]);
Cedric Roux's avatar
Cedric Roux committed
492

493
494
495
496
497
    //ue_transport_info_index[enb_id]+=UE_transport_info[ue_id][CC_id].tbs[enb_id];

    //UE_transport_info[ue_id][CC_id].transport_blocks+=ue_transport_info_index[enb_id];
    //LOG_T(EMU,"ulsch tbs is %d\n", UE_transport_info[ue_id][CC_id].tbs[enb_id]);
  }
498
}