mac_defs.h 19.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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
 */

22
/* \file mac_defs.h
cig's avatar
cig committed
23
 * \brief MAC data structures and constants
24 25 26 27 28 29 30
 * \author R. Knopp, K.H. HSU
 * \date 2018
 * \version 0.1
 * \company Eurecom / NTUST
 * \email: knopp@eurecom.fr, kai-hsiang.hsu@eurecom.fr
 * \note
 * \warning
31 32
 */

33 34
#ifndef __LAYER2_NR_MAC_DEFS_H__
#define __LAYER2_NR_MAC_DEFS_H__
35 36 37 38

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
39
#include "common/platform_types.h"
40 41 42 43 44 45 46 47

/* IF */
#include "NR_IF_Module.h"
#include "fapi_nr_ue_interface.h"

/* MAC */
#include "LAYER2/NR_MAC_COMMON/nr_mac.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_common.h"
48
#include "NR_MAC_COMMON/nr_mac_extern.h"
49
#include "mac_defs_sl.h"
50 51

/* RRC */
52 53 54 55 56 57 58 59 60
#include "NR_DRX-Config.h"
#include "NR_SchedulingRequestConfig.h"
#include "NR_BSR-Config.h"
#include "NR_TAG-Config.h"
#include "NR_PHR-Config.h"
#include "NR_RNTI-Value.h"
#include "NR_MIB.h"
#include "NR_MAC-CellGroupConfig.h"
#include "NR_PhysicalCellGroupConfig.h"
61
#include "NR_CellGroupConfig.h"
62
#include "NR_ServingCellConfig.h"
63
#include "NR_MeasConfig.h"
64
#include "NR_ServingCellConfigCommonSIB.h"
65

66

cig's avatar
cig committed
67 68 69
// ==========
// NR UE defs
// ==========
70

71 72 73 74 75 76 77
#define NR_BSR_TRIGGER_NONE      (0) /* No BSR Trigger */
#define NR_BSR_TRIGGER_REGULAR   (1) /* For Regular and ReTxBSR Expiry Triggers */
#define NR_BSR_TRIGGER_PERIODIC  (2) /* For BSR Periodic Timer Expiry Trigger */
#define NR_BSR_TRIGGER_PADDING   (4) /* For Padding BSR Trigger */

#define NR_INVALID_LCGID (NR_MAX_NUM_LCGID)

78
#define MAX_NUM_BWP_UE 5
79
#define NR_MAX_SR_ID 8  // SchedulingRequestId ::= INTEGER (0..7)
80 81 82

/*!\brief value for indicating BSR Timer is not running */
#define NR_MAC_UE_BSR_TIMER_NOT_RUNNING   (0xFFFF)
83

cig's avatar
cig committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
// ================================================
// SSB to RO mapping private defines and structures
// ================================================

#define MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PERIOD (16) // Maximum association period is 16
#define MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD (16) // Max association pattern period is 160ms and minimum PRACH configuration period is 10ms
#define MAX_NB_ASSOCIATION_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD (16) // Max nb of association periods in an association pattern period of 160ms
#define MAX_NB_FRAME_IN_PRACH_CONF_PERIOD (16) // Max PRACH configuration period is 160ms and frame is 10ms
#define MAX_NB_SLOT_IN_FRAME (160) // Max number of slots in a frame (@ SCS 240kHz = 160)
#define MAX_NB_FRAME_IN_ASSOCIATION_PATTERN_PERIOD (16) // Maximum number of frames in the maximum association pattern period
#define MAX_NB_SSB (64) // Maximum number of possible SSB indexes
#define MAX_RO_PER_SSB (8) // Maximum number of consecutive ROs that can be mapped to an SSB according to the ssb_per_RACH config

