defs.h 26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

/*! \file PHY/LTE_TRANSPORT/defs.h
* \brief data structures for PDSCH/DLSCH/PUSCH/ULSCH physical and transport channel descriptors (TX/RX)
* \author R. Knopp
* \date 2011
* \version 0.1
* \company Eurecom
* \email: raymond.knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it
* \note
* \warning
*/
#ifndef __LTE_TRANSPORT_DEFS__H__
#define __LTE_TRANSPORT_DEFS__H__
#include "PHY/defs.h"
#include "dci.h"
#include "uci.h"
knopp's avatar
knopp committed
37
#ifndef STANDALONE_COMPILE
38
#include "UTIL/LISTS/list.h"
knopp's avatar
knopp committed
39
#endif
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

#define MOD_TABLE_QPSK_OFFSET 1
#define MOD_TABLE_16QAM_OFFSET 5
#define MOD_TABLE_64QAM_OFFSET 21
#define MOD_TABLE_PSS_OFFSET 85

// structures below implement 36-211 and 36-212

/** @addtogroup _PHY_TRANSPORT_
 * @{
 */



#define NSOFT 1827072
55
#define LTE_NULL 2
56

57
// maximum of 3 segments before each coding block if data length exceeds 6144 bits.
58 59 60 61 62 63 64 65 66

#define MAX_NUM_DLSCH_SEGMENTS 16
#define MAX_NUM_ULSCH_SEGMENTS MAX_NUM_DLSCH_SEGMENTS
#define MAX_DLSCH_PAYLOAD_BYTES (MAX_NUM_DLSCH_SEGMENTS*768)
#define MAX_ULSCH_PAYLOAD_BYTES (MAX_NUM_ULSCH_SEGMENTS*768)

#define MAX_NUM_CHANNEL_BITS (14*1200*6)  // 14 symbols, 1200 REs, 12 bits/RE
#define MAX_NUM_RE (14*1200)

gauthier's avatar
gauthier committed
67
#if !defined(SI_RNTI)
gauthier's avatar
gauthier committed
68
#define SI_RNTI  (rnti_t)0xffff
gauthier's avatar
gauthier committed
69 70
#endif
#if !defined(M_RNTI)
gauthier's avatar
gauthier committed
71
#define M_RNTI   (rnti_t)0xfffd
gauthier's avatar
gauthier committed
72 73
#endif
#if !defined(P_RNTI)
gauthier's avatar
gauthier committed
74
#define P_RNTI   (rnti_t)0xfffe
gauthier's avatar
gauthier committed
75 76
#endif
#if !defined(CBA_RNTI)
gauthier's avatar
gauthier committed
77
#define CBA_RNTI (rnti_t)0xfff4
gauthier's avatar
gauthier committed
78 79
#endif
#if !defined(C_RNTI)
gauthier's avatar
gauthier committed
80
#define C_RNTI   (rnti_t)0x1234
gauthier's avatar
gauthier committed
81
#endif
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

#define PMI_2A_11 0
#define PMI_2A_1m1 1
#define PMI_2A_1j 2
#define PMI_2A_1mj 3

typedef enum {
  SCH_IDLE,
  ACTIVE,
  CBA_ACTIVE,
  DISABLED
} SCH_status_t;


typedef struct {
  /// Status Flag indicating for this DLSCH (idle,active,disabled)
  SCH_status_t status;
  /// Transport block size
  uint32_t TBS;
101 102
  /// The payload + CRC size in bits, "B" from 36-212
  uint32_t B;
103
  /// Pointer to the payload
104
  uint8_t *b;
105
  /// Pointers to transport block segments
106
  uint8_t *c[MAX_NUM_DLSCH_SEGMENTS];
107 108
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS];
109 110 111 112
  /// Frame where current HARQ round was sent
  uint32_t frame;
  /// Subframe where current HARQ round was sent
  uint32_t subframe;
113 114
  /// Index of current HARQ round for this DLSCH
  uint8_t round;
