defs.h 28.6 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

/*! \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"
35
#include "PHY/impl_defs_lte.h"
36
#include "dci.h"
37
#include "mdci.h"
38
#include "uci.h"
39
#ifndef STANDALONE_COMPILE
40
#include "UTIL/LISTS/list.h"
41
#endif
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

#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
57
#define LTE_NULL 2
58

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

#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)

Lionel Gauthier's avatar
Lionel Gauthier committed
69
#if !defined(SI_RNTI)
Lionel Gauthier's avatar
Lionel Gauthier committed
70
#define SI_RNTI  (rnti_t)0xffff
Lionel Gauthier's avatar
Lionel Gauthier committed
71 72
#endif
#if !defined(M_RNTI)
Lionel Gauthier's avatar
Lionel Gauthier committed
73
#define M_RNTI   (rnti_t)0xfffd
Lionel Gauthier's avatar
Lionel Gauthier committed
74 75
#endif
#if !defined(P_RNTI)
Lionel Gauthier's avatar
Lionel Gauthier committed
76
#define P_RNTI   (rnti_t)0xfffe
Lionel Gauthier's avatar
Lionel Gauthier committed
77 78
#endif
#if !defined(CBA_RNTI)
Lionel Gauthier's avatar
Lionel Gauthier committed
79
#define CBA_RNTI (rnti_t)0xfff4
Lionel Gauthier's avatar
Lionel Gauthier committed
80 81
#endif
#if !defined(C_RNTI)
Lionel Gauthier's avatar
Lionel Gauthier committed
82
#define C_RNTI   (rnti_t)0x1234
Lionel Gauthier's avatar
Lionel Gauthier committed
83
#endif
lukashov's avatar
lukashov committed
84 85 86
// These are the codebook indexes according to Table 6.3.4.2.3-1 of 36.211
//1 layer
#define PMI_2A_11  0
87
#define PMI_2A_1m1 1
lukashov's avatar
lukashov committed
88
#define PMI_2A_1j  2
89
#define PMI_2A_1mj 3
lukashov's avatar
lukashov committed
90
//2 layers
91
#define PMI_2A_R1_10 0
lukashov's avatar
lukashov committed
92 93 94
#define PMI_2A_R1_11 1
#define PMI_2A_R1_1j 2

95 96
typedef enum { SEARCH_EXIST=0,
	       SEARCH_EXIST_OR_FREE} find_type_t;
97 98

typedef enum {
Raymond Knopp's avatar
Raymond Knopp committed
99
  SCH_IDLE=0,
100 101 102 103 104 105 106 107 108 109 110
  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;
111 112
  /// pointer to pdu from MAC interface (this is "a" in 36.212)
  uint8_t *pdu;
113 114
  /// The payload + CRC size in bits, "B" from 36-212
  uint32_t B;
115
  /// Pointer to the payload
116
  uint8_t *b;
117
  /// Pointers to transport block segments
118
  uint8_t *c[MAX_NUM_DLSCH_SEGMENTS];
119 120
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS];
121 122 123 124
  /// Frame where current HARQ round was sent
  uint32_t frame;
  /// Subframe where current HARQ round was sent
  uint32_t subframe;
125 126
  /// Index of current HARQ round for this DLSCH
  uint8_t round;
127 128 129
  /// Modulation order
  uint8_t Qm;
  /// MCS
130
  uint8_t mcs;
131 132 133 134
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
  /// MIMO mode for this DLSCH
  MIMO_mode_t mimo_mode;
135 136
  /// Current RB allocation
  uint32_t rb_alloc[4];
137 138
  /// distributed/localized flag
  vrb_t vrb_type;
139 140 141 142 143 144 145 146 147 148
  /// 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;
149 150
  /// Current NDI
  uint8_t ndi;
151 152
  /// downlink power offset field
  uint8_t dl_power_off;
153 154
  /// start symbold of pdsch
  uint8_t pdsch_start;
155
  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
156
  uint8_t e[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32)));
157
  /// Turbo-code outputs (36-212 V8.6 2009-03, p.12
158
  uint8_t *d[MAX_NUM_DLSCH_SEGMENTS];//[(96+3+(3*6144))];
159
  /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17)
160 161 162
  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;
163
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
164
  uint32_t Cminus;
165
  /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
166 167 168
  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;
169
  /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
170
  uint32_t Kplus;
171
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
172
  uint32_t F;
173
  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17, TM3-4)
174
  uint8_t Nl;
175 176 177 178
  /// Number of layers for this PDSCH transmission (TM8-10)
  uint8_t Nlayers;
  /// First layer for this PSCH transmission
  uint8_t first_layer;
179
  /// codeword this transport block is mapped to
180
  uint8_t codeword;
181 182 183
} LTE_DL_eNB_HARQ_t;

typedef struct {
184 185 186 187
  /// Indicator of first transmission
  uint8_t first_tx;
  /// Last Ndi received for this process on DCI (used for C-RNTI only)
  uint8_t DCINdi;
188
  /// Flag indicating that this ULSCH has a new packet (start of new round)
189
  //  uint8_t Ndi;
190 191 192 193 194 195
  /// 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;
196
  /// First Allocated RB
197 198 199 200 201 202 203
  uint16_t first_rb;
  /// Current Number of RBs
  uint16_t nb_rb;
  /// Last TPC command
  uint8_t TPC;
  /// Transport block size
  uint32_t TBS;
204 205
  /// The payload + CRC size in bits, "B" from 36-212
  uint32_t B;
206 207 208
  /// Length of ACK information (bits)
  uint8_t O_ACK;
  /// Pointer to the payload
209
  uint8_t *b;
210
  /// Pointers to transport block segments
211
  uint8_t *c[MAX_NUM_ULSCH_SEGMENTS];
212 213
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS];
214 215
  /// Index of current HARQ round for this ULSCH
  uint8_t round;
216
  /// MCS format of this ULSCH
217
  uint8_t mcs;
218 219
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
220 221
  /// Turbo-code outputs (36-212 V8.6 2009-03, p.12
  uint8_t d[MAX_NUM_ULSCH_SEGMENTS][(96+3+(3*6144))];
222
  /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17)
223 224 225
  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;
226
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
227
  uint32_t Cminus;
228
  /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
229 230 231
  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;
232
  /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
233
  uint32_t Kplus;
234 235 236
  /// 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)
237
  uint32_t F;
238 239 240 241 242 243 244 245 246 247 248 249
  /// 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;
250 251 252 253 254
  /// Number of soft channel bits
  uint32_t G;

  // decode phich
  uint8_t decode_phich;
255
} LTE_UL_UE_HARQ_t; 
256

257 258 259 260 261 262 263
#ifdef Rel14
typedef enum {
  CEmodeA = 0,
  CEmodeB = 1
} CEmode_t;
#endif

264
typedef struct {
Raymond Knopp's avatar
 
Raymond Knopp committed
265
  /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
Florian Kaltenberger's avatar
Florian Kaltenberger committed
266
  int32_t *txdataF[8];
Xiwen JIANG's avatar
Xiwen JIANG committed
267
  /// beamforming weights for UE-spec transmission (antenna ports 5 or 7..14), for each codeword, maximum 4 layers?
Florian Kaltenberger's avatar
Florian Kaltenberger committed
268
  int32_t **ue_spec_bf_weights[4]; 
269 270
  /// dl channel estimates (estimated from ul channel estimates)
  int32_t **calib_dl_ch_estimates;
271
  /// Allocated RNTI (0 means DLSCH_t is not currently used)
272
  uint16_t rnti;
273 274
  /// Active flag for baseband transmitter processing
  uint8_t active;
275 276
  /// HARQ process mask, indicates which processes are currently active
  uint16_t harq_mask;
277 278
  /// Indicator of TX activation per subframe.  Used during PUCCH detection for ACK/NAK.
  uint8_t subframe_tx[10];
279
  /// First CCE of last PDSCH scheduling per subframe.  Again used during PUCCH detection for ACK/NAK.
280 281 282 283 284 285 286 287
  uint8_t nCCE[10];
  /// 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
288
  LTE_DL_eNB_HARQ_t *harq_processes[8];
289 290 291
  /// Number of soft channel bits
  uint32_t G;
  /// Codebook index for this dlsch (0,1,2,3)
292
  uint8_t codebook_index;
293
  /// Maximum number of HARQ processes (for definition see 36-212 V8.6 2009-03, p.17)
294
  uint8_t Mdlharq;
295 296
  /// Maximum number of HARQ rounds
  uint8_t Mlimit;
297 298
  /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Kmimo;
299 300
  /// Nsoft parameter related to UE Category
  uint32_t Nsoft;
301
  /// amplitude of PDSCH (compared to RS) in symbols without pilots
302 303 304
  int16_t sqrt_rho_a;
  /// amplitude of PDSCH (compared to RS) in symbols containing pilots
  int16_t sqrt_rho_b;
305 306 307 308 309 310 311
#ifdef Rel14
  /// indicator that this DLSCH corresponds to SIB1-BR, needed for c_init for scrambling
  uint8_t sib1_br_flag;
  /// initial absolute subframe (see 36.211 Section 6.3.1), needed for c_init for scrambling
  uint16_t i0;
  CEmode_t CEmode;
#endif
312 313 314 315 316 317 318 319 320 321 322
} 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
323
  LTE_UL_UE_HARQ_t *harq_processes[8];
Cedric Roux's avatar
Cedric Roux committed
324 325
  /// Pointer to CQI data (+1 for 8 bits crc)
  uint8_t o[1+MAX_CQI_BYTES];
326 327
  /// Length of CQI data (bits)
  uint8_t O;
328
  /// Format of CQI data
329
  UCI_format_t uci_format;
330
  /// Rank information
331 332 333 334 335 336 337 338 339
  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;
340
  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
341
  uint8_t e[MAX_NUM_CHANNEL_BITS];
342
  /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
343
  uint8_t h[MAX_NUM_CHANNEL_BITS];
344
  /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
345
  uint8_t b_tilde[MAX_NUM_CHANNEL_BITS];
346
  /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
347
  int32_t d[MAX_NUM_RE];
348
  /// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15)
349
  int32_t z[MAX_NUM_RE];
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
  /// "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;
hbilel's avatar
hbilel committed
378 379
  /// Po_SRS - target output power for SRS
  int16_t Po_SRS;
380
  /// num active cba group
381 382 383 384 385
  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];
386 387
  /// UL max-harq-retransmission
  uint8_t Mlimit;
388 389 390 391 392 393 394 395 396
} 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;
397 398 399 400 401 402
  /// Flag to indicate that eNB should decode UE Msg3
  uint8_t Msg3_flag;
  /// Subframe for reception
  uint8_t subframe;
  /// Frame for reception
  uint32_t frame;
403 404
  /// Flag to indicate that the UL configuration has been handled. Used to remove a stale ULSCH when frame wraps around
  uint8_t handled;
405 406 407 408
  /// PHICH active flag
  uint8_t phich_active;
  /// PHICH ACK
  uint8_t phich_ACK;
409
  /// First Allocated RB
410
  uint16_t first_rb;
411 412 413 414
  /// First Allocated RB - previous scheduling
  /// This is needed for PHICH generation which
  /// is done after a new scheduling
  uint16_t previous_first_rb;
415
  /// Current Number of RBs
416 417 418
  uint16_t nb_rb; 
  /// Current Modulation order
  uint8_t Qm;
419 420
  /// Transport block size
  uint32_t TBS;
421 422
  /// The payload + CRC size in bits
  uint32_t B;
423 424
  /// Number of soft channel bits
  uint32_t G;
Raymond Knopp's avatar
 
Raymond Knopp committed
425 426 427 428
  /// CQI CRC status
  uint8_t cqi_crc_status;
  /// Pointer to CQI data
  uint8_t o[MAX_CQI_BYTES];
429
  /// Format of CQI data
Raymond Knopp's avatar
 
Raymond Knopp committed
430 431 432 433 434
  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;
435
  /// Rank information
Raymond Knopp's avatar
 
Raymond Knopp committed
436 437 438 439 440
  uint8_t o_RI[2];
  /// Length of rank information (bits)
  uint8_t O_RI;
  /// Pointer to ACK
  uint8_t o_ACK[4];
441 442
  /// Length of ACK information (bits)
  uint8_t O_ACK;
443
  /// The value of DAI in DCI format 0
444
  uint8_t V_UL_DAI;
Raymond Knopp's avatar
 
Raymond Knopp committed
445 446 447 448 449 450 451 452 453 454 455 456
  /// "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];
457
  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
458
  int16_t e[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32)));
Raymond Knopp's avatar
 
Raymond Knopp committed
459 460
  /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
  uint8_t h[MAX_NUM_CHANNEL_BITS];
461
  /// Pointer to the payload
462
  uint8_t *b;
463 464
  /// Pointers to transport block segments
  uint8_t *c[MAX_NUM_ULSCH_SEGMENTS];
465 466
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS];
Raymond Knopp's avatar
 
Raymond Knopp committed
467 468 469 470
  /// Current Number of Symbols
  uint8_t Nsymb_pusch;
  /// SRS active flag
  uint8_t srs_active;
Raymond Knopp's avatar
Raymond Knopp committed
471 472
  /// NDI
  uint8_t ndi;
473
  /// Index of current HARQ round for this ULSCH
474
  uint8_t round;
475 476
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
477
  /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
478
  int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
479
  /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
480
  int16_t *d[MAX_NUM_ULSCH_SEGMENTS];
481 482
  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
  uint32_t C;
483
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
484 485 486 487 488 489
  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)
490
  uint32_t Kplus;
491 492
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t F;
493
  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
494
  uint8_t Nl;
495 496 497 498 499 500
  /// 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;
501 502 503 504
  /// 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;
505 506 507 508
  /// 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;
509 510
  /// delta_TF for power control
  int32_t delta_TF;
511 512
} LTE_UL_eNB_HARQ_t;

513 514 515 516 517

typedef enum {
  pucch_format1=0,
  pucch_format1a,
  pucch_format1b,
518 519 520
  pucch_format1b_csA2,
  pucch_format1b_csA3,
  pucch_format1b_csA4,
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
  pucch_format2,
  pucch_format2a,
  pucch_format2b,
  pucch_format3    // PUCCH format3
} PUCCH_FMT_t;

typedef enum {
  SR,
  HARQ,
  CQI,
  HARQ_SR,
  HARQ_CQI,
  SR_CQI,
  HARQ_SR_CQI  
} UCI_type_t;

#ifdef Rel14
typedef enum {
  NOCE,
  CEMODEA,
  CEMODEB
} UE_type_t;
#endif

typedef struct {
  uint8_t     active;
  /// Absolute frame for this UCI
  uint16_t    frame;
  /// Absolute subframe for this UCI
  uint8_t     subframe;
  /// corresponding UE RNTI
  uint16_t    rnti;
  /// Type (SR,HARQ,CQI,HARQ_SR,HARQ_CQI,SR_CQI,HARQ_SR_CQI)
  UCI_type_t  type;
555 556
  /// SRS active flag
  uint8_t     srs_active;
557 558
  /// PUCCH format to use
  PUCCH_FMT_t pucch_fmt;
559 560 561
  /// number of PUCCH antenna ports 
  uint8_t     num_antenna_ports;
  /// number of PUCCH resources
562
  uint8_t     num_pucch_resources;
563 564 565 566 567
  /// two antenna n1_pucch 1_0
  uint16_t    n_pucch_1[4][2];
  /// two antenna n1_pucch 1_0 for SR
  uint16_t    n_pucch_1_0_sr[2];
   /// two antenna n2_pucch
568
  uint16_t    n_pucch_2[2];
569 570 571 572
  /// two antenna n3_pucch
  uint16_t    n_pucch_3[2];
  /// TDD Bundling/multiplexing flag
  uint8_t     tdd_bundling;
573 574
  /// Received Energy
  uint32_t stat;
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
#ifdef Rel14
  /// non BL/CE, CEmodeA, CEmodeB
  UE_type_t ue_type;
  /// Indicates the symbols that are left empty due to eMTC retuning.
  uint8_t empty_symbols;
  /// number of repetitions for BL/CE
  uint16_t total_repetitions;
  /// The size of the DL CQI/PMI in bits.
  uint16_t dl_cqi_pmi_size2;
  /// The starting PRB for the PUCCH
  uint8_t starting_prb;
  /// The number of PRB in PUCCH
  uint8_t n_PRB;
  /// Selected CDM option
  uint8_t cdm_Index;
  // Indicates if the resource blocks allocated for this grant overlap with the SRS configuration.
  uint8_t Nsrs;
#endif
593
} LTE_eNB_UCI;
594

595
typedef struct {
596 597
  /// HARQ process mask, indicates which processes are currently active
  uint16_t harq_mask;
598
  /// Pointers to 8 HARQ processes for the ULSCH
599
  LTE_UL_eNB_HARQ_t *harq_processes[8];
600 601
  /// Maximum number of HARQ rounds
  uint8_t Mlimit;
602 603 604 605 606 607 608 609 610 611
  /// 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;
612
  /// Flag to indicate that eNB awaits UE Msg3
613 614 615 616 617 618 619
  uint8_t Msg3_active;
  /// RNTI attributed to this ULSCH
  uint16_t rnti;
  /// cyclic shift for DM RS
  uint8_t cyclicShift;
  /// cooperation flag
  uint8_t cooperation_flag;
620
  /// num active cba group
621 622 623
  uint8_t num_active_cba_groups;
  /// allocated CBA RNTI for this ulsch
  uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
624 625 626 627
#ifdef LOCALIZATION
  /// epoch timestamp in millisecond
  int32_t reference_timestamp_ms;
  /// aggregate physical states every n millisecond
628
  int32_t aggregation_period_ms;
629
  /// a set of lists used for localization
630 631
  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;
632
#endif
633 634 635
} LTE_eNB_ULSCH_t;

typedef struct {
636 637 638 639
  /// Indicator of first transmission
  uint8_t first_tx;
  /// Last Ndi received for this process on DCI (used for C-RNTI only)
  uint8_t DCINdi;
640
  /// DLSCH status flag indicating
641 642 643
  SCH_status_t status;
  /// Transport block size
  uint32_t TBS;
644 645
  /// The payload + CRC size in bits
  uint32_t B;
646
  /// Pointer to the payload
647
  uint8_t *b;
648 649
  /// Pointers to transport block segments
  uint8_t *c[MAX_NUM_DLSCH_SEGMENTS];
650 651
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS];
652
  /// Index of current HARQ round for this DLSCH
653
  uint8_t round;
654
  /// MCS format for this DLSCH
655
  uint8_t mcs;
656 657
  /// Qm (modulation order) for this DLSCH
  uint8_t Qm;
658 659 660 661
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
  /// MIMO mode for this DLSCH
  MIMO_mode_t mimo_mode;
662
  /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
663
  int16_t w[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)];
664
  /// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
665
  double w_abs[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)];
666
  /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
667
  int16_t *d[MAX_NUM_DLSCH_SEGMENTS];
668 669
  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
  uint32_t C;
670
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
671 672 673 674 675 676
  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)
677
  uint32_t Kplus;
678 679
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t F;
680 681 682
  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Nl;
  /// current delta_pucch
683
  int8_t delta_PUCCH;
684 685 686 687 688 689
  /// Number of soft channel bits
  uint32_t G;
  /// Current Number of RBs
  uint16_t nb_rb;
  /// Current subband PMI allocation
  uint16_t pmi_alloc;
690 691 692 693 694 695
  /// 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;
696 697
  /// downlink power offset field
  uint8_t dl_power_off;
698 699 700 701
  /// trials per round statistics
  uint32_t trials[8];
  /// error statistics per round
  uint32_t errors[8];
702 703
  /// codeword this transport block is mapped to
  uint8_t codeword;
704 705
} LTE_DL_UE_HARQ_t;

706
typedef struct {
707 708 709 710
  /// time-based localization, relying on TA and TOA
  double time_based;
  /// power-based localization, relying on RSS and RSSI
  double power_based;
711
} eNB_UE_estimated_distances;
712 713 714

typedef struct {
  /// UL RSSI per receive antenna
715
  int32_t UL_rssi[NB_ANTENNAS_RX];
716
  /// PUCCH1a/b power (digital linear)
717
  uint32_t Po_PUCCH;
718 719 720
  /// PUCCH1a/b power (dBm)
  int32_t Po_PUCCH_dBm;
  /// PUCCH1 power (digital linear), conditioned on below threshold
721
  uint32_t Po_PUCCH1_below;
722
  /// PUCCH1 power (digital linear), conditioned on above threshold
723
  uint32_t Po_PUCCH1_above;
724 725
  /// Indicator that Po_PUCCH has been updated by PHY
  int32_t Po_PUCCH_update;
726 727 728 729 730 731 732 733 734 735 736 737 738
  /// 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
739
  int32_t UE_timing_offset;
740
  /// Timing advance estimate from PUSCH for MAC timing advance signalling
741
  int32_t timing_advance_update;
742 743 744 745
  /// Current mode of UE (NOT SYCHED, RAR, PUSCH)
  UE_MODE_t mode;
  /// Current sector where UE is attached
  uint8_t sector;
746

Florian Kaltenberger's avatar
Florian Kaltenberger committed
747 748
  /// dlsch l2 errors
  uint32_t dlsch_l2_errors[8];
749
  /// dlsch trials per harq and round
Florian Kaltenberger's avatar
Florian Kaltenberger committed
750 751 752 753 754 755 756 757
  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
758
  uint32_t ulsch_consecutive_errors; //[8];
Florian Kaltenberger's avatar
Florian Kaltenberger committed
759 760 761 762 763 764
  /// 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];
765 766 767
  uint32_t sr_received;
  uint32_t sr_total;

Florian Kaltenberger's avatar
Florian Kaltenberger committed
768 769 770
  /// 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;
771
  int8_t dlsch_mcs_offset;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
772

773 774 775 776
  /// 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
777 778 779
  /// Total bits received from MAC on PDSCH
  int total_TBS_MAC;
  /// Total bits acknowledged on PDSCH
780
  int total_TBS;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
781
  /// Total bits acknowledged on PDSCH (last interval)
782
  int total_TBS_last;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
783
  /// Bitrate on the PDSCH [bps]
784
  unsigned int dlsch_bitrate;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
785
  //  unsigned int total_transmitted_bits;
786 787 788 789
#ifdef LOCALIZATION
  eNB_UE_estimated_distances distance;
  int32_t *subcarrier_rssi;
#endif
790 791 792 793 794
} LTE_eNB_UE_stats;

typedef struct {
  /// HARQ process id
  uint8_t harq_id;
795
  /// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX
796 797 798 799 800
  uint8_t ack;
  /// send status (for PUCCH)
  uint8_t send_harq_status;
  /// nCCE (for PUCCH)
  uint8_t nCCE;
801 802 803 804
  /// DAI value detected from DCI1/1a/1b/1d/2/2a/2b/2c. 0xff indicates not touched
  uint8_t vDAI_DL;
  /// DAI value detected from DCI0/4. 0xff indicates not touched
  uint8_t vDAI_UL;
805 806 807 808 809 810 811 812 813 814 815 816 817
} 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;
hbilel's avatar
hbilel committed
818
  /// Current HARQ process id threadRx Odd and threadRx Even
819 820 821 822 823 824 825 826 827
  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;
828 829
  /// saved subband PMI allocation from last PUSCH/PUCCH report
  uint16_t pmi_alloc;
830 831 832
  /// HARQ-ACKs
  harq_status_t harq_ack[10];
  /// Pointers to up to 8 HARQ processes
833
  LTE_DL_UE_HARQ_t *harq_processes[8];
834
  /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17
835
  uint8_t Mdlharq;
836 837
  /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Kmimo;
838 839
  /// Nsoft parameter related to UE Category
  uint32_t Nsoft;
840 841
  /// Maximum number of Turbo iterations
  uint8_t max_turbo_iterations;
842 843
  /// number of iterations used in last turbo decoding
  uint8_t last_iteration_cnt;
844 845
  /// accumulated tx power adjustment for PUCCH
  int8_t               g_pucch;
846 847
} LTE_UE_DLSCH_t;

848

849 850 851 852

typedef enum {
  SI_PDSCH=0,
  RA_PDSCH,
853
  P_PDSCH,
854
  PDSCH,
855
  PDSCH1,
856 857 858
  PMCH
} PDSCH_t;

859 860 861 862
typedef enum {
  rx_standard=0,
  rx_IC_single_stream,
  rx_IC_dual_stream,
lukashov's avatar
lukashov committed
863
  rx_SIC_dual_stream
864 865
} RX_type_t;

866

867 868 869 870
typedef enum {
  DCI_COMMON_SPACE,
  DCI_UE_SPACE
} dci_space_t;
871 872 873 874


/**@}*/
#endif