Revert "[Epic-ID: ODUHIGH-462][Task-ID: ODUHIGH-472] Implementation of drx timer"
[o-du/l2.git] / src / 5gnrmac / rg_uim.c
index add49a0..f021429 100755 (executable)
 manages Pst and Sap related information for upper interface APIs.
 */
 
-static const char* RLOG_MODULE_NAME="MAC";
-static int RLOG_MODULE_ID=4096;
-static int RLOG_FILE_ID=178;
 
 /* header include files -- defines (.h) */
 
 /* header/extern include files (.x) */
 /* header include files (.h) */
-#include "envopt.h"        /* environment options */
-#include "envdep.h"        /* environment dependent */
-#include "envind.h"        /* environment independent */
-#include "gen.h"           /* general layer */
-#include "ssi.h"           /* system services */
-#include "cm5.h"           /* common timers defines */
-#include "cm_hash.h"       /* common hash list defines */
-#include "cm_llist.h"      /* common linked list defines */
-#include "cm_mblk.h"       /* memory management */
-#include "cm_tkns.h"       /* common tokens */
-#include "cm_lte.h"
+#include "common_def.h"
 #include "crg.h"           /* CRG defines */
 #include "lrg.h"           /* layer management defines for LTE-MAC */
 #include "tfu.h"
@@ -60,24 +47,17 @@ static int RLOG_FILE_ID=178;
 #include "rg_env.h"        /* customizable defines and macros for MAC */
 #include "rg.h"            /* defines and macros for MAC */
 #include "rg_err.h"        /* RG error defines */
+#include "mac_utils.h"
 
 /* header/extern include files (.x) */
 
-#include "gen.x"           /* general layer typedefs */
-#include "ssi.x"           /* system services typedefs */
-#include "cm5.x"           /* common timers */
-#include "cm_hash.x"       /* common hash list */
-#include "cm_lib.x"        /* common library */
-#include "cm_llist.x"      /* common linked list */
-#include "cm_mblk.x"       /* memory management */
-#include "cm_tkns.x"       /* common tokens */
-#include "cm_lte.x"
 #include "crg.x"           /* CRG types */
 #include "lrg.x"           /* layer management typedefs for MAC */
 #include "tfu.x"
 #include "rgu.x"
 #include "rg_sch_inf.x"
 #include "rg_prg.x"        /* PRG interface typedefs*/
+#include "du_app_mac_inf.h"
 #include "rg.x"            /* typedefs for MAC */
 
 #include "ss_rbuf.h"
@@ -92,10 +72,10 @@ static int RLOG_FILE_ID=178;
 /* forward references */
 
 #if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF)
-PUBLIC S16 rgBatchProc(Void);
+S16 rgBatchProc(Void);
 #endif
-PUBLIC U8 rgRguDlSap;
-PUBLIC U8 rgRguUlSap;
+uint8_t rgRguDlSap;
+uint8_t rgRguUlSap;
 /**
  * @brief Handler for Bind request.
  *
@@ -113,28 +93,18 @@ PUBLIC U8 rgRguUlSap;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiRguBndReq
+S16 RgUiRguBndReq
 (
 Pst  *pst,
 SuId suId,
 SpId spId
 )
-#else
-PUBLIC S16 RgUiRguBndReq(pst, suId, spId)
-Pst  *pst;
-SuId suId;
-SpId spId;
-#endif
 {
    Inst      inst; 
    S16       ret = ROK;
    Pst       tmpPst;   /* Temporary Post Structure */
    RgUstaDgn dgn;      /* Alarm diagnostics structure */
 
-   TRC3(RgUiRguBndReq)
-
-
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
 
@@ -157,15 +127,14 @@ SpId spId;
       switch (rgCb[inst].rguSap[spId].sapSta.sapState)
       {
          case LRG_NOT_CFG: /* SAP Not configured */
-            RGDBGINFO(inst,(rgPBuf(inst), "SAP Not Configured\n"));
             rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM); 
             ret = rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE,LRG_NOT_CFG,
                   LCM_CAUSE_INV_SAP, &dgn);
-            RLOG0(L_DEBUG,"SAP Not Configured");
+            DU_LOG("\nDEBUG  -->  MAC : SAP Not Configured");
             ret = RgUiRguBndCfm(&tmpPst, suId, CM_BND_NOK);
             break;
          case LRG_UNBND: /* SAP is not bound */
-            RLOG0(L_DEBUG,"SAP Not yet bound");
+            DU_LOG("\nDEBUG  -->  MAC : SAP Not yet bound");
             rgCb[inst].rguSap[spId].sapSta.sapState = LRG_BND;
             rgCb[inst].rguSap[spId].sapCfg.suId = suId;
             /* Send Bind Confirm with status as SUCCESS */
@@ -177,14 +146,13 @@ SpId spId;
                   LCM_CAUSE_UNKNOWN, &dgn);
             break;
          case LRG_BND: /* SAP is already bound*/
-            RLOG0(L_DEBUG,"SAP already bound");
+            DU_LOG("\nDEBUG  -->  MAC : SAP already bound");
             /*T2K - Passing spId as it is required to access the SAP CB*/
             ret = rgUIMRguBndCfm(inst,spId, CM_BND_OK);
             break;
          default: /* Should Never Enter here */
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-            RGLOGERROR(inst,ERRCLS_INT_PAR, ERG008, (ErrVal)rgCb[inst].rguSap[spId].sapSta.sapState,
-                  "Invalid SAP State:RgUiRguBndReq failed\n");
+            DU_LOG("\nERROR  -->  MAC : Invalid SAP State:RgUiRguBndReq failed\n");
 #endif
             /*T2K - Passing spId as it is required to access the SAP CB*/
             ret = rgUIMRguBndCfm(inst,spId, CM_BND_NOK);