115
  /// MCS format for this DLSCH
116
  uint8_t mcs;
117 118 119 120
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
  /// MIMO mode for this DLSCH
  MIMO_mode_t mimo_mode;
121 122
  /// Current RB allocation
  uint32_t rb_alloc[4];
123 124
  /// distributed/localized flag
  vrb_t vrb_type;
125 126 127 128 129 130 131 132 133 134 135 136
  /// Current subband PMI allocation
  uint16_t pmi_alloc;
  /// Current subband RI allocation
  uint32_t ri_alloc;
  /// Current subband CQI1 allocation
  uint32_t cqi_alloc1;
  /// Current subband CQI2 allocation
  uint32_t cqi_alloc2;
  /// Current Number of RBs
  uint16_t nb_rb;
  /// downlink power offset field
  uint8_t dl_power_off;
137
  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
138
  uint8_t e[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32)));
139
  /// Turbo-code outputs (36-212 V8.6 2009-03, p.12
140
  uint8_t *d[MAX_NUM_DLSCH_SEGMENTS];//[(96+3+(3*6144))];
141
  /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17)
142 143 144
  uint8_t w[MAX_NUM_DLSCH_SEGMENTS][3*6144];
  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
  uint32_t C;
145
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
146
  uint32_t Cminus;
147
  /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
148 149 150
  uint32_t Cplus;
  /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t Kminus;
151
  /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
152
  uint32_t Kplus;
153
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
154
  uint32_t F;
155
  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17, TM3-4)
156
  uint8_t Nl;
157 158 159 160
  /// Number of layers for this PDSCH transmission (TM8-10)
  uint8_t Nlayers;
  /// First layer for this PSCH transmission
  uint8_t first_layer;
161 162 163
} LTE_DL_eNB_HARQ_t;

typedef struct {
164 165 166 167
  /// Indicator of first transmission
  uint8_t first_tx;
  /// Last Ndi received for this process on DCI (used for C-RNTI only)
  uint8_t DCINdi;
168
  /// Flag indicating that this ULSCH has a new packet (start of new round)
169
  //  uint8_t Ndi;
170 171 172 173 174 175
  /// Status Flag indicating for this ULSCH (idle,active,disabled)
  SCH_status_t status;
  /// Subframe scheduling indicator (i.e. Transmission opportunity indicator)
  uint8_t subframe_scheduling_flag;
  /// Subframe cba scheduling indicator (i.e. Transmission opportunity indicator)
  uint8_t subframe_cba_scheduling_flag;
176
  /// First Allocated RB
177 178 179 180 181 182 183
  uint16_t first_rb;
  /// Current Number of RBs
  uint16_t nb_rb;
  /// Last TPC command
  uint8_t TPC;
  /// Transport block size
  uint32_t TBS;
184 185
  /// The payload + CRC size in bits, "B" from 36-212
  uint32_t B;
186 187 188
  /// Length of ACK information (bits)
  uint8_t O_ACK;
  /// Pointer to the payload
189
  uint8_t *b;
190
  /// Pointers to transport block segments
191
  uint8_t *c[MAX_NUM_ULSCH_SEGMENTS];
192 193
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS];
194 195
  /// Index of current HARQ round for this ULSCH
  uint8_t round;
196
  /// MCS format of this ULSCH
197
  uint8_t mcs;
198 199
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
200 201
  /// Turbo-code outputs (36-212 V8.6 2009-03, p.12
  uint8_t d[MAX_NUM_ULSCH_SEGMENTS][(96+3+(3*6144))];
202
  /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17)
203 204 205
  uint8_t w[MAX_NUM_ULSCH_SEGMENTS][3*6144];
  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
  uint32_t C;
206
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
207
  uint32_t Cminus;
208
  /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
209 210 211
  uint32_t Cplus;
  /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t Kminus;
212
  /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
213
  uint32_t Kplus;
214 215 216
  /// Total number of bits across all segments
  uint32_t sumKr;
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
217
  uint32_t F;
