platform_types.h 10.5 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
#if !defined(NAS_NETLINK)
gauthier's avatar
gauthier committed
34
#include <stdint.h>
35
36
#endif

gauthier's avatar
gauthier committed
37
38
39
//-----------------------------------------------------------------------------
// GENERIC TYPES
//-----------------------------------------------------------------------------
40
41
42
43
44
45
46

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

47
typedef signed char        boolean_t;
gauthier's avatar
gauthier committed
48

gauthier's avatar
gauthier committed
49
50
51
#if !defined(TRUE)
#define TRUE               (boolean_t)0x01
#endif
gauthier's avatar
gauthier committed
52

gauthier's avatar
gauthier committed
53
54
55
56
#if !defined(FALSE)
#define FALSE              (boolean_t)0x00
#endif

57
58
#define BOOL_NOT(b) (b^TRUE)

59
60
#endif /* _BOOLEAN_T_DEFINED_ */

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

gauthier's avatar
gauthier committed
76
77
78
79
80
81
82
83
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
84
85
86
87
typedef boolean_t             srb_flag_t;
#define  SRB_FLAG_NO          FALSE
#define  SRB_FLAG_YES         TRUE

88
89
90
91
typedef boolean_t             sl_discovery_flag_t;
#define  SL_DISCOVERY_FLAG_NO          FALSE
#define  SL_DISCOVERY_FLAG_YES         TRUE

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

gauthier's avatar
gauthier committed
98
typedef enum rb_type_e {
99
100
101
  UNKNOWN_RADIO_BEARER        = 0,
  SIGNALLING_RADIO_BEARER     = 1,
  RADIO_ACCESS_BEARER         = 2
gauthier's avatar
gauthier committed
102
103
} rb_type_t;

104
105
106
107
108
109
typedef enum {
    CR_ROUND = 0,
    CR_SRB12 = 1,
    CR_HOL   = 2,
    CR_LC    = 3,
    CR_CQI   = 4,
110
111
    CR_LCP   = 5,
    CR_NUM   = 6
112
113
} sorting_criterion_t;

114
115
116
117
118
typedef enum {
    POL_FAIR   = 0,
    POL_GREEDY = 1,
    POL_NUM    = 2
} accounting_policy_t;
gauthier's avatar
gauthier committed
119
120
121
122
123
124
125
126
127
128
129
//-----------------------------------------------------------------------------
// PHY TYPES
//-----------------------------------------------------------------------------
typedef uint8_t            crc8_t;
typedef uint16_t           crc16_t;
typedef uint32_t           crc32_t;
typedef unsigned int       crc_t;

//-----------------------------------------------------------------------------
// MAC TYPES
//-----------------------------------------------------------------------------
130
131
typedef sdu_size_t         tbs_size_t;
typedef sdu_size_t         tb_size_t;
gauthier's avatar
gauthier committed
132
133
typedef unsigned int       logical_chan_id_t;
typedef unsigned int       num_tb_t;
134
typedef uint8_t            mac_enb_index_t;
gauthier's avatar
gauthier committed
135
136
137
138
139
140
141
142
143

//-----------------------------------------------------------------------------
// 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;
144
typedef int32_t            rlc_buffer_occupancy_t;
gauthier's avatar
gauthier committed
145
146
typedef signed int         rlc_op_status_t;

147
148
#define  SDU_CONFIRM_NO          FALSE
#define  SDU_CONFIRM_YES         TRUE
gauthier's avatar
gauthier committed
149
150
151
152
153
//-----------------------------------------------------------------------------
// PDCP TYPES
//-----------------------------------------------------------------------------
typedef uint16_t           pdcp_sn_t;
typedef uint32_t           pdcp_hfn_t;
154
typedef int16_t            pdcp_hfn_offset_t;
gauthier's avatar
gauthier committed
155
156