@@ -194,13 +162,12 @@ SpId spId;
    else
    {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-      RGLOGERROR(inst,ERRCLS_INT_PAR, ERG009, (ErrVal)rgCb[inst].rguSap[spId].sapCfg.spId,
-            "Invalid SAP Id:RgUiRguBndReq failed\n");
+      DU_LOG("\nERROR  -->  MAC : Invalid SAP Id:RgUiRguBndReq failed\n");
 #endif
       /*T2K - Passing spId as it is required to access the SAP CB*/
       ret = rgUIMRguBndCfm(inst,spId, CM_BND_NOK);
    }
-   RETVALUE(ret);
+   return (ret);
 }  /* RgUiRguBndReq */
 
 
@@ -221,23 +188,14 @@ SpId spId;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiRguUbndReq
+S16 RgUiRguUbndReq
 (
 Pst    *pst,
 SpId   spId,
 Reason reason
 )
-#else
-PUBLIC S16 RgUiRguUbndReq(pst, spId, reason)
-Pst    *pst;
-SpId   spId;
-Reason reason;
-#endif
 {
    Inst      inst;
-   TRC3(RgUiRguUbndReq)
-   
 
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
@@ -247,13 +205,13 @@ Reason reason;
       switch(rgCb[inst].rguSap[spId].sapSta.sapState)
       {
          case LRG_BND: /* SAP is already bound*/
-            RLOG0(L_DEBUG,"SAP already bound");
+            DU_LOG("\nDEBUG  -->  MAC : SAP already bound");
             /* setting SAP state to UN BOUND */
             rgCb[inst].rguSap[spId].sapSta.sapState = LRG_UNBND;
             break;
          default:
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-     RLOG1(L_ERROR,"Invalid SAP State:%d RgUiRguUbndReq failed",
+     DU_LOG("\nERROR  -->  MAC : Invalid SAP State:%d RgUiRguUbndReq failed",
                   rgCb[inst].rguSap[spId].sapSta.sapState);
        
 #endif
@@ -263,12 +221,11 @@ Reason reason;
    else
    {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-      RGLOGERROR(inst,ERRCLS_INT_PAR, ERG011, (ErrVal)rgCb[inst].rguSap[spId].sapCfg.spId,
-            "Invalid SAP Id:RgUiRguUbndReq failed\n");
+     DU_LOG("\nERROR  -->  MAC : Invalid SAP Id:RgUiRguUbndReq failed\n");
 #endif
-      RETVALUE(RFAILED);
+      return RFAILED;
    }
-   RETVALUE(ROK);
+   return ROK;
 }  /* RgUiRguUbndReq */
 /**
  * @brief API for sending bind confirm from MAC to RLC
@@ -283,39 +240,24 @@ Reason reason;
  *           
  *  @param[in] Inst        inst
  *  @param[in]  SuId          suId
- *  @param[in]  U8            status
+ *  @param[in]  uint8_t            status
  *  @return  S16
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 rgUIMRguBndCfm
-(
-Inst inst,
-SpId spId,
-U8 status
-)
-#else
-PUBLIC S16 rgUIMRguBndCfm(inst,spId, status)
-Inst          inst;
-SpId          spId;
-U8            status;
-#endif
+S16 rgUIMRguBndCfm(Inst inst,SpId spId,uint8_t status)
 {
    S16  ret = ROK;
    
-   TRC2(rgUIMRguBndCfm)
-   
-
    ret = RgUiRguBndCfm(&rgCb[inst].rguSap[spId].sapCfg.sapPst, 
                       rgCb[inst].rguSap[spId].sapCfg.suId, status);
    if (ret != ROK)
    {
       
-      RLOG0(L_ERROR,"RgUiRguBndCfm Failed ");
-      RETVALUE(ret);
+      DU_LOG("\nERROR  -->  MAC : RgUiRguBndCfm Failed ");
+      return (ret);
    }
-   RETVALUE(ret);
+   return (ret);
 }  /* rgUIMRguBndCfm*/
 
 
@@ -335,39 +277,24 @@ U8            status;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiRguDDatReq
-(
-Pst             *pst,
-SpId            spId,
-RguDDatReqInfo  *datReq
-)
-#else
-PUBLIC S16 RgUiRguDDatReq(pst, spId, datReq)
-Pst             *pst;
-SpId            spId;
-RguDDatReqInfo  *datReq;
-#endif
+S16 RgUiRguDDatReq(Pst *pst,SpId spId,RguDDatReqInfo  *datReq)
 {
    S16   ret = ROK;
    Inst  inst;
 #ifndef NO_ERRCLS 
-   U32   id;
-   U32   id1;
-   U32   id2;
-   U32   id3;
+   uint32_t   id;
+   uint32_t   id1;
+   uint32_t   id2;
+   uint32_t   id3;
 #endif
    
-   TRC3(RgUiRguDDatReq)
-
-
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
 #ifndef NO_ERRCLS
    if (datReq == NULLP)
    {
-      RLOG0(L_ERROR,"Input Message Buffer is NULL");
-      RETVALUE(RFAILED);
+      DU_LOG("\nERROR  -->  MAC : Input Message Buffer is NULL");
+      return RFAILED;
    }
    
    if(rgCb[inst].rguSap[spId].sapCfg.spId == spId)
@@ -375,11 +302,11 @@ RguDDatReqInfo  *datReq;
       switch (rgCb[inst].rguSap[spId].sapSta.sapState)
       {
          case LRG_BND: /* SAP is bound */
-            RLOG0(L_DEBUG,"SAP is already bound");
+            DU_LOG("\nDEBUG  -->  MAC : SAP is already bound");
             break;
          default: /* Should never reach here */
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-            RLOG1(L_ERROR,"Invalid SAP State:%d RgUiRguDDatReq failed",
+            DU_LOG("\nERROR  -->  MAC : Invalid SAP State:%d RgUiRguDDatReq failed",
                   rgCb[inst].rguSap[spId].sapSta.sapState);
 #endif
 #ifndef L2_OPTMZ
@@ -388,14 +315,13 @@ RguDDatReqInfo  *datReq;
                RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[id3]);
             }
 #endif
-            RETVALUE(RFAILED);
+            return RFAILED;
       }
    }
    else
    {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-      RGLOGERROR(inst,ERRCLS_INT_PAR, ERG013, (ErrVal)spId,
-            "Invalid SAP Id:RgUiRguDDatReq failed\n");
+      DU_LOG("\nERROR  -->  MAC : Invalid SAP Id:RgUiRguDDatReq failed\n");
 #endif
 #ifndef L2_OPTMZ
       for(id3 = 0; id3 < datReq->nmbOfUeGrantPerTti; id3++)
@@ -403,7 +329,7 @@ RguDDatReqInfo  *datReq;
          RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[id3]);
       }
 #endif
