defs_gNB.h 20.2 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
/*
 * 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/defs_gNB.h
 \brief Top-level defines and structure definitions for gNB
 \author Guy De Souza
 \date 2018
 \version 0.1
 \company Eurecom
 \email: desouza@eurecom.fr
 \note
 \warning
*/
yilmazt's avatar
yilmazt committed
32

33 34 35 36 37
#ifndef __PHY_DEFS_GNB__H__
#define __PHY_DEFS_GNB__H__

#include "defs_eNB.h"
#include "defs_nr_common.h"
38
#include "CODING/nrPolar_tools/nr_polar_pbch_defs.h"
39
#include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h"
Hongzhi Wang's avatar
Hongzhi Wang committed
40
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
41

42
#define MAX_NUM_RU_PER_gNB MAX_NUM_RU_PER_eNB
43

Guy De Souza's avatar
Guy De Souza committed
44
typedef struct {
Guy De Souza's avatar
Guy De Souza committed
45
  uint32_t pbch_a;
Hongzhi's avatar
Hongzhi committed
46 47 48
  uint32_t pbch_a_interleaved;
  uint32_t pbch_a_prime;
  uint32_t pbch_e[NR_POLAR_PBCH_E_DWORD];
Guy De Souza's avatar
Guy De Souza committed
49 50
} NR_gNB_PBCH;

51 52 53 54 55 56 57 58 59
typedef struct {
  uint8_t ssb_start_symbol;
  uint8_t n_hf;
  uint8_t Lmax;
  uint8_t ssb_index;
  int32_t sfn;
} NR_PBCH_parms_t;


60
typedef struct {
Guy De Souza's avatar
Guy De Souza committed
61
  /// Length of DCI payload in bits
62
  uint16_t size;
63 64
  /// Aggregation level
  uint8_t L;
Guy De Souza's avatar
Guy De Souza committed
65 66
  /// HARQ PID
  uint8_t harq_pid;
67 68 69 70
  /// PDCCH parameters
  nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params;
  /// CCE list
  nr_cce_t cce_list[NR_MAX_PDCCH_AGG_LEVEL];
71
  /// DCI pdu
Guy De Souza's avatar
Guy De Souza committed
72
  uint64_t dci_pdu[2];
73 74 75 76
} NR_gNB_DCI_ALLOC_t;

typedef struct {
  uint8_t     num_dci;
Guy De Souza's avatar
Guy De Souza committed
77
  uint8_t     num_pdsch_rnti;
Guy De Souza's avatar
Guy De Souza committed
78
  NR_gNB_DCI_ALLOC_t dci_alloc[256];
79 80
} NR_gNB_PDCCH;

Guy De Souza's avatar
Guy De Souza committed
81 82

typedef struct {
Guy De Souza's avatar
Guy De Souza committed
83 84
  /// Nfapi DLSCH PDU
  nfapi_nr_dl_config_dlsch_pdu dlsch_pdu;
Guy De Souza's avatar
Guy De Souza committed
85 86 87 88 89 90 91
  /// pointer to pdu from MAC interface (this is "a" in 36.212)
  uint8_t *pdu;
  /// The payload + CRC size in bits, "B" from 36-212
  uint32_t B;
  /// Pointer to the payload
  uint8_t *b;
  /// Pointers to transport block segments
Hongzhi Wang's avatar
Hongzhi Wang committed
92
  uint8_t *c[MAX_NUM_NR_DLSCH_SEGMENTS];
Guy De Souza's avatar
Guy De Souza committed
93 94 95 96 97 98 99 100
  /// 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;
  /// MIMO mode for this DLSCH
  MIMO_mode_t mimo_mode;
Hongzhi Wang's avatar
Hongzhi Wang committed
101 102 103 104 105 106 107
  /// Concatenated sequences
  uint8_t e[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32)));
  /// LDPC-code outputs
  uint8_t *d[MAX_NUM_NR_DLSCH_SEGMENTS];
  /// Interleaver outputs
  uint8_t f[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32)));
  /// Number of code segments
