defs.h 36.5 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"
37
#ifndef STANDALONE_COMPILE
38
#include "UTIL/LISTS/list.h"
39
#endif
40

41 42
#include "dci_nb_iot.h"

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 97 98 99 100 101 102 103 104 105 106 107 108

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;
109 110
  /// The payload + CRC size in bits, "B" from 36-212
  uint32_t B;
111
  /// Pointer to the payload
112
  uint8_t *b;
113
  /// Pointers to transport block segments
114
  uint8_t *c[MAX_NUM_DLSCH_SEGMENTS];
115 116
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS];
117 118 119 120
  /// Frame where current HARQ round was sent
  uint32_t frame;
  /// Subframe where current HARQ round was sent
  uint32_t subframe;
121 122
  /// Index of current HARQ round for this DLSCH
  uint8_t round;
123
  /// MCS format for this DLSCH
124
  uint8_t mcs;
125 126 127 128
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
  /// MIMO mode for this DLSCH
  MIMO_mode_t mimo_mode;
129 130
  /// Current RB allocation
  uint32_t rb_alloc[4];
131 132
  /// distributed/localized flag
  vrb_t vrb_type;
133 134 135 136 137 138 139 140 141 142 143 144
  /// 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;
145
  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
146
  uint8_t e[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32)));
147
  /// Turbo-code outputs (36-212 V8.6 2009-03, p.12
148
  uint8_t *d[MAX_NUM_DLSCH_SEGMENTS];//[(96+3+(3*6144))];
149
  /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17)
150 151 152
  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;
153
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
154
  uint32_t Cminus;
155
  /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
156 157 158
  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;
159
  /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
160
  uint32_t Kplus;
161
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
162
  uint32_t F;
163
  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17, TM3-4)
164
  uint8_t Nl;
165 166 167 168
  /// Number of layers for this PDSCH transmission (TM8-10)
  uint8_t Nlayers;
  /// First layer for this PSCH transmission
  uint8_t first_layer;
169 170
   /// codeword this transport block is mapped to
  uint8_t codeword;
171 172
} LTE_DL_eNB_HARQ_t;

173

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

  // decode phich
  uint8_t decode_phich;
246 247 248
} LTE_UL_UE_HARQ_t;

typedef struct {
Raymond Knopp's avatar
 
Raymond Knopp committed
249
  /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
Florian Kaltenberger's avatar
Florian Kaltenberger committed
250
  int32_t *txdataF[8];
Xiwen JIANG's avatar
Xiwen JIANG committed
251
  /// 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
252
  int32_t **ue_spec_bf_weights[4]; 
253 254
  /// dl channel estimates (estimated from ul channel estimates)
  int32_t **calib_dl_ch_estimates;
255
  /// Allocated RNTI (0 means DLSCH_t is not currently used)
256
  uint16_t rnti;
257 258 259 260
  /// 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];
261
  /// First CCE of last PDSCH scheduling per subframe.  Again used during PUCCH detection for ACK/NAK.
262 263 264 265 266 267 268 269 270 271
  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
272
  LTE_DL_eNB_HARQ_t *harq_processes[8];
273 274 275
  /// Number of soft channel bits
  uint32_t G;
  /// Codebook index for this dlsch (0,1,2,3)
276
  uint8_t codebook_index;
277
  /// Maximum number of HARQ processes (for definition see 36-212 V8.6 2009-03, p.17)
278
  uint8_t Mdlharq;
279 280
  /// Maximum number of HARQ rounds
  uint8_t Mlimit;
281 282
  /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Kmimo;
283 284
  /// Nsoft parameter related to UE Category
  uint32_t Nsoft;
285
  /// amplitude of PDSCH (compared to RS) in symbols without pilots
286 287 288
  int16_t sqrt_rho_a;
  /// amplitude of PDSCH (compared to RS) in symbols containing pilots
  int16_t sqrt_rho_b;
Raymond Knopp's avatar
 
Raymond Knopp committed
289

290 291 292 293 294 295 296 297 298 299 300
} 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
301
  LTE_UL_UE_HARQ_t *harq_processes[8];
