instru.h (36871B)
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_INSTRU_H__ 11 #define __BCM_INSTRU_H__ 12 13 #include <bcm/types.h> 14 #include <bcm/error.h> 15 #include <shared/pp.h> 16 17 /* Node type of IPT profile */ 18 typedef enum bcm_instru_ipt_node_type_e { 19 bcmInstruIptNodeTypeTail = 0, /* Tail */ 20 bcmInstruIptNodeTypeIntOverVxlanFirst = 1, /* Vxlan first node */ 21 bcmInstruIptNodeTypeIntOverVxlanIntermediate = 2, /* Vxlan intermediate node */ 22 bcmInstruIptNodeTypeIntOverVxlanLast = 3 /* Vxlan last node */ 23 } bcm_instru_ipt_node_type_t; 24 25 /* Control of various Instrumentation features */ 26 typedef enum bcm_instru_control_e { 27 bcmInstruControlIptSwitchId = 0, /* IPT switch ID */ 28 bcmInstruControlVisMode = 1, /* Visibility Mode */ 29 bcmInstruControlVisSampling = 2, /* Visibility sampling parameters in 30 Selective mode */ 31 bcmInstruControlSFlowSamplingRate = 3, /* Global sampling rate for sFlow 32 datagrams */ 33 bcmInstruControlSFlowAgentIPAddress = 4, /* Global agent IP address for sFlow 34 datagrams */ 35 bcmInstruControlSFlowUpTime = 5, /* Time stamp that will be stamped on 36 sFlow packets. Should be updated 37 periodically. */ 38 bcmInstruControlSFlowMyRouterASNumber = 6 /* Router/switch (my node) AS number. */ 39 } bcm_instru_control_t; 40 41 /* 42 * Supported visibility modes, used in arg when type is 43 * bcmInstruControlVisMode 44 */ 45 typedef enum bcm_instru_vis_mode_control_e { 46 bcmInstruVisModeNone = 0, /* No visibility enabled */ 47 bcmInstruVisModeAlways = 1, /* Visibility is enabled for any packet from 48 any port */ 49 bcmInstruVisModeSelective = 2 /* Selective visibility enabled, user port 50 control to enable specific resources */ 51 } bcm_instru_vis_mode_control_t; 52 53 /* Control of various per-port Instrumentation features */ 54 typedef enum bcm_instru_gport_control_e { 55 bcmInstruGportControlTraceProbability = 0, /* Probability in one tenth percentage */ 56 bcmInstruGportControlVisEnable = 1, /* Enable visibility on per port basis */ 57 bcmInstruGportControlVisForce = 2, /* Force visibility on per port basis */ 58 bcmInstruGportControlIptTrapToRcyEnable = 3, /* Trap IPT packet to Recycle interface */ 59 bcmInstruGportControlIfaInitiatorRcyEnable = 4 /* Set IFA Initiator recycle enable. */ 60 } bcm_instru_gport_control_t; 61 62 /* IPT first node header values */ 63 typedef struct bcm_instru_ipt_first_node_header_s { 64 uint32 options; /* Options field */ 65 uint32 type; /* Type field */ 66 uint32 length; /* IPT header length length in bytes */ 67 } bcm_instru_ipt_first_node_header_t; 68 69 /* IPT info */ 70 typedef struct bcm_instru_ipt_s { 71 bcm_instru_ipt_node_type_t node_type; /* Node type */ 72 uint32 metadata_flags; /* Metadata flags */ 73 bcm_instru_ipt_first_node_header_t first_node_header; /* First header info */ 74 } bcm_instru_ipt_t; 75 76 /* Flags controlling global visibiliy behavior */ 77 #define BCM_INSTRU_CONTROL_FLAG_DIRECTION_INGRESS 0x1 /* Apply control to 78 INGRESS direction */ 79 #define BCM_INSTRU_CONTROL_FLAG_DIRECTION_EGRESS 0x2 /* Apply control to 80 EGRESS direction */ 81 82 /* Flags controlling signal get behavior */ 83 #define BCM_INSTRU_VIS_SIGNAL_FLAG_RETURN_ON_1ST_ERROR 0x1 /* Values for all signals 84 in the key list should 85 be successfully 86 obtained */ 87 88 #ifndef BCM_HIDE_DISPATCHABLE 89 90 /* Set/Get visibility mode */ 91 extern int bcm_instru_control_set( 92 int unit, 93 uint32 flags, 94 bcm_instru_control_t type, 95 int arg); 96 97 /* Set/Get visibility mode */ 98 extern int bcm_instru_control_get( 99 int unit, 100 uint32 flags, 101 bcm_instru_control_t type, 102 int *arg); 103 104 /* Set/Get visibility mode */ 105 extern int bcm_instru_gport_control_set( 106 int unit, 107 bcm_gport_t gport, 108 uint32 flags, 109 bcm_instru_gport_control_t type, 110 int arg); 111 112 /* Set/Get visibility mode */ 113 extern int bcm_instru_gport_control_get( 114 int unit, 115 bcm_gport_t gport, 116 uint32 flags, 117 bcm_instru_gport_control_t type, 118 int *arg); 119 120 /* Get various instrumentation features at the port level. */ 121 extern int bcm_instru_ipt_profile_set( 122 int unit, 123 uint32 flags, 124 int ipt_profile, 125 bcm_instru_ipt_t *config); 126 127 /* Get various instrumentation features at the port level. */ 128 extern int bcm_instru_ipt_profile_get( 129 int unit, 130 uint32 flags, 131 int ipt_profile, 132 bcm_instru_ipt_t *config); 133 134 #endif /* BCM_HIDE_DISPATCHABLE */ 135 136 /* Initialize bcm_instru_ipt_t struct. */ 137 extern void bcm_instru_ipt_t_init( 138 bcm_instru_ipt_t *config); 139 140 /* IPT metadata options */ 141 #define BCM_INSTRU_IPT_METADATA_FLAG_INGRESS_TOD 0x1 /* INGRESS TOD */ 142 #define BCM_INSTRU_IPT_METADATA_FLAG_INGRESS_SYS_PORT 0x2 /* INGRESS PORT */ 143 #define BCM_INSTRU_IPT_METADATA_FLAG_INGRESS_DEV_ID 0x4 /* INGRESS DEVICE ID */ 144 #define BCM_INSTRU_IPT_METADATA_FLAG_INGRESS_RESERVED 0x8 /* INGRESS RESERVED */ 145 #define BCM_INSTRU_IPT_METADATA_FLAG_EGRESS_TOD 0x10 /* EGRESS TOD */ 146 #define BCM_INSTRU_IPT_METADATA_FLAG_EGRESS_SYS_PORT 0x20 /* EGRESS PORT */ 147 #define BCM_INSTRU_IPT_METADATA_FLAG_EGRESS_DEV_ID 0x40 /* EGRESS DEVICE ID */ 148 #define BCM_INSTRU_IPT_METADATA_FLAG_SWITCH_ID 0x80 /* SWITCH ID */ 149 #define BCM_INSTRU_IPT_METADATA_FLAG_EGRESS_RESERVED 0x100 /* EGRESS RESERVED */ 150 #define BCM_INSTRU_IPT_METADATA_FLAG_QUEUE_INFO 0x200 /* QUEUE INFO */ 151 #define BCM_INSTRU_IPT_METADATA_FLAG_QUEUE_SIZE_FG 0x400 /* Queue Level Fine 152 Granularity */ 153 #define BCM_INSTRU_IPT_METADATA_FLAG_LATENCY 0x800 /* Latency in nanoseconds */ 154 #define BCM_INSTRU_IPT_METADATA_FLAG_PORT_RATE 0x1000 /* NIF Port rate */ 155 #define BCM_INSTRU_IPT_METADATA_FLAG_QUEUE_SIZE_CG 0x2000 /* Queue Level Coarse 156 Granularity */ 157 158 /* sFlow encap flags. */ 159 #define BCM_INSTRU_SFLOW_ENCAP_WITH_ID (1 << 0) /* Allocate with sflow 160 encap id. */ 161 #define BCM_INSTRU_SFLOW_ENCAP_REPLACE (1 << 1) /* Replace existing 162 entry, update 163 EEDB_SFLOW, 164 EGRESS_OAM_LIF_DB 165 tables. */ 166 #define BCM_INSTRU_SFLOW_ENCAP_AGGREGATED (1 << 2) /* Sflow samples will be 167 aggregated. */ 168 #define BCM_INSTRU_SFLOW_ENCAP_EXTENDED_INITIATOR (1 << 3) /* Sflow Extended Gateway 169 mode (Sflow IPoETH 170 sampling) initator. */ 171 #define BCM_INSTRU_SFLOW_ENCAP_EXTENDED_FLOW (1 << 4) /* Sflow Extended Gateway 172 mode (Sflow IPoETH 173 sampling) per flow. */ 174 #define BCM_INSTRU_SFLOW_ENCAP_EXTENDED_IPV6 (1 << 5) /* Sflow Extended Gateway 175 mode (Sflow IPoETH 176 sampling) IPv6 mode. */ 177 #define BCM_INSTRU_SFLOW_ENCAP_EXTENDED_NOF_DSTS 4 /* MAX number of 178 Autonomous system path 179 to the destination. */ 180 181 /* SFlow EEDB instrumentation info */ 182 typedef struct bcm_instru_sflow_encap_info_s { 183 uint32 flags; /* See BCM_INSTRU_SFLOW_ENCAP_XXX flags definitions. */ 184 int sflow_encap_id; /* Global lif */ 185 bcm_gport_t tunnel_id; /* next eedb pointer - udp tunnel id */ 186 int stat_cmd; /* Statistic command - request sequence number */ 187 int counter_command_id; /* Command id (interface id) */ 188 int sub_agent_id; /* sub_agent_id for this sFlow encap */ 189 uint16 eventor_id; /* Eventor RX context to use for this flow */ 190 } bcm_instru_sflow_encap_info_t; 191 192 /* Sflow Sample Interface info */ 193 typedef struct bcm_instru_sflow_sample_interface_info_s { 194 uint32 flags; /* See BCM_INSTRU_SFLOW_SAMPLE_INTERFACE_XXX flags 195 definitions. */ 196 bcm_gport_t port; /* Local or System port */ 197 int interface; /* Interface the packet received/sent on */ 198 } bcm_instru_sflow_sample_interface_info_t; 199 200 /* Sflow Sample Interface Traverse info */ 201 typedef struct bcm_instru_sflow_sample_interface_traverse_info_s { 202 uint32 flags; /* See BCM_INSTRU_SFLOW_SAMPLE_INTERFACE_XXX flags 203 definitions. */ 204 } bcm_instru_sflow_sample_interface_traverse_info_t; 205 206 /* Sflow Sample Interface callback function prototype */ 207 typedef int (*bcm_instru_sflow_sample_traverse_cb)( 208 int unit, 209 bcm_instru_sflow_sample_interface_info_t *sample_interface_info, 210 void *user_data); 211 212 /* Vswitch callback function prototype */ 213 typedef int (*bcm_instru_sflow_encap_traverse_cb)( 214 int unit, 215 bcm_instru_sflow_encap_info_t *sflow_encap_info, 216 void *user_data); 217 218 #ifndef BCM_HIDE_DISPATCHABLE 219 220 /* Create/Get/Delete/Traverse sFlow etps types */ 221 extern int bcm_instru_sflow_encap_create( 222 int unit, 223 bcm_instru_sflow_encap_info_t *sflow_encap_info); 224 225 /* Create/Get/Delete/Traverse sFlow etps types */ 226 extern int bcm_instru_sflow_encap_get( 227 int unit, 228 bcm_instru_sflow_encap_info_t *sflow_encap_info); 229 230 /* Create/Get/Delete/Traverse sFlow etps types */ 231 extern int bcm_instru_sflow_encap_delete( 232 int unit, 233 bcm_instru_sflow_encap_info_t *sflow_encap_info); 234 235 /* Create/Get/Delete/Traverse sFlow etps types */ 236 extern int bcm_instru_sflow_encap_traverse( 237 int unit, 238 bcm_instru_sflow_encap_traverse_cb cb, 239 void *user_data); 240 241 #endif /* BCM_HIDE_DISPATCHABLE */ 242 243 /* Eventor context ID. */ 244 typedef uint16 bcm_eventor_context_id_t; 245 246 /* Eventor event ID. */ 247 typedef uint16 bcm_eventor_event_id_t; 248 249 /* Eventor engine ID. */ 250 typedef uint16 bcm_eventor_builder_id_t; 251 252 /* Number of Eventor srum bank. */ 253 typedef uint16 bcm_eventor_sram_bank_t; 254 255 /* Eventor context type */ 256 typedef enum bcm_eventor_context_type_e { 257 bcmEventorContextTypeRx = 0, /* RX Eventor context type */ 258 bcmEventorContextTypeTx = 1, /* TX Eventor context type */ 259 bcmEventorContextTypeTxFifo = 2, /* FIFO (TX) Eventor context type */ 260 bcmEventorContextTypeAny = 255 /* A value used to get any Eventor 261 context type in a get operation. Not 262 a real type */ 263 } bcm_eventor_context_type_t; 264 265 /* instru access info. */ 266 typedef struct bcm_instru_access_info_s { 267 uint32 flags; /* is register/memory, is broadcast */ 268 uint32 address; /* address/offset inside the block */ 269 uint16 phys_block; /* CMIC block ID */ 270 uint16 nof_entries; /* number of consecutive entries to read/write */ 271 uint16 entry_size; /* size of register/memory entry in 32 bit words */ 272 } bcm_instru_access_info_t; 273 274 /* Configuration for events with a specific event ID. */ 275 typedef struct bcm_instru_eventor_event_id_config_s { 276 uint32 flags; /* event config flags */ 277 bcm_eventor_context_id_t context; /* Context to use for Tx events with 278 this ID. */ 279 } bcm_instru_eventor_event_id_config_t; 280 281 /* Operations in the DMA program filling the buffers. */ 282 typedef struct bcm_instru_eventor_operation_s { 283 uint32 flags; /* control flags: TX/additional buffer */ 284 uint32 buf_offset; /* offset inside the buffer in 4 byte 285 words */ 286 bcm_instru_access_info_t access_info; /* memory,register access information */ 287 } bcm_instru_eventor_operation_t; 288 289 /* Constant value to be used in Eventor output. */ 290 typedef struct bcm_instru_eventor_const_value_s { 291 uint32 value; /* 4 byte words constant value to be used in Eventor output */ 292 uint32 offset; /* output offset for the constant value in 4 byte words */ 293 } bcm_instru_eventor_const_value_t; 294 295 #define BCM_INSTRU_EVENTOR_TIMEOUT_NONE ((uint32)-1) /* No timeout */ 296 #define BCM_INSTRU_EVENTOR_TIMEOUT_MINIMAL 0 /* smallest timeout 297 possible */ 298 #define BCM_INSTRU_ACCESS_FLAG_IS_WRITE 0x1 /* is a write operation */ 299 #define BCM_INSTRU_ACCESS_FLAG_IS_MEM 0x2 /* is a memory (and not 300 a register) access */ 301 302 /* Eventor context configuration */ 303 typedef struct bcm_instru_eventor_context_conf_s { 304 uint32 flags; /* control flags: Was there enough room 305 to return the full DMA program and 306 all constant values , auto select 307 bank/buffer for RX , event type 308 (RX/FIFO/TX) */ 309 bcm_eventor_sram_bank_t bank1; /* SRAM bank used for first buffer */ 310 bcm_eventor_sram_bank_t bank2; /* SRAM bank used for second buffer */ 311 uint32 buffer_size; /* buffer size in 4 byte words used for 312 both buffers */ 313 uint32 buffer1_start; /* offset in 4 byte words in the SRAM 314 bank of the first buffer */ 315 uint32 buffer2_start; /* offset in 4 byte words in the SRAM 316 bank of the second buffer */ 317 uint32 program1_start; /* offset in 4 byte words in the SRAM 318 bank of the first buffer's DMA 319 program filling the buffer */ 320 uint32 program2_start; /* offset in 4 byte words in the SRAM 321 bank of the second buffer's DMA 322 program filling the buffer */ 323 uint32 nof_operations; /* number operations in the DMA program 324 filling the buffers */ 325 bcm_instru_eventor_operation_t *operations; /* The operations in the DMA program 326 filling the buffers */ 327 uint32 nof_const_values; /* number constant values to be used in 328 Eventor output */ 329 bcm_instru_eventor_const_value_t *const_values; /* Constant value to be used in Eventor 330 output */ 331 uint32 builders; /* Context used Builders bitmap */ 332 } bcm_instru_eventor_context_conf_t; 333 334 #ifndef BCM_HIDE_DISPATCHABLE 335 336 /* Set the configuration of the given context */ 337 extern int bcm_instru_eventor_context_set( 338 int unit, 339 uint32 flags, 340 bcm_eventor_context_id_t context, 341 bcm_eventor_context_type_t context_type, 342 bcm_instru_eventor_context_conf_t *conf); 343 344 /* Get the configuration of the given context */ 345 extern int bcm_instru_eventor_context_get( 346 int unit, 347 uint32 flags, 348 bcm_eventor_context_id_t context, 349 bcm_eventor_context_type_t context_type, 350 bcm_instru_eventor_context_conf_t *out_conf); 351 352 #endif /* BCM_HIDE_DISPATCHABLE */ 353 354 /* Eventor builder configuration */ 355 typedef struct bcm_instru_eventor_builder_conf_s { 356 uint32 flags; /* control flags */ 357 uint32 thresh_size; /* When this amount of 4 byte words is reached, 358 generate a packet */ 359 uint32 thresh_time; /* When this amount of ms passes since stated 360 receiving data, generate a packet. May take 361 BCM_INSTRU_EVENTOR_TIMEOUT_* */ 362 uint32 header_length; /* The length, in bytes, of the header to use in 363 generated packets */ 364 uint8 *header_data; /* The data of the header to use in generated 365 packets */ 366 } bcm_instru_eventor_builder_conf_t; 367 368 #ifndef BCM_HIDE_DISPATCHABLE 369 370 /* Set the configuration of the given builder. */ 371 extern int bcm_instru_eventor_builder_set( 372 int unit, 373 uint32 flags, 374 bcm_eventor_builder_id_t builder, 375 bcm_instru_eventor_builder_conf_t *conf); 376 377 /* Get the configuration of the given builder. */ 378 extern int bcm_instru_eventor_builder_get( 379 int unit, 380 uint32 flags, 381 bcm_eventor_builder_id_t builder, 382 bcm_instru_eventor_builder_conf_t *out_conf); 383 384 /* get the low level access information for a memory */ 385 extern int bcm_instru_get_memory_access_info( 386 int unit, 387 uint32 flags, 388 int mem, 389 uint32 copyno, 390 uint32 index, 391 uint32 array_index, 392 bcm_instru_access_info_t *access_info); 393 394 /* get the low level access information for a register */ 395 extern int bcm_instru_get_register_access_info( 396 int unit, 397 uint32 flags, 398 int reg, 399 uint32 instance, 400 uint32 array_index, 401 bcm_instru_access_info_t *access_info); 402 403 /* Start or stop the Eventor. */ 404 extern int bcm_instru_eventor_active_set( 405 int unit, 406 uint32 flags, 407 int active); 408 409 /* Check id the Eventor is active/started. */ 410 extern int bcm_instru_eventor_active_get( 411 int unit, 412 uint32 flags, 413 int *out_active); 414 415 /* Clean signal cache and allow signals for new packet to be recorded */ 416 extern int bcm_instru_vis_resume( 417 int unit, 418 bcm_core_t core_id, 419 uint32 flags); 420 421 #endif /* BCM_HIDE_DISPATCHABLE */ 422 423 /* Maximum Sizes for different objects used by signal_get API */ 424 #define BCM_INSTRU_VIS_SIGNAL_NAME_MAX_SIZE SHR_PP_SIGNAL_NAME_MAX_SIZE /* Maximum size for 425 signal name */ 426 #define BCM_INSTRU_VIS_STAGE_NAME_MAX_SIZE SHR_PP_STAGE_NAME_MAX_SIZE /* Maximum size for 427 signal name */ 428 #define BCM_INSTRU_VIS_SIGNAL_VALUE_MAX_SIZE_UINT32 SHR_PP_SIGNAL_VALUE_MAX_SIZE_UINT32 /* Maximum size for 429 signal value */ 430 #define BCM_INSTRU_VIS_BLOCK_NAME_MAX_SIZE SHR_PP_BLOCK_NAME_MAX_SIZE /* Maximum size for 431 signal name */ 432 #define BCM_INSTRU_VIS_SIGNAL_PRINT_VALUE_MAX_SIZE_STR SHR_PP_SIGNAL_PRINT_VALUE_MAX_SIZE_STR /* Maximum size for 433 signal print value */ 434 435 /* Sflow Sample Interface flags. */ 436 #define BCM_INSTRU_SFLOW_SAMPLE_INTERFACE_REPLACE 1 /* Replace existing 437 mapping. */ 438 #define BCM_INSTRU_SFLOW_SAMPLE_INTERFACE_INPUT 2 /* The Interface is INPUT */ 439 #define BCM_INSTRU_SFLOW_SAMPLE_INTERFACE_OUTPUT 4 /* The Interface is 440 OUTPUT */ 441 #define BCM_INSTRU_SFLOW_SAMPLE_INTERFACE_DELETE_ALL 8 /* Delete all interface 442 mapping */ 443 444 /* Result of signal fetching */ 445 typedef struct bcm_instru_vis_signal_result_s { 446 uint32 value[BCM_INSTRU_VIS_SIGNAL_VALUE_MAX_SIZE_UINT32]; /* Signal value */ 447 char print_value[BCM_INSTRU_VIS_SIGNAL_PRINT_VALUE_MAX_SIZE_STR]; /* Signal print value */ 448 int size; /* Signal size in bits */ 449 bcm_error_t status; /* Signal get return status */ 450 } bcm_instru_vis_signal_result_t; 451 452 /* Result of signal fetching */ 453 typedef struct bcm_instru_vis_signal_key_s { 454 char signal[BCM_INSTRU_VIS_SIGNAL_NAME_MAX_SIZE]; /* Signal name */ 455 char from[BCM_INSTRU_VIS_STAGE_NAME_MAX_SIZE]; /* From stage name */ 456 char to[BCM_INSTRU_VIS_STAGE_NAME_MAX_SIZE]; /* To stage name */ 457 char block[BCM_INSTRU_VIS_BLOCK_NAME_MAX_SIZE]; /* Block name */ 458 } bcm_instru_vis_signal_key_t; 459 460 #ifndef BCM_HIDE_DISPATCHABLE 461 462 /* Clean signal cache and allow signals for new packet to be recorded */ 463 extern int bcm_instru_vis_signal_get( 464 int unit, 465 bcm_core_t core_id, 466 uint32 flags, 467 int nof_signals, 468 bcm_instru_vis_signal_key_t *signal_key, 469 bcm_instru_vis_signal_result_t *signal_result); 470 471 #endif /* BCM_HIDE_DISPATCHABLE */ 472 473 /* IFA encap flags. */ 474 #define BCM_INSTRU_IFA_ENCAP_WITH_ID 0x00000001 /* Create IFA entity with 475 specific encap_id. */ 476 #define BCM_INSTRU_IFA_ENCAP_REPLACE 0x00000002 /* Replace existing IFA 477 entity. */ 478 479 /* IFA info */ 480 typedef struct bcm_instru_ifa_info_s { 481 uint32 flags; /* See BCM_INSTRU_IFA_ENCAP_XXX flags 482 definitions. */ 483 int ifa_encap_id; /* Global lif */ 484 int stat_cmd; /* Counter ID associated with the the ifa 485 session for sequence number */ 486 uint8 counter_command_id; /* Counter interface associated with the ifa 487 session. */ 488 } bcm_instru_ifa_info_t; 489 490 /* callback function prototype */ 491 typedef int (*bcm_instru_ifa_encap_traverse_cb)( 492 int unit, 493 bcm_instru_ifa_info_t *ifa_encap_info, 494 void *user_data); 495 496 #ifndef BCM_HIDE_DISPATCHABLE 497 498 /* Fills the IFA types. */ 499 extern int bcm_instru_ifa_encap_create( 500 int unit, 501 bcm_instru_ifa_info_t *ifa_info); 502 503 /* Get IFA entry. */ 504 extern int bcm_instru_ifa_encap_get( 505 int unit, 506 bcm_instru_ifa_info_t *ifa_info); 507 508 /* Delete IFA entry. */ 509 extern int bcm_instru_ifa_encap_delete( 510 int unit, 511 bcm_instru_ifa_info_t *ifa_info); 512 513 /* Traverse IFA entries. */ 514 extern int bcm_instru_ifa_encap_traverse( 515 int unit, 516 bcm_instru_ifa_encap_traverse_cb cb, 517 void *user_data); 518 519 #endif /* BCM_HIDE_DISPATCHABLE */ 520 521 /* sFlow encap extended destination info */ 522 typedef struct bcm_instru_sflow_encap_extended_dst_info_s { 523 uint32 flags; /* See BCM_INSTRU_SFLOW_ENCAP_xxx flag 524 definitions. */ 525 int sflow_encap_extended_dst_id; /* Global lif */ 526 uint32 dst_as_path[BCM_INSTRU_SFLOW_ENCAP_EXTENDED_NOF_DSTS]; /* Autonomous System path to the 527 destination */ 528 int dst_as_path_length; /* Autonomous System path list length */ 529 bcm_ip_t next_hop_ipv4_address; /* Next Hop IPv4 Address. */ 530 bcm_ip6_t next_hop_ipv6_address; /* Next Hop IPv6 Address. */ 531 } bcm_instru_sflow_encap_extended_dst_info_t; 532 533 /* Autonomous System Destination callback function prototype */ 534 typedef int (*bcm_instru_sflow_encap_extended_dst_cb)( 535 int unit, 536 bcm_instru_sflow_encap_extended_dst_info_t *sflow_encap_ext_dst_info, 537 void *user_data); 538 539 #ifndef BCM_HIDE_DISPATCHABLE 540 541 /* 542 * Create Autonomous System Destination information for SFLOW Extended 543 * Gateway Data Record. 544 */ 545 extern int bcm_instru_sflow_encap_extended_dst_create( 546 int unit, 547 bcm_instru_sflow_encap_extended_dst_info_t *sflow_encap_ext_dst_info); 548 549 /* 550 * Get the Autonomous System Destination information for SFLOW Extended 551 * Gateway Data Record. 552 */ 553 extern int bcm_instru_sflow_encap_extended_dst_get( 554 int unit, 555 bcm_instru_sflow_encap_extended_dst_info_t *sflow_encap_ext_dst_info); 556 557 /* 558 * Delete Autonomous System Destination information for SFLOW Extended 559 * Gateway Data Record. 560 */ 561 extern int bcm_instru_sflow_encap_extended_dst_delete( 562 int unit, 563 bcm_instru_sflow_encap_extended_dst_info_t *sflow_encap_ext_dst_info); 564 565 /* 566 * Traverse Autonomous System Destination information for SFLOW Extended 567 * Gateway Data Record. 568 */ 569 extern int bcm_instru_sflow_encap_extended_dst_traverse( 570 int unit, 571 bcm_instru_sflow_encap_extended_dst_cb cb, 572 void *user_data); 573 574 #endif /* BCM_HIDE_DISPATCHABLE */ 575 576 /* sFlow encap extended source info */ 577 typedef struct bcm_instru_sflow_encap_extended_src_info_s { 578 uint32 flags; /* See BCM_INSTRU_SFLOW_ENCAP_xxx flag 579 definitions. */ 580 int sflow_encap_extended_src_id; /* Global lif */ 581 uint32 src_as; /* Autonomous system number of source */ 582 uint32 src_as_peer; /* Autonomous system number of source 583 peer */ 584 } bcm_instru_sflow_encap_extended_src_info_t; 585 586 /* Autonomous System Source callback function prototype */ 587 typedef int (*bcm_instru_sflow_encap_extended_src_cb)( 588 int unit, 589 bcm_instru_sflow_encap_extended_src_info_t *sflow_encap_ext_src_info, 590 void *user_data); 591 592 #ifndef BCM_HIDE_DISPATCHABLE 593 594 /* 595 * Create Autonomous System Source information for SFLOW Extended Gateway 596 * Data Record. 597 */ 598 extern int bcm_instru_sflow_encap_extended_src_create( 599 int unit, 600 bcm_instru_sflow_encap_extended_src_info_t *sflow_encap_ext_src_info); 601 602 /* 603 * Get the Autonomous System Source information for SFLOW Extended 604 * Gateway Data Record. 605 */ 606 extern int bcm_instru_sflow_encap_extended_src_get( 607 int unit, 608 bcm_instru_sflow_encap_extended_src_info_t *sflow_encap_ext_src_info); 609 610 /* 611 * Delete Autonomous System Source data base for SFLOW Extended Gateway 612 * Data Record. 613 */ 614 extern int bcm_instru_sflow_encap_extended_src_delete( 615 int unit, 616 bcm_instru_sflow_encap_extended_src_info_t *sflow_encap_ext_src_info); 617 618 /* 619 * Traverse Autonomous System Source information for SFLOW Extended 620 * Gateway Data Record. 621 */ 622 extern int bcm_instru_sflow_encap_extended_src_traverse( 623 int unit, 624 bcm_instru_sflow_encap_extended_src_cb cb, 625 void *user_data); 626 627 #endif /* BCM_HIDE_DISPATCHABLE */ 628 629 /* Instrumentation synced counters type of ingress cgm */ 630 typedef enum bcm_instru_synced_counters_icgm_type_e { 631 bcmInstruSyncedCountersIcgmTypeInvalid = 0, 632 bcmInstruSyncedCountersIcgmTypeMinFreeOcbBuffers = 1, 633 bcmInstruSyncedCountersIcgmTypeMinFreeOcbPDBs = 2, 634 bcmInstruSyncedCountersIcgmTypeMinFreeDramBDBs = 3, 635 bcmInstruSyncedCountersIcgmTypeMinFreeVoqSharedBytes = 4, 636 bcmInstruSyncedCountersIcgmTypeMinFreeVoqOcbSharedBuffers = 5, 637 bcmInstruSyncedCountersIcgmTypeMinFreeVoqOcbSharedPDs = 6, 638 bcmInstruSyncedCountersIcgmTypeMinFreeVsqHeadroomBytes = 7, 639 bcmInstruSyncedCountersIcgmTypeMinFreeVsqSharedPoolIndexBytes = 8, 640 bcmInstruSyncedCountersIcgmTypeMinFreeVsqOcbHeadroomBuffers = 9, 641 bcmInstruSyncedCountersIcgmTypeMinFreeVsqOcbSharedPoolIndexBuffers = 10, 642 bcmInstruSyncedCountersIcgmTypeMinFreeVsqOcbHeadroomPDBs = 11, 643 bcmInstruSyncedCountersIcgmTypeMinFreeVsqOcbSharedPoolIndexPDBs = 12, 644 bcmInstruSyncedCountersIcgmTypeEnqueuePackets = 13, 645 bcmInstruSyncedCountersIcgmTypeEnqueueBytes = 14, 646 bcmInstruSyncedCountersIcgmTypeRejectPackets = 15, 647 bcmInstruSyncedCountersIcgmTypeRejectBytes = 16, 648 bcmInstruSyncedCountersIcgmTypeDequeuePackets = 17, 649 bcmInstruSyncedCountersIcgmTypeDequeueBytes = 18 650 } bcm_instru_synced_counters_icgm_type_t; 651 652 /* Instrumentation synced counters type of nif */ 653 typedef enum bcm_instru_synced_counters_nif_type_e { 654 bcmInstruSyncedCountersNifTypeInvalid = 1000, 655 bcmInstruSyncedCountersNifTypeReceivedPackets = 1001, 656 bcmInstruSyncedCountersNifTypeReceivedBytes = 1002, 657 bcmInstruSyncedCountersNifTypeDroppedTdmPackets = 1003, 658 bcmInstruSyncedCountersNifTypeDroppedTdmBytes = 1004, 659 bcmInstruSyncedCountersNifTypeDroppedPriorityIndexPackets = 1005, 660 bcmInstruSyncedCountersNifTypeDroppedPriorityIndexBytes = 1006, 661 bcmInstruSyncedCountersNifTypePfcIndexNofOnTransitions = 1007, 662 bcmInstruSyncedCountersNifTypePfcIndexMaxClocksDuration = 1008, 663 bcmInstruSyncedCountersNifTypePfcIndexOnClockCyclesDuration = 1009 664 } bcm_instru_synced_counters_nif_type_t; 665 666 /* Defines the types of periods for synchronized counters mechanism */ 667 typedef enum bcm_instru_synced_counters_source_type_e { 668 bcmInstruSyncedCountersTypeIcgm = 0, 669 bcmInstruSyncedCountersTypeNif = 1, 670 bcmInstruSyncedCountersTypeCrps = 2, 671 bcmInstruSyncedCountersTypeCount = 3 672 } bcm_instru_synced_counters_source_type_t; 673 674 #define BCM_INSTRU_SYNCED_COUNTERS_RECORDS_MAX 16 /* Max instrumentation 675 synced counters 676 records in one API 677 call */ 678 679 #define BCM_INSTRU_SYNCED_COUNTERS_ICGM_STATS_NOF 21 /* Total number of synced 680 icgm 681 counters/statistics 682 available */ 683 #define BCM_INSTRU_SYNCED_COUNTERS_NIF_STATS_NOF 36 /* total number of synced 684 nif 685 counters/statistics 686 available */ 687 688 #define BCM_INSTRU_SYNCED_COUNTERS_STATS_MAX BCM_INSTRU_SYNCED_COUNTERS_NIF_STATS_NOF /* total number of synced 689 counters/statistics 690 available (max of icgm 691 and nif counters). 692 Should be max of 693 BCM_INSTRU_SYNCED_COUNTERS_* */ 694 695 /* 696 * Sync counter record, which gathers the counter values and time of day 697 * that the counters was taken. Value array is organized according to the 698 * 'stat format' (in the config API). 699 */ 700 typedef struct bcm_instru_synced_counters_record_s { 701 uint64 estimated_time_of_day; /* Returned IEEE1588 TOD. */ 702 uint64 value_arr[BCM_INSTRU_SYNCED_COUNTERS_STATS_MAX]; /* Ordered according to the stat format 703 in the config API. */ 704 } bcm_instru_synced_counters_record_t; 705 706 /* Configuration structure for synchronized counters mechanism */ 707 typedef struct bcm_instru_synced_counters_config_s { 708 int enable; /* if disable, all others params not relevant. */ 709 uint64 start_time; /* -1 immediate, or TOD format */ 710 uint64 period; /* nanoseconds */ 711 int is_eventor_collection; /* For eventor collection nof_interval=1, 712 otherwise, nof_interval=max (in HW) */ 713 int is_continuous; /* if FALSE, HW count one round of interval, if 714 TRUE, HW count in cyclic mode forever */ 715 } bcm_instru_synced_counters_config_t; 716 717 #ifndef BCM_HIDE_DISPATCHABLE 718 719 /* 720 * API to get synchronized instrumentation counters configuration per 721 * type 722 */ 723 extern int bcm_instru_synced_counters_config_get( 724 int unit, 725 uint32 flags, 726 bcm_instru_synced_counters_source_type_t source_type, 727 bcm_instru_synced_counters_config_t *config); 728 729 /* 730 * API configure and enable/disable synchronized instrumentation counters 731 * per type 732 */ 733 extern int bcm_instru_synced_counters_config_set( 734 int unit, 735 uint32 flags, 736 bcm_instru_synced_counters_source_type_t source_type, 737 bcm_instru_synced_counters_config_t *config); 738 739 #endif /* BCM_HIDE_DISPATCHABLE */ 740 741 /* 742 * Structure with the information regarding the each counter, what it 743 * represents. 744 */ 745 typedef struct bcm_instru_synced_counters_type_s { 746 int counter_type; /* The counter type represented as the relevant ENUM 747 (bcm_instru_synced_counters_icgm_type_t or 748 bcm_instru_synced_counters_nif_type_t) */ 749 int counter_index; /* The index of the counter type, for counter types that 750 use indices. Relevant only for types index in their 751 name. */ 752 } bcm_instru_synced_counters_type_t; 753 754 /* In/out structure, which gather the data reported of synced counters. */ 755 typedef struct bcm_instru_synced_counters_data_s { 756 int nof_records; /* Nof elements in record_arr. */ 757 bcm_instru_synced_counters_record_t record_arr[BCM_INSTRU_SYNCED_COUNTERS_RECORDS_MAX]; /* Each record represents the statistics 758 of one interval */ 759 int nof_counters; /* Nof elements in 760 record_arr_counters_type. */ 761 bcm_instru_synced_counters_type_t record_arr_counters_type[BCM_INSTRU_SYNCED_COUNTERS_STATS_MAX]; /* The list of counters in each record. */ 762 } bcm_instru_synced_counters_data_t; 763 764 /* Information about the synced counters required. */ 765 typedef struct bcm_instru_synced_counters_records_key_s { 766 bcm_core_t core_id; /* The core from which we read the 767 counters. */ 768 bcm_instru_synced_counters_source_type_t source_type; /* Source type of synchronized counters 769 mechanism. */ 770 bcm_gport_t gport; /* Encodes the logical port, if relevant 771 for the source type. */ 772 } bcm_instru_synced_counters_records_key_t; 773 774 #ifndef BCM_HIDE_DISPATCHABLE 775 776 /* Get the counter values of sync counters mechanism. */ 777 extern int bcm_instru_synced_counters_records_get( 778 int unit, 779 uint32 flags, 780 bcm_instru_synced_counters_records_key_t *key, 781 bcm_instru_synced_counters_data_t *data); 782 783 #endif /* BCM_HIDE_DISPATCHABLE */ 784 785 /* Initialize bcm_instru_synced_counters_config_t struct. */ 786 extern void bcm_instru_synced_counters_config_t_init( 787 bcm_instru_synced_counters_config_t *config); 788 789 /* Initialize bcm_instru_synced_counters_records_key_t struct. */ 790 extern void bcm_instru_synced_counters_records_key_t_init( 791 bcm_instru_synced_counters_records_key_t *key); 792 793 /* Initialize bcm_instru_synced_counters_data_t struct. */ 794 extern void bcm_instru_synced_counters_data_t_init( 795 bcm_instru_synced_counters_data_t *data); 796 797 #ifndef BCM_HIDE_DISPATCHABLE 798 799 /* Add mapping of physical port to Sample Interface. */ 800 extern int bcm_instru_sflow_sample_interface_add( 801 int unit, 802 bcm_instru_sflow_sample_interface_info_t *sample_interface_info); 803 804 /* Remove mapping of physical port to Sample Interface. */ 805 extern int bcm_instru_sflow_sample_interface_remove( 806 int unit, 807 bcm_instru_sflow_sample_interface_info_t *sample_interface_info); 808 809 /* Get mapping of physical port to Sample Interface. */ 810 extern int bcm_instru_sflow_sample_interface_get( 811 int unit, 812 bcm_instru_sflow_sample_interface_info_t *sample_interface_info); 813 814 /* Traverse on the mapping of physical port to Sample Interface */ 815 extern int bcm_instru_sflow_sample_interface_traverse( 816 int unit, 817 bcm_instru_sflow_sample_interface_traverse_info_t *sample_interface_traverse_info, 818 bcm_instru_sflow_sample_traverse_cb cb, 819 void *user_data); 820 821 /* Enable or disable the specific synchronized triggers. */ 822 extern int bcm_instru_synced_counters_trigger_enable_set( 823 int unit, 824 uint32 flags, 825 uint32 nof_sources, 826 bcm_instru_synced_counters_source_type_t *sources, 827 uint32 *enable); 828 829 /* Get the specific synchronized triggers. */ 830 extern int bcm_instru_synced_counters_trigger_enable_get( 831 int unit, 832 uint32 flags, 833 uint32 nof_sources, 834 bcm_instru_synced_counters_source_type_t *sources, 835 uint32 *enable); 836 837 /* Set the configuration of the given Event ID. */ 838 extern int bcm_instru_eventor_event_id_config_set( 839 int unit, 840 uint32 flags, 841 bcm_eventor_event_id_t event_id, 842 bcm_instru_eventor_event_id_config_t *config); 843 844 /* Get the configuration of the given Event ID. */ 845 extern int bcm_instru_eventor_event_id_config_get( 846 int unit, 847 uint32 flags, 848 bcm_eventor_event_id_t event_id, 849 bcm_instru_eventor_event_id_config_t *config); 850 851 /* Generate a single eventor event */ 852 extern int bcm_instru_eventor_event_generate( 853 int unit, 854 uint32 flags, 855 bcm_eventor_event_id_t event_id); 856 857 #endif /* BCM_HIDE_DISPATCHABLE */ 858 859 #endif /* __BCM_INSTRU_H__ */