RLC BO, BO response and DL Data handling. [Issue-ID: ODUHIGH-181]
[o-du/l2.git] / src / 5gnrrlc / kw_tmm_ul.c
index 4011621..55337b3 100755 (executable)
@@ -25,9 +25,9 @@
      Desc:     Source code for RLC Transparent mode assembly and
                reassembly.This file contains following functions
                 
-                  --kwTmmQSdu
-                  --kwTmmSndToLi
-                  --kwTmmRcvFrmLi
+                  --rlcTmmQSdu
+                  --rlcTmmSendToMac
+                  --rlcTmmRcvFrmMac
                   --kwTmmReEstablish 
 
      File:     kw_tmm_ul.c
@@ -42,18 +42,7 @@ static int RLOG_FILE_ID=201;
 */
 \f
 /* header (.h) include files */
-#include "envopt.h"        /* environment options */
-#include "envdep.h"        /* environment dependent */
-#include "envind.h"        /* environment independent */
-
-#include "gen.h"           /* general */
-#include "ssi.h"           /* system services */
-#include "cm5.h"           /* common timer defines */
-#include "cm_tkns.h"       /* common tokens defines */
-#include "cm_mblk.h"       /* common memory allocation library defines */
-#include "cm_llist.h"      /* common link list  defines  */
-#include "cm_hash.h"       /* common hash list  defines */
-#include "cm_lte.h"        /* common LTE defines */
+#include "common_def.h"
 #include "lkw.h"           /* LKW defines */
 #include "ckw.h"           /* CKW defines */
 #include "kwu.h"           /* KWU defines */
@@ -65,16 +54,6 @@ static int RLOG_FILE_ID=201;
 #include "kw_ul.h"
 
 /* extern (.x) include files */
-#include "gen.x"           /* general */
-#include "ssi.x"           /* system services */
-
-#include "cm5.x"           /* common timer library */
-#include "cm_tkns.x"       /* common tokens */
-#include "cm_mblk.x"       /* common memory allocation */
-#include "cm_llist.x"      /* common link list */
-#include "cm_hash.x"       /* common hash list */
-#include "cm_lte.x"        /* common LTE includes */
-#include "cm_lib.x"        /* common memory allocation library */
 #include "lkw.x"           /* LKW */
 #include "ckw.x"           /* CKW */
 #include "kwu.x"           /* KWU */
@@ -82,6 +61,9 @@ static int RLOG_FILE_ID=201;
 
 #include "kw.x"
 #include "kw_ul.x"
+#include "du_app_rlc_inf.h"
+#include "rlc_utils.h"
+#include "rlc_upr_inf_api.h"
 
 #if defined(PRE_DEF_UE_CTX) || defined(PRE_DEF_UE_CTX_HO)
 #ifdef EG_GEN_LOAD_5GTF
@@ -90,13 +72,13 @@ extern U32 loadStart;
 
 EXTERN S16 PjUiPjuDatInd(Pst* pst,SuId suId,CmLtePdcpId * pdcpId,Buffer *mBuf);
 #ifdef ANSI
-PUBLIC Void AddUeContext
+Void AddUeContext
 (
 CmLteRnti   crnti,
 U8 rrcMsgType
 )
 #else
-PUBLIC Void AddUeContext(crnti,rrcMsgType)
+Void AddUeContext(crnti,rrcMsgType)
 CmLteRnti   crnti,
 U8 rrcMsgType 
 #endif
@@ -124,9 +106,10 @@ U8 rrcUeCapabilityInfo[] =
    Buffer *pdu;
 
    Pst ulPst1 ={100,100,217,0,215,0,PRIOR0,0,81,1,1,0,0};
+#ifdef PJ
    Pst ulPst2 ={100,100,217,0,216,0,PRIOR0,0,68,0,1,0,0};