-      RETVALUE(RFAILED);
+      return RFAILED;
    }
 
    /* Update RGU SAP statistics for received sdu count */
@@ -435,9 +361,8 @@ RguDDatReqInfo  *datReq;
 
    /* Call Ownership module for further processing */
    ret = rgROMDedDatReq(inst,datReq);
-    SPutStaticBuffer(pst->region, pst->pool, (Data *)datReq,sizeof(RguDDatReqInfo), SS_SHARABLE_MEMORY);
-   datReq = NULLP;
-   RETVALUE(ret);
+   MAC_FREE_SHRABL_BUF(pst->region, pst->pool, datReq,sizeof(RguDDatReqInfo));
+   return (ret);
 }  /* RgUiRguDDatReq */
 
 
@@ -457,33 +382,23 @@ RguDDatReqInfo  *datReq;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiRguCDatReq
+S16 RgUiRguCDatReq
 (
 Pst             *pst,
 SpId            spId,
 RguCDatReqInfo  *datReq
 )
-#else
-PUBLIC S16 RgUiRguCDatReq(pst, spId, datReq)
-Pst             *pst;
-SpId            spId;
-RguCDatReqInfo  *datReq;
-#endif
 {
    Inst  inst;
    S16   ret = ROK;
    
-   TRC3(RgUiRguCDatReq)
-
-
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
 #ifndef NO_ERRCLS
    if (datReq == NULLP)
    {
-      RLOG0(L_ERROR,"Input Message Buffer is NULL");
-      RETVALUE(RFAILED);
+      DU_LOG("\nERROR  -->  MAC : Input Message Buffer is NULL");
+      return RFAILED;
    }
    
    if(rgCb[inst].rguSap[spId].sapCfg.spId == spId)
@@ -491,22 +406,22 @@ RguCDatReqInfo  *datReq;
       switch (rgCb[inst].rguSap[spId].sapSta.sapState)
       {
          case LRG_BND: /* SAP is bound */
-            RLOG0(L_DEBUG,"SAP is already bound");
+            DU_LOG("\nERROR  -->  MAC : SAP is already bound");
             break;
          default: /* Should never reach here */
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-            RLOG1(L_ERROR,"Invalid SAP State:%d RgUiRguCDatReq failed",
+            DU_LOG("\nERROR  -->  MAC : Invalid SAP State:%d RgUiRguCDatReq failed",
                   rgCb[inst].rguSap[spId].sapSta.sapState);
 #endif
-            RETVALUE(RFAILED);
+            return RFAILED;
       }
    }
    else
    {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-      RLOG1(L_ERROR,"Invalid SAP Id:%d RgUiRguCDatReq failed ",spId);
+      DU_LOG("\nERROR  -->  MAC : Invalid SAP Id:%d RgUiRguCDatReq failed ",spId);
 #endif
-      RETVALUE(RFAILED);
+      return RFAILED;
    }
 #endif
 
@@ -526,9 +441,8 @@ RguCDatReqInfo  *datReq;
    {
       RG_DROP_RGUCDATREQ_MBUF(datReq);
    }
-   ret = SPutStaticBuffer(pst->region, pst->pool,(Data *)datReq,sizeof(RguCDatReqInfo) , SS_SHARABLE_MEMORY);
-   datReq = NULLP;
-   RETVALUE(ret);
+   MAC_FREE_SHRABL_BUF(pst->region, pst->pool,datReq,sizeof(RguCDatReqInfo));
+   return (ret);
 }  /* RgUiRguCDatReq */
 
 
@@ -548,26 +462,17 @@ RguCDatReqInfo  *datReq;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiRguDStaRsp
+S16 RgUiRguDStaRsp
 (
 Pst             *pst,
 SpId            spId,
 RguDStaRspInfo  *staRsp
 )