// Maximum number of ROs that can be mapped to an SSB in an association pattern
// This is to reserve enough elements in the SSBs list for each mapped ROs for a single SSB
// An arbitrary maximum number is chosen to be safe: maximum number of slots in an association pattern * maximum number of ROs in a slot
#define MAX_NB_RO_PER_SSB_IN_ASSOCIATION_PATTERN (MAX_TDM*MAX_FDM*MAX_NB_SLOT_IN_FRAME*MAX_NB_FRAME_IN_ASSOCIATION_PATTERN_PERIOD)

// ===============
// DCI fields defs
// ===============

#define NBR_NR_FORMATS                   8     // The number of formats is 8 (0_0, 0_1, 1_0, 1_1, 2_0, 2_1, 2_2, 2_3)
#define NBR_NR_DCI_FIELDS               56    // The number of different dci fields defined in TS 38.212 subclause 7.3.1

#define IDENTIFIER_DCI_FORMATS           0
#define CARRIER_IND                      1
#define SUL_IND_0_1                      2
#define SLOT_FORMAT_IND                  3
#define PRE_EMPTION_IND                  4
#define BLOCK_NUMBER                     5
#define CLOSE_LOOP_IND                   6
#define BANDWIDTH_PART_IND               7
#define SHORT_MESSAGE_IND                8
#define SHORT_MESSAGES                   9
#define FREQ_DOM_RESOURCE_ASSIGNMENT_UL 10
#define FREQ_DOM_RESOURCE_ASSIGNMENT_DL 11
#define TIME_DOM_RESOURCE_ASSIGNMENT    12
#define VRB_TO_PRB_MAPPING              13
#define PRB_BUNDLING_SIZE_IND           14
#define RATE_MATCHING_IND               15
#define ZP_CSI_RS_TRIGGER               16
#define FREQ_HOPPING_FLAG               17
#define TB1_MCS                         18
#define TB1_NDI                         19
#define TB1_RV                          20
#define TB2_MCS                         21
#define TB2_NDI                         22
#define TB2_RV                          23
#define MCS                             24
#define NDI                             25
#define RV                              26
#define HARQ_PROCESS_NUMBER             27
#define DAI_                            28
#define FIRST_DAI                       29
#define SECOND_DAI                      30
#define TB_SCALING                      31
#define TPC_PUSCH                       32
#define TPC_PUCCH                       33
#define PUCCH_RESOURCE_IND              34
#define PDSCH_TO_HARQ_FEEDBACK_TIME_IND 35
#define SRS_RESOURCE_IND                36
#define PRECOD_NBR_LAYERS               37
#define ANTENNA_PORTS                   38
#define TCI                             39
#define SRS_REQUEST                     40
#define TPC_CMD                         41
#define CSI_REQUEST                     42
#define CBGTI                           43
#define CBGFI                           44
#define PTRS_DMRS                       45
#define BETA_OFFSET_IND                 46
#define DMRS_SEQ_INI                    47
#define UL_SCH_IND                      48
#define PADDING_NR_DCI                  49
#define SUL_IND_0_0                     50
#define RA_PREAMBLE_INDEX               51
#define SUL_IND_1_0                     52
#define SS_PBCH_INDEX                   53
#define PRACH_MASK_INDEX                54
#define RESERVED_NR_DCI                 55

166 167 168 169 170
// Define the UE L2 states with X-Macro
#define NR_UE_L2_STATES \
  UE_STATE(UE_NOT_SYNC) \
  UE_STATE(UE_SYNC) \
  UE_STATE(UE_PERFORMING_RA) \
171 172
  UE_STATE(UE_CONNECTED) \
  UE_STATE(UE_DETACHING)
173

174 175 176 177 178 179
typedef enum {
  phr_cause_prohibit_timer = 0,
  phr_cause_periodic_timer,
  phr_cause_phr_config,
} NR_UE_PHR_Reporting_cause_t;

cig's avatar
cig committed
180 181
/*!\brief UE layer 2 status */
typedef enum {
182 183 184
#define UE_STATE(state) state,
  NR_UE_L2_STATES
#undef UE_STATE
cig's avatar
cig committed
185
} NR_UE_L2_STATE_t;
186

