openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

profile_sal.c (2408B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File: 	profile_sal.c
      8  * Purpose: 	SAL resource usage profiler
      9  */
     10 
     11 #ifdef BROADCOM_DEBUG
     12 #ifdef INCLUDE_BCM_SAL_PROFILE
     13 
     14 #include <sal/types.h>
     15 #include <shared/alloc.h>
     16 #include <shared/bsl.h>
     17 #include <sal/core/sync.h>
     18 #include <sal/core/thread.h>
     19 
     20 #include <sal/appl/sal.h>
     21 
     22 #include <appl/diag/shell.h>
     23 #include <appl/diag/cmdlist.h>
     24 #include <soc/cm.h>
     25 
     26 char cmd_sal_profile_usage[] =
     27     "Parameters: None\n\t"
     28     "Display current SAL resource usage\n";
     29 
     30 static void
     31 _cmd_sal_profile_display(void)
     32 {
     33     unsigned int res0_curr, res0_max;
     34     unsigned int res1_curr, res1_max;
     35 
     36     /*
     37      * appl/sal resource usage
     38      */
     39     sal_dma_alloc_resource_usage_get(&res0_curr, &res0_max);
     40     if (res0_max != 0) {
     41         cli_out("DMA Memory Allocation Current / Maximum   %d / %d Bytes\n",
     42                 res0_curr,res0_max);
     43     }
     44 
     45     /*
     46      * core/sal resource usage
     47      */
     48     sal_alloc_resource_usage_get(&res0_curr, &res0_max);
     49     cli_out("CPU Memory Allocation Current / Maximum   %d / %d Bytes\n",
     50             res0_curr,res0_max);
     51 
     52     sal_sem_resource_usage_get(&res0_curr, &res0_max);
     53     if (res0_max != 0) {
     54         cli_out("Semaphore Count Current / Maximum         %d / %d\n",
     55                 res0_curr,res0_max);
     56     }
     57 
     58     sal_mutex_resource_usage_get(&res0_curr, &res0_max);
     59     cli_out("Mutex Count Current / Maximum             %d / %d\n",
     60             res0_curr,res0_max);
     61 
     62     sal_thread_resource_usage_get(&res0_curr, &res1_curr, &res0_max, &res1_max);
     63     cli_out("Thread Count Current / Maximum            %d / %d\n",
     64             res0_curr,res0_max);
     65 
     66     if (res1_max != 0) {
     67         cli_out("Thread Stack Allocation Current / Maximum %d / %d Bytes\n",
     68                 res1_curr,res1_max);
     69     }
     70 }
     71 
     72 cmd_result_t
     73 cmd_sal_profile(int u, args_t *a)
     74 /*
     75  * Function: 	cmd_sal_profile
     76  * Purpose:	Displays current SAL resource usage
     77  * Parameters:	None
     78  * Returns:	CMD_OK/CMD_USAGE
     79  */
     80 {
     81     int  arg_count;
     82 
     83     COMPILER_REFERENCE(u);
     84 
     85     arg_count = ARG_CNT(a);
     86 
     87     if (arg_count != 0) {
     88         return(CMD_USAGE);
     89     } else {
     90         _cmd_sal_profile_display();
     91         soc_cm_dump_info(u);
     92         return(CMD_OK);
     93     }
     94 }
     95 #endif
     96 #endif
     97 int _profile_sal_c_not_empty;