-#else
-PUBLIC S16 RgUiRguDStaRsp(pst, spId, staRsp)
-Pst             *pst;
-SpId            spId;
-RguDStaRspInfo  *staRsp;
-#endif
 {
    Inst  inst;
+   S16   ret       = ROK;
+   volatile uint32_t     startTime = 0;
 
-   S16              ret       = ROK;
-   VOLATILE U32     startTime = 0;
-
-   TRC3(RgUiRguDStaRsp)
 
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
@@ -577,14 +482,13 @@ RguDStaRspInfo  *staRsp;
    ret = rgROMDedStaRsp(inst,staRsp);
    if (ret != ROK)
    {
-      RLOG_ARG0(L_ERROR,DBG_CELLID,staRsp->cellId,
-                "Processing Of Status Response Failed");
+       DU_LOG("\nERROR  -->  MAC : Processing Of Status Response Failed");
    }
 
 
    /*stoping Task*/
    SStopTask(startTime, PID_MAC_STA_RSP);
-   RETVALUE(ret);
+   return (ret);
 }  /* RgUiRguDStaRsp */
 
 
@@ -606,33 +510,23 @@ RguDStaRspInfo  *staRsp;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiRguCStaRsp
+S16 RgUiRguCStaRsp
 (
 Pst             *pst,
 SpId            spId,
 RguCStaRspInfo  *staRsp
 )
-#else
-PUBLIC S16 RgUiRguCStaRsp(pst, spId, staRsp)
-Pst             *pst;
-SpId            spId;
-RguCStaRspInfo  *staRsp;
-#endif
 {
    Inst  inst;
    S16   ret = ROK;
 
-   TRC3(RgUiRguCStaRsp)
-   
-
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
 #ifndef NO_ERRCLS
    if (staRsp == NULLP)
    {
-      RLOG0(L_ERROR,"Input Response Buffer is NULL");
-      RETVALUE(RFAILED);
+      DU_LOG("\nERROR  -->  MAC : Input Response Buffer is NULL");
+      return RFAILED;
    }
 
    if (spId == rgCb[inst].rguSap[spId].sapCfg.spId)
@@ -640,35 +534,34 @@ RguCStaRspInfo  *staRsp;
       switch (rgCb[inst].rguSap[spId].sapSta.sapState)
       {
          case LRG_BND: /* SAP is bound */
-            RLOG0(L_DEBUG,"SAP is already bound");
+            DU_LOG("\nDEBUG  -->  MAC : SAP is already bound");
             break;
          default: /* Should never reach here */
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-            RLOG1(L_ERROR,"Invalid SAP State:%d RgUiRguCStaRsp failed",
+            DU_LOG("\nERROR  -->  MAC : Invalid SAP State:%d RgUiRguCStaRsp failed",
                   rgCb[inst].rguSap[spId].sapSta.sapState);
 #endif
-            RETVALUE(RFAILED);
+            return RFAILED;
       }
    }
    else
    {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-      RLOG1(L_ERROR,"Invalid SAP Id:%d RgUiRguCStaRsp failed",spId);
+      DU_LOG("\nERROR  -->  MAC : Invalid SAP Id:%d RgUiRguCStaRsp failed",spId);
 #endif
-      RETVALUE(RFAILED);
+      return RFAILED;
    }
 #endif
 
    ret = rgROMCmnStaRsp(inst,staRsp);
    if (ret != ROK)
    {
-      RLOG_ARG0(L_ERROR,DBG_CELLID,staRsp->cellId,"Processing Of Status Response Failed");
-      RETVALUE(ret);
+      DU_LOG("\nERROR  -->  MAC : Processing Of Status Response Failed");
+      return (ret);
    }
 
-   ret = SPutStaticBuffer(pst->region, pst->pool, (Data *)staRsp,sizeof(RguCStaRspInfo) , SS_SHARABLE_MEMORY);
-   staRsp = NULLP;
-   RETVALUE(ret);
+   MAC_FREE_SHRABL_BUF(pst->region, pst->pool, staRsp,sizeof(RguCStaRspInfo));
+   return (ret);
 }  /* RgUiRguCStaRsp */
 
 #ifdef LTE_L2_MEAS
@@ -689,34 +582,24 @@ RguCStaRspInfo  *staRsp;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiRguL2MUlThrpMeasReq 
+S16 RgUiRguL2MUlThrpMeasReq 
 (
 Pst             *pst,
 SpId            spId,
 RguL2MUlThrpMeasReqInfo  *measReq
 )
