[Epic-ID: ODUHIGH-402][Task-ID: ODUHIGH-418] Harq feature changes
[o-du/l2.git] / src / 5gnrmac / mac.h
index 5630501..6115c67 100644 (file)
 #define MAC_LCID_CRI               62
 #define MAC_LCID_PADDING           63
 
+/* Definitions for size of RAR PDU contents (in bits).
+ * Refer spec 38.321, sections 6.1.4, 6.2.2 and 6.2.3*/
+#define E_BIT_SIZE 1
+#define T_BIT_SIZE 1
+#define R_BIT_SIZE 1
+#define RAPID_SIZE 6
+#define LC_ID_SIZE 6
+#define TIMING_ADVANCE_SIZE 12
+#define T_CRNTI_SIZE 16
+/*  UL Grant is of size = 27 bits. Refer to Spec 38.213, Table 8.2-1 for
+ *  contents of UL grant in RAR */
+#define FREQ_HOP_FLAG_SIZE 1
+#define FREQ_RSRC_ALLOC_SIZE 14
+#define TIME_RSRC_ALLOC_SIZE 4
+#define MCS_SIZE 4
+#define TPC_COMMAND_SIZE 3
+#define CSI_REQUEST_SIZE 1
+
 typedef struct macCellCb MacCellCb;
 
 typedef enum
 {
    CELL_STATE_UP,
-   CELL_STATE_DELETION_IN_PROGRESS,
-   CELL_STATE_DOWN
+   CELL_TO_BE_STOPPED,
+   CELL_STOP_IN_PROGRESS,
 }CellState;       
 
 typedef enum
 {
    UE_STATE_INACTIVE,
-   UE_STATE_ACTIVE
+   UE_STATE_ACTIVE,
+   UE_HANDIN_IN_PROGRESS
 }UeState;
 
 typedef enum
@@ -71,9 +90,25 @@ typedef enum
    MAC_LC_STATE_ACTIVE
 }MacLcState;
 
+typedef struct dlTbInfo
+{
+   SlotTimingInfo  txTime;  
+   uint16_t        tbSize;
+   uint8_t         *tb;
+}DlTbInfo;
+
+/* DL HARQ Process Info */
+typedef struct dlHarqProcCb
+{
+   uint8_t     procId;                 /* HARQ Process Id */
+   uint8_t     numTb;                  /* Number of TB */
+   DlTbInfo    tbInfo[MAX_NUM_TB_PER_UE];  /* TB information */
+}DlHarqProcCb;
+
 typedef struct macDlSlot
 {
    DlSchedInfo dlInfo;
+   DlPageAlloc *pageAllocInfo;
 }MacDlSlot;
 
 typedef struct macUlSlot
@@ -88,8 +123,7 @@ typedef struct macCbInfo
    uint8_t     msg3Pdu[6];  /* used as CRI value during muxing */
    uint8_t     *msg4Pdu;    /* storing DL-CCCH Ind Pdu */
    uint16_t    msg4PduLen;  /* storing DL-CCCH Ind Pdu Len */
-   uint8_t     *msg4TxPdu;  /* muxed Pdu used for re-transmission */
-   uint16_t    msg4TbSize;  /* size required for msg4TxPdu */
+   DlHarqProcCb msg4HqInfo; /* HARQ process info for msg 4 */
 }MacRaCbInfo;
 
 typedef struct macCe
@@ -113,16 +147,11 @@ typedef struct macDlInfo
 
 typedef struct macDlData
 {
+   uint8_t  ueId;
    uint16_t numPdu;
    MacDlInfo  pduInfo[MAX_MAC_DL_PDU];
 }MacDlData;
 