-
-  TRC2(kwTmmRcvFrmLi
+#endif
+  TRC2(rlcTmmRcvFrmMac
 
   if(1 == rrcMsgType)
   {
@@ -146,33 +129,37 @@ U8 rrcUeCapabilityInfo[] =
 
    RLOG1(L_INFO,"Profiling Framework Sending RRC Connection Req to RRC for UE :%d\n",crnti);
    printf("Profiling Framework Sending RRC Connection Req to RRC for UE :%d\n",crnti);
-   KwUiKwuDatInd(&ulPst1, 1, datIndInfo, pdu);
+   rlcSendUlDataToDu(&ulPst1, datIndInfo, pdu);
  }
  else if(2 == rrcMsgType)
  {
+#ifdef PJ
     CmLtePdcpId pdcpId;
     pdcpId.cellId = 1;
     pdcpId.ueId = crnti;
     pdcpId.rbId = 1;
     pdcpId.rbType = 0;
-   
+#endif   
     SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu);
   
     SAddPstMsgMult(rrcConSetupComplete,34,pdu);
 
     RLOG1(L_INFO,"Profiling Framework: Sending RRC Connection Setup Complete to RRC for UE :%d\n",crnti);
     printf("Profiling Framework: Sending RRC Connection Setup Complete to RRC for UE :%d\n",crnti);
+#ifdef PJ
     PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu);
+#endif
  }
  
  else if(3 == rrcMsgType)
  {
+#ifdef PJ
     CmLtePdcpId pdcpId;
     pdcpId.cellId = 1;
     pdcpId.ueId = crnti;
     pdcpId.rbId = 1;
     pdcpId.rbType = 0;
-   
+#endif   
     SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu);
   
 #ifndef CA_PAL_5GTF 
@@ -182,15 +169,20 @@ U8 rrcUeCapabilityInfo[] =
 #endif
     RLOG1(L_INFO,"Profiling Framework: Sending RRC UE Capability Info to RRC for UE :%d\n",crnti);
     printf("Profiling Framework: Sending RRC UE Capability Info to RRC for UE :%d\n",crnti);
+#ifdef PJ
     PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu);
+#endif
+
  }
  else if(4 == rrcMsgType)
  {
+#ifdef PJ
     CmLtePdcpId pdcpId;
     pdcpId.cellId = 1;
     pdcpId.ueId = crnti;
     pdcpId.rbId = 1;
     pdcpId.rbType = 0;
+#endif
    
     SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu);
   
@@ -198,15 +190,19 @@ U8 rrcUeCapabilityInfo[] =
 
     RLOG1(L_INFO,"Profiling Framework: Sending RRC Security Mode Complete to RRC for UE :%d\n",crnti);
     printf("Profiling Framework: Sending RRC Security Mode Complete to RRC for UE :%d\n",crnti);
+#ifdef PJ
     PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu);
+#endif
  }
  else if(5 == rrcMsgType)
  {
+#ifdef PJ
     CmLtePdcpId pdcpId;
     pdcpId.cellId = 1;
     pdcpId.ueId = crnti;
     pdcpId.rbId = 1;
     pdcpId.rbType = 0;
+#endif
    
     SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu);
   
@@ -214,9 +210,11 @@ U8 rrcUeCapabilityInfo[] =
 
     RLOG1(L_INFO,"Profiling Framework: Sending RRC Reconfig Complete to RRC for UE :%d\n",crnti);
     printf("Profiling Framework: Sending RRC Reconfig Complete to RRC for UE :%d\n",crnti);
+#ifdef PJ
     PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu);
 #ifdef EG_GEN_LOAD_5GTF
     loadStart=1;
+#endif
 #endif
  }
  RETVOID;
@@ -225,7 +223,7 @@ U8 rrcUeCapabilityInfo[] =
 /** @addtogroup tmmode */
 /*@{*/
 
-#define KW_MODULE (KW_DBGMASK_TM | KW_DBGMASK_UL)
+#define RLC_MODULE (RLC_DBGMASK_TM | RLC_DBGMASK_UL)
 
 /**
  * @brief
@@ -247,77 +245,51 @@ U8 rrcUeCapabilityInfo[] =
  *    -# RFAILED 
  */
 #ifdef CCPU_OPT
-#ifdef ANSI
-PUBLIC Void kwTmmRcvFrmLi
-(
-KwCb        *gCb,
-KwUlRbCb    *rbCb,  
-CmLteRnti   tCrnti,  
-Buffer      *pdu      
-)
-#else
-PUBLIC Void kwTmmRcvFrmLi(gCb,rbCb, tCrnti, pdu)
-KwCb        *gCb;
-KwUlRbCb    *rbCb;  
-CmLteRnti   tCrnti; 
-Buffer      *pdu;  
-#endif
-#else
-#ifdef ANSI
-PUBLIC Void kwTmmRcvFrmLi
-(
-KwCb       *gCb,
-KwUlRbCb   *rbCb,         
-Buffer     *pdu            
-)
+void rlcTmmRcvFrmMac(RlcCb *gCb, RlcUlRbCb *rbCb, CmLteRnti tCrnti, Buffer *pdu)
 #else
-PUBLIC Void kwTmmRcvFrmLi(gCb,rbCb, pdu)
-KwCb       *gCb;
-KwUlRbCb   *rbCb;         
-Buffer     *pdu;         
+void rlcTmmRcvFrmMac(RlcCb *gCb, RlcUlRbCb *rbCb, Buffer *pdu)
 #endif
