RLC BO, BO response and DL Data handling. [Issue-ID: ODUHIGH-181]
[o-du/l2.git] / src / du_app / du_mgr_ex_ms.c
index 31a4b1d..76fabd6 100644 (file)
 #   See the License for the specific language governing permissions and        #
 #   limitations under the License.                                             #
 ################################################################################
-*******************************************************************************/
+ *******************************************************************************/
 
 /* This file contains message handling functionality for DU APP */
-
-#include "du_sctp.h"
-#include "du_f1ap_msg_hdl.h"
+#include "common_def.h"
+#include "lrg.h"
+#include "legtp.h"
 #include "lsctp.h"
 #include "legtp.h"
+#include "lkw.h"
+#include "kwu.h"
+#include "lrg.x"
+#include "lkw.x"
+#include "kwu.x"
 #include "du_app_mac_inf.h"
+#include "du_app_rlc_inf.h"
+#include "du_cfg.h"
+#include "du_mgr.h"
+#include "E2AP-PDU.h"
+#include "du_sctp.h"
+#include "F1AP-PDU.h"
+#include "du_f1ap_msg_hdl.h"
+#include "du_e2ap_msg_hdl.h"
+#include "du_app_mac_inf.h"
+#include "du_ue_mgr.h"
+#include "du_utils.h"
 
-extern S16 cmUnpkLkwCfgCfm(LkwCfgCfm func,Pst *pst, Buffer *mBuf);
-extern S16 cmUnpkLkwCntrlCfm(LkwCntrlCfm func,Pst *pst, Buffer *mBuf);
-extern S16 cmUnpkLrgCfgCfm(LrgCfgCfm func,Pst *pst, Buffer *mBuf);
-
+extern uint8_t unpackRlcConfigCfm(RlcConfigCfm func,Pst *pst, Buffer *mBuf);
+extern uint8_t cmUnpkLkwCntrlCfm(LkwCntrlCfm func,Pst *pst, Buffer *mBuf);
+extern uint8_t cmUnpkLrgCfgCfm(LrgCfgCfm func,Pst *pst, Buffer *mBuf);
+extern uint8_t cmUnpkKwuDatInd(KwuDatInd func,Pst *pst, Buffer *mBuf);
+extern uint8_t cmUnpkLrgSchCfgCfm(LrgSchCfgCfm func,Pst *pst,Buffer *mBuf);
 /**************************************************************************
  * @brief Task Initiation callback function. 
  *
@@ -48,9 +65,13 @@ extern S16 cmUnpkLrgCfgCfm(LrgCfgCfm func,Pst *pst, Buffer *mBuf);
  * @return ROK     - success
  *         RFAILED - failure
  ***************************************************************************/
-S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason)
+uint8_t duActvInit(Ent entity, Inst inst, Region region, Reason reason)
 {
-   duCb.init.procId  = SFndProcId();
+   uint8_t id;
+
+   memset(&duCb, 0, sizeof(DuCb));
+
+   duCb.init.procId  = ODU_GET_PROCID();
    duCb.init.ent     = entity;
    duCb.init.inst    = inst;
    duCb.init.region  = region;
@@ -64,30 +85,19 @@ S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason)
    duCb.mem.pool     = DU_POOL;
 
    duCb.f1Status     = FALSE;
+   duCb.e2Status     = FALSE;
 
-   if(ROK != cmHashListInit(&(duCb.cellLst), 
-            (U16) DU_MAX_CELLS,
-            (U16) 0,
-            (Bool) FALSE, 
-            (U16) CM_HASH_KEYTYPE_CONID,
-            0,   
-            0))
-   {
-      DU_LOG("\nDU_APP : cellLst Initialization Failed");
-   }
-
-   if(ROK != cmHashListInit(&(duCb.actvCellLst), 
-            (U16) DU_MAX_CELLS,
-            (U16) 0,
-            (Bool) FALSE, 
-            (U16) CM_HASH_KEYTYPE_CONID,
-            0,   
-            0))
+   for(id = 0; id < MAX_NUM_CELL; id ++)
    {
-      DU_LOG("\nDU_APP : ActvCellLst Initialization Failed");
+      duCb.cfgCellLst[id] = NULL;
+      duCb.actvCellLst[id] = NULL;
    }
+   duCb.numUe = 0;
+   memset(duCb.ueCcchCtxt, 0, MAX_NUM_UE * sizeof(UeCcchCtxt));
+   duCb.numCfgCells  = 0;
+   duCb.numActvCells = 0;
 
-   SSetProcId(DU_PROC);
+   ODU_SET_PROC_ID(DU_PROC);
 
    return ROK;
 
@@ -113,164 +123,205 @@ S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason)
  *         RFAILED - failure
  *
  ***************************************************************************/
