nr_transport_ue.h 13.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*
 * 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.1  (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
 */

/*! \file PHY/NR_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 __NR_TRANSPORT_UE__H__
#define __NR_TRANSPORT_UE__H__
34 35
#include <limits.h>
#include "PHY/impl_defs_top.h"
Jacques's avatar
Jacques committed
36

37
#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h"
Agustin's avatar
Agustin committed
38

39
//#include "PHY/defs_nr_UE.h"
Hongzhi Wang's avatar
Hongzhi Wang committed
40
#include "../NR_TRANSPORT/nr_transport_common_proto.h"
41 42 43 44
#ifndef STANDALONE_COMPILE
#include "UTIL/LISTS/list.h"
#endif

45
#include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h"
46

47 48 49 50 51 52 53

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

/** @addtogroup _PHY_TRANSPORT_
 * @{
 */

Jacques's avatar
Jacques committed
54 55 56 57 58
typedef enum {
 NEW_TRANSMISSION_HARQ,
 RETRANSMISSION_HARQ
} harq_result_t;

59 60 61 62 63
//#if defined(UPGRADE_RAT_NR)
#if 1
typedef struct {
  /// HARQ process id
  uint8_t harq_id;
Jacques's avatar
Jacques committed
64 65
  /// HARQ rx status
  harq_result_t rx_status;
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
  /// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX
  uint8_t ack;
  /// send status (for PUCCH)
  uint8_t send_harq_status;
  /// nCCE (for PUCCH)
  uint8_t nCCE;
  /// 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;
  /// allow to define pucch parameters TS 38.213 9.2.3 UE procedure for reporting HARQ-ACK
  uint8_t  pucch_resource_indicator;
  /// slot on which feedback ack should be send to network
  uint16_t slot_for_feedback_ack;
  /// index of a first CCE for the PDCCH reception
  uint8_t  n_CCE;
  /// number of CCEs in a control resource set of a PDCCH reception conveying DCI format 1_0
  uint8_t  N_CCE;
} NR_UE_HARQ_STATUS_t;
#endif
86 87

typedef struct {
88 89
  /// NDAPI struct for UE
  nfapi_nr_ue_pusch_pdu_t pusch_pdu;
90 91
  /// Indicator of first transmission
  uint8_t first_tx;
Jacques's avatar
Jacques committed
92 93
  /// HARQ tx status
  harq_result_t tx_status;
94 95 96 97 98 99 100 101 102 103 104 105 106 107
  /// 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;
  /// Last TPC command
  uint8_t TPC;
  /// The payload + CRC size in bits, "B" from 36-212
  uint32_t B;
  /// Length of ACK information (bits)
  uint8_t O_ACK;
  /// Index of current HARQ round for this ULSCH
  uint8_t round;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
108 109
  /// Last Ndi for this harq process
  uint8_t ndi;
110
  /// pointer to pdu from MAC interface (TS 36.212 V15.4.0, Sec 5.1 p. 8)
111
  unsigned char *a;
112 113 114 115
  /// Pointer to the payload + CRC 
  uint8_t *b;
  /// Pointers to transport block segments
  uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS];
116 117
  /// LDPC-code outputs
  uint8_t *d[MAX_NUM_NR_ULSCH_SEGMENTS];
118
  /// LDPC-code outputs (TS 36.212 V15.4.0, Sec 5.3.2 p. 17)
119
  uint8_t *e; 
120
  /// Rate matching (Interleaving) outputs (TS 36.212 V15.4.0, Sec 5.4.2.2 p. 30)
121
  uint8_t *f; 
Hongzhi Wang's avatar
Hongzhi Wang committed
122
  /// Number of code segments
123
  uint32_t C;
Hongzhi Wang's avatar
Hongzhi Wang committed
124 125
  /// Number of bits in code segments
  uint32_t K;
126 127
  /// Total number of bits across all segments
  uint32_t sumKr;
Hongzhi Wang's avatar
Hongzhi Wang committed
128
  /// Number of "Filler" bits
129
  uint32_t F;
Hongzhi Wang's avatar
Hongzhi Wang committed
130
  /// n_DMRS  for cyclic shift of DMRS
131
  uint8_t n_DMRS;
Hongzhi Wang's avatar
Hongzhi Wang committed
132
  /// n_DMRS2 for cyclic shift of DMRS
133 134 135 136 137 138 139
  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;
  /// Number of soft channel bits
  uint32_t G;
Khalid Ahmed's avatar
Khalid Ahmed committed
140
  // Number of modulated symbols carrying data
141
  uint32_t num_of_mod_symbols;
142 143
  // decode phich
  uint8_t decode_phich;
144 145
  // Encoder BG
  uint8_t BG;
146 147
  // LDPC lifting size
  uint32_t Z;
148 149 150 151
} NR_UL_UE_HARQ_t;

