X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrmac%2Fmac_utils.h;h=99b07e442461946673d4d57d003556bf178a14bc;hb=fc7d3ce9647a7da04f5a67fa34419076069defc1;hp=f982b6abda315d830a2c16f38601fe01d861b95b;hpb=9f07d42c8d327e4009833fc4c673e4086c4e726e;p=o-du%2Fl2.git diff --git a/src/5gnrmac/mac_utils.h b/src/5gnrmac/mac_utils.h index f982b6abd..99b07e442 100644 --- a/src/5gnrmac/mac_utils.h +++ b/src/5gnrmac/mac_utils.h @@ -23,11 +23,22 @@ #define MAC_MEM_REGION 4 #define MAC_POOL 1 +/* allocate and zero out a static buffer */ + +#ifdef MEM_SIZE_CHECK +#define MAC_MEMORY_ALLOC_SIZE_LOG(_line, _func, _size) \ +{\ + DU_LOG("\n MAC line = %d, func = %s, _size= %d ", _line, _func, _size); \ +} +#else +#define MAC_MEMORY_ALLOC_SIZE_LOG(_line, _func, _size) {} +#endif + #ifdef ODU_MEMORY_DEBUG_LOG #define MAC_MEM_LOG(_macro, _file, _line, _func, _size, _datPtr)\ {\ - printf("\n%s=== %s +%d, %s, %d, %p\n", \ - _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) {} @@ -36,13 +47,14 @@ /* allocate and zero out a MAC static buffer */ #define MAC_ALLOC(_datPtr, _size) \ { \ + MAC_MEMORY_ALLOC_SIZE_LOG(__LINE__, __FUNCTION__, _size); \ uint8_t _ret; \ _ret = SGetSBuf(MAC_MEM_REGION, MAC_POOL, \ (Data **)&_datPtr, _size); \ if(_ret == ROK) \ { \ memset(_datPtr, 0, _size); \ - MAC_MEM_LOG("MAC_ALLOC", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\ + MAC_MEM_LOG("MAC,ALLOC", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\ } \ else \ { \ @@ -55,7 +67,7 @@ { \ if(_datPtr) \ { \ - MAC_MEM_LOG("MAC_FREE", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\ + MAC_MEM_LOG("MAC,FREE", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\ SPutSBuf(MAC_MEM_REGION, MAC_POOL, \ (Data *)_datPtr, _size); \ _datPtr = NULLP; \ @@ -66,10 +78,11 @@ * during inter-layer communication */ #define MAC_ALLOC_SHRABL_BUF(_buf, _size) \ { \ + MAC_MEMORY_ALLOC_SIZE_LOG(__LINE__, __FUNCTION__, _size); \ if(SGetStaticBuffer(MAC_MEM_REGION, MAC_POOL, \ (Data **)&_buf, (Size) _size, 0) == ROK) \ { \ - MAC_MEM_LOG("MAC_ALLOC_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\ + MAC_MEM_LOG("MAC,ALLOC_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\ memset((_buf), 0, _size); \ } \ else \ @@ -83,7 +96,7 @@ { \ if (_buf != NULLP) \ { \ - MAC_MEM_LOG("MAC_FREE_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\ + MAC_MEM_LOG("MAC,FREE_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\ (Void) SPutStaticBuffer(_region, _pool, \ (Data *) _buf, (Size) _size, 0); \ _buf = NULLP; \ @@ -145,8 +158,8 @@ } /* Function declaration */ -uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES]; -uint32_t longBsrBytesTable[MAX_LONG_BSR_TABLE_ENTRIES]; +extern uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES]; +extern uint32_t longBsrBytesTable[MAX_LONG_BSR_TABLE_ENTRIES]; /********************************************************************** End of file