BroadView™ API Guide and Reference Manual
bst.h
Go to the documentation of this file.
1 
9 /*****************************************************************************
10  *
11  * Copyright © 2016 Broadcom. The term "Broadcom" refers
12  * to Broadcom Limited and/or its subsidiaries.
13  *
14  * Licensed under the Apache License, Version 2.0 (the "License");
15  * you may not use this file except in compliance with the License.
16  *
17  * You may obtain a copy of the License at
18  * http://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS,
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  *
26  ***************************************************************************/
27 
28 #ifndef INCLUDE_BST_H
29 #define INCLUDE_BST_H
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35 
36 #include "broadview.h"
37 #include "asic.h"
38 #include "sbplugin.h"
39 
40 /* Buffer Count for the device */
41 typedef struct _bst_device_
42 {
43  uint64_t bufferCount;
45 
46 /* Buffer Count for Ingress Port + Priority Groups */
47 typedef struct _bst_i_p_pg_
48 {
49 
50  struct _ippg_data_
51  {
52  uint64_t umShareBufferCount;
53  uint64_t umHeadroomBufferCount;
54  } data[BVIEW_ASIC_MAX_PORTS][BVIEW_ASIC_MAX_PRIORITY_GROUPS];
55 
57 
58 /* Buffer Count for Ingress Port + Service Pools */
59 typedef struct _bst_i_p_sp_
60 {
61 
62  struct _ipsp_data_
63  {
64  uint64_t umShareBufferCount;
65  } data[BVIEW_ASIC_MAX_PORTS][BVIEW_ASIC_MAX_INGRESS_SERVICE_POOLS];
66 
68 
69 /* Buffer Count for Ingress Service Pools */
70 typedef struct _bst_i_sp_
71 {
72 
73  struct _isp_data_
74  {
75  uint64_t umShareBufferCount;
76  } data[BVIEW_ASIC_MAX_INGRESS_SERVICE_POOLS];
77 
79 
80 /* Buffer Count for Egress Port + Service Pools */
81 typedef struct _bst_e_p_sp_
82 {
83 
84  struct _epsp_data_
85  {
86  uint64_t ucShareBufferCount;
87  uint64_t umShareBufferCount;
88  uint64_t mcShareBufferCount;
89  uint64_t mcShareQueueEntries;
90  } data[BVIEW_ASIC_MAX_PORTS][BVIEW_ASIC_MAX_SERVICE_POOLS];
91 
93 
94 /* Buffer Count for Egress Service Pools */
95 typedef struct _bst_e_sp_
96 {
97 
98  struct _esp_data_
99  {
100  uint64_t umShareBufferCount;
101  uint64_t mcShareBufferCount;
102  uint64_t mcShareQueueEntries;
103  } data[BVIEW_ASIC_MAX_SERVICE_POOLS];
104 
106 
107 /* Buffer Count for Egress Unicast Queues */
108 typedef struct _bst_e_ucq_
109 {
110 
111  struct _eucq_data_
112  {
113  uint64_t ucBufferCount;
114  uint64_t port; /* to indicate the port number using this queue */
115  } data[BVIEW_ASIC_MAX_UC_QUEUES];
116 
118 
119 /* Buffer Count for Egress Unicast Queue Groups */
120 typedef struct _bst_e_ucqg_
121 {
122 
124  {
125  uint64_t ucBufferCount;
126  } data[BVIEW_ASIC_MAX_UC_QUEUE_GROUPS];
127 
129 
130 /* Buffer Count for Egress Multicast Queues */
131 typedef struct _bst_e_mcq_
132 {
133 
134  struct _emcq_data_
135  {
136  uint64_t mcBufferCount;
137  uint64_t mcQueueEntries;
138  uint64_t port; /* to indicate the port number using this queue */
139  } data[BVIEW_ASIC_MAX_MC_QUEUES];
140 
142 
143 /* Buffer Count for CPU Queues */
144 typedef struct _bst_cpu_q_
145 {
146 
147  struct _cpuq_data_
148  {
149  uint64_t cpuBufferCount;
150  uint64_t cpuQueueEntries;
151  } data[BVIEW_ASIC_MAX_CPU_QUEUES];
152 
154 
155 /* Buffer Count for RQE Queues */
156 typedef struct _bst_rqe_q_
157 {
158 
159  struct _rqeq_data_
160  {
161  uint64_t rqeBufferCount;
162  uint64_t rqeQueueEntries;
163  } data[BVIEW_ASIC_MAX_RQE_QUEUES];
164 
166 
167 /* A Complete Data set for a 'snapshot' */
168 
170 {
171  /* Device Section */
173 
174  /* Ingress Section */
178 
179  /* Egress Section */
187 
189 
190 /* Statistics collection mode */
191 typedef enum _bst_collection_mode_
192 {
193  BVIEW_BST_MODE_CURRENT = 1,
194  BVIEW_BST_MODE_PEAK
195 } BVIEW_BST_COLLECTION_MODE;
196 
197 /* Feature Configuration */
198 typedef struct _bst_config_
199 {
200  /* enable the feature */
201  bool enableStatsMonitoring;
202 
203  /* For enabling selectively. When all are disabled, feature is disabled. */
204  bool enableDeviceStatsMonitoring;
205  bool enableIngressStatsMonitoring;
206  bool enableEgressStatsMonitoring;
207 
208  /* Statistics collection mode */
209  BVIEW_BST_COLLECTION_MODE mode;
210  /*Periodic collection*/
211  bool enablePeriodicCollection;
212  int collectionPeriod;
214 
215 /* Trigger Type */
216 typedef enum _bst_trigger_type_
217 {
218  BVIEW_BST_TRIGGER_DEVICE = (0x1 << 0),
219  BVIEW_BST_TRIGGER_INGRESS = (0x1 << 1),
220  BVIEW_BST_TRIGGER_EGRESS = (0x1 << 2)
221 
222 } BVIEW_BST_TRIGGER_TYPE;
223 
224 #define BVIEW_MAX_STRING_NAME_LEN 256
225 /* Trigger info */
226 typedef struct _bst_trigger_info_
227 {
228  char realm[BVIEW_MAX_STRING_NAME_LEN];
229  char counter[BVIEW_MAX_STRING_NAME_LEN];
230  int port;
231  int queue;
233 
234 
235 /* Profile configuration for Egress Port + Service Pools */
236 typedef struct _bst_ep_sp_threshold_
237 {
238  uint64_t ucShareThreshold;
239  uint64_t umShareThreshold;
240  uint64_t mcShareThreshold;
241  uint64_t mcShareQueueEntriesThreshold;
243 
244 /* Profile configuration for the device level buffers*/
246 {
247  uint64_t threshold;
249 
250 /* Profile configuration for Ingress Port + Priority Groups */
252 {
253  uint64_t umShareThreshold;
254  uint64_t umHeadroomThreshold;
256 
257 /* Profile configuration for Ingress Port + Service Pools */
259 {
260  uint64_t umShareThreshold;
262 
263 /* Profile configuration for Ingress Service Pools */
264 typedef struct _bst_i_sp_threshold_
265 {
266  uint64_t umShareThreshold;
268 
269 /* Profile configuration for Egress Service Pools */
270 typedef struct _bst_e_sp_threshold_
271 {
272  uint64_t umShareThreshold;
273  uint64_t mcShareThreshold;
275 
276 /* Profile configuration for Egress Unicast Queues */
277 typedef struct _bst_e_ucq_threshold_
278 {
279  uint64_t ucBufferThreshold;
281 
282 /* Profile configuration for Egress Unicast Queue Groups */
284 {
285  uint64_t ucBufferThreshold;
287 
288 /* Profile configuration for Egress Multicast Queues */
289 typedef struct _bst_e_mcq_threshold_
290 {
291  uint64_t mcBufferThreshold;
292  uint64_t mcQueueThreshold;
294 
295 /* Profile configuration for CPU Queues */
296 typedef struct _bst_cpu_q_threshold_
297 {
298  uint64_t cpuBufferThreshold;
299  uint64_t cpuQueueThreshold;
301 
302 /* Profile configuration for RQE Queues */
303 typedef struct _bst_rqe_q_threshold_
304 {
305  uint64_t rqeBufferThreshold;
306  uint64_t rqeQueueThreshold;
308 
309 /* The callback for invoking when a configured trigger goes off */
310 typedef BVIEW_STATUS(*BVIEW_BST_TRIGGER_CALLBACK_t) (int asic,
311  void *cookie,
312  BVIEW_BST_TRIGGER_INFO_t *triggerInfo);
313 
314 
315 /* macros for threshold validation */
316 
317 
318 
319 /* Check the validity of The BST_Threshold for the Egress CPU queues in units of bytes */
320 #define BVIEW_BST_E_CPU_THRESHOLD_CHECK(_p) ((_p)->cpuBufferThreshold <= 0 || \
321  (_p)->cpuBufferThreshold > (BVIEW_BST_E_CPU_UCMC_THRES_DEFAULT))
322 
323 /* Check the validy of threshold configuration for Egress CPU Queues Entries*/
324 #define BVIEW_BST_E_CPU_QUEUE_THRESHOLD_CHECK(_p) ((_p)->cpuQueueThreshold <= 0 || \
325  (_p)->cpuQueueThreshold > (BVIEW_BST_E_CPU_UCMC_THRES_DEFAULT))
326 
327 /* Check the validy of threshold configuration for Egress Multicast Queues Statistics */
328 #define BVIEW_BST_E_MC_THRESHOLD_CHECK(_p) ((_p)->mcBufferThreshold <= 0 || \
329  (_p)->mcBufferThreshold > BVIEW_BST_MCAST_THRES_DEFAULT)
330 
331 /* Check the validy of threshold configuration for Egress Multicast Queues Entries*/
332 #define BVIEW_BST_E_MC_QUEUE_THRESHOLD_CHECK(_p) ((_p)->mcQueueThreshold <= 0 || \
333  (_p)->mcQueueThreshold > (0x1FFFF * 208))
334 
335 /* Check the validy of configuration for Egress Unicast Queue Groups Statistics */
336 #define BVIEW_BST_E_UC_GRP_THRESHOLD_CHECK(_p) ((_p)->ucBufferThreshold <= 0 || \
337  (_p)->ucBufferThreshold > BVIEW_BST_UCAST_QUEUE_GROUP_DEFAULT)
338 
339 /* Check the validy of configuration for Egress Unicast Queue Entries */
340 #define BVIEW_BST_E_UC_THRESHOLD_CHECK(_p) ((_p)->ucBufferThreshold <= 0 || \
341  (_p)->ucBufferThreshold > BVIEW_BST_UCAST_THRES_DEFAULT)
342 
343 /* Check the validy of threshold configuration for Egress Port Service Pools UC Statistics */
344 #define BVIEW_BST_EPSP_UC_THRESHOLD_CHECK(_p) ((_p)->ucShareThreshold <= 0 || \
345  (_p)->ucShareThreshold > BVIEW_BST_E_P_SP_UC_THRES_DEFAULT)
346 
347 /* Check the validy of threshold configuration for Egress Service Pools UC+MC Statistics */
348 #define BVIEW_BST_EPSP_UM_THRESHOLD_CHECK(_p) ((_p)->umShareThreshold <= 0 || \
349  (_p)->umShareThreshold > BVIEW_BST_E_P_SP_UCMC_THRES_DEFAULT)
350 
351 /* Check the validy of threshold configuration for Egress Service Pools MC Statistics */
352 #define BVIEW_BST_EPSP_MC_THRESHOLD_CHECK(_p) ((_p)->mcShareThreshold <= 0 || \
353  (_p)->mcShareThreshold > (0x1FFFF * 208))
354 
355 /* Check the validy of threshold configuration for Egress Service Pools UC+MC Statistics */
356 #define BVIEW_BST_EPSP_MC_SQ_THRESHOLD_CHECK(_p) ((_p)->mcShareQueueEntriesThreshold <= 0 || \
357  (_p)->mcShareQueueEntriesThreshold > (0x1FFFF * 208))
358 
359 /* Check the validy of threshold configuration for Ingress Service Pools MC+UC Statistics */
360 #define BVIEW_BST_IPSP_THRESHOLD_CHECK(_p) ((_p)->umShareThreshold <= 0 || \
361  (_p)->umShareThreshold > BVIEW_BST_I_SP_UCMC_SHARED_THRES_DEFAULT)
362 
363 /* Check the validy of threshold configuration for Ingress Priority Group MC+UC Statistics */
364 #define BVIEW_BST_IPPG_SHRD_THRESHOLD_CHECK(_p) ((_p)->umShareThreshold <= 0 || \
365  (_p)->umShareThreshold > BVIEW_BST_I_P_SP_UCMC_SHARED_THRES_DEFAULT)
366 
367 /* Check the validy of threshold configuration for Ingress Priority Group Headroom Statistics */
368 #define BVIEW_BST_IPPG_HDRM_THRESHOLD_CHECK(_p) ((_p)->umHeadroomThreshold <= 0 || \
369  (_p)->umHeadroomThreshold > BVIEW_BST_I_P_PG_UCMC_HDRM_THRES_DEFAULT)
370 
371 
372 /* Check the validy of threshold configuration for Device level Statistics*/
373 #define BVIEW_BST_DEVICE_THRESHOLD_CHECK(_p) ((_p)->threshold <= 0 || \
374  (_p)->threshold > BVIEW_BST_DEVICE_THRES_DEFAULT)
375 
376 /* Check the validy of threshold configuration for Ingress Serivce Pool*/
377 #define BVIEW_BST_ISP_THRESHOLD_CHECK(_p) ((_p)->umShareThreshold <=0 || \
378  (_p)->umShareThreshold > (0x1FFFF * 208))
379 
380 /* Check the validy of threshold configuration for Egress Service Pools UC + MCStatistics */
381 #define BVIEW_BST_E_SP_UM_THRESHOLD_CHECK(_p) ((_p)->umShareThreshold <= 0 || \
382  (_p)->umShareThreshold > BVIEW_BST_E_SP_UCMC_THRES_DEFAULT)
383 
384 
385 /* Check the validy of threshold configuration for Egress Service Pools MC Statistics */
386 #define BVIEW_BST_E_SP_MC_THRESHOLD_CHECK(_p) ((_p)->mcShareThreshold <= 0 || \
387  (_p)->mcShareThreshold > BVIEW_BST_E_SP_MC_THRES_DEFAULT)
388 
389 /* Check the validy of threshold configuration for Egress Service Pools MC in Queue Entries */
390 #define BVIEW_BST_E_SP_MC_SQ_THRESHOLD_CHECK(_p) ((_p)->mcShareQueueEntriesThreshold <= 0 || \
391  (_p)->mcShareQueueEntriesThreshold > (0x1FFFF * 208))
392 
393 
394 
395 /* Check the validy of threshold configuration for Egress RQE Queues in units of buffers */
396 #define BVIEW_BST_E_RQE_THRESHOLD_CHECK(_p) ((_p)->rqeBufferThreshold <= 0 || \
397  (_p)->rqeBufferThreshold > BVIEW_BST_E_RQE_THRES_DEFAULT)
398 
399 /* Check the validy of threshold configuration for RQE Queues in units of queue Entries*/
400 #define BVIEW_BST_E_RQE_QUEUE_THRESHOLD_CHECK(_p) ((_p)->rqeQueueThreshold <= 0 || \
401  (_p)->rqeQueueThreshold > (0xFFF * 208))
402 
403 /* Check the validy of threshold configuration for mc egress Queues grp in units of queue Entries*/
404 #define BVIEW_BST_E_MC_QG_THRESHOLD_CHECK(_p) ((_p)->mcThreshold <= 0 || \
405  (_p)->mcThreshold > (0x1FFFF * 208))
406 
407 /* Check the validy of threshold configuration for mc shared egress Queues grp in units of queue Entries*/
408 #define BVIEW_BST_E_MC_SQG_THRESHOLD_CHECK(_p) ((_p)->mcQueueEntriesThreshold <= 0 || \
409  (_p)->mcQueueEntriesThreshold > (0x1FFFF * 208))
410 
411 
412 /* Check the validy of threshold configuration for Egress CPU Queues Statistics */
413 #define BVIEW_BST_EGRESS_CPU_THRESHOLD_CHECK(_p) ((_p)->cpuThreshold <= 0 || \
414  (_p)->cpuThreshold > (0x1FFFF * 208))
415 
416 
417 /* Check the validy of threshold configuration for Egress RQE Queues Statistics */
418 #define BVIEW_BST_EGRESS_RQE_QUEUE_THRESHOLD_CHECK(_p) ((_p)->rqeThreshold <= 0 || \
419  (_p)->rqeThreshold > (0x1FFFF * 208))
420 
421 
422 /* Check the validy of threshold configuration for Egress RQE Queues Statistics */
423 #define BVIEW_BST_EGRESS_UC_THRESHOLD_CHECK(_p) ((_p)->ucThreshold <= 0 || \
424  (_p)->ucThreshold > (0x1FFFF * 208))
425 
426 /* Check the validy of configuration for Egress Unicast Queue Groups Statistics */
427 #define BVIEW_BST_EGRESS_UC_GRP_THRESHOLD_CHECK(_p) ((_p)->ucThreshold <= 0 || \
428  (_p)->ucThreshold > BVIEW_BST_UCAST_QUEUE_GROUP_DEFAULT)
429 
430 typedef enum _threshold_fields_
431 {
432  DEVICE_COUNTER = 0,
433  UMSHARE_COUNTER,
434  UMHEADROOM_COUNTER,
435  UCSHARE_COUNTER,
436  MCSHARE_COUNTER,
437  MCSHARE_QUEUE_COUNTER,
438  UC_COUNTER,
439  MCQUEUE_COUNTER,
440  MC_COUNTER,
441  CPU_COUNTER,
442  RQE_COUNTER
443 }BVIEW_BST_COUNTER_t;
444 
445 #define BVIEW_BST_REALM_MAX RQE_COUNTER
446 
447 #define BVIEW_BST_PORT_POS (BVIEW_BST_REALM_MAX+1)
448 #define BVIEW_BST_SP_POS (BVIEW_BST_REALM_MAX+2)
449 #define BVIEW_BST_PG_POS (BVIEW_BST_REALM_MAX+3)
450 #define BVIEW_BST_QUEUE_POS (BVIEW_BST_REALM_MAX+4)
451 #define BVIEW_BST_QUEUE_GRP_POS (BVIEW_BST_REALM_MAX+5)
452 
453 #define BVIEW_BST_DEVICE_MASK (1<<DEVICE_COUNTER)
454 #define BVIEW_BST_UMSHARE_MASK (1<<UMSHARE_COUNTER)
455 #define BVIEW_BST_UMHEADROOM_MASK (1<<UMHEADROOM_COUNTER)
456 #define BVIEW_BST_UCSHARE_MASK (1<<UCSHARE_COUNTER)
457 #define BVIEW_BST_MCSHARE_MASK (1<<MCSHARE_COUNTER)
458 #define BVIEW_BST_MCSHARE_QUEUE_MASK (1<<MCSHARE_QUEUE_COUNTER)
459 #define BVIEW_BST_UC_MASK (1<<UC_COUNTER)
460 #define BVIEW_BST_MCQUEUE_MASK (1<<MCQUEUE_COUNTER)
461 #define BVIEW_BST_MC_MASK (1<<MC_COUNTER)
462 #define BVIEW_BST_CPU_MASK (1<<CPU_COUNTER)
463 #define BVIEW_BST_RQE_MASK (1<<RQE_COUNTER)
464 
465 #define BVIEW_BST_PORT_MASK (1<<BVIEW_BST_PORT_POS)
466 #define BVIEW_BST_SP_MASK (1<<BVIEW_BST_SP_POS)
467 #define BVIEW_BST_PG_MASK (1<<BVIEW_BST_PG_POS)
468 #define BVIEW_BST_QUEUE_MASK (1<<BVIEW_BST_QUEUE_POS)
469 #define BVIEW_BST_QUEUE_GRP_MASK (1<<BVIEW_BST_QUEUE_GRP_POS)
470 
471 
472 
473 /*****************************************************************/
489 BVIEW_STATUS bst_main ();
490 
491 /*****************************************************************/
503 void bst_app_uninit();
504 
505 /*****************************************************************/
515 BVIEW_STATUS bst_app_main(void);
516 
517 /*****************************************************************/
530 BVIEW_STATUS bst_app_config_init(unsigned int num_units);
531 
532 BVIEW_STATUS bst_cancel_request(unsigned int unit, unsigned int id);
533 
534 
535 #ifdef __cplusplus
536 }
537 /* __doxy_func_body_end__ */
538 #endif
539 
540 
541 #endif /* INCLUDE_BST_H */
542