187 188
typedef enum {
  GO_TO_IDLE,
189
  DETACH,
francescomani's avatar
francescomani committed
190
  T300_EXPIRY,
191 192 193
  RE_ESTABLISHMENT
} NR_UE_MAC_reset_cause_t;

194 195 196 197
typedef struct {
  // after multiplexing buffer remain for each lcid
  int32_t LCID_buffer_remain;
  // buffer status for each lcid
198
  bool LCID_buffer_with_data;
199 200 201
  // logical channel group id of this LCID
  long LCGID;
  // Bj bucket usage per lcid
202
  int32_t Bj;
203
  NR_timer_t Bj_timer;
204 205 206 207 208 209 210 211 212
} NR_LC_SCHEDULING_INFO;

typedef struct {
  // buffer status for each lcgid
  uint8_t BSR; // should be more for mesh topology
  // keep the number of bytes in rlc buffer for each lcgid
  int32_t BSR_bytes;
} NR_LCG_SCHEDULING_INFO;

213 214 215 216 217 218 219 220 221 222 223 224
typedef struct {
  bool active_SR_ID;
  /// SR pending as defined in 38.321
  bool pending;
  /// SR_COUNTER as defined in 38.321
  uint32_t counter;
  /// sr ProhibitTimer
  NR_timer_t prohibitTimer;
  // Maximum number of SR transmissions
  uint32_t maxTransmissions;
} nr_sr_info_t;

225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
typedef struct {
  bool is_configured;
  ///timer before triggering a periodic PHR
  NR_timer_t periodicPHR_Timer;
  ///timer before triggering a prohibit PHR
  NR_timer_t prohibitPHR_Timer;
  ///DL Pathloss change value
  uint16_t PathlossLastValue;
  ///number of subframe before triggering a periodic PHR
  int16_t periodicPHR_SF;
  ///number of subframe before triggering a prohibit PHR
  int16_t prohibitPHR_SF;
  ///DL Pathloss Change in db
  uint16_t PathlossChange_db;
  int phr_reporting;
  bool was_mac_reset;
} nr_phr_info_t;

243 244
// LTE structure, might need to be adapted for NR
typedef struct {
245 246 247 248
  // lcs scheduling info
  NR_LC_SCHEDULING_INFO lc_sched_info[NR_MAX_NUM_LCID];
  // lcg scheduling info
  NR_LCG_SCHEDULING_INFO lcg_sched_info[NR_MAX_NUM_LCGID];
249 250
  // SR INFO
  nr_sr_info_t sr_info[NR_MAX_SR_ID];
251 252 253 254
  /// BSR report flag management
  uint8_t BSR_reporting_active;
  // LCID triggering BSR
  NR_LogicalChannelIdentity_t regularBSR_trigger_lcid;
255 256
  // logicalChannelSR-DelayTimer
  NR_timer_t sr_DelayTimer;
257 258
  /// retxBSR-Timer
  NR_timer_t retxBSR_Timer;
259 260
  /// periodicBSR-Timer
  NR_timer_t periodicBSR_Timer;
261 262

  nr_phr_info_t phr_info;
263 264
} NR_UE_SCHEDULING_INFO;

cig's avatar
cig committed
265
typedef enum {
266 267 268 269 270 271 272
  nrRA_UE_IDLE,
  nrRA_GENERATE_PREAMBLE,
  nrRA_WAIT_RAR,
  nrRA_WAIT_MSGB,
  nrRA_WAIT_CONTENTION_RESOLUTION,
  nrRA_SUCCEEDED,
  nrRA_FAILED,
273 274 275
} nrRA_UE_state_t;

static const char *const nrra_ue_text[] =
276
    {"UE_IDLE", "GENERATE_PREAMBLE", "WAIT_RAR", "WAIT_MSGB", "WAIT_CONTENTION_RESOLUTION", "RA_SUCCEEDED", "RA_FAILED"};
