[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-423] Fixes in DU APP to support cell ID other...
[o-du/l2.git] / src / cm / common_def.h
index a144678..aad5bfd 100644 (file)
@@ -15,6 +15,9 @@
 #   limitations under the License.                                             #
 ################################################################################
 *******************************************************************************/
+#ifndef __COMMON_DEF_H__
+#define __COMMON_DEF_H__
+
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdint.h>
 
 #include "cm_mem.h"
-#include "cm_math.h"
 #include "envopt.h"
 #include "envdep.h"
 #include "envind.h"
 #include "gen.h" 
 #include "ssi.h" 
+#include "cm_math.h"
 #include "cm5.h"
 #include "cm_tkns.h"
 #include "cm_mblk.h"
@@ -40,7 +43,6 @@
 #include "cm.h"
 #include "gen.x"           /* general */
 #include "ssi.x"           /* system services */
-#include "cm_math.x"
 #include "cm_tpt.x"
 #include "cm_tkns.x" 
 #include "cm_mblk.x"
 #include "cm_hash.x"
 #include "cm_lte.x"
 #include "cm_lib.x"
+#include "du_log.h"
+
+#define RADIO_FRAME_DURATION 10 /* Time duration of a radio frame in ms */
+/* MAX values */
+#define MAX_NUM_CELL 2 /* Changed to 2 to support cell Id 2 even if there is only one cell in DU */
+#define MAX_NUM_MU   4
+#define MAX_NUM_UE   3
+#define MAX_NUM_UE_PER_TTI 1
+#define MAX_NUM_LC   MAX_DRB_LCID + 1   /*Spec 38.331: Sec 6.4: maxLC-ID Keyword*/
+#define MAX_NUM_SRB  3    /* Max. no of Srbs */
+#define MAX_NUM_DRB  29   /* spec 38.331, maxDRB */
 
 /* 5G ORAN phy delay */
-#define PHY_DELTA 2
+#define PHY_DELTA_DL 1
+#define PHY_DELTA_UL 0
 
  /* SELECTORS */ 
 #define ODU_SELECTOR_LC 0
 #define ODU_SELECTOR_TC 1
 #define ODU_SELECTOR_LWLC 2
 