218 219 220 221 222 223 224 225 226 227 228 229
  /// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27)
  uint16_t Msc_initial;
  /// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27)
  uint8_t Nsymb_initial;
  /// n_DMRS  for cyclic shift of DMRS (36.213 Table 9.1.2-2)
  uint8_t n_DMRS;
  /// n_DMRS2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1)
  uint8_t n_DMRS2;
  /// Flag to indicate that this is a control only ULSCH (i.e. no MAC SDU)
  uint8_t control_only;
  /// Flag to indicate that this is a calibration ULSCH (i.e. no MAC SDU and filled with TDD calibration information)
  //  int calibration_flag;
Gabriel's avatar
Gabriel committed
230 231 232 233 234
  /// Number of soft channel bits
  uint32_t G;

  // decode phich
  uint8_t decode_phich;
235 236 237
} LTE_UL_UE_HARQ_t;

typedef struct {
knopp's avatar
 
knopp committed
238
  /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
239
  uint32_t *txdataF[8];
240
  /// Allocated RNTI (0 means DLSCH_t is not currently used)
241
  uint16_t rnti;
242 243 244 245
  /// Active flag for baseband transmitter processing
  uint8_t active;
  /// Indicator of TX activation per subframe.  Used during PUCCH detection for ACK/NAK.
  uint8_t subframe_tx[10];
246
  /// First CCE of last PDSCH scheduling per subframe.  Again used during PUCCH detection for ACK/NAK.
247 248 249 250 251 252 253 254 255 256
  uint8_t nCCE[10];
  /// Current HARQ process id
  uint8_t current_harq_pid;
  /// Process ID's per subframe.  Used to associate received ACKs on PUSCH/PUCCH to DLSCH harq process ids
  uint8_t harq_ids[10];
  /// Window size (in outgoing transport blocks) for fine-grain rate adaptation
  uint8_t ra_window_size;
  /// First-round error threshold for fine-grain rate adaptation
  uint8_t error_threshold;
  /// Pointers to 8 HARQ processes for the DLSCH
257
  LTE_DL_eNB_HARQ_t *harq_processes[8];
258 259 260
  /// Number of soft channel bits
  uint32_t G;
  /// Codebook index for this dlsch (0,1,2,3)
261
  uint8_t codebook_index;
262
  /// Maximum number of HARQ processes (for definition see 36-212 V8.6 2009-03, p.17)
263
  uint8_t Mdlharq;
264 265
  /// Maximum number of HARQ rounds
  uint8_t Mlimit;
266 267
  /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Kmimo;
268 269
  /// Nsoft parameter related to UE Category
  uint32_t Nsoft;
270
  /// amplitude of PDSCH (compared to RS) in symbols without pilots
271 272 273
  int16_t sqrt_rho_a;
  /// amplitude of PDSCH (compared to RS) in symbols containing pilots
  int16_t sqrt_rho_b;
knopp's avatar
 
knopp committed
274

275 276 277 278 279 280 281 282 283 284 285
} LTE_eNB_DLSCH_t;

#define PUSCH_x 2
#define PUSCH_y 3