cig's avatar
cig committed
277

278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
typedef struct {
  /// PRACH format retrieved from prach_ConfigIndex
  uint16_t prach_format;
  /// Preamble Tx Counter
  uint8_t RA_PREAMBLE_TRANSMISSION_COUNTER;
  /// Preamble Power Ramping Counter
  uint8_t RA_PREAMBLE_POWER_RAMPING_COUNTER;
  /// 2-step RA power offset
  int POWER_OFFSET_2STEP_RA;
  /// Target received power at gNB. Baseline is range -202..-60 dBm. Depends on delta preamble, power ramping counter and step.
  int ra_PREAMBLE_RECEIVED_TARGET_POWER;
  /// PRACH index for TDD (0 ... 6) depending on TDD configuration and prachConfigIndex
  uint8_t ra_TDD_map_index;
  /// RA Preamble Power Ramping Step in dB
  uint32_t RA_PREAMBLE_POWER_RAMPING_STEP;
  ///
  uint8_t RA_PREAMBLE_BACKOFF;
  ///
  uint8_t RA_SCALING_FACTOR_BI;
  /// Indicating whether it is 2-step or 4-step RA
298
  nr_ra_type_t RA_TYPE;
299 300 301 302
  /// UE configured maximum output power
  int RA_PCMAX;
} NR_PRACH_RESOURCES_t;

303 304 305 306 307
typedef struct {

  // pointer to RACH config dedicated
  NR_RACH_ConfigDedicated_t *rach_ConfigDedicated;
  /// state of RA procedure
308
  nrRA_UE_state_t ra_state;
309 310
  /// RA contention type
  uint8_t cfra;
311 312
  /// RA type
  nr_ra_type_t ra_type;
313 314
  /// RA rx frame offset: compensate RA rx offset introduced by OAI gNB.
  uint8_t RA_offset;
315 316 317 318 319 320 321 322 323 324 325
  /// MsgB SuccessRAR MAC subheader
  int8_t MsgB_R;
  int8_t MsgB_CH_ACESS_CPEXT;
  uint8_t MsgB_TPC;
  int8_t MsgB_HARQ_FTI;
  uint16_t timing_advance_command;
  int8_t PUCCH_RI;
  /// RA-rnti
  uint16_t ra_rnti;
  /// MsgB RNTI
  uint16_t MsgB_rnti;
326 327 328 329 330
  /// Temporary CRNTI
  uint16_t t_crnti;
  /// number of attempt for rach
  uint8_t RA_attempt_number;
  /// Random-access procedure flag
331
  bool RA_active;
332 333
  /// Random-access preamble index
  int ra_PreambleIndex;
334 335
  // When multiple SSBs per RO is configured, this indicates which one is selected in this RO -> this is used to properly compute the PRACH preamble
  uint8_t ssb_nb_in_ro;
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357

  /// Random-access window counter
  int16_t RA_window_cnt;
  /// Flag to monitor if matching RAPID was received in RAR
  uint8_t RA_RAPID_found;
  /// Flag to monitor if BI was received in RAR
  uint8_t RA_BI_found;
  /// Random-access backoff counter
  int16_t RA_backoff_indicator;
  /// Flag to indicate whether preambles Group A was used
  uint8_t RA_usedGroupA;
  /// RA backoff counter
  int16_t RA_backoff_cnt;
  /// RA max number of preamble transmissions
  int preambleTransMax;
  /// Nb of preambles per SSB
  long cb_preambles_per_ssb;
  int starting_preamble_nb;

  /// Received TPC command (in dB) from RAR
  int8_t Msg3_TPC;
  /// Flag to indicate whether it is the first Msg3 to be transmitted
358
  bool first_Msg3;
359 360
  /// RA Msg3 size in bytes
  uint8_t Msg3_size;
361 362
  /// Msg3 buffer
  uint8_t *Msg3_buffer;
363

364 365
  bool msg3_C_RNTI;

366 367
  /// Random-access Contention Resolution Timer
  NR_timer_t contention_resolution_timer;
rmagueta's avatar
rmagueta committed
368 369
  /// Transmitted UE Contention Resolution Identifier
  uint8_t cont_res_id[6];
370 371 372 373

  /// BeamfailurerecoveryConfig
  NR_BeamFailureRecoveryConfig_t RA_BeamFailureRecoveryConfig;

374
  NR_PRACH_RESOURCES_t prach_resources;
375 376
} RA_config_t;