302 303 304 305
  /// Pointer to CQI data
  uint8_t o[MAX_CQI_BYTES];
  /// Length of CQI data (bits)
  uint8_t O;
306
  /// Format of CQI data
307
  UCI_format_t uci_format;
308
  /// Rank information
309 310 311 312 313 314 315 316 317
  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;
318
  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
319
  uint8_t e[MAX_NUM_CHANNEL_BITS];
320
  /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
321
  uint8_t h[MAX_NUM_CHANNEL_BITS];
322
  /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
323
  uint8_t b_tilde[MAX_NUM_CHANNEL_BITS];
324
  /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
325
  int32_t d[MAX_NUM_RE];
326
  /// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15)
327
  int32_t z[MAX_NUM_RE];
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
  /// "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
356 357
  /// Po_SRS - target output power for SRS
  int16_t Po_SRS;
358
  /// num active cba group
359 360 361 362 363
  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];
364 365
  /// UL max-harq-retransmission
  uint8_t Mlimit;
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
} 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;
385
  /// First Allocated RB
386
  uint16_t first_rb;
387 388 389 390
  /// First Allocated RB - previous scheduling
  /// This is needed for PHICH generation which
  /// is done after a new scheduling
  uint16_t previous_first_rb;
391 392 393 394
  /// Current Number of RBs
  uint16_t nb_rb;
  /// Transport block size
  uint32_t TBS;
395 396
  /// The payload + CRC size in bits
  uint32_t B;
397 398
  /// Number of soft channel bits
  uint32_t G;
Raymond Knopp's avatar
 
Raymond Knopp committed
399 400 401 402
  /// CQI CRC status
  uint8_t cqi_crc_status;
  /// Pointer to CQI data
  uint8_t o[MAX_CQI_BYTES];
403
  /// Format of CQI data
Raymond Knopp's avatar
 
Raymond Knopp committed
404 405 406 407 408
  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;
409
  /// Rank information
Raymond Knopp's avatar
 
Raymond Knopp committed
410 411 412 413 414
  uint8_t o_RI[2];
  /// Length of rank information (bits)
  uint8_t O_RI;
  /// Pointer to ACK
  uint8_t o_ACK[4];
415 416
  /// Length of ACK information (bits)
  uint8_t O_ACK;
417
  /// The value of DAI in DCI format 0
418
  uint8_t V_UL_DAI;
Raymond Knopp's avatar
 
Raymond Knopp committed
419 420 421 422 423 424 425 426 427 428 429 430
  /// "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];
431
  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
432
  int16_t e[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32)));
Raymond Knopp's avatar
 
Raymond Knopp committed
433 434
  /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
  uint8_t h[MAX_NUM_CHANNEL_BITS];
435
  /// Pointer to the payload
436
  uint8_t *b;
437 438
  /// Pointers to transport block segments
  uint8_t *c[MAX_NUM_ULSCH_SEGMENTS];
439 440
  /// 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
441 442 443 444
  /// Current Number of Symbols
  uint8_t Nsymb_pusch;
  /// SRS active flag
  uint8_t srs_active;
445
  /// Index of current HARQ round for this ULSCH
446
  uint8_t round;
447
  /// MCS format for this ULSCH
448
  uint8_t mcs;
449 450
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
451
  /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
452
  int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
453
  /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
454
  int16_t *d[MAX_NUM_ULSCH_SEGMENTS];
455 456
  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
  uint32_t C;
457
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
458 459 460 461 462 463
  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)
464
  uint32_t Kplus;
465 466
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t F;
467
  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
468
  uint8_t Nl;
469 470 471 472 473 474
  /// 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;
475 476 477 478
  /// 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;
479 480 481 482
  /// 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;
483 484
  /// delta_TF for power control
  int32_t delta_TF;
485 486 487 488
} LTE_UL_eNB_HARQ_t;