typedef struct {
  /// Current Number of Symbols
  uint8_t Nsymb_pusch;
  /// SRS active flag
  uint8_t srs_active;
  /// Pointers to 8 HARQ processes for the ULSCH
Gabriel's avatar
Gabriel committed
286
  LTE_UL_UE_HARQ_t *harq_processes[9];
287 288 289 290
  /// Pointer to CQI data
  uint8_t o[MAX_CQI_BYTES];
  /// Length of CQI data (bits)
  uint8_t O;
291
  /// Format of CQI data
292
  UCI_format_t uci_format;
293
  /// Rank information
294 295 296 297 298 299 300 301 302
  uint8_t o_RI[2];
  /// Length of rank information (bits)
  uint8_t O_RI;
  /// Pointer to ACK
  uint8_t o_ACK[4];
  /// Minimum number of CQI bits for PUSCH (36-212 r8.6, Sec 5.2.4.1 p. 37)
  uint8_t O_CQI_MIN;
  /// ACK/NAK Bundling flag
  uint8_t bundling;
303
  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
304
  uint8_t e[MAX_NUM_CHANNEL_BITS];
305
  /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
306
  uint8_t h[MAX_NUM_CHANNEL_BITS];
307
  /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
308
  uint8_t b_tilde[MAX_NUM_CHANNEL_BITS];
309
  /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
310
  int32_t d[MAX_NUM_RE];
311
  /// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15)
312
  int32_t z[MAX_NUM_RE];
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
  /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27)
  uint8_t q[MAX_CQI_PAYLOAD];
  /// coded and interleaved CQI bits
  uint8_t o_w[(MAX_CQI_BITS+8)*3];
  /// coded CQI bits
  uint8_t o_d[96+((MAX_CQI_BITS+8)*3)];
  /// coded ACK bits
  uint8_t q_ACK[MAX_ACK_PAYLOAD];
  /// coded RI bits
  uint8_t q_RI[MAX_RI_PAYLOAD];
  /// beta_offset_cqi times 8
  uint16_t beta_offset_cqi_times8;
  /// beta_offset_ri times 8
  uint16_t beta_offset_ri_times8;
  /// beta_offset_harqack times 8
  uint16_t beta_offset_harqack_times8;
  /// power_offset
  uint8_t power_offset;
  // for cooperative communication
  uint8_t cooperation_flag;
  /// RNTI attributed to this ULSCH
  uint16_t rnti;
  /// f_PUSCH parameter for PUSCH power control
  int16_t f_pusch;
  /// Po_PUSCH - target output power for PUSCH
  int16_t Po_PUSCH;
  /// PHR - current power headroom (based on last PUSCH transmission)
  int16_t PHR;
Bilel's avatar
Bilel committed
341 342
  /// Po_SRS - target output power for SRS
  int16_t Po_SRS;
343
  /// num active cba group
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
  uint8_t num_active_cba_groups;
  /// num dci found for cba
  uint8_t num_cba_dci[10];
  /// allocated CBA RNTI
  uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
} LTE_UE_ULSCH_t;

typedef struct {
  /// Flag indicating that this ULSCH has been allocated by a DCI (otherwise it is a retransmission based on PHICH NAK)
  uint8_t dci_alloc;
  /// Flag indicating that this ULSCH has been allocated by a RAR (otherwise it is a retransmission based on PHICH NAK or DCI)
  uint8_t rar_alloc;
  /// Status Flag indicating for this ULSCH (idle,active,disabled)
  SCH_status_t status;
  /// Subframe scheduling indicator (i.e. Transmission opportunity indicator)
  uint8_t subframe_scheduling_flag;
  /// Subframe cba scheduling indicator (i.e. CBA Transmission opportunity indicator)
  uint8_t subframe_cba_scheduling_flag;
  /// PHICH active flag
  uint8_t phich_active;
  /// PHICH ACK
  uint8_t phich_ACK;
  /// Last TPC command
  uint8_t TPC;
368
  /// First Allocated RB
369
  uint16_t first_rb;
Cedric Roux's avatar
Cedric Roux committed
370 371 372 373
  /// First Allocated RB - previous scheduling
  /// This is needed for PHICH generation which
  /// is done after a new scheduling
  uint16_t previous_first_rb;
374 375 376 377
  /// Current Number of RBs
  uint16_t nb_rb;
  /// Transport block size
  uint32_t TBS;
378 379
  /// The payload + CRC size in bits
  uint32_t B;
380 381
  /// Number of soft channel bits
  uint32_t G;
knopp's avatar
 
knopp committed
382 383 384 385
  /// CQI CRC status
  uint8_t cqi_crc_status;
  /// Pointer to CQI data
  uint8_t o[MAX_CQI_BYTES];
386
  /// Format of CQI data
knopp's avatar
 
knopp committed
387 388 389 390 391
  UCI_format_t uci_format;
  /// Length of CQI data under RI=1 assumption(bits)
  uint8_t Or1;
  /// Length of CQI data under RI=2 assumption(bits)
  uint8_t Or2;
392
  /// Rank information
knopp's avatar
 
knopp committed
393 394 395 396 397
  uint8_t o_RI[2];
  /// Length of rank information (bits)
  uint8_t O_RI;
  /// Pointer to ACK
  uint8_t o_ACK[4];
398 399
  /// Length of ACK information (bits)
  uint8_t O_ACK;
400
  /// The value of DAI in DCI format 0
401
  uint8_t V_UL_DAI;
knopp's avatar
 
knopp committed
402 403 404 405 406 407 408 409 410 411 412 413
  /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27)
  int8_t q[MAX_CQI_PAYLOAD];
  /// number of coded CQI bits after interleaving
  uint8_t o_RCC;
  /// coded and interleaved CQI bits
  int8_t o_w[(MAX_CQI_BITS+8)*3];
  /// coded CQI bits
  int8_t o_d[96+((MAX_CQI_BITS+8)*3)];
  /// coded ACK bits
  int16_t q_ACK[MAX_ACK_PAYLOAD];
  /// coded RI bits
  int16_t q_RI[MAX_RI_PAYLOAD];
