X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrmac%2Fmac_utils.h;h=09ce1976db30b7be5cd64d952c1443fa1cc22d39;hb=531da47c7bfb6ce138a454f66eb184729860beef;hp=899324e890da14f4ae16cba96bd8188eb62f6993;hpb=a5530e70a9d414952dadd1688aa9b4280c0dbb5a;p=o-du%2Fl2.git diff --git a/src/5gnrmac/mac_utils.h b/src/5gnrmac/mac_utils.h index 899324e89..09ce1976d 100644 --- a/src/5gnrmac/mac_utils.h +++ b/src/5gnrmac/mac_utils.h @@ -18,18 +18,31 @@ /* Contains common utility definitions to be used at MAC */ +#define MAX_SHORT_BSR_TABLE_ENTRIES 32 +#define MAX_LONG_BSR_TABLE_ENTRIES 256 #define MAC_MEM_REGION 4 #define MAC_POOL 1 +#ifdef ODU_MEMORY_DEBUG_LOG +#define MAC_MEM_LOG(_macro, _file, _line, _func, _size, _datPtr)\ +{\ + printf("\n%s,=== %s +%d, %s, %lu, %p \n", \ + _macro, _file, _line, _func, (uint64_t)_size, _datPtr); \ +} +#else +#define MAC_MEM_LOG(_macro, _file, _line, _func, _size, _dataPtr) {} +#endif + /* allocate and zero out a MAC static buffer */ #define MAC_ALLOC(_datPtr, _size) \ { \ uint8_t _ret; \ _ret = SGetSBuf(MAC_MEM_REGION, MAC_POOL, \ - (Data **)&_datPtr, _size); \ + (Data **)&_datPtr, _size); \ if(_ret == ROK) \ { \ - cmMemset((uint8_t *)_datPtr, 0, _size); \ + memset(_datPtr, 0, _size); \ + MAC_MEM_LOG("MAC,ALLOC", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\ } \ else \ { \ @@ -42,8 +55,10 @@ { \ if(_datPtr) \ { \ + MAC_MEM_LOG("MAC,FREE", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\ SPutSBuf(MAC_MEM_REGION, MAC_POOL, \ - (Data *)_datPtr, _size); \ + (Data *)_datPtr, _size); \ + _datPtr = NULLP; \ } \ } @@ -52,9 +67,10 @@ #define MAC_ALLOC_SHRABL_BUF(_buf, _size) \ { \ if(SGetStaticBuffer(MAC_MEM_REGION, MAC_POOL, \ - (Data **)&_buf, (Size) _size, 0) == ROK) \ + (Data **)&_buf, (Size) _size, 0) == ROK) \ { \ - cmMemset((uint8_t *)(_buf), 0, _size); \ + MAC_MEM_LOG("MAC,ALLOC_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\ + memset((_buf), 0, _size); \ } \ else \ { \ @@ -67,6 +83,7 @@ { \ if (_buf != NULLP) \ { \ + MAC_MEM_LOG("MAC,FREE_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\ (Void) SPutStaticBuffer(_region, _pool, \ (Data *) _buf, (Size) _size, 0); \ _buf = NULLP; \ @@ -77,7 +94,7 @@ #define FILL_PST_MAC_TO_DUAPP(_pst, _event) \ { \ _pst.selector = ODU_SELECTOR_LWLC; \ - _pst.srcEnt = ENTRG; \ + _pst.srcEnt = ENTMAC; \ _pst.dstEnt = ENTDUAPP; \ _pst.dstInst = 0; \ _pst.srcInst = macCb.macInst; \ @@ -95,8 +112,8 @@ #define FILL_PST_MAC_TO_SCH(_pst, _event) \ { \ _pst.selector = ODU_SELECTOR_TC; \ - _pst.srcEnt = ENTRG; \ - _pst.dstEnt = ENTRG; \ + _pst.srcEnt = ENTMAC; \ + _pst.dstEnt = ENTMAC; \ _pst.dstInst = 1; \ _pst.srcInst = macCb.macInst; \ _pst.dstProcId = macCb.procId; \ @@ -109,6 +126,28 @@ _pst.intfVer = 0; \ } +/* Fills Pst to send msg to RLC */ +#define FILL_PST_MAC_TO_RLC(_pst, _dstInst, _event) \ +{ \ + pst.selector = ODU_SELECTOR_LWLC; \ + pst.srcEnt = ENTMAC; \ + pst.dstEnt = ENTRLC; \ + pst.dstInst = _dstInst; \ + pst.srcInst = macCb.macInst; \ + pst.dstProcId = macCb.procId; \ + pst.srcProcId = macCb.procId; \ + pst.region = MAC_MEM_REGION; \ + pst.pool = MAC_POOL; \ + pst.event = _event; \ + pst.route = 0; \ + pst.prior = 0; \ + pst.intfVer = 0; \ +} + +/* Function declaration */ +uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES]; +uint32_t longBsrBytesTable[MAX_LONG_BSR_TABLE_ENTRIES]; + /********************************************************************** End of file **********************************************************************/