-S16 duActvTsk(Pst *pst, Buffer *mBuf)
+uint8_t duActvTsk(Pst *pst, Buffer *mBuf)
 {
-   S16 ret = ROK;
+   uint8_t ret = ROK;
 
    switch(pst->srcEnt)
    {
       case ENTDUAPP:
-         {
-            switch(pst->event)
-            {
-               case EVTCFG:
-                  {
-                     DU_LOG("\n****** Received initial configs at DU APP ******\n");
-                     duProcCfgComplete();
-                     SPutMsg(mBuf);
-                     break;
-                  }
-               default:
-                  {
-                     DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTDUAPP");
-                     SPutMsg(mBuf);
-                     ret = RFAILED;
-                  }
-            }
+        {
+           switch(pst->event)
+           {
+              case EVTCFG:
+                 {
+                    DU_LOG("\n****** Received initial configs at DU APP ******\n");
+                    duProcCfgComplete();
+                    ODU_PUT_MSG_BUF(mBuf);
+                    break;
+                 }
+              default:
+                 {
+                    DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTDUAPP");
+                    ODU_PUT_MSG_BUF(mBuf);
+                    ret = RFAILED;
+                 }
+           }
 
-            break;
-         }
-      case ENTKW:
-         {
-            switch(pst->event)
-            {
-               case LKW_EVT_CFG_CFM:
-                  {
-                     ret = cmUnpkLkwCfgCfm(duHdlRlcCfgComplete, pst, mBuf);
-                     break;
-                  }
-               case LKW_EVT_CNTRL_CFM:
-                  {
-                     ret = cmUnpkLkwCntrlCfm(duHdlRlcCntrlCfgComplete, pst, mBuf);
-                     break;
-                  }
-               case LKW_EVT_STA_IND:
-                  {
-                     break;
-                  }
-               default:
-                  {
-                     DU_LOG("\nDU_APP : Invalid event %d received at duActvTsk from ENTKW", \
-                           pst->event);
-                     SPutMsg(mBuf);
-                     ret = RFAILED;
-                  }
-            }
-            break;
-         }
-      case ENTRG:
-         {
-            switch(pst->event)
-            {
-               //Config complete
-               case EVTCFG:
-                  {
-                     SPutMsg(mBuf);
-                     break;
+           break;
+        }
+      case ENTRLC:
+        {
+           switch(pst->event)
+           {
+              case LKW_EVT_CFG_CFM:
+                 {
+                    ret = unpackRlcConfigCfm(DuHdlRlcCfgComplete, pst, mBuf);
+                    break;
+                 }
+              case LKW_EVT_CNTRL_CFM:
+                 {
+                    ret = cmUnpkLkwCntrlCfm(duHdlRlcCntrlCfgComplete, pst, mBuf);
+                    break;
+                 }
+              case LKW_EVT_STA_IND:
+                 {
+                    break;
+                 }
+              case EVENT_RLC_UL_UE_CREATE_RSP:
+                 {
+                    ret = unpackRlcUlUeCreateRsp(DuProcRlcUlUeCreateRsp, pst, mBuf);
+                    break;
+                 }
+              case EVENT_UL_RRC_MSG_TRANS_TO_DU:
+                 {
+                    ret = unpackRlcUlRrcMsgToDu(DuProcRlcUlRrcMsgTrans, pst, mBuf);
+                    break;
                   }
-               case EVTLRGCFGCFM:
-                  {
-                     ret = cmUnpkLrgCfgCfm(duHdlMacCfgComplete, pst, mBuf);
-                     break;
-                  }
-               case EVTLRGCNTRLCFM:
-                  {
-                     break;
-                  }
-               case EVTMACSCHGENCFGCFM:
-                  {
-                     ret = cmUnpkLrgSchCfgCfm(duHdlSchCfgComplete, pst, mBuf);
-                     break;
-                  }
-               case EVENT_MAC_CELL_CONFIG_CFM:
-                  {
-                     ret = unpackMacCellCfgCfm(duHandleMacCellCfgCfm, pst, mBuf);
-                     break;
-                  }
-               default:
-                  {
-                     DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTRG");
-                     SPutMsg(mBuf);
-                     ret = RFAILED;
-                  }
-            }
+              case EVENT_RRC_DELIVERY_MSG_TRANS_TO_DU:
+                 {
+                    ret = unpackRrcDeliveryReportToDu(DuProcRlcRrcDeliveryReport, pst, mBuf);
+                    break;
+                 }
+              default:
+                 {
+                    DU_LOG("\nDU_APP : Invalid event %d received at duActvTsk from ENTRLC", \
+                          pst->event);
+                    ODU_PUT_MSG_BUF(mBuf);
+                    ret = RFAILED;
+                 }
+           }
+           break;
+        }
+      case ENTMAC:
+        {
+           switch(pst->event)
+           {
+              //Config complete
+              case EVTCFG:
+                 {
+                    ODU_PUT_MSG_BUF(mBuf);
+                    break;
+                 }
+              case EVTLRGCFGCFM:
+                 {
+                    ret = cmUnpkLrgCfgCfm(duHdlMacCfgComplete, pst, mBuf);
+                    break;
+                 }
+              case EVTLRGCNTRLCFM:
+                 {
+                    break;
+                 }
+              case EVTMACSCHGENCFGCFM:
+                 {
+                    ret = cmUnpkLrgSchCfgCfm(duHdlSchCfgComplete, pst, mBuf);
+                    break;
+                 }
+              case EVENT_MAC_CELL_CONFIG_CFM:
+                 {
+                    ret = unpackMacCellCfgCfm(duHandleMacCellCfgCfm, pst, mBuf);
+                    break;
+                 }
+              case EVENT_MAC_SLOT_IND:
+                 {
+                    ret = unpackMacSlotInd(duHandleSlotInd, pst, mBuf);
+                    break;
+                 }
+              case EVENT_MAC_STOP_IND:
+                 {
+                    ret = unpackMacStopInd(duHandleStopInd, pst, mBuf);
+                    break;
+                 }
+              case EVENT_MAC_UL_CCCH_IND:
+                 {
+                    ret = unpackMacUlCcchInd(duHandleUlCcchInd, pst, mBuf);
+                    break;
+                 }
+              case EVENT_MAC_UE_CREATE_RSP:
+                 {
+                    ret = unpackDuMacUeCreateRsp(DuHandleMacUeCreateRsp, pst, mBuf); 
+                    break;
+                 }
+
+              default:
+                 {
+                    DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTMAC");
+                    ODU_PUT_MSG_BUF(mBuf);
+                    ret = RFAILED;
+                 }
+           }
 
-            break;
-         }
+           break;
+        }
       case ENTSCTP:
-         {
-            switch(pst->event)
-            {
-               case EVTSCTPDATA:
-               {
-                  F1APMsgHdlr(mBuf);
-                  break;
-               }
-               case EVTSCTPNTFY:
-               {
-                  ret = cmUnpkSctpNtfy(duSctpNtfyHdl, pst, mBuf);
-                  break;
-               }
-               default:
-               {
-                  DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTSCTP");
-                  ret = RFAILED;
-               }
+        {
+           switch(pst->event)
+           {
+              case EVENT_CU_DATA:
+                 {
+                    F1APMsgHdlr(mBuf);
+                    break;
+                 }
+              case EVENT_SCTP_NTFY:
+                 {
+                    ret = cmUnpkSctpNtfy(duSctpNtfyHdl, pst, mBuf);
+                    break;
+                 }
+              case EVENT_RIC_DATA:
+                 {
+                    E2APMsgHdlr(mBuf);
+                    break;
+                 }
+              default:
+                 {
+                    DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTSCTP");
+                    ret = RFAILED;
+                 }
 
-            }
-            SPutMsg(mBuf);
-            break;
-         }
+           }
+           ODU_PUT_MSG_BUF(mBuf);
+           break;
+        }
       case ENTEGTP:
-         {
-            switch(pst->event)
-            {
-               case EVTCFGCFM:
-               {
-                  cmUnpkEgtpCfgCfm(duHdlEgtpCfgComplete, mBuf);
-                  break;
-               }
-               case EVTSRVOPENCFM:
-               {
-                  cmUnpkEgtpSrvOpenCfm(duHdlEgtpSrvOpenComplete, mBuf);
-                  break;
-               }
-               case EVTTNLMGMTCFM:
-               {
-                  cmUnpkEgtpTnlMgmtCfm(duHdlEgtpTnlMgmtCfm, mBuf);
-                  break;
-               }
-               default:
-               {
-                  DU_LOG("\nDU_APP : Invalid event[%d] received at duActvTsk from ENTEGTP", pst->event);
-                  ret = RFAILED;
-               }
-            }
-            SPutMsg(mBuf);
-            break;
-         }
+        {
+           switch(pst->event)
+           {
+              case EVTCFGCFM:
+                 {
+                    unpackEgtpCfgCfm(duHdlEgtpCfgComplete, mBuf);
+                    break;
+                 }
+              case EVTSRVOPENCFM:
+                 {
+                    unpackEgtpSrvOpenCfm(duHdlEgtpSrvOpenComplete, mBuf);
+                    break;
+                 }
+              case EVTTNLMGMTCFM:
+                 {
+                    unpackEgtpTnlMgmtCfm(duHdlEgtpTnlMgmtCfm, mBuf);
+                    break;
+                 }
+              default:
+                 {
+                    DU_LOG("\nDU_APP : Invalid event[%d] received at duActvTsk from ENTEGTP", pst->event);
+                    ret = RFAILED;
+                 }
+           }
+           ODU_PUT_MSG_BUF(mBuf);
+           break;
+        }
       default:
-         {
-            DU_LOG("\nDU_APP : DU APP can not process message from Entity %d", pst->srcEnt);
-            SPutMsg(mBuf);
-            ret = RFAILED;
-         }
+        {
+           DU_LOG("\nDU_APP : DU APP can not process message from Entity %d", pst->srcEnt);
+           ODU_PUT_MSG_BUF(mBuf);
+           ret = RFAILED;
+        }
 
    }
-   SExitTsk();
+   ODU_EXIT_TASK();
    return ret;
 }
 
 /**********************************************************************
-         End of file
-**********************************************************************/
+  End of file
+ **********************************************************************/