[Epic-ID: ODUHIGH-464][Task-ID: ODUHIGH-483] Memeory related fix in FDD and TDD mode
[o-du/l2.git] / src / 5gnrmac / rg_dux.c
index 8466d3a..55d7080 100755 (executable)
@@ -32,9 +32,6 @@
 @brief This module handles de-multiplexing of the data recieved at MAC.
 */
 
-static const char* RLOG_MODULE_NAME="MAC";
-static int RLOG_FILE_ID=176;
-static int RLOG_MODULE_ID=4096;
 /* header include files -- defines (.h) */
 #include "common_def.h"
   
@@ -111,8 +108,8 @@ static int RLOG_MODULE_ID=4096;
    _ret = SRemPreMsgMult(_unpkArray, (MsgLen) 2, _mBuf);\
    if (_ret == ROK)\
    {\
-      *_rnti = (U16) PutHiByte(*_rnti, (U8) _unpkArray[0]);\
-      *_rnti = (U16) PutLoByte(*_rnti, (U8) _unpkArray[1]);\
+      *_rnti = (uint16_t) PutHiByte(*_rnti, (uint8_t) _unpkArray[0]);\
+      *_rnti = (uint16_t) PutLoByte(*_rnti, (uint8_t) _unpkArray[1]);\
    }\
 }
 