typedef struct {
  /// SRS active flag
152 153 154 155 156
  uint8_t srs_active; 
//#if defined(UPGRADE_RAT_NR)
#if 1
  // Pointers to HARQ processes for the ULSCH
  NR_UL_UE_HARQ_t *harq_processes[NR_MAX_ULSCH_HARQ_PROCESSES];
Jacques's avatar
Jacques committed
157
  int harq_process_id[NR_MAX_SLOTS_PER_FRAME];
158 159 160
  // UL number of harq processes
  uint8_t number_harq_processes_for_pusch;
#endif 
161
  /*
162 163 164 165 166 167 168 169 170 171 172 173
  /// Pointer to CQI data (+1 for 8 bits crc)
  uint8_t o[1+MAX_CQI_BYTES];
  /// Length of CQI data (bits)
  uint8_t O;
  /// Format of CQI data
  UCI_format_t uci_format;
  /// Rank information
  uint8_t o_RI[2];
  /// Length of rank information (bits)
  uint8_t O_RI;
  /// Pointer to ACK
  uint8_t o_ACK[4];
174
  */
175 176 177 178
  /// 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;
179 180
  /// Concatenated "g"-sequences (for definition see 36-212 V15.4.0 2018-12, p.31)
  uint8_t g[MAX_NUM_NR_CHANNEL_BITS];
181
  /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
182
  uint8_t h[MAX_NUM_NR_CHANNEL_BITS];
183
  /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
184
  uint8_t b_tilde[MAX_NUM_NR_CHANNEL_BITS];
185
  /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
186
  int32_t d_mod[MAX_NUM_NR_RE] __attribute__ ((aligned(16)));
187
  /// Transform-coded "y"-sequences (for definition see 38-211 V15.3.0 2018-09, subsection 6.3.1.4)
188
  int32_t y[MAX_NUM_NR_RE] __attribute__ ((aligned(16)));
189
  /*
190 191
  /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27)
  uint8_t q[MAX_CQI_PAYLOAD];
192
  
193 194 195 196 197 198 199 200
  /// 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];
201
  */
202 203 204 205 206 207 208 209 210 211
  /// 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;
Jacques's avatar
Jacques committed
212 213
  /// RNTI type
  uint8_t rnti_type;
214 215
  /// Cell ID
  int     Nid_cell;
216 217 218 219 220 221 222 223 224 225
  /// 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;
  /// Po_SRS - target output power for SRS
  int16_t Po_SRS;
  /// num active cba group
  uint8_t num_active_cba_groups;
adk's avatar
adk committed
226 227
  /// bit mask of PT-RS ofdm symbol indicies
  uint16_t ptrs_symbols;
228
  /// num dci found for cba
229
  //uint8_t num_cba_dci[10];
230
  /// allocated CBA RNTI
231
  //uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
232
  /// UL max-harq-retransmission
233
  uint16_t Mlimit;
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
} NR_UE_ULSCH_t;

typedef struct {
  /// Indicator of first transmission
  uint8_t first_tx;
  /// Last Ndi received for this process on DCI (used for C-RNTI only)
  uint8_t DCINdi;
  /// DLSCH status flag indicating
  SCH_status_t status;
  /// Transport block size
  uint32_t TBS;
  /// The payload + CRC size in bits
  uint32_t B;
  /// Pointer to the payload
  uint8_t *b;
  /// Pointers to transport block segments
Hongzhi Wang's avatar
Hongzhi Wang committed
250
  uint8_t *c[MAX_NUM_NR_DLSCH_SEGMENTS];
251 252
  /// Index of current HARQ round for this DLSCH
  uint8_t round;
253 254
  /// MCS table for this DLSCH
  uint8_t mcs_table;
255 256 257 258
  /// MCS format for this DLSCH
  uint8_t mcs;
  /// Qm (modulation order) for this DLSCH
  uint8_t Qm;
259 260
  /// target code rate R x 1024
  uint16_t R;
261 262 263
  /// Redundancy-version of the current sub-frame
  uint8_t rvidx;
  /// MIMO mode for this DLSCH
Hongzhi Wang's avatar
Hongzhi Wang committed
264
  MIMO_nrmode_t mimo_mode;
265
  /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
266
  int16_t *w[MAX_NUM_NR_DLSCH_SEGMENTS];
267
  /// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
laurent's avatar
fixes  
laurent committed
268
  //double w_abs[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448];
269
  /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
Hongzhi Wang's avatar
Hongzhi Wang committed
270
  int16_t *d[MAX_NUM_NR_DLSCH_SEGMENTS];
271
  /// LDPC processing buffers
272
  t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_DLSCH_SEGMENTS];
Hongzhi Wang's avatar
Hongzhi Wang committed
273
  /// Number of code segments 
274
  uint32_t C;
Hongzhi Wang's avatar
Hongzhi Wang committed
275 276 277
  /// Number of bits in code segments
  uint32_t K;
  /// Number of "Filler" bits 
278
  uint32_t F;
Hongzhi Wang's avatar
Hongzhi Wang committed
279 280
  /// LDPC lifting factor
  uint32_t Z;
Hongzhi Wang's avatar
Hongzhi Wang committed
281
  /// Number of MIMO layers (streams) 
282 283 284 285 286
  uint8_t Nl;
  /// current delta_pucch
  int8_t delta_PUCCH;
  /// Number of soft channel bits
  uint32_t G;
