platform_types.h 11.3 KB
Newer Older
1
2
3
4
5
/*
 * 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
Cedric Roux's avatar
Cedric Roux committed
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 * 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
23
24
25
26
27
28
29
30
31
32
/*
                                 platform_types.h
                             -------------------
  AUTHOR  : Lionel GAUTHIER
  COMPANY : EURECOM
  EMAIL   : Lionel.Gauthier@eurecom.fr

 ***************************************************************************/
#ifndef __PLATFORM_TYPES_H__
#    define __PLATFORM_TYPES_H__

33
#ifdef USER_MODE
gauthier's avatar
gauthier committed
34
#include <stdint.h>
35
36
#endif

37
38
39
#if defined(ENABLE_ITTI)
#include "itti_types.h"
#endif
gauthier's avatar
gauthier committed
40
41
42
//-----------------------------------------------------------------------------
// GENERIC TYPES
//-----------------------------------------------------------------------------
43
44
45
46
47
48
49

/* boolean_t is also defined in openair2/COMMON/commonDef.h,
 * let's protect potential redefinition
 */
#ifndef _BOOLEAN_T_DEFINED_
#define _BOOLEAN_T_DEFINED_

50
typedef signed char        boolean_t;
gauthier's avatar
gauthier committed
51

gauthier's avatar
gauthier committed
52
53
54
#if !defined(TRUE)
#define TRUE               (boolean_t)0x01
#endif
gauthier's avatar
gauthier committed
55

gauthier's avatar
gauthier committed
56
57
58
59
#if !defined(FALSE)
#define FALSE              (boolean_t)0x00
#endif

60
61
#define BOOL_NOT(b) (b^TRUE)

62
63
#endif /* _BOOLEAN_T_DEFINED_ */

gauthier's avatar
gauthier committed
64
65
66
//-----------------------------------------------------------------------------
// GENERIC ACCESS STRATUM TYPES
//-----------------------------------------------------------------------------
67
typedef int32_t               sdu_size_t;
gauthier's avatar
gauthier committed
68
69
70
71
typedef uint32_t              frame_t;
typedef int32_t               sframe_t;
typedef uint32_t              sub_frame_t;
typedef uint8_t               module_id_t;
72
typedef uint8_t               eNB_index_t;
knopp's avatar
   
knopp committed
73
74
typedef uint16_t              ue_id_t;
typedef int16_t               smodule_id_t;
gauthier's avatar
gauthier committed
75
76
77
typedef uint16_t              rb_id_t;
typedef uint16_t              srb_id_t;

gauthier's avatar
gauthier committed
78
79
80
81
82
83
84
85
typedef boolean_t             MBMS_flag_t;
#define  MBMS_FLAG_NO         FALSE
#define  MBMS_FLAG_YES        TRUE

typedef boolean_t             eNB_flag_t;
#define  ENB_FLAG_NO          FALSE
#define  ENB_FLAG_YES         TRUE

nikaeinn's avatar
nikaeinn committed
86
87
88
89
typedef boolean_t             srb_flag_t;
#define  SRB_FLAG_NO          FALSE
#define  SRB_FLAG_YES         TRUE

Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
90
91
92
93
typedef boolean_t             sl_discovery_flag_t;
#define  SL_DISCOVERY_FLAG_NO          FALSE
#define  SL_DISCOVERY_FLAG_YES         TRUE

gauthier's avatar
gauthier committed
94
typedef enum link_direction_e {
95
96
97
  UNKNOWN_DIR          = 0,
  DIR_UPLINK           = 1,
  DIR_DOWNLINK         = 2
gauthier's avatar
gauthier committed
98
99
} link_direction_t;

gauthier's avatar
gauthier committed
100
typedef enum rb_type_e {
101
102
103
  UNKNOWN_RADIO_BEARER        = 0,
  SIGNALLING_RADIO_BEARER     = 1,
  RADIO_ACCESS_BEARER         = 2
gauthier's avatar
gauthier committed
104
105
106
107
108
109
110
111
112
113
114
115
116
} rb_type_t;

