latency_monitor.h (8184B)
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 * DO NOT EDIT THIS FILE! 9 * This file is auto-generated. 10 * Edits to this file will be lost when it is regenerated. 11 */ 12 13 #ifndef __BCM_LATENCY_MONITOR_H__ 14 #define __BCM_LATENCY_MONITOR_H__ 15 16 #include <bcm/types.h> 17 18 /* Latency Monitor operation mode. */ 19 typedef enum bcm_latency_monitor_mode_e { 20 bcmLatencyMonitorAccrueMode = 0, /* Histogram data is accumulated per 21 queue per bucket */ 22 bcmLatencyMonitorTimeSeriesMode = 1 /* Histogram data retains the time 23 series info */ 24 } bcm_latency_monitor_mode_t; 25 26 /* Latency Monitor count mode (cut-through/store-and-Forward/All). */ 27 typedef enum bcm_latency_monitor_count_mode_e { 28 bcmLatencyMonitorCutThrough = 0, /* Count only cut through packets. */ 29 bcmLatencyMonitorStoreAndForward = 1, /* Count only store and forward packets. */ 30 bcmLatencyMonitorCountAll = 2 /* Count all types of packets. */ 31 } bcm_latency_monitor_count_mode_t; 32 33 /* Latency Monitor status */ 34 typedef enum bcm_latency_monitor_status_e { 35 bcmLatencyMonitorStatusUninit = 0, /* Latency Monitor is in Uninitialized 36 state. */ 37 bcmLatencyMonitorStatusIdle = 1, /* Latency Monitor is in Idle state. */ 38 bcmLatencyMonitorStatusRunning = 2, /* Latency Monitor is in Running state. */ 39 bcmLatencyMonitorStatusError = 3 /* Latency Monitor is in Faulty state. */ 40 } bcm_latency_monitor_status_t; 41 42 /* Per COSQ latency limit configuration structure */ 43 typedef struct bcm_latency_monitor_cosq_info_s { 44 uint8 bucket_count; /* Number of histogram buckets for a 45 given cosq. */ 46 uint8 latency_index_array[BCM_MAX_HISTOGRAM_BUCKET_COUNT-1]; /* Array of indexes in to the latency 47 limit table. The indexed value is the 48 upper latency limit for the 49 corresponding bucket. */ 50 } bcm_latency_monitor_cosq_info_t; 51 52 /* Histogram for a given cosq id. */ 53 typedef struct bcm_latency_monitor_histogram_s { 54 uint8 histogram_size; /* Number of histogram counters for a 55 given cosq. */ 56 uint64 histogram[BCM_MAX_HISTOGRAM_BUCKET_COUNT]; /* Array of histogram counters */ 57 } bcm_latency_monitor_histogram_t; 58 59 /* Latency Monitor status informations. */ 60 typedef struct bcm_latency_monitor_info_s { 61 bcm_latency_monitor_status_t monitor_status; /* Monitor status */ 62 void *sw_buf_addr; /* Base address of 64 bits wide (Bit 63 Field 0:27 Packet Counter, Bit field 64 28:63 is Byte Counter) software ring 65 buffer (Valid in Time Series Mode 66 only). */ 67 uint32 sw_buf_size; /* Size of Software ring buffer in terms 68 of 64 bit width (Valid in Time Series 69 Mode only). */ 70 uint32 sw_buf_wr_idx; /* Index in to the software ring buffer 71 pointing to last counter write 72 operation (Valid in Time Series Mode 73 only). */ 74 } bcm_latency_monitor_info_t; 75 76 /* 77 * User application call back function on update of counter info in 78 * software ring buffer (Valid in TIME_SERIES mode only). 79 */ 80 typedef int (*bcm_latency_monitor_cb)( 81 int unit, 82 uint8 monitor_id, 83 bcm_latency_monitor_status_t monitor_status, 84 void *sw_buf_addr, 85 uint32 sw_buf_size, 86 uint32 sw_buf_wr_idx); 87 88 /* Monitor configuration structure */ 89 typedef struct bcm_latency_monitor_config_s { 90 bcm_latency_monitor_mode_t mode; /* Monitor operation mode. */ 91 bcm_pbmp_t src_pbmp; /* Ingress Port Bit Map */ 92 bcm_pbmp_t dest_pbmp; /* Egress Port Bit Map */ 93 uint32 time_step; /* Time series step value in Micro Sec. 94 (Min 100 ms). */ 95 bcm_latency_monitor_count_mode_t count_mode; /* cut-though or store-and-Forward or 96 Count All */ 97 uint32 histogram_set_count; /* Max number of histogram sets to 98 accomodate in Software Ring Buffer 99 (Minimum is 10). */ 100 bcm_latency_monitor_cb cb; /* User callback function on 101 availability of counter info in the 102 software ring buffer. */ 103 } bcm_latency_monitor_config_t; 104 105 /* Initialize the Monitor configuration structure. */ 106 extern void bcm_latency_monitor_config_t_init( 107 bcm_latency_monitor_config_t *config); 108 109 /* Initialize the COSQ latency limit configuration structure. */ 110 extern void bcm_latency_monitor_cosq_info_t_init( 111 bcm_latency_monitor_cosq_info_t *config); 112 113 /* Initialize the latency monitor histogram structure. */ 114 extern void bcm_latency_monitor_histogram_t_init( 115 bcm_latency_monitor_histogram_t *histogram); 116 117 /* Initialize the latency monitor info structure. */ 118 extern void bcm_latency_monitor_info_t_init( 119 bcm_latency_monitor_info_t *monitor_info); 120 121 #ifndef BCM_HIDE_DISPATCHABLE 122 123 /* Set a monitor with given configuration. */ 124 extern int bcm_latency_monitor_config_set( 125 int unit, 126 uint8 monitor_id, 127 bcm_latency_monitor_config_t *config); 128 129 /* Get configuration for a given monitor. */ 130 extern int bcm_latency_monitor_config_get( 131 int unit, 132 uint8 monitor_id, 133 bcm_latency_monitor_config_t *config); 134 135 /* 136 * Configures the LATENCY_LIMIT device table, which has 32 entries max 137 * and each entry is specified in terms of 64 nSec quanta. 138 */ 139 extern int bcm_latency_monitor_latency_limit_table_set( 140 int unit, 141 uint8 table_size, 142 uint32 *latency_limit_table); 143 144 /* 145 * Output is the table size and configured values of LATENCY_LIMIT device 146 * table. 147 */ 148 extern int bcm_latency_monitor_latency_limit_table_get( 149 int unit, 150 uint8 table_size, 151 uint32 *latency_limit_table); 152 153 /* 154 * Configure the bucket size and upper latency limit of each bucket for a 155 * given cos queue and monitor. 156 */ 157 extern int bcm_latency_monitor_cosq_config_set( 158 int unit, 159 uint8 monitor_id, 160 uint8 cosq, 161 bcm_latency_monitor_cosq_info_t cosq_info); 162 163 /* 164 * Output is the bucket size and upper latency limit of each bucket for a 165 * given cos queue and monitor. 166 */ 167 extern int bcm_latency_monitor_cosq_config_get( 168 int unit, 169 uint8 monitor_id, 170 uint8 cosq, 171 bcm_latency_monitor_cosq_info_t *cosq_info); 172 173 /* Enable or Disable a given monitor */ 174 extern int bcm_latency_monitor_enable( 175 int unit, 176 uint8 monitor_id, 177 uint8 enable); 178 179 /* 180 * Returns the accrued histogram counter values for a given monitor ID 181 * and cosq (Valid in Accrue mode only) 182 */ 183 extern int bcm_latency_monitor_histogram_get( 184 int unit, 185 uint8 monitor_id, 186 uint8 cosq, 187 uint8 byte_counter_flag, 188 bcm_latency_monitor_histogram_t *histogram); 189 190 /* Get the monitor status information for a given monitor id. */ 191 extern int bcm_latency_monitor_info_get( 192 int unit, 193 uint8 monitor_id, 194 bcm_latency_monitor_info_t *monitor_info); 195 196 /* 197 * Release all the resource allocated for a given monitor (Effective only 198 * when the monitor is in Disable/Error state). 199 */ 200 extern int bcm_latency_monitor_destroy( 201 int unit, 202 uint8 monitor_id); 203 204 /* Initialize the Latency monitor subsystem. */ 205 extern int bcm_latency_monitor_init( 206 int unit); 207 208 /* Shut down the latency_monitor subsystem. */ 209 extern int bcm_latency_monitor_detach( 210 int unit); 211 212 #endif /* BCM_HIDE_DISPATCHABLE */ 213 214 #endif /* __BCM_LATENCY_MONITOR_H__ */