Guy De Souza's avatar
Guy De Souza committed
108
  uint32_t C;
Hongzhi Wang's avatar
Hongzhi Wang committed
109 110 111
  /// Number of bits in "small" code segments
  uint32_t K;
  /// Number of "Filler" bits
Guy De Souza's avatar
Guy De Souza committed
112 113 114 115 116 117
  uint32_t F;
} NR_DL_gNB_HARQ_t;


typedef struct {

Guy De Souza's avatar
Guy De Souza committed
118
  /// Pointers to 16 HARQ processes for the DLSCH
Guy De Souza's avatar
Guy De Souza committed
119
  NR_DL_gNB_HARQ_t *harq_processes[NR_MAX_NB_HARQ_PROCESSES];
Hongzhi Wang's avatar
Hongzhi Wang committed
120
  /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
Guy De Souza's avatar
Guy De Souza committed
121 122 123
  int32_t *txdataF[NR_MAX_NB_LAYERS];
  /// Modulated symbols buffer
  int32_t *mod_symbs[NR_MAX_NB_CODEWORDS];
Guy De Souza's avatar
Guy De Souza committed
124
  /// beamforming weights for UE-spec transmission (antenna ports 5 or 7..14), for each codeword, maximum 4 layers?
125
  int32_t **ue_spec_bf_weights[NR_MAX_NB_LAYERS];
Guy De Souza's avatar
Guy De Souza committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
  /// 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;
  /// HARQ process mask, indicates which processes are currently active
  uint16_t harq_mask;
  /// 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];
  /// 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;
  /// Number of soft channel bits
  uint32_t G;
  /// Codebook index for this dlsch (0,1,2,3)
  uint8_t codebook_index;
Hongzhi Wang's avatar
Hongzhi Wang committed
148
  /// Maximum number of HARQ processes
Guy De Souza's avatar
Guy De Souza committed
149 150 151
  uint8_t Mdlharq;
  /// Maximum number of HARQ rounds
  uint8_t Mlimit;
Hongzhi Wang's avatar
Hongzhi Wang committed
152
  /// MIMO transmission mode indicator for this sub-frame
Guy De Souza's avatar
Guy De Souza committed
153 154 155 156 157 158 159 160 161 162
  uint8_t Kmimo;
  /// 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;
} NR_gNB_DLSCH_t;