414
  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
415
  int16_t e[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32)));
knopp's avatar
 
knopp committed
416 417
  /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
  uint8_t h[MAX_NUM_CHANNEL_BITS];
418
  /// Pointer to the payload
419
  uint8_t *b;
420 421
  /// Pointers to transport block segments
  uint8_t *c[MAX_NUM_ULSCH_SEGMENTS];
422 423
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS];
knopp's avatar
 
knopp committed
424 425 426 427
  /// Current Number of Symbols
  uint8_t Nsymb_pusch;
  /// SRS active flag
  uint8_t srs_active;
428
  /// Index of current HARQ round for this ULSCH
429
  uint8_t round;
430
  /// MCS format for this ULSCH
431
  uint8_t mcs;
432 433
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
434
  /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
435
  int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
436
  /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
437
  int16_t *d[MAX_NUM_ULSCH_SEGMENTS];
438 439
  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
  uint32_t C;
440
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
441 442 443 444 445 446
  uint32_t Cminus;
  /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t Cplus;
  /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t Kminus;
  /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
447
  uint32_t Kplus;
448 449
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t F;
450
  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
451
  uint8_t Nl;
452 453 454 455 456 457
  /// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27)
  uint16_t Msc_initial;
  /// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27)
  uint8_t Nsymb_initial;
  /// n_DMRS  for cyclic shift of DMRS (36.213 Table 9.1.2-2)
  uint8_t n_DMRS;
Cedric Roux's avatar
Cedric Roux committed
458 459 460 461
  /// n_DMRS  for cyclic shift of DMRS (36.213 Table 9.1.2-2) - previous scheduling
  /// This is needed for PHICH generation which
  /// is done after a new scheduling
  uint8_t previous_n_DMRS;
462 463 464 465
  /// n_DMRS 2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1)
  uint8_t n_DMRS2;
  /// Flag to indicate that this ULSCH is for calibration information sent from UE (i.e. no MAC SDU to pass up)
  //  int calibration_flag;
466 467
  /// delta_TF for power control
  int32_t delta_TF;
468 469 470 471
} LTE_UL_eNB_HARQ_t;