-#else
-PUBLIC S16 RgUiRguL2MUlThrpMeasReq(pst, spId, measReq)
-Pst             *pst;
-SpId            spId;
-RguL2MUlThrpMeasReqInfo  *measReq;
-#endif
 {
    Inst  inst;
 
    S16   ret = ROK;
 
-   TRC3(RgUiRguL2MUlThrpMeasReq)
-   
-
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
 #ifndef NO_ERRCLS
    if (measReq == NULLP)
    {
-      RLOG0(L_ERROR,"Input Response Buffer is NULL");
-      RETVALUE(RFAILED);
+      DU_LOG("\nERROR  -->  MAC : Input Response Buffer is NULL");
+      return RFAILED;
    }
 
    if (spId == rgCb[inst].rguSap[spId].sapCfg.spId)
@@ -724,34 +607,33 @@ RguL2MUlThrpMeasReqInfo  *measReq;
       switch (rgCb[inst].rguSap[spId].sapSta.sapState)
       {
          case LRG_BND: /* SAP is bound */
-            RLOG0(L_DEBUG,"SAP is already bound");
+            DU_LOG("\nERROR  -->  MAC : SAP is already bound");
             break;
          default: /* Should never reach here */
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-            RLOG1(L_ERROR,"Invalid SAP State:%d RgUiRguL2MUlThrpMeasReq failed",
+            DU_LOG("\nERROR  -->  MAC : Invalid SAP State:%d RgUiRguL2MUlThrpMeasReq failed",
                   rgCb[inst].rguSap[spId].sapSta.sapState);
 #endif
-            RETVALUE(RFAILED);
+            return RFAILED;
       }
    }
    else
    {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-      RLOG1(L_ERROR,"Invalid SAP Id:%d RgUiRguL2MUlThrpMeasReq failed",spId);
+      DU_LOG("\nERROR  -->  MAC : Invalid SAP Id:%d RgUiRguL2MUlThrpMeasReq failed",spId);
 #endif
-      RETVALUE(RFAILED);
+      return RFAILED;
    }
 #endif
 
    ret = rgROML2MUlThrpMeasReq(inst,measReq);
    if (ret != ROK)
    {
-      RLOG_ARG0(L_ERROR,DBG_CELLID,measReq->cellId,"Processing Of Meas Request Failed");
+      DU_LOG("\nERROR  -->  MAC : Processing Of Meas Request Failed");
    }
 
-  SPutStaticBuffer(pst->region, pst->pool, (Data *)measReq,sizeof(RguL2MUlThrpMeasReqInfo) , SS_SHARABLE_MEMORY);
-   measReq= NULLP;
-   RETVALUE(ret);
+   MAC_FREE_SHRABL_BUF(pst->region, pst->pool, (Data *)measReq,sizeof(RguL2MUlThrpMeasReqInfo));
+   return (ret);
 }  /* RgUiRguL2MUlThrpMeasReq */
 #endif
 
@@ -773,34 +655,25 @@ RguL2MUlThrpMeasReqInfo  *measReq;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 rgUIMSndDedStaInd
+S16 rgUIMSndDedStaInd
 (
 Inst         inst,
 RgUpSapCb    *rguSap,
 RgRguDedStaInd  *staInd
 )
-#else
-PUBLIC S16 rgUIMSndDedStaInd(inst,rguSap,staInd)
-Inst         inst;
-RgUpSapCb    *rguSap;
-RgRguDedStaInd  *staInd;
-#endif
 {
    S16  ret = ROK;
    
-   TRC2(rgUIMSndDedStaInd)
-   
-   RGDBGPRM(inst,(rgPBuf(inst),"rgUIMSndDedStaInd(): staInd = %p;\n", (void *)staInd));
+   DU_LOG("\nINFO  -->  MAC : rgUIMSndDedStaInd(): staInd = %p;\n", (void *)staInd);
    
    ret = RgUiRguDStaInd(&(rguSap->sapCfg.sapPst), rguSap->sapCfg.suId, 
          staInd);
    if (ret != ROK)
    {
-      RLOG_ARG0(L_ERROR,DBG_CELLID,staInd->cellId,"RgUiRguDStaInd Failed");
-      RETVALUE(ret);
+      DU_LOG("\nERROR  -->  MAC : RgUiRguDStaInd Failed");
+      return (ret);
    }
-   RETVALUE(ret);
+   return (ret);
 }  /* rgUIMSndDedStaInd */
 
 
@@ -822,34 +695,23 @@ RgRguDedStaInd  *staInd;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 rgUIMSndCmnStaInd
+S16 rgUIMSndCmnStaInd
 (
 Inst            inst,
 RgUpSapCb    *rguDlSap,
 RgRguCmnStaInd  *staInd
 )
-#else
-PUBLIC S16 rgUIMSndCmnStaInd(inst,rguDlSap,staInd)
-Inst          inst,
-RgUpSapCb    *rguDlSap,
-RgRguCmnStaInd  *staInd;
-#endif
 {
    S16  ret = ROK;
 
-
-   TRC2(rgUIMSndCmnStaInd)
-   
-
    ret = RgUiRguCStaInd(&(rguDlSap->sapCfg.sapPst), rguDlSap->sapCfg.suId, 
          staInd);
    if (ret != ROK)
    {
-      RLOG_ARG0(L_ERROR,DBG_CELLID,staInd->cellId,"RgUiRguCStaInd Failed");
-      RETVALUE(ret);
+      DU_LOG("\nERROR  -->  MAC : RgUiRguCStaInd Failed");
+      return (ret);
    }
-   RETVALUE(ret);
+   return (ret);
 }  /* rgUIMSndCmnStaInd */
 
 
@@ -871,40 +733,29 @@ RgRguCmnStaInd  *staInd;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 rgUIMSndDedDatInd
+S16 rgUIMSndDedDatInd
 (
 Inst         inst,
 RgUpSapCb    *rguUlSap,
 RgRguDedDatInd  *datInd
 )
-#else
-PUBLIC S16 rgUIMSndDedDatInd(datInd)
-Inst         inst;
-RgUpSapCb    *rguUlSap;
-RgRguDedDatInd  *datInd;
-#endif
 {
    S16  ret = ROK;
 
-
-   TRC2(rgUIMSndDedDatInd)
-   
-
    rguUlSap->sapSts.numPduTxmit += datInd->numLch;
 #ifndef SS_RBUF
    ret = RgUiRguDDatInd(&(rguUlSap->sapCfg.sapPst), rguUlSap->sapCfg.suId, 
          datInd);
    if (ret != ROK)
    {
-      RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"RgUiRguDdatInd Failed");
-      RETVALUE(ret);
+      DU_LOG("\nERROR  -->  MAC : RgUiRguDdatInd Failed");
+      return (ret);
    }
 #else
    SRngIncrWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
    SsRngInfoTbl[SS_RNG_BUF_ULMAC_TO_ULRLC].pktRate++;
 #endif