typedef struct {
  /// Pointers to 8 HARQ processes for the ULSCH
489
  LTE_UL_eNB_HARQ_t *harq_processes[8];
490 491
  /// Maximum number of HARQ rounds
  uint8_t Mlimit;
492 493 494 495 496 497 498 499 500 501
  /// 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;
502
  /// Flag to indicate that eNB awaits UE Msg3
503
  uint8_t Msg3_active;
504
  /// Flag to indicate that eNB should decode UE Msg3
505 506 507 508 509 510 511 512 513 514 515
  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;
516
  /// num active cba group
517 518 519
  uint8_t num_active_cba_groups;
  /// allocated CBA RNTI for this ulsch
  uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
520 521 522 523
#ifdef LOCALIZATION
  /// epoch timestamp in millisecond
  int32_t reference_timestamp_ms;
  /// aggregate physical states every n millisecond
524
  int32_t aggregation_period_ms;
525
  /// a set of lists used for localization
526 527
  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;
528
#endif
529 530 531
} LTE_eNB_ULSCH_t;

typedef struct {
532 533 534 535
  /// Indicator of first transmission
  uint8_t first_tx;
  /// Last Ndi received for this process on DCI (used for C-RNTI only)
  uint8_t DCINdi;
536
  /// DLSCH status flag indicating
537 538 539
  SCH_status_t status;
  /// Transport block size
  uint32_t TBS;
540 541
  /// The payload + CRC size in bits
  uint32_t B;
542
  /// Pointer to the payload
543
  uint8_t *b;
544 545
  /// Pointers to transport block segments
  uint8_t *c[MAX_NUM_DLSCH_SEGMENTS];
546 547
  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
  uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS];
548
  /// Index of current HARQ round for this DLSCH
549
  uint8_t round;
550
  /// MCS format for this DLSCH
551
  uint8_t mcs;
552 553
  /// Qm (modulation order) for this DLSCH
  uint8_t Qm;
554 555 556 557
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
  /// MIMO mode for this DLSCH
  MIMO_mode_t mimo_mode;
558
  /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
559
  int16_t w[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)];
560
  /// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
561
  double w_abs[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)];
562
  /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
563
  int16_t *d[MAX_NUM_DLSCH_SEGMENTS];
564 565
  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
  uint32_t C;
566
  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
567 568 569 570 571 572
  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)
573
  uint32_t Kplus;
574 575
  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
  uint32_t F;
576 577 578
  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Nl;
  /// current delta_pucch
579
  int8_t delta_PUCCH;
580 581 582 583 584 585
  /// Number of soft channel bits
  uint32_t G;
  /// Current Number of RBs
  uint16_t nb_rb;
  /// Current subband PMI allocation
  uint16_t pmi_alloc;
586 587 588 589 590 591
  /// 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;
592 593
  /// downlink power offset field
  uint8_t dl_power_off;
594 595 596 597
  /// trials per round statistics
  uint32_t trials[8];
  /// error statistics per round
  uint32_t errors[8];
598 599
  /// codeword this transport block is mapped to
  uint8_t codeword;
600 601
} LTE_DL_UE_HARQ_t;

602
typedef struct {
603 604 605 606
  /// time-based localization, relying on TA and TOA
  double time_based;
  /// power-based localization, relying on RSS and RSSI
  double power_based;
607
} eNB_UE_estimated_distances;
608 609 610

