Merge "Revert "[Epic-ID: ODUHIGH-462][Task-ID: ODUHIGH-472] Implementation of drx...
[o-du/l2.git] / src / cm / du_app_mac_inf.h
index a10e2aa..8df0b10 100644 (file)
 #define EVENT_MAC_SLICE_CFG_RSP      217
 #define EVENT_MAC_SLICE_RECFG_REQ    218
 #define EVENT_MAC_SLICE_RECFG_RSP    219
+#define EVENT_MAC_SLOT_IND           220
+#define EVENT_MAC_RACH_RESOURCE_REQ  221
+#define EVENT_MAC_RACH_RESOURCE_RSP  222
+#define EVENT_MAC_RACH_RESOURCE_REL  223
+#define EVENT_MAC_DL_PCCH_IND        224
 
 #define BSR_PERIODIC_TIMER_SF_10 10
 #define BSR_RETX_TIMER_SF_320 320
 #define BSR_SR_DELAY_TMR_2560 2560
 
+#define PAGING_SCHED_DELTA  4
+
 typedef enum
 {
    MAC_DU_APP_RSP_NOK,
@@ -98,9 +105,9 @@ typedef enum
 
 typedef enum
 {
-   SUCCESS,
+   DEL_SUCCESSFUL,
    CELLID_INVALID,
-   UEIDX_INVALID
+   UEID_INVALID
 }UeDeleteStatus;
 
 typedef enum
@@ -503,6 +510,13 @@ typedef enum
    RSRC_RRC_CONNECTED_USERS
 }ResourceType;
 
+typedef enum
+{
+   TRANSMISSION_ALLOWED,
+   STOP_TRANSMISSION,
+   RESTART_TRANSMISSION
+}DataTransmissionAction;
+
 typedef struct failureCause
 {
    CauseGrp   type;
@@ -562,7 +576,9 @@ typedef struct prachCfg
    uint8_t       msg1Fdm;             /* PRACH FDM (1,2,4,8) */
    uint8_t       rootSeqLen;          /* Root sequence length */
    PrachFdmInfo  fdm[8];              /* FDM info */
+   uint8_t       totalNumRaPreamble;  /* Total number of RA preambles */
    uint8_t       ssbPerRach;          /* SSB per RACH occassion */
+   uint8_t       numCbPreamblePerSsb; /* Number of CB preamble per SSB */
    bool          prachMultCarrBand;   /* Multiple carriers in Band */
    uint8_t       prachRestrictedSet; /* Support for PRACH restricted set */
    uint8_t       raContResTmr;        /* RA Contention Resoultion Timer */
@@ -570,6 +586,13 @@ typedef struct prachCfg
    uint8_t       raRspWindow;         /* RA Response Window */
 }PrachCfg;
 
+typedef struct schPageCfg
+{
+  uint8_t  numPO;                    /*Derived from Ns*/
+  bool     poPresent;                /*Whether FirstPDCCH-MonitoringPO is present or not*/
+  uint16_t pagingOcc[MAX_PO_PER_PF]; /*FirstPDCCH-Monitoring Paging Occasion*/
+}SchPageCfg;
+
 typedef struct sib1CellCfg
 {
    uint8_t  *sib1Pdu;
@@ -578,6 +601,7 @@ typedef struct sib1CellCfg
    uint8_t coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
    uint8_t searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
    uint16_t sib1Mcs;
+   SchPageCfg  pagingCfg;
 } Sib1CellCfg; 
 
 typedef struct bwpParams
@@ -675,6 +699,45 @@ typedef struct plmnInfoList
    Snssai         **snssai;         /* List of supporting snssai*/
 }PlmnInfoList;
 