-   RETVALUE(ret);
+   return (ret);
 }  /* rgUIMSndDedDatInd */
 
 
@@ -926,39 +777,23 @@ RgRguDedDatInd  *datInd;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 rgUIMSndCmnDatInd
-(
-Inst         inst,
-RgUpSapCb    *rguUlSap,
-RgRguCmnDatInd  *datInd
-)
-#else
-PUBLIC S16 rgUIMSndCmnDatInd(datInd)
-Inst         inst;
-RgUpSapCb    *rguUlSap;
-RgRguCmnDatInd  *datInd;
-#endif
+S16 rgUIMSndCmnDatInd(Inst inst,RgUpSapCb *rguUlSap,RgRguCmnDatInd  *datInd)
 {
    S16  ret = ROK;
 
-   TRC2(rgUIMSndCmnDatInd)
-
-
-   RGDBGPRM(inst,(rgPBuf(inst),"rgUIMSndCmnDatInd(): staInd = %p;\n", (void *)datInd));
+   DU_LOG("\nDEBUG  -->  MAC : rgUIMSndCmnDatInd(): staInd = %p;\n", (void *)datInd);
 
    rguUlSap->sapSts.numPduTxmit++;
 
-   RGDBGPRM(inst,(rgPBuf(inst),"rgUIMSndCmnDatInd suId = %d\n", rguUlSap->sapCfg.suId));   
+   DU_LOG("\nDEBUG  -->  MAC : rgUIMSndCmnDatInd suId = %d\n", rguUlSap->sapCfg.suId);   
    ret = RgUiRguCDatInd(&(rguUlSap->sapCfg.sapPst), rguUlSap->sapCfg.suId, 
          datInd);
    if (ret != ROK)
    {
-      RGDBGERRNEW(inst,(rgPBuf(inst),"RgUiRguCDatInd Failed\n"));
-      RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"RgUiRguCDatInd Failed");
-      RETVALUE(ret);
+      DU_LOG("\nERROR  -->  MAC : RgUiRguCDatInd Failed");
+      return (ret);
    }
-   RETVALUE(ret);
+   return (ret);
 }  /* rgUIMSndCmnDatInd */
 
 /**
@@ -980,28 +815,13 @@ RgRguCmnDatInd  *datInd;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiCrgBndReq
-(
-Pst   *pst, 
-SuId  suId,
-SpId  spId
-)
-#else
-PUBLIC S16 RgUiCrgBndReq(pst, suId, spId)
-Pst   *pst; 
-SuId  suId;
-SpId  spId;
-#endif
+S16 RgUiCrgBndReq(Pst   *pst, SuId  suId,SpId  spId)
 {
    S16       ret = ROK;
    Pst       tmpPst;   /* Temporary Post Structure */
    RgUstaDgn dgn;      /* Alarm diagnostics structure */
    Inst      inst;
 
-   TRC3(RgUiCrgBndReq)
-
-
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
 
@@ -1029,11 +849,11 @@ SpId  spId;
             rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM); 
             ret = rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE,LRG_NOT_CFG,
                   LCM_CAUSE_INV_SAP, &dgn);
-            RLOG0(L_DEBUG,"SAP Not Configured");
+            DU_LOG("\nDEBUG  -->  MAC : SAP Not Configured");
             ret = RgUiCrgBndCfm(&tmpPst, suId, CM_BND_NOK);
             break;
          case LRG_UNBND: /* SAP is not bound */
-            RLOG0(L_DEBUG,"SAP Not yet bound");
+            DU_LOG("\nERROR  -->  MAC : SAP Not yet bound");
             
             rgCb[inst].crgSap.sapSta.sapState = LRG_BND;
             rgCb[inst].crgSap.sapCfg.suId = suId;
@@ -1045,13 +865,13 @@ SpId  spId;
                   LCM_CAUSE_UNKNOWN, &dgn);
             break;
          case LRG_BND: /* SAP is already bound*/