163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
typedef struct {
  /// \brief Pointers (dynamic) to the received data in the time domain.
  /// - first index: rx antenna [0..nb_antennas_rx[
  /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[
  int32_t **rxdata;
  /// \brief Pointers (dynamic) to the received data in the frequency domain.
  /// - first index: rx antenna [0..nb_antennas_rx[
  /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[
  int32_t **rxdataF;
  /// \brief holds the transmit data in the frequency domain.
  /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //?
  /// - first index: eNB id [0..2] (hard coded)
  /// - second index: tx antenna [0..14[ where 14 is the total supported antenna ports.
  /// - third index: sample [0..]
  int32_t **txdataF;
} NR_gNB_COMMON;


181
/// Context data structure for RX/TX portion of slot processing
182 183 184 185 186
typedef struct {
  /// Component Carrier index
  uint8_t              CC_id;
  /// timestamp transmitted to HW
  openair0_timestamp timestamp_tx;
187 188 189 190
  /// slot to act upon for transmission
  int slot_tx;
  /// slot to act upon for reception
  int slot_rx;
191 192 193 194 195 196
  /// frame to act upon for transmission
  int frame_tx;
  /// frame to act upon for reception
  int frame_rx;
  /// \brief Instance count for RXn-TXnp4 processing thread.
  /// \internal This variable is protected by \ref mutex_rxtx.
Wang Tsu-Han's avatar
Wang Tsu-Han committed
197
  int instance_cnt;
198
  /// pthread structure for RXn-TXnp4 processing thread
Wang Tsu-Han's avatar
Wang Tsu-Han committed
199
  pthread_t pthread;
200
  /// pthread attributes for RXn-TXnp4 processing thread
Wang Tsu-Han's avatar
Wang Tsu-Han committed
201
  pthread_attr_t attr;
202
  /// condition variable for tx processing thread
Wang Tsu-Han's avatar
Wang Tsu-Han committed
203
  pthread_cond_t cond;
204
  /// mutex for RXn-TXnp4 processing thread
Wang Tsu-Han's avatar
Wang Tsu-Han committed
205
  pthread_mutex_t mutex;
206 207
  /// scheduling parameters for RXn-TXnp4 thread
  struct sched_param sched_param_rxtx;
Wang Tsu-Han's avatar
Wang Tsu-Han committed
208 209 210 211 212 213 214 215

  /// \internal This variable is protected by \ref mutex_RUs.
  int instance_cnt_RUs;
  /// condition variable for tx processing thread
  pthread_cond_t cond_RUs;
  /// mutex for RXn-TXnp4 processing thread
  pthread_mutex_t mutex_RUs;
} gNB_L1_rxtx_proc_t;
216 217


218
/// Context data structure for eNB slot processing
Wang Tsu-Han's avatar
Wang Tsu-Han committed
219
typedef struct gNB_L1_proc_t_s {
220 221 222 223 224 225 226 227
  /// Component Carrier index
  uint8_t              CC_id;
  /// thread index
  int thread_index;
  /// timestamp received from HW
  openair0_timestamp timestamp_rx;
  /// timestamp to send to "slave rru"
  openair0_timestamp timestamp_tx;
228 229 230 231
  /// slot to act upon for reception
  int slot_rx;
  /// slot to act upon for PRACH
  int slot_prach;
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
  /// frame to act upon for reception
  int frame_rx;
  /// frame to act upon for transmission
  int frame_tx;
  /// frame to act upon for PRACH
  int frame_prach;
  /// \internal This variable is protected by \ref mutex_td.
  int instance_cnt_td;
  /// \internal This variable is protected by \ref mutex_te.
  int instance_cnt_te;
  /// \internal This variable is protected by \ref mutex_prach.
  int instance_cnt_prach;

  // instance count for over-the-air gNB synchronization
  int instance_cnt_synch;
  /// \internal This variable is protected by \ref mutex_asynch_rxtx.
  int instance_cnt_asynch_rxtx;
  /// pthread structure for eNB single processing thread
  pthread_t pthread_single;
  /// pthread structure for asychronous RX/TX processing thread
  pthread_t pthread_asynch_rxtx;
  /// flag to indicate first RX acquisition
  int first_rx;
  /// flag to indicate first TX transmission
  int first_tx;
  /// pthread attributes for single gNB processing thread
  pthread_attr_t attr_single;
  /// pthread attributes for prach processing thread
  pthread_attr_t attr_prach;
  /// pthread attributes for asynchronous RX thread
  pthread_attr_t attr_asynch_rxtx;
  /// scheduling parameters for parallel turbo-decoder thread
  struct sched_param sched_param_td;
  /// scheduling parameters for parallel turbo-encoder thread
  struct sched_param sched_param_te;
  /// scheduling parameters for single eNB thread
  struct sched_param sched_param_single;
  /// scheduling parameters for prach thread
  struct sched_param sched_param_prach;
  /// scheduling parameters for asynch_rxtx thread
  struct sched_param sched_param_asynch_rxtx;
  pthread_cond_t cond_prach;
  /// condition variable for asynch RX/TX thread
  pthread_cond_t cond_asynch_rxtx;
  /// mutex for parallel turbo-decoder thread
  pthread_mutex_t mutex_td;
  /// mutex for parallel turbo-encoder thread
  pthread_mutex_t mutex_te;
  /// mutex for PRACH thread
  pthread_mutex_t mutex_prach;
  /// mutex for asynch RX/TX thread
  pthread_mutex_t mutex_asynch_rxtx;
  /// mutex for RU access to eNB processing (PDSCH/PUSCH)
  pthread_mutex_t mutex_RU;
Wang Tsu-Han's avatar
Wang Tsu-Han committed
286 287
  /// mutex for RU_tx access to eNB_tx processing (PDSCH/PUSCH)
  pthread_mutex_t mutex_RU_tx;
288 289 290 291 292
  /// mutex for RU access to eNB processing (PRACH)
  pthread_mutex_t mutex_RU_PRACH;
  /// mutex for RU access to eNB processing (PRACH BR)
  pthread_mutex_t mutex_RU_PRACH_br;
  /// mask for RUs serving eNB (PDSCH/PUSCH)
Wang Tsu-Han's avatar
Wang Tsu-Han committed
293
  int RU_mask, RU_mask_tx;
294 295 296
  /// mask for RUs serving eNB (PRACH)
  int RU_mask_prach;
  /// set of scheduling variables RXn-TXnp4 threads
Wang Tsu-Han's avatar
Wang Tsu-Han committed
297 298
  gNB_L1_rxtx_proc_t L1_proc, L1_proc_tx;
} gNB_L1_proc_t;
299 300 301 302 303 304



typedef struct {
  // common measurements
  //! estimated noise power (linear)
Guy De Souza's avatar
Guy De Souza committed
305
  unsigned int   n0_power[MAX_NUM_RU_PER_gNB];
306
  //! estimated noise power (dB)
Guy De Souza's avatar
Guy De Souza committed
307
  unsigned short n0_power_dB[MAX_NUM_RU_PER_gNB];
308 309 310 311 312 313 314
  //! total estimated noise power (linear)
  unsigned int   n0_power_tot;
  //! estimated avg noise power (dB)
  unsigned short n0_power_tot_dB;
  //! estimated avg noise power (dB)
  short n0_power_tot_dBm;
  //! estimated avg noise power per RB per RX ant (lin)
Guy De Souza's avatar
Guy De Souza committed
315
  unsigned short n0_subband_power[MAX_NUM_RU_PER_gNB][100];
316
  //! estimated avg noise power per RB per RX ant (dB)
Guy De Souza's avatar
Guy De Souza committed
317
  unsigned short n0_subband_power_dB[MAX_NUM_RU_PER_gNB][100];
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
  //! estimated avg noise power per RB (dB)
  short n0_subband_power_tot_dB[100];
  //! estimated avg noise power per RB (dBm)
  short n0_subband_power_tot_dBm[100];
  // gNB measurements (per user)
  //! estimated received spatial signal power (linear)
  unsigned int   rx_spatial_power[NUMBER_OF_UE_MAX][2][2];
  //! estimated received spatial signal power (dB)
  unsigned short rx_spatial_power_dB[NUMBER_OF_UE_MAX][2][2];
  //! estimated rssi (dBm)
  short          rx_rssi_dBm[NUMBER_OF_UE_MAX];
  //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation)
  int            rx_correlation[NUMBER_OF_UE_MAX][2];
  //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation)
  int            rx_correlation_dB[NUMBER_OF_UE_MAX][2];

  /// Wideband CQI (= SINR)
Guy De Souza's avatar
Guy De Souza committed
335
  int            wideband_cqi[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_gNB];
336
  /// Wideband CQI in dB (= SINR dB)
Guy De Souza's avatar
Guy De Souza committed
337
  int            wideband_cqi_dB[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_gNB];
338 339 340
  /// Wideband CQI (sum of all RX antennas, in dB)
  char           wideband_cqi_tot[NUMBER_OF_UE_MAX];
  /// Subband CQI per RX antenna and RB (= SINR)
Guy De Souza's avatar
Guy De Souza committed
341
  int            subband_cqi[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_gNB][100];
342 343 344
  /// Total Subband CQI and RB (= SINR)
  int            subband_cqi_tot[NUMBER_OF_UE_MAX][100];
  /// Subband CQI in dB and RB (= SINR dB)
Guy De Souza's avatar
Guy De Souza committed
345
  int            subband_cqi_dB[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_gNB][100];
346 347 348 349 350 351 352 353 354 355 356 357
  /// Total Subband CQI and RB
  int            subband_cqi_tot_dB[NUMBER_OF_UE_MAX][100];
  /// PRACH background noise level
  int            prach_I0;
} PHY_MEASUREMENTS_gNB;

/// Top-level PHY Data Structure for gNB
typedef struct PHY_VARS_gNB_s {
  /// Module ID indicator for this instance
  module_id_t          Mod_id;
  uint8_t              CC_id;
  uint8_t              configured;
Wang Tsu-Han's avatar
Wang Tsu-Han committed
358
  gNB_L1_proc_t           proc;
359 360 361
  int                  single_thread_flag;
  int                  abstraction_flag;
  int                  num_RU;
Guy De Souza's avatar
Guy De Souza committed
362
  RU_t                 *RU_list[MAX_NUM_RU_PER_gNB];
363 364 365 366 367 368 369
  /// Ethernet parameters for northbound midhaul interface
  eth_params_t         eth_params_n;
  /// Ethernet parameters for fronthaul interface
  eth_params_t         eth_params;
  int                  rx_total_gain_dB;
  int                  (*start_if)(struct RU_t_s *ru,struct PHY_VARS_gNB_s *gNB);
  uint8_t              local_flag;
ChenWeiTai's avatar
ChenWeiTai committed
370
  nfapi_nr_config_request_t  gNB_config;
371 372
  NR_DL_FRAME_PARMS   frame_parms;
  PHY_MEASUREMENTS_gNB measurements;
ChenWeiTai's avatar
ChenWeiTai committed
373
  NR_IF_Module_t          *if_inst;
ChenWeiTai's avatar
ChenWeiTai committed
374
  NR_UL_IND_t             UL_INFO;
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
  pthread_mutex_t      UL_INFO_mutex;
  /// NFAPI RX ULSCH information
  nfapi_rx_indication_pdu_t  rx_pdu_list[NFAPI_RX_IND_MAX_PDU];
  /// NFAPI RX ULSCH CRC information
  nfapi_crc_indication_pdu_t crc_pdu_list[NFAPI_CRC_IND_MAX_PDU];
  /// NFAPI HARQ information
  nfapi_harq_indication_pdu_t harq_pdu_list[NFAPI_HARQ_IND_MAX_PDU];
  /// NFAPI SR information
  nfapi_sr_indication_pdu_t sr_pdu_list[NFAPI_SR_IND_MAX_PDU];
  /// NFAPI CQI information
  nfapi_cqi_indication_pdu_t cqi_pdu_list[NFAPI_CQI_IND_MAX_PDU];
  /// NFAPI CQI information (raw component)
  nfapi_cqi_indication_raw_pdu_t cqi_raw_pdu_list[NFAPI_CQI_IND_MAX_PDU];
  /// NFAPI PRACH information
  nfapi_preamble_pdu_t preamble_list[MAX_NUM_RX_PRACH_PREAMBLES];

yilmazt's avatar
yilmazt committed
391
  Sched_Rsp_t         Sched_INFO;
392
  NR_gNB_PDCCH        pdcch_vars;
yilmazt's avatar
yilmazt committed
393 394
  NR_gNB_PBCH         pbch;
  LTE_eNB_PHICH       phich_vars[2];
395 396 397 398 399 400

  NR_gNB_COMMON       common_vars;
  LTE_eNB_UCI          uci_vars[NUMBER_OF_UE_MAX];
  LTE_eNB_SRS          srs_vars[NUMBER_OF_UE_MAX];
  LTE_eNB_PUSCH       *pusch_vars[NUMBER_OF_UE_MAX];
  LTE_eNB_PRACH        prach_vars;
Guy De Souza's avatar
Guy De Souza committed
401
  NR_gNB_DLSCH_t     *dlsch[NUMBER_OF_UE_MAX][2];   // Nusers times two spatial streams
402
  LTE_eNB_ULSCH_t     *ulsch[NUMBER_OF_UE_MAX+1];      // Nusers + number of RA
Guy De Souza's avatar
Guy De Souza committed
403 404 405
  NR_gNB_DLSCH_t     *dlsch_SI,*dlsch_ra,*dlsch_p;
  NR_gNB_DLSCH_t     *dlsch_MCH;
  NR_gNB_DLSCH_t     *dlsch_PCH;
406 407 408 409 410 411 412 413 414 415 416 417 418 419
  LTE_eNB_UE_stats     UE_stats[NUMBER_OF_UE_MAX];
  LTE_eNB_UE_stats    *UE_stats_ptr[NUMBER_OF_UE_MAX];

  uint8_t pbch_configured;
  uint8_t pbch_pdu[4]; //PBCH_PDU_SIZE
  char gNB_generate_rar;

  /// NR synchronization sequences
  int16_t d_pss[NR_PSS_LENGTH];
  int16_t d_sss[NR_SSS_LENGTH];

  /// PBCH DMRS sequence
  uint32_t nr_gold_pbch_dmrs[2][64][NR_PBCH_DMRS_LENGTH_DWORD];

Guy De Souza's avatar
Guy De Souza committed
420 421 422
  /// PBCH interleaver
  uint8_t nr_pbch_interleaver[NR_POLAR_PBCH_PAYLOAD_BITS];

423
  /// PDCCH DMRS sequence
Guy De Souza's avatar
Guy De Souza committed
424
  uint32_t ***nr_gold_pdcch_dmrs;
425

426
  /// PDSCH DMRS sequence
Guy De Souza's avatar
Guy De Souza committed
427
  uint32_t ****nr_gold_pdsch_dmrs;
428

429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
  /// Indicator set to 0 after first SR
  uint8_t first_sr[NUMBER_OF_UE_MAX];

  uint32_t max_peak_val;

  /// \brief sinr for all subcarriers of the current link (used only for abstraction).
  /// first index: ? [0..N_RB_DL*12[
  double *sinr_dB;

  /// N0 (used for abstraction)
  double N0;

  unsigned char first_run_timing_advance[NUMBER_OF_UE_MAX];
  unsigned char first_run_I0_measurements;

yilmazt's avatar
yilmazt committed
444

445 446 447 448 449 450 451 452 453 454 455 456 457 458
  unsigned char    is_secondary_gNB; // primary by default
  unsigned char    is_init_sync;     /// Flag to tell if initial synchronization is performed. This affects how often the secondary eNB will listen to the PSS from the primary system.
  unsigned char    has_valid_precoder; /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from, and this B/F vector is created.
  unsigned char    PgNB_id;          /// id of Primary eNB

  /// hold the precoder for NULL beam to the primary user
  int              **dl_precoder_SgNB[3];
  char             log2_maxp; /// holds the maximum channel/precoder coefficient

  /// if ==0 enables phy only test mode
  int mac_enabled;
  /// counter to average prach energh over first 100 prach opportunities
  int prach_energy_counter;

459
  // PDSCH Variables
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
  PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_UE_MAX];

  // PUSCH Varaibles
  PUSCH_CONFIG_DEDICATED pusch_config_dedicated[NUMBER_OF_UE_MAX];

  // PUCCH variables
  PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_UE_MAX];

  // UL-POWER-Control
  UL_POWER_CONTROL_DEDICATED ul_power_control_dedicated[NUMBER_OF_UE_MAX];

  // TPC
  TPC_PDCCH_CONFIG tpc_pdcch_config_pucch[NUMBER_OF_UE_MAX];
  TPC_PDCCH_CONFIG tpc_pdcch_config_pusch[NUMBER_OF_UE_MAX];

  // CQI reporting
  CQI_REPORT_CONFIG cqi_report_config[NUMBER_OF_UE_MAX];

  // SRS Variables
  SOUNDINGRS_UL_CONFIG_DEDICATED soundingrs_ul_config_dedicated[NUMBER_OF_UE_MAX];
  uint8_t ncs_cell[20][7];

  // Scheduling Request Config
  SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_UE_MAX];

  // Transmission mode per UE
  uint8_t transmission_mode[NUMBER_OF_UE_MAX];

  /// cba_last successful reception for each group, used for collision detection
  uint8_t cba_last_reception[4];