-#define CRNTI_START_RANGE 100
-#define CRNTI_END_RANGE   500
+#define ODU_START_CRNTI   100
+#define ODU_END_CRNTI     500
+
+/* LCID */
+#define SRB0_LCID  0
+#define SRB1_LCID  1
+#define SRB2_LCID  2
+#define SRB3_LCID  3
+#define MIN_DRB_LCID 4
+#define MAX_DRB_LCID 32
+
+#define FREQ_DOM_RSRC_SIZE  6      /* i.e. 6 bytes because Size of frequency domain resource is 45 bits */
+#define PUCCH_FORMAT_0 0
+#define PUCCH_FORMAT_1 1
+#define PUCCH_FORMAT_2 2
+#define PUCCH_FORMAT_3 3 
+#define PUCCH_FORMAT_4 4
+
+#define DEFAULT_MCS 4
+
+#define BANDWIDTH_20MHZ 20
+#define BANDWIDTH_100MHZ 100
+
+/* PRB allocation as per 38.101, Section 5.3.2 */
+#define TOTAL_PRB_20MHZ_MU0 106
+#define TOTAL_PRB_100MHZ_MU1 273
+#ifdef NR_TDD
+#define MAX_NUM_RB TOTAL_PRB_100MHZ_MU1  /* value for numerology 1, 100 MHz */
+#else
+#define MAX_NUM_RB TOTAL_PRB_20MHZ_MU0 /* value for numerology 0, 20 MHz */
+#endif
+
+#define ODU_UE_THROUGHPUT_PRINT_TIME_INTERVAL      5     /* in milliseconds */
+#define ODU_SNSSAI_THROUGHPUT_PRINT_TIME_INTERVAL  60000 /* in milliseconds */
+
+/*Spec 38.331 Sec 6.4: Maximum number of paging occasion per paging frame*/
+#define MAX_PO_PER_PF 4
+
+/* Defining macros for common utility functions */
+#define ODU_GET_MSG_BUF SGetMsg
+#define ODU_PUT_MSG_BUF SPutMsg
+#define ODU_ADD_PRE_MSG_MULT SAddPreMsgMult
+#define ODU_ADD_PRE_MSG_MULT_IN_ORDER SAddPreMsgMultInOrder
+#define ODU_ADD_POST_MSG_MULT SAddPstMsgMult
+#define ODU_START_TASK SStartTask
+#define ODU_STOP_TASK SStopTask
+#define ODU_ATTACH_TTSK SAttachTTsk
+#define ODU_POST_TASK SPstTsk
+#define ODU_COPY_MSG_TO_FIX_BUF SCpyMsgFix
+#define ODU_COPY_FIX_BUF_TO_MSG SCpyFixMsg
+#define ODU_REG_TTSK SRegTTsk
+#define ODU_SET_PROC_ID SSetProcId
+#define ODU_GET_MSG_LEN SFndLenMsg
+#define ODU_EXIT_TASK SExitTsk
+#define ODU_PRINT_MSG SPrntMsg
+#define ODU_REM_PRE_MSG SRemPreMsg
+#define ODU_REM_PRE_MSG_MULT SRemPreMsgMult
+#define ODU_REG_TMR_MT SRegTmrMt
+#define ODU_SEGMENT_MSG SSegMsg
+#define ODU_CAT_MSG SCatMsg
+#define ODU_GET_PROCID SFndProcId
+#define ODU_SET_THREAD_AFFINITY SSetAffinity
+#define ODU_CREATE_TASK SCreateSTsk
+
+#define MAX_SYMB_PER_SLOT 14 
+
+/* Slice */
+#define SD_SIZE 3
+
+#ifdef NR_TDD
+/* Maximum slots for max periodicity and highest numerology is 320.
+ * However, aligning to fapi_interface.h, setting this macro to 160 */
+#define MAX_TDD_PERIODICITY_SLOTS 160 
+#endif
+
+#define GET_UE_ID( _crnti,_ueId)           \
+{                                          \
+   _ueId = _crnti - ODU_START_CRNTI + 1;  \
+}
+
+#define GET_CRNTI( _crnti, _ueId)          \
+{                                          \
+   _crnti = _ueId + ODU_START_CRNTI - 1;  \
+}
+
+/* Calculates cellIdx from cellId */
+#define GET_CELL_IDX(_cellId, _cellIdx)   \
+{                                         \
+   _cellIdx = _cellId - 1;                \
+}
+
+#define SET_BITS_MSB(_startBit, _numBits, _byte) \
+{                                                \
+   _byte = (~((0xFF) >> _numBits));              \
+       _byte >>= _startBit;                          \
+}
+
+#define SET_BITS_LSB(_startBit, _numBits, _byte) \
+{                                                \
+   _byte = (~((0xFF) << _numBits));              \
+       _byte <<= _startBit;                          \
+}
+
+/* this MACRO set 1 bit at the bit position */
+#define SET_ONE_BIT(_bitPos, _out)            \
+{                                             \
+   _out = ((1<<_bitPos) | _out);              \
+}
+
+/* this MACRO un-set 1 bit at the bit position */
+#define UNSET_ONE_BIT(_bitPos, _out)            \
+{                                               \
+   _out = (~(1<<_bitPos) & _out);               \
+}
+
+/* this MACRO finds the index of the rightmost set bit */
+#define GET_RIGHT_MOST_SET_BIT( _in,_bitPos)        \
+{                                                \
+   _bitPos = __builtin_ctz(_in);                 \
+}
+
+/* MACRO for checking CRNTI range*/
+#define CHECK_CRNTI(_crnti, _isCrntiValid)                                         \
+{                                                                   \
+  _isCrntiValid = ((_crnti >= ODU_START_CRNTI && _crnti <= ODU_END_CRNTI ) ? 1 : 0); \
+}
 