typedef struct {
  /// Pointers to 8 HARQ processes for the ULSCH
472
  LTE_UL_eNB_HARQ_t *harq_processes[8];
473 474
  /// Maximum number of HARQ rounds
  uint8_t Mlimit;
475 476 477 478 479 480 481 482 483 484
  /// Maximum number of iterations used in eNB turbo decoder
  uint8_t max_turbo_iterations;
  /// ACK/NAK Bundling flag
  uint8_t bundling;
  /// beta_offset_cqi times 8
  uint16_t beta_offset_cqi_times8;
  /// beta_offset_ri times 8
  uint16_t beta_offset_ri_times8;
  /// beta_offset_harqack times 8
  uint16_t beta_offset_harqack_times8;
485
  /// Flag to indicate that eNB awaits UE Msg3
486
  uint8_t Msg3_active;
487
  /// Flag to indicate that eNB should decode UE Msg3
488 489 490 491 492 493 494 495 496 497 498
  uint8_t Msg3_flag;
  /// Subframe for Msg3
  uint8_t Msg3_subframe;
  /// Frame for Msg3
  uint32_t Msg3_frame;
  /// RNTI attributed to this ULSCH
  uint16_t rnti;
  /// cyclic shift for DM RS
  uint8_t cyclicShift;
  /// cooperation flag
  uint8_t cooperation_flag;
499
  /// num active cba group
500 501 502
  uint8_t num_active_cba_groups;
  /// allocated CBA RNTI for this ulsch
  uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
503 504 505 506
#ifdef LOCALIZATION
  /// epoch timestamp in millisecond
  int32_t reference_timestamp_ms;
  /// aggregate physical states every n millisecond
507
  int32_t aggregation_period_ms;
508
  /// a set of lists used for localization
509 510
  struct list loc_rss_list[10], loc_rssi_list[10], loc_subcarrier_rss_list[10], loc_timing_advance_list[10], loc_timing_update_list[10];
  struct list tot_loc_rss_list, tot_loc_rssi_list, tot_loc_subcarrier_rss_list, tot_loc_timing_advance_list, tot_loc_timing_update_list;
511
#endif
512 513 514
} LTE_eNB_ULSCH_t;

typedef struct {
515 516 517 518
  /// Indicator of first transmission
  uint8_t first_tx;
  /// Last Ndi received for this process on DCI (used for C-RNTI only)
  uint8_t DCINdi;
519
  /// DLSCH status flag indicating
520 521 522
  SCH_status_t status;
  /// Transport block size
  uint32_t TBS;
523 524
  /// The payload + CRC size in bits
  uint32_t B;
525
  /// Pointer to the payload
526
  uint8_t *b;
527 528
  /// Pointers to transport block segments
  uint8_t *c[MAX_NUM_DLSCH_SEGMENTS];
529 530
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS];
531
  /// Index of current HARQ round for this DLSCH
532
  uint8_t round;
533
  /// MCS format for this DLSCH
534
  uint8_t mcs;
535 536
  /// Qm (modulation order) for this DLSCH
  uint8_t Qm;
537 538 539 540
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
  /// MIMO mode for this DLSCH
  MIMO_mode_t mimo_mode;
541
  /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
542
  int16_t w[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)];
543
  /// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
544
  double w_abs[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)];
545
  /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
546
  int16_t *d[MAX_NUM_DLSCH_SEGMENTS];
547 548
  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
  uint32_t C;
549
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
550 551 552 553 554 555
  uint32_t Cminus;
  /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t Cplus;
  /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t Kminus;
  /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
556
  uint32_t Kplus;
557 558
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t F;
559 560 561
  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Nl;
  /// current delta_pucch
gauthier's avatar
gauthier committed
562
  int8_t delta_PUCCH;
563 564 565 566 567 568
  /// Number of soft channel bits
  uint32_t G;
  /// Current Number of RBs
  uint16_t nb_rb;
  /// Current subband PMI allocation
  uint16_t pmi_alloc;
569 570 571 572 573 574
  /// Current RB allocation (even slots)
  uint32_t rb_alloc_even[4];
  /// Current RB allocation (odd slots)
  uint32_t rb_alloc_odd[4];
  /// distributed/localized flag
  vrb_t vrb_type;
575 576
  /// downlink power offset field
  uint8_t dl_power_off;
577 578 579 580
  /// trials per round statistics
  uint32_t trials[8];
  /// error statistics per round
  uint32_t errors[8];
581 582
} LTE_DL_UE_HARQ_t;