377 378 379 380
typedef struct {
  bool active;
  bool ack_received;
  uint8_t  pucch_resource_indicator;
381 382
  frame_t ul_frame;
  int ul_slot;
383 384 385
  uint8_t ack;
  int n_CCE;
  int N_CCE;
386
  int dai_cumul;
387
  int8_t delta_pucch;
388 389
  uint32_t R;
  uint32_t TBS;
390
  int last_ndi;
391 392
} NR_UE_HARQ_STATUS_t;

393 394 395
typedef struct {
  uint32_t R;
  uint32_t TBS;
396
  int last_ndi;
397 398
} NR_UL_HARQ_INFO_t;

cig's avatar
cig committed
399 400 401
typedef struct {
  uint8_t freq_hopping;
  uint8_t mcs;
402 403
  uint8_t Msg3_t_alloc;
  uint16_t Msg3_f_alloc;
cig's avatar
cig committed
404 405
} RAR_grant_t;

406
typedef struct {
407
  NR_PUCCH_Resource_t *pucch_resource;
408 409 410 411
  uint32_t ack_payload;
  uint8_t sr_payload;
  uint32_t csi_part1_payload;
  uint32_t csi_part2_payload;
412 413 414
  int n_sr;
  int n_csi;
  int n_harq;
415 416
  int n_CCE;
  int N_CCE;
417
  int initial_pucch_id;
418 419
} PUCCH_sched_t;

420 421 422 423
typedef struct {
  uint32_t ssb_index;
  /// SSB RSRP in dBm
  short ssb_rsrp_dBm;
424
} NR_SSB_meas_t;
425

426 427 428 429 430 431
typedef enum ta_type {
  no_ta = 0,
  adjustment_ta,
  rar_ta,
} ta_type_t;

432
typedef struct NR_UL_TIME_ALIGNMENT {
433
  /// TA command received from the gNB
434
  ta_type_t ta_apply;
435 436 437 438 439
  int ta_command;
  int frame;
  int slot;
} NR_UL_TIME_ALIGNMENT_t;

francescomani's avatar
francescomani committed
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
// The PRACH Config period is a series of selected slots in one or multiple frames
typedef struct prach_conf_period {
  prach_occasion_slot_t prach_occasion_slot_map[MAX_NB_FRAME_IN_PRACH_CONF_PERIOD][MAX_NB_SLOT_IN_FRAME];
  uint16_t nb_of_prach_occasion; // Total number of PRACH occasions in the PRACH Config period
  uint8_t nb_of_frame; // Size of the PRACH Config period in number of 10ms frames
  uint8_t nb_of_slot; // Nb of slots in each frame
} prach_conf_period_t;

// The association period is a series of PRACH Config periods
typedef struct prach_association_period {
  prach_conf_period_t *prach_conf_period_list[MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PERIOD];
  uint8_t nb_of_prach_conf_period; // Nb of PRACH configuration periods within the association period
  uint8_t nb_of_frame; // Total number of frames included in the association period
} prach_association_period_t;

// The association pattern is a series of Association periods
typedef struct prach_association_pattern {
  prach_association_period_t prach_association_period_list[MAX_NB_ASSOCIATION_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD];
  prach_conf_period_t prach_conf_period_list[MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD];
  uint8_t nb_of_assoc_period; // Nb of association periods within the association pattern
  uint8_t nb_of_prach_conf_period_in_max_period; // Nb of PRACH configuration periods within the maximum association pattern period (according to the size of the configured PRACH
  uint8_t nb_of_frame; // Total number of frames included in the association pattern period (after mapping the SSBs and determining the real association pattern length)
} prach_association_pattern_t;

