[Epic-ID: ODUHIGH-406] [Task-ID: ODUHIGH-439] Building Paging RRC PDU
[o-du/l2.git] / src / du_app / du_egtp.c
index 3b77996..f5fe776 100644 (file)
 #include "du_app_mac_inf.h"
 #include "du_cfg.h"
 #include "du_egtp.h"
+#include "du_app_rlc_inf.h"
+#include "du_mgr.h"
 #include "du_utils.h"
 
-/* Global variable declaration */
-EgtpGlobalCb egtpCb;
 
 /**************************************************************************
  * @brief Task Initiation callback function. 
@@ -63,6 +63,102 @@ uint8_t egtpActvInit(Ent entity, Inst inst, Region region, Reason reason)
   return ROK;
 }
 
+/**************************************************************************
+* @brief Function prints the src dest and msg reached to egtp.
+*
+* @details
+*
+*      Function : callFlowEgtpActvTsk 
+*
+*      Functionality:
+*           Function prints the src dest and msg reached to egtp.
+*
+* @param[in]  Pst     *pst, Post structure of the primitive.
+*
+* @return void 
+*
+***************************************************************************/
+
+void callFlowEgtpActvTsk(Pst *pst)
+{
+
+   char sourceTask[50];
+   char destTask[50]="ENTEGTP";
+   char message[100];
+
+   switch(pst->srcEnt)
+   {
+      case ENTDUAPP:
+         {
+            strcpy(sourceTask,"ENTDUAPP");
+            switch(pst->event)
+            {
+               case EVTCFGREQ:
+                  {
+                     strcpy(message,"EVTCFGREQ");
+                     break;
+                  }
+               case EVTSRVOPENREQ:
+                  {
+                     strcpy(message,"EVTSRVOPENREQ");
+                     break;
+                  }
+               case EVTTNLMGMTREQ:
+                  {
+                     strcpy(message,"EVTTNLMGMTREQ");
+                     break;
+                  }
+               default:
+                  {
+                     strcpy(message,"Invalid Event");
+                     break;
+                  }
+            }
+            break;
+         }
+      case ENTEGTP:
+         {
+            strcpy(sourceTask,"ENTEGTP");
+            switch(pst->event)
+            {
+               case EVTSTARTPOLL:
+                  {
+                     strcpy(message,"EVTSTARTPOLL");
+                     break;
+                  }
+               default:
+                  {
+                     strcpy(message,"Invalid Event");
+                     break;
+                  }
+            }
+            break;
+         }
+      case ENTRLC:
+         {
+            strcpy(sourceTask,"ENTRLC");
+            switch(pst->event)
+            {
+               case EVTDATIND:
+                  {
+                     strcpy(message,"EVTDATIND");
+                     break;
+                  }
+               default:
+                  {
+                     strcpy(message,"Invalid Event");
+                     break;
+                  }
+            }
+            break;
+         }
+      default:
+         {
+             strcpy(sourceTask,"Invalid Source Entity Id");
+         }
+   }
+   DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);
+}
 
 /**************************************************************************
  * @brief Task Activation callback function. 
@@ -86,6 +182,10 @@ uint8_t egtpActvInit(Ent entity, Inst inst, Region region, Reason reason)
 uint8_t egtpActvTsk(Pst *pst, Buffer *mBuf)
 {
    uint8_t ret = ROK;
+  
+#ifdef CALL_FLOW_DEBUG_LOG
+   callFlowEgtpActvTsk(pst);
+#endif
 
    switch(pst->srcEnt)
    {
@@ -187,7 +287,7 @@ uint8_t egtpCfgReq(Pst *pst, EgtpConfig egtpCfg)
    memcpy(&egtpCb.egtpCfg, &egtpCfg, sizeof(EgtpConfig));
 
    egtpCb.recvTptSrvr.addr.address = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.localIp.ipV4Addr);
-   egtpCb.recvTptSrvr.addr.port = EGTP_DFLT_PORT;
+   egtpCb.recvTptSrvr.addr.port = EGTP_RECVR_PORT;
 
    egtpCb.dstCb.dstIp = CM_INET_NTOH_UINT32(egtpCb.egtpCfg.destIp.ipV4Addr);
    egtpCb.dstCb.dstPort = egtpCb.egtpCfg.destPort;
@@ -377,6 +477,10 @@ uint8_t egtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt)
 {
    uint8_t ret = ROK;
 
+#ifdef CALL_FLOW_DEBUG_LOG
+   DU_LOG("\nCall Flow: ENTDUAPP -> ENTEGTP : TNL_MGMT\n");
+#endif
+
    DU_LOG("\nDEBUG   -->  EGTP : Received tunnel management request");
    switch(tnlEvt.action)
    {
@@ -566,6 +670,10 @@ uint8_t egtpHdlDatInd(EgtpMsg egtpMsg)
    uint32_t    msgLen;
    EgtpMsgHdr  *msgHdr;
 
+#ifdef CALL_FLOW_DEBUG_LOG
+   DU_LOG("\nCall Flow: ENTDUAPP -> ENTEGTP : DATA_INDICATION\n");
+#endif
+   
    DU_LOG("\nDEBUG  -->  EGTP : Received Data Indication");
 
    cmHashListFind(&(egtpCb.dstCb.teIdLst), (uint8_t *)&(egtpMsg.msgHdr.teId), sizeof(uint32_t), 0, (PTR *)&teidCb);
@@ -766,11 +874,12 @@ uint8_t egtpSendMsg(Buffer *mBuf)
    uint16_t       txLen;
    CmInetMemInfo  info;
    CmInetAddr     dstAddr;
+   static uint64_t numDataSent = 0;
 
    info.region = DU_APP_MEM_REGION;
    info.pool = DU_POOL;
 
-   dstAddr.port = EGTP_DFLT_PORT;
+   dstAddr.port = EGTP_RECVR_PORT;
    dstAddr.address = egtpCb.dstCb.dstIp;
 
    ret = cmInetSendMsg(&(egtpCb.dstCb.sendTptSrvr.sockFd), &dstAddr, &info, \
@@ -780,8 +889,11 @@ uint8_t egtpSendMsg(Buffer *mBuf)
       DU_LOG("\nERROR  -->  EGTP : Failed sending the message");
       return RFAILED;
    }
-
-   DU_LOG("\nDEBUG   -->  EGTP : Message Sent");
+   else
+   {
+      DU_LOG("\nDEBUG -->  EGTP : Sent UL Message [%ld]", numDataSent+1);
+      numDataSent++;
+   }
 
    return ROK;
 }
@@ -824,10 +936,11 @@ uint8_t egtpRecvMsg()
          &recvBuf, (int16_t *)&bufLen, CM_INET_NO_FLAG);
       if(ret == ROK && recvBuf != NULLP)
       {  
-         //DU_LOG("\nDEBUG  -->  EGTP : Received DL Message[%ld]\n", gDlDataRcvdCnt + 1);
+         DU_LOG("\nDEBUG  -->  EGTP : Received DL Message[%ld]\n", gDlDataRcvdCnt + 1);
          //ODU_PRINT_MSG(recvBuf, 0 ,0);
          egtpHdlRecvData(recvBuf);
          gDlDataRcvdCnt++;
+         
       }
    }