583
typedef struct {
584 585 586 587
  /// time-based localization, relying on TA and TOA
  double time_based;
  /// power-based localization, relying on RSS and RSSI
  double power_based;
588
} eNB_UE_estimated_distances;
589 590 591

typedef struct {
  /// UL RSSI per receive antenna
gauthier's avatar
gauthier committed
592
  int32_t UL_rssi[NB_ANTENNAS_RX];
knopp's avatar
knopp committed
593
  /// PUCCH1a/b power (digital linear)
594
  uint32_t Po_PUCCH;
knopp's avatar
knopp committed
595 596 597
  /// PUCCH1a/b power (dBm)
  int32_t Po_PUCCH_dBm;
  /// PUCCH1 power (digital linear), conditioned on below threshold
598
  uint32_t Po_PUCCH1_below;
knopp's avatar
knopp committed
599
  /// PUCCH1 power (digital linear), conditioned on above threshold
600
  uint32_t Po_PUCCH1_above;
knopp's avatar
knopp committed
601 602
  /// Indicator that Po_PUCCH has been updated by PHY
  int32_t Po_PUCCH_update;
603 604 605 606 607 608 609 610 611 612 613 614 615
  /// DL Wideband CQI index (2 TBs)
  uint8_t DL_cqi[2];
  /// DL Subband CQI index (from HLC feedback)
  uint8_t DL_subband_cqi[2][13];
  /// DL PMI Single Stream
  uint16_t DL_pmi_single;
  /// DL PMI Dual Stream
  uint16_t DL_pmi_dual;
  /// Current RI
  uint8_t rank;
  /// CRNTI of UE
  uint16_t crnti; ///user id (rnti) of connected UEs
  /// Initial timing offset estimate from PRACH for RAR
616
  int32_t UE_timing_offset;
617
  /// Timing advance estimate from PUSCH for MAC timing advance signalling
618
  int32_t timing_advance_update;
619 620 621 622
  /// Current mode of UE (NOT SYCHED, RAR, PUSCH)
  UE_MODE_t mode;
  /// Current sector where UE is attached
  uint8_t sector;
623

Florian Kaltenberger's avatar
Florian Kaltenberger committed
624 625
  /// dlsch l2 errors
  uint32_t dlsch_l2_errors[8];
626
  /// dlsch trials per harq and round
Florian Kaltenberger's avatar
Florian Kaltenberger committed
627 628 629 630 631 632 633 634
  uint32_t dlsch_trials[8][8];
  /// dlsch ACK/NACK per hard_pid and round
  uint32_t dlsch_ACK[8][8];
  uint32_t dlsch_NAK[8][8];

  /// ulsch l2 errors per harq_pid
  uint32_t ulsch_errors[8];
  /// ulsch l2 consecutive errors per harq_pid
635
  uint32_t ulsch_consecutive_errors; //[8];
Florian Kaltenberger's avatar
Florian Kaltenberger committed
636 637 638 639 640 641
  /// ulsch trials/errors/fer per harq and round
  uint32_t ulsch_decoding_attempts[8][8];
  uint32_t ulsch_round_errors[8][8];
  uint32_t ulsch_decoding_attempts_last[8][8];
  uint32_t ulsch_round_errors_last[8][8];
  uint32_t ulsch_round_fer[8][8];
642 643 644
  uint32_t sr_received;
  uint32_t sr_total;

Florian Kaltenberger's avatar
Florian Kaltenberger committed
645 646 647
  /// dlsch sliding count and total errors in round 0 are used to compute the dlsch_mcs_offset
  uint32_t dlsch_sliding_cnt;
  uint32_t dlsch_NAK_round0;
gauthier's avatar
gauthier committed
648
  int8_t dlsch_mcs_offset;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
649

650 651 652 653
  /// Target mcs1 after rate-adaptation (used by MAC layer scheduler)
  uint8_t dlsch_mcs1;
  /// Target mcs2 after rate-adaptation (used by MAC layer scheduler)
  uint8_t dlsch_mcs2;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
654 655 656
  /// Total bits received from MAC on PDSCH
  int total_TBS_MAC;
  /// Total bits acknowledged on PDSCH
657
  int total_TBS;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
658
  /// Total bits acknowledged on PDSCH (last interval)
659
  int total_TBS_last;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
660
  /// Bitrate on the PDSCH [bps]
661
  unsigned int dlsch_bitrate;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
662
  //  unsigned int total_transmitted_bits;
663 664 665 666
#ifdef LOCALIZATION
  eNB_UE_estimated_distances distance;
  int32_t *subcarrier_rssi;
#endif
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700
} LTE_eNB_UE_stats;