-#endif 
 {
-   KwuDatIndInfo   *datIndInfo;   /* Data Indication Information */
-   MsgLen          msgLen;
+   RlcUlRrcMsgInfo  *ulRrcMsgInfo;
+   uint16_t         msgLen;
+   uint16_t         copyLen;    /* Number of bytes copied */
+   Pst              pst;
  
-   TRC2(kwTmmRcvFrmLi) 
-
-   /* Creating static memory for KwuDatIndInfo. #else will be 
-    * removed once the sanity testing is performed for all platforms */
-   KwuDatIndInfo datIndInfoTmp;
-   datIndInfo = &datIndInfoTmp;
-#if (ERRCLASS & ERRCLS_ADD_RES)
-   if ( datIndInfo == NULLP )
-   {   
-      RLOG_ARG2(L_FATAL,DBG_RBID,rbCb->rlcId.rbId,
-            "Memory Allocation failed UEID:%d CELLID:%d",
-            rbCb->rlcId.ueId,
-            rbCb->rlcId.cellId);   
-      RETVOID;
-   }
-#endif /* ERRCLASS & ERRCLS_ADD_RES */
-   KW_MEM_CPY(&(datIndInfo->rlcId),&(rbCb->rlcId),sizeof(CmLteRlcId));
-#ifdef CCPU_OPT 
-   if ( rbCb->lch.lChType == CM_LTE_LCH_CCCH ) 
-   {
-      datIndInfo->tCrnti = tCrnti;
-   }
-#endif 
    gCb->genSts.pdusRecv++;
-   SFndLenMsg(pdu, &msgLen);
+   ODU_GET_MSG_LEN(pdu, (MsgLen *)&msgLen);
    gCb->genSts.bytesRecv += msgLen;
-   /* If trace flag is enabled send the trace indication */
-   if(gCb->init.trc == TRUE)
+  
+   /* Filling UL RRC Message Info */
+   RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL,
+      ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
+   if (ulRrcMsgInfo)
    {
-      /* Populate the trace params */
-      kwLmmSendTrc(gCb,KWU_EVT_DAT_IND, pdu);
+      ulRrcMsgInfo->cellId = rbCb->rlcId.cellId;
+      ulRrcMsgInfo->ueIdx = rbCb->rlcId.ueId;
+      ulRrcMsgInfo->lcId = rbCb->lch.lChId;
+      RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL,
+         ulRrcMsgInfo->rrcMsg, msgLen);
+      if (ulRrcMsgInfo->rrcMsg)
+      {
+         ODU_COPY_MSG_TO_FIX_BUF(pdu, 0, msgLen, ulRrcMsgInfo->rrcMsg, (MsgLen *)&copyLen);
+         ulRrcMsgInfo->msgLen = msgLen;
+
+         /* Sending UL RRC Message transfeer to DU APP */
+         memset(&pst, 0, sizeof(Pst));
+         FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_UL_RRC_MSG_TRANS_TO_DU);
+         rlcSendUlRrcMsgToDu(&pst, ulRrcMsgInfo);
+      }
+      else
+      {
+         DU_LOG("\nRLC : rlcTmmRcvFrmMac: Memory allocation failed for UL RRC Msg");
+      }
    }
-   KwUiKwuDatInd( &gCb->u.ulCb->kwuUlSap->pst, 
-                  gCb->u.ulCb->kwuUlSap->suId, 
-                  datIndInfo, pdu);
-   
-   RETVOID;
+   else
+   {
+      DU_LOG("\nRLC : rlcTmmRcvFrmMac: Memory allocation failed for ulRrcMsgInfo");
+   }
+   return;
 }
 
 /**
@@ -334,18 +306,18 @@ Buffer     *pdu;
  *       
  **/
 #ifdef ANSI
-PUBLIC Void kwTmmUlReEstablish
+Void rlcTmmUlReEstablish
 (
-KwCb        *gCb,
-KwUlRbCb    *rbCb        
+RlcCb        *gCb,
+RlcUlRbCb    *rbCb        
 )
 #else
-PUBLIC Void kwTmmUlReEstablish(rbCb)
-KwCb        *gCb;
-KwRbCb      *rbCb;          
+Void rlcTmmUlReEstablish(rbCb)
+RlcCb        *gCb;
+RlcUlRbCb    *rbCb;          
 #endif
 {
-   TRC2(kwUlTmmReEstablish)
+   TRC2(rlcUlTmmReEstablish)
 
    RLOG_ARG0(L_DEBUG,DBG_RBID,rbCb->rlcId.rbId,"do nothing for TMM for ReEstablish");
    RETVOID;