-/* HARQ Process Info */
-typedef struct dlHarqProcCb
-{
-   uint8_t   procId;    /* HARQ Process Id */
-}DlHarqProcCb;
-
 /* DL HARQ entity */
 typedef struct dlHarqEnt
 {
@@ -134,16 +163,28 @@ typedef struct dlHarqEnt
 /* Uplink deidcated logical channel info */
 typedef struct ulLcCb
 {
-   uint8_t   lcId;      /* Logical Channel Id */
-   uint8_t   lcGrpId;   /* Logical Channel group */
-   MacLcState lcActive;  /* Is LC active ? */
+   uint8_t    lcId;         /* Logical Channel Id */
+   uint8_t    lcGrpId;      /* Logical Channel group */
+   MacLcState lcActive;     /* Is LC active ? */
+   /*Commenting as S-NSSAI and PDU session will be used in future scope*/
+   /*For eg: When we have to send these for AMBR cases*/
+   #if 0
+   uint16_t   pduSessionId; /*Pdu Session Id*/
+   Snssai     *snssai;      /*S-NSSAI assoc with LCID*/
+   #endif
 }UlLcCb;
 
 /* Downlink dedicated logical channel info */
 typedef struct dlLcCb
 {
-   uint8_t   lcId;      /* Logical channel Id */ 
-   MacLcState   lcState;  /* Is LC active ? */
+   uint8_t    lcId;        /* Logical channel Id */ 
+   MacLcState lcState;     /* Is LC active ? */
+   /*Commenting as S-NSSAI and PDU session will be used in future scope*/
+   /*For eg: When we have to send these info via FAPI to phy layer*/
+   #if 0
+   uint16_t   pduSessionId;/*Pdu Session Id*/
+   Snssai     *snssai;    /*S-NSSAI assoc with LCID*/
+   #endif
 }DlLcCb;
 
 /* BSR Information */
@@ -173,21 +214,23 @@ typedef struct ueDlCb
 /* UE Cb */
 typedef struct macUeCb
 {
-   uint16_t     ueIdx;    /* UE Idx assigned by DU APP */
-   uint16_t     crnti;    /* UE CRNTI */
-   MacCellCb    *cellCb;  /* Pointer to cellCb to whihc this UE belongs */
-   UeState      state;    /* Is UE active ? */
-   MacRaCbInfo  *raCb;    /* RA info */
-   MacBsrTmrCfg bsrTmrCfg;  /* BSR Timer Info */
-   UeUlCb       ulInfo;   /* UE specific UL info */
-   UeDlCb       dlInfo;   /* UE specific DL info */
+   uint16_t         ueId;           /* UE Id from DU APP */
+   uint16_t         crnti;          /* UE CRNTI */
+   MacCellCb        *cellCb;        /* Pointer to cellCb to whihc this UE belongs */
+   UeState          state;          /* Is UE active ? */
+   MacCfraResource  cfraResource;   /* CF-RA resource */
+   MacRaCbInfo      *raCb;          /* RA info */
+   MacBsrTmrCfg     bsrTmrCfg;      /* BSR Timer Info */
+   UeUlCb           ulInfo;         /* UE specific UL info */
+   UeDlCb           dlInfo;         /* UE specific DL info */
+   DataTransmissionAction transmissionAction;
 }MacUeCb;
 
 struct macCellCb
 {
    uint16_t    cellId;
    CellState   state;
-   uint8_t     crntiMap;
+   uint16_t    crntiMap;
    MacRaCbInfo macRaCb[MAX_NUM_UE];
    MacDlSlot   dlSlot[MAX_SLOTS];
    MacUlSlot   ulSlot[MAX_SLOTS];
@@ -195,18 +238,18 @@ struct macCellCb
    MacUeCfg    *ueCfgTmpData[MAX_NUM_UE];
    MacUeCb     ueCb[MAX_NUM_UE];
    MacCellCfg  macCellCfg;
-   SlotIndInfo currTime;
+   SlotTimingInfo currTime;
 };
 
 typedef struct macCb
 {
-   Inst       macInst;
-   ProcId     procId;
-   uint8_t    tmrRes;                    /*!< Timer resolution */
-   CmTqCp     tmrTqCp;                   /*!< Timer Task Queue Cntrl Point */
-   CmTqType   tmrTq[MAC_TQ_SIZE];        /*!< Timer Task Queue */
-   CmTimer    tmrBlk[MAX_NUM_TIMER];     /*!< Timer Block */
-   MacCellCb  *macCell[MAX_NUM_CELL];
+   Inst        macInst;
+   ProcId      procId;
+   uint8_t     tmrRes;                    /*!< Timer resolution */
+   CmTqCp      tmrTqCp;                   /*!< Timer Task Queue Cntrl Point */
+   CmTqType    tmrTq[MAC_TQ_SIZE];        /*!< Timer Task Queue */
+   CmTimer     tmrBlk[MAX_NUM_TIMER];     /*!< Timer Block */
+   MacCellCb   *macCell[MAX_NUM_CELL];
 }MacCb;
 
 /* global variable */
@@ -215,18 +258,20 @@ MacCb macCb;
 /* Function declarations */
 short int macActvTmr(Ent ent,Inst inst);
 void fillRarPdu(RarInfo *rarInfo);
-void createMacRaCb(RachIndInfo *rachIndInfo);
 void fillMsg4DlData(MacDlData *dlData, uint16_t msg4PduLen, uint8_t *msg4Pdu);
 void fillMacCe(MacCeInfo  *macCeData, uint8_t *msg3Pdu);
 void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize);
-uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxDataIndPdu);
+uint8_t unpackRxData(uint16_t cellId, SlotTimingInfo slotInfo, RxDataIndPdu *rxDataIndPdu);
 void fillMg4Pdu(DlMsgAlloc *msg4Alloc);
-void buildAndSendMuxPdu(SlotIndInfo currTimingInfo);
+void buildAndSendMuxPdu(SlotTimingInfo currTimingInfo);
 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer);
 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize);
-uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotIndInfo slotInfo, \
+uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotTimingInfo slotInfo, \
    uint8_t lcId, uint16_t pduLen, uint8_t *pdu);
-uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotIndInfo slotInfo);
+uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx);
+uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
+                         DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS]);
+void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst);
 #endif
 /**********************************************************************
   End of file