typedef struct {
  /// HARQ process id
  uint8_t harq_id;
  /// ACK bits (after decoding)
  uint8_t ack;
  /// send status (for PUCCH)
  uint8_t send_harq_status;
  /// nCCE (for PUCCH)
  uint8_t nCCE;
} harq_status_t;

typedef struct {
  /// RNTI
  uint16_t rnti;
  /// Active flag for DLSCH demodulation
  uint8_t active;
  /// Transmission mode
  uint8_t mode1_flag;
  /// amplitude of PDSCH (compared to RS) in symbols without pilots
  int16_t sqrt_rho_a;
  /// amplitude of PDSCH (compared to RS) in symbols containing pilots
  int16_t sqrt_rho_b;
  /// Current HARQ process id
  uint8_t current_harq_pid;
  /// Current subband antenna selection
  uint32_t antenna_alloc;
  /// Current subband RI allocation
  uint32_t ri_alloc;
  /// Current subband CQI1 allocation
  uint32_t cqi_alloc1;
  /// Current subband CQI2 allocation
  uint32_t cqi_alloc2;
701 702
  /// saved subband PMI allocation from last PUSCH/PUCCH report
  uint16_t pmi_alloc;
703 704 705
  /// HARQ-ACKs
  harq_status_t harq_ack[10];
  /// Pointers to up to 8 HARQ processes
706
  LTE_DL_UE_HARQ_t *harq_processes[8];
707
  /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17
708
  uint8_t Mdlharq;
709 710
  /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Kmimo;
711 712
  /// Nsoft parameter related to UE Category
  uint32_t Nsoft;
713 714
  /// Maximum number of Turbo iterations
  uint8_t max_turbo_iterations;
715 716
  /// number of iterations used in last turbo decoding
  uint8_t last_iteration_cnt;
717 718
  /// accumulated tx power adjustment for PUCCH
  int8_t               g_pucch;
719 720 721
} LTE_UE_DLSCH_t;

typedef enum {format0,
722 723 724 725 726 727 728 729 730 731 732
              format1,
              format1A,
              format1B,
              format1C,
              format1D,
              format1E_2A_M10PRB,
              format2,
              format2A,
              format2B,
              format2C,
              format2D,
733 734 735
              format3,
	      format3A,
	      format4
736
             } DCI_format_t;
737 738 739 740

typedef enum {
  SI_PDSCH=0,
  RA_PDSCH,
741
  P_PDSCH,
742
  PDSCH,
743
  PDSCH1,
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
  PMCH
} PDSCH_t;

typedef enum {
  pucch_format1=0,
  pucch_format1a,
  pucch_format1b,
  pucch_format2,
  pucch_format2a,
  pucch_format2b
} PUCCH_FMT_t;


typedef struct {
  /// Length of DCI in bits
  uint8_t dci_length;
760
  /// Aggregation level
761 762
  uint8_t L;
  /// Position of first CCE of the dci
763
  int firstCCE;
764
  /// flag to indicate that this is a RA response
gauthier's avatar
gauthier committed
765
  boolean_t ra_flag;
766
  /// rnti
gauthier's avatar
gauthier committed
767
  rnti_t rnti;
768 769 770 771 772 773 774 775 776
  /// Format
  DCI_format_t format;
  /// DCI pdu
  uint8_t dci_pdu[8];
} DCI_ALLOC_t;


/**@}*/
#endif