-#define GET_UE_IDX( _crnti,_ueIdx)    \
-{                                                  \
-   _ueIdx = _crnti - CRNTI_START_RANGE;            \
+#define CHECK_LCID(_lcId, _isLcidValid)      \
+{\
+   _isLcidValid = ((_lcId >= SRB0_LCID && _lcId <= MAX_DRB_LCID) ? 1 : 0);\
 }
 
-#define GET_CRNTI( _crnti,_ueIdx)    \
-{                                                  \
-   _crnti = _ueIdx + CRNTI_START_RANGE;            \
+#define GET_PAGING_CYCLE(enmValue, T) {               \
+        if (enmValue == 0) T = 32;                           \
+       else if (enmValue == 1) T = 64;                       \
+       else if (enmValue == 2) T = 128;                      \
+       else if (enmValue == 3) T = 256;                      \
+       else T = 0;                                         \
 }
 
+#define GET_NUM_PAGING_OCC(enmValue, PO) {               \
+        if (enmValue == 0) PO = 4;                            \
+       else if (enmValue == 1) PO = 2;                       \
+       else if (enmValue == 2) PO = 1;                      \
+       else PO = 0;                                         \
+}
+typedef enum
+{
+   UE_CFG_INACTIVE,
+   UE_CFG_INPROGRESS,
+   UE_CREATE_COMPLETE,
+   UE_DELETE_COMPLETE,
+   UE_RECFG_COMPLETE
+}UeCfgState;
+
+typedef enum
+{
+   CONFIG_UNKNOWN,
+   CONFIG_ADD,
+   CONFIG_MOD,
+   CONFIG_DEL
+}ConfigType;
+
+#ifdef NR_TDD
+typedef enum
+{
+   DL_SLOT,
+   UL_SLOT,
+   FLEXI_SLOT
+}SlotConfig;
+
+typedef enum
+{
+   TX_PRDCTY_MS_0P5,
+   TX_PRDCTY_MS_0P625,
+   TX_PRDCTY_MS_1,
+   TX_PRDCTY_MS_1P25,
+   TX_PRDCTY_MS_2,
+   TX_PRDCTY_MS_2P5,
+   TX_PRDCTY_MS_5,
+   TX_PRDCTY_MS_10
+}DlUlTxPeriodicity;
+#endif
+
+typedef enum
+{
+   SCS_15KHZ,
+   SCS_30KHZ,
+   SCS_60KHZ,
+   SCS_120KHZ,
+   SCS_240KHZ
+}SCS;
+
+typedef enum
+{
+   SCS_5MS,
+   SCS_10MS,
+   SCS_20MS,
+   SCS_40MS,
+   SCS_80MS,
+   SCS_160MS
+}ScsPeriodicity;
+
+typedef enum
+{
+   CELL_UP,
+   CELL_DOWN
+}OduCellStatus;
+
+
+typedef enum
+{
+   DIR_NONE,
+   DIR_UL,
+   DIR_DL,
+   DIR_BOTH
+}Direction;
+
+typedef struct slotTimingInfo
+{
+   uint16_t cellId;
+   uint16_t sfn;
+   uint16_t slot;
+}SlotTimingInfo;
+
+typedef struct PlmnIdentity
+{
+   uint8_t mcc[3];
+   uint8_t mnc[3];
+}Plmn;
+
+typedef struct snssai
+{
+   uint8_t   sst;
+   uint8_t   sd[SD_SIZE];
+}Snssai;
+
+typedef struct oduCellId
+{
+   uint16_t cellId;
+}OduCellId;
+
+#ifdef NR_TDD
+typedef struct tddCfg
+{
+   bool               pres;
+   DlUlTxPeriodicity  tddPeriod;      /* DL UL Transmission periodicity */
+   SlotConfig         slotCfg[MAX_TDD_PERIODICITY_SLOTS][MAX_SYMB_PER_SLOT]; 
+}TDDCfg;
+#endif
+
+OduCellStatus gCellStatus;
+uint64_t gSlotCount;
+uint64_t gDlDataRcvdCnt;   /* Number of DL data received at EGTP */
+
+void fillCoresetFeqDomAllocMap(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain);
+void oduCpyFixBufToMsg(uint8_t *fixBuf, Buffer *mBuf, uint16_t len);
+uint8_t buildPlmnId(Plmn plmn, uint8_t *buf);
+uint16_t convertScsEnumValToScsVal(uint8_t scsEnumValue);
+
+uint8_t SGetSBufNewForDebug(char *file, char *func, char *line, Region region, Pool pool, Data **ptr, Size size);
+uint8_t SPutSBufNewForDebug(char *file, char *func, char *line, Region region, Pool pool, Data *ptr, Size size);
+uint8_t SGetStaticBufNewForDebug(char *file, char *func, char *line, \
+Region region, Pool pool, Data **ptr, Size size, uint8_t memType);
+uint8_t SPutStaticBufNewForDebug(char *file, char *func, char *line, \
+Region region, Pool pool, Data *ptr, Size size, uint8_t memType);
+uint8_t countSetBits(uint32_t num);
+
+#endif
+
 /**********************************************************************
-         End of file
-**********************************************************************/
+  End of file
+***********************************************************************/