nr_rrc_defs.h 14.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.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
 */

yilmazt's avatar
yilmazt committed
21
/*! \file RRC/NR/nr_rrc_defs.h
22
* \brief NR RRC struct definitions and function prototypes
WEI-TAI CHEN's avatar
WEI-TAI CHEN committed
23
* \author Navid Nikaein, Raymond Knopp, WEI-TAI CHEN
24 25
* \date 2010 - 2014, 2018
* \version 1.0
WEI-TAI CHEN's avatar
WEI-TAI CHEN committed
26 27
* \company Eurecom, NTSUT
* \email: navid.nikaein@eurecom.fr, raymond.knopp@eurecom.fr, kroempa@gmail.com
28 29 30 31 32 33 34 35 36 37 38
*/

#ifndef __OPENAIR_RRC_DEFS_NR_H__
#define __OPENAIR_RRC_DEFS_NR_H__


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "collection/tree.h"
39
#include "collection/linear_alloc.h"
40
#include "nr_rrc_common.h"
41
#include "ds/byte_array.h"
42

43
#include "common/ngran_types.h"
laurent's avatar
laurent committed
44
#include "common/platform_constants.h"
45
#include "COMMON/platform_types.h"
46
#include "mac_rrc_dl.h"
47
#include "cucp_cuup_if.h"
48 49 50 51

#include "NR_SIB1.h"
#include "NR_RRCReconfigurationComplete.h"
#include "NR_RRCReconfiguration.h"
52
#include "NR_RRCReestablishmentRequest.h"
53
#include "NR_BCCH-BCH-Message.h"
54
#include "NR_BCCH-DL-SCH-Message.h"
55
#include "NR_BCCH-BCH-Message.h"
56 57
#include "NR_PLMN-IdentityInfo.h"
#include "NR_MCC-MNC-Digit.h"
58
#include "NR_NG-5G-S-TMSI.h"
francescomani's avatar
francescomani committed
59

60
#include "NR_UE-NR-Capability.h"
61
#include "NR_UE-MRDC-Capability.h"
62 63
#include "NR_MeasResults.h"
#include "NR_CellGroupConfig.h"
64
#include "NR_ServingCellConfigCommon.h"
65
#include "NR_EstablishmentCause.h"
66

67 68
//-------------------

69
#include "intertask_interface.h"
70 71 72 73 74

/* TODO: be sure this include is correct.
 * It solves a problem of compilation of the RRH GW,
 * issue #186.
 */
75
  #include "as_message.h"
76

77
  #include "commonDef.h"
78 79

#define PROTOCOL_NR_RRC_CTXT_UE_FMT                PROTOCOL_CTXT_FMT
Xue Song's avatar
Xue Song committed
80
#define PROTOCOL_NR_RRC_CTXT_UE_ARGS(CTXT_Pp)      PROTOCOL_NR_CTXT_ARGS(CTXT_Pp)
81 82

#define PROTOCOL_NR_RRC_CTXT_FMT                   PROTOCOL_CTXT_FMT
Xue Song's avatar
Xue Song committed
83
#define PROTOCOL_NR_RRC_CTXT_ARGS(CTXT_Pp)         PROTOCOL_NR_CTXT_ARGS(CTXT_Pp)
84

85
// 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs
86 87 88
#define NR_RRC_SETUP_DELAY_MS           10
#define NR_RRC_RECONFIGURATION_DELAY_MS 10
#define NR_RRC_BWP_SWITCHING_DELAY_MS   6
89

90 91 92 93 94 95
// 3GPP TS 38.133 - Section 8 - Table 8.2.1.2.7-2: Parameters which cause interruption other than SCS
// This table was recently added to 3GPP. It shows that changing the parameters locationAndBandwidth, nrofSRS-Ports or
// maxMIMO-Layers-r16 causes an interruption. This parameter is not yet being used in code, but has been placed here
// for future reference.
#define NR_OF_SRS_PORTS_SWITCHING_DELAY_MS 30