287 288 289 290
  /// Start PRB of BWP
  uint16_t BWPStart;
  /// Number of PRBs in BWP
  uint16_t BWPSize;
291 292
  /// Current Number of RBs
  uint16_t nb_rb;
293 294 295 296
  /// Starting RB number
  uint16_t start_rb;
  /// Number of Symbols
  uint16_t nb_symbols;
297 298 299 300
  /// DMRS symbol positions
  uint16_t dlDmrsSymbPos;
  /// DMRS Configuration Type
  uint8_t dmrsConfigType;
301 302
  // Number of DMRS CDM groups with no data
  uint8_t n_dmrs_cdm_groups;
303 304
  /// Starting Symbol number
  uint16_t start_symbol;
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
  /// Current subband PMI allocation
  uint16_t pmi_alloc;
  /// 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;
  /// downlink power offset field
  uint8_t dl_power_off;
  /// trials per round statistics
  uint32_t trials[8];
  /// error statistics per round
  uint32_t errors[8];
  /// codeword this transport block is mapped to
  uint8_t codeword;
321 322
  /// HARQ-ACKs
  NR_UE_HARQ_STATUS_t harq_ack;
323 324 325 326 327 328 329 330 331 332 333 334 335
  /// PTRS Frequency Density
  uint8_t PTRSFreqDensity;
  /// PTRS Time Density
  uint8_t PTRSTimeDensity;
  uint8_t PTRSPortIndex ;
  uint8_t nEpreRatioOfPDSCHToPTRS;
  uint8_t PTRSReOffset;
  /// bit mask of PT-RS ofdm symbol indicies
  uint16_t ptrs_symbols;
  // PTRS symbol index, to be updated every PTRS symbol within a slot.
  uint8_t ptrs_symbol_index;
  /// PDU BITMAP 
  uint16_t pduBitmap;
336 337 338 339 340
} NR_DL_UE_HARQ_t;

typedef struct {
  /// RNTI
  uint16_t rnti;
Jacques's avatar
Jacques committed
341 342
  /// RNTI type
  uint8_t rnti_type;
343 344
  /// Active flag for DLSCH demodulation
  uint8_t active;
345 346
  /// accumulated tx power adjustment for PUCCH
  int8_t g_pucch;
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
  /// 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 threadRx Odd and threadRx Even
  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;
  /// saved subband PMI allocation from last PUSCH/PUCCH report
  uint16_t pmi_alloc;
365 366 367 368 369 370 371 372
  /// Pointers to up to HARQ processes
  NR_DL_UE_HARQ_t *harq_processes[NR_MAX_DLSCH_HARQ_PROCESSES];
  // DL number of harq processes
  uint8_t number_harq_processes_for_pdsch;
  /* higher layer parameter for reception of two transport blocks TS 38.213 9.1.3.1 Type-2 HARQ-ACK codebook dtermination */
  uint8_t Number_MCS_HARQ_DL_DCI;
  /* spatial bundling of PUCCH */
  uint8_t HARQ_ACK_spatial_bundling_PUCCH;
373 374 375 376 377 378
  /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17
  uint8_t Mdlharq;
  /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
  uint8_t Kmimo;
  /// Nsoft parameter related to UE Category
  uint32_t Nsoft;
Hongzhi Wang's avatar
Hongzhi Wang committed
379 380
  /// Maximum number of LDPC iterations
  uint8_t max_ldpc_iterations;
381
  /// number of iterations used in last turbo decoding
382
  uint8_t last_iteration_cnt;  
383 384
  /// Maximum number of HARQ rounds 
  uint8_t Mlimit;
385 386
} NR_UE_DLSCH_t;

Agustin's avatar
Agustin committed
387 388 389 390 391 392 393 394 395
typedef enum {format0_0,
              format0_1,
              format1_0,
              format1_1,
              format2_0,
              format2_1,
              format2_2,
              format2_3
             } NR_DCI_format_t;
396 397


Agustin's avatar
Agustin committed
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
typedef enum {nr_pucch_format0=0,
              nr_pucch_format1,
              nr_pucch_format2,
              nr_pucch_format3,
              nr_pucch_format4
             } NR_PUCCH_FMT_t;

typedef struct {
  /// Length of DCI in bits
  uint8_t dci_length;
  /// Aggregation level
  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;
416 417
  /// rnti type
  //crc_scrambled_t rnti_type;
Agustin's avatar
Agustin committed
418 419 420 421 422
  /// Format
  NR_DCI_format_t format;
  /// search space
  dci_space_t search_space;
  /// DCI pdu
Guy De Souza's avatar
Guy De Souza committed
423
  uint64_t dci_pdu[2];
424 425 426 427 428 429 430
//#if defined(UPGRADE_RAT_NR)
#if 1
  /// harq information
  uint8_t harq_pid_pusch;
  /// delay between current slot and slot to transmit
  uint8_t number_slots_rx_to_tx;
#endif
Agustin's avatar
Agustin committed
431 432
} NR_DCI_ALLOC_t;

433 434 435

/**@}*/
#endif