typedef struct {
  /// UL RSSI per receive antenna
611
  int32_t UL_rssi[NB_ANTENNAS_RX];
612
  /// PUCCH1a/b power (digital linear)
613
  uint32_t Po_PUCCH;
614 615 616
  /// PUCCH1a/b power (dBm)
  int32_t Po_PUCCH_dBm;
  /// PUCCH1 power (digital linear), conditioned on below threshold
617
  uint32_t Po_PUCCH1_below;
618
  /// PUCCH1 power (digital linear), conditioned on above threshold
619
  uint32_t Po_PUCCH1_above;
620 621
  /// Indicator that Po_PUCCH has been updated by PHY
  int32_t Po_PUCCH_update;
622 623 624 625 626 627 628 629 630 631 632 633 634
  /// 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
635
  int32_t UE_timing_offset;
636
  /// Timing advance estimate from PUSCH for MAC timing advance signalling
637
  int32_t timing_advance_update;
638 639 640 641
  /// Current mode of UE (NOT SYCHED, RAR, PUSCH)
  UE_MODE_t mode;
  /// Current sector where UE is attached
  uint8_t sector;
642

Florian Kaltenberger's avatar
Florian Kaltenberger committed
643 644
  /// dlsch l2 errors
  uint32_t dlsch_l2_errors[8];
645
  /// dlsch trials per harq and round
Florian Kaltenberger's avatar
Florian Kaltenberger committed
646 647 648 649 650 651 652 653
  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
654
  uint32_t ulsch_consecutive_errors; //[8];
Florian Kaltenberger's avatar
Florian Kaltenberger committed
655 656 657 658 659 660
  /// 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];
661 662 663
  uint32_t sr_received;
  uint32_t sr_total;

Florian Kaltenberger's avatar
Florian Kaltenberger committed
664 665 666
  /// 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;
667
  int8_t dlsch_mcs_offset;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
668

669 670 671 672
  /// 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
673 674 675
  /// Total bits received from MAC on PDSCH
  int total_TBS_MAC;
  /// Total bits acknowledged on PDSCH
676
  int total_TBS;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
677
  /// Total bits acknowledged on PDSCH (last interval)
678
  int total_TBS_last;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
679
  /// Bitrate on the PDSCH [bps]
680
  unsigned int dlsch_bitrate;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
681
  //  unsigned int total_transmitted_bits;
682 683 684 685
#ifdef LOCALIZATION
  eNB_UE_estimated_distances distance;
  int32_t *subcarrier_rssi;
#endif
686 687 688 689 690
} LTE_eNB_UE_stats;

typedef struct {
  /// HARQ process id
  uint8_t harq_id;
691
  /// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX
692 693 694 695 696
  uint8_t ack;
  /// send status (for PUCCH)
  uint8_t send_harq_status;
  /// nCCE (for PUCCH)
  uint8_t nCCE;
697 698 699 700
  /// 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;
701 702 703 704 705 706 707 708 709 710 711 712 713
} 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
714
  /// Current HARQ process id threadRx Odd and threadRx Even
715 716 717 718 719 720 721 722 723
  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;
724 725
  /// saved subband PMI allocation from last PUSCH/PUCCH report
  uint16_t pmi_alloc;
726 727 728
  /// HARQ-ACKs
  harq_status_t harq_ack[10];
  /// Pointers to up to 8 HARQ processes
729
  LTE_DL_UE_HARQ_t *harq_processes[8];
730
  /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17
731
  uint8_t Mdlharq;
732 733
  /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Kmimo;
734 735
  /// Nsoft parameter related to UE Category
  uint32_t Nsoft;
736 737
  /// Maximum number of Turbo iterations
  uint8_t max_turbo_iterations;
738 739
  /// number of iterations used in last turbo decoding
  uint8_t last_iteration_cnt;
740 741
  /// accumulated tx power adjustment for PUCCH
  int8_t               g_pucch;
742 743 744
} LTE_UE_DLSCH_t;

typedef enum {format0,
745 746 747 748 749 750 751 752 753 754 755
              format1,
              format1A,
              format1B,
              format1C,
              format1D,
              format1E_2A_M10PRB,
              format2,
              format2A,
              format2B,
              format2C,
              format2D,
756 757 758
              format3,
	      format3A,
	      format4
759
             } DCI_format_t;
760 761 762 763

typedef enum {
  SI_PDSCH=0,
  RA_PDSCH,
764
  P_PDSCH,
765
  PDSCH,
766
  PDSCH1,
767 768 769
  PMCH
} PDSCH_t;