96 97
#define NR_UE_MODULE_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!!
#define NR_UE_INDEX_INVALID  ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!! used to be -1
98

99 100 101 102 103 104 105 106 107 108 109 110 111
typedef enum {
  NR_RRC_OK=0,
  NR_RRC_ConnSetup_failed,
  NR_RRC_PHY_RESYNCH,
  NR_RRC_Handover_failed,
  NR_RRC_HO_STARTED
} NR_RRC_status_t;

#define RRM_FREE(p)       if ( (p) != NULL) { free(p) ; p=NULL ; }
#define RRM_MALLOC(t,n)   (t *) malloc16( sizeof(t) * n )
#define RRM_CALLOC(t,n)   (t *) malloc16( sizeof(t) * n)
#define RRM_CALLOC2(t,s)  (t *) malloc16( s )

112 113 114
#define MAX_MEAS_OBJ                                  7
#define MAX_MEAS_CONFIG                               7
#define MAX_MEAS_ID                                   7
115 116

#define PAYLOAD_SIZE_MAX                              1024
117
#define RRC_BUF_SIZE                                  1024
118 119 120 121
#define UNDEF_SECURITY_MODE                           0xff
#define NO_SECURITY_MODE                              0x20

/* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */
122
#define NR_RRC_TRANSACTION_IDENTIFIER_NUMBER 4
123 124

typedef struct UE_S_TMSI_NR_s {
125
  bool                                                presence;
Xue Song's avatar
Xue Song committed
126 127 128
  uint16_t                                            amf_set_id;
  uint8_t                                             amf_pointer;
  uint32_t                                            fiveg_tmsi;
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
} __attribute__ ((__packed__)) NR_UE_S_TMSI;


typedef enum nr_e_rab_satus_e {
  NR_E_RAB_STATUS_NEW,
  NR_E_RAB_STATUS_DONE,           // from the gNB perspective
  NR_E_RAB_STATUS_ESTABLISHED,    // get the reconfigurationcomplete form UE
  NR_E_RAB_STATUS_FAILED,
} nr_e_rab_status_t;

typedef struct nr_e_rab_param_s {
  e_rab_t param;
  uint8_t status;
  uint8_t xid; // transaction_id
} __attribute__ ((__packed__)) nr_e_rab_param_t;


typedef struct HANDOVER_INFO_NR_s {
  uint8_t                                             ho_prepare;
  uint8_t                                             ho_complete;
  uint8_t                                             modid_s;            //module_idP of serving cell
  uint8_t                                             modid_t;            //module_idP of target cell
  uint8_t                                             ueid_s;             //UE index in serving cell
  uint8_t                                             ueid_t;             //UE index in target cell

  // NR not define at this moment
  //AS_Config_t                                       as_config;          /* these two parameters are taken from 36.331 section 10.2.2: HandoverPreparationInformation-r8-IEs */
  //AS_Context_t                                      as_context;         /* They are mandatory for HO */

  uint8_t                                             buf[RRC_BUF_SIZE];  /* ASN.1 encoded handoverCommandMessage */
  int                                                 size;               /* size of above message in bytes */
} NR_HANDOVER_INFO;

#define NR_RRC_BUFFER_SIZE                            sizeof(RRC_BUFFER_NR)

Xue Song's avatar
Xue Song committed
164 165 166 167 168 169 170 171
typedef struct nr_rrc_guami_s {
  uint16_t mcc;
  uint16_t mnc;
  uint8_t  mnc_len;
  uint8_t  amf_region_id;
  uint16_t amf_set_id;
  uint8_t  amf_pointer;
} nr_rrc_guami_t;
172