+#ifdef NR_DRX
+/* The following list of structures is taken from the DRX-Config section of specification 33.331. */
+typedef struct drxOnDurationTimer
+{
+   bool  onDurationTimerValInMs;
+   union
+   {
+      uint8_t  subMilliSeconds;
+      uint16_t milliSeconds;
+   }onDurationtimerValue;
+}DrxOnDurationTimer;
+
+typedef struct drxLongCycleStartOffset
+{
+   uint16_t drxLongCycleStartOffsetChoice;
+   uint16_t drxLongCycleStartOffsetVal;
+}DrxLongCycleStartOffset;
+
+typedef struct shortDrx
+{
+   uint16_t   drxShortCycle;
+   uint8_t    drxShortCycleTimer;
+}ShortDrx;
+
+typedef struct drxCfg
+{
+   DrxOnDurationTimer       drxOnDurationTimer;   
+   uint16_t                 drxInactivityTimer;
+   uint8_t                  drxHarqRttTimerDl;
+   uint8_t                  drxHarqRttTimerUl;
+   uint16_t                 drxRetransmissionTimerDl;
+   uint16_t                 drxRetransmissionTimerUl;
+   DrxLongCycleStartOffset  drxLongCycleStartOffset;
+   bool                     shortDrxPres;
+   ShortDrx                 shortDrx;
+   uint8_t                  drxSlotOffset;
+}DrxCfg;
+#endif
+
 typedef struct macCellCfg
 {
    uint16_t       cellId;           /* Cell Id */
@@ -779,6 +842,9 @@ typedef struct macCellGrpCfg
    BsrTmrCfg   bsrTmrCfg;
    bool        phrCfgSetupPres;   /* true/false: phrCfgSetup/phrCfgRelease */
    PhrCfg      phrCfg;
+#ifdef NR_DRX
+   DrxCfg      drxCfg;
+#endif
 }MacCellGrpCfg;
 
 typedef struct phyCellGrpCfg
@@ -975,8 +1041,8 @@ typedef struct pucchResrcCfg
 
 typedef struct pucchFormatCfg
 {
-   uint8_t interSlotFreqHop;
-   uint8_t addDmrs;
+   bool interSlotFreqHop;
+   bool addDmrs;
    uint8_t maxCodeRate;
    uint8_t numSlots;
    bool    pi2BPSK;
@@ -1219,7 +1285,7 @@ typedef struct modulationInfo
 typedef struct macUeCfg
 {
    uint16_t cellId;
-   uint8_t  ueIdx;
+   uint8_t  ueId;
    uint16_t crnti;
    bool macCellGrpCfgPres;
    MacCellGrpCfg macCellGrpCfg;
@@ -1233,6 +1299,7 @@ typedef struct macUeCfg
    uint8_t numLcs;
    LcCfg lcCfgList[MAX_NUM_LC];
    UeCfgState macUeCfgState;    /* InActive / Completed */
+   DataTransmissionAction transmissionAction;
 }MacUeCfg;
 
 typedef struct nrcgi
@@ -1262,7 +1329,7 @@ typedef struct sCellFailInfo
 typedef struct ueCfgRsp
 {
    uint16_t       cellId;
-   uint16_t       ueIdx;
+   uint16_t       ueId;
    MacRsp         result;
    uint8_t        numSRBFailed;   /* valid values : 0 to MAX_NUM_SRB */ 
    SRBFailInfo    *failedSRBlisti;
@@ -1272,6 +1339,42 @@ typedef struct ueCfgRsp
    SCellFailInfo  *failedSCellList;
 }MacUeCfgRsp;
 
+typedef struct rachRsrcReq
+{
+   uint16_t cellId;
+   uint16_t ueId;
+   uint8_t  numSsb;
+   uint8_t  ssbIdx[MAX_NUM_SSB];
+}MacRachRsrcReq;
+
+typedef struct macCfraSsbResource
+{
+   uint8_t  ssbIdx;
+   uint8_t  raPreambleIdx;
+}MacCfraSsbResource;
+
+typedef struct macCfraResource
+{
+   uint8_t   numSsb;
+   MacCfraSsbResource ssbResource[MAX_NUM_SSB];
+}MacCfraResource;
+
+typedef struct macRachRsrcRsp
+{
+   uint16_t   cellId;
+   uint16_t   ueId;
+   MacRsp     result;
+   uint16_t   newCrnti;     /* This parameter maps to 3GPP TS 38.331 newUE-Identity */
+   MacCfraResource  cfraResource;
+}MacRachRsrcRsp;
+
+typedef struct macRachRsrcRel
+{
+   uint16_t cellId;
+   uint16_t ueId;
+   uint16_t crnti;
+}MacRachRsrcRel;
+
 typedef struct ueDelete
 {
     uint16_t cellId;
@@ -1286,10 +1389,10 @@ typedef struct ueDeleteRsp
    UeDeleteStatus result;
 }MacUeDeleteRsp;
 
-typedef struct macCellDelete
+typedef struct macCellDeleteReq
 {
    uint16_t cellId;
-}MacCellDelete;
+}MacCellDeleteReq;
 
 typedef struct macCellDeleteRsp
 {
@@ -1329,11 +1432,38 @@ typedef struct macSliceCfgRsp
    MacSliceRsp  **listOfSliceCfgRsp;
 }MacSliceCfgRsp;
 