491
  // Pointers for active physicalConfigDedicated to be applied in current slot
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 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 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
  struct PhysicalConfigDedicated *physicalConfigDedicated[NUMBER_OF_UE_MAX];


  uint32_t rb_mask_ul[4];

  /// Information regarding TM5
  MU_MIMO_mode mu_mimo_mode[NUMBER_OF_UE_MAX];


  /// target_ue_dl_mcs : only for debug purposes
  uint32_t target_ue_dl_mcs;
  /// target_ue_ul_mcs : only for debug purposes
  uint32_t target_ue_ul_mcs;
  /// target_ue_dl_rballoc : only for debug purposes
  uint32_t ue_dl_rb_alloc;
  /// target ul PRBs : only for debug
  uint32_t ue_ul_nb_rb;

  ///check for Total Transmissions
  uint32_t check_for_total_transmissions;

  ///check for MU-MIMO Transmissions
  uint32_t check_for_MUMIMO_transmissions;

  ///check for SU-MIMO Transmissions
  uint32_t check_for_SUMIMO_transmissions;

  ///check for FULL MU-MIMO Transmissions
  uint32_t  FULL_MUMIMO_transmissions;

  /// Counter for total bitrate, bits and throughput in downlink
  uint32_t total_dlsch_bitrate;
  uint32_t total_transmitted_bits;
  uint32_t total_system_throughput;

  int hw_timing_advance;

  time_stats_t phy_proc;
  time_stats_t phy_proc_tx;
  time_stats_t phy_proc_rx;
  time_stats_t rx_prach;

  time_stats_t ofdm_mod_stats;
  time_stats_t dlsch_encoding_stats;
  time_stats_t dlsch_modulation_stats;
  time_stats_t dlsch_scrambling_stats;
  time_stats_t dlsch_rate_matching_stats;
  time_stats_t dlsch_turbo_encoding_stats;
  time_stats_t dlsch_interleaving_stats;

  time_stats_t rx_dft_stats;
  time_stats_t ulsch_channel_estimation_stats;
  time_stats_t ulsch_freq_offset_estimation_stats;
  time_stats_t ulsch_decoding_stats;
  time_stats_t ulsch_demodulation_stats;
  time_stats_t ulsch_rate_unmatching_stats;
  time_stats_t ulsch_turbo_decoding_stats;
  time_stats_t ulsch_deinterleaving_stats;
  time_stats_t ulsch_demultiplexing_stats;
  time_stats_t ulsch_llr_stats;
  time_stats_t ulsch_tc_init_stats;
  time_stats_t ulsch_tc_alpha_stats;
  time_stats_t ulsch_tc_beta_stats;
  time_stats_t ulsch_tc_gamma_stats;
  time_stats_t ulsch_tc_ext_stats;
  time_stats_t ulsch_tc_intl1_stats;
  time_stats_t ulsch_tc_intl2_stats;

#ifdef LOCALIZATION
  /// time state for localization
  time_stats_t localization_stats;
#endif

  int32_t pucch1_stats_cnt[NUMBER_OF_UE_MAX][10];
  int32_t pucch1_stats[NUMBER_OF_UE_MAX][10*1024];
  int32_t pucch1_stats_thres[NUMBER_OF_UE_MAX][10*1024];
  int32_t pucch1ab_stats_cnt[NUMBER_OF_UE_MAX][10];
  int32_t pucch1ab_stats[NUMBER_OF_UE_MAX][2*10*1024];
  int32_t pusch_stats_rb[NUMBER_OF_UE_MAX][10240];
  int32_t pusch_stats_round[NUMBER_OF_UE_MAX][10240];
  int32_t pusch_stats_mcs[NUMBER_OF_UE_MAX][10240];
  int32_t pusch_stats_bsr[NUMBER_OF_UE_MAX][10240];
  int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240];
} PHY_VARS_gNB;

#endif