1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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__
44 #include "gen.x" /* general */
45 #include "ssi.x" /* system services */
56 #define SCH_INST_START 1
57 #define SCH_MAX_INST 1
60 #define MAX_NUM_CELL 2 /* Changed to 2 to support cell Id 2 even if there is only one cell in DU */
63 #define MAX_NUM_UE_PER_TTI 2
64 #define MAX_NUM_LC MAX_DRB_LCID + 1 /*Spec 38.331: Sec 6.4: maxLC-ID Keyword*/
65 #define MAX_NUM_SRB 3 /* Max. no of Srbs */
66 #define MAX_NUM_DRB 29 /* spec 38.331, maxDRB */
67 #define MAX_NUM_SSB 64 /* spec 28.331, maxNrofSSBs */
68 #define MAX_NUM_HARQ_PROC 16 /* spec 38.331, nrofHARQ-ProcessesForPDSCH */
69 #define MAX_NUM_TB_PER_UE 2 /* spec 38.331, maxNrofCodeWordsScheduledByDCI */
72 #define ODU_SELECTOR_LC 0
73 #define ODU_SELECTOR_TC 1
74 #define ODU_SELECTOR_LWLC 2
76 #define ODU_START_CRNTI 100
77 #define ODU_END_CRNTI 500
84 #define MIN_DRB_LCID 4
85 #define MAX_DRB_LCID 32
87 #define FREQ_DOM_RSRC_SIZE 6 /* i.e. 6 bytes because Size of frequency domain resource is 45 bits */
88 #define PUCCH_FORMAT_0 0
89 #define PUCCH_FORMAT_1 1
90 #define PUCCH_FORMAT_2 2
91 #define PUCCH_FORMAT_3 3
92 #define PUCCH_FORMAT_4 4
96 #define BANDWIDTH_20MHZ 20
97 #define BANDWIDTH_100MHZ 100
99 /* PRB allocation as per 38.101, Section 5.3.2 */
100 #define TOTAL_PRB_20MHZ_MU0 106
101 #define TOTAL_PRB_100MHZ_MU1 273
103 #define MAX_NUM_RB TOTAL_PRB_100MHZ_MU1 /* value for numerology 1, 100 MHz */
105 #define MAX_NUM_RB TOTAL_PRB_20MHZ_MU0 /* value for numerology 0, 20 MHz */
108 /*Spec 38.331 Sec 6.4: Maximum number of paging occasion per paging frame*/
109 #define MAX_PO_PER_PF 4
119 /*First SCS in kHz as per 3gpp spec 38.211 Table 4.2-1 */
122 #define MAX_NUM_STATS_GRP 5 /* Max number of statistics group per configuration request */
123 #define MAX_NUM_STATS 10 /* Max number of statistics per group */
125 /* Defining macros for common utility functions */
126 #define ODU_GET_MSG_BUF SGetMsg
127 #define ODU_PUT_MSG_BUF SPutMsg
128 #define ODU_ADD_PRE_MSG_MULT SAddPreMsgMult
129 #define ODU_ADD_PRE_MSG_MULT_IN_ORDER SAddPreMsgMultInOrder
130 #define ODU_ADD_POST_MSG_MULT SAddPstMsgMult
131 #define ODU_START_TASK SStartTask
132 #define ODU_STOP_TASK SStopTask
133 #define ODU_ATTACH_TTSK SAttachTTsk
134 #define ODU_POST_TASK SPstTsk
135 #define ODU_COPY_MSG_TO_FIX_BUF SCpyMsgFix
136 #define ODU_COPY_FIX_BUF_TO_MSG SCpyFixMsg
137 #define ODU_REG_TTSK SRegTTsk
138 #define ODU_SET_PROC_ID SSetProcId
139 #define ODU_GET_MSG_LEN SFndLenMsg
140 #define ODU_EXIT_TASK SExitTsk
141 #define ODU_PRINT_MSG SPrntMsg
142 #define ODU_REM_PRE_MSG SRemPreMsg
143 #define ODU_REM_PRE_MSG_MULT SRemPreMsgMult
144 #define ODU_REM_POST_MSG_MULT SRemPstMsgMult
145 #define ODU_REG_TMR_MT SRegTmrMt
146 #define ODU_SEGMENT_MSG SSegMsg
147 #define ODU_CAT_MSG SCatMsg
148 #define ODU_GET_PROCID SFndProcId
149 #define ODU_SET_THREAD_AFFINITY SSetAffinity
150 #define ODU_CREATE_TASK SCreateSTsk
152 #define MAX_SYMB_PER_SLOT 14
158 /* Maximum slots for max periodicity and highest numerology is 320.
159 * However, aligning to fapi_interface.h, setting this macro to 160.
160 * TODO : To support 160, FAPI_MAX_NUM_TLVS_CONFIG in fapi_interface.h
161 * of Intel L1 must be incremented to a higher number */
162 #define MAX_TDD_PERIODICITY_SLOTS 10
165 #define GET_UE_ID( _crnti,_ueId) \
167 _ueId = _crnti - ODU_START_CRNTI + 1; \
170 #define GET_CRNTI( _crnti, _ueId) \
172 _crnti = _ueId + ODU_START_CRNTI - 1; \
175 /* Calculates cellIdx from cellId */
176 #define GET_CELL_IDX(_cellId, _cellIdx) \
178 _cellIdx = _cellId - 1; \
181 #define SET_BITS_MSB(_startBit, _numBits, _byte) \
183 _byte = (~((0xFF) >> _numBits)); \
184 _byte >>= _startBit; \
187 #define SET_BITS_LSB(_startBit, _numBits, _byte) \
189 _byte = (~((0xFF) << _numBits)); \
190 _byte <<= _startBit; \
193 /* this MACRO set 1 bit at the bit position */
194 #define SET_ONE_BIT(_bitPos, _out) \
196 _out = ((1<<_bitPos) | _out); \
199 /* this MACRO un-set 1 bit at the bit position */
200 #define UNSET_ONE_BIT(_bitPos, _out) \
202 _out = (~(1<<_bitPos) & _out); \
205 /* this MACRO finds the index of the rightmost set bit */
206 #define GET_RIGHT_MOST_SET_BIT( _in,_bitPos) \
208 _bitPos = __builtin_ctz(_in); \
211 /* MACRO for checking CRNTI range*/
212 #define CHECK_CRNTI(_crnti, _isCrntiValid) \
214 _isCrntiValid = ((_crnti >= ODU_START_CRNTI && _crnti <= ODU_END_CRNTI ) ? 1 : 0); \
217 #define CHECK_LCID(_lcId, _isLcidValid) \
219 _isLcidValid = ((_lcId >= SRB0_LCID && _lcId <= MAX_DRB_LCID) ? 1 : 0);\
223 * @def TMR_CALCUATE_WAIT
225 * This macro calculates and assigns wait time based on the value of the
226 * timer and the timer resolution. Timer value of 0 signifies that the
227 * timer is not configured
229 * @param[out] _wait Time for which to arm the timer changed to proper
230 * value according to the resolution
231 * @param[in] _tmrVal Value of the timer
232 * @param[in] _timerRes Resolution of the timer
235 #define TMR_CALCUATE_WAIT(_wait, _tmrVal, _timerRes) \
237 (_wait) = ((_tmrVal) * SS_TICKS_SEC)/((_timerRes) * 1000); \
238 if((0 != (_tmrVal)) && (0 == (_wait))) \
249 RESOURCE_UNAVAILABLE,
332 typedef struct slotTimingInfo
339 typedef struct PlmnIdentity
345 typedef struct snssai
351 typedef struct supportedSliceList
353 uint8_t numSupportedSlices;
357 typedef struct oduCellId
363 typedef struct tddCfg
365 DlUlTxPeriodicity tddPeriod; /*DL UL Transmission periodicity */
366 uint8_t nrOfDlSlots; /*No. of consecultive full DL slots at beginning of DL-UL pattern*/
367 uint8_t nrOfDlSymbols; /*No. of consecultive DL symbol at beginning of slot after last full DL slot*/
368 uint8_t nrOfUlSlots; /*No. of consecutive full UL slots at the end of each DL-UL pattern*/
369 uint8_t nrOfUlSymbols; /*No. of consecutive UL symbols in the end of the slot before the first full UL slot*/
373 typedef struct gConfiguration
377 uint8_t gUeThrptTimeIntervl;
378 uint8_t gSnssaiThrptTimeIntervl;
379 uint8_t gRadioFrameDuration;
380 OduCellStatus gCellStatus;
382 uint64_t gDlDataRcvdCnt; /* Number of DL data received at EGTP */
385 extern GConfiguration gConfigInfo;
387 void fillCoresetFeqDomAllocMap(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain);
388 void oduCpyFixBufToMsg(uint8_t *fixBuf, Buffer *mBuf, uint16_t len);
389 uint8_t buildPlmnId(Plmn plmn, uint8_t *buf);
390 uint16_t convertScsEnumValToScsVal(uint8_t scsEnumValue);
391 uint8_t convertScsValToScsEnum(uint32_t num);
392 uint8_t convertSSBPeriodicityToEnum(uint32_t num);
394 uint8_t SGetSBufNewForDebug(char *file, const char *func, int line, Region region, Pool pool, Data **ptr, Size size);
395 uint8_t SPutSBufNewForDebug(char *file, const char *func, int line, Region region, Pool pool, Data *ptr, Size size);
396 uint8_t SGetStaticBufNewForDebug(char *file, const char *func, int line, \
397 Region region, Pool pool, Data **ptr, Size size, uint8_t memType);
398 uint8_t SPutStaticBufNewForDebug(char *file, const char *func, int line, \
399 Region region, Pool pool, Data *ptr, Size size, uint8_t memType);
400 uint8_t countSetBits(uint32_t num);
401 uint32_t convertArfcnToFreqKhz(uint32_t arfcn);
404 /**********************************************************************
406 ***********************************************************************/