-/* Functions for slot Ind from MAC to DU APP*/
+/*As per ORAN-WG8, Slice Cfg and ReCfg are same structures*/
+typedef struct macSliceCfgReq MacSliceRecfgReq;
+typedef struct macSliceCfgRsp MacSliceRecfgRsp;
+
+typedef struct dlPcchInd
+{
+   uint16_t  cellId;
+   uint16_t  pf;
+   uint8_t   i_s;
+   uint16_t  pduLen;
+   uint8_t  *pcchPdu;
+}DlPcchInd;
+
+typedef struct cellInfo
+{
+    SlotTimingInfo slotInfo;
+    uint16_t       cellId;
+}CellInfo;
+
+typedef struct cellInfo CellStartInfo;
+typedef struct cellInfo CellStopInfo;
+
+/* Functions for CellUp Ind from MAC to DU APP*/
 typedef uint8_t (*DuMacCellUpInd) ARGS((
         Pst       *pst,
         OduCellId *cellId ));
 
+/* Functions for slot Ind from MAC to DU APP*/
+typedef uint8_t (*DuMacSlotInd) ARGS((
+        Pst       *pst,
+        SlotTimingInfo *slotIndInfo));
+
 /* Functions for stop Ind from MAC to DU APP*/
 typedef uint8_t (*DuMacStopInd) ARGS((
         Pst        *pst,
@@ -1342,12 +1472,12 @@ typedef uint8_t (*DuMacStopInd) ARGS((
 /* Functions for mac cell start req */
 typedef uint8_t (*DuMacCellStart) ARGS((
         Pst        *pst, 
-        OduCellId  *cellId));
+        CellStartInfo  *cellId));
 
 /* Functions for mac cell stop request */
 typedef uint8_t (*DuMacCellStop) ARGS((
         Pst        *pst,
-        OduCellId  *cellId ));
+        CellStopInfo  *cellId ));
 
 /* Function pointers for packing macCellCfg Request and Confirm */
 typedef uint8_t (*packMacCellCfgReq) ARGS((
@@ -1386,11 +1516,26 @@ typedef uint8_t (*MacDuUeCfgRspFunc) ARGS((
         Pst           *pst, 
         MacUeCfgRsp   *cfgRsp));
 
-/* UE Reconfig Request from DU APP to MAC*/
+/* UE Reconfig Request from DU APP to MAC */
 typedef uint8_t (*DuMacUeReconfigReq) ARGS((
         Pst           *pst,
         MacUeCfg      *ueCfg ));
 
+/* RACH Resource Request from DU APP to MAC */
+typedef uint8_t (*DuMacRachRsrcReq) ARGS((
+    Pst            *pst,
+    MacRachRsrcReq *rachRsrcReq));
+
+/* RACH Resource Response from MAC to DU APP */
+typedef uint8_t (*MacDuRachRsrcRspFunc) ARGS((
+    Pst            *pst,
+    MacRachRsrcRsp *rachRsrcRsp));
+
+/* RACH Resource Release from DU APP to MAC */
+typedef uint8_t (*DuMacRachRsrcRel) ARGS((
+    Pst            *pst,
+    MacRachRsrcRel *rachRsrcRel));
+
 /* UE Delete Request from DU APP to MAC*/
 typedef uint8_t (*DuMacUeDeleteReq) ARGS((
      Pst           *pst,
@@ -1404,7 +1549,7 @@ typedef uint8_t (*MacDuUeDeleteRspFunc) ARGS((
 /* Cell Delete Request from DU APP to MAC*/
 typedef uint8_t (*DuMacCellDeleteReq) ARGS((
      Pst           *pst,
-     MacCellDelete *cellDelete ));
+     MacCellDeleteReq *cellDelete ));
 
 /* Cell Delete Response from MAC to DU APP*/
 typedef uint8_t (*MacDuCellDeleteRspFunc) ARGS((
@@ -1424,23 +1569,29 @@ typedef uint8_t (*MacDuSliceCfgRspFunc) ARGS((
 /* Slice ReReCfg Request from DU APP to MAC*/
 typedef uint8_t (*DuMacSliceRecfgReq) ARGS((
      Pst           *pst,
-     MacSliceCfgReq *CfgReq));
+     MacSliceRecfgReq *CfgReq));
 
 /* Slice ReReCfg Response from MAC to DU APP */
-typedef uint8_t (*MacDuSliceReCfgRspFunc) ARGS((
+typedef uint8_t (*MacDuSliceRecfgRspFunc) ARGS((
         Pst           *pst,
-        MacSliceCfgRsp   *cfgRsp));
+        MacSliceRecfgRsp   *cfgRsp));
 
+/* Pcch indication from DU APP to MAC*/
+typedef uint8_t (*DuMacDlPcchInd) ARGS((
+     Pst        *pst,
+     DlPcchInd *pcchInd));
+
+uint64_t ueBitMapPerCell[MAX_NUM_CELL]; /* Bit Map to store used/free UE-IDX per Cell */
 
 uint8_t packMacCellUpInd(Pst *pst, OduCellId *cellId);
 uint8_t unpackMacCellUpInd(DuMacCellUpInd func, Pst *pst, Buffer *mBuf);
 uint8_t duHandleCellUpInd(Pst *pst, OduCellId *cellId);
-uint8_t packMacCellStart(Pst *pst, OduCellId *cellId);
+uint8_t packMacCellStart(Pst *pst, CellStartInfo *cellStartInfo);
 uint8_t unpackMacCellStart(DuMacCellStart func, Pst *pst, Buffer *mBuf);
-uint8_t MacProcCellStart(Pst *pst, OduCellId *cellId);
-uint8_t packMacCellStop(Pst *pst, OduCellId *cellId);
+uint8_t MacProcCellStart(Pst *pst, CellStartInfo *cellStartInfo);
+uint8_t packMacCellStop(Pst *pst, CellStopInfo *cellStopInfo);
 uint8_t unpackMacCellStop(DuMacCellStop func, Pst *pst, Buffer *mBuf);
-uint8_t MacProcCellStop(Pst *pst, OduCellId *cellId);
+uint8_t MacProcCellStop(Pst *pst, CellStopInfo *cellStopInfo);
 uint8_t packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg);
 uint8_t unpackDuMacCellCfg(DuMacCellCfgReq func,  Pst *pst,  Buffer *mBuf);
 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
@@ -1466,14 +1617,23 @@ uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp);
 uint8_t packDuMacUeReconfigReq(Pst *pst, MacUeCfg *ueCfg);
 uint8_t unpackMacUeReconfigReq(DuMacUeReconfigReq func, Pst *pst, Buffer *mBuf);
 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg);
+uint8_t packDuMacRachRsrcReq(Pst *pst, MacRachRsrcReq *rachRsrcReq);
+uint8_t unpackMacRachRsrcReq(DuMacRachRsrcReq func, Pst *pst, Buffer *mBuf);
+uint8_t MacProcRachRsrcReq(Pst *pst, MacRachRsrcReq *rachRsrcReq);
+uint8_t packDuMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp);
+uint8_t unpackDuMacRachRsrcRsp(MacDuRachRsrcRspFunc func, Pst *pst, Buffer *mBuf);
+uint8_t DuProcMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp);
+uint8_t packDuMacRachRsrcRel(Pst *pst, MacRachRsrcRel *rachRsrcRel);
+uint8_t unpackMacRachRsrcRel(DuMacRachRsrcRel func, Pst *pst, Buffer *mBuf);
+uint8_t MacProcRachRsrcRel(Pst *pst, MacRachRsrcRel *rachRsrcRel);
 uint8_t packDuMacUeDeleteReq(Pst *pst, MacUeDelete *ueDelete);
 uint8_t MacProcUeDeleteReq(Pst *pst,  MacUeDelete *ueDelete);
 uint8_t unpackMacUeDeleteReq(DuMacUeDeleteReq func, Pst *pst, Buffer *mBuf);
 uint8_t packDuMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp);
 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp);
 uint8_t unpackDuMacUeDeleteRsp(MacDuUeDeleteRspFunc func, Pst *pst, Buffer *mBuf);