// SSB details
typedef struct ssb_info {
  prach_occasion_info_t *mapped_ro[MAX_NB_RO_PER_SSB_IN_ASSOCIATION_PATTERN]; // List of mapped RACH Occasions to this SSB index
  uint32_t nb_mapped_ro; // Total number of mapped ROs to this SSB index
} ssb_info_t;

// List of all the possible SSBs and their details
typedef struct ssb_list_info {
472 473 474
  ssb_info_t *tx_ssb;
  int nb_tx_ssb;
  int nb_ssb_per_index[MAX_NB_SSB];
francescomani's avatar
francescomani committed
475 476
} ssb_list_info_t;

477 478
typedef struct nr_lcordered_info_s {
  // logical channels ids ordered as per priority
479
  NR_LogicalChannelIdentity_t lcid;
480
  int sr_id;
481
  long priority;
482
  uint32_t pbr; // in B/s (UINT_MAX = infinite)
483 484
  // Bucket size per lcid
  uint32_t bucket_size;
485
  bool sr_DelayTimerApplied;
486
  bool lc_SRMask;
487 488
} nr_lcordered_info_t;

489 490 491 492 493

typedef struct {
  uint8_t payload[NR_CCCH_PAYLOAD_SIZE_MAX];
} __attribute__ ((__packed__)) NR_CCCH_PDU;

494 495 496 497 498 499 500 501 502
typedef struct {
  NR_SearchSpace_t *otherSI_SS;
  NR_SearchSpace_t *ra_SS;
  NR_SearchSpace_t *paging_SS;
  NR_ControlResourceSet_t *commonControlResourceSet;
  A_SEQUENCE_OF(NR_ControlResourceSet_t) list_Coreset;
  A_SEQUENCE_OF(NR_SearchSpace_t) list_SS;
} NR_BWP_PDCCH_t;

503 504 505 506 507 508 509 510 511 512 513 514 515
typedef struct csi_payload {
  uint32_t part1_payload;
  uint32_t part2_payload;
  int p1_bits;
  int p2_bits;
} csi_payload_t;

typedef enum {
  WIDEBAND_ON_PUCCH,
  SUBBAND_ON_PUCCH,
  ON_PUSCH
} CSI_mapping_t;

516
/*!\brief Top level UE MAC structure */
517
typedef struct NR_UE_MAC_INST_s {
518
  module_id_t ue_id;
francescomani's avatar
francescomani committed
519
  NR_UE_L2_STATE_t state;
520 521 522 523 524 525
  int servCellIndex;
  long physCellId;
  int first_sync_frame;
  bool get_sib1;
  bool get_otherSI;
  NR_MIB_t *mib;
francescomani's avatar
francescomani committed
526
  struct NR_SI_SchedulingInfo *si_SchedulingInfo;
Roberto Rosca's avatar
Roberto Rosca committed
527
  struct NR_SI_SchedulingInfo_v1700 *si_SchedulingInfo_v1700;
francescomani's avatar
francescomani committed
528
  int si_window_start;
529 530
  ssb_list_info_t ssb_list[MAX_NUM_BWP_UE];
  prach_association_pattern_t prach_assoc_pattern[MAX_NUM_BWP_UE];
531

532
  NR_UE_ServingCell_Info_t sc_info;
533 534
  A_SEQUENCE_OF(NR_UE_DL_BWP_t) dl_BWPs;
  A_SEQUENCE_OF(NR_UE_UL_BWP_t) ul_BWPs;
535
  NR_BWP_PDCCH_t config_BWP_PDCCH[MAX_NUM_BWP_UE];
536 537
  NR_ControlResourceSet_t *coreset0;
  NR_SearchSpace_t *search_space_zero;
538 539
  NR_UE_DL_BWP_t *current_DL_BWP;
  NR_UE_UL_BWP_t *current_UL_BWP;
540

541 542 543
  bool harq_ACK_SpatialBundlingPUCCH;
  bool harq_ACK_SpatialBundlingPUSCH;

544
  uint32_t uecap_maxMIMO_PDSCH_layers;
545 546
  uint32_t uecap_maxMIMO_PUSCH_layers_cb;
  uint32_t uecap_maxMIMO_PUSCH_layers_nocb;
547

548
  NR_UL_TIME_ALIGNMENT_t ul_time_alignment;
549
  NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon;
francescomani's avatar
francescomani committed
550
  frame_type_t frame_type;
cig's avatar
cig committed
551

552
  /* Random Access */
553
  /// CRNTI
cig's avatar
cig committed
554
  uint16_t crnti;
555 556
  /// RA configuration
  RA_config_t ra;
557 558
  /// SSB index from MIB decoding
  uint8_t mib_ssb;
francescomani's avatar
francescomani committed
559
  uint32_t mib_additional_bits;
560
  int mib_frame;
561

562 563
  nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG];