//-----------------------------------------------------------------------------
// PHY TYPES
//-----------------------------------------------------------------------------
typedef uint8_t            crc8_t;
typedef uint16_t           crc16_t;
typedef uint32_t           crc32_t;
typedef unsigned int       crc_t;

//-----------------------------------------------------------------------------
// MAC TYPES
//-----------------------------------------------------------------------------
117
118
typedef sdu_size_t         tbs_size_t;
typedef sdu_size_t         tb_size_t;
gauthier's avatar
gauthier committed
119
120
typedef unsigned int       logical_chan_id_t;
typedef unsigned int       num_tb_t;
121
typedef uint8_t            mac_enb_index_t;
gauthier's avatar
gauthier committed
122
123
124
125
126
127
128
129
130

//-----------------------------------------------------------------------------
// RLC TYPES
//-----------------------------------------------------------------------------
typedef unsigned int       mui_t;
typedef unsigned int       confirm_t;
typedef unsigned int       rlc_tx_status_t;
typedef int16_t            rlc_sn_t;
typedef uint16_t           rlc_usn_t;
131
typedef int32_t            rlc_buffer_occupancy_t;
gauthier's avatar
gauthier committed
132
133
typedef signed int         rlc_op_status_t;

134
135
#define  SDU_CONFIRM_NO          FALSE
#define  SDU_CONFIRM_YES         TRUE
gauthier's avatar
gauthier committed
136
137
138
139
140
//-----------------------------------------------------------------------------
// PDCP TYPES
//-----------------------------------------------------------------------------
typedef uint16_t           pdcp_sn_t;
typedef uint32_t           pdcp_hfn_t;
141
typedef int16_t            pdcp_hfn_offset_t;
gauthier's avatar
gauthier committed
142
143

typedef enum pdcp_transmission_mode_e {
144
145
146
147
  PDCP_TRANSMISSION_MODE_UNKNOWN     = 0,
  PDCP_TRANSMISSION_MODE_CONTROL     = 1,
  PDCP_TRANSMISSION_MODE_DATA        = 2,
  PDCP_TRANSMISSION_MODE_TRANSPARENT = 3
gauthier's avatar
gauthier committed
148
149
150
151
} pdcp_transmission_mode_t;
//-----------------------------------------------------------------------------
// IP DRIVER / PDCP TYPES
//-----------------------------------------------------------------------------
152
typedef uint16_t           tcp_udp_port_t;
gauthier's avatar
gauthier committed
153
typedef enum  ip_traffic_type_e {
154
155
156
157
158
159
160
161
  TRAFFIC_IPVX_TYPE_UNKNOWN    =  0,
  TRAFFIC_IPV6_TYPE_UNICAST    =  1,
  TRAFFIC_IPV6_TYPE_MULTICAST  =  2,
  TRAFFIC_IPV6_TYPE_UNKNOWN    =  3,
  TRAFFIC_IPV4_TYPE_UNICAST    =  5,
  TRAFFIC_IPV4_TYPE_MULTICAST  =  6,
  TRAFFIC_IPV4_TYPE_BROADCAST  =  7,
  TRAFFIC_IPV4_TYPE_UNKNOWN    =  8
gauthier's avatar
gauthier committed
162
163
164
165
166
167
168
169
} ip_traffic_type_t;

//-----------------------------------------------------------------------------
// RRC TYPES
//-----------------------------------------------------------------------------
typedef uint32_t           mbms_session_id_t;
typedef uint16_t           mbms_service_id_t;
typedef uint16_t           rnti_t;
170
typedef uint8_t            rrc_enb_index_t;
gauthier's avatar
gauthier committed
171
172
typedef uint8_t            mme_code_t;
typedef uint32_t           m_tmsi_t;
173

