Merge "[Epic-ID: ODUHIGH-405][Task-ID: ODUHIGH-437] Establishing communication betwee...
[o-du/l2.git] / src / cm / cm_mem.c
index 4ef65d6..a507098 100755 (executable)
@@ -294,7 +294,7 @@ void InsertToT2kMemLeakInfo(uint64_t address, uint32_t size, uint32_t lineNo, ch
 
    if(((uint64_t)(address - regMemLeakInfo.regStartAddr[region]) & regMinBktSzInfo[region].minBktSzMins1) !=0)
    {
-     printf("address in InsertToT2kMemLeakInfo is %ld size = %d file is %s line is %d \n", address, size, fileName, lineNo);
+      DU_LOG("\nINFO  --> address in InsertToT2kMemLeakInfo is %ld size = %d file is %s line is %d \n", address, size, fileName, lineNo);
    }
 
    leakInfo = (((T2kMeamLeakInfo*)(regMemLeakInfo.gMemLeakInfo[region])) + index1);
@@ -308,7 +308,8 @@ void InsertToT2kMemLeakInfo(uint64_t address, uint32_t size, uint32_t lineNo, ch
       leakInfo->prevRemLineNo = 0;
       leakInfo->prevRemFileName = '\0';
 
-      //printf("InsertToT2kMemLeakInfo  the adress from List  Address = %x, index1 = %d   from File=%s, line=%d \n",address,index1,fileName,lineNo);
+      //DU_LOG("\nINFO  --> InsertToT2kMemLeakInfo  the adress from List  Address = %x, index1 = %d   \
+      from File=%s, line=%d \n",address,index1,fileName,lineNo);
       if(smallTick++ == 4096)
       {
          smallTick = 0;
@@ -317,8 +318,8 @@ void InsertToT2kMemLeakInfo(uint64_t address, uint32_t size, uint32_t lineNo, ch
    }
    else
    {
-         printf("Something is wrong, trying to insert %ld index1 = %d file is %s line is %d \n",address, index1, fileName, lineNo);
-         printf("Address present :%ld, from File:%s, Line:%d, Size:%d, Age:%d",
+         DU_LOG("\nERROR  --> Something is wrong, trying to insert %ld index1 = %d file is %s line is %d \n",address, index1, fileName, lineNo);
+         DU_LOG("\nINFO  --> Address present :%ld, from File:%s, Line:%d, Size:%d, Age:%d",
                leakInfo->address, leakInfo->fileName,
                leakInfo->lineNo, leakInfo->size,
                leakInfo->age);
@@ -339,7 +340,7 @@ void RemoveFromT2kMemLeakInfo(uint64_t address, char *file, uint32_t line,Region
 
    if(index1 >= T2K_MEM_LEAK_INFO_TABLE_SIZE)
    {
-      printf("index1 out of range = %d address is %ld file = %s line = %d. We are going to crash!!!\n",
+      DU_LOG("\nERROR  --> index1 out of range = %d address is %ld file = %s line = %d. We are going to crash!!!\n",
               index1,
               address,
               file,
@@ -358,14 +359,14 @@ void RemoveFromT2kMemLeakInfo(uint64_t address, char *file, uint32_t line,Region
    }
    else
    {
-         printf("Something is wrong, trying to remove %ld index1 = %d  from File=%s, line=%d address present is %ld region%d \n",address, index1, file,line,leakInfo->address,region);
+         DU_LOG("\nERROR  --> Something is wrong, trying to remove %ld index1 = %d  from File=%s, line=%d address present is %ld region%d \n",address, index1, file,line,leakInfo->address,region);
 
-         printf("\n Last Del file %s line %d\n",leakInfo->lastDelFileName,
+         DU_LOG("\nINFO  -->  Last Del file %s line %d\n",leakInfo->lastDelFileName,
                  leakInfo->lastDelLineNum);
 
          if(leakInfo->prevRemFileName != NULLP)
          {
-            printf("Previous File:%s, Previous Line:%d\n",
+             DU_LOG("\nINFO  --> Previous File:%s, Previous Line:%d\n",
                   leakInfo->prevRemFileName, leakInfo->prevRemLineNo);
          }
    }
@@ -380,7 +381,7 @@ void DumpT2kMemLeakInfoToFile()
 
    if(fp == NULL)
    {
-      printf("Could not open file for dumping mem leak info\n");
+      DU_LOG("\nERROR  --> Could not open file for dumping mem leak info\n");
       return;
    }
    for(reg=0; reg <regMemLeakInfo.numActvRegions; reg++)
@@ -747,7 +748,7 @@ S16 cmMmRegInit(Region region,CmMmRegCb *regCb,CmMmRegCfg  *cfg)
 #ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2
     /* Initialize the hast list to maintain the SSI memory information for Broadcom */
     offset = (uint16_t)((PTR)(&ptrHdr.ent) - (PTR) &ptrHdr);
-    printf("###########offset is %d region %d\n", offset, region);
+    DU_LOG("\nINFO  --> offset is %d region %d\n", offset, region);
     if(cmHashListInit(&regCb->brdcmSsiLstCp, 1000, offset, FALSE, 
        CM_HASH_KEYTYPE_UINT32_MOD, region, 0) != ROK)
     {
@@ -1205,7 +1206,7 @@ Data  **prevptr;
       /* Initialize the elements with 0xAB */
       memset(*ptr, 0xAB, *size);
 #endif
-//      printf("Pointer allocated %8p size %d\n", *ptr, *size);
+//      DU_LOG("\nINFO  --> Pointer allocated %8p size %d\n", *ptr, *size);
       /* Store this pointer in hash list */
       if ((bkt->nextBlk) && *ptr)
 #elif SS_LIGHT_MEM_LEAK_STS
@@ -1310,7 +1311,7 @@ Data  **prevptr;
                if (g_overused[bktIdx] == 0 && OVERUSED(bkt))
                {
                   g_overused[bktIdx] = 1;
-                  /*printf("cmAlloc: bktIdx %u overused %u numAlloc %u\n", bktIdx, g_overused[bktIdx], bkt->numAlloc); */
+                  /*DU_LOG("\nINFO  --> cmAlloc: bktIdx %u overused %u numAlloc %u\n", bktIdx, g_overused[bktIdx], bkt->numAlloc); */
                }
             }
 #endif
@@ -1703,13 +1704,13 @@ Size    size
                size(%d) %8p, Bucket Id:%03d\n",
                size, ptrHdr->requestedSize, ptr, regCb->mapTbl[idx].bktIdx);
 #endif
-         printf("Passed size (%d) does not match with allocated \
+         DU_LOG("\nERROR  --> Passed size (%d) does not match with allocated \
                size(%d) %8p, Bucket Id:%03d\n",
                size, ptrHdr->requestedSize, ptr, regCb->mapTbl[idx].bktIdx);
          abort();
       }
       /* Validate the tail part to see if there is any over run */
-//      printf("Pointer free request %8p, size %d\n", ptr, size);
+//      DU_LOG("\nINFO  --> Pointer free request %8p, size %d\n", ptr, size);
 #endif
 
       /* validate the block to be freed for trampling */
@@ -1770,7 +1771,7 @@ Size    size
                 return (RTRAMPLINGNOK);
            }
 #ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1
-         printf("Memory signature is invalid\n");
+         DU_LOG("\nERROR  --> Memory signature is invalid\n");
          abort();
 #endif
       }
@@ -1806,7 +1807,7 @@ Size    size
           (Void) SUnlock(&(bkt->bktLock));
 #endif
 #ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1
-         printf("Attempt to double deallocate memory at: %8p, Bucket Id:%03d,\
+         DU_LOG("\nERROR  --> Attempt to double deallocate memory at: %8p, Bucket Id:%03d,\
                  size %u bytes \n", ptr, regCb->mapTbl[idx].bktIdx, bkt->size);
           abort();
 #endif
@@ -2782,7 +2783,7 @@ Size    size
          sprintf(dbgPrntBuf, "Passed size (%d) does not match with allocated size(%d):%8p, Bucket Id:%03d\n",
                  size, ptrHdr->requestedSize, ptr, regCb->mapTbl[idx].bktIdx);
 #endif
-         printf("Passed size (%d) does not match with allocated size(%d):%8p, Bucket Id:%03d\n",
+         DU_LOG("\nERROR  --> Passed size (%d) does not match with allocated size(%d):%8p, Bucket Id:%03d\n",
                  size, ptrHdr->requestedSize, ptr, regCb->mapTbl[idx].bktIdx);
          abort();
       }
@@ -2826,7 +2827,7 @@ Size    size
          }
 #endif
 #ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1
-         printf("Memory signature is invalid\n");
+         DU_LOG("\nERROR  --> Memory signature is invalid\n");
          abort();
 #endif
       }
@@ -2856,7 +2857,7 @@ Size    size
          SDisplay(0, dbgPrntBuf);
 #endif /* DEBUGP */
 #ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1
-         printf("Attempt to double deallocate memory at: %8p, Bucket Id:%03d,\
+         DU_LOG("\nERROR  --> Attempt to double deallocate memory at: %8p, Bucket Id:%03d,\
                  size %u bytes \n", ptr, regCb->mapTbl[idx].bktIdx, bkt->size);
           abort();
 #endif
@@ -4587,13 +4588,13 @@ Void cmStartStopLeakLog(Void)
 {
    if (FALSE == gmemLkCb.isStarted)
    {
-      printf("!!leak capturing started\n");
+      DU_LOG("\nINFO  --> leak capturing started\n");
       gmemLkCb.isStarted = TRUE;
    }
    else
    {
       gmemLkCb.isStarted = FALSE;
-      printf("!!leak capturing stopped\n");
+      DU_LOG("\nINFO  --> leak capturing stopped\n");
       cmPrintLeakLog();
    }
    return;
@@ -4620,18 +4621,18 @@ Void cmPrintLeakLog(Void)
    static uint32_t leakCount =0; 
 
 
-   printf("---- START OF LEAK LOG ----");
+   DU_LOG("\nINFO  --> START OF LEAK LOG ");
    SLock(&gmemLkCb.memLock);
-   printf("---- Lock Acquired ----");
+   DU_LOG("\nINFO  -->  Lock Acquired");
    for(indx = 0; indx < CM_MAX_ALLOC_ENTERIES; indx++)
    {
       if(gmemLkCb.allocInfo[indx].used == TRUE)
       {
          leakCount++;
          aBkt =(CmMmBlkHdr *)gmemLkCb.allocInfo[indx].memAddr;
-         printf("LeakCnt(%ld)Addr(0x%p)RqSz(%ld)",
+         DU_LOG("LeakCnt(%ld)Addr(0x%p)RqSz(%ld)",
             leakCount,gmemLkCb.allocInfo[indx].memAddr, aBkt->requestedSize);
-         printf("LineNo(%ld)funcName(%s)\n",
+         DU_LOG("LineNo(%ld)funcName(%s)\n",
             aBkt->lineNo, aBkt->currFuncName);
          gmemLkCb.allocInfo[indx].used = FALSE;
          cmPutFreeIndx(indx);
@@ -4639,9 +4640,9 @@ Void cmPrintLeakLog(Void)
       //if(leakCount % 10 == 0)
         // sleep(1);
    }
-   printf("---- END OF LEAK LOG ----");
+   DU_LOG("\nINFO  -->  END OF LEAK LOG ");
    SUnlock(&gmemLkCb.memLock);
-   printf("---- Lock Released ----");
+   DU_LOG("\nINFO  -->  Lock Released");
    leakCount =0; 
    return;
 }
@@ -4881,7 +4882,7 @@ uint16_t    bktIdx
 #else
    funcNm = (S8 **)calloc(1, (sizeof(uint32_t) * CM_MAX_STACK_TRACE));
 #endif
-       /* SGetSBuf(DFLT_REGION, DFLT_POOL, &funcNm, sizeof(uint32_t) * CM_MAX_STACK_TRACE); */
+       /* SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,DFLT_REGION, DFLT_POOL, &funcNm, sizeof(uint32_t) * CM_MAX_STACK_TRACE); */
    traceSize = backtrace((Void **)funcNm, CM_MAX_STACK_TRACE);
 #else /* SS_MEM_LEAK_SOL */
 #ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2
@@ -4904,7 +4905,7 @@ uint16_t    bktIdx
    allocInfo = (MemAllocInfo *)calloc(1, sizeof(MemAllocInfo));  
 #endif
 #endif
-       /* SGetSBuf(DFLT_REGION, DFLT_POOL, &allocInfo,  sizeof(MemAllocInfo)); */
+       /* SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,DFLT_REGION, DFLT_POOL, &allocInfo,  sizeof(MemAllocInfo)); */
 #ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2
    /* check if hashListCp is initialised yet */
    if ( regCb->brdcmSsiLstCp.nmbBins == 0)
@@ -5237,7 +5238,7 @@ Void SFlushLkInfo (Void)
 #else
                 free(funcNm[i]); 
 #endif
-                                   /* SPutSBuf(DFLT_REGION, DFLT_POOL, funcNm[i], sizeof(uint32_t) * CM_MAX_STACK_TRACE); */
+                                   /* SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,DFLT_REGION, DFLT_POOL, funcNm[i], sizeof(uint32_t) * CM_MAX_STACK_TRACE); */
              }
 #endif /* SS_MEM_LEAK_SOl */
 /*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/   
@@ -5458,7 +5459,7 @@ S32 cmLeakCallBack(uintptr_t pc,S32  sigNo, Void *arg)
 #else
     buffer = (S8 *)calloc(1, 510); 
 #endif
-        /* SGetSBuf(DFLT_REGION, DFLT_POOL, &buffer, 510); */
+        /* SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,DFLT_REGION, DFLT_POOL, &buffer, 510); */
     (void) cmAddrToSymStr((void *)pc, buffer, 505);
     bt->bt_buffer[bt->bt_actcount++] = (S8 *)buffer;
 
@@ -5669,7 +5670,7 @@ Pool         pool          /* memory pool to allocate bins */
    /* allocate memory for bins */
    if (nmbBins)
    {
-      if (SGetSBuf(region, pool, (Data **) &hashListCp->hashList,
+      if (SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,region, pool, (Data **) &hashListCp->hashList,
                (Size)(nmbBins * sizeof(CmMmHashListEnt))) != ROK)
       return RFAILED;
 
@@ -5716,7 +5717,7 @@ Pool   pool          /* memory pool to allocate bins */
 
    /* deallocate memory for bins */
    if (hashListCp->numOfbins)
-      (Void) SPutSBuf(region, pool,
+      (Void) SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,region, pool,
                       (Data *) hashListCp->hashList,
                       (Size) (hashListCp->numOfbins * sizeof(CmMmHashListEnt)));
 
@@ -5930,7 +5931,7 @@ uint8_t   entId    /* Tapa task which free the memory */
    /* If hash list is full then print the error tna continue */
    if(hashListCp->totalNumEntries == (CMM_HIST_MAX_MEM_BIN * CMM_HIST_MAX_MEM_ENTRY_PER_BIN))
    {
-        printf("No place in the hash list. Increase the value of macro CMM_HIST_MAX_MEM_BIN and CMM_HIST_MAX_MEM_ENTRY_PER_BIN \n");
+        DU_LOG("\nERROR  --> No place in the hash list. Increase the value of macro CMM_HIST_MAX_MEM_BIN and CMM_HIST_MAX_MEM_ENTRY_PER_BIN \n");
         return RFAILED;
    } /* End of if */
 
@@ -6004,7 +6005,7 @@ uint8_t    entId
 
    if(hashListCp->totalNumEntries == (CMM_HIST_MAX_MEM_BIN * CMM_HIST_MAX_MEM_ENTRY_PER_BIN))
    {
-        printf("No place in the hash list. Increase the value of macro CMM_HIST_MAX_MEM_BIN and CMM_HIST_MAX_MEM_ENTRY_PER_BIN\n");
+        DU_LOG("\nERROR  --> No place in the hash list. Increase the value of macro CMM_HIST_MAX_MEM_BIN and CMM_HIST_MAX_MEM_ENTRY_PER_BIN\n");
         return RFAILED;
    } /* End of if */
 
@@ -6173,12 +6174,12 @@ CmMemEntries  **entry
       } /* End of if (numEnt) */
       else
       {
-         printf ("Unable to find the entry in hash list\n");
+         DU_LOG("\nERROR  --> Unable to find the entry in hash list\n");
          return RFAILED;
       }/* End of else (numEnt) */
    }/* end of for (numBin = 0) */
 
-   printf("Unable to find the entry in the hash list\n");
+   DU_LOG("\nERROR  --> Unable to find the entry in the hash list\n");
    return RFAILED;
 } /* end of cmHstGrmFindEntry */