564 565 566
  /// measurements from CSI-RS
  fapi_nr_csirs_measurements_t csirs_measurements;

567
  ////	FAPI-like interface message
568
  fapi_nr_ul_config_request_t *ul_config_request;
569
  fapi_nr_dl_config_request_t *dl_config_request;
570 571 572 573

  ///     Interface module instances
  nr_ue_if_module_t       *if_module;
  nr_phy_config_t         phy_config;
574
  nr_synch_request_t      synch_request;
575

576
  // order lc info
577
  A_SEQUENCE_OF(nr_lcordered_info_t) lc_ordered_list;
578
  NR_UE_SCHEDULING_INFO scheduling_info;
579
  NR_timer_t *data_inactivity_timer;
mjoang's avatar
mjoang committed
580

581
  int dmrs_TypeA_Position;
582 583
  int p_Max;
  int p_Max_alt;
584
  int n_ta_offset; // -1 not present, otherwise value to be applied
585 586

  long pdsch_HARQ_ACK_Codebook;
587

588
  NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config;
francescomani's avatar
francescomani committed
589
  frequency_range_t frequency_range;
590
  uint16_t nr_band;
591
  uint8_t ssb_subcarrier_offset;
francescomani's avatar
francescomani committed
592
  int ssb_start_subcarrier;
593

594
  NR_SSB_meas_t ssb_measurements;
595

596
  dci_pdu_rel15_t def_dci_pdu_rel15[NR_MAX_SLOTS_PER_FRAME][8];
597

598
  // Defined for abstracted mode
599
  nr_downlink_indication_t dl_info;
Melissa Elkadi's avatar
Melissa Elkadi committed
600
  NR_UE_HARQ_STATUS_t dl_harq_info[NR_MAX_HARQ_PROCESSES];
601
  NR_UL_HARQ_INFO_t ul_harq_info[NR_MAX_HARQ_PROCESSES];
602

603
  NR_TAG_Id_t tag_Id;
francescomani's avatar
francescomani committed
604
  A_SEQUENCE_OF(NR_TAG_t) TAG_list;
605
  NR_TimeAlignmentTimer_t timeAlignmentTimerCommon;
606
  NR_timer_t time_alignment_timer;
607

608
  nr_emulated_l1_t nr_ue_emul_l1;
609

610 611
  pthread_mutex_t mutex_dl_info;

612 613
  //SIDELINK MAC PARAMETERS
  sl_nr_ue_mac_params_t *SL_MAC_PARAMS;
614 615 616
  // PUCCH closed loop power control state
  int G_b_f_c;
  bool pucch_power_control_initialized;
617 618
  int f_b_f_c;
  bool pusch_power_control_initialized;
619
  int delta_msg2;
620
} NR_UE_MAC_INST_t;
621 622 623

/*@}*/
#endif /*__LAYER2_MAC_DEFS_H__ */