-uint8_t packDuMacCellDeleteReq(Pst *pst, MacCellDelete *cellDelete);
-uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete);
+uint8_t packDuMacCellDeleteReq(Pst *pst, MacCellDeleteReq *cellDelete);
+uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDeleteReq *cellDelete);
 uint8_t unpackMacCellDeleteReq(DuMacCellDeleteReq func, Pst *pst, Buffer *mBuf);
 uint8_t packDuMacCellDeleteRsp(Pst *pst, MacCellDeleteRsp *cellDeleteRsp);
 uint8_t DuProcMacCellDeleteRsp(Pst *pst, MacCellDeleteRsp *cellDeleteRsp);
@@ -1484,13 +1644,20 @@ uint8_t unpackMacSliceCfgReq(DuMacSliceCfgReq func, Pst *pst, Buffer *mBuf);
 uint8_t DuProcMacSliceCfgRsp(Pst *pst,  MacSliceCfgRsp *cfgRsp);
 uint8_t packDuMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp);
 uint8_t unpackDuMacSliceCfgRsp(MacDuSliceCfgRspFunc func, Pst *pst, Buffer *mBuf);
-uint8_t packDuMacSliceRecfgReq(Pst *pst, MacSliceCfgReq *sliceReCfgReq);
-uint8_t MacProcSliceReCfgReq(Pst *pst, MacSliceCfgReq *sliceReCfgReq);
-uint8_t unpackMacSliceReCfgReq(DuMacSliceRecfgReq func, Pst *pst, Buffer *mBuf);
-uint8_t DuProcMacSliceReCfgRsp(Pst *pst,  MacSliceCfgRsp *cfgRsp);
-uint8_t packDuMacSliceReCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp);
-uint8_t unpackDuMacSliceReCfgRsp(MacDuSliceReCfgRspFunc func, Pst *pst, Buffer *mBuf);
-
+uint8_t packDuMacSliceRecfgReq(Pst *pst, MacSliceRecfgReq *sliceRecfgReq);
+uint8_t MacProcSliceRecfgReq(Pst *pst, MacSliceRecfgReq *sliceRecfgReq);
+uint8_t unpackMacSliceRecfgReq(DuMacSliceRecfgReq func, Pst *pst, Buffer *mBuf);
+uint8_t DuProcMacSliceRecfgRsp(Pst *pst,  MacSliceRecfgRsp *sliceRecfgRsp);
+uint8_t packDuMacSliceRecfgRsp(Pst *pst, MacSliceRecfgRsp *sliceRecfgRsp);
+uint8_t unpackDuMacSliceRecfgRsp(MacDuSliceRecfgRspFunc func, Pst *pst, Buffer *mBuf);
+uint8_t duHandleSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo);
+uint8_t packMacSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo);
+uint8_t unpackDuMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf);
+uint8_t packDuMacDlPcchInd(Pst *pst, DlPcchInd *pcchInd);
+uint8_t MacProcDlPcchInd(Pst *pst, DlPcchInd *pcchInd);
+uint8_t unpackMacDlPcchInd(DuMacDlPcchInd func, Pst *pst, Buffer *mBuf);
+int8_t getFreeBitFromUeBitMap(uint16_t cellId);
+void unsetBitInUeBitMap(uint16_t cellId, uint8_t bitPos);
 #endif