typedef enum pdcp_transmission_mode_e {
157
158
159
160
  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
161
162
163
164
} pdcp_transmission_mode_t;
//-----------------------------------------------------------------------------
// IP DRIVER / PDCP TYPES
//-----------------------------------------------------------------------------
165
typedef uint16_t           tcp_udp_port_t;
gauthier's avatar
gauthier committed
166
typedef enum  ip_traffic_type_e {
167
168
169
170
171
172
173
  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,
174
175
176
  TRAFFIC_IPV4_TYPE_UNKNOWN    =  8,
  TRAFFIC_PC5S_SIGNALLING      =  9,
  TRAFFIC_PC5S_SESSION_INIT    =  10
gauthier's avatar
gauthier committed
177
178
179
180
181
182
183
184
} 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;
185
typedef uint8_t            rrc_enb_index_t;
gauthier's avatar
gauthier committed
186
187
typedef uint8_t            mme_code_t;
typedef uint32_t           m_tmsi_t;
188

gauthier's avatar
gauthier committed
189
190
191
192
//Random UE identity length = 40 bits
#if ! defined(NOT_A_RANDOM_UE_IDENTITY)
#define NOT_A_RANDOM_UE_IDENTITY (uint64_t)0xFFFFFFFF
#endif
193
194
195
196
197
198
199
200
201
202
203
204
#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
205
typedef enum config_action_e {
206
207
208
209
210
211
212
  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
213
} config_action_t;
214
215
216
217
218
219

//-----------------------------------------------------------------------------
// GTPV1U TYPES
//-----------------------------------------------------------------------------
typedef uint32_t           teid_t; // tunnel endpoint identifier
typedef uint8_t            ebi_t;  // eps bearer id
220
221
222
223
224
225



//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
226
227
228
229
// may be ITTI not enabled, but type instance is useful also for OTG,
#if !defined(instance_t)
typedef uint16_t instance_t;
#endif
230
typedef struct protocol_ctxt_s {
231
  module_id_t module_id;     /*!< \brief  Virtualized module identifier      */
232
  eNB_flag_t  enb_flag;      /*!< \brief  Flag to indicate eNB (1) or UE (0) */
233
234
235
236
  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.*/
237
  eNB_index_t eNB_index;     /*!< \brief  valid for UE indicating the index of connected eNB(s)      */
238
  boolean_t   configured;  /*!< \brief  flag indicating whether the instance is configured or not  */
239
} protocol_ctxt_t;
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
// 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 )


269
#define PROTOCOL_CTXT_SET_BY_MODULE_ID(Ctxt_Pp, mODULE_iD, eNB_fLAG, rNTI, fRAME, sUBfRAME, eNB_iNDEX) \
270
271
272
273
274
    (Ctxt_Pp)->module_id = mODULE_iD; \
    (Ctxt_Pp)->enb_flag  = eNB_fLAG; \
    (Ctxt_Pp)->rnti      = rNTI; \
    (Ctxt_Pp)->frame     = fRAME; \
    (Ctxt_Pp)->subframe  = sUBfRAME; \
275
    (Ctxt_Pp)->eNB_index  = eNB_iNDEX; \
276
277
278
279
280
281
282
283
284
285
    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
286
#define PROTOCOL_CTXT_FMT "[FRAME %05u][%s][MOD %02u][RNTI %" PRIx16 "]"
287
#define PROTOCOL_CTXT_ARGS(CTXT_Pp) \
288
289
290
291
292
293
    (CTXT_Pp)->frame, \
    ((CTXT_Pp)->enb_flag == ENB_FLAG_YES) ? "eNB":" UE", \
    (CTXT_Pp)->module_id, \
    (CTXT_Pp)->rnti

#define CHECK_CTXT_ARGS(CTXT_Pp)
294
295
296

#define exit_fun(msg) exit_function(__FILE__,__FUNCTION__,__LINE__,msg)
void exit_function(const char* file, const char* function, const int line, const char* s);
297
#endif