173
typedef enum pdu_session_satus_e {
Xue Song's avatar
Xue Song committed
174 175 176
  PDU_SESSION_STATUS_NEW,
  PDU_SESSION_STATUS_DONE,
  PDU_SESSION_STATUS_ESTABLISHED,
177
  PDU_SESSION_STATUS_REESTABLISHED, // after HO
178
  PDU_SESSION_STATUS_TOMODIFY, // ENDC NSA
Xue Song's avatar
Xue Song committed
179
  PDU_SESSION_STATUS_FAILED,
180 181
  PDU_SESSION_STATUS_TORELEASE, // to release DRB between eNB and UE
  PDU_SESSION_STATUS_RELEASED
182 183 184 185
} pdu_session_status_t;

typedef struct pdu_session_param_s {
  pdusession_t param;
186
  pdu_session_status_t status;
187
  uint8_t xid; // transaction_id
188
  ngap_Cause_t cause;
189
  uint8_t cause_value;
laurent's avatar
tmp  
laurent committed
190
} rrc_pdu_session_param_t;
191

192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
typedef struct drb_s {
  int status;
  int defaultDRBid;
  int drb_id;
  int reestablishPDCP;
  int recoverPDCP;
  int daps_Config_r16;
  struct cnAssociation_s {
    int present;
    int eps_BearerIdentity;
    struct sdap_config_s {
      bool defaultDRB;
      int pdusession_id;
      int sdap_HeaderDL;
      int sdap_HeaderUL;
      int mappedQoS_FlowsToAdd[QOSFLOW_MAX_VALUE];
    } sdap_config;
  } cnAssociation;
  struct pdcp_config_s {
    int discardTimer;
    int pdcp_SN_SizeUL;
    int pdcp_SN_SizeDL;
    int t_Reordering;
    int integrityProtection;
216
    struct headerCompression_s {
217 218 219 220 221 222 223 224 225
      int NotUsed;
      int present;
    } headerCompression;
    struct ext1_s {
      int cipheringDisabled;
    } ext1;
  } pdcp_config;
} drb_t;

226 227 228 229 230 231 232 233 234 235 236 237
typedef enum {
  RRC_SETUP,
  RRC_SETUP_FOR_REESTABLISHMENT,
  RRC_REESTABLISH,
  RRC_REESTABLISH_COMPLETE,
  RRC_DEFAULT_RECONF,
  RRC_DEDICATED_RECONF,
  RRC_PDUSESSION_ESTABLISH,
  RRC_PDUSESSION_MODIFY,
  RRC_PDUSESSION_RELEASE
} rrc_action_t;

