JIRA-ID:[ODUHIGH-295]- Tunnel creation in EGTP
[o-du/l2.git] / src / cm / common_def.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18 #ifndef __COMMON_DEF_H__
19 #define __COMMON_DEF_H__
20
21 #include <stdio.h>
22 #include <ctype.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <stdbool.h>
26 #include <stdint.h>
27
28 #include "cm_mem.h"
29 #include "cm_math.h"
30 #include "envopt.h"
31 #include "envdep.h"
32 #include "envind.h"
33 #include "gen.h" 
34 #include "ssi.h" 
35 #include "cm5.h"
36 #include "cm_tkns.h"
37 #include "cm_mblk.h"
38 #include "cm_llist.h"
39 #include "cm_hash.h"
40 #include "cm_lte.h"
41 #include "cm_err.h"
42 #include "cm_tpt.h"
43 #include "cm.h"
44 #include "gen.x"           /* general */
45 #include "ssi.x"           /* system services */
46 #include "cm_math.x"
47 #include "cm_tpt.x"
48 #include "cm_tkns.x" 
49 #include "cm_mblk.x"
50 #include "cm_llist.x"
51 #include "cm5.x" 
52 #include "cm_hash.x"
53 #include "cm_lte.x"
54 #include "cm_lib.x"
55 #include "du_log.h"
56
57 /* MAX values */
58 #define MAX_NUM_CELL 1
59 #define MAX_NUM_UE   1
60 #define MAX_NUM_LC   11
61 #define MAX_NUM_TUNNEL  2 /* Max. no of Tunnels */
62
63 /* 5G ORAN phy delay */
64 #define PHY_DELTA 2
65
66  /* SELECTORS */ 
67 #define ODU_SELECTOR_LC 0
68 #define ODU_SELECTOR_TC 1
69 #define ODU_SELECTOR_LWLC 2
70
71 #define ODU_START_CRNTI   100
72 #define ODU_END_CRNTI     500
73
74 /* LCID */
75 #define SRB0_LCID  0
76 #define SRB1_LCID  1
77 #define SRB2_LCID  2
78 #define SRB3_LCID  3
79 #define MIN_DRB_LCID 4
80 #define MAX_DRB_LCID 32
81
82 #define FREQ_DOM_RSRC_SIZE  6      /* i.e. 6 bytes because Size of frequency domain resource is 45 bits */
83 #define PUCCH_FORMAT_0 0
84 #define PUCCH_FORMAT_1 1
85 #define PUCCH_FORMAT_2 2
86 #define PUCCH_FORMAT_3 3 
87 #define PUCCH_FORMAT_4 4
88
89 #define BANDWIDTH_20MHZ 20
90 #define BANDWIDTH_100MHZ 100
91
92 /* PRB allocation as per 38.101, Section 5.3.2 */
93 #define TOTAL_PRB_20MHZ_MU0 106
94 #define TOTAL_PRB_100MHZ_MU1 273
95
96 /* Defining macros for common utility functions */
97 #define ODU_GET_MSG_BUF SGetMsg
98 #define ODU_PUT_MSG_BUF SPutMsg
99 #define ODU_ADD_PRE_MSG_MULT SAddPreMsgMult
100 #define ODU_ADD_PRE_MSG_MULT_IN_ORDER SAddPreMsgMultInOrder
101 #define ODU_ADD_POST_MSG_MULT SAddPstMsgMult
102 #define ODU_START_TASK SStartTask
103 #define ODU_STOP_TASK SStopTask
104 #define ODU_ATTACH_TTSK SAttachTTsk
105 #define ODU_POST_TASK SPstTsk
106 #define ODU_COPY_MSG_TO_FIX_BUF SCpyMsgFix
107 #define ODU_COPY_FIX_BUF_TO_MSG SCpyFixMsg
108 #define ODU_REG_TTSK SRegTTsk
109 #define ODU_SET_PROC_ID SSetProcId
110 #define ODU_GET_MSG_LEN SFndLenMsg
111 #define ODU_EXIT_TASK SExitTsk
112 #define ODU_PRINT_MSG SPrntMsg
113 #define ODU_REM_PRE_MSG SRemPreMsg
114 #define ODU_REM_PRE_MSG_MULT SRemPreMsgMult
115 #define ODU_REG_TMR_MT SRegTmrMt
116 #define ODU_SEGMENT_MSG SSegMsg
117 #define ODU_CAT_MSG SCatMsg
118 #define ODU_GET_PROCID SFndProcId
119 #define ODU_SET_THREAD_AFFINITY SSetAffinity
120 #define ODU_CREATE_TASK SCreateSTsk
121
122 #ifdef NR_TDD
123 /* Maximum slots for max periodicity and highest numerology is 320.
124  * However, aligning to fapi_interface.h, setting this macro to 160 */
125 #define MAX_TDD_PERIODICITY_SLOTS 160 
126 #define MAX_SYMB_PER_SLOT 14 
127 #endif
128
129 #define GET_UE_IDX( _crnti,_ueIdx)         \
130 {                                          \
131    _ueIdx = _crnti - ODU_START_CRNTI + 1;  \
132 }
133
134 #define GET_CRNTI( _crnti,_ueIdx)          \
135 {                                          \
136    _crnti = _ueIdx + ODU_START_CRNTI - 1;  \
137 }
138
139 /* Calculates cellIdx from cellId */
140 #define GET_CELL_IDX(_cellId, _cellIdx)   \
141 {                                         \
142    _cellIdx = _cellId - 1;                \
143 }
144
145 #define SET_BITS_MSB(_startBit, _numBits, _byte) \
146 {                                                \
147    _byte = (~((0xFF) >> _numBits));              \
148        _byte >>= _startBit;                          \
149 }
150
151 #define SET_BITS_LSB(_startBit, _numBits, _byte) \
152 {                                                \
153    _byte = (~((0xFF) << _numBits));              \
154        _byte <<= _startBit;                          \
155 }
156
157 /* this MACRO set 1 bit at the bit position */
158 #define SET_ONE_BIT(_bitPos, _out)            \
159 {                                             \
160    _out = ((1<<_bitPos) | _out);              \
161 }
162
163 /* this MACRO un-set 1 bit at the bit position */
164 #define UNSET_ONE_BIT(_bitPos, _out)            \
165 {                                               \
166    _out = (~(1<<_bitPos) & _out);               \
167 }
168
169 /* this MACRO finds the index of the rightmost set bit */
170 #define GET_RIGHT_MOST_SET_BIT( _in,_bitPos)        \
171 {                                                \
172    _bitPos = __builtin_ctz(_in);                 \
173 }
174
175 typedef enum
176 {
177    UE_CFG_INACTIVE,
178    UE_CREATE_COMPLETE,
179    UE_RECFG_COMPLETE
180 }UeCfgState;
181
182 typedef enum
183 {
184    CONFIG_UNKNOWN,
185    CONFIG_ADD,
186    CONFIG_MOD,
187    CONFIG_DEL
188 }ConfigType;
189
190 #ifdef NR_TDD
191 typedef enum
192 {
193    DL_SLOT,
194    UL_SLOT,
195    FLEXI_SLOT
196 }SlotConfig;
197
198 typedef enum
199 {
200    TX_PRDCTY_MS_0P5,
201    TX_PRDCTY_MS_0P625,
202    TX_PRDCTY_MS_1,
203    TX_PRDCTY_MS_1P25,
204    TX_PRDCTY_MS_2,
205    TX_PRDCTY_MS_2P5,
206    TX_PRDCTY_MS_5,
207    TX_PRDCTY_MS_10
208 }DlUlTxPeriodicity;
209 #endif
210
211 typedef struct slotIndInfo
212 {
213    uint16_t cellId;
214    uint16_t sfn;
215    uint16_t slot;
216 }SlotIndInfo;
217
218 typedef struct PlmnIdentity
219 {
220    uint8_t mcc[3];
221    uint8_t mnc[3];
222 }Plmn;
223
224 typedef struct oduCellId
225 {
226    uint16_t cellId;
227 }OduCellId;
228
229 #ifdef NR_TDD
230 typedef struct tddCfg
231 {
232    bool               pres;
233    DlUlTxPeriodicity  tddPeriod;      /* DL UL Transmission periodicity */
234    SlotConfig         slotCfg[MAX_TDD_PERIODICITY_SLOTS][MAX_SYMB_PER_SLOT]; 
235 }TDDCfg;
236 #endif
237
238
239 uint64_t gSlotCount;
240 uint64_t gDlDataRcvdCnt;   /* Number of DL data received at EGTP */
241
242 void freqDomRscAllocType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain);
243 void oduCpyFixBufToMsg(uint8_t *fixBuf, Buffer *mBuf, uint16_t len);
244 uint8_t buildPlmnId(Plmn plmn, uint8_t *buf);
245
246 #endif
247
248 /**********************************************************************
249   End of file
250 ***********************************************************************/