770 771 772 773
typedef enum {
  rx_standard=0,
  rx_IC_single_stream,
  rx_IC_dual_stream,
lukashov's avatar
lukashov committed
774
  rx_SIC_dual_stream
775 776
} RX_type_t;

777 778 779 780 781 782
typedef enum {
  pucch_format1=0,
  pucch_format1a,
  pucch_format1b,
  pucch_format2,
  pucch_format2a,
Yoshi's avatar
Yoshi committed
783 784
  pucch_format2b,
  pucch_format3    // PUCCH format3
785 786 787 788 789 790
} PUCCH_FMT_t;


typedef struct {
  /// Length of DCI in bits
  uint8_t dci_length;
791
  /// Aggregation level
792 793
  uint8_t L;
  /// Position of first CCE of the dci
794
  int firstCCE;
795
  /// flag to indicate that this is a RA response
Lionel Gauthier's avatar
Lionel Gauthier committed
796
  boolean_t ra_flag;
797
  /// rnti
Lionel Gauthier's avatar
Lionel Gauthier committed
798
  rnti_t rnti;
799 800 801 802 803 804
  /// Format
  DCI_format_t format;
  /// DCI pdu
  uint8_t dci_pdu[8];
} DCI_ALLOC_t;

805 806 807 808
//----------------------------------------------------------------------------------------------------------
// NB-IoT
//----------------------------------------------------------------------------------------------------

809 810 811
//enum for distinguish the different type of ndlsch (may in the future will be not needed)
typedef enum
{
812 813 814 815
  SIB1,
  SI_Message,
  RAR,
  UE_Data
816 817 818

}ndlsch_flag_t;

819

820 821

typedef struct {
822 823 824 825 826
  rnti_t rnti;
  //array containing the pdus of DCI
  uint8_t *a[2];
  //Array containing encoded DCI data
  uint8_t *e[2];
827

828 829
  //UE specific parameters
  uint16_t npdcch_NumRepetitions;
830

831 832 833
  uint16_t repetition_number;
  //indicate the corresponding subframe within the repetition (set to 0 when a new NPDCCH pdu is received)
  uint16_t repetition_idx;
834

835 836
//  uint16_t npdcch_Offset_USS;
//  uint16_t npdcch_StartSF_USS;
837

838 839 840 841

}NB_IoT_eNB_NPDCCH_t;


842 843 844 845 846 847 848 849 850 851 852 853 854
typedef struct{

//Number of repetitions (R) for common search space (RAR and PAGING)
uint16_t number_repetition_RA;
uint16_t number_repetition_PAg;
//index of the current subframe among the repetition (set to 0 when we receive the new NPDCCH)
uint16_t repetition_idx_RA;
uint16_t repetition_idx_Pag;


}NB_IoT_eNB_COMMON_NPDCCH_t;


855
typedef struct {
856

857 858
  /// Length of DCI in bits
  uint8_t dci_length;
859
  /// Aggregation level only 1,2 in NB-IoT
860 861 862 863 864 865 866 867
  uint8_t L;
  /// Position of first CCE of the dci
  int firstCCE;
  /// flag to indicate that this is a RA response
  boolean_t ra_flag;
  /// rnti
  rnti_t rnti;
  /// Format
868
  DCI_format_NB_IoT_t format;
869 870
  /// DCI pdu
  uint8_t dci_pdu[8];
871
} DCI_ALLOC_NB_IoT_t;
872

873

874 875 876
typedef struct {
  //delete the count for the DCI numbers,NUM_DCI_MAX should set to 2
  uint32_t num_npdcch_symbols;
877 878 879
  ///indicates the starting OFDM symbol in the first slot of a subframe k for the NPDCCH transmission
  /// see FAPI/NFAPI specs Table 4-45
  uint8_t npdcch_start_symbol;
880
  uint8_t Num_dci;
881
  DCI_ALLOC_NB_IoT_t dci_alloc[2] ;
882
} DCI_PDU_NB_IoT;
883 884