238
typedef struct gNB_RRC_UE_s {
239 240
  drb_t                              established_drbs[MAX_DRBS_PER_UE];
  uint8_t                            DRB_active[MAX_DRBS_PER_UE];
241
  NR_DRB_ToReleaseList_t            *DRB_ReleaseList;
242

laurent's avatar
tmp  
laurent committed
243
  NR_SRB_INFO_TABLE_ENTRY Srb[maxSRBs]; // 3gpp max is 3 SRBs, number 1..3, we waste the entry 0 for code simplicity
244
  NR_MeasConfig_t                   *measConfig;
245
  NR_HANDOVER_INFO                  *handover_info;
246
  NR_MeasResults_t                  *measResults;
247

248
  byte_array_t ue_cap_buffer;
249
  NR_UE_NR_Capability_t*             UE_Capability_nr;
250
  int                                UE_Capability_size;
251
  NR_UE_MRDC_Capability_t*           UE_Capability_MRDC;
252
  int                                UE_MRDC_Capability_size;
253

Raymond Knopp's avatar
Raymond Knopp committed
254
  NR_CellGroupConfig_t               *secondaryCellGroup;
255
  NR_CellGroupConfig_t               *masterCellGroup;
Raymond Knopp's avatar
Raymond Knopp committed
256 257 258
  NR_RRCReconfiguration_t            *reconfig;
  NR_RadioBearerConfig_t             *rb_config;

259 260
  ImsiMobileIdentity_t               imsi;

261 262 263
  /* KgNB as derived from KASME received from EPC */
  uint8_t kgnb[32];
  int8_t  kgnb_ncc;
264 265
  uint8_t nh[32];
  int8_t  nh_ncc;
Xue Song's avatar
Xue Song committed
266

267
  /* Used integrity/ciphering algorithms */
268 269
  NR_CipheringAlgorithm_t            ciphering_algorithm;
  e_NR_IntegrityProtAlgorithm        integrity_algorithm;
270

271
  NR_UE_STATE_t                      StatusRrc;
272 273 274
  rnti_t                             rnti;
  uint64_t                           random_ue_identity;

275
  /* Information from UE RRC Setup Request */
Xue Song's avatar
Xue Song committed
276 277 278
  NR_UE_S_TMSI                       Initialue_identity_5g_s_TMSI;
  uint64_t                           ng_5G_S_TMSI_Part1;
  uint16_t                           ng_5G_S_TMSI_Part2;
279
  NR_EstablishmentCause_t            establishment_cause;
280

281
  /* Information from UE RRCReestablishmentRequest */
282
  NR_ReestablishmentCause_t          reestablishment_cause;
283

284
  uint32_t                           rrc_ue_id;
285
  uint64_t amf_ue_ngap_id;
Xue Song's avatar
Xue Song committed
286
  nr_rrc_guami_t                     ue_guami;
287

288
  ngap_security_capabilities_t       security_capabilities;
289 290
  //NSA block
  /* Number of NSA e_rab */
291
  uint8_t                            nb_of_e_rabs;
292
  /* list of pdu session to be setup by RRC layers */
293
  nr_e_rab_param_t                   e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB];
294 295 296 297
  uint32_t                           nsa_gtp_teid[S1AP_MAX_E_RAB];
  transport_layer_addr_t             nsa_gtp_addrs[S1AP_MAX_E_RAB];
  rb_id_t                            nsa_gtp_ebi[S1AP_MAX_E_RAB];
  rb_id_t                            nsa_gtp_psi[S1AP_MAX_E_RAB];
298

299 300 301 302 303 304
  //SA block
  int nb_of_pdusessions;
  rrc_pdu_session_param_t pduSession[NGAP_MAX_PDU_SESSION];
  rrc_action_t xids[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER];
  uint8_t e_rab_release_command_flag;
  uint32_t ue_rrc_inactivity_timer;
305 306
  uint32_t                           ue_reestablishment_counter;
  uint32_t                           ue_reconfiguration_after_reestablishment_counter;
307 308 309 310 311 312 313 314
  NR_CellGroupId_t                                      cellGroupId;
  struct NR_SpCellConfig                                *spCellConfig;
  struct NR_CellGroupConfig__sCellToAddModList          *sCellconfig;
  struct NR_CellGroupConfig__sCellToReleaseList         *sCellconfigRelease;
  struct NR_CellGroupConfig__rlc_BearerToAddModList     *rlc_BearerBonfig;
  struct NR_CellGroupConfig__rlc_BearerToReleaseList    *rlc_BearerRelease;
  struct NR_MAC_CellGroupConfig                         *mac_CellGroupConfig;
  struct NR_PhysicalCellGroupConfig                     *physicalCellGroupConfig;
315

Xue Song's avatar
Xue Song committed
316
  /* Nas Pdu */
laurent's avatar
tmp  
laurent committed
317
  ngap_pdu_t nas_pdu;
Xue Song's avatar
Xue Song committed
318

319 320 321 322 323
} gNB_RRC_UE_t;

typedef struct rrc_gNB_ue_context_s {
  /* Tree related data */
  RB_ENTRY(rrc_gNB_ue_context_s) entries;
324
  /* UE id for initial connection to NGAP */
325 326 327
  struct gNB_RRC_UE_s   ue_context;
} rrc_gNB_ue_context_t;