gauthier's avatar
gauthier committed
174
175
176
177
//Random UE identity length = 40 bits
#if ! defined(NOT_A_RANDOM_UE_IDENTITY)
#define NOT_A_RANDOM_UE_IDENTITY (uint64_t)0xFFFFFFFF
#endif
178
179
180
181
182
183
184
185
186
187
188
189
#if ! defined(NOT_A_RNTI)
#define NOT_A_RNTI (rnti_t)0
#endif
#if ! defined(M_RNTI)
#define M_RNTI     (rnti_t)0xFFFD
#endif
#if ! defined(P_RNTI)
#define P_RNTI     (rnti_t)0xFFFE
#endif
#if ! defined(SI_RNTI)
#define SI_RNTI    (rnti_t)0xFFFF
#endif
gauthier's avatar
gauthier committed
190
typedef enum config_action_e {
191
192
193
194
195
196
197
  CONFIG_ACTION_NULL              = 0,
  CONFIG_ACTION_ADD               = 1,
  CONFIG_ACTION_REMOVE            = 2,
  CONFIG_ACTION_MODIFY            = 3,
  CONFIG_ACTION_SET_SECURITY_MODE = 4,
  CONFIG_ACTION_MBMS_ADD          = 10,
  CONFIG_ACTION_MBMS_MODIFY       = 11
gauthier's avatar
gauthier committed
198
} config_action_t;
199
200
201
202
203
204

//-----------------------------------------------------------------------------
// GTPV1U TYPES
//-----------------------------------------------------------------------------
typedef uint32_t           teid_t; // tunnel endpoint identifier
typedef uint8_t            ebi_t;  // eps bearer id
205
206
207
208
209
210



//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
211
212
213
214
// may be ITTI not enabled, but type instance is useful also for OTG,
#if !defined(instance_t)
typedef uint16_t instance_t;
#endif
215
typedef struct protocol_ctxt_s {
216
  module_id_t module_id;     /*!< \brief  Virtualized module identifier      */
217
  eNB_flag_t  enb_flag;      /*!< \brief  Flag to indicate eNB (1) or UE (0) */
218
219
220
221
  instance_t  instance;      /*!< \brief  ITTI or OTG module identifier      */
  rnti_t      rnti;
  frame_t     frame;         /*!< \brief  LTE frame number.*/
  sub_frame_t subframe;      /*!< \brief  LTE sub frame number.*/
222
  eNB_index_t eNB_index;     /*!< \brief  valid for UE indicating the index of connected eNB(s)      */
223
  boolean_t   configured;  /*!< \brief  flag indicating whether the instance is configured or not  */
224
} protocol_ctxt_t;
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
// warning time hardcoded
#define PROTOCOL_CTXT_TIME_MILLI_SECONDS(CtXt_h) ((CtXt_h)->frame*10+(CtXt_h)->subframe)

#define UE_MODULE_ID_TO_INSTANCE( mODULE_iD ) mODULE_iD + NB_eNB_INST
#define ENB_MODULE_ID_TO_INSTANCE( mODULE_iD ) mODULE_iD
#define UE_INSTANCE_TO_MODULE_ID( iNSTANCE ) iNSTANCE - NB_eNB_INST
#define ENB_INSTANCE_TO_MODULE_ID( iNSTANCE )iNSTANCE


#define MODULE_ID_TO_INSTANCE(mODULE_iD, iNSTANCE, eNB_fLAG) \
    if(eNB_fLAG == ENB_FLAG_YES) \
        iNSTANCE = ENB_MODULE_ID_TO_INSTANCE(mODULE_iD); \
    else \
        iNSTANCE = UE_MODULE_ID_TO_INSTANCE(mODULE_iD)

