[Epic-ID: ODUHIGH-464][Task-ID: ODUHIGH-483] Memeory related fix in FDD and TDD mode
[o-du/l2.git] / src / cm / common_def.c
index 2321783..184d1d7 100644 (file)
@@ -155,7 +155,7 @@ uint8_t buildPlmnId(Plmn plmn, uint8_t *buf)
  *
  * @details
  *
- *    Function : fetchScsValue
+ *    Function : convertScsEnumValToScsVal
  *
  *    Functionality:
  *       Function to map Sub carrier spacing enum value to value in kHz
@@ -164,7 +164,7 @@ uint8_t buildPlmnId(Plmn plmn, uint8_t *buf)
  * @return sub-carrier spacing value in kHz
  *
  * ****************************************************************/
-uint16_t fetchScsValue(uint8_t scsEnumValue)
+uint16_t convertScsEnumValToScsVal(uint8_t scsEnumValue)
 {
    switch(scsEnumValue)
    {
@@ -179,6 +179,87 @@ uint16_t fetchScsValue(uint8_t scsEnumValue)
    }
 }
 
+/*******************************************************************
+ * @brief convert scs offset value into the enum value received from O1 
+ *
+ * @details
+ *
+ *    Function : convertScsValToScsEnum
+ *
+ *    Functionality:
+ *       - convert scs periodicity value 
+ *
+ * @params[in] uint32_t num
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t convertScsValToScsEnum(uint32_t num)
+{
+   switch(num)
+   {
+      case 15:
+         return SCS_15KHZ;
+
+      case 30:
+         return SCS_30KHZ;
+
+      case 60:
+         return SCS_60KHZ;
+
+      case 120:
+         return SCS_120KHZ;
+      
+      case 240:
+         return SCS_240KHZ;
+      
+      default:
+         return SCS_15KHZ;
+   }
+}
+
+/*******************************************************************
+ * @brief convert scs periodicity value into the enum value received from O1 
+ *
+ * @details
+ *
+ *    Function : convertScsPeriodicityToEnum
+ *
+ *    Functionality:
+ *       - convert scs periodicity value 
+ *
+ * @params[in] uint32_t num
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t convertScsPeriodicityToEnum(uint32_t num)
+{
+   switch(num)
+   {
+      case 5:
+         return SCS_5MS;
+
+      case 10:
+         return SCS_10MS;
+
+      case 20:
+         return SCS_20MS;
+
+      case 40:
+         return SCS_40MS;
+
+      case 80:
+         return SCS_80MS;
+
+      case 160:
+         return SCS_160MS;
+
+      default:
+         return SCS_5MS;
+   }
+}
 /*******************************************************************
 *
 * @brief  SGetSBuf with debug logs
@@ -195,13 +276,16 @@ uint16_t fetchScsValue(uint8_t scsEnumValue)
 *         RFAILED - failure
 *
 * ****************************************************************/
-uint8_t SGetSBufNewForDebug(char *file, char *func, char *line, Region region, Pool pool, Data **ptr, Size size)
+uint8_t SGetSBufNewForDebug(char *file, const char *func, int line, Region region, Pool pool, Data **ptr, Size size)
 {
    if(SGetSBuf(region, pool, ptr, size) == ROK)
    {
 #ifdef ODU_MEMORY_DEBUG_LOG
-      printf("\nCM_ALLOC=== SGetSBufNewForDebug %s +%d, %s, %d, %p\n",\
+      if (strncmp(func,"cmInetRecvMsg",sizeof("cmInetRecvMsg")))
+      {
+         printf("\nCM_ALLOC=== SGetSBufNewForDebug %s +%d, %s, %d, %p \n",\
          file, line, func, size, *ptr);
+      }
 #endif
       return ROK;
    }
@@ -225,13 +309,16 @@ uint8_t SGetSBufNewForDebug(char *file, char *func, char *line, Region region, P
 *         RFAILED - failure
 *
 * ****************************************************************/
-uint8_t SPutSBufNewForDebug(char *file, char *func, char *line, Region region, Pool pool, Data *ptr, Size size)
+uint8_t SPutSBufNewForDebug(char *file, const char *func, int line, Region region, Pool pool, Data *ptr, Size size)
 {
    if(SPutSBuf(region, pool, ptr, size) == ROK)
    {
 #ifdef ODU_MEMORY_DEBUG_LOG
-      printf("\nCM_FREE=== SPutSBufNewForDebug %s +%d, %s, %d, %p\n",\
+      if (strncmp(func,"cmInetRecvMsg",sizeof("cmInetRecvMsg")))
+      {
+         printf("\nCM_FREE=== SPutSBufNewForDebug %s +%d, %s, %d, %p \n",\
          file, line, func, size, ptr);
+      }
 #endif
       return ROK;
    }
@@ -256,13 +343,13 @@ uint8_t SPutSBufNewForDebug(char *file, char *func, char *line, Region region, P
 *         RFAILED - failure
 *
 * ****************************************************************/
-uint8_t SGetStaticBufNewForDebug(char *file, char *func, char *line, \
+uint8_t SGetStaticBufNewForDebug(char *file, const char *func, int line, \
 Region region, Pool pool, Data **ptr, Size size, uint8_t memType)
 {
    if(SGetStaticBuffer(region, pool, ptr, size, memType) == ROK)
    {
 #ifdef ODU_MEMORY_DEBUG_LOG
-      printf("\nCM_ALLOC=== SGetStaticBufNewForDebug %s +%d, %s, %d, %p\n",\
+      printf("\nCM_ALLOC=== SGetStaticBufNewForDebug %s +%d, %s, %d, %p \n",\
          file, line, func, size, *ptr);
 #endif
       return ROK;
@@ -287,13 +374,13 @@ Region region, Pool pool, Data **ptr, Size size, uint8_t memType)
 *         RFAILED - failure
 *
 * ****************************************************************/
-uint8_t SPutStaticBufNewForDebug(char *file, char *func, char *line, \
+uint8_t SPutStaticBufNewForDebug(char *file, const char *func, int line, \
 Region region, Pool pool, Data *ptr, Size size, uint8_t memType)
 {
    if(SPutStaticBuffer(region, pool, ptr, size, memType) == ROK)
    {
 #ifdef ODU_MEMORY_DEBUG_LOG
-      printf("\nCM_FREE=== SPutStaticBufNewForDebug %s +%d, %s, %d, %p\n",\
+      printf("\nCM_FREE=== SPutStaticBufNewForDebug %s +%d, %s, %d, %p \n",\
          file, line, func, size, ptr);
 #endif
       return ROK;
@@ -301,6 +388,35 @@ Region region, Pool pool, Data *ptr, Size size, uint8_t memType)
    else
       return RFAILED;
 }
+
+
+/*******************************************************************
+*
+* @brief  countSetBits in an integer
+*
+* @details
+*
+*    Function : countSetBits 
+*
+*    Functionality: countSetBits in unsigned integer
+*
+* @params[in] uint32_t number/Bitmask
+*
+* @return [out] uint8_t count of Set Bits
+*
+* ****************************************************************/
+uint8_t countSetBits(uint32_t num)
+{
+   uint8_t count = 0;
+
+   while(num)
+   {
+      count += num & 1;
+      num >>= 1;
+   }
+   return(count);
+}
+
 /**********************************************************************
          End of file
 **********************************************************************/