| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2010, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bkni_metrics.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/1 $ |
|---|
| 12 | * $brcm_Date: 8/19/10 8:08a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/basemodules/kni/ucos_ii/bkni_metrics.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/1 8/19/10 8:08a jfisher |
|---|
| 21 | * SW7572-49: Add nesting check. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/8 4/4/03 11:27a erickson |
|---|
| 24 | * updated documentation |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/7 4/3/03 6:13p erickson |
|---|
| 27 | * some pre 0.9 api rework |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/6 3/28/03 6:53p erickson |
|---|
| 30 | * updated comments |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/5 3/17/03 4:09p erickson |
|---|
| 33 | * kernel interface doc changes |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/4 3/10/03 2:29p erickson |
|---|
| 36 | * updated docs |
|---|
| 37 | * |
|---|
| 38 | * Hydra_Software_Devel/3 3/7/03 5:20p erickson |
|---|
| 39 | * linux kernel interface work |
|---|
| 40 | * |
|---|
| 41 | * Hydra_Software_Devel/2 3/6/03 6:27p erickson |
|---|
| 42 | * rework KNI api |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/1 3/5/03 5:16p erickson |
|---|
| 45 | * Initial kernelinterface work |
|---|
| 46 | * |
|---|
| 47 | ***************************************************************************/ |
|---|
| 48 | #ifndef BKNI_METRICS_H__ |
|---|
| 49 | #define BKNI_METRICS_H__ |
|---|
| 50 | |
|---|
| 51 | /*=************************************************************************* |
|---|
| 52 | The purpose of the metrics interface is to provide a standard way of |
|---|
| 53 | monitoring kernel interface usage. This meets a basic requirement of the Magnum |
|---|
| 54 | architecture which is to improve system performance. One simple way of doing this is |
|---|
| 55 | to know who is sleeping and blocking and for how long. Grep'ing code can find |
|---|
| 56 | these spots, but it can't tell you how frequently and for how long these calls |
|---|
| 57 | are being made. |
|---|
| 58 | |
|---|
| 59 | No Magnum code is allowed to call the metrics interface. It is only callable |
|---|
| 60 | by system level code. |
|---|
| 61 | |
|---|
| 62 | The metrics interface can be turned off or compiled out. If you don't want the overhead, |
|---|
| 63 | you're not required to have it. However, we do require that every platform |
|---|
| 64 | should implement the metrics interface so that it can be used if desired. |
|---|
| 65 | |
|---|
| 66 | See bkni.h for a kernel interface overview. |
|---|
| 67 | ****************************************************************************/ |
|---|
| 68 | |
|---|
| 69 | #ifdef __cplusplus |
|---|
| 70 | extern "C" { |
|---|
| 71 | #endif |
|---|
| 72 | |
|---|
| 73 | /*************************************************************************** |
|---|
| 74 | Summary: |
|---|
| 75 | Data structure populated by BKNI_Metrics_Get. |
|---|
| 76 | ****************************************************************************/ |
|---|
| 77 | typedef struct { |
|---|
| 78 | uint32_t totalDelays; /* Total number of times BKNI_Delay was called. */ |
|---|
| 79 | uint32_t totalDelayTime; /* Acculated microsec's passed into BKNI_Delay. */ |
|---|
| 80 | uint32_t maxDelayTime; /* Largest microsec value passed into BKNI_Delay. */ |
|---|
| 81 | |
|---|
| 82 | uint32_t totalSleeps; /* Total number of times BKNI_Sleep was called. */ |
|---|
| 83 | uint32_t totalSleepTime; /* Acculated millisec's passed into BKNI_Sleep. */ |
|---|
| 84 | uint32_t maxSleepTime; /* Largest millisec value passed into BKNI_Sleep. */ |
|---|
| 85 | |
|---|
| 86 | uint32_t totalMutexSections; /* Total number of times BKNI_AcquireMutex was called. */ |
|---|
| 87 | uint32_t totalMutexSectionTime; /* Total time in milliseconds spent between matching |
|---|
| 88 | BKNI_AcquireMutex and BKNI_ReleaseMutex calls. */ |
|---|
| 89 | uint32_t maxMutexSectionTime; /* Largest time in milliseconds spent between matching |
|---|
| 90 | BKNI_AcquireMutex and BKNI_ReleaseMutex calls. */ |
|---|
| 91 | |
|---|
| 92 | uint32_t totalWaitForEvents; /* Total number of times BKNI_WaitForEvent was called. */ |
|---|
| 93 | uint32_t totalWaitForEventTime; /* Total time in milliseconds spent blocking in |
|---|
| 94 | BKNI_WaitForEvent calls. */ |
|---|
| 95 | uint32_t maxWaitForEventTime; /* Largest time in milliseconds spent blocking in |
|---|
| 96 | BKNI_WaitForEvent calls. */ |
|---|
| 97 | |
|---|
| 98 | uint32_t totalCriticalSections; /* Total number of times BKNI_AcquireMutex was called. */ |
|---|
| 99 | uint32_t totalCriticalSectionTime;/* Total time in milliseconds spent between |
|---|
| 100 | BKNI_EnterCriticalSection and BKNI_LeaveCriticalSection calls. */ |
|---|
| 101 | uint32_t maxCriticalSectionTime; /* Largest time in milliseconds spent between |
|---|
| 102 | BKNI_EnterCriticalSection and BKNI_LeaveCriticalSection calls. */ |
|---|
| 103 | |
|---|
| 104 | uint32_t totalMallocs; /* The total number of times BKNI_Malloc is called. */ |
|---|
| 105 | uint32_t totalMemoryAllocated; /* The total number of bytes allocated by BKNI_Malloc. |
|---|
| 106 | This total is not decremented by BKNI_Free, therefore |
|---|
| 107 | this number only reflects the amount of system |
|---|
| 108 | memory usage, not the current amount actually allocated. */ |
|---|
| 109 | } BKNI_Metrics; |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | /*************************************************************************** |
|---|
| 113 | Summary: |
|---|
| 114 | Retrieve metrics from kernel interface regarding delay, sleep and mutex usage. The |
|---|
| 115 | metrics are accumulated since the last BKNI_Init() or BKNI_Metrics_Reset() call. |
|---|
| 116 | ****************************************************************************/ |
|---|
| 117 | void BKNI_Metrics_Get(BKNI_Metrics *metrics); |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | /*************************************************************************** |
|---|
| 121 | Summary: |
|---|
| 122 | Reset all metrics to initial values before kernel interface was used. |
|---|
| 123 | ****************************************************************************/ |
|---|
| 124 | void BKNI_Metrics_Reset(void); |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | /*************************************************************************** |
|---|
| 128 | Summary: |
|---|
| 129 | Structure to control debug output of kernel interface. |
|---|
| 130 | |
|---|
| 131 | Ideally, this debug output should include the FILE and LINE number of each |
|---|
| 132 | call. This can be implemented by using tagged versions of the kernel interface |
|---|
| 133 | functions. |
|---|
| 134 | |
|---|
| 135 | Also, the output mechanism may be the debug interface, BKNI_Printf or some other |
|---|
| 136 | means. If it is the debug interface, you must also enable the correct |
|---|
| 137 | debug level for the kernel interface module. The exact implementation of this |
|---|
| 138 | is up to the platform developer. |
|---|
| 139 | ****************************************************************************/ |
|---|
| 140 | typedef struct { |
|---|
| 141 | bool printDelays; /* Print every time BKNI_Delay is called. */ |
|---|
| 142 | bool printSleeps; /* Print every time BKNI_Sleep is called. */ |
|---|
| 143 | bool printMutexSections; /* Print every time BKNI_ReleaseMutex is called and |
|---|
| 144 | every time BKNI_AcquireMutex is entered and exited. */ |
|---|
| 145 | bool printCriticalSections; /* Print every time BKNI_LeaveCriticalSection is called and |
|---|
| 146 | every time BKNI_EnterCriticalSection is entered and exited. */ |
|---|
| 147 | bool printEvents; /* Print every time BKNI_SetEvent and BKNI_ResetEvent are called and |
|---|
| 148 | every time BKNI_WaitForEvent is entered and exited. */ |
|---|
| 149 | } BKNI_Metrics_LoggingState; |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | /*************************************************************************** |
|---|
| 153 | Summary: |
|---|
| 154 | Change the debug output of the kernel interface. |
|---|
| 155 | ****************************************************************************/ |
|---|
| 156 | void BKNI_Metrics_GetLoggingState(BKNI_Metrics_LoggingState *logging); |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | /*************************************************************************** |
|---|
| 160 | Summary: |
|---|
| 161 | Get the debug output state of the kernel interface. |
|---|
| 162 | ****************************************************************************/ |
|---|
| 163 | void BKNI_Metrics_SetLoggingState(const BKNI_Metrics_LoggingState *logging); |
|---|
| 164 | |
|---|
| 165 | #ifdef __cplusplus |
|---|
| 166 | } |
|---|
| 167 | #endif |
|---|
| 168 | |
|---|
| 169 | #endif /* BKNI_METRICS_H__ */ |
|---|