885 886 887
typedef struct {
  /// NB-IoT
  /// The scheduling the NPDCCH and the NPDSCH transmission TS 36.213 Table 16.4.1-1
888
  uint8_t scheduling_delay;
889
  /// The number of the subframe to transmit the NPDSCH Table TS 36.213 Table 16.4.1.3-1  (Nsf) (NB. in this case is not the index Isf)
890
  uint8_t resource_assignment;
891
  /// is the index that determined the repeat number of NPDSCH through table TS 36.213 Table 16.4.1.3-2 / for SIB1-NB Table 16.4.1.3-3
892 893 894
  uint8_t repetition_number;
  /// Determined the ACK/NACK delay and the subcarrier allocation TS 36.213 Table 16.4.2
  uint8_t HARQ_ACK_resource;
895
  /// Determined the repetition number value 0-3 (2 biut carried by the FAPI NPDCCH)
896 897 898 899 900 901 902 903 904 905 906 907
  uint8_t dci_subframe_repetitions;
  /// modulation always QPSK Qm = 2 
  uint8_t modulation;

  /// Status Flag indicating for this DLSCH (idle,active,disabled)
  SCH_status_t status;
  /// Transport block size
  uint32_t TBS;
  /// The payload + CRC size in bits, "B" from 36-212
  uint32_t B;
  /// Pointer to the payload
  uint8_t *b;
908 909
  ///pdu of the ndlsch message
  uint8_t*pdu;
910 911 912 913 914 915 916 917 918 919
  /// Frame where current HARQ round was sent
  uint32_t frame;
  /// Subframe where current HARQ round was sent
  uint32_t subframe;
  /// Index of current HARQ round for this DLSCH
  uint8_t round;
  /// MCS format for this NDLSCH , TS 36.213 Table 16.4.1.5
  uint8_t mcs;
  // we don't have code block segmentation / crc attachment / concatenation in NB-IoT R13 36.212 6.4.2
  // we don't have beamforming in NB-IoT
920 921
  //this index will be used mainly for SI message buffer
   uint8_t pdu_buffer_index;
922 923 924

} NB_IoT_DL_eNB_HARQ_t;

925 926 927 928 929 930 931 932 933 934 935 936 937 938 939
typedef struct {
  /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
  int32_t *txdataF[8];
  /// dl channel estimates (estimated from ul channel estimates)
  int32_t **calib_dl_ch_estimates;
  /// Allocated RNTI (0 means DLSCH_t is not currently used)
  uint16_t rnti;
  /// 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];
  /// First CCE of last PDSCH scheduling per subframe.  Again used during PUCCH detection for ACK/NAK.
  uint8_t nCCE[10];

  /*in NB-IoT there is only 1 HARQ process for each UE therefore no pid is required*/
940 941
  /// The only HARQ process for the DLSCH
  NB_IoT_DL_eNB_HARQ_t *harq_process;
942 943 944 945 946 947 948 949 950 951 952
  /// Number of soft channel bits
  uint32_t G;
  /// Maximum number of HARQ rounds
  uint8_t Mlimit;
  /// Nsoft parameter related to UE Category
  uint32_t Nsoft;
  /// 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;

953 954 955 956 957 958
  ///NB-IoT
  /// may use in the npdsch_procedures
  uint16_t scrambling_sequence_intialization;
  /// number of cell specific TX antenna ports assumed by the UE
  uint8_t nrs_antenna_ports;

959
  //This indicate the current subframe within the subframe interval between the NPDSCH transmission (Nsf*Nrep)
960 961
  uint16_t sf_index;

962 963 964 965
  ///indicates the starting OFDM symbol in the first slot of a subframe k for the NPDSCH transmission
  /// see FAPI/NFAPI specs Table 4-47
  uint8_t npdsch_start_symbol;

966 967 968 969 970 971 972
  /*SIB1-NB related parameters*/
  ///flag for indicate if the current frame is the start of a new SIB1-NB repetition within the SIB1-NB period (0 = FALSE, 1 = TRUE)
  uint8_t sib1_rep_start;
  ///the number of the frame within the 16 continuous frame in which sib1-NB is transmitted (1-8 = 1st, 2nd ecc..) (0 = not foresees a transmission)
  uint8_t relative_sib1_frame;

  //Flag  used to discern among different NDLSCH structures (SIB1,SI,RA,UE-spec)
973
  //(used inside the ndlsch procedure for distinguish the different type of data to manage also in term of repetitions and transmission over more subframes
974
  ndlsch_flag_t ndlsch_type;
975

976

977

978 979
} NB_IoT_eNB_NDLSCH_t;