@@ -148,35 +145,16 @@ static int RLOG_MODULE_ID=4096;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PRIVATE S16 rgDUXInsSdu
-(
-Inst        inst,
-RgMacPdu    *pdu,
-RgMacSdu    **sdu,
-U8          lcId,
-U16         sduLen,
-RgErrInfo   *err
-)
-#else
-PRIVATE S16 rgDUXInsSdu(inst,pdu, sdu, lcId, sduLen, err)
-Inst        inst;
-RgMacPdu    *pdu;
-RgMacSdu    **sdu,
-U8          lcId;
-U16         sduLen;
-RgErrInfo   *err;
-#endif
+static S16 rgDUXInsSdu(Inst inst, RgMacPdu *pdu, RgMacSdu **sdu, uint8_t lcId, uint16_t sduLen, RgErrInfo *err)
 {
    S16         ret;
    RgMacSdu    *sduAloc = NULLP;
 
-   TRC2(rgDUXInsSdu)
 
    RG_DUX_ALLOC(pdu, sizeof(RgMacSdu), sduAloc, ret);
    if(ret != ROK)
    {
-      RLOG1(L_ERROR, "Allocation of RgSubHdr failed for LCID:%d",lcId);
+      DU_LOG("\nERROR  -->  MAC : Allocation of RgSubHdr failed for LCID:%d",lcId);
       err->errCause = RGERR_DUX_MEM_EXHAUST;
       return RFAILED;
    }
@@ -208,36 +186,16 @@ RgErrInfo   *err;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PRIVATE S16 rgDUXExtSubHdr
-(
-Inst        inst,
-RgMacPdu    *pdu,
-Buffer      *mBuf,
-U8          *lcId,
-U16         *len,
-RgErrInfo   *err
-)
-#else
-PRIVATE S16 rgDUXExtSubHdr(inst,pdu, mBuf, lcId,
-len, err)
-Inst        inst;
-RgMacPdu    *pdu;
-Buffer      *mBuf;
-U8          *lcId;
-U16         *len;
-RgErrInfo   *err;
-#endif
+static S16 rgDUXExtSubHdr(Inst inst, RgMacPdu *pdu, Buffer *mBuf, uint8_t *lcId, uint16_t *len, RgErrInfo *err)
 {
-   U8             byte;
-   U8             fmt=0;
+   uint8_t             byte;
+   uint8_t             fmt=0;
  
-   TRC2(rgDUXExtSubHdr)
 
    *len = 0;   
    if(oduPackUInt8(&byte,mBuf) != ROK)
    {
-      RLOG0(L_ERROR, "oduPackUInt8 failed");
+      DU_LOG("\nERROR  -->  MAC : oduPackUInt8 failed");
       err->errCause = RGERR_DUX_UNPACK_FAILURE;
       return RFAILED;
    }
@@ -250,7 +208,7 @@ RgErrInfo   *err;
       RG_EXT_FORMT_BIT(fmt,byte);
       if(oduPackUInt8(&byte, mBuf) != ROK)
       {
-         RLOG0(L_ERROR, "oduPackUInt8 failed");
+         DU_LOG("\nERROR  -->  MAC : oduPackUInt8 failed");
          err->errCause = RGERR_DUX_UNPACK_FAILURE;
          return RFAILED;
       }
@@ -259,7 +217,7 @@ RgErrInfo   *err;
       {
          if(oduPackUInt8(&byte,mBuf) != ROK)
          {
-            RLOG0(L_ERROR, "oduPackUInt8 failed");
+            DU_LOG("\nERROR  -->  MAC : oduPackUInt8 failed");
             err->errCause = RGERR_DUX_UNPACK_FAILURE;
             return RFAILED;
          }
@@ -292,46 +250,26 @@ RgErrInfo   *err;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PRIVATE S16 rgDUXExtCe
-(
-Inst        inst,
-RgMacPdu    *pdu,
-RgInfCeInfo  *ceInfo,
-Buffer       *mBuf,
-U8          lcId,
-U16         subPduLen,
-RgErrInfo    *err
-)
-#else
-PRIVATE S16 rgDUXExtCe(inst,pdu, ceInfo, mBuf,lcId,subPduLen, err)
-Inst        inst;
-RgMacPdu    *pdu;
-RgInfCeInfo  *ceInfo;
-Buffer       *mBuf;
-U8          lcId;
-U16         subPduLen;
-RgErrInfo    *err;
-#endif
+static S16 rgDUXExtCe(Inst inst, RgMacPdu *pdu, RgInfCeInfo *ceInfo, Buffer *mBuf, uint8_t lcId, uint16_t subPduLen,\
+RgErrInfo *err)
 {
    S16            ret;
 
-   TRC2(rgDUXExtCe);
 
    switch(lcId)
    {
       case RG_EXT_PHR_LCID:
          {
-            U8 Ci;
-            U8 sCellIdx;
-            U8 extPhrOctet;
-            U8 extPhrPCmax;
+            uint8_t Ci;
+            uint8_t sCellIdx;
+            uint8_t extPhrOctet;
+            uint8_t extPhrPCmax;
             RgInfExtPhrCEInfo *extPhr;
 
             RG_UNPACK_EXT_PHR_CI(&Ci,mBuf,ret);
             if(ret != ROK)
             {
-               RLOG1(L_ERROR,"Unpacking of EXT PHR failed LCID:%d",lcId);
+               DU_LOG("\nERROR  -->  MAC : Unpacking of EXT PHR failed LCID:%d",lcId);
                err->errCause = RGERR_DUX_UNPACK_FAILURE;
                return RFAILED;
             }
@@ -352,7 +290,7 @@ RgErrInfo    *err;
                   RG_UNPACK_EXT_PHR(&extPhrOctet,mBuf,ret);
                   if(ret != ROK)
                   {
-                     RLOG1(L_ERROR,"Unpacking of EXT PHR failed LCID:%d",lcId);
+                     DU_LOG("\nERROR  -->  MAC : Unpacking of EXT PHR failed LCID:%d",lcId);
                      err->errCause = RGERR_DUX_UNPACK_FAILURE;
                      return RFAILED;
                   }
@@ -376,7 +314,7 @@ RgErrInfo    *err;
                      RG_UNPACK_EXT_PHR(&extPhrPCmax,mBuf,ret);
                      if(ret != ROK)
                      {
-                        RLOG1(L_ERROR,"Unpacking of EXT PHR failed LCID:%d",lcId);
+                        DU_LOG("\nERROR  -->  MAC : Unpacking of EXT PHR failed LCID:%d",lcId);
                         err->errCause = RGERR_DUX_UNPACK_FAILURE;
                         return RFAILED;
                      }
@@ -396,7 +334,7 @@ RgErrInfo    *err;
             RG_UNPACK_PHR(&ceInfo->ces.phr,mBuf,ret);
             if(ret != ROK)
             {
-               RLOG1(L_ERROR,"Unpacking of PHR failed LCID:%d",lcId);
+               DU_LOG("\nERROR  -->  MAC : Unpacking of PHR failed LCID:%d",lcId);
                err->errCause = RGERR_DUX_UNPACK_FAILURE;
                return RFAILED;
             }
@@ -408,7 +346,7 @@ RgErrInfo    *err;
             RG_UNPACK_TRUNC_BSR(&ceInfo->ces.bsr.truncBsr,mBuf,ret);
             if(ret != ROK)
             {
-               RLOG1(L_ERROR,"Unpacking of Trunc BSR failed LCID:%d",lcId);
+               DU_LOG("\nERROR  -->  MAC : Unpacking of Trunc BSR failed LCID:%d",lcId);
                err->errCause = RGERR_DUX_UNPACK_FAILURE;
                return RFAILED;
             }
@@ -420,7 +358,7 @@ RgErrInfo    *err;
             RG_UNPACK_SHORT_BSR(&ceInfo->ces.bsr.shortBsr,mBuf,ret);
             if(ret != ROK)
             {
-               RLOG1(L_ERROR,"Unpacking of Short BSR failed LCID:%d",lcId);
+               DU_LOG("\nERROR  -->  MAC : Unpacking of Short BSR failed LCID:%d",lcId);
                err->errCause = RGERR_DUX_UNPACK_FAILURE;
                return RFAILED;
             }
@@ -429,11 +367,11 @@ RgErrInfo    *err;
          break;
       case RG_LONG_BSR_LCID:
          {
-            U8 longBsr[3] = {0}; /* KW_FIXX */
+            uint8_t longBsr[3] = {0}; /* KW_FIXX */
             RG_UNPACK_LONG_BSR(longBsr,mBuf,ret);
             if(ret != ROK)
             {
-               RLOG1(L_ERROR,"Unpacking of Long BSR failed LCID:%d",lcId);
+               DU_LOG("\nERROR  -->  MAC : Unpacking of Long BSR failed LCID:%d",lcId);
                err->errCause = RGERR_DUX_UNPACK_FAILURE;
                return RFAILED;
             }
@@ -450,7 +388,7 @@ RgErrInfo    *err;
             RG_UNPACK_CRNTI(&ceInfo->ces.cRnti,mBuf,ret);
             if(ret != ROK)
             {
-               RLOG1(L_ERROR,"Unpacking of C-RNTI failed LCID:%d",lcId);
+               DU_LOG("\nERROR  -->  MAC : Unpacking of C-RNTI failed LCID:%d",lcId);
                err->errCause = RGERR_DUX_UNPACK_FAILURE;
                return RFAILED;
             }
@@ -458,7 +396,7 @@ RgErrInfo    *err;
          }
          break;
       default:
-         RLOG1(L_ERROR, "Invalid LCID:%u received",lcId); 
+         DU_LOG("\nERROR  -->  MAC : Invalid LCID:%u received",lcId); 
          err->errCause = RGERR_DUX_INV_LCID_RX;
          return RFAILED;
    }
@@ -489,34 +427,14 @@ RgErrInfo    *err;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-PRIVATE S16 rgDUXExtSdu
-(
-Inst        inst,
-RgMacPdu    *pdu,
-RgInfCeInfo  *ceInfo,
-Buffer      **mBuf,
-U8          lcId,
-U16         subPduLen,
-RgErrInfo   *err
-)
-#else
-PRIVATE S16 rgDUXExtSdu(inst,pdu, ceInfo,mBuf,lcId,subPduLen,err)
-Inst        inst;
-RgMacPdu    *pdu;
-RgInfCeInfo  *ceInfo;
-Buffer      **mBuf;
-U8          lcId;
-U16         subPduLen;
-RgErrInfo   *err;
-#endif
+static S16 rgDUXExtSdu(Inst inst, RgMacPdu *pdu, RgInfCeInfo *ceInfo, Buffer **mBuf, uint8_t lcId, uint16_t subPduLen,\
+RgErrInfo *err)
 {
    S16         ret;
    Buffer      *tmpBuf1;
    Buffer      *tmpBuf2 = NULLP;
    RgMacSdu    *sdu;
 
-   TRC2(rgDUXExtSdu)
 
    if(lcId == RG_CCCH_LCID)
    {
@@ -535,7 +453,7 @@ RgErrInfo   *err;
       if((ret != ROK) && (!((ret == ROKDNA) )))
       {
          RG_FREE_MSG(tmpBuf1);
-         RLOG0(L_ERROR,"SSegMsg failed");
+         DU_LOG("\nERROR  -->  MAC : SSegMsg failed");
          err->errCause = RGERR_DUX_RLC_PDU_CREAT_FAIL;
          return RFAILED;
       }
@@ -567,28 +485,11 @@ RgErrInfo   *err;
  *      -# ROK 
  *      -# RFAILED 
  **/
-#ifdef ANSI
-S16 rgDUXDemuxData
-(
-Inst          inst,
-RgMacPdu      *pdu,
-RgInfCeInfo   *ceInfo,
-Buffer        **mBuf,
-RgErrInfo     *err
-)
-#else
-S16 rgDUXDemuxData(inst,pdu, ceInfo, mBuf, err)
-Inst          inst;
-RgMacPdu      *pdu;
-RgInfCeInfo   *ceInfo;
-Buffer        **mBuf;
-RgErrInfo     *err;
-#endif
+S16 rgDUXDemuxData(Inst inst, RgMacPdu  *pdu, RgInfCeInfo *ceInfo, Buffer **mBuf, RgErrInfo *err)
 {
-   U8          lcId;
-   U16          subPduLen;
+   uint8_t     lcId;
+   uint16_t    subPduLen;
    MsgLen      len;  
-   TRC2(rgDUXDemuxData)
 
    ceInfo->bitMask = 0x0000;
 
@@ -597,7 +498,7 @@ RgErrInfo     *err;
 
    if(*mBuf == NULLP) 
    {
-      RLOG0(L_ERROR, "Null Buffer Recevived");
+      DU_LOG("\nERROR  -->  MAC : Null Buffer Recevived");
       return RFAILED;
    }
    do
@@ -609,7 +510,7 @@ RgErrInfo     *err;
                &subPduLen, err) != ROK)
       {
          RG_FREE_MSG(*mBuf);         
-         RLOG0(L_ERROR, "Failed to extract pad sub headers");
+         DU_LOG("\nERROR  -->  MAC : Failed to extract pad sub headers");
          return RFAILED;
       }
       if(lcId == RG_PAD_LCID)
@@ -625,7 +526,7 @@ RgErrInfo     *err;
             /* Fix : syed rgDUXExtSdu would have segmented mBuf and hence
              * will be responsible for freeing mBuf */
             *mBuf = NULLP;
-            RLOG0(L_ERROR, "failed to Extract the sdus");
+            DU_LOG("\nERROR  -->  MAC : failed to Extract the sdus");
             return RFAILED;
          }
          if(*mBuf == NULLP) /* if message read completes then return */
@@ -639,14 +540,14 @@ RgErrInfo     *err;
          if(rgDUXExtCe(inst,pdu,ceInfo,*mBuf, lcId,subPduLen, err) != ROK)
          {
             RG_FREE_MSG(*mBuf);              
-            RLOG0(L_ERROR, " failed to Extract the ces");
+            DU_LOG("\nERROR  -->  MAC : failed to Extract the ces");
             return RFAILED;
          }
       }
       if(SFndLenMsg(*mBuf,&len) != ROK)
       {
          RG_FREE_MSG(*mBuf);
-         RLOG0(L_ERROR,"mBuf length check failed");
+         DU_LOG("\nERROR  -->  MAC : mBuf length check failed");
          err->errCause = RGERR_DUX_UNPACK_FAILURE;
          return RFAILED;
       }