pstats.h (4136B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 7 * 8 */ 9 10 #ifndef __BCM_PSTATS_H__ 11 #define __BCM_PSTATS_H__ 12 13 #if defined(INCLUDE_PSTATS) 14 15 #include <bcm/types.h> 16 17 /* PSTATS time stamp structure. */ 18 typedef struct bcm_pstats_timestamp_s { 19 uint64 seconds; /* Seconds */ 20 uint32 nanoseconds; /* Nanoseconds */ 21 } bcm_pstats_timestamp_t; 22 23 /* Definition for session element type. */ 24 typedef enum bcm_pstats_session_element_type_e { 25 bcmPStatsSessionUnicastQueue = 1, 26 bcmPStatsSessionIngPool = 2, 27 bcmPStatsSessionEgrPool = 3, 28 bcmPStatsSessionTypeCount = 4 /* Max value defined for this enum */ 29 } bcm_pstats_session_element_type_t; 30 31 /* PSTATS session element structure. */ 32 typedef struct bcm_pstats_session_element_s { 33 bcm_pstats_session_element_type_t type; /* Session element type */ 34 bcm_gport_t gport; /* UC queue gport */ 35 bcm_cos_queue_t cosq; /* Cos queue */ 36 bcm_service_pool_id_t pool; /* Service Pool ID */ 37 } bcm_pstats_session_element_t; 38 39 #define BCM_PSTATS_BUFFER_COUNT 8 /* PSTATS buffer count */ 40 41 /* PSTATS use counts sturcture. */ 42 typedef struct bcm_pstats_data_s { 43 uint32 array_count; /* Number of elements in array */ 44 uint32 use_counts_array[BCM_PSTATS_BUFFER_COUNT]; /* PSTATS use counts array */ 45 } bcm_pstats_data_t; 46 47 #define BCM_PSTATS_OPTIONS_WITH_ID 0x00000001 /* With ID option creation */ 48 #define BCM_PSTATS_OPTIONS_REPLACE 0x00000002 /* Replace existing entry */ 49 50 #ifndef BCM_HIDE_DISPATCHABLE 51 52 /* Create a Pstats session instance for SDK management. */ 53 extern int bcm_pstats_session_create( 54 int unit, 55 int options, 56 int array_count, 57 bcm_pstats_session_element_t *element_array, 58 bcm_pstats_session_id_t *session_id); 59 60 /* Destroy an existing Pstats session. */ 61 extern int bcm_pstats_session_destroy( 62 int unit, 63 bcm_pstats_session_id_t session_id); 64 65 /* Get an existing Pstats session elements. */ 66 extern int bcm_pstats_session_get( 67 int unit, 68 bcm_pstats_session_id_t session_id, 69 int array_max, 70 bcm_pstats_session_element_t *element_array, 71 int *array_count); 72 73 /* Start a Pstats sync operation. */ 74 extern int bcm_pstats_data_sync( 75 int unit); 76 77 /* Get an existing Pstats session data. */ 78 extern int bcm_pstats_session_data_get( 79 int unit, 80 bcm_pstats_session_id_t session_id, 81 bcm_pstats_timestamp_t *timestamp, 82 int array_max, 83 bcm_pstats_data_t *data_array, 84 int *array_count); 85 86 /* 87 * Start a session sync operation first. Then get an existing Pstats 88 * session data. 89 */ 90 extern int bcm_pstats_session_data_sync_get( 91 int unit, 92 bcm_pstats_session_id_t session_id, 93 bcm_pstats_timestamp_t *timestamp, 94 int array_max, 95 bcm_pstats_data_t *data_array, 96 int *array_count); 97 98 /* 99 * Clear an existing Pstats session hw use counts and sw use counts 100 * buffer. 101 */ 102 extern int bcm_pstats_session_data_clear( 103 int unit, 104 bcm_pstats_session_id_t session_id); 105 106 #endif /* BCM_HIDE_DISPATCHABLE */ 107 108 /* bcm_pstats_session_traverse_cb */ 109 typedef int (*bcm_pstats_session_traverse_cb)( 110 int unit, 111 bcm_pstats_session_id_t session_id, 112 int array_count, 113 bcm_pstats_session_element_t *element_array, 114 void *user_data); 115 116 #ifndef BCM_HIDE_DISPATCHABLE 117 118 /* Traverse through the pstats sessions and run callback at each session. */ 119 extern int bcm_pstats_session_traverse( 120 int unit, 121 bcm_pstats_session_traverse_cb cb, 122 void *user_data); 123 124 #endif /* BCM_HIDE_DISPATCHABLE */ 125 126 /* Initialize a pstats timestamp structure. */ 127 extern void bcm_pstats_timestamp_t_init( 128 bcm_pstats_timestamp_t *timestamp); 129 130 /* Initialize a pstats session element structure. */ 131 extern void bcm_pstats_session_element_t_init( 132 bcm_pstats_session_element_t *element); 133 134 /* Initialize a pstats data structure. */ 135 extern void bcm_pstats_data_t_init( 136 bcm_pstats_data_t *data); 137 138 #endif /* defined(INCLUDE_PSTATS) */ 139 140 #endif /* __BCM_PSTATS_H__ */