980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046
typedef struct {

  /// Determined the subcarrier allocation for the NPUSCH.(15, 3.75 KHz)
  uint8_t subcarrier_indication;
  /// Determined the number of resource unit for the NPUSCH
  uint8_t resource_assignment;
  /// Determined the scheduling delay for NPUSCH
  uint8_t scheduling_delay;
  /// The number of the repetition number for NPUSCH Transport block
  uint8_t repetition_number;
  /// Determined the repetition number value 0-3
  uint8_t dci_subframe_repetitions;

  /// 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;

  /// Transport block size
  uint32_t TBS;
  /// The payload + CRC size in bits
  uint32_t B;
  /// Number of soft channel bits
  uint32_t G;

  /// Pointer to ACK
  uint8_t o_ACK[4];
  /// Length of ACK information (bits)
  uint8_t O_ACK;

  /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
  uint8_t h[MAX_NUM_CHANNEL_BITS];
  /// Pointer to the payload
  uint8_t *b;

  /// Current Number of Symbols
  uint8_t Nsymb_pusch;

  /// Index of current HARQ round for this ULSCH
  uint8_t round;
  /// MCS format for this ULSCH
  uint8_t mcs;
  /// Redundancy-version of the current sub-frame (value 0->RV0,value 1 ->RV2)
  uint8_t rvidx;

  /// 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_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;
  /// 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;
  /// delta_TF for power control
  int32_t delta_TF;
} NB_IoT_UL_eNB_HARQ_t;

1047 1048 1049

typedef struct {
  /// Pointers to 8 HARQ processes for the ULSCH
1050
  NB_IoT_UL_eNB_HARQ_t *harq_process;
1051
  /// Maximum number of HARQ rounds
Nick Ho's avatar
Nick Ho committed
1052
  uint8_t Mlimit;
1053 1054 1055

  /// Value 0 = npush format 1 (data) value 1 = npusch format 2 (ACK/NAK)
  uint8_t npusch_format;
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069
  /// Flag to indicate that eNB awaits UE Msg3
  uint8_t Msg3_active;
  /// Flag to indicate that eNB should decode UE Msg3
  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;
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082
  /// (only in-band mode), indicate the resource block overlap the SRS configuration of LTE
  uint8_t N_srs;

  uint8_t scrambling_re_intialization_batch_index;
  /// number of cell specific TX antenna ports assumed by the UE
  uint8_t nrs_antenna_ports;

  uint16_t scrambling_sequence_intialization;

  uint16_t sf_index;

  /// Determined the ACK/NACK delay and the subcarrier allocation TS 36.213 Table 16.4.2
  uint8_t HARQ_ACK_resource;
1083 1084 1085

} NB_IoT_eNB_NULSCH_t;

1086 1087 1088 1089 1090


#define NPBCH_A 34

typedef struct {
1091 1092 1093
  //the 2 LSB of the hsfn (the MSB are indicated by the SIB1-NB)
  uint16_t h_sfn_lsb;

1094 1095 1096 1097 1098
  uint8_t npbch_d[96+(3*(16+NPBCH_A))];
  uint8_t npbch_w[3*3*(16+NPBCH_A)];
  uint8_t npbch_e[1600];
  ///pdu of the npbch message
  uint8_t*pdu;
1099
} NB_IoT_eNB_NPBCH_t;
1100 1101


1102 1103
//---------------------------------------------------------------------------------------

1104 1105
/**@}*/
#endif