source: svn/trunk/newcon3bcm2_21bu/magnum/basemodules/int/bint_stats.h @ 16

Last change on this file since 16 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 6.8 KB
Line 
1/***************************************************************************
2 *         Copyright (c) 2003-2007, 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: bint_stats.h $
11 * $brcm_Revision: Hydra_Software_Devel/2 $
12 * $brcm_Date: 2/9/07 5:24p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/basemodules/int/bint_stats.h $
19 *
20 * Hydra_Software_Devel/2   2/9/07 5:24p albertl
21 * PR24115:  Added warning messages for long executing interrupts and
22 * runaway interrupts with adjustable compile time thresholds.
23 *
24 * Hydra_Software_Devel/1   5/25/06 4:10p albertl
25 * PR21392:  BINT_Stats functions now split off into bint_stats.h to solve
26 * BTMR circular dependency.
27 *
28
29 *
30 ***************************************************************************/
31
32#ifndef BINT_STATS_H
33#define BINT_STATS_H
34
35#include "bstd.h"
36#include "bint.h"
37#include "btmr.h"
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43#ifdef BDBG_DEBUG_BUILD
44#define BINT_STATS_ENABLE
45#endif /* BDBG_DEBUG_BUILD */
46
47/***************************************************************************
48Summary:
49        List of errors unique to INT
50****************************************************************************/
51#define BINT_STATS_ERR_ALREADY_ENABLED           BERR_MAKE_CODE(BERR_INT_ID, 0)
52#define BINT_STATS_ERR_ALREADY_DISABLED          BERR_MAKE_CODE(BERR_INT_ID, 1)
53
54#define BINT_P_STATS_BIN_MAX 10 /* Number of maximum bins. */
55#define BINT_P_STATS_SAMPLE_MAX 10000
56#define BINT_P_STATS_RECENT_CB_HIT_COUNT 20 /* Number of hits used to track hit frequency */
57#define BINT_P_STATS_EXECUTION_TIME_MAX_THRESHOLD 5000 /* Maxmim time for callback execution */
58#define BINT_P_STATS_AVG_PERIOD_MIN_THRESHOLD 1000 /* Minimum avg time between callback hits */
59
60/*
61This structure defines a callback statistics bin.  It has a minimum and maximum range in
62microseconds. Each time the callback associated with it executes and completes within the
63minimum and maximum range of the bin, ulBinHitCount of the bin increments.
64*/
65typedef struct BINT_Stats_CallbackBin
66{
67        uint32_t ulBinRangeMin; /* minimum bin range, in microseconds. */
68        uint32_t ulBinRangeMax; /* maximum bin range, in microseconds. */
69        uint32_t ulBinHitCount; /* count of times callback executed within this bin's range. */
70}BINT_Stats_CallbackBin;
71
72/*
73This structure keeps track of a callback's statistics.  It is updated every time the
74callback executes, and can be obtained by callling BINT_Stats_Get().  It may be
75necessary to lock this structure down when reading from it to ensure that it is
76not updated in mid-read.
77*/
78typedef struct BINT_Stats_CallbackStats
79{
80        uint32_t ulTimeMin;    /* Minimum execution time. */
81        uint32_t ulTimeMax;    /* Maximum execution time. */
82        uint32_t ulTimeAvg;    /* Average execution time.  Average is over ulCbHitCount
83                                                      samples, if ulCbHitCount is less than BINT_P_STATS_SAMPLE_MAX.
84
85                                                      If ulCbHitCount is greater than BINT_P_STATS_SAMPLE_MAX,
86                                                      Average is roughly equivalent to BINT_P_STATS_SAMPLE_MAX
87                                                      samples */
88        uint32_t ulCbHitCount; /* Number of times callback has executed. */
89        bool bDefaultBins;     /* whether default bins or user bins are being used */
90        uint32_t ulActiveBins; /* Number of active bins */
91
92        BINT_Stats_CallbackBin aBinInfo[BINT_P_STATS_BIN_MAX];   /* array storing stat bins */
93        uint32_t aulTimeStamp[BINT_P_STATS_RECENT_CB_HIT_COUNT]; /* circular array storing start times of
94                                                                                                                        last BINT_P_STATS_RECENT_CB_HIT_COUNT
95                                                                                                                            hits to track hit frequency */
96        uint32_t ulTimeStampStartIdx;                            /* start index of above array */
97
98}BINT_Stats_CallbackStats;
99
100/*
101Summary:
102Enables statistics tracking of callbacks.
103
104Description:
105Enables tracking of statistics for the interrupt module.  Must be called for
106statistics to be tracked.  If enabled, a call to BINT_Stats_Disable is
107required before the module is closed with BINT_Close.
108
109Access to a shared freerun timer from the TMR module will be acquired when
110stats tracking is enabled.
111*/
112BERR_Code BINT_Stats_Enable(
113                                                        BINT_Handle intHandle, /* [in] Interrupt handle */
114                                                        BTMR_Handle hTmrHandle /* [in] Timer module handle */
115                                                        );
116
117/*
118Summary:
119Disables statistics tracking of callbacks.
120
121Description:
122Disables tracking of statistics for the interrupt module.  Must be called before
123the module is closed with BINT_Close if stats tracking was enabled with
124BINT_Stats_Enable.
125
126Disabling stats tracking also relinquishes access to the shared freerun timer
127acquired when tracking was enabled.
128*/
129BERR_Code BINT_Stats_Disable(
130                                                        BINT_Handle intHandle /* [in] Interrupt handle */
131                                                        );
132
133/*
134Summary:
135Adds a statistics bin to a callback.
136
137Description:
138Adds a bin with a minimum and maximum time range in microseconds.  The ulBinHitCount
139field will be incremented in this bin everytime the execution of the callback falls
140within the time range.  Returns an error if maximum number of bins is exceeded or
141if the max and min ranges overlap or fall within an existing bin's range.  No two
142bins can have overlapping ranges.
143
144Adding a bin removes the default bins for a callback.
145*/
146BERR_Code BINT_Stats_AddBin(
147                                                        BINT_CallbackHandle cbHandle, /* [in] Callback handle returned by BINT_CreateCallback() */
148                                                        uint32_t ulRangeMin, /* [in] Minimum time range, in microseconds */
149                                                        uint32_t ulRangeMax  /* [in] Maximum time range, in microseconds */
150                                                        );
151
152/*
153Summary:
154Destroys existing stats bins of a callback.
155
156Description:
157Destroys and clears out the created stats bins of a given callback.
158*/
159BERR_Code BINT_Stats_DestroyBins(
160                                                        BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
161                                                        );
162
163
164/*
165Summary:
166Gets the statistics of a callback.
167
168Description:
169Gets the statistics of a specific callback.  It returns the pointer to the BINT_CallbackStats
170structure associated with the callback.  The BINT_CallbackStats structure is constantly being
171updated, each time the callback executes.  It may be necessary to use critical sections when
172reading from the callback structure to make sure the stats don't update in mid-read.
173
174#define BINT_STATS_ENABLE to enable stats tracking.  Stats tracking functions and datastructures
175are disabled by default.
176*/
177BERR_Code BINT_Stats_Get(
178                                                 BINT_CallbackHandle cbHandle,
179                                                 BINT_Stats_CallbackStats **ppCbStats
180                                                 );
181
182/*
183Summary:
184Resets the statistics of a callback.
185
186Description:
187Resets the statistics of a specific callback.  All stats for the callback and its bins are
188reset when this function is called.
189*/
190BERR_Code BINT_Stats_Reset(
191                                                 BINT_CallbackHandle cbHandle
192                                                 );
193
194#ifdef __cplusplus
195}
196#endif
197 
198#endif
199/* End of File */
200
201
202
Note: See TracBrowser for help on using the repository browser.