328 329
typedef struct {

330 331 332
  uint8_t                                   *SIB23;
  uint8_t                                   sizeof_SIB23;

333 334 335 336
} rrc_gNB_carrier_data_t;
//---------------------------------------------------


337 338 339 340 341 342 343 344
typedef struct {
  /* nea0 = 0, nea1 = 1, ... */
  int ciphering_algorithms[4];
  int ciphering_algorithms_count;

  /* nia0 = 0, nia1 = 1, ... */
  int integrity_algorithms[4];
  int integrity_algorithms_count;
345 346 347 348

  /* flags to enable/disable ciphering and integrity for DRBs */
  int do_drb_ciphering;
  int do_drb_integrity;
349
} nr_security_configuration_t;
350

351
typedef struct nr_mac_rrc_dl_if_s {
352 353
  f1_setup_response_func_t f1_setup_response;
  f1_setup_failure_func_t f1_setup_failure;
354
  ue_context_setup_request_func_t ue_context_setup_request;
355
  ue_context_modification_request_func_t ue_context_modification_request;
356 357
  ue_context_modification_confirm_func_t ue_context_modification_confirm;
  ue_context_modification_refuse_func_t ue_context_modification_refuse;
358
  ue_context_release_command_func_t ue_context_release_command;
359 360 361
  dl_rrc_message_transfer_func_t dl_rrc_message_transfer;
} nr_mac_rrc_dl_if_t;

362 363 364 365 366
typedef struct cucp_cuup_if_s {
  cucp_cuup_bearer_context_setup_func_t bearer_context_setup;
  cucp_cuup_bearer_context_setup_func_t bearer_context_mod;
} cucp_cuup_if_t;

367
typedef struct nr_rrc_du_container_t {
368
  sctp_assoc_t assoc_id;
369
  f1ap_setup_req_t *setup_req;
Robert Schmidt's avatar
Robert Schmidt committed
370
  NR_MIB_t *mib;
Robert Schmidt's avatar
Robert Schmidt committed
371
  NR_SIB1_t *sib1;
372 373
} nr_rrc_du_container_t;

374
typedef struct nr_rrc_cuup_container_t {
375 376 377
  /* Tree-related data */
  RB_ENTRY(nr_rrc_cuup_container_t) entries;

378
  e1ap_setup_req_t *setup_req;
379
  sctp_assoc_t assoc_id;
380 381
} nr_rrc_cuup_container_t;

382 383 384
//---NR---(completely change)---------------------
typedef struct gNB_RRC_INST_s {

Xue Song's avatar
Xue Song committed
385 386 387
  ngran_node_t                                        node_type;
  uint32_t                                            node_id;
  char                                               *node_name;
388
  int                                                 module_id;
389
  eth_params_t                                        eth_params_s;
390
  rrc_gNB_carrier_data_t                              carrier;
391
  uid_allocator_t                                     uid_allocator;
392
  RB_HEAD(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s) rrc_ue_head; // ue_context tree key search by rnti
Xue Song's avatar
Xue Song committed
393 394 395
  /// NR cell id
  uint64_t nr_cellid;

Xue Song's avatar
Xue Song committed
396 397 398
  // RRC configuration
  gNB_RrcConfigurationReq configuration;

399 400 401
  // gNB N3 GTPU instance
  instance_t e1_inst;

402 403
  char *uecap_file;

404 405
  // security configuration (preferred algorithms)
  nr_security_configuration_t security;
406 407

  nr_mac_rrc_dl_if_t mac_rrc;
408 409
  cucp_cuup_if_t cucp_cuup;

410
  nr_rrc_du_container_t *du;
411 412
  RB_HEAD(rrc_cuup_tree, nr_rrc_cuup_container_t) cuups; // CU-UPs, indexed by assoc_id
  size_t num_cuups;
413

414 415 416 417 418 419
} gNB_RRC_INST;

#include "nr_rrc_proto.h" //should be put here otherwise compilation error

#endif
/** @} */