#define INSTANCE_TO_MODULE_ID(iNSTANCE, mODULE_iD, eNB_fLAG) \
    if(eNB_fLAG == ENB_FLAG_YES) \
        mODULE_iD = ENB_INSTANCE_TO_MODULE_ID(iNSTANCE); \
    else \
        mODULE_iD = UE_INSTANCE_TO_MODULE_ID(iNSTANCE)

#define PROTOCOL_CTXT_COMPUTE_MODULE_ID(CtXt_h) \
    INSTANCE_TO_MODULE_ID( (CtXt_h)->instance , (CtXt_h)->module_id , (CtXt_h)->enb_flag )


#define PROTOCOL_CTXT_COMPUTE_INSTANCE(CtXt_h) \
    MODULE_ID_TO_INSTANCE( (CtXt_h)->module_id , (CtXt_h)->instance , (CtXt_h)->enb_flag )


254
#define PROTOCOL_CTXT_SET_BY_MODULE_ID(Ctxt_Pp, mODULE_iD, eNB_fLAG, rNTI, fRAME, sUBfRAME, eNB_iNDEX) \
255
256
257
258
259
    (Ctxt_Pp)->module_id = mODULE_iD; \
    (Ctxt_Pp)->enb_flag  = eNB_fLAG; \
    (Ctxt_Pp)->rnti      = rNTI; \
    (Ctxt_Pp)->frame     = fRAME; \
    (Ctxt_Pp)->subframe  = sUBfRAME; \
260
    (Ctxt_Pp)->eNB_index  = eNB_iNDEX; \
261
262
263
264
265
266
267
268
269
270
    PROTOCOL_CTXT_COMPUTE_INSTANCE(Ctxt_Pp)

#define PROTOCOL_CTXT_SET_BY_INSTANCE(Ctxt_Pp, iNSTANCE, eNB_fLAG, rNTI, fRAME, sUBfRAME) \
    (Ctxt_Pp)->instance  = iNSTANCE; \
    (Ctxt_Pp)->enb_flag  = eNB_fLAG; \
    (Ctxt_Pp)->rnti      = rNTI; \
    (Ctxt_Pp)->frame     = fRAME; \
    (Ctxt_Pp)->subframe  = sUBfRAME; \
    PROTOCOL_CTXT_COMPUTE_MODULE_ID(Ctxt_Pp)

laurent's avatar
laurent committed
271
#define PROTOCOL_CTXT_FMT "[FRAME %05u][%s][MOD %02u][RNTI %" PRIx16 "]"
272
#define PROTOCOL_CTXT_ARGS(CTXT_Pp) \
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
    (CTXT_Pp)->frame, \
    ((CTXT_Pp)->enb_flag == ENB_FLAG_YES) ? "eNB":" UE", \
    (CTXT_Pp)->module_id, \
    (CTXT_Pp)->rnti

#ifdef OAI_EMU
#define CHECK_CTXT_ARGS(CTXT_Pp) \
    if ((CTXT_Pp)->enb_flag) {\
        AssertFatal (((CTXT_Pp)->module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0),\
                     "eNB module id is too low (%u/%d/%d)!\n",\
                     (CTXT_Pp)->module_id,\
                     oai_emulation.info.first_enb_local,\
                     oai_emulation.info.nb_enb_local);\
        AssertFatal (((CTXT_Pp)->module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0),\
                     "eNB module id is too high (%u/%d)!\n",\
                     (CTXT_Pp)->module_id,\
                     oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local);\
    } else {\
        AssertFatal ((CTXT_Pp)->module_id  < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local),\
                     "UE module id is too high (%u/%d)!\n",\
                     (CTXT_Pp)->module_id,\
                     oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);\
        AssertFatal ((CTXT_Pp)->module_id  >= oai_emulation.info.first_ue_local,\
                     "UE module id is too low (%u/%d)!\n",\
                     (CTXT_Pp)->module_id,\
                     oai_emulation.info.first_ue_local);\
    }
#else
#define CHECK_CTXT_ARGS(CTXT_Pp)
#endif
303
#endif