-            RLOG0(L_DEBUG,"SAP is already bound");
+            DU_LOG("\nDEBUG  -->  MAC : SAP is already bound");
             
             ret = rgUIMCrgBndCfm(inst,suId, CM_BND_OK);
             break;
          default: /* Should Never Enter here */
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-            RLOG1(L_ERROR,"Invalid SAP State:%d RgUiCrgBndReq failed",
+            DU_LOG("\nERROR  -->  MAC : Invalid SAP State:%d RgUiCrgBndReq failed",
                   rgCb[inst].crgSap.sapSta.sapState);
 #endif
             ret = rgUIMCrgBndCfm(inst,suId, CM_BND_NOK);
@@ -1061,12 +881,12 @@ SpId  spId;
    else
    {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-      RLOG1(L_ERROR,"Invalid SAP Id:%d RgUiCrgBndReq failed",
+      DU_LOG("\nERROR  -->  MAC : Invalid SAP Id:%d RgUiCrgBndReq failed",
            rgCb[inst].crgSap.sapCfg.spId);
 #endif
       ret = rgUIMCrgBndCfm(inst,suId, CM_BND_NOK);
    }
-   RETVALUE(ret);
+   return (ret);
 }  /* RgUiCrgBndReq */
 
 
@@ -1088,23 +908,9 @@ SpId  spId;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiCrgUbndReq
-(
-Pst    *pst,
-SpId   spId,
-Reason reason
-)
-#else
-PUBLIC S16 RgUiCrgUbndReq(pst, spId, reason)
-Pst    *pst; 
-SpId   spId;
-Reason reason;
-#endif
+S16 RgUiCrgUbndReq(Pst *pst,SpId spId,Reason reason)
 {
    Inst      inst;
-   TRC3(RgUiCrgUbndReq)
-
 
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
@@ -1115,27 +921,27 @@ Reason reason;
       {
          case LRG_BND: /* SAP is already bound*/
             /* setting SAP state to UN BOUND */
-            RLOG0(L_DEBUG, "SAP is already bound");
+            DU_LOG("\nDEBUG  -->  MAC : SAP is already bound");
             
             rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
             break;
          default:
 #if (ERRCLASS & ERRCLS_ADD_RES)
-            RLOG1(L_ERROR,"Invalid SAP State:%d RgUiCrgUbndReq failed",
+            DU_LOG("\nERROR  -->  MAC : Invalid SAP State:%d RgUiCrgUbndReq failed",
                   rgCb[inst].crgSap.sapSta.sapState);
 #endif
-            RETVALUE(RFAILED);
+            return RFAILED;
       }
    }
    else
    {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-      RLOG1(L_ERROR,"Invalid SAP Id:%d RgUiCrgUbndReq failed",
+      DU_LOG("\nERROR  -->  MAC : Invalid SAP Id:%d RgUiCrgUbndReq failed",
             rgCb[inst].crgSap.sapCfg.spId);
 #endif
-      RETVALUE(RFAILED);
+      return RFAILED;
    }
-   RETVALUE(ROK);
+   return ROK;
 }  /* RgUiCrgUbndReq */
 
 /**
@@ -1151,35 +957,21 @@ Reason reason;
  *           
  *  @param[in] Inst        inst
  *  @param[in]  SuId          suId
- *  @param[in]  U8            status
+ *  @param[in]  uint8_t            status
  *  @return  S16
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 rgUIMCrgBndCfm
-(
-Inst  inst,
-SuId suId,
-U8 status
-)
-#else
-PUBLIC S16 rgUIMCrgBndCfm(inst,suId, status)
-Inst          inst;
-SuId          suId;
-U8            status;
-#endif
+S16 rgUIMCrgBndCfm(Inst  inst,SuId suId,uint8_t status)
 {
-   TRC2(rgUIMCrgBndCfm)
-   
 
    if(RgUiCrgBndCfm(&(rgCb[inst].crgSap.sapCfg.sapPst), rgCb[inst].crgSap.sapCfg.suId, status) != ROK)
    {
-      RLOG0(L_ERROR,"RgUiCrgBndCfm Failed ");
-      RETVALUE(RFAILED);
+      DU_LOG("\nERROR  -->  MAC : RgUiCrgBndCfm Failed ");
+      return RFAILED;
    }
 
-   RETVALUE(ROK);
+   return ROK;
 }  /* rgUIMCrgBndCfm*/
 
 /**
@@ -1202,42 +994,32 @@ U8            status;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 RgUiCrgCfgReq
+S16 RgUiCrgCfgReq
 (
 Pst           *pst, 
 SpId          spId,
 CrgCfgTransId transId,
 CrgCfgReqInfo *cfgReqInfo
 )
-#else
-PUBLIC S16 RgUiCrgCfgReq(pst, spId, transId, cfgReqInfo)
-Pst           *pst; 
-SpId          spId;
-CrgCfgTransId transId;
-CrgCfgReqInfo *cfgReqInfo;
-#endif
 {
    Inst      inst;
    S16       ret       = ROK;
-   U8        cfmStatus = 0x00ff;
-   U8        prntTrans[CRG_CFG_TRANSID_SIZE+1];
-
-   TRC3(RgUiCrgCfgReq);
+   uint8_t   cfmStatus = 0x00ff;
+   uint8_t   prntTrans[CRG_CFG_TRANSID_SIZE+1];
 
    RG_IS_INST_VALID(pst->dstInst);
    inst = pst->dstInst - RG_INST_START;
    /* Ensuring transId is always Null terminated. */
-   cmMemcpy((U8 *)prntTrans, (U8 *)transId.trans, CRG_CFG_TRANSID_SIZE);
+   memcpy(prntTrans, transId.trans, CRG_CFG_TRANSID_SIZE);
    prntTrans[CRG_CFG_TRANSID_SIZE] = '\0';
 
 
    /* CrgCfgReqInfo Validation for NULLP */
    if (cfgReqInfo == NULLP)
    {
-      RLOG0(L_ERROR,"Input Param crgReqInfo is NULL ");
+      DU_LOG("\nERROR  -->  MAC : Input Param crgReqInfo is NULL ");
       rgUIMCrgCfgCfm(inst,transId, cfmStatus); 
-      RETVALUE(RFAILED);
+      return RFAILED;
    }
 
    /* Upper SAP Id and State validation */
@@ -1246,44 +1028,38 @@ CrgCfgReqInfo *cfgReqInfo;
       switch(rgCb[inst].crgSap.sapSta.sapState)
       {
          case LRG_BND: /* SAP is already bound */
-            RLOG0(L_DEBUG,"SAP is already bound");
+            DU_LOG("\nDEBUG  -->  MAC : SAP is already bound");
             break;
          default: /* Should never reach here */
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-            RLOG1(L_ERROR,"Invalid SAP State:%d RgUiCrgCfgReq failed",
+           DU_LOG("\nERROR  -->  MAC : Invalid SAP State:%d RgUiCrgCfgReq failed",
                   rgCb[inst].crgSap.sapSta.sapState);
 #endif
-         SPutSBuf (pst->region, pst->pool, (Data *)cfgReqInfo,
-               sizeof(CrgCfgReqInfo));
-         cfgReqInfo = NULLP;
+           MAC_FREE(cfgReqInfo, sizeof(CrgCfgReqInfo));
 
-            rgUIMCrgCfgCfm(inst,transId, cfmStatus);
-            RETVALUE(RFAILED);
+           rgUIMCrgCfgCfm(inst,transId, cfmStatus);
+           return RFAILED;
       }
    }
    else
    {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
-      RLOG1(L_ERROR,"Invalid SAP Id:%d RgUiCrgCfgReq failed",
+      DU_LOG("\nERROR  -->  MAC : Invalid SAP Id:%d RgUiCrgCfgReq failed",
             rgCb[inst].crgSap.sapCfg.spId);
 #endif
-      SPutSBuf (pst->region, pst->pool, (Data *)cfgReqInfo,
-            sizeof(CrgCfgReqInfo));
-      cfgReqInfo = NULLP;
+      MAC_FREE(cfgReqInfo, sizeof(CrgCfgReqInfo));
       rgUIMCrgCfgCfm(inst,transId, cfmStatus); 
-      RETVALUE(RFAILED);
+      return RFAILED;
    }
    ret = rgCOMCfgReq(inst,transId, cfgReqInfo);
-   SPutSBuf (pst->region, pst->pool, (Data *)cfgReqInfo,
-         sizeof(CrgCfgReqInfo));
-   cfgReqInfo = NULLP;
+   MAC_FREE(cfgReqInfo, sizeof(CrgCfgReqInfo));
    if (ret != ROK)
    {
-      RLOG0(L_ERROR,"Configuration Request Handling Failed ");
-      RETVALUE(RFAILED);
+      DU_LOG("\nERROR  -->  MAC : Configuration Request Handling Failed ");
+      return RFAILED;
    }
 
-   RETVALUE(ROK);
+   return ROK;
 }  /* RgUiCrgCfgReq */
 
 /**
@@ -1299,67 +1075,50 @@ CrgCfgReqInfo *cfgReqInfo;
  *           
  *  @param[in] Inst        inst
  *  @param[in]  CrgCfgTransId transId
- *  @param[in]  U8            status
+ *  @param[in]  uint8_t            status
  *  @return  S16
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PUBLIC S16 rgUIMCrgCfgCfm
+S16 rgUIMCrgCfgCfm
 (
 Inst      inst,
 CrgCfgTransId transId,
-U8            status
+uint8_t       status
 )
-#else
-PUBLIC S16 rgUIMCrgCfgCfm(inst,transId, status)
-Inst      inst;
-CrgCfgTransId transId;
-U8            status;
-#endif
 {
    S16  ret = ROK;
-   U8   prntTrans[CRG_CFG_TRANSID_SIZE+1];
+   uint8_t   prntTrans[CRG_CFG_TRANSID_SIZE+1];
 
-   TRC2(rgUIMCrgCfgCfm)
-   
-   cmMemcpy((U8 *)prntTrans, (U8 *)transId.trans, CRG_CFG_TRANSID_SIZE);
+   memcpy(prntTrans, transId.trans, CRG_CFG_TRANSID_SIZE);
    prntTrans[CRG_CFG_TRANSID_SIZE] = '\0';
 
 
    ret = RgUiCrgCfgCfm(&(rgCb[inst].crgSap.sapCfg.sapPst), rgCb[inst].crgSap.sapCfg.suId, transId, status);
    if (ret != ROK)
    {
-      RLOG0(L_ERROR,"RgUiCrgCfgCfm Failed ");
-      RETVALUE(ret);
+      DU_LOG("\nERROR  -->  MAC : RgUiCrgCfgCfm Failed ");
+      return (ret);
    }
 
-   RETVALUE(ret);
+   return (ret);
 }  /* rgUIMCrgCfgCfm */
 #if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF)
 
-#ifdef ANSI
-PUBLIC S16 rgBatchProc
-(
-Void
-)
-#else
-PUBLIC S16 rgBatchProc()
-Void;
-#endif
+S16 rgBatchProc(Void)
 {
 /* Read from Ring Buffer and process RLC BO Update */
    Pst pst = {0};
    SpId spId = 0;
    RguDStaRspInfo  *staRsp;
-   U32 elmIndx = 0;
+   uint32_t elmIndx = 0;
 #ifndef LTE_ADV
 /* Fill pst */
    pst.srcProcId = 1;
    pst.dstProcId = 1;
-   pst.dstEnt = ENTRG;
+   pst.dstEnt = ENTMAC;
    pst.dstInst = 0;
-   pst.srcEnt = ENTKW;
+   pst.srcEnt = ENTRLC;
    pst.srcInst = 1;
    pst.prior = PRIOR0;
    pst.route = RTESPEC;
@@ -1370,7 +1129,7 @@ Void;
 #else
 #endif
   
-   elmIndx = (U32)SRngGetRIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
+   elmIndx = (uint32_t)SRngGetRIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
    while(NULLP != elmIndx)
    {
       staRsp = (RguDStaRspInfo *)elmIndx;
@@ -1383,10 +1142,10 @@ Void;
       staRsp = NULLP;
       SRngIncrRIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
 
-      if((elmIndx = (U32)SRngGetRIndx(SS_RNG_BUF_DLRLC_TO_DLMAC)) == NULLP)
+      if((elmIndx = (uint32_t)SRngGetRIndx(SS_RNG_BUF_DLRLC_TO_DLMAC)) == NULLP)
       break;
    }
-   RETVALUE(ROK);
+   return ROK;
 }
 #endif